/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/mathjslab@1.9.1/lib/mathjslab.web.esm2022.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var __webpack_modules__={168(e,t,r){r.d(t,{Dj:()=>cr,JG:()=>rr,M8:()=>Yt,MG:()=>Zt,Pg:()=>or,X2:()=>ir,ay:()=>nr,eP:()=>tr,fr:()=>$t,iH:()=>Wt,iX:()=>ar,jB:()=>Xt,ou:()=>ur,pG:()=>er,re:()=>sr,tD:()=>lr});var n={763:()=>{}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};a.d(s,{MG:()=>X,fr:()=>Pe,sR:()=>bt,Zo:()=>Nt,iH:()=>Rt,rt:()=>Fe,jB:()=>kt,M8:()=>mt,$t:()=>Mt,aq:()=>Et,pG:()=>Oe,eP:()=>yt,KU:()=>_t,zW:()=>wt,IX:()=>L,mY:()=>T,a7:()=>W,JG:()=>ze,ay:()=>Ye,X2:()=>it,WU:()=>xt,Uw:()=>Ct,gw:()=>ft,iX:()=>Bt,re:()=>st,Pg:()=>qt,tD:()=>ot,R$:()=>nt,Dj:()=>Be,m7:()=>z,NZ:()=>F,xo:()=>k,ou:()=>o,qC:()=>Jt,mD:()=>x,Ay:()=>Qt});class o{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(e){this._text=e}}function l(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!(e[r]===t[r]||e[r].equals&&e[r].equals(t[r])))return!1;return!0}o.INVALID_TYPE=0,o.EPSILON=-2,o.MIN_USER_TOKEN_TYPE=1,o.EOF=-1,o.DEFAULT_CHANNEL=0,o.HIDDEN_CHANNEL=1;const c=Math.round(Math.random()*Math.pow(2,32));function u(e){if(!e)return 0;const t=typeof e,r="string"===t?e:!("object"!==t||!e.toString)&&e.toString();if(!r)return 0;let n,i;const a=3&r.length,s=r.length-a;let o=c;const l=3432918353,u=461845907;let m=0;for(;m<s;)i=255&r.charCodeAt(m)|(255&r.charCodeAt(++m))<<8|(255&r.charCodeAt(++m))<<16|(255&r.charCodeAt(++m))<<24,++m,i=(65535&i)*l+(((i>>>16)*l&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,o^=i,o=o<<13|o>>>19,n=5*(65535&o)+((5*(o>>>16)&65535)<<16)&4294967295,o=27492+(65535&n)+((58964+(n>>>16)&65535)<<16);switch(i=0,a){case 3:i^=(255&r.charCodeAt(m+2))<<16;case 2:i^=(255&r.charCodeAt(m+1))<<8;case 1:i^=255&r.charCodeAt(m),i=(65535&i)*l+(((i>>>16)*l&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,o^=i}return o^=r.length,o^=o>>>16,o=2246822507*(65535&o)+((2246822507*(o>>>16)&65535)<<16)&4294967295,o^=o>>>13,o=3266489909*(65535&o)+((3266489909*(o>>>16)&65535)<<16)&4294967295,o^=o>>>16,o>>>0}class m{constructor(){this.count=0,this.hash=0}update(){for(let e=0;e<arguments.length;e++){const t=arguments[e];if(null!=t)if(Array.isArray(t))this.update.apply(this,t);else{let e=0;switch(typeof t){case"undefined":case"function":continue;case"number":case"boolean":e=t;break;case"string":e=u(t);break;default:t.updateHashCode?t.updateHashCode(this):console.log("No updateHashCode for "+t.toString());continue}e*=3432918353,e=e<<15|e>>>17,e*=461845907,this.count=this.count+1;let r=this.hash^e;r=r<<13|r>>>19,r=5*r+3864292196,this.hash=r}}}finish(){let e=this.hash^4*this.count;return e^=e>>>16,e*=2246822507,e^=e>>>13,e*=3266489909,e^=e>>>16,e}static hashStuff(){const e=new m;return e.update.apply(e,arguments),e.finish()}}function h(e){return e?"string"==typeof e?u(e):e.hashCode():-1}function p(e,t){return e&&e.equals?e.equals(t):e===t}function d(e){return null===e?"null":e}function x(e){return Array.isArray(e)?"["+e.map(d).join(", ")+"]":"null"}class C{constructor(e,t){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=e||h,this.equalsFunction=t||p}get(e){if(null==e)return e;const t=this._getBucket(e);if(!t)return null;for(const r of t)if(this.equalsFunction(r,e))return r;return null}add(e){return this.getOrAdd(e)===e}getOrAdd(e){this._expand();const t=this._getSlot(e);let r=this.buckets[t];if(!r)return r=[e],this.buckets[t]=r,this.itemCount++,e;for(const t of r)if(this.equalsFunction(t,e))return t;return r.push(e),this.itemCount++,e}has(e){return null!=this.get(e)}values(){return this.buckets.filter(e=>null!=e).flat(1)}toString(){return x(this.values())}get length(){return this.itemCount}_getSlot(e){return this.hashFunction(e)&this.buckets.length-1}_getBucket(e){return this.buckets[this._getSlot(e)]}_expand(){if(this.itemCount<=this.threshold)return;const e=this.buckets,t=2*this.buckets.length;this.buckets=new Array(t),this.threshold=Math.floor(.75*t);for(const t of e)if(t)for(const e of t){const t=this._getSlot(e);let r=this.buckets[t];r||(r=[],this.buckets[t]=r),r.push(e)}}}class f{hashCode(){const e=new m;return this.updateHashCode(e),e.finish()}evaluate(e,t){}evalPrecedence(e,t){return this}static andContext(e,t){if(null===e||e===f.NONE)return t;if(null===t||t===f.NONE)return e;const r=new g(e,t);return 1===r.opnds.length?r.opnds[0]:r}static orContext(e,t){if(null===e)return t;if(null===t)return e;if(e===f.NONE||t===f.NONE)return f.NONE;const r=new _(e,t);return 1===r.opnds.length?r.opnds[0]:r}}class g extends f{constructor(e,t){super();const r=new C;e instanceof g?e.opnds.map(function(e){r.add(e)}):r.add(e),t instanceof g?t.opnds.map(function(e){r.add(e)}):r.add(t);const n=y(r);if(n.length>0){let e=null;n.map(function(t){(null===e||t.precedence<e.precedence)&&(e=t)}),r.add(e)}this.opnds=Array.from(r.values())}equals(e){return this===e||e instanceof g&&l(this.opnds,e.opnds)}updateHashCode(e){e.update(this.opnds,"AND")}evaluate(e,t){for(let r=0;r<this.opnds.length;r++)if(!this.opnds[r].evaluate(e,t))return!1;return!0}evalPrecedence(e,t){let r=!1;const n=[];for(let i=0;i<this.opnds.length;i++){const a=this.opnds[i],s=a.evalPrecedence(e,t);if(r|=s!==a,null===s)return null;s!==f.NONE&&n.push(s)}if(!r)return this;if(0===n.length)return f.NONE;let i=null;return n.map(function(e){i=null===i?e:f.andContext(i,e)}),i}toString(){const e=this.opnds.map(e=>e.toString());return(e.length>3?e.slice(3):e).join("&&")}}class _ extends f{constructor(e,t){super();const r=new C;e instanceof _?e.opnds.map(function(e){r.add(e)}):r.add(e),t instanceof _?t.opnds.map(function(e){r.add(e)}):r.add(t);const n=y(r);if(n.length>0){const e=n.sort(function(e,t){return e.compareTo(t)}),t=e[e.length-1];r.add(t)}this.opnds=Array.from(r.values())}equals(e){return this===e||e instanceof _&&l(this.opnds,e.opnds)}updateHashCode(e){e.update(this.opnds,"OR")}evaluate(e,t){for(let r=0;r<this.opnds.length;r++)if(this.opnds[r].evaluate(e,t))return!0;return!1}evalPrecedence(e,t){let r=!1;const n=[];for(let i=0;i<this.opnds.length;i++){const a=this.opnds[i],s=a.evalPrecedence(e,t);if(r|=s!==a,s===f.NONE)return f.NONE;null!==s&&n.push(s)}return r?(0===n.length||n.map(function(e){return e}),null):this}toString(){const e=this.opnds.map(e=>e.toString());return(e.length>3?e.slice(3):e).join("||")}}function y(e){const t=[];return e.values().map(function(e){e instanceof f.PrecedencePredicate&&t.push(e)}),t}function A(e,t){if(null===e){const e={state:null,alt:null,context:null,semanticContext:null};return t&&(e.reachesIntoOuterContext=0),e}{const r={};return r.state=e.state||null,r.alt=void 0===e.alt?null:e.alt,r.context=e.context||null,r.semanticContext=e.semanticContext||null,t&&(r.reachesIntoOuterContext=e.reachesIntoOuterContext||0,r.precedenceFilterSuppressed=e.precedenceFilterSuppressed||!1),r}}class E{constructor(e,t){this.checkContext(e,t),e=A(e),t=A(t,!0),this.state=null!==e.state?e.state:t.state,this.alt=null!==e.alt?e.alt:t.alt,this.context=null!==e.context?e.context:t.context,this.semanticContext=null!==e.semanticContext?e.semanticContext:null!==t.semanticContext?t.semanticContext:f.NONE,this.reachesIntoOuterContext=t.reachesIntoOuterContext,this.precedenceFilterSuppressed=t.precedenceFilterSuppressed}checkContext(e,t){null!==e.context&&void 0!==e.context||null!==t&&null!==t.context&&void 0!==t.context||(this.context=null)}hashCode(){const e=new m;return this.updateHashCode(e),e.finish()}updateHashCode(e){e.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(e){return this===e||e instanceof E&&this.state.stateNumber===e.state.stateNumber&&this.alt===e.alt&&(null===this.context?null===e.context:this.context.equals(e.context))&&this.semanticContext.equals(e.semanticContext)&&this.precedenceFilterSuppressed===e.precedenceFilterSuppressed}hashCodeForConfigSet(){const e=new m;return e.update(this.state.stateNumber,this.alt,this.semanticContext),e.finish()}equalsForConfigSet(e){return this===e||e instanceof E&&this.state.stateNumber===e.state.stateNumber&&this.alt===e.alt&&this.semanticContext.equals(e.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==f.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class L{constructor(e,t){this.start=e,this.stop=t}clone(){return new L(this.start,this.stop)}contains(e){return e>=this.start&&e<this.stop}toString(){return this.start===this.stop-1?this.start.toString():this.start.toString()+".."+(this.stop-1).toString()}get length(){return this.stop-this.start}}L.INVALID_INTERVAL=new L(-1,-2);class T{constructor(){this.intervals=null,this.readOnly=!1}first(e){return null===this.intervals||0===this.intervals.length?o.INVALID_TYPE:this.intervals[0].start}addOne(e){this.addInterval(new L(e,e+1))}addRange(e,t){this.addInterval(new L(e,t+1))}addInterval(e){if(null===this.intervals)this.intervals=[],this.intervals.push(e.clone());else{for(let t=0;t<this.intervals.length;t++){const r=this.intervals[t];if(e.stop<r.start)return void this.intervals.splice(t,0,e);if(e.stop===r.start)return void(this.intervals[t]=new L(e.start,r.stop));if(e.start<=r.stop)return this.intervals[t]=new L(Math.min(r.start,e.start),Math.max(r.stop,e.stop)),void this.reduce(t)}this.intervals.push(e.clone())}}addSet(e){return null!==e.intervals&&e.intervals.forEach(e=>this.addInterval(e),this),this}reduce(e){if(e<this.intervals.length-1){const t=this.intervals[e],r=this.intervals[e+1];t.stop>=r.stop?(this.intervals.splice(e+1,1),this.reduce(e)):t.stop>=r.start&&(this.intervals[e]=new L(t.start,r.stop),this.intervals.splice(e+1,1))}}complement(e,t){const r=new T;return r.addInterval(new L(e,t+1)),null!==this.intervals&&this.intervals.forEach(e=>r.removeRange(e)),r}contains(e){if(null===this.intervals)return!1;for(let t=0;t<this.intervals.length;t++)if(this.intervals[t].contains(e))return!0;return!1}removeRange(e){if(e.start===e.stop-1)this.removeOne(e.start);else if(null!==this.intervals){let t=0;for(let r=0;r<this.intervals.length;r++){const r=this.intervals[t];if(e.stop<=r.start)return;if(e.start>r.start&&e.stop<r.stop){this.intervals[t]=new L(r.start,e.start);const n=new L(e.stop,r.stop);return void this.intervals.splice(t,0,n)}e.start<=r.start&&e.stop>=r.stop?(this.intervals.splice(t,1),t-=1):e.start<r.stop?this.intervals[t]=new L(r.start,e.start):e.stop<r.stop&&(this.intervals[t]=new L(e.stop,r.stop)),t+=1}}}removeOne(e){if(null!==this.intervals)for(let t=0;t<this.intervals.length;t++){const r=this.intervals[t];if(e<r.start)return;if(e===r.start&&e===r.stop-1)return void this.intervals.splice(t,1);if(e===r.start)return void(this.intervals[t]=new L(r.start+1,r.stop));if(e===r.stop-1)return void(this.intervals[t]=new L(r.start,r.stop-1));if(e<r.stop-1){const n=new L(r.start,e);return r.start=e+1,void this.intervals.splice(t,0,n)}}}toString(e,t,r){return e=e||null,t=t||null,r=r||!1,null===this.intervals?"{}":null!==e||null!==t?this.toTokenString(e,t):r?this.toCharString():this.toIndexString()}toCharString(){const e=[];for(let t=0;t<this.intervals.length;t++){const r=this.intervals[t];r.stop===r.start+1?r.start===o.EOF?e.push("<EOF>"):e.push("'"+String.fromCharCode(r.start)+"'"):e.push("'"+String.fromCharCode(r.start)+"'..'"+String.fromCharCode(r.stop-1)+"'")}return e.length>1?"{"+e.join(", ")+"}":e[0]}toIndexString(){const e=[];for(let t=0;t<this.intervals.length;t++){const r=this.intervals[t];r.stop===r.start+1?r.start===o.EOF?e.push("<EOF>"):e.push(r.start.toString()):e.push(r.start.toString()+".."+(r.stop-1).toString())}return e.length>1?"{"+e.join(", ")+"}":e[0]}toTokenString(e,t){const r=[];for(let n=0;n<this.intervals.length;n++){const i=this.intervals[n];for(let n=i.start;n<i.stop;n++)r.push(this.elementName(e,t,n))}return r.length>1?"{"+r.join(", ")+"}":r[0]}elementName(e,t,r){return r===o.EOF?"<EOF>":r===o.EPSILON?"<EPSILON>":e[r]||t[r]}get length(){return this.intervals.map(e=>e.length).reduce((e,t)=>e+t)}}class M{constructor(){this.atn=null,this.stateNumber=M.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(e){return e instanceof M&&this.stateNumber===e.stateNumber}isNonGreedyExitState(){return!1}addTransition(e,t){void 0===t&&(t=-1),0===this.transitions.length?this.epsilonOnlyTransitions=e.isEpsilon:this.epsilonOnlyTransitions!==e.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===t?this.transitions.push(e):this.transitions.splice(t,1,e)}}M.INVALID_TYPE=0,M.BASIC=1,M.RULE_START=2,M.BLOCK_START=3,M.PLUS_BLOCK_START=4,M.STAR_BLOCK_START=5,M.TOKEN_START=6,M.RULE_STOP=7,M.BLOCK_END=8,M.STAR_LOOP_BACK=9,M.STAR_LOOP_ENTRY=10,M.PLUS_LOOP_BACK=11,M.LOOP_END=12,M.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],M.INVALID_STATE_NUMBER=-1;class b extends M{constructor(){return super(),this.stateType=M.RULE_STOP,this}}class S{constructor(e){if(null==e)throw"target cannot be null.";this.target=e,this.isEpsilon=!1,this.label=null}}S.EPSILON=1,S.RANGE=2,S.RULE=3,S.PREDICATE=4,S.ATOM=5,S.ACTION=6,S.SET=7,S.NOT_SET=8,S.WILDCARD=9,S.PRECEDENCE=10,S.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],S.serializationTypes={EpsilonTransition:S.EPSILON,RangeTransition:S.RANGE,RuleTransition:S.RULE,PredicateTransition:S.PREDICATE,AtomTransition:S.ATOM,ActionTransition:S.ACTION,SetTransition:S.SET,NotSetTransition:S.NOT_SET,WildcardTransition:S.WILDCARD,PrecedencePredicateTransition:S.PRECEDENCE};class N extends S{constructor(e,t,r,n){super(e),this.ruleIndex=t,this.precedence=r,this.followState=n,this.serializationType=S.RULE,this.isEpsilon=!0}matches(e,t,r){return!1}}class w extends S{constructor(e,t){super(e),this.serializationType=S.SET,null!=t?this.label=t:(this.label=new T,this.label.addOne(o.INVALID_TYPE))}matches(e,t,r){return this.label.contains(e)}toString(){return this.label.toString()}}class I extends w{constructor(e,t){super(e,t),this.serializationType=S.NOT_SET}matches(e,t,r){return e>=t&&e<=r&&!super.matches(e,t,r)}toString(){return"~"+super.toString()}}class P extends S{constructor(e){super(e),this.serializationType=S.WILDCARD}matches(e,t,r){return e>=t&&e<=r}toString(){return"."}}class O extends S{constructor(e){super(e)}}class R{}class v extends R{}class D extends v{}class F extends D{get ruleContext(){throw new Error("missing interface implementation")}}class k extends D{}class U extends k{}const B={toStringTree:function(e,t,r){t=t||null,null!==(r=r||null)&&(t=r.ruleNames);let n=B.getNodeText(e,t);n=function(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(n);const i=e.getChildCount();if(0===i)return n;let a="("+n+" ";i>0&&(n=B.toStringTree(e.getChild(0),t),a=a.concat(n));for(let r=1;r<i;r++)n=B.toStringTree(e.getChild(r),t),a=a.concat(" "+n);return a=a.concat(")"),a},getNodeText:function(e,t,r){if(t=t||null,null!==(r=r||null)&&(t=r.ruleNames),null!==t){if(e instanceof F){const r=e.ruleContext.getAltNumber();return 0!=r?t[e.ruleIndex]+":"+r:t[e.ruleIndex]}if(e instanceof U)return e.toString();if(e instanceof k&&null!==e.symbol)return e.symbol.text}const n=e.getPayload();return n instanceof o?n.text:e.getPayload().toString()},getChildren:function(e){const t=[];for(let r=0;r<e.getChildCount();r++)t.push(e.getChild(r));return t},getAncestors:function(e){let t=[];for(e=e.getParent();null!==e;)t=[e].concat(t),e=e.getParent();return t},findAllTokenNodes:function(e,t){return B.findAllNodes(e,t,!0)},findAllRuleNodes:function(e,t){return B.findAllNodes(e,t,!1)},findAllNodes:function(e,t,r){const n=[];return B._findAllNodes(e,t,r,n),n},_findAllNodes:function(e,t,r,n){r&&e instanceof k?e.symbol.type===t&&n.push(e):!r&&e instanceof F&&e.ruleIndex===t&&n.push(e);for(let i=0;i<e.getChildCount();i++)B._findAllNodes(e.getChild(i),t,r,n)},descendants:function(e){let t=[e];for(let r=0;r<e.getChildCount();r++)t=t.concat(B.descendants(e.getChild(r)));return t}},K=B;class z extends F{constructor(e,t){super(),this.parentCtx=e||null,this.invokingState=t||-1}depth(){let e=0,t=this;for(;null!==t;)t=t.parentCtx,e+=1;return e}isEmpty(){return-1===this.invokingState}getSourceInterval(){return L.INVALID_INTERVAL}get ruleContext(){return this}getPayload(){return this}getText(){return 0===this.getChildCount()?"":this.children.map(function(e){return e.getText()}).join("")}getAltNumber(){return 0}setAltNumber(e){}getChild(e){return null}getChildCount(){return 0}accept(e){return e.visitChildren(this)}toStringTree(e,t){return K.toStringTree(this,e,t)}toString(e,t){e=e||null,t=t||null;let r=this,n="[";for(;null!==r&&r!==t;){if(null===e)r.isEmpty()||(n+=r.invokingState);else{const t=r.ruleIndex;n+=t>=0&&t<e.length?e[t]:""+t}null===r.parentCtx||null===e&&r.parentCtx.isEmpty()||(n+=" "),r=r.parentCtx}return n+="]",n}}class q{constructor(e){this.cachedHashCode=e}isEmpty(){return this===q.EMPTY}hasEmptyPath(){return this.getReturnState(this.length-1)===q.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}updateHashCode(e){e.update(this.cachedHashCode)}}q.EMPTY=null,q.EMPTY_RETURN_STATE=2147483647,q.globalNodeCount=1,q.id=q.globalNodeCount,q.trace_atn_sim=!1;class J extends q{constructor(e,t){const r=new m;return r.update(e,t),super(r.finish()),this.parents=e,this.returnStates=t,this}isEmpty(){return this.returnStates[0]===q.EMPTY_RETURN_STATE}getParent(e){return this.parents[e]}getReturnState(e){return this.returnStates[e]}equals(e){return this===e||e instanceof J&&this.hashCode()===e.hashCode()&&l(this.returnStates,e.returnStates)&&l(this.parents,e.parents)}toString(){if(this.isEmpty())return"[]";{let e="[";for(let t=0;t<this.returnStates.length;t++)t>0&&(e+=", "),this.returnStates[t]!==q.EMPTY_RETURN_STATE?(e+=this.returnStates[t],null!==this.parents[t]?e=e+" "+this.parents[t]:e+="null"):e+="$";return e+"]"}}get length(){return this.returnStates.length}}class V extends q{constructor(e,t){let r=0;const n=new m;null!==e?n.update(e,t):n.update(1),r=n.finish(),super(r),this.parentCtx=e,this.returnState=t}getParent(e){return this.parentCtx}getReturnState(e){return this.returnState}equals(e){return this===e||e instanceof V&&this.hashCode()===e.hashCode()&&this.returnState===e.returnState&&(null==this.parentCtx?null==e.parentCtx:this.parentCtx.equals(e.parentCtx))}toString(){const e=null===this.parentCtx?"":this.parentCtx.toString();return 0===e.length?this.returnState===q.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+e}get length(){return 1}static create(e,t){return t===q.EMPTY_RETURN_STATE&&null===e?q.EMPTY:new V(e,t)}}class H extends V{constructor(){super(null,q.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(e){return null}getReturnState(e){return this.returnState}equals(e){return this===e}toString(){return"$"}}q.EMPTY=new H;class j{constructor(e,t){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=e||h,this.equalsFunction=t||p}set(e,t){this._expand();const r=this._getSlot(e);let n=this.buckets[r];if(!n)return n=[[e,t]],this.buckets[r]=n,this.itemCount++,t;const i=n.find(t=>this.equalsFunction(t[0],e),this);if(i){const e=i[1];return i[1]=t,e}return n.push([e,t]),this.itemCount++,t}containsKey(e){const t=this._getBucket(e);return!!t&&!!t.find(t=>this.equalsFunction(t[0],e),this)}get(e){const t=this._getBucket(e);if(!t)return null;const r=t.find(t=>this.equalsFunction(t[0],e),this);return r?r[1]:null}entries(){return this.buckets.filter(e=>null!=e).flat(1)}getKeys(){return this.entries().map(e=>e[0])}getValues(){return this.entries().map(e=>e[1])}toString(){return"["+this.entries().map(e=>"{"+e[0]+":"+e[1]+"}").join(", ")+"]"}get length(){return this.itemCount}_getSlot(e){return this.hashFunction(e)&this.buckets.length-1}_getBucket(e){return this.buckets[this._getSlot(e)]}_expand(){if(this.itemCount<=this.threshold)return;const e=this.buckets,t=2*this.buckets.length;this.buckets=new Array(t),this.threshold=Math.floor(.75*t);for(const t of e)if(t)for(const e of t){const t=this._getSlot(e[0]);let r=this.buckets[t];r||(r=[],this.buckets[t]=r),r.push(e)}}}function G(e,t){if(null==t&&(t=z.EMPTY),null===t.parentCtx||t===z.EMPTY)return q.EMPTY;const r=G(e,t.parentCtx),n=e.states[t.invokingState].transitions[0];return V.create(r,n.followState.stateNumber)}function Q(e,t,r){if(e.isEmpty())return e;let n=r.get(e)||null;if(null!==n)return n;if(n=t.get(e),null!==n)return r.set(e,n),n;let i=!1,a=[];for(let n=0;n<a.length;n++){const s=Q(e.getParent(n),t,r);if(i||s!==e.getParent(n)){if(!i){a=[];for(let t=0;t<e.length;t++)a[t]=e.getParent(t);i=!0}a[n]=s}}if(!i)return t.add(e),r.set(e,e),e;let s=null;return s=0===a.length?q.EMPTY:1===a.length?V.create(a[0],e.getReturnState(0)):new J(a,e.returnStates),t.add(s),r.set(s,s),r.set(e,s),s}function Z(e,t,r,n){if(e===t)return e;if(e instanceof V&&t instanceof V)return function(e,t,r,n){if(null!==n){let r=n.get(e,t);if(null!==r)return r;if(r=n.get(t,e),null!==r)return r}const i=function(e,t,r){if(r){if(e===q.EMPTY)return q.EMPTY;if(t===q.EMPTY)return q.EMPTY}else{if(e===q.EMPTY&&t===q.EMPTY)return q.EMPTY;if(e===q.EMPTY){const e=[t.returnState,q.EMPTY_RETURN_STATE],r=[t.parentCtx,null];return new J(r,e)}if(t===q.EMPTY){const t=[e.returnState,q.EMPTY_RETURN_STATE],r=[e.parentCtx,null];return new J(r,t)}}return null}(e,t,r);if(null!==i)return null!==n&&n.set(e,t,i),i;if(e.returnState===t.returnState){const i=Z(e.parentCtx,t.parentCtx,r,n);if(i===e.parentCtx)return e;if(i===t.parentCtx)return t;const a=V.create(i,e.returnState);return null!==n&&n.set(e,t,a),a}{let r=null;if((e===t||null!==e.parentCtx&&e.parentCtx===t.parentCtx)&&(r=e.parentCtx),null!==r){const i=[e.returnState,t.returnState];e.returnState>t.returnState&&(i[0]=t.returnState,i[1]=e.returnState);const a=new J([r,r],i);return null!==n&&n.set(e,t,a),a}const i=[e.returnState,t.returnState];let a=[e.parentCtx,t.parentCtx];e.returnState>t.returnState&&(i[0]=t.returnState,i[1]=e.returnState,a=[t.parentCtx,e.parentCtx]);const s=new J(a,i);return null!==n&&n.set(e,t,s),s}}(e,t,r,n);if(r){if(e instanceof H)return e;if(t instanceof H)return t}return e instanceof V&&(e=new J([e.getParent()],[e.returnState])),t instanceof V&&(t=new J([t.getParent()],[t.returnState])),function(e,t,r,n){if(null!==n){let r=n.get(e,t);if(null!==r)return q.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> previous"),r;if(r=n.get(t,e),null!==r)return q.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> previous"),r}let i=0,a=0,s=0,o=new Array(e.returnStates.length+t.returnStates.length).fill(0),l=new Array(e.returnStates.length+t.returnStates.length).fill(null);for(;i<e.returnStates.length&&a<t.returnStates.length;){const c=e.parents[i],u=t.parents[a];if(e.returnStates[i]===t.returnStates[a]){const t=e.returnStates[i];t===q.EMPTY_RETURN_STATE&&null===c&&null===u||null!==c&&null!==u&&c===u?(l[s]=c,o[s]=t):(l[s]=Z(c,u,r,n),o[s]=t),i+=1,a+=1}else e.returnStates[i]<t.returnStates[a]?(l[s]=c,o[s]=e.returnStates[i],i+=1):(l[s]=u,o[s]=t.returnStates[a],a+=1);s+=1}if(i<e.returnStates.length)for(let t=i;t<e.returnStates.length;t++)l[s]=e.parents[t],o[s]=e.returnStates[t],s+=1;else for(let e=a;e<t.returnStates.length;e++)l[s]=t.parents[e],o[s]=t.returnStates[e],s+=1;if(s<l.length){if(1===s){const r=V.create(l[0],o[0]);return null!==n&&n.set(e,t,r),r}l=l.slice(0,s),o=o.slice(0,s)}const c=new J(l,o);return c.equals(e)?(null!==n&&n.set(e,t,e),q.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> a"),e):c.equals(t)?(null!==n&&n.set(e,t,t),q.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> b"),t):(function(e){const t=new j;for(let r=0;r<e.length;r++){const n=e[r];t.containsKey(n)||t.set(n,n)}for(let r=0;r<e.length;r++)e[r]=t.get(e[r])}(l),null!==n&&n.set(e,t,c),q.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> "+c),c)}(e,t,r,n)}class ${constructor(){this.data=new Uint32Array(1)}set(e){$._checkIndex(e),this._resize(e),this.data[e>>>5]|=1<<e%32}get(e){$._checkIndex(e);const t=e>>>5;return!(t>=this.data.length||!(this.data[t]&1<<e%32))}clear(e){$._checkIndex(e);const t=e>>>5;t<this.data.length&&(this.data[t]&=~(1<<e))}or(e){const t=Math.min(this.data.length,e.data.length);for(let r=0;r<t;++r)this.data[r]|=e.data[r];if(this.data.length<e.data.length){this._resize((e.data.length<<5)-1);const r=e.data.length;for(let n=t;n<r;++n)this.data[n]=e.data[n]}}values(){const e=new Array(this.length);let t=0;const r=this.data.length;for(let n=0;n<r;++n){let r=this.data[n];for(;0!==r;){const i=r&-r;e[t++]=(n<<5)+$._bitCount(i-1),r^=i}}return e}minValue(){for(let e=0;e<this.data.length;++e){let t=this.data[e];if(0!==t){let r=0;for(;!(1&t);)r++,t>>=1;return r+32*e}}return 0}hashCode(){return m.hashStuff(this.values())}equals(e){return e instanceof $&&l(this.data,e.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.data.map(e=>$._bitCount(e)).reduce((e,t)=>e+t,0)}_resize(e){const t=e+32>>>5;if(t<=this.data.length)return;const r=new Uint32Array(t);r.set(this.data),r.fill(0,this.data.length),this.data=r}static _checkIndex(e){if(e<0)throw new RangeError("index cannot be negative")}static _bitCount(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,0+(e+=e>>16)&63}}class W{constructor(e){this.atn=e}getDecisionLookahead(e){if(null===e)return null;const t=e.transitions.length,r=[];for(let n=0;n<t;n++){r[n]=new T;const t=new C,i=!1;this._LOOK(e.transition(n).target,null,q.EMPTY,r[n],t,new $,i,!1),(0===r[n].length||r[n].contains(W.HIT_PRED))&&(r[n]=null)}return r}LOOK(e,t,r){const n=new T,i=null!==(r=r||null)?G(e.atn,r):null;return this._LOOK(e,t,i,n,new C,new $,!0,!0),n}_LOOK(e,t,r,n,i,a,s,l){const c=new E({state:e,alt:0,context:r},null);if(!i.has(c)){if(i.add(c),e===t){if(null===r)return void n.addOne(o.EPSILON);if(r.isEmpty()&&l)return void n.addOne(o.EOF)}if(e instanceof b){if(null===r)return void n.addOne(o.EPSILON);if(r.isEmpty()&&l)return void n.addOne(o.EOF);if(r!==q.EMPTY){const o=a.get(e.ruleIndex);try{a.clear(e.ruleIndex);for(let e=0;e<r.length;e++){const o=this.atn.states[r.getReturnState(e)];this._LOOK(o,t,r.getParent(e),n,i,a,s,l)}}finally{o&&a.set(e.ruleIndex)}return}}for(let c=0;c<e.transitions.length;c++){const u=e.transitions[c];if(u.constructor===N){if(a.get(u.target.ruleIndex))continue;const e=V.create(r,u.followState.stateNumber);try{a.set(u.target.ruleIndex),this._LOOK(u.target,t,e,n,i,a,s,l)}finally{a.clear(u.target.ruleIndex)}}else if(u instanceof O)s?this._LOOK(u.target,t,r,n,i,a,s,l):n.addOne(W.HIT_PRED);else if(u.isEpsilon)this._LOOK(u.target,t,r,n,i,a,s,l);else if(u.constructor===P)n.addRange(o.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);else{let e=u.label;null!==e&&(u instanceof I&&(e=e.complement(o.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),n.addSet(e))}}}}}W.HIT_PRED=o.INVALID_TYPE;class X{constructor(e,t){this.grammarType=e,this.maxTokenType=t,this.states=[],this.decisionToState=[],this.ruleToStartState=[],this.ruleToStopState=null,this.modeNameToStartState={},this.ruleToTokenType=null,this.lexerActions=null,this.modeToStartState=[]}nextTokensInContext(e,t){return new W(this).LOOK(e,null,t)}nextTokensNoContext(e){return null!==e.nextTokenWithinRule||(e.nextTokenWithinRule=this.nextTokensInContext(e,null),e.nextTokenWithinRule.readOnly=!0),e.nextTokenWithinRule}nextTokens(e,t){return void 0===t?this.nextTokensNoContext(e):this.nextTokensInContext(e,t)}addState(e){null!==e&&(e.atn=this,e.stateNumber=this.states.length),this.states.push(e)}removeState(e){this.states[e.stateNumber]=null}defineDecisionState(e){return this.decisionToState.push(e),e.decision=this.decisionToState.length-1,e.decision}getDecisionState(e){return 0===this.decisionToState.length?null:this.decisionToState[e]}getExpectedTokens(e,t){if(e<0||e>=this.states.length)throw"Invalid state number.";const r=this.states[e];let n=this.nextTokens(r);if(!n.contains(o.EPSILON))return n;const i=new T;for(i.addSet(n),i.removeOne(o.EPSILON);null!==t&&t.invokingState>=0&&n.contains(o.EPSILON);){const e=this.states[t.invokingState].transitions[0];n=this.nextTokens(e.followState),i.addSet(n),i.removeOne(o.EPSILON),t=t.parentCtx}return n.contains(o.EPSILON)&&i.addOne(o.EOF),i}}X.INVALID_ALT_NUMBER=0;class Y extends M{constructor(){super(),this.stateType=M.BASIC}}class ee extends M{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class te extends ee{constructor(){return super(),this.endState=null,this}}class re extends M{constructor(){return super(),this.stateType=M.BLOCK_END,this.startState=null,this}}class ne extends M{constructor(){return super(),this.stateType=M.LOOP_END,this.loopBackState=null,this}}class ie extends M{constructor(){return super(),this.stateType=M.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class ae extends ee{constructor(){return super(),this.stateType=M.TOKEN_START,this}}class se extends ee{constructor(){return super(),this.stateType=M.PLUS_LOOP_BACK,this}}class oe extends M{constructor(){return super(),this.stateType=M.STAR_LOOP_BACK,this}}class le extends ee{constructor(){return super(),this.stateType=M.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class ce extends te{constructor(){return super(),this.stateType=M.PLUS_BLOCK_START,this.loopBackState=null,this}}class ue extends te{constructor(){return super(),this.stateType=M.STAR_BLOCK_START,this}}class me extends te{constructor(){return super(),this.stateType=M.BLOCK_START,this}}class he extends S{constructor(e,t){super(e),this.label_=t,this.label=this.makeLabel(),this.serializationType=S.ATOM}makeLabel(){const e=new T;return e.addOne(this.label_),e}matches(e,t,r){return this.label_===e}toString(){return this.label_}}class pe extends S{constructor(e,t,r){super(e),this.serializationType=S.RANGE,this.start=t,this.stop=r,this.label=this.makeLabel()}makeLabel(){const e=new T;return e.addRange(this.start,this.stop),e}matches(e,t,r){return e>=this.start&&e<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class de extends S{constructor(e,t,r,n){super(e),this.serializationType=S.ACTION,this.ruleIndex=t,this.actionIndex=void 0===r?-1:r,this.isCtxDependent=void 0!==n&&n,this.isEpsilon=!0}matches(e,t,r){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class xe extends S{constructor(e,t){super(e),this.serializationType=S.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=t}matches(e,t,r){return!1}toString(){return"epsilon"}}class Ce extends f{constructor(e,t,r){super(),this.ruleIndex=void 0===e?-1:e,this.predIndex=void 0===t?-1:t,this.isCtxDependent=void 0!==r&&r}evaluate(e,t){const r=this.isCtxDependent?t:null;return e.sempred(r,this.ruleIndex,this.predIndex)}updateHashCode(e){e.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(e){return this===e||e instanceof Ce&&this.ruleIndex===e.ruleIndex&&this.predIndex===e.predIndex&&this.isCtxDependent===e.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}f.NONE=new Ce;class fe extends O{constructor(e,t,r,n){super(e),this.serializationType=S.PREDICATE,this.ruleIndex=t,this.predIndex=r,this.isCtxDependent=n,this.isEpsilon=!0}matches(e,t,r){return!1}getPredicate(){return new Ce(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class ge extends f{constructor(e){super(),this.precedence=void 0===e?0:e}evaluate(e,t){return e.precpred(t,this.precedence)}evalPrecedence(e,t){return e.precpred(t,this.precedence)?f.NONE:null}compareTo(e){return this.precedence-e.precedence}updateHashCode(e){e.update(this.precedence)}equals(e){return this===e||e instanceof ge&&this.precedence===e.precedence}toString(){return"{"+this.precedence+">=prec}?"}}f.PrecedencePredicate=ge;class _e extends O{constructor(e,t){super(e),this.serializationType=S.PRECEDENCE,this.precedence=t,this.isEpsilon=!0}matches(e,t,r){return!1}getPredicate(){return new ge(this.precedence)}toString(){return this.precedence+" >= _p"}}class ye{constructor(e){void 0===e&&(e=null),this.readOnly=!1,this.verifyATN=null===e||e.verifyATN,this.generateRuleBypassTransitions=null!==e&&e.generateRuleBypassTransitions}}ye.defaultOptions=new ye,ye.defaultOptions.readOnly=!0;class Ae{constructor(e){this.actionType=e,this.isPositionDependent=!1}hashCode(){const e=new m;return this.updateHashCode(e),e.finish()}updateHashCode(e){e.update(this.actionType)}equals(e){return this===e}}class Ee extends Ae{constructor(){super(6)}execute(e){e.skip()}toString(){return"skip"}}Ee.INSTANCE=new Ee;class Le extends Ae{constructor(e){super(0),this.channel=e}execute(e){e._channel=this.channel}updateHashCode(e){e.update(this.actionType,this.channel)}equals(e){return this===e||e instanceof Le&&this.channel===e.channel}toString(){return"channel("+this.channel+")"}}class Te extends Ae{constructor(e,t){super(1),this.ruleIndex=e,this.actionIndex=t,this.isPositionDependent=!0}execute(e){e.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(e){e.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(e){return this===e||e instanceof Te&&this.ruleIndex===e.ruleIndex&&this.actionIndex===e.actionIndex}}class Me extends Ae{constructor(){super(3)}execute(e){e.more()}toString(){return"more"}}Me.INSTANCE=new Me;class be extends Ae{constructor(e){super(7),this.type=e}execute(e){e.type=this.type}updateHashCode(e){e.update(this.actionType,this.type)}equals(e){return this===e||e instanceof be&&this.type===e.type}toString(){return"type("+this.type+")"}}class Se extends Ae{constructor(e){super(5),this.mode=e}execute(e){e.pushMode(this.mode)}updateHashCode(e){e.update(this.actionType,this.mode)}equals(e){return this===e||e instanceof Se&&this.mode===e.mode}toString(){return"pushMode("+this.mode+")"}}class Ne extends Ae{constructor(){super(4)}execute(e){e.popMode()}toString(){return"popMode"}}Ne.INSTANCE=new Ne;class we extends Ae{constructor(e){super(2),this.mode=e}execute(e){e.setMode(this.mode)}updateHashCode(e){e.update(this.actionType,this.mode)}equals(e){return this===e||e instanceof we&&this.mode===e.mode}toString(){return"mode("+this.mode+")"}}function Ie(e,t){const r=[];return r[e-1]=t,r.map(function(e){return t})}class Pe{constructor(e){null==e&&(e=ye.defaultOptions),this.deserializationOptions=e,this.stateFactories=null,this.actionFactories=null}deserialize(e){const t=this.reset(e);this.checkVersion(t),t&&this.skipUUID();const r=this.readATN();this.readStates(r,t),this.readRules(r,t),this.readModes(r);const n=[];return this.readSets(r,n,this.readInt.bind(this)),t&&this.readSets(r,n,this.readInt32.bind(this)),this.readEdges(r,n),this.readDecisions(r),this.readLexerActions(r,t),this.markPrecedenceDecisions(r),this.verifyATN(r),this.deserializationOptions.generateRuleBypassTransitions&&1===r.grammarType&&(this.generateRuleBypassTransitions(r),this.verifyATN(r)),r}reset(e){if(3===(e.charCodeAt?e.charCodeAt(0):e[0])){const t=function(e){const t=e.charCodeAt(0);return t>1?t-2:t+65534},r=e.split("").map(t);return r[0]=e.charCodeAt(0),this.data=r,this.pos=0,!0}return this.data=e,this.pos=0,!1}skipUUID(){let e=0;for(;e++<8;)this.readInt()}checkVersion(e){const t=this.readInt();if(!e&&4!==t)throw"Could not deserialize ATN with version "+t+" (expected 4)."}readATN(){const e=this.readInt(),t=this.readInt();return new X(e,t)}readStates(e,t){let r,n,i;const a=[],s=[],o=this.readInt();for(let r=0;r<o;r++){const r=this.readInt();if(r===M.INVALID_TYPE){e.addState(null);continue}let n=this.readInt();t&&65535===n&&(n=-1);const i=this.stateFactory(r,n);if(r===M.LOOP_END){const e=this.readInt();a.push([i,e])}else if(i instanceof te){const e=this.readInt();s.push([i,e])}e.addState(i)}for(r=0;r<a.length;r++)n=a[r],n[0].loopBackState=e.states[n[1]];for(r=0;r<s.length;r++)n=s[r],n[0].endState=e.states[n[1]];let l=this.readInt();for(r=0;r<l;r++)i=this.readInt(),e.states[i].nonGreedy=!0;let c=this.readInt();for(r=0;r<c;r++)i=this.readInt(),e.states[i].isPrecedenceRule=!0}readRules(e,t){let r;const n=this.readInt();for(0===e.grammarType&&(e.ruleToTokenType=Ie(n,0)),e.ruleToStartState=Ie(n,0),r=0;r<n;r++){const n=this.readInt();if(e.ruleToStartState[r]=e.states[n],0===e.grammarType){let n=this.readInt();t&&65535===n&&(n=o.EOF),e.ruleToTokenType[r]=n}}for(e.ruleToStopState=Ie(n,0),r=0;r<e.states.length;r++){const t=e.states[r];t instanceof b&&(e.ruleToStopState[t.ruleIndex]=t,e.ruleToStartState[t.ruleIndex].stopState=t)}}readModes(e){const t=this.readInt();for(let r=0;r<t;r++){let t=this.readInt();e.modeToStartState.push(e.states[t])}}readSets(e,t,r){const n=this.readInt();for(let e=0;e<n;e++){const e=new T;t.push(e);const n=this.readInt();0!==this.readInt()&&e.addOne(-1);for(let t=0;t<n;t++){const t=r(),n=r();e.addRange(t,n)}}}readEdges(e,t){let r,n,i,a,s;const o=this.readInt();for(r=0;r<o;r++){const r=this.readInt(),n=this.readInt(),i=this.readInt(),s=this.readInt(),o=this.readInt(),l=this.readInt();a=this.edgeFactory(e,i,r,n,s,o,l,t),e.states[r].addTransition(a)}for(r=0;r<e.states.length;r++)for(i=e.states[r],n=0;n<i.transitions.length;n++){const t=i.transitions[n];if(!(t instanceof N))continue;let r=-1;e.ruleToStartState[t.target.ruleIndex].isPrecedenceRule&&0===t.precedence&&(r=t.target.ruleIndex),a=new xe(t.followState,r),e.ruleToStopState[t.target.ruleIndex].addTransition(a)}for(r=0;r<e.states.length;r++){if(i=e.states[r],i instanceof te){if(null===i.endState)throw"IllegalState";if(null!==i.endState.startState)throw"IllegalState";i.endState.startState=i}if(i instanceof se)for(n=0;n<i.transitions.length;n++)s=i.transitions[n].target,s instanceof ce&&(s.loopBackState=i);else if(i instanceof oe)for(n=0;n<i.transitions.length;n++)s=i.transitions[n].target,s instanceof le&&(s.loopBackState=i)}}readDecisions(e){const t=this.readInt();for(let r=0;r<t;r++){const t=this.readInt(),n=e.states[t];e.decisionToState.push(n),n.decision=r}}readLexerActions(e,t){if(0===e.grammarType){const r=this.readInt();e.lexerActions=Ie(r,null);for(let n=0;n<r;n++){const r=this.readInt();let i=this.readInt();t&&65535===i&&(i=-1);let a=this.readInt();t&&65535===a&&(a=-1),e.lexerActions[n]=this.lexerActionFactory(r,i,a)}}}generateRuleBypassTransitions(e){let t;const r=e.ruleToStartState.length;for(t=0;t<r;t++)e.ruleToTokenType[t]=e.maxTokenType+t+1;for(t=0;t<r;t++)this.generateRuleBypassTransition(e,t)}generateRuleBypassTransition(e,t){let r,n;const i=new me;i.ruleIndex=t,e.addState(i);const a=new re;a.ruleIndex=t,e.addState(a),i.endState=a,e.defineDecisionState(i),a.startState=i;let s=null,o=null;if(e.ruleToStartState[t].isPrecedenceRule){for(o=null,r=0;r<e.states.length;r++)if(n=e.states[r],this.stateIsEndStateFor(n,t)){o=n,s=n.loopBackState.transitions[0];break}if(null===s)throw"Couldn't identify final state of the precedence rule prefix section."}else o=e.ruleToStopState[t];for(r=0;r<e.states.length;r++){n=e.states[r];for(let e=0;e<n.transitions.length;e++){const t=n.transitions[e];t!==s&&t.target===o&&(t.target=a)}}const l=e.ruleToStartState[t],c=l.transitions.length;for(;c>0;)i.addTransition(l.transitions[c-1]),l.transitions=l.transitions.slice(-1);e.ruleToStartState[t].addTransition(new xe(i)),a.addTransition(new xe(o));const u=new Y;e.addState(u),u.addTransition(new he(a,e.ruleToTokenType[t])),i.addTransition(new xe(u))}stateIsEndStateFor(e,t){if(e.ruleIndex!==t)return null;if(!(e instanceof le))return null;const r=e.transitions[e.transitions.length-1].target;return r instanceof ne&&r.epsilonOnlyTransitions&&r.transitions[0].target instanceof b?e:null}markPrecedenceDecisions(e){for(let t=0;t<e.states.length;t++){const r=e.states[t];if(r instanceof le&&e.ruleToStartState[r.ruleIndex].isPrecedenceRule){const e=r.transitions[r.transitions.length-1].target;e instanceof ne&&e.epsilonOnlyTransitions&&e.transitions[0].target instanceof b&&(r.isPrecedenceDecision=!0)}}}verifyATN(e){if(this.deserializationOptions.verifyATN)for(let t=0;t<e.states.length;t++){const r=e.states[t];if(null!==r)if(this.checkCondition(r.epsilonOnlyTransitions||r.transitions.length<=1),r instanceof ce)this.checkCondition(null!==r.loopBackState);else if(r instanceof le)if(this.checkCondition(null!==r.loopBackState),this.checkCondition(2===r.transitions.length),r.transitions[0].target instanceof ue)this.checkCondition(r.transitions[1].target instanceof ne),this.checkCondition(!r.nonGreedy);else{if(!(r.transitions[0].target instanceof ne))throw"IllegalState";this.checkCondition(r.transitions[1].target instanceof ue),this.checkCondition(r.nonGreedy)}else r instanceof oe?(this.checkCondition(1===r.transitions.length),this.checkCondition(r.transitions[0].target instanceof le)):r instanceof ne?this.checkCondition(null!==r.loopBackState):r instanceof ie?this.checkCondition(null!==r.stopState):r instanceof te?this.checkCondition(null!==r.endState):r instanceof re?this.checkCondition(null!==r.startState):r instanceof ee?this.checkCondition(r.transitions.length<=1||r.decision>=0):this.checkCondition(r.transitions.length<=1||r instanceof b)}}checkCondition(e,t){if(!e)throw null==t&&(t="IllegalState"),t}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(e,t,r,n,i,a,s,l){const c=e.states[n];switch(t){case S.EPSILON:return new xe(c);case S.RANGE:return new pe(c,0!==s?o.EOF:i,a);case S.RULE:return new N(e.states[i],a,s,c);case S.PREDICATE:return new fe(c,i,a,0!==s);case S.PRECEDENCE:return new _e(c,i);case S.ATOM:return new he(c,0!==s?o.EOF:i);case S.ACTION:return new de(c,i,a,0!==s);case S.SET:return new w(c,l[i]);case S.NOT_SET:return new I(c,l[i]);case S.WILDCARD:return new P(c);default:throw"The specified transition type: "+t+" is not valid."}}stateFactory(e,t){if(null===this.stateFactories){const e=[];e[M.INVALID_TYPE]=null,e[M.BASIC]=()=>new Y,e[M.RULE_START]=()=>new ie,e[M.BLOCK_START]=()=>new me,e[M.PLUS_BLOCK_START]=()=>new ce,e[M.STAR_BLOCK_START]=()=>new ue,e[M.TOKEN_START]=()=>new ae,e[M.RULE_STOP]=()=>new b,e[M.BLOCK_END]=()=>new re,e[M.STAR_LOOP_BACK]=()=>new oe,e[M.STAR_LOOP_ENTRY]=()=>new le,e[M.PLUS_LOOP_BACK]=()=>new se,e[M.LOOP_END]=()=>new ne,this.stateFactories=e}if(e>this.stateFactories.length||null===this.stateFactories[e])throw"The specified state type "+e+" is not valid.";{const r=this.stateFactories[e]();if(null!==r)return r.ruleIndex=t,r}}lexerActionFactory(e,t,r){if(null===this.actionFactories){const e=[];e[0]=(e,t)=>new Le(e),e[1]=(e,t)=>new Te(e,t),e[2]=(e,t)=>new we(e),e[3]=(e,t)=>Me.INSTANCE,e[4]=(e,t)=>Ne.INSTANCE,e[5]=(e,t)=>new Se(e),e[6]=(e,t)=>Ee.INSTANCE,e[7]=(e,t)=>new be(e),this.actionFactories=e}if(e>this.actionFactories.length||null===this.actionFactories[e])throw"The specified lexer action type "+e+" is not valid.";return this.actionFactories[e](t,r)}}class Oe{syntaxError(e,t,r,n,i,a){}reportAmbiguity(e,t,r,n,i,a,s){}reportAttemptingFullContext(e,t,r,n,i,a){}reportContextSensitivity(e,t,r,n,i,a){}}class Re extends Oe{constructor(){super()}syntaxError(e,t,r,n,i,a){console.error("line "+r+":"+n+" "+i)}}Re.INSTANCE=new Re;class ve extends Oe{constructor(e){if(super(),null===e)throw"delegates";return this.delegates=e,this}syntaxError(e,t,r,n,i,a){this.delegates.map(s=>s.syntaxError(e,t,r,n,i,a))}reportAmbiguity(e,t,r,n,i,a,s){this.delegates.map(o=>o.reportAmbiguity(e,t,r,n,i,a,s))}reportAttemptingFullContext(e,t,r,n,i,a){this.delegates.map(s=>s.reportAttemptingFullContext(e,t,r,n,i,a))}reportContextSensitivity(e,t,r,n,i,a){this.delegates.map(s=>s.reportContextSensitivity(e,t,r,n,i,a))}}class De{constructor(){this._listeners=[Re.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(e){const t="4.13.2";t!==e&&console.log("ANTLR runtime and generated code versions disagree: "+t+"!="+e)}addErrorListener(e){this._listeners.push(e)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const e=this.getLiteralNames(),t=this.getSymbolicNames(),r=e.length>t.length?e.length:t.length;this.tokenNames=[];for(let n=0;n<r;n++)this.tokenNames[n]=e[n]||t[n]||"<INVALID"}return this.tokenNames}getTokenTypeMap(){const e=this.getTokenNames();if(null===e)throw"The current recognizer does not provide a list of token names.";let t=this.tokenTypeMapCache[e];return void 0===t&&(t=e.reduce(function(e,t,r){e[t]=r}),t.EOF=o.EOF,this.tokenTypeMapCache[e]=t),t}getRuleIndexMap(){const e=this.ruleNames;if(null===e)throw"The current recognizer does not provide a list of rule names.";let t=this.ruleIndexMapCache[e];return void 0===t&&(t=e.reduce(function(e,t,r){e[t]=r}),this.ruleIndexMapCache[e]=t),t}getTokenType(e){const t=this.getTokenTypeMap()[e];return void 0!==t?t:o.INVALID_TYPE}getErrorHeader(e){return"line "+e.getOffendingToken().line+":"+e.getOffendingToken().column}getTokenErrorDisplay(e){if(null===e)return"<no token>";let t=e.text;return null===t&&(t=e.type===o.EOF?"<EOF>":"<"+e.type+">"),t=t.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+t+"'"}getErrorListenerDispatch(){return console.warn("Calling deprecated method in Recognizer class: getErrorListenerDispatch()"),this.getErrorListener()}getErrorListener(){return new ve(this._listeners)}sempred(e,t,r){return!0}precpred(e,t){return!0}get atn(){return this._interp.atn}get state(){return this._stateNumber}set state(e){this._stateNumber=e}}De.tokenTypeMapCache={},De.ruleIndexMapCache={};class Fe extends o{constructor(e,t,r,n,i){super(),this.source=void 0!==e?e:Fe.EMPTY_SOURCE,this.type=void 0!==t?t:null,this.channel=void 0!==r?r:o.DEFAULT_CHANNEL,this.start=void 0!==n?n:-1,this.stop=void 0!==i?i:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=e[0].line,this.column=e[0].column):this.column=-1}clone(){const e=new Fe(this.source,this.type,this.channel,this.start,this.stop);return e.tokenIndex=this.tokenIndex,e.line=this.line,e.column=this.column,e.text=this.text,e}cloneWithType(e){const t=new Fe(this.source,e,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,e===o.EOF&&(t.text=""),t}toString(){let e=this.text;return e=null!==e?e.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"<no text>","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+e+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const e=this.getInputStream();if(null===e)return null;const t=e.size;return this.start<t&&this.stop<t?e.getText(this.start,this.stop):"<EOF>"}set text(e){this._text=e}}Fe.EMPTY_SOURCE=[null,null];class ke{}class Ue extends ke{constructor(e){super(),this.copyText=void 0!==e&&e}create(e,t,r,n,i,a,s,o){const l=new Fe(e,t,n,i,a);return l.line=s,l.column=o,null!==r?l.text=r:this.copyText&&null!==e[1]&&(l.text=e[1].getText(i,a)),l}createThin(e,t){const r=new Fe(null,e);return r.text=t,r}}Ue.DEFAULT=new Ue;class Be extends Error{constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,Be),this.message=e.message,this.recognizer=e.recognizer,this.input=e.input,this.ctx=e.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}class Ke extends Be{constructor(e,t,r,n){super({message:"",recognizer:e,input:t,ctx:null}),this.startIndex=r,this.deadEndConfigs=n}toString(){let e="";return this.startIndex>=0&&this.startIndex<this.input.size&&(e=this.input.getText(new L(this.startIndex,this.startIndex))),"LexerNoViableAltException"+e}}class ze extends De{constructor(e){super(),this._input=e,this._factory=Ue.DEFAULT,this._tokenFactorySourcePair=[this,e],this._interp=null,this._token=null,this._tokenStartCharIndex=-1,this._tokenStartLine=-1,this._tokenStartColumn=-1,this._hitEOF=!1,this._channel=o.DEFAULT_CHANNEL,this._type=o.INVALID_TYPE,this._modeStack=[],this._mode=ze.DEFAULT_MODE,this._text=null}reset(){null!==this._input&&this._input.seek(0),this._token=null,this._type=o.INVALID_TYPE,this._channel=o.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=ze.DEFAULT_MODE,this._modeStack=[],this._interp.reset()}nextToken(){if(null===this._input)throw"nextToken requires a non-null input stream.";const e=this._input.mark();try{for(;;){if(this._hitEOF)return this.emitEOF(),this._token;this._token=null,this._channel=o.DEFAULT_CHANNEL,this._tokenStartCharIndex=this._input.index,this._tokenStartColumn=this._interp.column,this._tokenStartLine=this._interp.line,this._text=null;let t=!1;for(;;){this._type=o.INVALID_TYPE;let r=ze.SKIP;try{r=this._interp.match(this._input,this._mode)}catch(e){if(!(e instanceof Be))throw console.log(e.stack),e;this.notifyListeners(e),this.recover(e)}if(this._input.LA(1)===o.EOF&&(this._hitEOF=!0),this._type===o.INVALID_TYPE&&(this._type=r),this._type===ze.SKIP){t=!0;break}if(this._type!==ze.MORE)break}if(!t)return null===this._token&&this.emit(),this._token}}finally{this._input.release(e)}}skip(){this._type=ze.SKIP}more(){this._type=ze.MORE}mode(e){console.warn("Calling deprecated method in Lexer class: mode(...)"),this.setMode(e)}setMode(e){this._mode=e}getMode(){return this._mode}getModeStack(){return this._modeStack}pushMode(e){this._interp.debug&&console.log("pushMode "+e),this._modeStack.push(this._mode),this.setMode(e)}popMode(){if(0===this._modeStack.length)throw"Empty Stack";return this._interp.debug&&console.log("popMode back to "+this._modeStack.slice(0,-1)),this.setMode(this._modeStack.pop()),this._mode}emitToken(e){this._token=e}emit(){const e=this._factory.create(this._tokenFactorySourcePair,this._type,this._text,this._channel,this._tokenStartCharIndex,this.getCharIndex()-1,this._tokenStartLine,this._tokenStartColumn);return this.emitToken(e),e}emitEOF(){const e=this.column,t=this.line,r=this._factory.create(this._tokenFactorySourcePair,o.EOF,null,o.DEFAULT_CHANNEL,this._input.index,this._input.index-1,t,e);return this.emitToken(r),r}getCharIndex(){return this._input.index}getAllTokens(){const e=[];let t=this.nextToken();for(;t.type!==o.EOF;)e.push(t),t=this.nextToken();return e}notifyListeners(e){const t=this._tokenStartCharIndex,r=this._input.index,n=this._input.getText(t,r),i="token recognition error at: '"+this.getErrorDisplay(n)+"'";this.getErrorListener().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,i,e)}getErrorDisplay(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r]);return t.join("")}getErrorDisplayForChar(e){return e.charCodeAt(0)===o.EOF?"<EOF>":"\n"===e?"\\n":"\t"===e?"\\t":"\r"===e?"\\r":e}getCharErrorDisplay(e){return"'"+this.getErrorDisplayForChar(e)+"'"}recover(e){this._input.LA(1)!==o.EOF&&(e instanceof Ke?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(e){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=e,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(e){this._type=e}get line(){return this._interp.line}set line(e){this._interp.line=e}get column(){return this._interp.column}set column(e){this._interp.column=e}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(e){this._text=e}}function qe(e){return e.hashCodeForConfigSet()}function Je(e,t){return e===t||null!==e&&null!==t&&e.equalsForConfigSet(t)}ze.DEFAULT_MODE=0,ze.MORE=-2,ze.SKIP=-3,ze.DEFAULT_TOKEN_CHANNEL=o.DEFAULT_CHANNEL,ze.HIDDEN=o.HIDDEN_CHANNEL,ze.MIN_CHAR_VALUE=0,ze.MAX_CHAR_VALUE=1114111;class Ve{constructor(e){this.configLookup=new C(qe,Je),this.fullCtx=void 0===e||e,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(e,t){if(void 0===t&&(t=null),this.readOnly)throw"This set is readonly";e.semanticContext!==f.NONE&&(this.hasSemanticContext=!0),e.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const r=this.configLookup.getOrAdd(e);if(r===e)return this.cachedHashCode=-1,this.configs.push(e),!0;const n=!this.fullCtx,i=Z(r.context,e.context,n,t);return r.reachesIntoOuterContext=Math.max(r.reachesIntoOuterContext,e.reachesIntoOuterContext),e.precedenceFilterSuppressed&&(r.precedenceFilterSuppressed=!0),r.context=i,!0}getStates(){const e=new C;for(let t=0;t<this.configs.length;t++)e.add(this.configs[t].state);return e}getPredicates(){const e=[];for(let t=0;t<this.configs.length;t++){const r=this.configs[t].semanticContext;r!==f.NONE&&e.push(r.semanticContext)}return e}optimizeConfigs(e){if(this.readOnly)throw"This set is readonly";if(0!==this.configLookup.length)for(let t=0;t<this.configs.length;t++){const r=this.configs[t];r.context=e.getCachedContext(r.context)}}addAll(e){for(let t=0;t<e.length;t++)this.add(e[t]);return!1}equals(e){return this===e||e instanceof Ve&&l(this.configs,e.configs)&&this.fullCtx===e.fullCtx&&this.uniqueAlt===e.uniqueAlt&&this.conflictingAlts===e.conflictingAlts&&this.hasSemanticContext===e.hasSemanticContext&&this.dipsIntoOuterContext===e.dipsIntoOuterContext}hashCode(){const e=new m;return e.update(this.configs),e.finish()}updateHashCode(e){this.readOnly?(-1===this.cachedHashCode&&(this.cachedHashCode=this.hashCode()),e.update(this.cachedHashCode)):e.update(this.hashCode())}isEmpty(){return 0===this.configs.length}contains(e){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.contains(e)}containsFast(e){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.containsFast(e)}clear(){if(this.readOnly)throw"This set is readonly";this.configs=[],this.cachedHashCode=-1,this.configLookup=new C}setReadonly(e){this.readOnly=e,e&&(this.configLookup=null)}toString(){return x(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==X.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(null!==this.conflictingAlts?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}get items(){return this.configs}get length(){return this.configs.length}}class He{constructor(e,t){return null===e&&(e=-1),null===t&&(t=new Ve),this.stateNumber=e,this.configs=t,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}getAltSet(){const e=new C;if(null!==this.configs)for(let t=0;t<this.configs.length;t++){const r=this.configs[t];e.add(r.alt)}return 0===e.length?null:e}equals(e){return this===e||e instanceof He&&this.configs.equals(e.configs)}toString(){let e=this.stateNumber+":"+this.configs;return this.isAcceptState&&(e+="=>",null!==this.predicates?e+=this.predicates:e+=this.prediction),e}hashCode(){const e=new m;return e.update(this.configs),e.finish()}}class je{constructor(e,t){return this.atn=e,this.sharedContextCache=t,this}getCachedContext(e){if(null===this.sharedContextCache)return e;const t=new j;return Q(e,this.sharedContextCache,t)}}je.ERROR=new He(2147483647,new Ve);class Ge extends Ve{constructor(){super(),this.configLookup=new C}}class Qe extends E{constructor(e,t){super(e,t);const r=e.lexerActionExecutor||null;return this.lexerActionExecutor=r||(null!==t?t.lexerActionExecutor:null),this.passedThroughNonGreedyDecision=null!==t&&this.checkNonGreedyDecision(t,this.state),this.hashCodeForConfigSet=Qe.prototype.hashCode,this.equalsForConfigSet=Qe.prototype.equals,this}updateHashCode(e){e.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)}equals(e){return this===e||e instanceof Qe&&this.passedThroughNonGreedyDecision===e.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(e.lexerActionExecutor):!e.lexerActionExecutor)&&super.equals(e)}checkNonGreedyDecision(e,t){return e.passedThroughNonGreedyDecision||t instanceof ee&&t.nonGreedy}}class Ze extends Ae{constructor(e,t){super(t.actionType),this.offset=e,this.action=t,this.isPositionDependent=!0}execute(e){this.action.execute(e)}updateHashCode(e){e.update(this.actionType,this.offset,this.action)}equals(e){return this===e||e instanceof Ze&&this.offset===e.offset&&this.action===e.action}}class $e{constructor(e){return this.lexerActions=null===e?[]:e,this.cachedHashCode=m.hashStuff(e),this}fixOffsetBeforeMatch(e){let t=null;for(let r=0;r<this.lexerActions.length;r++)!this.lexerActions[r].isPositionDependent||this.lexerActions[r]instanceof Ze||(null===t&&(t=this.lexerActions.concat([])),t[r]=new Ze(e,this.lexerActions[r]));return null===t?this:new $e(t)}execute(e,t,r){let n=!1;const i=t.index;try{for(let a=0;a<this.lexerActions.length;a++){let s=this.lexerActions[a];if(s instanceof Ze){const e=s.offset;t.seek(r+e),s=s.action,n=r+e!==i}else s.isPositionDependent&&(t.seek(i),n=!1);s.execute(e)}}finally{n&&t.seek(i)}}hashCode(){return this.cachedHashCode}updateHashCode(e){e.update(this.cachedHashCode)}equals(e){if(this===e)return!0;if(e instanceof $e){if(this.cachedHashCode!=e.cachedHashCode)return!1;if(this.lexerActions.length!=e.lexerActions.length)return!1;{const t=this.lexerActions.length;for(let r=0;r<t;++r)if(!this.lexerActions[r].equals(e.lexerActions[r]))return!1;return!0}}return!1}static append(e,t){if(null===e)return new $e([t]);const r=e.lexerActions.concat([t]);return new $e(r)}}function We(e){e.index=-1,e.line=0,e.column=-1,e.dfaState=null}class Xe{constructor(){We(this)}reset(){We(this)}}class Ye extends je{constructor(e,t,r,n){super(t,n),this.decisionToDFA=r,this.recog=e,this.startIndex=-1,this.line=1,this.column=0,this.mode=ze.DEFAULT_MODE,this.prevAccept=new Xe}copyState(e){this.column=e.column,this.line=e.line,this.mode=e.mode,this.startIndex=e.startIndex}match(e,t){this.mode=t;const r=e.mark();try{this.startIndex=e.index,this.prevAccept.reset();const r=this.decisionToDFA[t];return null===r.s0?this.matchATN(e):this.execATN(e,r.s0)}finally{e.release(r)}}reset(){this.prevAccept.reset(),this.startIndex=-1,this.line=1,this.column=0,this.mode=ze.DEFAULT_MODE}matchATN(e){const t=this.atn.modeToStartState[this.mode];Ye.debug&&console.log("matchATN mode "+this.mode+" start: "+t);const r=this.mode,n=this.computeStartState(e,t),i=n.hasSemanticContext;n.hasSemanticContext=!1;const a=this.addDFAState(n);i||(this.decisionToDFA[this.mode].s0=a);const s=this.execATN(e,a);return Ye.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[r].toLexerString()),s}execATN(e,t){Ye.debug&&console.log("start state closure="+t.configs),t.isAcceptState&&this.captureSimState(this.prevAccept,e,t);let r=e.LA(1),n=t;for(;;){Ye.debug&&console.log("execATN loop starting closure: "+n.configs);let t=this.getExistingTargetState(n,r);if(null===t&&(t=this.computeTargetState(e,n,r)),t===je.ERROR)break;if(r!==o.EOF&&this.consume(e),t.isAcceptState&&(this.captureSimState(this.prevAccept,e,t),r===o.EOF))break;r=e.LA(1),n=t}return this.failOrAccept(this.prevAccept,e,n.configs,r)}getExistingTargetState(e,t){if(null===e.edges||t<Ye.MIN_DFA_EDGE||t>Ye.MAX_DFA_EDGE)return null;let r=e.edges[t-Ye.MIN_DFA_EDGE];return void 0===r&&(r=null),Ye.debug&&null!==r&&console.log("reuse state "+e.stateNumber+" edge to "+r.stateNumber),r}computeTargetState(e,t,r){const n=new Ge;return this.getReachableConfigSet(e,t.configs,n,r),0===n.items.length?(n.hasSemanticContext||this.addDFAEdge(t,r,je.ERROR),je.ERROR):this.addDFAEdge(t,r,null,n)}failOrAccept(e,t,r,n){if(null!==this.prevAccept.dfaState){const r=e.dfaState.lexerActionExecutor;return this.accept(t,r,this.startIndex,e.index,e.line,e.column),e.dfaState.prediction}if(n===o.EOF&&t.index===this.startIndex)return o.EOF;throw new Ke(this.recog,t,this.startIndex,r)}getReachableConfigSet(e,t,r,n){let i=X.INVALID_ALT_NUMBER;for(let a=0;a<t.items.length;a++){const s=t.items[a],l=s.alt===i;if(!l||!s.passedThroughNonGreedyDecision){Ye.debug&&console.log("testing %s at %s\n",this.getTokenName(n),s.toString(this.recog,!0));for(let t=0;t<s.state.transitions.length;t++){const a=s.state.transitions[t],c=this.getReachableTarget(a,n);if(null!==c){let t=s.lexerActionExecutor;null!==t&&(t=t.fixOffsetBeforeMatch(e.index-this.startIndex));const a=n===o.EOF,u=new Qe({state:c,lexerActionExecutor:t},s);this.closure(e,u,r,l,!0,a)&&(i=s.alt)}}}}}accept(e,t,r,n,i,a){Ye.debug&&console.log("ACTION %s\n",t),e.seek(n),this.line=i,this.column=a,null!==t&&null!==this.recog&&t.execute(this.recog,e,r)}getReachableTarget(e,t){return e.matches(t,0,ze.MAX_CHAR_VALUE)?e.target:null}computeStartState(e,t){const r=q.EMPTY,n=new Ge;for(let i=0;i<t.transitions.length;i++){const a=t.transitions[i].target,s=new Qe({state:a,alt:i+1,context:r},null);this.closure(e,s,n,!1,!1,!1)}return n}closure(e,t,r,n,i,a){let s=null;if(Ye.debug&&console.log("closure("+t.toString(this.recog,!0)+")"),t.state instanceof b){if(Ye.debug&&(null!==this.recog?console.log("closure at %s rule stop %s\n",this.recog.ruleNames[t.state.ruleIndex],t):console.log("closure at rule stop %s\n",t)),null===t.context||t.context.hasEmptyPath()){if(null===t.context||t.context.isEmpty())return r.add(t),!0;r.add(new Qe({state:t.state,context:q.EMPTY},t)),n=!0}if(null!==t.context&&!t.context.isEmpty())for(let o=0;o<t.context.length;o++)if(t.context.getReturnState(o)!==q.EMPTY_RETURN_STATE){const l=t.context.getParent(o),c=this.atn.states[t.context.getReturnState(o)];s=new Qe({state:c,context:l},t),n=this.closure(e,s,r,n,i,a)}return n}t.state.epsilonOnlyTransitions||n&&t.passedThroughNonGreedyDecision||r.add(t);for(let o=0;o<t.state.transitions.length;o++){const l=t.state.transitions[o];s=this.getEpsilonTarget(e,t,l,r,i,a),null!==s&&(n=this.closure(e,s,r,n,i,a))}return n}getEpsilonTarget(e,t,r,n,i,a){let s=null;if(r.serializationType===S.RULE){const e=V.create(t.context,r.followState.stateNumber);s=new Qe({state:r.target,context:e},t)}else{if(r.serializationType===S.PRECEDENCE)throw"Precedence predicates are not supported in lexers.";if(r.serializationType===S.PREDICATE)Ye.debug&&console.log("EVAL rule "+r.ruleIndex+":"+r.predIndex),n.hasSemanticContext=!0,this.evaluatePredicate(e,r.ruleIndex,r.predIndex,i)&&(s=new Qe({state:r.target},t));else if(r.serializationType===S.ACTION)if(null===t.context||t.context.hasEmptyPath()){const e=$e.append(t.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);s=new Qe({state:r.target,lexerActionExecutor:e},t)}else s=new Qe({state:r.target},t);else r.serializationType===S.EPSILON?s=new Qe({state:r.target},t):r.serializationType!==S.ATOM&&r.serializationType!==S.RANGE&&r.serializationType!==S.SET||a&&r.matches(o.EOF,0,ze.MAX_CHAR_VALUE)&&(s=new Qe({state:r.target},t))}return s}evaluatePredicate(e,t,r,n){if(null===this.recog)return!0;if(!n)return this.recog.sempred(null,t,r);const i=this.column,a=this.line,s=e.index,o=e.mark();try{return this.consume(e),this.recog.sempred(null,t,r)}finally{this.column=i,this.line=a,e.seek(s),e.release(o)}}captureSimState(e,t,r){e.index=t.index,e.line=this.line,e.column=this.column,e.dfaState=r}addDFAEdge(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),null===r&&null!==n){const e=n.hasSemanticContext;if(n.hasSemanticContext=!1,r=this.addDFAState(n),e)return r}return t<Ye.MIN_DFA_EDGE||t>Ye.MAX_DFA_EDGE||(Ye.debug&&console.log("EDGE "+e+" -> "+r+" upon "+t),null===e.edges&&(e.edges=[]),e.edges[t-Ye.MIN_DFA_EDGE]=r),r}addDFAState(e){const t=new He(null,e);let r=null;for(let t=0;t<e.items.length;t++){const n=e.items[t];if(n.state instanceof b){r=n;break}}null!==r&&(t.isAcceptState=!0,t.lexerActionExecutor=r.lexerActionExecutor,t.prediction=this.atn.ruleToTokenType[r.state.ruleIndex]);const n=this.decisionToDFA[this.mode],i=n.states.get(t);if(null!==i)return i;const a=t;return a.stateNumber=n.states.length,e.setReadonly(!0),a.configs=e,n.states.add(a),a}getDFA(e){return this.decisionToDFA[e]}getText(e){return e.getText(this.startIndex,e.index-1)}consume(e){e.LA(1)==="\n".charCodeAt(0)?(this.line+=1,this.column=0):this.column+=1,e.consume()}getTokenName(e){return-1===e?"EOF":"'"+String.fromCharCode(e)+"'"}}Ye.debug=!1,Ye.dfa_debug=!1,Ye.MIN_DFA_EDGE=0,Ye.MAX_DFA_EDGE=127;class et{constructor(e,t){this.alt=t,this.pred=e}toString(){return"("+this.pred+", "+this.alt+")"}}class tt{constructor(){this.data={}}get(e){return this.data["k-"+e]||null}set(e,t){this.data["k-"+e]=t}values(){return Object.keys(this.data).filter(e=>e.startsWith("k-")).map(e=>this.data[e],this)}}const rt={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(e,t){if(rt.allConfigsInRuleStopStates(t))return!0;if(e===rt.SLL&&t.hasSemanticContext){const e=new Ve;for(let r=0;r<t.items.length;r++){let n=t.items[r];n=new E({semanticContext:f.NONE},n),e.add(n)}t=e}const r=rt.getConflictingAltSubsets(t);return rt.hasConflictingAltSet(r)&&!rt.hasStateAssociatedWithOneAlt(t)},hasConfigInRuleStopState:function(e){for(let t=0;t<e.items.length;t++)if(e.items[t].state instanceof b)return!0;return!1},allConfigsInRuleStopStates:function(e){for(let t=0;t<e.items.length;t++)if(!(e.items[t].state instanceof b))return!1;return!0},resolvesToJustOneViableAlt:function(e){return rt.getSingleViableAlt(e)},allSubsetsConflict:function(e){return!rt.hasNonConflictingAltSet(e)},hasNonConflictingAltSet:function(e){for(let t=0;t<e.length;t++)if(1===e[t].length)return!0;return!1},hasConflictingAltSet:function(e){for(let t=0;t<e.length;t++)if(e[t].length>1)return!0;return!1},allSubsetsEqual:function(e){let t=null;for(let r=0;r<e.length;r++){const n=e[r];if(null===t)t=n;else if(n!==t)return!1}return!0},getUniqueAlt:function(e){const t=rt.getAlts(e);return 1===t.length?t.minValue():X.INVALID_ALT_NUMBER},getAlts:function(e){const t=new $;return e.map(function(e){t.or(e)}),t},getConflictingAltSubsets:function(e){const t=new j;return t.hashFunction=function(e){m.hashStuff(e.state.stateNumber,e.context)},t.equalsFunction=function(e,t){return e.state.stateNumber===t.state.stateNumber&&e.context.equals(t.context)},e.items.map(function(e){let r=t.get(e);null===r&&(r=new $,t.set(e,r)),r.set(e.alt)}),t.getValues()},getStateToAltMap:function(e){const t=new tt;return e.items.map(function(e){let r=t.get(e.state);null===r&&(r=new $,t.set(e.state,r)),r.set(e.alt)}),t},hasStateAssociatedWithOneAlt:function(e){const t=rt.getStateToAltMap(e).values();for(let e=0;e<t.length;e++)if(1===t[e].length)return!0;return!1},getSingleViableAlt:function(e){let t=null;for(let r=0;r<e.length;r++){const n=e[r].minValue();if(null===t)t=n;else if(t!==n)return X.INVALID_ALT_NUMBER}return t}},nt=rt;class it extends Be{constructor(e,t,r,n,i,a){a=a||e._ctx,n=n||e.getCurrentToken(),r=r||e.getCurrentToken(),t=t||e.getInputStream(),super({message:"",recognizer:e,input:t,ctx:a}),this.deadEndConfigs=i,this.startToken=r,this.offendingToken=n}}class at{constructor(e){this.defaultMapCtor=e||j,this.cacheMap=new this.defaultMapCtor}get(e,t){const r=this.cacheMap.get(e)||null;return null===r?null:r.get(t)||null}set(e,t,r){let n=this.cacheMap.get(e)||null;null===n&&(n=new this.defaultMapCtor,this.cacheMap.set(e,n)),n.set(t,r)}}class st extends je{constructor(e,t,r,n){super(t,n),this.parser=e,this.decisionToDFA=r,this.predictionMode=nt.LL,this._input=null,this._startIndex=0,this._outerContext=null,this._dfa=null,this.mergeCache=null,this.debug=!1,this.debug_closure=!1,this.debug_add=!1,this.trace_atn_sim=!1,this.dfa_debug=!1,this.retry_debug=!1}reset(){}adaptivePredict(e,t,r){(this.debug||this.trace_atn_sim)&&console.log("adaptivePredict decision "+t+" exec LA(1)=="+this.getLookaheadName(e)+" line "+e.LT(1).line+":"+e.LT(1).column),this._input=e,this._startIndex=e.index,this._outerContext=r;const n=this.decisionToDFA[t];this._dfa=n;const i=e.mark(),a=e.index;try{let t;if(t=n.precedenceDfa?n.getPrecedenceStartState(this.parser.getPrecedence()):n.s0,null===t){null===r&&(r=z.EMPTY),this.debug&&console.log("predictATN decision "+n.decision+" exec LA(1)=="+this.getLookaheadName(e)+", outerContext="+r.toString(this.parser.ruleNames));const i=!1;let a=this.computeStartState(n.atnStartState,z.EMPTY,i);n.precedenceDfa?(n.s0.configs=a,a=this.applyPrecedenceFilter(a),t=this.addDFAState(n,new He(null,a)),n.setPrecedenceStartState(this.parser.getPrecedence(),t)):(t=this.addDFAState(n,new He(null,a)),n.s0=t)}const i=this.execATN(n,t,e,a,r);return this.debug&&console.log("DFA after predictATN: "+n.toString(this.parser.literalNames,this.parser.symbolicNames)),i}finally{this._dfa=null,this.mergeCache=null,e.seek(a),e.release(i)}}execATN(e,t,r,n,i){let a;(this.debug||this.trace_atn_sim)&&console.log("execATN decision "+e.decision+", DFA state "+t+", LA(1)=="+this.getLookaheadName(r)+" line "+r.LT(1).line+":"+r.LT(1).column);let s=t;this.debug&&console.log("s0 = "+t);let l=r.LA(1);for(;;){let t=this.getExistingTargetState(s,l);if(null===t&&(t=this.computeTargetState(e,s,l)),t===je.ERROR){const e=this.noViableAlt(r,i,s.configs,n);if(r.seek(n),a=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(s.configs,i),a!==X.INVALID_ALT_NUMBER)return a;throw e}if(t.requiresFullContext&&this.predictionMode!==nt.SLL){let s=null;if(null!==t.predicates){this.debug&&console.log("DFA state has preds in DFA sim LL failover");const e=r.index;if(e!==n&&r.seek(n),s=this.evalSemanticContext(t.predicates,i,!0),1===s.length)return this.debug&&console.log("Full LL avoided"),s.minValue();e!==n&&r.seek(e)}this.dfa_debug&&console.log("ctx sensitive state "+i+" in "+t);const o=!0,l=this.computeStartState(e.atnStartState,i,o);return this.reportAttemptingFullContext(e,s,t.configs,n,r.index),a=this.execATNWithFullContext(e,t,l,r,n,i),a}if(t.isAcceptState){if(null===t.predicates)return t.prediction;const a=r.index;r.seek(n);const s=this.evalSemanticContext(t.predicates,i,!0);if(0===s.length)throw this.noViableAlt(r,i,t.configs,n);return 1===s.length||this.reportAmbiguity(e,t,n,a,!1,s,t.configs),s.minValue()}s=t,l!==o.EOF&&(r.consume(),l=r.LA(1))}}getExistingTargetState(e,t){const r=e.edges;return null===r?null:r[t+1]||null}computeTargetState(e,t,r){const n=this.computeReachSet(t.configs,r,!1);if(null===n)return this.addDFAEdge(e,t,r,je.ERROR),je.ERROR;let i=new He(null,n);const a=this.getUniqueAlt(n);if(this.debug){const e=nt.getConflictingAltSubsets(n);console.log("SLL altSubSets="+x(e)+", configs="+n+", predict="+a+", allSubsetsConflict="+nt.allSubsetsConflict(e)+", conflictingAlts="+this.getConflictingAlts(n))}return a!==X.INVALID_ALT_NUMBER?(i.isAcceptState=!0,i.configs.uniqueAlt=a,i.prediction=a):nt.hasSLLConflictTerminatingPrediction(this.predictionMode,n)&&(i.configs.conflictingAlts=this.getConflictingAlts(n),i.requiresFullContext=!0,i.isAcceptState=!0,i.prediction=i.configs.conflictingAlts.minValue()),i.isAcceptState&&i.configs.hasSemanticContext&&(this.predicateDFAState(i,this.atn.getDecisionState(e.decision)),null!==i.predicates&&(i.prediction=X.INVALID_ALT_NUMBER)),i=this.addDFAEdge(e,t,r,i),i}predicateDFAState(e,t){const r=t.transitions.length,n=this.getConflictingAltsOrUniqueAlt(e.configs),i=this.getPredsForAmbigAlts(n,e.configs,r);null!==i?(e.predicates=this.getPredicatePredictions(n,i),e.prediction=X.INVALID_ALT_NUMBER):e.prediction=n.minValue()}execATNWithFullContext(e,t,r,n,i,a){(this.debug||this.trace_atn_sim)&&console.log("execATNWithFullContext "+r);let s,l=!1,c=r;n.seek(i);let u=n.LA(1),m=-1;for(;;){if(s=this.computeReachSet(c,u,!0),null===s){const e=this.noViableAlt(n,a,c,i);n.seek(i);const t=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(c,a);if(t!==X.INVALID_ALT_NUMBER)return t;throw e}const e=nt.getConflictingAltSubsets(s);if(this.debug&&console.log("LL altSubSets="+e+", predict="+nt.getUniqueAlt(e)+", resolvesToJustOneViableAlt="+nt.resolvesToJustOneViableAlt(e)),s.uniqueAlt=this.getUniqueAlt(s),s.uniqueAlt!==X.INVALID_ALT_NUMBER){m=s.uniqueAlt;break}if(this.predictionMode!==nt.LL_EXACT_AMBIG_DETECTION){if(m=nt.resolvesToJustOneViableAlt(e),m!==X.INVALID_ALT_NUMBER)break}else if(nt.allSubsetsConflict(e)&&nt.allSubsetsEqual(e)){l=!0,m=nt.getSingleViableAlt(e);break}c=s,u!==o.EOF&&(n.consume(),u=n.LA(1))}return s.uniqueAlt!==X.INVALID_ALT_NUMBER?(this.reportContextSensitivity(e,m,s,i,n.index),m):(this.reportAmbiguity(e,t,i,n.index,l,null,s),m)}computeReachSet(e,t,r){this.debug&&console.log("in computeReachSet, starting closure: "+e),null===this.mergeCache&&(this.mergeCache=new at);const n=new Ve(r);let i=null;for(let a=0;a<e.items.length;a++){const s=e.items[a];if(this.debug&&console.log("testing "+this.getTokenName(t)+" at "+s),s.state instanceof b)(r||t===o.EOF)&&(null===i&&(i=[]),i.push(s),this.debug_add&&console.log("added "+s+" to skippedStopStates"));else for(let e=0;e<s.state.transitions.length;e++){const r=s.state.transitions[e],i=this.getReachableTarget(r,t);if(null!==i){const e=new E({state:i},s);n.add(e,this.mergeCache),this.debug_add&&console.log("added "+e+" to intermediate")}}}let a=null;if(null===i&&t!==o.EOF&&(1===n.items.length||this.getUniqueAlt(n)!==X.INVALID_ALT_NUMBER)&&(a=n),null===a){a=new Ve(r);const e=new C,i=t===o.EOF;for(let t=0;t<n.items.length;t++)this.closure(n.items[t],a,e,!1,r,i)}if(t===o.EOF&&(a=this.removeAllConfigsNotInRuleStopState(a,a===n)),!(null===i||r&&nt.hasConfigInRuleStopState(a)))for(let e=0;e<i.length;e++)a.add(i[e],this.mergeCache);return this.trace_atn_sim&&console.log("computeReachSet "+e+" -> "+a),0===a.items.length?null:a}removeAllConfigsNotInRuleStopState(e,t){if(nt.allConfigsInRuleStopStates(e))return e;const r=new Ve(e.fullCtx);for(let n=0;n<e.items.length;n++){const i=e.items[n];if(i.state instanceof b)r.add(i,this.mergeCache);else if(t&&i.state.epsilonOnlyTransitions&&this.atn.nextTokens(i.state).contains(o.EPSILON)){const e=this.atn.ruleToStopState[i.state.ruleIndex];r.add(new E({state:e},i),this.mergeCache)}}return r}computeStartState(e,t,r){const n=G(this.atn,t),i=new Ve(r);this.trace_atn_sim&&console.log("computeStartState from ATN state "+e+" initialContext="+n.toString(this.parser));for(let t=0;t<e.transitions.length;t++){const a=e.transitions[t].target,s=new E({state:a,alt:t+1,context:n},null),o=new C;this.closure(s,i,o,!0,r,!1)}return i}applyPrecedenceFilter(e){let t;const r=[],n=new Ve(e.fullCtx);for(let i=0;i<e.items.length;i++){if(t=e.items[i],1!==t.alt)continue;const a=t.semanticContext.evalPrecedence(this.parser,this._outerContext);null!==a&&(r[t.state.stateNumber]=t.context,a!==t.semanticContext?n.add(new E({semanticContext:a},t),this.mergeCache):n.add(t,this.mergeCache))}for(let i=0;i<e.items.length;i++)if(t=e.items[i],1!==t.alt){if(!t.precedenceFilterSuppressed){const e=r[t.state.stateNumber]||null;if(null!==e&&e.equals(t.context))continue}n.add(t,this.mergeCache)}return n}getReachableTarget(e,t){return e.matches(t,0,this.atn.maxTokenType)?e.target:null}getPredsForAmbigAlts(e,t,r){let n=[];for(let r=0;r<t.items.length;r++){const i=t.items[r];e.get(i.alt)&&(n[i.alt]=f.orContext(n[i.alt]||null,i.semanticContext))}let i=0;for(let e=1;e<r+1;e++){const t=n[e]||null;null===t?n[e]=f.NONE:t!==f.NONE&&(i+=1)}return 0===i&&(n=null),this.debug&&console.log("getPredsForAmbigAlts result "+x(n)),n}getPredicatePredictions(e,t){const r=[];let n=!1;for(let i=1;i<t.length;i++){const a=t[i];null!==e&&e.get(i)&&r.push(new et(a,i)),a!==f.NONE&&(n=!0)}return n?r:null}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(e,t){const r=this.splitAccordingToSemanticValidity(e,t),n=r[0],i=r[1];let a=this.getAltThatFinishedDecisionEntryRule(n);return a!==X.INVALID_ALT_NUMBER||i.items.length>0&&(a=this.getAltThatFinishedDecisionEntryRule(i),a!==X.INVALID_ALT_NUMBER)?a:X.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(e){const t=[];for(let r=0;r<e.items.length;r++){const n=e.items[r];(n.reachesIntoOuterContext>0||n.state instanceof b&&n.context.hasEmptyPath())&&t.indexOf(n.alt)<0&&t.push(n.alt)}return 0===t.length?X.INVALID_ALT_NUMBER:Math.min.apply(null,t)}splitAccordingToSemanticValidity(e,t){const r=new Ve(e.fullCtx),n=new Ve(e.fullCtx);for(let i=0;i<e.items.length;i++){const a=e.items[i];a.semanticContext!==f.NONE?a.semanticContext.evaluate(this.parser,t)?r.add(a):n.add(a):r.add(a)}return[r,n]}evalSemanticContext(e,t,r){const n=new $;for(let i=0;i<e.length;i++){const a=e[i];if(a.pred===f.NONE){if(n.set(a.alt),!r)break;continue}const s=a.pred.evaluate(this.parser,t);if((this.debug||this.dfa_debug)&&console.log("eval pred "+a+"="+s),s&&((this.debug||this.dfa_debug)&&console.log("PREDICT "+a.alt),n.set(a.alt),!r))break}return n}closure(e,t,r,n,i,a){this.closureCheckingStopState(e,t,r,n,i,0,a)}closureCheckingStopState(e,t,r,n,i,a,s){if((this.trace_atn_sim||this.debug_closure)&&console.log("closure("+e.toString(this.parser,!0)+")"),e.state instanceof b){if(!e.context.isEmpty()){for(let o=0;o<e.context.length;o++){if(e.context.getReturnState(o)===q.EMPTY_RETURN_STATE){if(i){t.add(new E({state:e.state,context:q.EMPTY},e),this.mergeCache);continue}this.debug&&console.log("FALLING off rule "+this.getRuleName(e.state.ruleIndex)),this.closure_(e,t,r,n,i,a,s);continue}const l=this.atn.states[e.context.getReturnState(o)],c=e.context.getParent(o),u={state:l,alt:e.alt,context:c,semanticContext:e.semanticContext},m=new E(u,null);m.reachesIntoOuterContext=e.reachesIntoOuterContext,this.closureCheckingStopState(m,t,r,n,i,a-1,s)}return}if(i)return void t.add(e,this.mergeCache);this.debug&&console.log("FALLING off rule "+this.getRuleName(e.state.ruleIndex))}this.closure_(e,t,r,n,i,a,s)}closure_(e,t,r,n,i,a,s){const o=e.state;o.epsilonOnlyTransitions||t.add(e,this.mergeCache);for(let l=0;l<o.transitions.length;l++){if(0===l&&this.canDropLoopEntryEdgeInLeftRecursiveRule(e))continue;const c=o.transitions[l],u=n&&!(c instanceof de),m=this.getEpsilonTarget(e,c,u,0===a,i,s);if(null!==m){let n=a;if(e.state instanceof b){if(null!==this._dfa&&this._dfa.precedenceDfa&&c.outermostPrecedenceReturn===this._dfa.atnStartState.ruleIndex&&(m.precedenceFilterSuppressed=!0),m.reachesIntoOuterContext+=1,r.getOrAdd(m)!==m)continue;t.dipsIntoOuterContext=!0,n-=1,this.debug&&console.log("dips into outer ctx: "+m)}else{if(!c.isEpsilon&&r.getOrAdd(m)!==m)continue;c instanceof N&&n>=0&&(n+=1)}this.closureCheckingStopState(m,t,r,u,i,n,s)}}}canDropLoopEntryEdgeInLeftRecursiveRule(e){const t=e.state;if(t.stateType!==M.STAR_LOOP_ENTRY)return!1;if(t.stateType!==M.STAR_LOOP_ENTRY||!t.isPrecedenceDecision||e.context.isEmpty()||e.context.hasEmptyPath())return!1;const r=e.context.length;for(let n=0;n<r;n++)if(this.atn.states[e.context.getReturnState(n)].ruleIndex!==t.ruleIndex)return!1;const n=t.transitions[0].target.endState.stateNumber,i=this.atn.states[n];for(let n=0;n<r;n++){const r=e.context.getReturnState(n),a=this.atn.states[r];if(1!==a.transitions.length||!a.transitions[0].isEpsilon)return!1;const s=a.transitions[0].target;if(!(a.stateType===M.BLOCK_END&&s===t||a===i||s===i||s.stateType===M.BLOCK_END&&1===s.transitions.length&&s.transitions[0].isEpsilon&&s.transitions[0].target===t))return!1}return!0}getRuleName(e){return null!==this.parser&&e>=0?this.parser.ruleNames[e]:"<rule "+e+">"}getEpsilonTarget(e,t,r,n,i,a){switch(t.serializationType){case S.RULE:return this.ruleTransition(e,t);case S.PRECEDENCE:return this.precedenceTransition(e,t,r,n,i);case S.PREDICATE:return this.predTransition(e,t,r,n,i);case S.ACTION:return this.actionTransition(e,t);case S.EPSILON:return new E({state:t.target},e);case S.ATOM:case S.RANGE:case S.SET:return a&&t.matches(o.EOF,0,1)?new E({state:t.target},e):null;default:return null}}actionTransition(e,t){if(this.debug){const e=-1===t.actionIndex?65535:t.actionIndex;console.log("ACTION edge "+t.ruleIndex+":"+e)}return new E({state:t.target},e)}precedenceTransition(e,t,r,n,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+t.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+x(this.parser.getRuleInvocationStack())));let a=null;if(r&&n)if(i){const r=this._input.index;this._input.seek(this._startIndex);const n=t.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),n&&(a=new E({state:t.target},e))}else{const r=f.andContext(e.semanticContext,t.getPredicate());a=new E({state:t.target,semanticContext:r},e)}else a=new E({state:t.target},e);return this.debug&&console.log("config from pred transition="+a),a}predTransition(e,t,r,n,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+t.ruleIndex+":"+t.predIndex+", ctx dependent="+t.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+x(this.parser.getRuleInvocationStack())));let a=null;if(r&&(t.isCtxDependent&&n||!t.isCtxDependent))if(i){const r=this._input.index;this._input.seek(this._startIndex);const n=t.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),n&&(a=new E({state:t.target},e))}else{const r=f.andContext(e.semanticContext,t.getPredicate());a=new E({state:t.target,semanticContext:r},e)}else a=new E({state:t.target},e);return this.debug&&console.log("config from pred transition="+a),a}ruleTransition(e,t){this.debug&&console.log("CALL rule "+this.getRuleName(t.target.ruleIndex)+", ctx="+e.context);const r=t.followState,n=V.create(e.context,r.stateNumber);return new E({state:t.target,context:n},e)}getConflictingAlts(e){const t=nt.getConflictingAltSubsets(e);return nt.getAlts(t)}getConflictingAltsOrUniqueAlt(e){let t=null;return e.uniqueAlt!==X.INVALID_ALT_NUMBER?(t=new $,t.set(e.uniqueAlt)):t=e.conflictingAlts,t}getTokenName(e){if(e===o.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(e>=this.parser.literalNames.length&&e>=this.parser.symbolicNames.length))return(this.parser.literalNames[e]||this.parser.symbolicNames[e])+"<"+e+">";console.log(e+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+e}getLookaheadName(e){return this.getTokenName(e.LA(1))}dumpDeadEndConfigs(e){console.log("dead end configs: ");const t=e.getDeadEndConfigs();for(let e=0;e<t.length;e++){const r=t[e];let n="no edges";if(r.state.transitions.length>0){const e=r.state.transitions[0];e instanceof he?n="Atom "+this.getTokenName(e.label):e instanceof w&&(n=(e instanceof I?"~":"")+"Set "+e.set)}console.error(r.toString(this.parser,!0)+":"+n)}}noViableAlt(e,t,r,n){return new it(this.parser,e,e.get(n),e.LT(1),r,t)}getUniqueAlt(e){let t=X.INVALID_ALT_NUMBER;for(let r=0;r<e.items.length;r++){const n=e.items[r];if(t===X.INVALID_ALT_NUMBER)t=n.alt;else if(n.alt!==t)return X.INVALID_ALT_NUMBER}return t}addDFAEdge(e,t,r,n){if(this.debug&&console.log("EDGE "+t+" -> "+n+" upon "+this.getTokenName(r)),null===n)return null;if(n=this.addDFAState(e,n),null===t||r<-1||r>this.atn.maxTokenType)return n;if(null===t.edges&&(t.edges=[]),t.edges[r+1]=n,this.debug){const t=null===this.parser?null:this.parser.literalNames,r=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+e.toString(t,r))}return n}addDFAState(e,t){if(t===je.ERROR)return t;const r=e.states.get(t);return null!==r?(this.trace_atn_sim&&console.log("addDFAState "+t+" exists"),r):(t.stateNumber=e.states.length,t.configs.readOnly||(t.configs.optimizeConfigs(this),t.configs.setReadonly(!0)),this.trace_atn_sim&&console.log("addDFAState new "+t),e.states.add(t),this.debug&&console.log("adding new DFA state: "+t),t)}reportAttemptingFullContext(e,t,r,n,i){if(this.debug||this.retry_debug){const t=new L(n,i+1);console.log("reportAttemptingFullContext decision="+e.decision+":"+r+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListener().reportAttemptingFullContext(this.parser,e,n,i,t,r)}reportContextSensitivity(e,t,r,n,i){if(this.debug||this.retry_debug){const t=new L(n,i+1);console.log("reportContextSensitivity decision="+e.decision+":"+r+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListener().reportContextSensitivity(this.parser,e,n,i,t,r)}reportAmbiguity(e,t,r,n,i,a,s){if(this.debug||this.retry_debug){const e=new L(r,n+1);console.log("reportAmbiguity "+a+":"+s+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportAmbiguity(this.parser,e,r,n,i,a,s)}}class ot{constructor(){this.cache=new j}add(e){if(e===q.EMPTY)return q.EMPTY;const t=this.cache.get(e)||null;return null!==t?t:(this.cache.set(e,e),e)}get(e){return this.cache.get(e)||null}get length(){return this.cache.length}}const lt={ATN:X,ATNDeserializer:Pe,LexerATNSimulator:Ye,ParserATNSimulator:st,PredictionMode:nt,PredictionContextCache:ot};class ct{constructor(e,t,r){this.dfa=e,this.literalNames=t||[],this.symbolicNames=r||[]}toString(){if(null===this.dfa.s0)return null;let e="";const t=this.dfa.sortedStates();for(let r=0;r<t.length;r++){const n=t[r];if(null!==n.edges){const t=n.edges.length;for(let r=0;r<t;r++){const t=n.edges[r]||null;null!==t&&2147483647!==t.stateNumber&&(e=e.concat(this.getStateString(n)),e=e.concat("-"),e=e.concat(this.getEdgeLabel(r)),e=e.concat("->"),e=e.concat(this.getStateString(t)),e=e.concat("\n"))}}}return 0===e.length?null:e}getEdgeLabel(e){return 0===e?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[e-1]||this.symbolicNames[e-1]:String.fromCharCode(e-1)}getStateString(e){const t=(e.isAcceptState?":":"")+"s"+e.stateNumber+(e.requiresFullContext?"^":"");return e.isAcceptState?null!==e.predicates?t+"=>"+x(e.predicates):t+"=>"+e.prediction.toString():t}}class ut extends ct{constructor(e){super(e,null)}getEdgeLabel(e){return"'"+String.fromCharCode(e)+"'"}}class mt{constructor(e,t){if(void 0===t&&(t=0),this.atnStartState=e,this.decision=t,this._states=new C,this.s0=null,this.precedenceDfa=!1,e instanceof le&&e.isPrecedenceDecision){this.precedenceDfa=!0;const e=new He(null,new Ve);e.edges=[],e.isAcceptState=!1,e.requiresFullContext=!1,this.s0=e}}getPrecedenceStartState(e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return e<0||e>=this.s0.edges.length?null:this.s0.edges[e]||null}setPrecedenceStartState(e,t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";e<0||(this.s0.edges[e]=t)}setPrecedenceDfa(e){if(this.precedenceDfa!==e){if(this._states=new C,e){const e=new He(null,new Ve);e.edges=[],e.isAcceptState=!1,e.requiresFullContext=!1,this.s0=e}else this.s0=null;this.precedenceDfa=e}}sortedStates(){return this._states.values().sort(function(e,t){return e.stateNumber-t.stateNumber})}toString(e,t){return e=e||null,t=t||null,null===this.s0?"":new ct(this,e,t).toString()}toLexerString(){return null===this.s0?"":new ut(this).toString()}get states(){return this._states}}const ht={DFA:mt,DFASerializer:ct,LexerDFASerializer:ut,PredPrediction:et},pt={PredictionContext:q},dt={Interval:L,IntervalSet:T};class xt{visitTerminal(e){}visitErrorNode(e){}enterEveryRule(e){}exitEveryRule(e){}}class Ct{visit(e){return Array.isArray(e)?e.map(function(e){return e.accept(this)},this):e.accept(this)}visitChildren(e){return e.children?this.visit(e.children):null}visitTerminal(e){}visitErrorNode(e){}}class ft{walk(e,t){if(t instanceof U||void 0!==t.isErrorNode&&t.isErrorNode())e.visitErrorNode(t);else if(t instanceof k)e.visitTerminal(t);else{this.enterRule(e,t);for(let r=0;r<t.getChildCount();r++){const n=t.getChild(r);this.walk(e,n)}this.exitRule(e,t)}}enterRule(e,t){const r=t.ruleContext;e.enterEveryRule(r),r.enterRule(e)}exitRule(e,t){const r=t.ruleContext;r.exitRule(e),e.exitEveryRule(r)}}ft.DEFAULT=new ft;const gt={Trees:K,RuleNode:F,ErrorNode:U,TerminalNode:k,ParseTreeListener:xt,ParseTreeVisitor:Ct,ParseTreeWalker:ft};class _t extends Be{constructor(e){super({message:"",recognizer:e,input:e.getInputStream(),ctx:e._ctx}),this.offendingToken=e.getCurrentToken()}}class yt extends Be{constructor(e,t,r){super({message:At(t,r||null),recognizer:e,input:e.getInputStream(),ctx:e._ctx});const n=e._interp.atn.states[e.state].transitions[0];n instanceof fe?(this.ruleIndex=n.ruleIndex,this.predicateIndex=n.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=t,this.offendingToken=e.getCurrentToken()}}function At(e,t){return null!==t?t:"failed predicate: {"+e+"}?"}class Et extends Oe{constructor(e){super(),e=e||!0,this.exactOnly=e}reportAmbiguity(e,t,r,n,i,a,s){if(this.exactOnly&&!i)return;const o="reportAmbiguity d="+this.getDecisionDescription(e,t)+": ambigAlts="+this.getConflictingAlts(a,s)+", input='"+e.getTokenStream().getText(new L(r,n))+"'";e.notifyErrorListeners(o)}reportAttemptingFullContext(e,t,r,n,i,a){const s="reportAttemptingFullContext d="+this.getDecisionDescription(e,t)+", input='"+e.getTokenStream().getText(new L(r,n))+"'";e.notifyErrorListeners(s)}reportContextSensitivity(e,t,r,n,i,a){const s="reportContextSensitivity d="+this.getDecisionDescription(e,t)+", input='"+e.getTokenStream().getText(new L(r,n))+"'";e.notifyErrorListeners(s)}getDecisionDescription(e,t){const r=t.decision,n=t.atnStartState.ruleIndex,i=e.ruleNames;if(n<0||n>=i.length)return""+r;const a=i[n]||null;return null===a||0===a.length?""+r:`${r} (${a})`}getConflictingAlts(e,t){if(null!==e)return e;const r=new $;for(let e=0;e<t.items.length;e++)r.set(t.items[e].alt);return`{${r.values().join(", ")}}`}}class Lt extends Error{constructor(){super(),Error.captureStackTrace(this,Lt)}}class Tt{reset(e){}recoverInline(e){}recover(e,t){}sync(e){}inErrorRecoveryMode(e){}reportError(e){}}class Mt extends Tt{constructor(){super(),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this.nextTokensContext=null,this.nextTokenState=0}reset(e){this.endErrorCondition(e)}beginErrorCondition(e){this.errorRecoveryMode=!0}inErrorRecoveryMode(e){return this.errorRecoveryMode}endErrorCondition(e){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1}reportMatch(e){this.endErrorCondition(e)}reportError(e,t){this.inErrorRecoveryMode(e)||(this.beginErrorCondition(e),t instanceof it?this.reportNoViableAlternative(e,t):t instanceof _t?this.reportInputMismatch(e,t):t instanceof yt?this.reportFailedPredicate(e,t):(console.log("unknown recognition error type: "+t.constructor.name),console.log(t.stack),e.notifyErrorListeners(t.getOffendingToken(),t.getMessage(),t)))}recover(e,t){this.lastErrorIndex===e.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(e.state)>=0&&e.consume(),this.lastErrorIndex=e._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(e.state);const r=this.getErrorRecoverySet(e);this.consumeUntil(e,r)}sync(e){if(this.inErrorRecoveryMode(e))return;const t=e._interp.atn.states[e.state],r=e.getTokenStream().LA(1),n=e.atn.nextTokens(t);if(n.contains(r))return this.nextTokensContext=null,void(this.nextTokenState=M.INVALID_STATE_NUMBER);if(n.contains(o.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=e._ctx,this.nextTokensState=e._stateNumber);else switch(t.stateType){case M.BLOCK_START:case M.STAR_BLOCK_START:case M.PLUS_BLOCK_START:case M.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(e))return;throw new _t(e);case M.PLUS_LOOP_BACK:case M.STAR_LOOP_BACK:{this.reportUnwantedToken(e);const t=new T;t.addSet(e.getExpectedTokens());const r=t.addSet(this.getErrorRecoverySet(e));this.consumeUntil(e,r)}}}reportNoViableAlternative(e,t){const r=e.getTokenStream();let n;n=null!==r?t.startToken.type===o.EOF?"<EOF>":r.getText(new L(t.startToken.tokenIndex,t.offendingToken.tokenIndex)):"<unknown input>";const i="no viable alternative at input "+this.escapeWSAndQuote(n);e.notifyErrorListeners(i,t.offendingToken,t)}reportInputMismatch(e,t){const r="mismatched input "+this.getTokenErrorDisplay(t.offendingToken)+" expecting "+t.getExpectedTokens().toString(e.literalNames,e.symbolicNames);e.notifyErrorListeners(r,t.offendingToken,t)}reportFailedPredicate(e,t){const r="rule "+e.ruleNames[e._ctx.ruleIndex]+" "+t.message;e.notifyErrorListeners(r,t.offendingToken,t)}reportUnwantedToken(e){if(this.inErrorRecoveryMode(e))return;this.beginErrorCondition(e);const t=e.getCurrentToken(),r="extraneous input "+this.getTokenErrorDisplay(t)+" expecting "+this.getExpectedTokens(e).toString(e.literalNames,e.symbolicNames);e.notifyErrorListeners(r,t,null)}reportMissingToken(e){if(this.inErrorRecoveryMode(e))return;this.beginErrorCondition(e);const t=e.getCurrentToken(),r="missing "+this.getExpectedTokens(e).toString(e.literalNames,e.symbolicNames)+" at "+this.getTokenErrorDisplay(t);e.notifyErrorListeners(r,t,null)}recoverInline(e){const t=this.singleTokenDeletion(e);if(null!==t)return e.consume(),t;if(this.singleTokenInsertion(e))return this.getMissingSymbol(e);throw new _t(e)}singleTokenInsertion(e){const t=e.getTokenStream().LA(1),r=e._interp.atn,n=r.states[e.state].transitions[0].target;return!!r.nextTokens(n,e._ctx).contains(t)&&(this.reportMissingToken(e),!0)}singleTokenDeletion(e){const t=e.getTokenStream().LA(2);if(this.getExpectedTokens(e).contains(t)){this.reportUnwantedToken(e),e.consume();const t=e.getCurrentToken();return this.reportMatch(e),t}return null}getMissingSymbol(e){const t=e.getCurrentToken(),r=this.getExpectedTokens(e).first();let n;n=r===o.EOF?"<missing EOF>":"<missing "+e.literalNames[r]+">";let i=t;const a=e.getTokenStream().LT(-1);return i.type===o.EOF&&null!==a&&(i=a),e.getTokenFactory().create(i.source,r,n,o.DEFAULT_CHANNEL,-1,-1,i.line,i.column)}getExpectedTokens(e){return e.getExpectedTokens()}getTokenErrorDisplay(e){if(null===e)return"<no token>";let t=e.text;return null===t&&(t=e.type===o.EOF?"<EOF>":"<"+e.type+">"),this.escapeWSAndQuote(t)}escapeWSAndQuote(e){return"'"+(e=(e=(e=e.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(e){const t=e._interp.atn;let r=e._ctx;const n=new T;for(;null!==r&&r.invokingState>=0;){const e=t.states[r.invokingState].transitions[0],i=t.nextTokens(e.followState);n.addSet(i),r=r.parentCtx}return n.removeOne(o.EPSILON),n}consumeUntil(e,t){let r=e.getTokenStream().LA(1);for(;r!==o.EOF&&!t.contains(r);)e.consume(),r=e.getTokenStream().LA(1)}}class bt extends Mt{constructor(){super()}recover(e,t){let r=e._ctx;for(;null!==r;)r.exception=t,r=r.parentCtx;throw new Lt(t)}recoverInline(e){this.recover(e,new _t(e))}sync(e){}}const St={RecognitionException:Be,NoViableAltException:it,LexerNoViableAltException:Ke,InputMismatchException:_t,FailedPredicateException:yt,DiagnosticErrorListener:Et,BailErrorStrategy:bt,DefaultErrorStrategy:Mt,ErrorListener:Oe};class Nt{constructor(e,t){if(this.name="<empty>",this.strdata=e,this.decodeToUnicodeCodePoints=t||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let e=0;e<this.strdata.length;){const t=this.strdata.codePointAt(e);this.data.push(t),e+=t<=65535?1:2}else{this.data=new Array(this.strdata.length);for(let e=0;e<this.strdata.length;e++)this.data[e]=this.strdata.charCodeAt(e)}this._size=this.data.length}reset(){this._index=0}consume(){if(this._index>=this._size)throw"cannot consume EOF";this._index+=1}LA(e){if(0===e)return 0;e<0&&(e+=1);const t=this._index+e-1;return t<0||t>=this._size?o.EOF:this.data[t]}LT(e){return this.LA(e)}mark(){return-1}release(e){}seek(e){e<=this._index?this._index=e:this._index=Math.min(e,this._size)}getText(e,t){if(t>=this._size&&(t=this._size-1),e>=this._size)return"";if(this.decodeToUnicodeCodePoints){let r="";for(let n=e;n<=t;n++)r+=String.fromCodePoint(this.data[n]);return r}return this.strdata.slice(e,t+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}class wt extends Nt{constructor(e,t){super(e,t)}}var It=a(763);const Pt="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;class Ot extends wt{static fromPath(e,t,r){if(!Pt)throw new Error("FileStream is only available when running in Node!");It.readFile(e,t,function(e,t){let n=null;null!==t&&(n=new Nt(t,!0)),r(e,n)})}constructor(e,t,r){if(!Pt)throw new Error("FileStream is only available when running in Node!");super(It.readFileSync(e,t||"utf-8"),r),this.fileName=e}}const Rt={fromString:function(e){return new Nt(e,!0)},fromBlob:function(e,t,r,n){const i=new window.FileReader;i.onload=function(e){const t=new Nt(e.target.result,!0);r(t)},i.onerror=n,i.readAsText(e,t)},fromBuffer:function(e,t){return new Nt(e.toString(t),!0)},fromPath:function(e,t,r){Ot.fromPath(e,t,r)},fromPathSync:function(e,t){return new Ot(e,t)}},vt={arrayToString:x,stringToCharArray:function(e){let t=new Uint16Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}};class Dt{}class Ft extends Dt{constructor(e){super(),this.tokenSource=e,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(e){}reset(){this.seek(0)}seek(e){this.lazyInit(),this.index=this.adjustSeekIndex(e)}get size(){return this.tokens.length}get(e){return this.lazyInit(),this.tokens[e]}consume(){let e=!1;if(e=this.index>=0&&(this.fetchedEOF?this.index<this.tokens.length-1:this.index<this.tokens.length),!e&&this.LA(1)===o.EOF)throw"cannot consume EOF";this.sync(this.index+1)&&(this.index=this.adjustSeekIndex(this.index+1))}sync(e){const t=e-this.tokens.length+1;return!(t>0)||this.fetch(t)>=t}fetch(e){if(this.fetchedEOF)return 0;for(let t=0;t<e;t++){const e=this.tokenSource.nextToken();if(e.tokenIndex=this.tokens.length,this.tokens.push(e),e.type===o.EOF)return this.fetchedEOF=!0,t+1}return e}getTokens(e,t,r){if(void 0===r&&(r=null),e<0||t<0)return null;this.lazyInit();const n=[];t>=this.tokens.length&&(t=this.tokens.length-1);for(let i=e;i<t;i++){const e=this.tokens[i];if(e.type===o.EOF)break;(null===r||r.contains(e.type))&&n.push(e)}return n}LA(e){return this.LT(e).type}LB(e){return this.index-e<0?null:this.tokens[this.index-e]}LT(e){if(this.lazyInit(),0===e)return null;if(e<0)return this.LB(-e);const t=this.index+e-1;return this.sync(t),t>=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[t]}adjustSeekIndex(e){return e}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(e){this.tokenSource=e,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(e,t){if(this.sync(e),e>=this.tokens.length)return-1;let r=this.tokens[e];for(;r.channel!==t;){if(r.type===o.EOF)return-1;e+=1,this.sync(e),r=this.tokens[e]}return e}previousTokenOnChannel(e,t){for(;e>=0&&this.tokens[e].channel!==t;)e-=1;return e}getHiddenTokensToRight(e,t){if(void 0===t&&(t=-1),this.lazyInit(),e<0||e>=this.tokens.length)throw e+" not in 0.."+this.tokens.length-1;const r=this.nextTokenOnChannel(e+1,ze.DEFAULT_TOKEN_CHANNEL),n=e+1,i=-1===r?this.tokens.length-1:r;return this.filterForChannel(n,i,t)}getHiddenTokensToLeft(e,t){if(void 0===t&&(t=-1),this.lazyInit(),e<0||e>=this.tokens.length)throw e+" not in 0.."+this.tokens.length-1;const r=this.previousTokenOnChannel(e-1,ze.DEFAULT_TOKEN_CHANNEL);if(r===e-1)return null;const n=r+1,i=e-1;return this.filterForChannel(n,i,t)}filterForChannel(e,t,r){const n=[];for(let i=e;i<t+1;i++){const e=this.tokens[i];-1===r?e.channel!==ze.DEFAULT_TOKEN_CHANNEL&&n.push(e):e.channel===r&&n.push(e)}return 0===n.length?null:n}getSourceName(){return this.tokenSource.getSourceName()}getText(e){this.lazyInit(),this.fill(),e||(e=new L(0,this.tokens.length-1));let t=e.start;t instanceof o&&(t=t.tokenIndex);let r=e.stop;if(r instanceof o&&(r=r.tokenIndex),null===t||null===r||t<0||r<0)return"";r>=this.tokens.length&&(r=this.tokens.length-1);let n="";for(let e=t;e<r+1;e++){const t=this.tokens[e];if(t.type===o.EOF)break;n+=t.text}return n}fill(){for(this.lazyInit();1e3===this.fetch(1e3););}}Object.defineProperty(Ft,"size",{get:function(){return this.tokens.length}});class kt extends Ft{constructor(e,t){super(e),this.channel=void 0===t?o.DEFAULT_CHANNEL:t}adjustSeekIndex(e){return this.nextTokenOnChannel(e,this.channel)}LB(e){if(0===e||this.index-e<0)return null;let t=this.index,r=1;for(;r<=e;)t=this.previousTokenOnChannel(t-1,this.channel),r+=1;return t<0?null:this.tokens[t]}LT(e){if(this.lazyInit(),0===e)return null;if(e<0)return this.LB(-e);let t=this.index,r=1;for(;r<e;)this.sync(t+1)&&(t=this.nextTokenOnChannel(t+1,this.channel)),r+=1;return this.tokens[t]}getNumberOfOnChannelTokens(){let e=0;this.fill();for(let t=0;t<this.tokens.length;t++){const r=this.tokens[t];if(r.channel===this.channel&&(e+=1),r.type===o.EOF)break}return e}}class Ut extends xt{constructor(e){super(),this.parser=e}enterEveryRule(e){console.log("enter   "+this.parser.ruleNames[e.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}visitTerminal(e){console.log("consume "+e.symbol+" rule "+this.parser.ruleNames[this.parser._ctx.ruleIndex])}exitEveryRule(e){console.log("exit    "+this.parser.ruleNames[e.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}}class Bt extends De{constructor(e){super(),this._input=null,this._errHandler=new Mt,this._precedenceStack=[],this._precedenceStack.push(0),this._ctx=null,this.buildParseTrees=!0,this._tracer=null,this._parseListeners=null,this._syntaxErrors=0,this.setInputStream(e)}reset(){null!==this._input&&this._input.seek(0),this._errHandler.reset(this),this._ctx=null,this._syntaxErrors=0,this.setTrace(!1),this._precedenceStack=[],this._precedenceStack.push(0),null!==this._interp&&this._interp.reset()}match(e){let t=this.getCurrentToken();return t.type===e?(this._errHandler.reportMatch(this),this.consume()):(t=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===t.tokenIndex&&this._ctx.addErrorNode(t)),t}matchWildcard(){let e=this.getCurrentToken();return e.type>0?(this._errHandler.reportMatch(this),this.consume()):(e=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===e.tokenIndex&&this._ctx.addErrorNode(e)),e}getParseListeners(){return this._parseListeners||[]}addParseListener(e){if(null===e)throw"listener";null===this._parseListeners&&(this._parseListeners=[]),this._parseListeners.push(e)}removeParseListener(e){if(null!==this._parseListeners){const t=this._parseListeners.indexOf(e);t>=0&&this._parseListeners.splice(t,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const e=this._ctx;this._parseListeners.forEach(function(t){t.enterEveryRule(e),e.enterRule(t)})}}triggerExitRuleEvent(){if(null!==this._parseListeners){const e=this._ctx;this._parseListeners.slice(0).reverse().forEach(function(t){e.exitRule(t),t.exitEveryRule(e)})}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(e){this._input.tokenSource._factory=e}getATNWithBypassAlts(){const e=this.getSerializedATN();if(null===e)throw"The current parser does not support an ATN with bypass alternatives.";let t=this.bypassAltsAtnCache[e];if(null===t){const r=new ye;r.generateRuleBypassTransitions=!0,t=new Pe(r).deserialize(e),this.bypassAltsAtnCache[e]=t}return t}getInputStream(){return this.getTokenStream()}setInputStream(e){this.setTokenStream(e)}getTokenStream(){return this._input}setTokenStream(e){this._input=null,this.reset(),this._input=e}get syntaxErrorsCount(){return this._syntaxErrors}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(e,t,r){r=r||null,null===(t=t||null)&&(t=this.getCurrentToken()),this._syntaxErrors+=1;const n=t.line,i=t.column;this.getErrorListener().syntaxError(this,t,n,i,e,r)}consume(){const e=this.getCurrentToken();e.type!==o.EOF&&this.getInputStream().consume();const t=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||t){let r;r=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(e):this._ctx.addTokenNode(e),r.invokingState=this.state,t&&this._parseListeners.forEach(function(e){r instanceof U||void 0!==r.isErrorNode&&r.isErrorNode()?e.visitErrorNode(r):r instanceof k&&e.visitTerminal(r)})}return e}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(e,t,r){this.state=t,this._ctx=e,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(e,t){e.setAltNumber(t),this.buildParseTrees&&this._ctx!==e&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(e)),this._ctx=e}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(e,t,r,n){this.state=t,this._precedenceStack.push(n),this._ctx=e,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(e,t,r){const n=this._ctx;n.parentCtx=e,n.invokingState=t,n.stop=this._input.LT(-1),this._ctx=e,this._ctx.start=n.start,this.buildParseTrees&&this._ctx.addChild(n),this.triggerEnterRuleEvent()}unrollRecursionContexts(e){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const t=this._ctx,r=this.getParseListeners();if(null!==r&&r.length>0)for(;this._ctx!==e;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=e;t.parentCtx=e,this.buildParseTrees&&null!==e&&e.addChild(t)}getInvokingContext(e){let t=this._ctx;for(;null!==t;){if(t.ruleIndex===e)return t;t=t.parentCtx}return null}precpred(e,t){return t>=this._precedenceStack[this._precedenceStack.length-1]}inContext(e){return!1}isExpectedToken(e){const t=this._interp.atn;let r=this._ctx;const n=t.states[this.state];let i=t.nextTokens(n);if(i.contains(e))return!0;if(!i.contains(o.EPSILON))return!1;for(;null!==r&&r.invokingState>=0&&i.contains(o.EPSILON);){const n=t.states[r.invokingState].transitions[0];if(i=t.nextTokens(n.followState),i.contains(e))return!0;r=r.parentCtx}return!(!i.contains(o.EPSILON)||e!==o.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const e=this._interp.atn,t=e.states[this.state];return e.nextTokens(t)}getRuleIndex(e){const t=this.getRuleIndexMap()[e];return null!==t?t:-1}getRuleInvocationStack(e){null===(e=e||null)&&(e=this._ctx);const t=[];for(;null!==e;){const r=e.ruleIndex;r<0?t.push("n/a"):t.push(this.ruleNames[r]),e=e.parentCtx}return t}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let e=!1;for(let t=0;t<this._interp.decisionToDFA.length;t++){const r=this._interp.decisionToDFA[t];r.states.length>0&&(e&&console.log(),this.printer.println("Decision "+r.decision+":"),this.printer.print(r.toString(this.literalNames,this.symbolicNames)),e=!0)}}getSourceName(){return this._input.getSourceName()}setTrace(e){e?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new Ut(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}Bt.bypassAltsAtnCache={};class Kt extends k{constructor(e){super(),this.parentCtx=null,this.symbol=e}getChild(e){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return L.INVALID_INTERVAL;const e=this.symbol.tokenIndex;return new L(e,e)}getChildCount(){return 0}accept(e){return e.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===o.EOF?"<EOF>":this.symbol.text}}class zt extends Kt{constructor(e){super(e)}isErrorNode(){return!0}accept(e){return e.visitErrorNode(this)}}class qt extends z{constructor(e,t){super(e,t),this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(e){this.parentCtx=e.parentCtx,this.invokingState=e.invokingState,this.children=null,this.start=e.start,this.stop=e.stop,e.children&&(this.children=[],e.children.map(function(e){e instanceof zt&&(this.children.push(e),e.parentCtx=this)},this))}enterRule(e){}exitRule(e){}addChild(e){return null===this.children&&(this.children=[]),this.children.push(e),e}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(e){const t=new Kt(e);return this.addChild(t),t.parentCtx=this,t}addErrorNode(e){const t=new zt(e);return this.addChild(t),t.parentCtx=this,t}getChild(e,t){if(t=t||null,null===this.children||e<0||e>=this.children.length)return null;if(null===t)return this.children[e];for(let r=0;r<this.children.length;r++){const n=this.children[r];if(n instanceof t){if(0===e)return n;e-=1}}return null}getToken(e,t){if(null===this.children||t<0||t>=this.children.length)return null;for(let r=0;r<this.children.length;r++){const n=this.children[r];if(n instanceof k&&n.symbol.type===e){if(0===t)return n;t-=1}}return null}getTokens(e){if(null===this.children)return[];{const t=[];for(let r=0;r<this.children.length;r++){const n=this.children[r];n instanceof k&&n.symbol.type===e&&t.push(n)}return t}}getTypedRuleContext(e,t){return this.getChild(t,e)}getTypedRuleContexts(e){if(null===this.children)return[];{const t=[];for(let r=0;r<this.children.length;r++){const n=this.children[r];n instanceof e&&t.push(n)}return t}}getChildCount(){return null===this.children?0:this.children.length}getSourceInterval(){return null===this.start||null===this.stop?L.INVALID_INTERVAL:new L(this.start.tokenIndex,this.stop.tokenIndex)}}z.EMPTY=new qt;class Jt{static DEFAULT_PROGRAM_NAME="default";constructor(e){this.tokens=e,this.programs=new Map}getTokenStream(){return this.tokens}insertAfter(e,t){let r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jt.DEFAULT_PROGRAM_NAME;r="number"==typeof e?e:e.tokenIndex;let i=this.getProgram(n),a=new jt(this.tokens,r,i.length,t);i.push(a)}insertBefore(e,t){let r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jt.DEFAULT_PROGRAM_NAME;r="number"==typeof e?e:e.tokenIndex;const i=this.getProgram(n),a=new Ht(this.tokens,r,i.length,t);i.push(a)}replaceSingle(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jt.DEFAULT_PROGRAM_NAME;this.replace(e,e,t,r)}replace(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Jt.DEFAULT_PROGRAM_NAME;if("number"!=typeof e&&(e=e.tokenIndex),"number"!=typeof t&&(t=t.tokenIndex),e>t||e<0||t<0||t>=this.tokens.size)throw new RangeError(`replace: range invalid: ${e}..${t}(size=${this.tokens.size})`);let i=this.getProgram(n),a=new Gt(this.tokens,e,t,i.length,r);i.push(a)}delete(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jt.DEFAULT_PROGRAM_NAME;void 0===t&&(t=e),this.replace(e,t,null,r)}getProgram(e){let t=this.programs.get(e);return null==t&&(t=this.initializeProgram(e)),t}initializeProgram(e){const t=[];return this.programs.set(e,t),t}getText(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt.DEFAULT_PROGRAM_NAME;t=e instanceof L?e:new L(0,this.tokens.size-1),"string"==typeof e&&(r=e);const n=this.programs.get(r);let i=t.start,a=t.stop;if(a>this.tokens.size-1&&(a=this.tokens.size-1),i<0&&(i=0),null==n||0===n.length)return this.tokens.getText(new L(i,a));let s=[],l=this.reduceToSingleOperationPerIndex(n),c=i;for(;c<=a&&c<this.tokens.size;){let e=l.get(c);l.delete(c);let t=this.tokens.get(c);null==e?(t.type!==o.EOF&&s.push(String(t.text)),c++):c=e.execute(s)}if(a===this.tokens.size-1)for(const e of l.values())e.index>=this.tokens.size-1&&s.push(e.text.toString());return s.join("")}reduceToSingleOperationPerIndex(e){for(let t=0;t<e.length;t++){let r=e[t];if(null==r)continue;if(!(r instanceof Gt))continue;let n=r,i=this.getKindOfOps(e,Ht,t);for(let t of i)t.index===n.index?(e[t.instructionIndex]=void 0,n.text=t.text.toString()+(null!=n.text?n.text.toString():"")):t.index>n.index&&t.index<=n.lastIndex&&(e[t.instructionIndex]=void 0);let a=this.getKindOfOps(e,Gt,t);for(let t of a){if(t.index>=n.index&&t.lastIndex<=n.lastIndex){e[t.instructionIndex]=void 0;continue}let r=t.lastIndex<n.index||t.index>n.lastIndex;if(null!=t.text||null!=n.text||r){if(!r)throw new Error(`replace op boundaries of ${n} overlap with previous ${t}`)}else e[t.instructionIndex]=void 0,n.index=Math.min(t.index,n.index),n.lastIndex=Math.max(t.lastIndex,n.lastIndex)}}for(let t=0;t<e.length;t++){let r=e[t];if(null==r)continue;if(!(r instanceof Ht))continue;let n=r,i=this.getKindOfOps(e,Ht,t);for(let t of i)t.index===n.index&&(t instanceof jt?(n.text=this.catOpText(t.text,n.text),e[t.instructionIndex]=void 0):t instanceof Ht&&(n.text=this.catOpText(n.text,t.text),e[t.instructionIndex]=void 0));let a=this.getKindOfOps(e,Gt,t);for(let r of a)if(n.index!==r.index){if(n.index>=r.index&&n.index<=r.lastIndex)throw new Error(`insert op ${n} within boundaries of previous ${r}`)}else r.text=this.catOpText(n.text,r.text),e[t]=void 0}let t=new Map;for(let r of e)if(null!=r){if(null!=t.get(r.index))throw new Error("should only be one op per index");t.set(r.index,r)}return t}catOpText(e,t){let r="",n="";return null!=e&&(r=e.toString()),null!=t&&(n=t.toString()),r+n}getKindOfOps(e,t,r){return e.slice(0,r).filter(e=>e&&e instanceof t)}}class Vt{constructor(e,t,r,n){this.tokens=e,this.instructionIndex=r,this.index=t,this.text=void 0===n?"":n}toString(){let e=this.constructor.name;const t=e.indexOf("$");return e=e.substring(t+1,e.length),"<"+e+"@"+this.tokens.get(this.index)+':"'+this.text+'">'}}class Ht extends Vt{constructor(e,t,r,n){super(e,t,r,n)}execute(e){return this.text&&e.push(this.text.toString()),this.tokens.get(this.index).type!==o.EOF&&e.push(String(this.tokens.get(this.index).text)),this.index+1}}class jt extends Ht{constructor(e,t,r,n){super(e,t+1,r,n)}}class Gt extends Vt{constructor(e,t,r,n,i){super(e,t,n,i),this.lastIndex=r}execute(e){return this.text&&e.push(this.text.toString()),this.lastIndex+1}toString(){return null==this.text?"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">":"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}}const Qt={atn:lt,dfa:ht,context:pt,misc:dt,tree:gt,error:St,Token:o,CommonToken:Fe,CharStreams:Rt,CharStream:Nt,InputStream:wt,CommonTokenStream:kt,Lexer:ze,Parser:Bt,ParserRuleContext:qt,Interval:L,IntervalSet:T,LL1Analyzer:W,Utils:vt,TokenStreamRewriter:Jt};var Zt=s.MG,$t=s.fr,Wt=s.iH,Xt=s.jB,Yt=s.M8,er=s.pG,tr=s.eP,rr=s.JG,nr=s.ay,ir=s.X2,ar=s.iX,sr=s.re,or=s.Pg,lr=s.tD,cr=s.Dj,ur=s.ou},207(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{A:()=>MathJSLabLexer});var antlr4__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(168);class MathJSLabLexer extends antlr4__WEBPACK_IMPORTED_MODULE_0__.JG{static GLOBAL=1;static PERSISTENT=2;static IF=3;static ENDIF=4;static END=5;static ENDRANGE=6;static ELSEIF=7;static ELSE=8;static SWITCH=9;static ENDSWITCH=10;static CASE=11;static OTHERWISE=12;static WHILE=13;static ENDWHILE=14;static DO=15;static UNTIL=16;static FOR=17;static ENDFOR=18;static PARFOR=19;static ENDPARFOR=20;static BREAK=21;static CONTINUE=22;static RETURN=23;static FUNCTION=24;static ENDFUNCTION=25;static TRY=26;static CATCH=27;static END_TRY_CATCH=28;static UNWIND_PROTECT=29;static UNWIND_PROTECT_CLEANUP=30;static END_UNWIND_PROTECT=31;static CLASSDEF=32;static ENDCLASSDEF=33;static ENUMERATION=34;static ENDENUMERATION=35;static PROPERTIES=36;static ENDPROPERTIES=37;static EVENTS=38;static ENDEVENTS=39;static METHODS=40;static ENDMETHODS=41;static WSPACE=42;static STRING=43;static ARGUMENTS=44;static PLUS=45;static MINUS=46;static MUL=47;static DIV=48;static EQ=49;static COLON=50;static SEMICOLON=51;static COMMA=52;static DOT=53;static TILDE=54;static EXCLAMATION=55;static COMMAT=56;static LPAREN=57;static RPAREN=58;static LBRACKET=59;static RBRACKET=60;static LCURLYBR=61;static RCURLYBR=62;static LEFTDIV=63;static ADD_EQ=64;static SUB_EQ=65;static MUL_EQ=66;static DIV_EQ=67;static LEFTDIV_EQ=68;static POW_EQ=69;static EMUL_EQ=70;static EDIV_EQ=71;static ELEFTDIV_EQ=72;static EPOW_EQ=73;static AND_EQ=74;static OR_EQ=75;static EXPR_AND_AND=76;static EXPR_OR_OR=77;static EXPR_AND=78;static EXPR_OR=79;static EXPR_LT=80;static EXPR_LE=81;static EXPR_EQ=82;static EXPR_NE=83;static EXPR_GE=84;static EXPR_GT=85;static EMUL=86;static EDIV=87;static ELEFTDIV=88;static PLUS_PLUS=89;static MINUS_MINUS=90;static POW=91;static EPOW=92;static TRANSPOSE=93;static HERMITIAN=94;static DQSTRING=95;static IDENTIFIER=96;static FLOAT_NUMBER=97;static NUMBER_DOT_OP=98;static SPACE_OR_CONTINUATION=99;static NEWLINE=100;static BLOCK_COMMENT_START=101;static COMMENT_LINE=102;static INVALID=103;static SINGLEQ_STRING=104;static SINGLEQ_NL=105;static SINGLEQ_SINGLEQ=106;static SINGLEQ_END=107;static DOUBLEQ_STRING=108;static DOUBLEQ_NL=109;static DOUBLEQ_DOUBLEQ=110;static DOUBLEQ_ESCAPE=111;static DOUBLEQ_ESCAPE_OTHER=112;static DOUBLEQ_ESCAPE_OCT=113;static DOUBLEQ_ESCAPE_HEX=114;static DOUBLEQ_ESCAPE_UNICODE=115;static DOUBLEQ_END=116;static BLOCK_COMMENT_START_AGAIN=117;static BLOCK_COMMENT_END=118;static BLOCK_COMMENT_LINE=119;static BLOCK_COMMENT_EOF=120;static SKIP_SPACE=121;static SKIP_COMMENT_LINE=122;static EXIT_AT_NEWLINE=123;static EXIT_AT_EOF=124;static UNQUOTED_STRING=125;static EOF=antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF;static SQ_STRING=1;static DQ_STRING=2;static BLOCK_COMMENT=3;static ANY_AS_STRING_UNTIL_END_OF_LINE=4;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","SKIP_SPACE","SKIP_COMMENT_LINE","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static modeNames=["DEFAULT_MODE","SQ_STRING","DQ_STRING","BLOCK_COMMENT","ANY_AS_STRING_UNTIL_END_OF_LINE"];static ruleNames=["PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","SKIP_SPACE","SKIP_COMMENT_LINE","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING","CCHAR","NL","SPACE","IDENT","FQIDENT","REAL_NUMBER","INTEGER_NUMBER","INTEGER_DIGITS","DECIMAL_DIGITS","BINARY_DIGITS","OCTAL_DIGITS","HEXADECIMAL_DIGITS","EXPONENT"];static keywordNames=[null,"global","persistent","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","break","continue","return","function","endfunction","try","catch","end_try_catch","unwind_protect","unwind_protect_cleanup","end_unwind_protect","classdef","endclassdef","enumeration","endenumeration","properties","endproperties","events","endevents","methods","endmethods","arguments"];static keywordTypes=[NaN,MathJSLabLexer.GLOBAL,MathJSLabLexer.PERSISTENT,MathJSLabLexer.IF,MathJSLabLexer.ENDIF,MathJSLabLexer.END,MathJSLabLexer.ELSEIF,MathJSLabLexer.ELSE,MathJSLabLexer.SWITCH,MathJSLabLexer.ENDSWITCH,MathJSLabLexer.CASE,MathJSLabLexer.OTHERWISE,MathJSLabLexer.WHILE,MathJSLabLexer.ENDWHILE,MathJSLabLexer.DO,MathJSLabLexer.UNTIL,MathJSLabLexer.FOR,MathJSLabLexer.ENDFOR,MathJSLabLexer.PARFOR,MathJSLabLexer.ENDPARFOR,MathJSLabLexer.BREAK,MathJSLabLexer.CONTINUE,MathJSLabLexer.RETURN,MathJSLabLexer.FUNCTION,MathJSLabLexer.ENDFUNCTION,MathJSLabLexer.TRY,MathJSLabLexer.CATCH,MathJSLabLexer.END_TRY_CATCH,MathJSLabLexer.UNWIND_PROTECT,MathJSLabLexer.UNWIND_PROTECT_CLEANUP,MathJSLabLexer.END_UNWIND_PROTECT,MathJSLabLexer.CLASSDEF,MathJSLabLexer.ENDCLASSDEF,MathJSLabLexer.ENUMERATION,MathJSLabLexer.ENDENUMERATION,MathJSLabLexer.PROPERTIES,MathJSLabLexer.ENDPROPERTIES,MathJSLabLexer.EVENTS,MathJSLabLexer.ENDEVENTS,MathJSLabLexer.METHODS,MathJSLabLexer.ENDMETHODS,MathJSLabLexer.ARGUMENTS];commandNames=[];static nonTerminalSign=[MathJSLabLexer.PLUS,MathJSLabLexer.MINUS,MathJSLabLexer.MUL,MathJSLabLexer.DIV,MathJSLabLexer.EQ,MathJSLabLexer.DOT,MathJSLabLexer.TILDE,MathJSLabLexer.EXCLAMATION,MathJSLabLexer.COMMAT,MathJSLabLexer.LPAREN,MathJSLabLexer.LBRACKET,MathJSLabLexer.LCURLYBR,MathJSLabLexer.LEFTDIV,MathJSLabLexer.ADD_EQ,MathJSLabLexer.SUB_EQ,MathJSLabLexer.MUL_EQ,MathJSLabLexer.DIV_EQ,MathJSLabLexer.LEFTDIV_EQ,MathJSLabLexer.POW_EQ,MathJSLabLexer.EMUL_EQ,MathJSLabLexer.EDIV_EQ,MathJSLabLexer.ELEFTDIV_EQ,MathJSLabLexer.EPOW_EQ,MathJSLabLexer.AND_EQ,MathJSLabLexer.OR_EQ,MathJSLabLexer.EXPR_AND_AND,MathJSLabLexer.EXPR_OR_OR,MathJSLabLexer.EXPR_AND,MathJSLabLexer.EXPR_OR,MathJSLabLexer.EXPR_LT,MathJSLabLexer.EXPR_LE,MathJSLabLexer.EXPR_EQ,MathJSLabLexer.EXPR_NE,MathJSLabLexer.EXPR_GE,MathJSLabLexer.EXPR_GT,MathJSLabLexer.EMUL,MathJSLabLexer.EDIV,MathJSLabLexer.ELEFTDIV,MathJSLabLexer.PLUS_PLUS,MathJSLabLexer.MINUS_MINUS,MathJSLabLexer.POW,MathJSLabLexer.EPOW];previousTokenType=antlr4__WEBPACK_IMPORTED_MODULE_0__.ou.EOF;parenthesisCount=0;matrixContext=[];quotedString="";constructor(e){super(e),this._interp=new antlr4__WEBPACK_IMPORTED_MODULE_0__.ay(this,MathJSLabLexer._ATN,MathJSLabLexer.DecisionsToDFA,new antlr4__WEBPACK_IMPORTED_MODULE_0__.tD)}get grammarFileName(){return"MathJSLabLexer.g4"}get literalNames(){return MathJSLabLexer.literalNames}get symbolicNames(){return MathJSLabLexer.symbolicNames}get ruleNames(){return MathJSLabLexer.ruleNames}get serializedATN(){return MathJSLabLexer._serializedATN}get channelNames(){return MathJSLabLexer.channelNames}get modeNames(){return MathJSLabLexer.modeNames}action(e,t,r){switch(t){case 0:this.PLUS_action(e,r);break;case 1:this.MINUS_action(e,r);break;case 2:this.MUL_action(e,r);break;case 3:this.DIV_action(e,r);break;case 4:this.EQ_action(e,r);break;case 5:this.COLON_action(e,r);break;case 6:this.SEMICOLON_action(e,r);break;case 7:this.COMMA_action(e,r);break;case 8:this.DOT_action(e,r);break;case 9:this.TILDE_action(e,r);break;case 10:this.EXCLAMATION_action(e,r);break;case 11:this.COMMAT_action(e,r);break;case 12:this.LPAREN_action(e,r);break;case 13:this.RPAREN_action(e,r);break;case 14:this.LBRACKET_action(e,r);break;case 15:this.RBRACKET_action(e,r);break;case 16:this.LCURLYBR_action(e,r);break;case 17:this.RCURLYBR_action(e,r);break;case 18:this.LEFTDIV_action(e,r);break;case 19:this.ADD_EQ_action(e,r);break;case 20:this.SUB_EQ_action(e,r);break;case 21:this.MUL_EQ_action(e,r);break;case 22:this.DIV_EQ_action(e,r);break;case 23:this.LEFTDIV_EQ_action(e,r);break;case 24:this.POW_EQ_action(e,r);break;case 25:this.EMUL_EQ_action(e,r);break;case 26:this.EDIV_EQ_action(e,r);break;case 27:this.ELEFTDIV_EQ_action(e,r);break;case 28:this.EPOW_EQ_action(e,r);break;case 29:this.AND_EQ_action(e,r);break;case 30:this.OR_EQ_action(e,r);break;case 31:this.EXPR_AND_AND_action(e,r);break;case 32:this.EXPR_OR_OR_action(e,r);break;case 33:this.EXPR_AND_action(e,r);break;case 34:this.EXPR_OR_action(e,r);break;case 35:this.EXPR_LT_action(e,r);break;case 36:this.EXPR_LE_action(e,r);break;case 37:this.EXPR_EQ_action(e,r);break;case 38:this.EXPR_NE_action(e,r);break;case 39:this.EXPR_GE_action(e,r);break;case 40:this.EXPR_GT_action(e,r);break;case 41:this.EMUL_action(e,r);break;case 42:this.EDIV_action(e,r);break;case 43:this.ELEFTDIV_action(e,r);break;case 44:this.PLUS_PLUS_action(e,r);break;case 45:this.MINUS_MINUS_action(e,r);break;case 46:this.POW_action(e,r);break;case 47:this.EPOW_action(e,r);break;case 48:this.TRANSPOSE_action(e,r);break;case 49:this.HERMITIAN_action(e,r);break;case 50:this.DQSTRING_action(e,r);break;case 51:this.IDENTIFIER_action(e,r);break;case 52:this.FLOAT_NUMBER_action(e,r);break;case 53:this.NUMBER_DOT_OP_action(e,r);break;case 54:this.SPACE_OR_CONTINUATION_action(e,r);break;case 55:this.NEWLINE_action(e,r);break;case 56:this.BLOCK_COMMENT_START_action(e,r);break;case 57:this.COMMENT_LINE_action(e,r);break;case 59:this.SINGLEQ_STRING_action(e,r);break;case 60:this.SINGLEQ_NL_action(e,r);break;case 61:this.SINGLEQ_SINGLEQ_action(e,r);break;case 62:this.SINGLEQ_END_action(e,r);break;case 63:this.DOUBLEQ_STRING_action(e,r);break;case 64:this.DOUBLEQ_NL_action(e,r);break;case 65:this.DOUBLEQ_DOUBLEQ_action(e,r);break;case 66:this.DOUBLEQ_ESCAPE_action(e,r);break;case 67:this.DOUBLEQ_ESCAPE_OTHER_action(e,r);break;case 68:this.DOUBLEQ_ESCAPE_OCT_action(e,r);break;case 69:this.DOUBLEQ_ESCAPE_HEX_action(e,r);break;case 70:this.DOUBLEQ_ESCAPE_UNICODE_action(e,r);break;case 71:this.DOUBLEQ_END_action(e,r);break;case 72:this.BLOCK_COMMENT_START_AGAIN_action(e,r);break;case 73:this.BLOCK_COMMENT_END_action(e,r);break;case 75:this.BLOCK_COMMENT_EOF_action(e,r);break;case 78:this.EXIT_AT_NEWLINE_action(e,r);break;case 79:this.EXIT_AT_EOF_action(e,r);break;case 80:this.UNQUOTED_STRING_action(e,r)}}PLUS_action(e,t){0===t&&(this.previousTokenType=MathJSLabLexer.PLUS)}MINUS_action(e,t){1===t&&(this.previousTokenType=MathJSLabLexer.MINUS)}MUL_action(e,t){2===t&&(this.previousTokenType=MathJSLabLexer.MUL)}DIV_action(e,t){3===t&&(this.previousTokenType=MathJSLabLexer.DIV)}EQ_action(e,t){4===t&&(this.previousTokenType=MathJSLabLexer.EQ)}COLON_action(e,t){5===t&&(this.previousTokenType=MathJSLabLexer.COLON)}SEMICOLON_action(e,t){6===t&&(this.previousTokenType=MathJSLabLexer.SEMICOLON)}COMMA_action(e,t){7===t&&(this.previousTokenType=MathJSLabLexer.COMMA)}DOT_action(e,t){8===t&&(this.previousTokenType=MathJSLabLexer.DOT)}TILDE_action(e,t){9===t&&(this.previousTokenType=MathJSLabLexer.TILDE)}EXCLAMATION_action(e,t){10===t&&(this.previousTokenType=MathJSLabLexer.EXCLAMATION)}COMMAT_action(e,t){11===t&&(this.previousTokenType=MathJSLabLexer.COMMAT)}LPAREN_action(e,t){12===t&&(this.matrixContext.length>0&&this.matrixContext.push(MathJSLabLexer.LPAREN),this.parenthesisCount++,this.previousTokenType=MathJSLabLexer.LPAREN)}RPAREN_action(e,t){13===t&&(this.matrixContext.length>0&&this.matrixContext.pop(),this.parenthesisCount--,this.previousTokenType=MathJSLabLexer.RPAREN)}LBRACKET_action(e,t){14===t&&(this.matrixContext.push(MathJSLabLexer.LBRACKET),this.previousTokenType=MathJSLabLexer.LBRACKET)}RBRACKET_action(e,t){15===t&&(this.matrixContext.pop(),this.previousTokenType=MathJSLabLexer.RBRACKET)}LCURLYBR_action(e,t){16===t&&(this.matrixContext.push(MathJSLabLexer.LCURLYBR),this.previousTokenType=MathJSLabLexer.LCURLYBR)}RCURLYBR_action(e,t){17===t&&(this.matrixContext.pop(),this.previousTokenType=MathJSLabLexer.RCURLYBR)}LEFTDIV_action(e,t){18===t&&(this.previousTokenType=MathJSLabLexer.LEFTDIV)}ADD_EQ_action(e,t){19===t&&(this.previousTokenType=MathJSLabLexer.ADD_EQ)}SUB_EQ_action(e,t){20===t&&(this.previousTokenType=MathJSLabLexer.SUB_EQ)}MUL_EQ_action(e,t){21===t&&(this.previousTokenType=MathJSLabLexer.MUL_EQ)}DIV_EQ_action(e,t){22===t&&(this.previousTokenType=MathJSLabLexer.DIV_EQ)}LEFTDIV_EQ_action(e,t){23===t&&(this.previousTokenType=MathJSLabLexer.LEFTDIV_EQ)}POW_EQ_action(e,t){24===t&&(this.previousTokenType=MathJSLabLexer.POW_EQ)}EMUL_EQ_action(e,t){25===t&&(this.previousTokenType=MathJSLabLexer.EMUL_EQ)}EDIV_EQ_action(e,t){26===t&&(this.previousTokenType=MathJSLabLexer.EDIV_EQ)}ELEFTDIV_EQ_action(e,t){27===t&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV_EQ)}EPOW_EQ_action(e,t){28===t&&(this.previousTokenType=MathJSLabLexer.EPOW_EQ)}AND_EQ_action(e,t){29===t&&(this.previousTokenType=MathJSLabLexer.AND_EQ)}OR_EQ_action(e,t){30===t&&(this.previousTokenType=MathJSLabLexer.OR_EQ)}EXPR_AND_AND_action(e,t){31===t&&(this.previousTokenType=MathJSLabLexer.EXPR_AND_AND)}EXPR_OR_OR_action(e,t){32===t&&(this.previousTokenType=MathJSLabLexer.EXPR_OR_OR)}EXPR_AND_action(e,t){33===t&&(this.previousTokenType=MathJSLabLexer.EXPR_AND)}EXPR_OR_action(e,t){34===t&&(this.previousTokenType=MathJSLabLexer.EXPR_OR)}EXPR_LT_action(e,t){35===t&&(this.previousTokenType=MathJSLabLexer.EXPR_LT)}EXPR_LE_action(e,t){36===t&&(this.previousTokenType=MathJSLabLexer.EXPR_LE)}EXPR_EQ_action(e,t){37===t&&(this.previousTokenType=MathJSLabLexer.EXPR_EQ)}EXPR_NE_action(e,t){38===t&&(this.previousTokenType=MathJSLabLexer.EXPR_NE)}EXPR_GE_action(e,t){39===t&&(this.previousTokenType=MathJSLabLexer.EXPR_GE)}EXPR_GT_action(e,t){40===t&&(this.previousTokenType=MathJSLabLexer.EXPR_GT)}EMUL_action(e,t){41===t&&(this.previousTokenType=MathJSLabLexer.EMUL)}EDIV_action(e,t){42===t&&(this.previousTokenType=MathJSLabLexer.EDIV)}ELEFTDIV_action(e,t){43===t&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV)}PLUS_PLUS_action(e,t){44===t&&(this.previousTokenType=MathJSLabLexer.PLUS_PLUS)}MINUS_MINUS_action(e,t){45===t&&(this.previousTokenType=MathJSLabLexer.MINUS_MINUS)}POW_action(e,t){46===t&&(this.previousTokenType=MathJSLabLexer.POW)}EPOW_action(e,t){47===t&&(this.previousTokenType=MathJSLabLexer.EPOW)}TRANSPOSE_action(e,t){48===t&&(this.previousTokenType=MathJSLabLexer.TRANSPOSE)}HERMITIAN_action(e,t){49===t&&(this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER?this.previousTokenType=MathJSLabLexer.HERMITIAN:(this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip()))}DQSTRING_action(e,t){50===t&&(this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}IDENTIFIER_action(e,t){if(51===t)if(this.previousTokenType===MathJSLabLexer.DOT)this.previousTokenType=MathJSLabLexer.IDENTIFIER;else{let e=MathJSLabLexer.keywordNames.indexOf(this.text);e>=0?MathJSLabLexer.keywordTypes[e]===MathJSLabLexer.END?this._type=this.previousTokenType=this.parenthesisCount>0||this.matrixContext.length>0?MathJSLabLexer.ENDRANGE:MathJSLabLexer.END:this._type=this.previousTokenType=MathJSLabLexer.keywordTypes[e]:(e=this.commandNames.indexOf(this.text),e>=0&&this.pushMode(MathJSLabLexer.ANY_AS_STRING_UNTIL_END_OF_LINE),this.previousTokenType=MathJSLabLexer.IDENTIFIER)}}FLOAT_NUMBER_action(e,t){52===t&&(this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}NUMBER_DOT_OP_action(e,t){53===t&&(this._input.seek(this._input.index-2),this._type=this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}SPACE_OR_CONTINUATION_action(e,t){54===t&&(this.matrixContext.length>0&&this.previousTokenType!==MathJSLabLexer.LBRACKET&&this.previousTokenType!==MathJSLabLexer.COMMA&&this.previousTokenType!==MathJSLabLexer.SEMICOLON&&this.matrixContext[this.matrixContext.length-1]!==MathJSLabLexer.LPAREN&&MathJSLabLexer.nonTerminalSign.indexOf(this.previousTokenType)<0?this._type=this.previousTokenType=MathJSLabLexer.WSPACE:this.skip())}NEWLINE_action(e,t){55===t&&(this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this.previousTokenType=MathJSLabLexer.NEWLINE)}BLOCK_COMMENT_START_action(e,t){56===t&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}COMMENT_LINE_action(e,t){switch(t){case 57:this._type=this.previousTokenType=MathJSLabLexer.NEWLINE;break;case 58:this._type=this.previousTokenType=MathJSLabLexer.EOF}}SINGLEQ_STRING_action(e,t){59===t&&(this.quotedString+=this.text,this.skip())}SINGLEQ_NL_action(e,t){60===t&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}SINGLEQ_SINGLEQ_action(e,t){61===t&&(this.quotedString+="'",this.skip())}SINGLEQ_END_action(e,t){62===t&&(this.text=`'${this.quotedString}'`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}DOUBLEQ_STRING_action(e,t){63===t&&(this.quotedString+=this.text,this.skip())}DOUBLEQ_NL_action(e,t){64===t&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}DOUBLEQ_DOUBLEQ_action(e,t){65===t&&(this.quotedString+='"',this.skip())}DOUBLEQ_ESCAPE_action(e,t){66===t&&(this.quotedString+=JSON.parse(`"${this.text}"`),this.skip())}DOUBLEQ_ESCAPE_OTHER_action(e,t){67===t&&(this.quotedString+=this.text.substring(1),this.skip())}DOUBLEQ_ESCAPE_OCT_action(e,t){68===t&&(this.quotedString+=JSON.parse(`"\\u${parseInt(this.text.substring(1),8).toString(16).padStart(4,"0")}"`),this.skip())}DOUBLEQ_ESCAPE_HEX_action(localctx,actionIndex){69===actionIndex&&(this.quotedString+=eval(`"\\x${this.text.substring(2)}"`),this.skip())}DOUBLEQ_ESCAPE_UNICODE_action(e,t){70===t&&(this.quotedString+=JSON.parse(`"\\u${this.text.substring(2).padStart(4,"0")}"`),this.skip())}DOUBLEQ_END_action(e,t){71===t&&(this.text=`"${this.quotedString}"`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}BLOCK_COMMENT_START_AGAIN_action(e,t){72===t&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}BLOCK_COMMENT_END_action(e,t){73===t&&(this.popMode(),this.skip())}BLOCK_COMMENT_EOF_action(e,t){if(74===t)throw new SyntaxError("Block comment open at end of input.")}EXIT_AT_NEWLINE_action(e,t){75===t&&(this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}EXIT_AT_EOF_action(e,t){76===t&&(this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.EOF)}UNQUOTED_STRING_action(e,t){77===t&&(this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING)}static _serializedATN=[4,0,125,784,6,-1,6,-1,6,-1,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,7,91,2,92,7,92,2,93,7,93,1,0,1,0,1,0,1,1,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,3,24,281,8,24,1,24,1,24,1,25,1,25,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,3,28,310,8,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,34,1,34,1,34,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,3,38,357,8,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,41,1,41,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,3,46,397,8,46,1,46,1,46,1,47,1,47,1,47,1,47,1,47,3,47,406,8,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,52,1,52,3,52,426,8,52,1,52,1,52,1,53,1,53,1,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,54,5,54,441,8,54,10,54,12,54,444,9,54,1,54,3,54,447,8,54,1,54,1,54,1,55,1,55,1,55,1,56,3,56,455,8,56,1,56,1,56,1,56,3,56,460,8,56,1,56,1,56,1,56,1,57,1,57,5,57,467,8,57,10,57,12,57,470,9,57,1,57,1,57,1,57,1,57,1,57,3,57,477,8,57,1,58,1,58,1,59,4,59,482,8,59,11,59,12,59,483,1,59,1,59,1,60,1,60,1,60,1,61,1,61,1,61,1,61,1,61,1,62,1,62,1,62,1,63,4,63,500,8,63,11,63,12,63,501,1,63,1,63,1,64,1,64,1,64,1,65,1,65,1,65,1,65,1,65,1,66,1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,68,1,68,1,68,3,68,525,8,68,1,68,3,68,528,8,68,1,68,1,68,1,69,1,69,1,69,1,69,3,69,536,8,69,1,69,1,69,1,70,1,70,1,70,1,70,3,70,544,8,70,1,70,3,70,547,8,70,1,70,3,70,550,8,70,1,70,1,70,1,71,1,71,1,71,1,72,3,72,558,8,72,1,72,1,72,1,72,3,72,563,8,72,1,72,1,72,1,72,1,73,3,73,569,8,73,1,73,1,73,1,73,3,73,574,8,73,1,73,3,73,577,8,73,1,73,1,73,1,74,5,74,582,8,74,10,74,12,74,585,9,74,1,74,1,74,1,74,1,74,1,75,5,75,592,8,75,10,75,12,75,595,9,75,1,75,1,75,1,75,1,76,1,76,1,76,1,76,1,77,1,77,5,77,606,8,77,10,77,12,77,609,9,77,1,77,1,77,1,78,1,78,1,78,1,79,1,79,1,79,1,80,4,80,620,8,80,11,80,12,80,621,1,80,1,80,1,81,1,81,1,82,1,82,3,82,630,8,82,1,82,3,82,633,8,82,1,83,4,83,636,8,83,11,83,12,83,637,1,84,1,84,5,84,642,8,84,10,84,12,84,645,9,84,1,85,1,85,3,85,649,8,85,1,85,1,85,3,85,653,8,85,1,85,5,85,656,8,85,10,85,12,85,659,9,85,1,86,1,86,3,86,663,8,86,1,86,3,86,666,8,86,1,86,1,86,3,86,670,8,86,1,86,1,86,3,86,674,8,86,1,86,1,86,1,86,1,86,3,86,680,8,86,1,86,3,86,683,8,86,1,86,1,86,3,86,687,8,86,1,86,1,86,3,86,691,8,86,1,86,1,86,1,86,1,86,3,86,697,8,86,1,86,3,86,700,8,86,1,86,1,86,3,86,704,8,86,1,86,1,86,3,86,708,8,86,1,86,1,86,1,86,1,86,3,86,714,8,86,1,86,3,86,717,8,86,1,86,1,86,3,86,721,8,86,1,86,1,86,3,86,725,8,86,3,86,727,8,86,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,3,87,738,8,87,1,88,1,88,1,88,1,88,1,88,1,88,1,88,1,88,3,88,748,8,88,3,88,750,8,88,1,89,1,89,5,89,754,8,89,10,89,12,89,757,9,89,1,90,1,90,5,90,761,8,90,10,90,12,90,764,9,90,1,91,1,91,5,91,768,8,91,10,91,12,91,771,9,91,1,92,1,92,5,92,775,8,92,10,92,12,92,778,9,92,1,93,3,93,781,8,93,1,93,1,93,1,583,0,94,5,45,7,46,9,47,11,48,13,49,15,50,17,51,19,52,21,53,23,54,25,55,27,56,29,57,31,58,33,59,35,60,37,61,39,62,41,63,43,64,45,65,47,66,49,67,51,68,53,69,55,70,57,71,59,72,61,73,63,74,65,75,67,76,69,77,71,78,73,79,75,80,77,81,79,82,81,83,83,84,85,85,87,86,89,87,91,88,93,89,95,90,97,91,99,92,101,93,103,94,105,95,107,96,109,97,111,98,113,99,115,100,117,101,119,102,121,103,123,104,125,105,127,106,129,107,131,108,133,109,135,110,137,111,139,112,141,113,143,114,145,115,147,116,149,117,151,118,153,119,155,120,157,121,159,122,161,123,163,124,165,125,167,0,169,0,171,0,173,0,175,0,177,0,179,0,181,0,183,0,185,0,187,0,189,0,191,0,5,0,1,2,3,4,26,2,0,73,74,105,106,5,0,39,39,42,42,47,47,92,92,94,94,2,0,10,10,13,13,3,0,10,10,13,13,39,39,4,0,10,10,13,13,34,34,92,92,8,0,34,34,39,39,92,92,98,98,102,102,110,110,114,114,116,116,1,0,48,55,3,0,48,57,65,70,97,102,3,0,9,10,13,13,32,32,2,0,35,35,37,37,2,0,9,9,32,32,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,68,69,100,101,2,0,66,66,98,98,2,0,80,80,112,112,2,0,79,79,111,111,2,0,88,88,120,120,2,0,115,115,117,117,1,0,48,57,2,0,48,57,95,95,1,0,48,49,2,0,48,49,95,95,2,0,48,55,95,95,4,0,48,57,65,70,95,95,97,102,2,0,43,43,45,45,832,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,1,123,1,0,0,0,1,125,1,0,0,0,1,127,1,0,0,0,1,129,1,0,0,0,2,131,1,0,0,0,2,133,1,0,0,0,2,135,1,0,0,0,2,137,1,0,0,0,2,139,1,0,0,0,2,141,1,0,0,0,2,143,1,0,0,0,2,145,1,0,0,0,2,147,1,0,0,0,3,149,1,0,0,0,3,151,1,0,0,0,3,153,1,0,0,0,3,155,1,0,0,0,4,157,1,0,0,0,4,159,1,0,0,0,4,161,1,0,0,0,4,163,1,0,0,0,4,165,1,0,0,0,5,193,1,0,0,0,7,196,1,0,0,0,9,199,1,0,0,0,11,202,1,0,0,0,13,205,1,0,0,0,15,208,1,0,0,0,17,211,1,0,0,0,19,214,1,0,0,0,21,217,1,0,0,0,23,220,1,0,0,0,25,223,1,0,0,0,27,226,1,0,0,0,29,229,1,0,0,0,31,232,1,0,0,0,33,235,1,0,0,0,35,238,1,0,0,0,37,241,1,0,0,0,39,244,1,0,0,0,41,247,1,0,0,0,43,250,1,0,0,0,45,255,1,0,0,0,47,260,1,0,0,0,49,265,1,0,0,0,51,270,1,0,0,0,53,280,1,0,0,0,55,284,1,0,0,0,57,290,1,0,0,0,59,296,1,0,0,0,61,309,1,0,0,0,63,313,1,0,0,0,65,318,1,0,0,0,67,323,1,0,0,0,69,328,1,0,0,0,71,333,1,0,0,0,73,336,1,0,0,0,75,339,1,0,0,0,77,342,1,0,0,0,79,347,1,0,0,0,81,356,1,0,0,0,83,360,1,0,0,0,85,365,1,0,0,0,87,368,1,0,0,0,89,373,1,0,0,0,91,378,1,0,0,0,93,383,1,0,0,0,95,388,1,0,0,0,97,396,1,0,0,0,99,405,1,0,0,0,101,409,1,0,0,0,103,414,1,0,0,0,105,417,1,0,0,0,107,420,1,0,0,0,109,423,1,0,0,0,111,429,1,0,0,0,113,434,1,0,0,0,115,450,1,0,0,0,117,454,1,0,0,0,119,464,1,0,0,0,121,478,1,0,0,0,123,481,1,0,0,0,125,487,1,0,0,0,127,490,1,0,0,0,129,495,1,0,0,0,131,499,1,0,0,0,133,505,1,0,0,0,135,508,1,0,0,0,137,513,1,0,0,0,139,517,1,0,0,0,141,521,1,0,0,0,143,531,1,0,0,0,145,539,1,0,0,0,147,553,1,0,0,0,149,557,1,0,0,0,151,568,1,0,0,0,153,583,1,0,0,0,155,593,1,0,0,0,157,599,1,0,0,0,159,603,1,0,0,0,161,612,1,0,0,0,163,615,1,0,0,0,165,619,1,0,0,0,167,625,1,0,0,0,169,632,1,0,0,0,171,635,1,0,0,0,173,639,1,0,0,0,175,646,1,0,0,0,177,726,1,0,0,0,179,728,1,0,0,0,181,749,1,0,0,0,183,751,1,0,0,0,185,758,1,0,0,0,187,765,1,0,0,0,189,772,1,0,0,0,191,780,1,0,0,0,193,194,5,43,0,0,194,195,6,0,0,0,195,6,1,0,0,0,196,197,5,45,0,0,197,198,6,1,1,0,198,8,1,0,0,0,199,200,5,42,0,0,200,201,6,2,2,0,201,10,1,0,0,0,202,203,5,47,0,0,203,204,6,3,3,0,204,12,1,0,0,0,205,206,5,61,0,0,206,207,6,4,4,0,207,14,1,0,0,0,208,209,5,58,0,0,209,210,6,5,5,0,210,16,1,0,0,0,211,212,5,59,0,0,212,213,6,6,6,0,213,18,1,0,0,0,214,215,5,44,0,0,215,216,6,7,7,0,216,20,1,0,0,0,217,218,5,46,0,0,218,219,6,8,8,0,219,22,1,0,0,0,220,221,5,126,0,0,221,222,6,9,9,0,222,24,1,0,0,0,223,224,5,33,0,0,224,225,6,10,10,0,225,26,1,0,0,0,226,227,5,64,0,0,227,228,6,11,11,0,228,28,1,0,0,0,229,230,5,40,0,0,230,231,6,12,12,0,231,30,1,0,0,0,232,233,5,41,0,0,233,234,6,13,13,0,234,32,1,0,0,0,235,236,5,91,0,0,236,237,6,14,14,0,237,34,1,0,0,0,238,239,5,93,0,0,239,240,6,15,15,0,240,36,1,0,0,0,241,242,5,123,0,0,242,243,6,16,16,0,243,38,1,0,0,0,244,245,5,125,0,0,245,246,6,17,17,0,246,40,1,0,0,0,247,248,5,92,0,0,248,249,6,18,18,0,249,42,1,0,0,0,250,251,5,43,0,0,251,252,5,61,0,0,252,253,1,0,0,0,253,254,6,19,19,0,254,44,1,0,0,0,255,256,5,45,0,0,256,257,5,61,0,0,257,258,1,0,0,0,258,259,6,20,20,0,259,46,1,0,0,0,260,261,5,42,0,0,261,262,5,61,0,0,262,263,1,0,0,0,263,264,6,21,21,0,264,48,1,0,0,0,265,266,5,47,0,0,266,267,5,61,0,0,267,268,1,0,0,0,268,269,6,22,22,0,269,50,1,0,0,0,270,271,5,92,0,0,271,272,5,61,0,0,272,273,1,0,0,0,273,274,6,23,23,0,274,52,1,0,0,0,275,276,5,94,0,0,276,281,5,61,0,0,277,278,5,42,0,0,278,279,5,42,0,0,279,281,5,61,0,0,280,275,1,0,0,0,280,277,1,0,0,0,281,282,1,0,0,0,282,283,6,24,24,0,283,54,1,0,0,0,284,285,5,46,0,0,285,286,5,42,0,0,286,287,5,61,0,0,287,288,1,0,0,0,288,289,6,25,25,0,289,56,1,0,0,0,290,291,5,46,0,0,291,292,5,47,0,0,292,293,5,61,0,0,293,294,1,0,0,0,294,295,6,26,26,0,295,58,1,0,0,0,296,297,5,46,0,0,297,298,5,92,0,0,298,299,5,61,0,0,299,300,1,0,0,0,300,301,6,27,27,0,301,60,1,0,0,0,302,303,5,46,0,0,303,304,5,94,0,0,304,310,5,61,0,0,305,306,5,46,0,0,306,307,5,42,0,0,307,308,5,42,0,0,308,310,5,61,0,0,309,302,1,0,0,0,309,305,1,0,0,0,310,311,1,0,0,0,311,312,6,28,28,0,312,62,1,0,0,0,313,314,5,38,0,0,314,315,5,61,0,0,315,316,1,0,0,0,316,317,6,29,29,0,317,64,1,0,0,0,318,319,5,124,0,0,319,320,5,61,0,0,320,321,1,0,0,0,321,322,6,30,30,0,322,66,1,0,0,0,323,324,5,38,0,0,324,325,5,38,0,0,325,326,1,0,0,0,326,327,6,31,31,0,327,68,1,0,0,0,328,329,5,124,0,0,329,330,5,124,0,0,330,331,1,0,0,0,331,332,6,32,32,0,332,70,1,0,0,0,333,334,5,38,0,0,334,335,6,33,33,0,335,72,1,0,0,0,336,337,5,124,0,0,337,338,6,34,34,0,338,74,1,0,0,0,339,340,5,60,0,0,340,341,6,35,35,0,341,76,1,0,0,0,342,343,5,60,0,0,343,344,5,61,0,0,344,345,1,0,0,0,345,346,6,36,36,0,346,78,1,0,0,0,347,348,5,61,0,0,348,349,5,61,0,0,349,350,1,0,0,0,350,351,6,37,37,0,351,80,1,0,0,0,352,353,5,33,0,0,353,357,5,61,0,0,354,355,5,126,0,0,355,357,5,61,0,0,356,352,1,0,0,0,356,354,1,0,0,0,357,358,1,0,0,0,358,359,6,38,38,0,359,82,1,0,0,0,360,361,5,62,0,0,361,362,5,61,0,0,362,363,1,0,0,0,363,364,6,39,39,0,364,84,1,0,0,0,365,366,5,62,0,0,366,367,6,40,40,0,367,86,1,0,0,0,368,369,5,46,0,0,369,370,5,42,0,0,370,371,1,0,0,0,371,372,6,41,41,0,372,88,1,0,0,0,373,374,5,46,0,0,374,375,5,47,0,0,375,376,1,0,0,0,376,377,6,42,42,0,377,90,1,0,0,0,378,379,5,46,0,0,379,380,5,92,0,0,380,381,1,0,0,0,381,382,6,43,43,0,382,92,1,0,0,0,383,384,5,43,0,0,384,385,5,43,0,0,385,386,1,0,0,0,386,387,6,44,44,0,387,94,1,0,0,0,388,389,5,45,0,0,389,390,5,45,0,0,390,391,1,0,0,0,391,392,6,45,45,0,392,96,1,0,0,0,393,397,5,94,0,0,394,395,5,42,0,0,395,397,5,42,0,0,396,393,1,0,0,0,396,394,1,0,0,0,397,398,1,0,0,0,398,399,6,46,46,0,399,98,1,0,0,0,400,401,5,46,0,0,401,406,5,94,0,0,402,403,5,46,0,0,403,404,5,42,0,0,404,406,5,42,0,0,405,400,1,0,0,0,405,402,1,0,0,0,406,407,1,0,0,0,407,408,6,47,47,0,408,100,1,0,0,0,409,410,5,46,0,0,410,411,5,39,0,0,411,412,1,0,0,0,412,413,6,48,48,0,413,102,1,0,0,0,414,415,5,39,0,0,415,416,6,49,49,0,416,104,1,0,0,0,417,418,5,34,0,0,418,419,6,50,50,0,419,106,1,0,0,0,420,421,3,173,84,0,421,422,6,51,51,0,422,108,1,0,0,0,423,425,3,177,86,0,424,426,7,0,0,0,425,424,1,0,0,0,425,426,1,0,0,0,426,427,1,0,0,0,427,428,6,52,52,0,428,110,1,0,0,0,429,430,3,181,88,0,430,431,5,46,0,0,431,432,7,1,0,0,432,433,6,53,53,0,433,112,1,0,0,0,434,446,3,171,83,0,435,436,5,46,0,0,436,437,5,46,0,0,437,438,5,46,0,0,438,442,1,0,0,0,439,441,8,2,0,0,440,439,1,0,0,0,441,444,1,0,0,0,442,440,1,0,0,0,442,443,1,0,0,0,443,445,1,0,0,0,444,442,1,0,0,0,445,447,3,169,82,0,446,435,1,0,0,0,446,447,1,0,0,0,447,448,1,0,0,0,448,449,6,54,54,0,449,114,1,0,0,0,450,451,3,169,82,0,451,452,6,55,55,0,452,116,1,0,0,0,453,455,3,171,83,0,454,453,1,0,0,0,454,455,1,0,0,0,455,456,1,0,0,0,456,457,3,167,81,0,457,459,5,123,0,0,458,460,3,171,83,0,459,458,1,0,0,0,459,460,1,0,0,0,460,461,1,0,0,0,461,462,3,169,82,0,462,463,6,56,56,0,463,118,1,0,0,0,464,468,3,167,81,0,465,467,8,2,0,0,466,465,1,0,0,0,467,470,1,0,0,0,468,466,1,0,0,0,468,469,1,0,0,0,469,476,1,0,0,0,470,468,1,0,0,0,471,472,3,169,82,0,472,473,6,57,57,0,473,477,1,0,0,0,474,475,5,0,0,1,475,477,6,57,58,0,476,471,1,0,0,0,476,474,1,0,0,0,477,120,1,0,0,0,478,479,9,0,0,0,479,122,1,0,0,0,480,482,8,3,0,0,481,480,1,0,0,0,482,483,1,0,0,0,483,481,1,0,0,0,483,484,1,0,0,0,484,485,1,0,0,0,485,486,6,59,59,0,486,124,1,0,0,0,487,488,3,169,82,0,488,489,6,60,60,0,489,126,1,0,0,0,490,491,5,39,0,0,491,492,5,39,0,0,492,493,1,0,0,0,493,494,6,61,61,0,494,128,1,0,0,0,495,496,5,39,0,0,496,497,6,62,62,0,497,130,1,0,0,0,498,500,8,4,0,0,499,498,1,0,0,0,500,501,1,0,0,0,501,499,1,0,0,0,501,502,1,0,0,0,502,503,1,0,0,0,503,504,6,63,63,0,504,132,1,0,0,0,505,506,3,169,82,0,506,507,6,64,64,0,507,134,1,0,0,0,508,509,5,34,0,0,509,510,5,34,0,0,510,511,1,0,0,0,511,512,6,65,65,0,512,136,1,0,0,0,513,514,5,92,0,0,514,515,7,5,0,0,515,516,6,66,66,0,516,138,1,0,0,0,517,518,5,92,0,0,518,519,9,0,0,0,519,520,6,67,67,0,520,140,1,0,0,0,521,522,5,92,0,0,522,524,7,6,0,0,523,525,7,6,0,0,524,523,1,0,0,0,524,525,1,0,0,0,525,527,1,0,0,0,526,528,7,6,0,0,527,526,1,0,0,0,527,528,1,0,0,0,528,529,1,0,0,0,529,530,6,68,68,0,530,142,1,0,0,0,531,532,5,92,0,0,532,533,5,120,0,0,533,535,7,7,0,0,534,536,7,7,0,0,535,534,1,0,0,0,535,536,1,0,0,0,536,537,1,0,0,0,537,538,6,69,69,0,538,144,1,0,0,0,539,540,5,92,0,0,540,541,5,117,0,0,541,543,7,7,0,0,542,544,7,7,0,0,543,542,1,0,0,0,543,544,1,0,0,0,544,546,1,0,0,0,545,547,7,7,0,0,546,545,1,0,0,0,546,547,1,0,0,0,547,549,1,0,0,0,548,550,7,7,0,0,549,548,1,0,0,0,549,550,1,0,0,0,550,551,1,0,0,0,551,552,6,70,70,0,552,146,1,0,0,0,553,554,5,34,0,0,554,555,6,71,71,0,555,148,1,0,0,0,556,558,3,171,83,0,557,556,1,0,0,0,557,558,1,0,0,0,558,559,1,0,0,0,559,560,3,167,81,0,560,562,5,123,0,0,561,563,3,171,83,0,562,561,1,0,0,0,562,563,1,0,0,0,563,564,1,0,0,0,564,565,3,169,82,0,565,566,6,72,72,0,566,150,1,0,0,0,567,569,3,171,83,0,568,567,1,0,0,0,568,569,1,0,0,0,569,570,1,0,0,0,570,571,3,167,81,0,571,573,5,125,0,0,572,574,3,171,83,0,573,572,1,0,0,0,573,574,1,0,0,0,574,576,1,0,0,0,575,577,3,169,82,0,576,575,1,0,0,0,576,577,1,0,0,0,577,578,1,0,0,0,578,579,6,73,73,0,579,152,1,0,0,0,580,582,9,0,0,0,581,580,1,0,0,0,582,585,1,0,0,0,583,584,1,0,0,0,583,581,1,0,0,0,584,586,1,0,0,0,585,583,1,0,0,0,586,587,3,169,82,0,587,588,1,0,0,0,588,589,6,74,74,0,589,154,1,0,0,0,590,592,8,2,0,0,591,590,1,0,0,0,592,595,1,0,0,0,593,591,1,0,0,0,593,594,1,0,0,0,594,596,1,0,0,0,595,593,1,0,0,0,596,597,5,0,0,1,597,598,6,75,75,0,598,156,1,0,0,0,599,600,3,171,83,0,600,601,1,0,0,0,601,602,6,76,74,0,602,158,1,0,0,0,603,607,3,167,81,0,604,606,8,2,0,0,605,604,1,0,0,0,606,609,1,0,0,0,607,605,1,0,0,0,607,608,1,0,0,0,608,610,1,0,0,0,609,607,1,0,0,0,610,611,6,77,74,0,611,160,1,0,0,0,612,613,3,169,82,0,613,614,6,78,76,0,614,162,1,0,0,0,615,616,5,0,0,1,616,617,6,79,77,0,617,164,1,0,0,0,618,620,8,8,0,0,619,618,1,0,0,0,620,621,1,0,0,0,621,619,1,0,0,0,621,622,1,0,0,0,622,623,1,0,0,0,623,624,6,80,78,0,624,166,1,0,0,0,625,626,7,9,0,0,626,168,1,0,0,0,627,633,5,13,0,0,628,630,5,13,0,0,629,628,1,0,0,0,629,630,1,0,0,0,630,631,1,0,0,0,631,633,5,10,0,0,632,627,1,0,0,0,632,629,1,0,0,0,633,170,1,0,0,0,634,636,7,10,0,0,635,634,1,0,0,0,636,637,1,0,0,0,637,635,1,0,0,0,637,638,1,0,0,0,638,172,1,0,0,0,639,643,7,11,0,0,640,642,7,12,0,0,641,640,1,0,0,0,642,645,1,0,0,0,643,641,1,0,0,0,643,644,1,0,0,0,644,174,1,0,0,0,645,643,1,0,0,0,646,657,3,173,84,0,647,649,3,171,83,0,648,647,1,0,0,0,648,649,1,0,0,0,649,650,1,0,0,0,650,652,5,46,0,0,651,653,3,171,83,0,652,651,1,0,0,0,652,653,1,0,0,0,653,654,1,0,0,0,654,656,3,173,84,0,655,648,1,0,0,0,656,659,1,0,0,0,657,655,1,0,0,0,657,658,1,0,0,0,658,176,1,0,0,0,659,657,1,0,0,0,660,662,3,183,89,0,661,663,5,46,0,0,662,661,1,0,0,0,662,663,1,0,0,0,663,670,1,0,0,0,664,666,3,183,89,0,665,664,1,0,0,0,665,666,1,0,0,0,666,667,1,0,0,0,667,668,5,46,0,0,668,670,3,183,89,0,669,660,1,0,0,0,669,665,1,0,0,0,670,673,1,0,0,0,671,672,7,13,0,0,672,674,3,191,93,0,673,671,1,0,0,0,673,674,1,0,0,0,674,727,1,0,0,0,675,676,5,48,0,0,676,686,7,14,0,0,677,679,3,185,90,0,678,680,5,46,0,0,679,678,1,0,0,0,679,680,1,0,0,0,680,687,1,0,0,0,681,683,3,185,90,0,682,681,1,0,0,0,682,683,1,0,0,0,683,684,1,0,0,0,684,685,5,46,0,0,685,687,3,185,90,0,686,677,1,0,0,0,686,682,1,0,0,0,687,690,1,0,0,0,688,689,7,15,0,0,689,691,3,191,93,0,690,688,1,0,0,0,690,691,1,0,0,0,691,727,1,0,0,0,692,693,5,48,0,0,693,703,7,16,0,0,694,696,3,187,91,0,695,697,5,46,0,0,696,695,1,0,0,0,696,697,1,0,0,0,697,704,1,0,0,0,698,700,3,187,91,0,699,698,1,0,0,0,699,700,1,0,0,0,700,701,1,0,0,0,701,702,5,46,0,0,702,704,3,187,91,0,703,694,1,0,0,0,703,699,1,0,0,0,704,707,1,0,0,0,705,706,7,15,0,0,706,708,3,191,93,0,707,705,1,0,0,0,707,708,1,0,0,0,708,727,1,0,0,0,709,710,5,48,0,0,710,720,7,17,0,0,711,713,3,189,92,0,712,714,5,46,0,0,713,712,1,0,0,0,713,714,1,0,0,0,714,721,1,0,0,0,715,717,3,189,92,0,716,715,1,0,0,0,716,717,1,0,0,0,717,718,1,0,0,0,718,719,5,46,0,0,719,721,3,189,92,0,720,711,1,0,0,0,720,716,1,0,0,0,721,724,1,0,0,0,722,723,7,15,0,0,723,725,3,191,93,0,724,722,1,0,0,0,724,725,1,0,0,0,725,727,1,0,0,0,726,669,1,0,0,0,726,675,1,0,0,0,726,692,1,0,0,0,726,709,1,0,0,0,727,178,1,0,0,0,728,729,3,181,88,0,729,737,7,18,0,0,730,738,5,56,0,0,731,732,5,49,0,0,732,738,5,54,0,0,733,734,5,51,0,0,734,738,5,50,0,0,735,736,5,54,0,0,736,738,5,52,0,0,737,730,1,0,0,0,737,731,1,0,0,0,737,733,1,0,0,0,737,735,1,0,0,0,738,180,1,0,0,0,739,750,3,183,89,0,740,747,5,48,0,0,741,742,7,14,0,0,742,748,3,185,90,0,743,744,7,16,0,0,744,748,3,187,91,0,745,746,7,17,0,0,746,748,3,189,92,0,747,741,1,0,0,0,747,743,1,0,0,0,747,745,1,0,0,0,748,750,1,0,0,0,749,739,1,0,0,0,749,740,1,0,0,0,750,182,1,0,0,0,751,755,7,19,0,0,752,754,7,20,0,0,753,752,1,0,0,0,754,757,1,0,0,0,755,753,1,0,0,0,755,756,1,0,0,0,756,184,1,0,0,0,757,755,1,0,0,0,758,762,7,21,0,0,759,761,7,22,0,0,760,759,1,0,0,0,761,764,1,0,0,0,762,760,1,0,0,0,762,763,1,0,0,0,763,186,1,0,0,0,764,762,1,0,0,0,765,769,7,6,0,0,766,768,7,23,0,0,767,766,1,0,0,0,768,771,1,0,0,0,769,767,1,0,0,0,769,770,1,0,0,0,770,188,1,0,0,0,771,769,1,0,0,0,772,776,7,7,0,0,773,775,7,24,0,0,774,773,1,0,0,0,775,778,1,0,0,0,776,774,1,0,0,0,776,777,1,0,0,0,777,190,1,0,0,0,778,776,1,0,0,0,779,781,7,25,0,0,780,779,1,0,0,0,780,781,1,0,0,0,781,782,1,0,0,0,782,783,3,183,89,0,783,192,1,0,0,0,66,0,1,2,3,4,280,309,356,396,405,425,442,446,454,459,468,476,483,501,524,527,535,543,546,549,557,562,568,573,576,583,593,607,621,629,632,637,643,648,652,657,662,665,669,673,679,682,686,690,696,699,703,707,713,716,720,724,726,737,747,749,755,762,769,776,780,79,1,0,0,1,1,1,1,2,2,1,3,3,1,4,4,1,5,5,1,6,6,1,7,7,1,8,8,1,9,9,1,10,10,1,11,11,1,12,12,1,13,13,1,14,14,1,15,15,1,16,16,1,17,17,1,18,18,1,19,19,1,20,20,1,21,21,1,22,22,1,23,23,1,24,24,1,25,25,1,26,26,1,27,27,1,28,28,1,29,29,1,30,30,1,31,31,1,32,32,1,33,33,1,34,34,1,35,35,1,36,36,1,37,37,1,38,38,1,39,39,1,40,40,1,41,41,1,42,42,1,43,43,1,44,44,1,45,45,1,46,46,1,47,47,1,48,48,1,49,49,1,50,50,1,51,51,1,52,52,1,53,53,1,54,54,1,55,55,1,56,56,1,57,57,1,57,58,1,59,59,1,60,60,1,61,61,1,62,62,1,63,63,1,64,64,1,65,65,1,66,66,1,67,67,1,68,68,1,69,69,1,70,70,1,71,71,1,72,72,1,73,73,6,0,0,1,75,74,1,78,75,1,79,76,1,80,77];static __ATN;static get _ATN(){return MathJSLabLexer.__ATN||(MathJSLabLexer.__ATN=(new antlr4__WEBPACK_IMPORTED_MODULE_0__.fr).deserialize(MathJSLabLexer._serializedATN)),MathJSLabLexer.__ATN}static DecisionsToDFA=MathJSLabLexer._ATN.decisionToState.map((e,t)=>new antlr4__WEBPACK_IMPORTED_MODULE_0__.M8(e,t))}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={},EXP_LIMIT=9e15,MAX_DIGITS=1e9,NUMERALS="0123456789abcdef",LN10="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",PI="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",DEFAULTS={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-EXP_LIMIT,maxE:EXP_LIMIT,crypto:!1},inexact,quadrant,external=!0,decimalError="[DecimalError] ",invalidArgument=decimalError+"Invalid argument: ",precisionLimitExceeded=decimalError+"Precision limit exceeded",cryptoUnavailable=decimalError+"crypto unavailable",tag="[object Decimal]",mathfloor=Math.floor,mathpow=Math.pow,isBinary=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,isHex=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,isOctal=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,isDecimal=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,BASE=1e7,LOG_BASE=7,MAX_SAFE_INTEGER=9007199254740991,LN10_PRECISION=LN10.length-1,PI_PRECISION=PI.length-1,P={toStringTag:tag};function digitsToString(e){var t,r,n,i=e.length-1,a="",s=e[0];if(i>0){for(a+=s,t=1;t<i;t++)n=e[t]+"",(r=LOG_BASE-n.length)&&(a+=getZeroString(r)),a+=n;s=e[t],(r=LOG_BASE-(n=s+"").length)&&(a+=getZeroString(r))}else if(0===s)return"0";for(;s%10==0;)s/=10;return a+s}function checkInt32(e,t,r){if(e!==~~e||e<t||e>r)throw Error(invalidArgument+e)}function checkRoundingDigits(e,t,r,n){var i,a,s,o;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=LOG_BASE,i=0):(i=Math.ceil((t+1)/LOG_BASE),t%=LOG_BASE),a=mathpow(10,LOG_BASE-t),o=e[i]%a|0,null==n?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),s=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):s=(r<4&&o+1==a||r>3&&o+1==a/2)&&(e[i+1]/a/100|0)==mathpow(10,t-2)-1||(o==a/2||0==o)&&!(e[i+1]/a/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),s=(n||r<4)&&9999==o||!n&&r>3&&4999==o):s=((n||r<4)&&o+1==a||!n&&r>3&&o+1==a/2)&&(e[i+1]/a/1e3|0)==mathpow(10,t-3)-1,s}function convertBase(e,t,r){for(var n,i,a=[0],s=0,o=e.length;s<o;){for(i=a.length;i--;)a[i]*=t;for(a[0]+=NUMERALS.indexOf(e.charAt(s++)),n=0;n<a.length;n++)a[n]>r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}function cosine(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/tinyPow(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=taylorSeries(e,1,t.times(i),new e(1));for(var a=r;a--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=r,t}P.absoluteValue=P.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),finalise(e)},P.ceil=function(){return finalise(new this.constructor(this),this.e+1,2)},P.clampedTo=P.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(invalidArgument+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},P.comparedTo=P.cmp=function(e){var t,r,n,i,a=this,s=a.d,o=(e=new a.constructor(e)).d,l=a.s,c=e.s;if(!s||!o)return l&&c?l!==c?l:s===o?0:!s^l<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?l:o[0]?-c:0;if(l!==c)return l;if(a.e!==e.e)return a.e>e.e^l<0?1:-1;for(t=0,r=(n=s.length)<(i=o.length)?n:i;t<r;++t)if(s[t]!==o[t])return s[t]>o[t]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1},P.cosine=P.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+LOG_BASE,n.rounding=1,r=cosine(n,toLessThanHalfPi(n,r)),n.precision=e,n.rounding=t,finalise(2==quadrant||3==quadrant?r.neg():r,e,t,!0)):new n(1):new n(NaN)},P.cubeRoot=P.cbrt=function(){var e,t,r,n,i,a,s,o,l,c,u=this,m=u.constructor;if(!u.isFinite()||u.isZero())return new m(u);for(external=!1,(a=u.s*mathpow(u.s*u,1/3))&&Math.abs(a)!=1/0?n=new m(a.toString()):(r=digitsToString(u.d),(a=((e=u.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=mathpow(r,1/3),e=mathfloor((e+1)/3)-(e%3==(e<0?-1:2)),(n=new m(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=u.s),s=(e=m.precision)+3;;)if(c=(l=(o=n).times(o).times(o)).plus(u),n=divide(c.plus(u).times(o),c.plus(l),s+2,1),digitsToString(o.d).slice(0,s)===(r=digitsToString(n.d)).slice(0,s)){if("9999"!=(r=r.slice(s-3,s+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(finalise(n,e+1,1),t=!n.times(n).times(n).eq(u));break}if(!i&&(finalise(o,e+1,0),o.times(o).times(o).eq(u))){n=o;break}s+=4,i=1}return external=!0,finalise(n,e,m.rounding,t)},P.decimalPlaces=P.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=((e=t.length-1)-mathfloor(this.e/LOG_BASE))*LOG_BASE,e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},P.dividedBy=P.div=function(e){return divide(this,new this.constructor(e))},P.dividedToIntegerBy=P.divToInt=function(e){var t=this.constructor;return finalise(divide(this,new t(e),0,1,1),t.precision,t.rounding)},P.equals=P.eq=function(e){return 0===this.cmp(e)},P.floor=function(){return finalise(new this.constructor(this),this.e+1,3)},P.greaterThan=P.gt=function(e){return this.cmp(e)>0},P.greaterThanOrEqualTo=P.gte=function(e){var t=this.cmp(e);return 1==t||0===t},P.hyperbolicCosine=P.cosh=function(){var e,t,r,n,i,a=this,s=a.constructor,o=new s(1);if(!a.isFinite())return new s(a.s?1/0:NaN);if(a.isZero())return o;r=s.precision,n=s.rounding,s.precision=r+Math.max(a.e,a.sd())+4,s.rounding=1,(i=a.d.length)<32?t=(1/tinyPow(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),a=taylorSeries(s,1,a.times(t),new s(1),!0);for(var l,c=e,u=new s(8);c--;)l=a.times(a),a=o.minus(l.times(u.minus(l.times(u))));return finalise(a,s.precision=r,s.rounding=n,!0)},P.hyperbolicSine=P.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=taylorSeries(a,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=taylorSeries(a,2,i=i.times(1/tinyPow(5,e)),i,!0);for(var s,o=new a(5),l=new a(16),c=new a(20);e--;)s=i.times(i),i=i.times(o.plus(s.times(l.times(s).plus(c))))}return a.precision=t,a.rounding=r,finalise(i,t,r,!0)},P.hyperbolicTangent=P.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,divide(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},P.inverseCosine=P.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return-1!==r?0===r?e.isNeg()?getPi(t,n,i):new t(0):new t(NaN):e.isZero()?getPi(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))},P.inverseHyperbolicCosine=P.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,external=!1,r=r.times(r).minus(1).sqrt().plus(r),external=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},P.inverseHyperbolicSine=P.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,external=!1,r=r.times(r).plus(1).sqrt().plus(r),external=!0,n.precision=e,n.rounding=t,r.ln())},P.inverseHyperbolicTangent=P.atanh=function(){var e,t,r,n,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?finalise(new a(i),e,t,!0):(a.precision=r=n-i.e,i=divide(i.plus(1),new a(1).minus(i),r+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},P.inverseSine=P.asin=function(){var e,t,r,n,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),r=a.precision,n=a.rounding,-1!==t?0===t?((e=getPi(a,r+4,n).times(.5)).s=i.s,e):new a(NaN):(a.precision=r+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=r,a.rounding=n,i.times(2)))},P.inverseTangent=P.atan=function(){var e,t,r,n,i,a,s,o,l,c=this,u=c.constructor,m=u.precision,h=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&m+4<=PI_PRECISION)return(s=getPi(u,m+4,h).times(.25)).s=c.s,s}else{if(!c.s)return new u(NaN);if(m+4<=PI_PRECISION)return(s=getPi(u,m+4,h).times(.5)).s=c.s,s}for(u.precision=o=m+10,u.rounding=1,e=r=Math.min(28,o/LOG_BASE+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(external=!1,t=Math.ceil(o/LOG_BASE),n=1,l=c.times(c),s=new u(c),i=c;-1!==e;)if(i=i.times(l),a=s.minus(i.div(n+=2)),i=i.times(l),void 0!==(s=a.plus(i.div(n+=2))).d[t])for(e=t;s.d[e]===a.d[e]&&e--;);return r&&(s=s.times(2<<r-1)),external=!0,finalise(s,u.precision=m,u.rounding=h,!0)},P.isFinite=function(){return!!this.d},P.isInteger=P.isInt=function(){return!!this.d&&mathfloor(this.e/LOG_BASE)>this.d.length-2},P.isNaN=function(){return!this.s},P.isNegative=P.isNeg=function(){return this.s<0},P.isPositive=P.isPos=function(){return this.s>0},P.isZero=function(){return!!this.d&&0===this.d[0]},P.lessThan=P.lt=function(e){return this.cmp(e)<0},P.lessThanOrEqualTo=P.lte=function(e){return this.cmp(e)<1},P.logarithm=P.log=function(e){var t,r,n,i,a,s,o,l,c=this,u=c.constructor,m=u.precision,h=u.rounding;if(null==e)e=new u(10),t=!0;else{if(r=(e=new u(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new u(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(external=!1,s=naturalLogarithm(c,o=m+5),n=t?getLn10(u,o+10):naturalLogarithm(e,o),checkRoundingDigits((l=divide(s,n,o,1)).d,i=m,h))do{if(s=naturalLogarithm(c,o+=10),n=t?getLn10(u,o+10):naturalLogarithm(e,o),l=divide(s,n,o,1),!a){+digitsToString(l.d).slice(i+1,i+15)+1==1e14&&(l=finalise(l,m+1,0));break}}while(checkRoundingDigits(l.d,i+=10,h));return external=!0,finalise(l,m,h)},P.minus=P.sub=function(e){var t,r,n,i,a,s,o,l,c,u,m,h,p=this,d=p.constructor;if(e=new d(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new d(e.d||p.s!==e.s?p:NaN):e=new d(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,h=e.d,o=d.precision,l=d.rounding,!c[0]||!h[0]){if(h[0])e.s=-e.s;else{if(!c[0])return new d(3===l?-0:0);e=new d(p)}return external?finalise(e,o,l):e}if(r=mathfloor(e.e/LOG_BASE),u=mathfloor(p.e/LOG_BASE),c=c.slice(),a=u-r){for((m=a<0)?(t=c,a=-a,s=h.length):(t=h,r=u,s=c.length),a>(n=Math.max(Math.ceil(o/LOG_BASE),s)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((m=(n=c.length)<(s=h.length))&&(s=n),n=0;n<s;n++)if(c[n]!=h[n]){m=c[n]<h[n];break}a=0}for(m&&(t=c,c=h,h=t,e.s=-e.s),s=c.length,n=h.length-s;n>0;--n)c[s++]=0;for(n=h.length;n>a;){if(c[--n]<h[n]){for(i=n;i&&0===c[--i];)c[i]=BASE-1;--c[i],c[n]+=BASE}c[n]-=h[n]}for(;0===c[--s];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=getBase10Exponent(c,r),external?finalise(e,o,l):e):new d(3===l?-0:0)},P.modulo=P.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?finalise(new n(r),n.precision,n.rounding):(external=!1,9==n.modulo?(t=divide(r,e.abs(),0,3,1)).s*=e.s:t=divide(r,e,0,n.modulo,1),t=t.times(e),external=!0,r.minus(t))},P.naturalExponential=P.exp=function(){return naturalExponential(this)},P.naturalLogarithm=P.ln=function(){return naturalLogarithm(this)},P.negated=P.neg=function(){var e=new this.constructor(this);return e.s=-e.s,finalise(e)},P.plus=P.add=function(e){var t,r,n,i,a,s,o,l,c,u,m=this,h=m.constructor;if(e=new h(e),!m.d||!e.d)return m.s&&e.s?m.d||(e=new h(e.d||m.s===e.s?m:NaN)):e=new h(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.minus(e);if(c=m.d,u=e.d,o=h.precision,l=h.rounding,!c[0]||!u[0])return u[0]||(e=new h(m)),external?finalise(e,o,l):e;if(a=mathfloor(m.e/LOG_BASE),n=mathfloor(e.e/LOG_BASE),c=c.slice(),i=a-n){for(i<0?(r=c,i=-i,s=u.length):(r=u,n=a,s=c.length),i>(s=(a=Math.ceil(o/LOG_BASE))>s?a+1:s+1)&&(i=s,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((s=c.length)-(i=u.length)<0&&(i=s,r=u,u=c,c=r),t=0;i;)t=(c[--i]=c[i]+u[i]+t)/BASE|0,c[i]%=BASE;for(t&&(c.unshift(t),++n),s=c.length;0==c[--s];)c.pop();return e.d=c,e.e=getBase10Exponent(c,n),external?finalise(e,o,l):e},P.precision=P.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(invalidArgument+e);return r.d?(t=getPrecision(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},P.round=function(){var e=this,t=e.constructor;return finalise(new t(e),e.e+1,t.rounding)},P.sine=P.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+LOG_BASE,n.rounding=1,r=sine(n,toLessThanHalfPi(n,r)),n.precision=e,n.rounding=t,finalise(quadrant>2?r.neg():r,e,t,!0)):new n(NaN)},P.squareRoot=P.sqrt=function(){var e,t,r,n,i,a,s=this,o=s.d,l=s.e,c=s.s,u=s.constructor;if(1!==c||!o||!o[0])return new u(!c||c<0&&(!o||o[0])?NaN:o?s:1/0);for(external=!1,0==(c=Math.sqrt(+s))||c==1/0?(((t=digitsToString(o)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=mathfloor((l+1)/2)-(l<0||l%2),n=new u(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):n=new u(c.toString()),r=(l=u.precision)+3;;)if(n=(a=n).plus(divide(s,a,r+2,1)).times(.5),digitsToString(a.d).slice(0,r)===(t=digitsToString(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(finalise(n,l+1,1),e=!n.times(n).eq(s));break}if(!i&&(finalise(a,l+1,0),a.times(a).eq(s))){n=a;break}r+=4,i=1}return external=!0,finalise(n,l,u.rounding,e)},P.tangent=P.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=divide(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,finalise(2==quadrant||4==quadrant?r.neg():r,e,t,!0)):new n(NaN)},P.times=P.mul=function(e){var t,r,n,i,a,s,o,l,c,u=this,m=u.constructor,h=u.d,p=(e=new m(e)).d;if(e.s*=u.s,!(h&&h[0]&&p&&p[0]))return new m(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:h&&p?0*e.s:e.s/0);for(r=mathfloor(u.e/LOG_BASE)+mathfloor(e.e/LOG_BASE),(l=h.length)<(c=p.length)&&(a=h,h=p,p=a,s=l,l=c,c=s),a=[],n=s=l+c;n--;)a.push(0);for(n=c;--n>=0;){for(t=0,i=l+n;i>n;)o=a[i]+p[n]*h[i-n-1]+t,a[i--]=o%BASE|0,t=o/BASE|0;a[i]=(a[i]+t)%BASE|0}for(;!a[--s];)a.pop();return t?++r:a.shift(),e.d=a,e.e=getBase10Exponent(a,r),external?finalise(e,m.precision,m.rounding):e},P.toBinary=function(e,t){return toStringBinary(this,2,e,t)},P.toDecimalPlaces=P.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(checkInt32(e,0,MAX_DIGITS),void 0===t?t=n.rounding:checkInt32(t,0,8),finalise(r,e+r.e+1,t))},P.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=finiteToString(n,!0):(checkInt32(e,0,MAX_DIGITS),void 0===t?t=i.rounding:checkInt32(t,0,8),r=finiteToString(n=finalise(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},P.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return void 0===e?r=finiteToString(i):(checkInt32(e,0,MAX_DIGITS),void 0===t?t=a.rounding:checkInt32(t,0,8),r=finiteToString(n=finalise(new a(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},P.toFraction=function(e){var t,r,n,i,a,s,o,l,c,u,m,h,p=this,d=p.d,x=p.constructor;if(!d)return new x(p);if(c=r=new x(1),n=l=new x(0),s=(a=(t=new x(n)).e=getPrecision(d)-p.e-1)%LOG_BASE,t.d[0]=mathpow(10,s<0?LOG_BASE+s:s),null==e)e=a>0?t:c;else{if(!(o=new x(e)).isInt()||o.lt(c))throw Error(invalidArgument+o);e=o.gt(t)?a>0?t:c:o}for(external=!1,o=new x(digitsToString(d)),u=x.precision,x.precision=a=d.length*LOG_BASE*2;m=divide(o,t,0,1,1),1!=(i=r.plus(m.times(n))).cmp(e);)r=n,n=i,i=c,c=l.plus(m.times(i)),l=i,i=t,t=o.minus(m.times(i)),o=i;return i=divide(e.minus(r),n,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(n)),l.s=c.s=p.s,h=divide(c,n,a,1).minus(p).abs().cmp(divide(l,r,a,1).minus(p).abs())<1?[c,n]:[l,r],x.precision=u,external=!0,h},P.toHexadecimal=P.toHex=function(e,t){return toStringBinary(this,16,e,t)},P.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:checkInt32(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(external=!1,r=divide(r,e,0,t,1).times(e),external=!0,finalise(r)):(e.s=r.s,r=e),r},P.toNumber=function(){return+this},P.toOctal=function(e,t){return toStringBinary(this,8,e,t)},P.toPower=P.pow=function(e){var t,r,n,i,a,s,o=this,l=o.constructor,c=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(mathpow(+o,c));if((o=new l(o)).eq(1))return o;if(n=l.precision,a=l.rounding,e.eq(1))return finalise(o,n,a);if((t=mathfloor(e.e/LOG_BASE))>=e.d.length-1&&(r=c<0?-c:c)<=MAX_SAFE_INTEGER)return i=intPow(l,o,r,n),e.s<0?new l(1).div(i):finalise(i,n,a);if((s=o.s)<0){if(t<e.d.length-1)return new l(NaN);if(1&e.d[t]||(s=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=s,o}return(t=0!=(r=mathpow(+o,c))&&isFinite(r)?new l(r+"").e:mathfloor(c*(Math.log("0."+digitsToString(o.d))/Math.LN10+o.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?s/0:0):(external=!1,l.rounding=o.s=1,r=Math.min(12,(t+"").length),(i=naturalExponential(e.times(naturalLogarithm(o,n+r)),n)).d&&checkRoundingDigits((i=finalise(i,n+5,1)).d,n,a)&&(t=n+10,+digitsToString((i=finalise(naturalExponential(e.times(naturalLogarithm(o,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=finalise(i,n+1,0))),i.s=s,external=!0,l.rounding=a,finalise(i,n,a))},P.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=finiteToString(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(checkInt32(e,1,MAX_DIGITS),void 0===t?t=i.rounding:checkInt32(t,0,8),r=finiteToString(n=finalise(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},P.toSignificantDigits=P.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(checkInt32(e,1,MAX_DIGITS),void 0===t?t=r.rounding:checkInt32(t,0,8)),finalise(new r(this),e,t)},P.toString=function(){var e=this,t=e.constructor,r=finiteToString(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},P.truncated=P.trunc=function(){return finalise(new this.constructor(this),this.e+1,1)},P.valueOf=P.toJSON=function(){var e=this,t=e.constructor,r=finiteToString(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var divide=function(){function e(e,t,r){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+i,e[a]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;i<r;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,s,o,l){var c,u,m,h,p,d,x,C,f,g,_,y,A,E,L,T,M,b,S,N,w=n.constructor,I=n.s==i.s?1:-1,P=n.d,O=i.d;if(!(P&&P[0]&&O&&O[0]))return new w(n.s&&i.s&&(P?!O||P[0]!=O[0]:O)?P&&0==P[0]||!O?0*I:I/0:NaN);for(l?(p=1,u=n.e-i.e):(l=BASE,p=LOG_BASE,u=mathfloor(n.e/p)-mathfloor(i.e/p)),S=O.length,M=P.length,g=(f=new w(I)).d=[],m=0;O[m]==(P[m]||0);m++);if(O[m]>(P[m]||0)&&u--,null==a?(E=a=w.precision,s=w.rounding):E=o?a+(n.e-i.e)+1:a,E<0)g.push(1),d=!0;else{if(E=E/p+2|0,m=0,1==S){for(h=0,O=O[0],E++;(m<M||h)&&E--;m++)L=h*l+(P[m]||0),g[m]=L/O|0,h=L%O|0;d=h||m<M}else{for((h=l/(O[0]+1)|0)>1&&(O=e(O,h,l),P=e(P,h,l),S=O.length,M=P.length),T=S,y=(_=P.slice(0,S)).length;y<S;)_[y++]=0;(N=O.slice()).unshift(0),b=O[0],O[1]>=l/2&&++b;do{h=0,(c=t(O,_,S,y))<0?(A=_[0],S!=y&&(A=A*l+(_[1]||0)),(h=A/b|0)>1?(h>=l&&(h=l-1),1==(c=t(x=e(O,h,l),_,C=x.length,y=_.length))&&(h--,r(x,S<C?N:O,C,l))):(0==h&&(c=h=1),x=O.slice()),(C=x.length)<y&&x.unshift(0),r(_,x,y,l),-1==c&&(c=t(O,_,S,y=_.length))<1&&(h++,r(_,S<y?N:O,y,l)),y=_.length):0===c&&(h++,_=[0]),g[m++]=h,c&&_[0]?_[y++]=P[T]||0:(_=[P[T]],y=1)}while((T++<M||void 0!==_[0])&&E--);d=void 0!==_[0]}g[0]||g.shift()}if(1==p)f.e=u,inexact=d;else{for(m=1,h=g[0];h>=10;h/=10)m++;f.e=m+u*p-1,finalise(f,o?a+f.e+1:a,s,d)}return f}}();function finalise(e,t,r,n){var i,a,s,o,l,c,u,m,h,p=e.constructor;e:if(null!=t){if(!(m=e.d))return e;for(i=1,o=m[0];o>=10;o/=10)i++;if((a=t-i)<0)a+=LOG_BASE,s=t,l=(u=m[h=0])/mathpow(10,i-s-1)%10|0;else if((h=Math.ceil((a+1)/LOG_BASE))>=(o=m.length)){if(!n)break e;for(;o++<=h;)m.push(0);u=l=0,i=1,s=(a%=LOG_BASE)-LOG_BASE+1}else{for(u=o=m[h],i=1;o>=10;o/=10)i++;l=(s=(a%=LOG_BASE)-LOG_BASE+i)<0?0:u/mathpow(10,i-s-1)%10|0}if(n=n||t<0||void 0!==m[h+1]||(s<0?u:u%mathpow(10,i-s-1)),c=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(a>0?s>0?u/mathpow(10,i-s):0:m[h-1])%10&1||r==(e.s<0?8:7)),t<1||!m[0])return m.length=0,c?(t-=e.e+1,m[0]=mathpow(10,(LOG_BASE-t%LOG_BASE)%LOG_BASE),e.e=-t||0):m[0]=e.e=0,e;if(0==a?(m.length=h,o=1,h--):(m.length=h+1,o=mathpow(10,LOG_BASE-a),m[h]=s>0?(u/mathpow(10,i-s)%mathpow(10,s)|0)*o:0),c)for(;;){if(0==h){for(a=1,s=m[0];s>=10;s/=10)a++;for(s=m[0]+=o,o=1;s>=10;s/=10)o++;a!=o&&(e.e++,m[0]==BASE&&(m[0]=1));break}if(m[h]+=o,m[h]!=BASE)break;m[h--]=0,o=1}for(a=m.length;0===m[--a];)m.pop()}return external&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function finiteToString(e,t,r){if(!e.isFinite())return nonFiniteToString(e);var n,i=e.e,a=digitsToString(e.d),s=a.length;return t?(r&&(n=r-s)>0?a=a.charAt(0)+"."+a.slice(1)+getZeroString(n):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):i<0?(a="0."+getZeroString(-i-1)+a,r&&(n=r-s)>0&&(a+=getZeroString(n))):i>=s?(a+=getZeroString(i+1-s),r&&(n=r-i-1)>0&&(a=a+"."+getZeroString(n))):((n=i+1)<s&&(a=a.slice(0,n)+"."+a.slice(n)),r&&(n=r-s)>0&&(i+1===s&&(a+="."),a+=getZeroString(n))),a}function getBase10Exponent(e,t){var r=e[0];for(t*=LOG_BASE;r>=10;r/=10)t++;return t}function getLn10(e,t,r){if(t>LN10_PRECISION)throw external=!0,r&&(e.precision=r),Error(precisionLimitExceeded);return finalise(new e(LN10),t,1,!0)}function getPi(e,t,r){if(t>PI_PRECISION)throw Error(precisionLimitExceeded);return finalise(new e(PI),t,r,!0)}function getPrecision(e){var t=e.length-1,r=t*LOG_BASE+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function getZeroString(e){for(var t="";e--;)t+="0";return t}function intPow(e,t,r,n){var i,a=new e(1),s=Math.ceil(n/LOG_BASE+4);for(external=!1;;){if(r%2&&truncate((a=a.times(t)).d,s)&&(i=!0),0===(r=mathfloor(r/2))){r=a.d.length-1,i&&0===a.d[r]&&++a.d[r];break}truncate((t=t.times(t)).d,s)}return external=!0,a}function isOdd(e){return 1&e.d[e.d.length-1]}function maxOrMin(e,t,r){for(var n,i,a=new e(t[0]),s=0;++s<t.length;){if(!(i=new e(t[s])).s){a=i;break}((n=a.cmp(i))===r||0===n&&a.s===r)&&(a=i)}return a}function naturalExponential(e,t){var r,n,i,a,s,o,l,c=0,u=0,m=0,h=e.constructor,p=h.rounding,d=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(external=!1,l=d):l=t,o=new h(.03125);e.e>-2;)e=e.times(o),m+=5;for(l+=n=Math.log(mathpow(2,m))/Math.LN10*2+5|0,r=a=s=new h(1),h.precision=l;;){if(a=finalise(a.times(e),l,1),r=r.times(++u),digitsToString((o=s.plus(divide(a,r,l,1))).d).slice(0,l)===digitsToString(s.d).slice(0,l)){for(i=m;i--;)s=finalise(s.times(s),l,1);if(null!=t)return h.precision=d,s;if(!(c<3&&checkRoundingDigits(s.d,l-n,p,c)))return finalise(s,h.precision=d,p,external=!0);h.precision=l+=10,r=a=o=new h(1),u=0,c++}s=o}}function naturalLogarithm(e,t){var r,n,i,a,s,o,l,c,u,m,h,p=1,d=e,x=d.d,C=d.constructor,f=C.rounding,g=C.precision;if(d.s<0||!x||!x[0]||!d.e&&1==x[0]&&1==x.length)return new C(x&&!x[0]?-1/0:1!=d.s?NaN:x?0:d);if(null==t?(external=!1,u=g):u=t,C.precision=u+=10,n=(r=digitsToString(x)).charAt(0),!(Math.abs(a=d.e)<15e14))return c=getLn10(C,u+2,g).times(a+""),d=naturalLogarithm(new C(n+"."+r.slice(1)),u-10).plus(c),C.precision=g,null==t?finalise(d,g,f,external=!0):d;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=digitsToString((d=d.times(e)).d)).charAt(0),p++;for(a=d.e,n>1?(d=new C("0."+r),a++):d=new C(n+"."+r.slice(1)),m=d,l=s=d=divide(d.minus(1),d.plus(1),u,1),h=finalise(d.times(d),u,1),i=3;;){if(s=finalise(s.times(h),u,1),digitsToString((c=l.plus(divide(s,new C(i),u,1))).d).slice(0,u)===digitsToString(l.d).slice(0,u)){if(l=l.times(2),0!==a&&(l=l.plus(getLn10(C,u+2,g).times(a+""))),l=divide(l,new C(p),u,1),null!=t)return C.precision=g,l;if(!checkRoundingDigits(l.d,u-10,f,o))return finalise(l,C.precision=g,f,external=!0);C.precision=u+=10,c=s=d=divide(m.minus(1),m.plus(1),u,1),h=finalise(d.times(d),u,1),i=o=1}l=c,i+=2}}function nonFiniteToString(e){return String(e.s*e.s/0)}function parseDecimal(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%LOG_BASE,r<0&&(n+=LOG_BASE),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=LOG_BASE;n<i;)e.d.push(+t.slice(n,n+=LOG_BASE));t=t.slice(n),n=LOG_BASE-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),external&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function parseOther(e,t){var r,n,i,a,s,o,l,c,u;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),isDecimal.test(t))return parseDecimal(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(isHex.test(t))r=16,t=t.toLowerCase();else if(isBinary.test(t))r=2;else{if(!isOctal.test(t))throw Error(invalidArgument+t);r=8}for((a=t.search(/p/i))>0?(l=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),s=(a=t.indexOf("."))>=0,n=e.constructor,s&&(a=(o=(t=t.replace(".","")).length)-a,i=intPow(n,new n(r),a,2*a)),a=u=(c=convertBase(t,r,BASE)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=getBase10Exponent(c,u),e.d=c,external=!1,s&&(e=divide(e,i,4*o)),l&&(e=e.times(Math.abs(l)<54?mathpow(2,l):Decimal.pow(2,l))),external=!0,e)}function sine(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:taylorSeries(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=taylorSeries(e,2,t=t.times(1/tinyPow(5,r)),t);for(var i,a=new e(5),s=new e(16),o=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(s.times(i).minus(o))));return t}function taylorSeries(e,t,r,n,i){var a,s,o,l,c=e.precision,u=Math.ceil(c/LOG_BASE);for(external=!1,l=r.times(r),o=new e(n);;){if(s=divide(o.times(l),new e(t++*t++),c,1),o=i?n.plus(s):n.minus(s),n=divide(s.times(l),new e(t++*t++),c,1),void 0!==(s=o.plus(n)).d[u]){for(a=u;s.d[a]===o.d[a]&&a--;);if(-1==a)break}a=o,o=n,n=s,s=a}return external=!0,s.d.length=u+1,s}function tinyPow(e,t){for(var r=e;--t;)r*=e;return r}function toLessThanHalfPi(e,t){var r,n=t.s<0,i=getPi(e,e.precision,1),a=i.times(.5);if((t=t.abs()).lte(a))return quadrant=n?4:1,t;if((r=t.divToInt(i)).isZero())quadrant=n?3:2;else{if((t=t.minus(r.times(i))).lte(a))return quadrant=isOdd(r)?n?2:3:n?4:1,t;quadrant=isOdd(r)?n?1:4:n?3:2}return t.minus(i).abs()}function toStringBinary(e,t,r,n){var i,a,s,o,l,c,u,m,h,p=e.constructor,d=void 0!==r;if(d?(checkInt32(r,1,MAX_DIGITS),void 0===n?n=p.rounding:checkInt32(n,0,8)):(r=p.precision,n=p.rounding),e.isFinite()){for(d?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(s=(u=finiteToString(e)).indexOf("."))>=0&&(u=u.replace(".",""),(h=new p(1)).e=u.length-s,h.d=convertBase(finiteToString(h),10,i),h.e=h.d.length),a=l=(m=convertBase(u,10,i)).length;0==m[--l];)m.pop();if(m[0]){if(s<0?a--:((e=new p(e)).d=m,e.e=a,m=(e=divide(e,h,r,n,0,i)).d,a=e.e,c=inexact),s=m[r],o=i/2,c=c||void 0!==m[r+1],c=n<4?(void 0!==s||c)&&(0===n||n===(e.s<0?3:2)):s>o||s===o&&(4===n||c||6===n&&1&m[r-1]||n===(e.s<0?8:7)),m.length=r,c)for(;++m[--r]>i-1;)m[r]=0,r||(++a,m.unshift(1));for(l=m.length;!m[l-1];--l);for(s=0,u="";s<l;s++)u+=NUMERALS.charAt(m[s]);if(d){if(l>1)if(16==t||8==t){for(s=16==t?4:3,--l;l%s;l++)u+="0";for(l=(m=convertBase(u,i,t)).length;!m[l-1];--l);for(s=1,u="1.";s<l;s++)u+=NUMERALS.charAt(m[s])}else u=u.charAt(0)+"."+u.slice(1);u=u+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)u="0"+u;u="0."+u}else if(++a>l)for(a-=l;a--;)u+="0";else a<l&&(u=u.slice(0,a)+"."+u.slice(a))}else u=d?"0p+0":"0";u=(16==t?"0x":2==t?"0b":8==t?"0o":"")+u}else u=nonFiniteToString(e);return e.s<0?"-"+u:u}function truncate(e,t){if(e.length>t)return e.length=t,!0}function abs(e){return new this(e).abs()}function acos(e){return new this(e).acos()}function acosh(e){return new this(e).acosh()}function add(e,t){return new this(e).plus(t)}function asin(e){return new this(e).asin()}function asinh(e){return new this(e).asinh()}function atan(e){return new this(e).atan()}function atanh(e){return new this(e).atanh()}function atan2(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?getPi(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=getPi(this,a,1).times(.5)).s=e.s:t.s<0?(this.precision=a,this.rounding=1,r=this.atan(divide(e,t,a,1)),t=getPi(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(divide(e,t,a,1)):(r=getPi(this,a,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function cbrt(e){return new this(e).cbrt()}function ceil(e){return finalise(e=new this(e),e.e+1,2)}function clamp(e,t,r){return new this(e).clamp(t,r)}function config(e){if(!e||"object"!=typeof e)throw Error(decimalError+"Object expected");var t,r,n,i=!0===e.defaults,a=["precision",1,MAX_DIGITS,"rounding",0,8,"toExpNeg",-EXP_LIMIT,0,"toExpPos",0,EXP_LIMIT,"maxE",0,EXP_LIMIT,"minE",-EXP_LIMIT,0,"modulo",0,9];for(t=0;t<a.length;t+=3)if(r=a[t],i&&(this[r]=DEFAULTS[r]),void 0!==(n=e[r])){if(!(mathfloor(n)===n&&n>=a[t+1]&&n<=a[t+2]))throw Error(invalidArgument+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=DEFAULTS[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(invalidArgument+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(cryptoUnavailable);this[r]=!0}else this[r]=!1}return this}function cos(e){return new this(e).cos()}function cosh(e){return new this(e).cosh()}function clone(e){var t,r,n;function i(e){var t,r,n,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,isDecimalInstance(e))return a.s=e.s,void(external?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return a.s=1/e<0?-1:1,a.e=0,void(a.d=[0]);if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,r=e;r>=10;r/=10)t++;return void(external?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]))}return 0*e!=0?(e||(a.s=NaN),a.e=NaN,void(a.d=null)):parseDecimal(a,e.toString())}if("string"===n)return 45===(r=e.charCodeAt(0))?(e=e.slice(1),a.s=-1):(43===r&&(e=e.slice(1)),a.s=1),isDecimal.test(e)?parseDecimal(a,e):parseOther(a,e);if("bigint"===n)return e<0?(e=-e,a.s=-1):a.s=1,parseDecimal(a,e.toString());throw Error(invalidArgument+e)}if(i.prototype=P,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=config,i.clone=clone,i.isDecimal=isDecimalInstance,i.abs=abs,i.acos=acos,i.acosh=acosh,i.add=add,i.asin=asin,i.asinh=asinh,i.atan=atan,i.atanh=atanh,i.atan2=atan2,i.cbrt=cbrt,i.ceil=ceil,i.clamp=clamp,i.cos=cos,i.cosh=cosh,i.div=div,i.exp=exp,i.floor=floor,i.hypot=hypot,i.ln=ln,i.log=log,i.log10=log10,i.log2=log2,i.max=max,i.min=min,i.mod=mod,i.mul=mul,i.pow=pow,i.random=random,i.round=round,i.sign=sign,i.sin=sin,i.sinh=sinh,i.sqrt=sqrt,i.sub=sub,i.sum=sum,i.tan=tan,i.tanh=tanh,i.trunc=trunc,void 0===e&&(e={}),e&&!0!==e.defaults)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)e.hasOwnProperty(r=n[t++])||(e[r]=this[r]);return i.config(e),i}function div(e,t){return new this(e).div(t)}function exp(e){return new this(e).exp()}function floor(e){return finalise(e=new this(e),e.e+1,3)}function hypot(){var e,t,r=new this(0);for(external=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return external=!0,new this(1/0);r=t}return external=!0,r.sqrt()}function isDecimalInstance(e){return e instanceof Decimal||e&&e.toStringTag===tag||!1}function ln(e){return new this(e).ln()}function log(e,t){return new this(e).log(t)}function log2(e){return new this(e).log(2)}function log10(e){return new this(e).log(10)}function max(){return maxOrMin(this,arguments,-1)}function min(){return maxOrMin(this,arguments,1)}function mod(e,t){return new this(e).mod(t)}function mul(e,t){return new this(e).mul(t)}function pow(e,t){return new this(e).pow(t)}function random(e){var t,r,n,i,a=0,s=new this(1),o=[];if(void 0===e?e=this.precision:checkInt32(e,1,MAX_DIGITS),n=Math.ceil(e/LOG_BASE),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));a<n;)(i=t[a])>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:o[a++]=i%1e7;else{if(!crypto.randomBytes)throw Error(cryptoUnavailable);for(t=crypto.randomBytes(n*=4);a<n;)(i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((127&t[a+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,a):(o.push(i%1e7),a+=4);a=n/4}else for(;a<n;)o[a++]=1e7*Math.random()|0;for(n=o[--a],e%=LOG_BASE,n&&e&&(i=mathpow(10,LOG_BASE-e),o[a]=(n/i|0)*i);0===o[a];a--)o.pop();if(a<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=LOG_BASE)o.shift();for(n=1,i=o[0];i>=10;i/=10)n++;n<LOG_BASE&&(r-=LOG_BASE-n)}return s.e=r,s.d=o,s}function round(e){return finalise(e=new this(e),e.e+1,this.rounding)}function sign(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function sin(e){return new this(e).sin()}function sinh(e){return new this(e).sinh()}function sqrt(e){return new this(e).sqrt()}function sub(e,t){return new this(e).sub(t)}function sum(){var e=0,t=arguments,r=new this(t[e]);for(external=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return external=!0,finalise(r,this.precision,this.rounding)}function tan(e){return new this(e).tan()}function tanh(e){return new this(e).tanh()}function trunc(e){return finalise(e=new this(e),e.e+1,1)}P[Symbol.for("nodejs.util.inspect.custom")]=P.toString,P[Symbol.toStringTag]="Decimal";var Decimal=P.constructor=clone(DEFAULTS);LN10=new Decimal(LN10),PI=new Decimal(PI);const decimal=null,ComplexConfigKeyTable=["precision","precisionCompare","rounding","toExpPos","minE","maxE","toExpNeg","modulo","crypto"],ComplexInterfaceStaticKeyTable=["LOGICAL","REAL","COMPLEX","defaultSettings","settings","isInstanceOf","set","setNumberType","create","realSet","imagSet","realApply","imagApply","from","real","imag","isComplexValue","isRealValue","realIsInteger","imagIsInteger","realIsFinite","imagIsFinite","realIsNaN","imagIsNaN","realIsNegative","imagIsNegative","realIsZero","imagIsZero","realIsPositive","imagIsPositive","realToNumber","toBoolean","imagToNumber","realLessThan","imagLessThan","realLessThanOrEqualTo","imagLessThanOrEqualTo","realEquals","imagEquals","realGreaterThanOrEqualTo","imagGreaterThanOrEqualTo","realGreaterThan","imagGreaterThan","parse","unparseValue","unparse","toString","unparseMathMLValue","precedence","unparseMathML","copy","toMaxPrecisionValue","toMaxPrecision","epsilonValue","epsilon","random","eq","ne","compareValue","cmp","minMaxArrayReal","minMaxArrayRealWithIndex","minMaxArrayComplex","minMaxArrayComplexWithIndex","min","minWise","max","maxWise","lt","le","gt","ge","false","true","logical","toLogical","and","or","xor","not","zero","one","onediv2","minusonediv2","minusone","pi","pidiv2","onei","onediv2i","minusonediv2i","minusonei","two","sqrt2pi","e","NaN_0","inf_0","add","sub","neg","mul","mulAndSumTo","rdiv","ldiv","inv","power","root","absValue","abs2Value","abs","abs2","hypot","arg","conj","mod","rem","fix","ceil","floor","round","sign","sqrt","exp","log","logb","log2","log10","deg2rad","rad2deg","sin","sind","cos","cosd","tan","tand","csc","cscd","sec","secd","cot","cotd","asin","asind","acos","acosd","atan","atan2","atand","acsc","acscd","asec","asecd","acot","acotd","sinh","cosh","tanh","csch","sech","coth","asinh","acosh","atanh","acsch","asech","acoth","gamma","factorial","applyFunction","mapFunction","twoArgFunction"],roundingMode={ROUND_UP:0,ROUND_DOWN:1,ROUND_CEIL:2,ROUND_FLOOR:3,ROUND_HALF_UP:4,ROUND_HALF_DOWN:5,ROUND_HALF_EVEN:6,ROUND_HALF_CEIL:7,ROUND_HALF_FLOOR:8,EUCLID:9},roundingName=["up","down","ceil","floor","half_up","half_down","half_even","half_ceil","half_floor"],moduloName=["up","down",void 0,"floor",void 0,void 0,"half_even",void 0,void 0,"euclid"],numberClass={LOGICAL:0,REAL:1,COMPLEX:2},setNumberTypeFactory=e=>t=>{e.imagIsZero(t)?(e.realIsZero(t)||e.realEquals(t,1))&&t.type===e.LOGICAL||(t.type=e.REAL):t.type=e.COMPLEX},createFactory=e=>(t,r,n,i)=>new e(t,r,n,i),parseFactory=e=>t=>{const r="0"!==t[0]||"x"!==t[1]&&"X"!==t[1]?t.replace(/[dD]/,"e"):t.replace("_","");return/[ijIJ]$/.test(r)?e.create(0,r.slice(0,-1)):e.create(r,0)},precedenceFactory=e=>(t,r)=>{if(t.type!==e.LOGICAL){const n=e.toMaxPrecision(t);return e.realIsZero(n)||e.imagIsZero(n)?e.realIsZero(n)?e.imagIsZero(n)?e.realIsNegative(n)||e.imagIsNegative(n)?e.realIsNegative(n)&&e.imagIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["+"]:r.precedenceTable["()"]:e.imagIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["()"]:e.realIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["()"]:r.precedenceTable["+"]}return r.precedenceTable["()"]},unparseValueFactory=(e,t)=>r=>{if(e.isFinite(r)){const n=e.unparse(r).split("e");return 1===n.length?n[0].slice(0,t.settings.toExpPos):n[0].slice(0,t.settings.toExpPos)+"e"+Number(n[1])}return e.isNaN(r)?"NaN":(e.isNeg(r)?"-":"")+"&infin;"},unparseFactory=e=>(t,r,n=0)=>{if(t.type!==e.LOGICAL){const i=e.toMaxPrecision(t);if(e.realIsZero(i)||e.imagIsZero(i)){if(e.realIsZero(i)){if(e.imagIsZero(i)){if(e.realIsNegative(i)||e.imagIsNegative(i)){if(e.realIsNegative(i)&&e.imagIsNegative(i)){const e="-0";return n>r.precedenceTable["-_"]?"("+e+")":e}if(e.realIsNegative(i)&&!e.imagIsNegative(i)){const e="-0+0i";return n>r.precedenceTable["+"]?"("+e+")":e}{const e="0-0i";return n>r.precedenceTable["+"]?"("+e+")":e}}return"0"}{const t=(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"-":e.unparseValue(i.im))+"i";return n>(e.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+t+")":t}}{const t=e.unparseValue(i.re);return n>(e.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+t+")":t}}{const t=e.unparseValue(i.re)+(e.imagGreaterThan(i,0)?"+":"")+(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"-":e.unparseValue(i.im))+"i";return n>r.precedenceTable["+"]?"("+t+")":t}}return e.realIsZero(t)?"false":"true"},toStringFactory=e=>t=>{if(t.type!==e.LOGICAL){const r=e.toMaxPrecision(t);return e.realIsZero(r)||e.imagIsZero(r)?e.realIsZero(r)?e.imagIsZero(r)?e.realIsNegative(r)||e.imagIsNegative(r)?e.realIsNegative(r)&&e.imagIsNegative(r)?"-0":e.realIsNegative(r)&&!e.imagIsNegative(r)?"-0+0i":"0-0i":"0":(e.imagEquals(r,1)?"":e.imagEquals(r,-1)?"-":e.unparseValue(r.im))+"i":e.unparseValue(r.re):e.unparseValue(r.re)+(e.imagGreaterThan(r,0)?"+":"")+(e.imagEquals(r,1)?"":e.imagEquals(r,-1)?"-":e.unparseValue(r.im))+"i"}return e.realIsZero(t)?"false":"true"},unparseMathMLValueFactory=(e,t)=>r=>{if(e.isFinite(r)){const n=e.unparse(r).split("e");return 1==n.length?"<mn>"+n[0].slice(0,t.settings.toExpPos)+"</mn>":"<mn>"+n[0].slice(0,t.settings.toExpPos)+"</mn><mo>&sdot;</mo><msup><mrow><mn>10</mn></mrow><mrow><mn>"+Number(n[1])+"</mn></mrow></msup>"}return e.isNaN(r)?"<mi><b>NaN</b></mi>":(e.isNeg(r)?"<mo>-</mo>":"")+"<mi>&infin;</mi>"},unparseMathMLFactory=e=>(t,r,n=0)=>{if(t.type!==e.LOGICAL){const i=e.toMaxPrecision(t);if(e.realIsZero(i)||e.imagIsZero(i)){if(e.realIsZero(i)){if(e.imagIsZero(i)){if(e.realIsNegative(i)||e.imagIsNegative(i)){if(e.realIsNegative(i)&&e.imagIsNegative(i)){const e="<mn>-0</mn>";return n>r.precedenceTable["-_"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}if(e.realIsNegative(i)&&!e.imagIsNegative(i)){const e="<mn>-0</mn><mo>+</mo><mn>0</mn><mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}{const e="<mn>0</mn><mo>-</mo><mn>0</mn><mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}return"<mn>0</mn>"}{const t=(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"<mo>-</mo>":e.unparseMathMLValue(i.im))+"<mi>i</mi>";return n>(e.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(i.re);return n>(e.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(i.re)+(e.imagGreaterThan(i,0)?"<mo>+</mo>":"")+(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"<mo>-</mo>":e.unparseMathMLValue(i.im))+"<mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}return e.realIsZero(t)?"<mi>false</mi>":"<mi>true</mi>"},toMaxPrecisionFactory=e=>t=>new e(e.toMaxPrecisionValue(t.re),e.toMaxPrecisionValue(t.im)),copyFactory=e=>t=>new e(t.re,t.im,t.type),epsilonFactory=e=>()=>new e(e.epsilonValue()),equalsFactory=(e,t=!0)=>t?(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realEquals(n,i.re)&&e.imagEquals(n,i.im)?e.true():e.false()}:(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realEquals(n,i.re)&&e.imagEquals(n,i.im)?e.false():e.true()},cmpFactory=e=>(t,r,n)=>{const i=e.toMaxPrecision(r),a=e.toMaxPrecision(n);if(e.imagIsZero(i)&&e.imagIsZero(a))return e.compareValue(t,i.re,a.re)?e.true():e.false();const s=e.toMaxPrecisionValue(e.abs(r).re),o=e.toMaxPrecisionValue(e.abs(n).re);return e.compareValue("eq",s,o)?e.compareValue(t,e.toMaxPrecisionValue(e.arg(r).re),e.toMaxPrecisionValue(e.arg(n).re))?e.true():e.false():e.compareValue(t,s,o)?e.true():e.false()},minMaxArrayRealFactory=e=>(t,...r)=>r.reduce((r,n)=>e.compareValue(t,r.re,n.re)?r:n,r[0]),minMaxArrayRealWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,i,a)=>e.compareValue(t,r.re,i.re)?r:(n=a,i),r[r.length-1]),n]},minMaxArrayComplexFactory=e=>(t,...r)=>r.reduce((r,n)=>{const i=e.abs(r).re,a=e.abs(n).re;return e.compareValue("eq",i,a)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,a)?r:n},r[0]),minMaxArrayComplexWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,i,a)=>{const s=e.abs(r).re,o=e.abs(i).re;return e.compareValue("eq",s,o)?e.compareValue(t,e.arg(r).re,e.arg(i).re)?r:(n=a,i):e.compareValue(t,s,o)?r:(n=a,i)},r[r.length-1]),n]},minMaxFactory=(e,t)=>(r,n)=>{if(e.imagIsZero(r)&&e.imagIsZero(n))return e.compareValue(t,r.re,n.re)?r:n;{const i=e.abs(r).re,a=e.abs(n).re;return e.compareValue("eq",i,a)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,a)?r:n}},minMaxWiseFactory=(e,t)=>(r,n)=>{if(r.type<=e.REAL&&r.type<=e.REAL)return e.compareValue(t,r.re,n.re)?r:n;{const i=e.abs(r).re,a=e.abs(n).re;return e.compareValue("eq",i,a)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,a)?r:n}},comparisonFactory=(e,t)=>(r,n)=>e.cmp(t,r,n),logicalFactory=e=>t=>{const r=e.toMaxPrecision(t);return new e(e.realIsZero(r)&&e.imagIsZero(r)?0:1,0,e.LOGICAL)},andFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)||e.realIsZero(i)&&e.imagIsZero(i)?e.false():e.true()},orFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&e.realIsZero(i)&&e.imagIsZero(i)?e.false():e.true()},xorFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&(!e.realIsZero(i)||!e.imagIsZero(i))||(!e.realIsZero(n)||!e.imagIsZero(n))&&e.realIsZero(i)&&e.imagIsZero(i)?e.true():e.false()},notFactory=e=>t=>{const r=e.toMaxPrecision(t);return e.realIsZero(r)&&e.imagIsZero(r)?e.true():e.false()},literalFactory=(e,t,r,n)=>()=>new e(t,r,n),mulFactory=(e,t)=>(r,n)=>t.imagIsZero(r)&&t.imagIsZero(n)?new t(e.mul(r.re,n.re),e.ZERO):new t(e.sub(e.mul(r.re,n.re),e.mul(r.im,n.im)),e.add(e.mul(r.re,n.im),e.mul(r.im,n.re))),mulAndSumToFactory=(e,t)=>(r,n,i)=>(t.imagIsZero(n)&&t.imagIsZero(i)&&t.imagIsZero(r)?r.re=e.add(r.re,e.mul(n.re,i.re)):(r.re=e.add(r.re,e.sub(e.mul(n.re,i.re),e.mul(n.im,i.im))),r.im=e.add(r.im,e.add(e.mul(n.re,i.im),e.mul(n.im,i.re)))),r),rdivFactory=(e,t)=>(r,n)=>{if(e.isZero(n.im))return e.isFinite(n.re)?e.isZero(n.re)?new t(e.mul(r.re,e.INF),e.mul(r.im,e.INF)):new t(e.div(r.re,n.re),e.div(r.im,n.re)):e.isNaN(n.re)?(t.realIsFinite(n)||t.realIsNaN(n))&&(t.imagIsFinite(n)||t.imagIsNaN(n))?new t(NaN,0):t.zero():t.realIsFinite(r)&&t.imagIsFinite(r)?t.zero():new t(NaN,0);{const i=e.add(e.mul(n.re,n.re),e.mul(n.im,n.im));return e.isFinite(i)?e.isZero(i)?new t(e.mul(r.re,e.INF),t.imagIsZero(r)?e.ZERO:e.mul(r.im,e.INF)):new t(e.div(e.add(e.mul(r.re,n.re),e.mul(r.im,n.im)),i),e.div(e.sub(e.mul(r.im,n.re),e.mul(r.re,n.im)),i)):e.isNaN(i)?(t.realIsFinite(n)||t.realIsNaN(n))&&(t.imagIsFinite(n)||t.imagIsNaN(n))?new t(NaN,0):t.zero():t.realIsFinite(r)&&t.imagIsFinite(r)?t.zero():new t(NaN,0)}},ldivFactory=(e,t)=>{const r=rdivFactory(e,t);return(e,t)=>r(t,e)},invFactory=(e,t)=>r=>{const n=e.add(e.mul(r.re,r.re),e.mul(r.im,r.im));return e.isFinite(n)?e.isZero(n)?new t(1/0,0):new t(e.div(r.re,n),e.neg(e.div(r.im,n))):e.isNaN(n)&&(t.realIsFinite(r)||t.realIsNaN(r))&&(t.imagIsFinite(r)||t.imagIsNaN(r))?new t(NaN,0):t.zero()},powerFactory=(e,t)=>(r,n)=>{if(t.imagIsZero(r)&&t.imagIsZero(n)&&t.realGreaterThanOrEqualTo(r,0))return new t(e.pow(r.re,n.re),0);{const i=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,t.realIsZero(r)?e.ZERO:r.re),a=e.add(e.mul(r.re,r.re),e.mul(r.im,r.im)),s=e.mul(e.pow(a,e.div(n.re,e.TWO)),e.exp(e.mul(e.mul(e.MINUSONE,n.im),i))),o=e.add(e.mul(n.re,i),e.mul(e.div(n.im,e.TWO),e.ln(a)));return new t(e.mul(s,e.cos(o)),t.imagIsZero(r)&&t.imagIsZero(n)&&(t.realGreaterThanOrEqualTo(n,1)||t.realLessThanOrEqualTo(n,-1))?0:e.mul(s,e.sin(o)))}},rootFactory=e=>(t,r)=>e.power(t,e.inv(r)),absValueFactory=e=>t=>e.sqrt(e.add(e.mul(t.re,t.re),e.mul(t.im,t.im))),abs2ValueFactory=e=>t=>e.add(e.mul(t.re,t.re),e.mul(t.im,t.im)),absFactory=(e,t)=>r=>t.imagIsZero(r)?new t(e.abs(r.re)):new t(t.absValue(r)),abs2Factory=(e,t)=>r=>{const n=e.abs(r.re);return t.imagIsZero(r)?new t(e.mul(n,n)):new t(t.abs2Value(r))},hypotFactory=e=>(t,r)=>new e(e.absValue(new e(e.absValue(t),e.absValue(r)))),argFactory=(e,t)=>r=>new t(e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),0),conjFactory=(e,t)=>r=>new t(r.re,e.neg(r.im)),modFactory=(e,t)=>(r,n)=>{if(!t.imagIsZero(r)||!t.imagIsZero(n))throw new Error("mod: not defined for complex numbers");return t.realIsZero(n)?r:new t(e.mod(r.re,n.re))},remFactory=(e,t)=>(r,n)=>{if(!t.imagIsZero(r)||!t.imagIsZero(n))throw new Error("rem: not defined for complex numbers");return new t(e.mod(r.re,n.re))},fixFactory=(e,t)=>r=>new t(e.trunc(r.re),e.trunc(r.im)),ceilFactory=(e,t)=>r=>new t(e.ceil(r.re),e.ceil(r.im)),floorFactory=(e,t)=>r=>new t(e.floor(r.re),e.floor(r.im)),roundFactory=(e,t)=>r=>new t(e.round(r.re),e.round(r.im)),signFactory=(e,t)=>r=>t.realIsZero(r)?t.imagIsZero(r)?t.zero():new t(0,e.div(r.im,t.absValue(r))):t.imagIsZero(r)?new t(e.div(r.re,t.absValue(r)),0):new t(e.div(r.re,t.absValue(r)),e.div(r.im,t.absValue(r))),sqrtFactory=(e,t)=>r=>{const n=t.absValue(r),i=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re);return new t(e.mul(e.sqrt(n),e.cos(e.div(i,e.TWO))),e.mul(e.sqrt(n),e.sin(e.div(i,e.TWO))))},expFactory=(e,t)=>r=>new t(e.mul(e.exp(r.re),e.cos(r.im)),e.mul(e.exp(r.re),e.sin(r.im))),logFactory=(e,t)=>r=>new t(e.ln(t.absValue(r)),e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re)),logbFactory=(e,t)=>(r,n)=>{const i=t.absValue(r);if(e.isZero(i))return t.zero();{const a=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),s=t.absValue(n),o=e.atan2(t.imagIsZero(n)?e.ZERO:n.im,n.re),l=e.add(e.mul(e.ln(i),e.ln(i)),e.mul(a,a));return new t(e.div(e.add(e.mul(e.ln(s),e.ln(i)),e.mul(o,a)),l),e.div(e.sub(e.mul(o,e.ln(i)),e.mul(e.ln(s),a)),l))}},log2Factory=e=>t=>e.logb(new e(2),t),log10Factory=e=>t=>e.logb(new e(10),t),deg2radFactory=(e,t)=>r=>new t(e.mul(e.div(e.PI,e.PI_DEG),r.re),e.mul(e.div(e.PI,e.PI_DEG),r.im)),rad2degFactory=(e,t)=>r=>new t(e.mul(e.div(e.PI_DEG,e.PI),r.re),e.mul(e.div(e.PI_DEG,e.PI),r.im)),sinFactory=(e,t)=>r=>new t(e.mul(e.sin(r.re),e.cosh(r.im)),e.mul(e.cos(r.re),e.sinh(r.im))),sindFactory=e=>t=>e.sin(e.deg2rad(t)),cosFactory=(e,t)=>r=>new t(e.mul(e.cos(r.re),e.cosh(r.im)),e.mul(e.sin(r.re),e.neg(e.sinh(r.im)))),cosdFactory=e=>t=>e.cos(e.deg2rad(t)),tanFactory=e=>t=>e.rdiv(e.sin(t),e.cos(t)),tandFactory=e=>t=>e.tan(e.deg2rad(t)),cscFactory=e=>t=>e.rdiv(e.one(),e.sin(t)),cscdFactory=e=>t=>e.csc(e.deg2rad(t)),secFactory=e=>t=>e.rdiv(e.one(),e.cos(t)),secdFactory=e=>t=>e.sec(e.deg2rad(t)),cotFactory=e=>t=>e.rdiv(e.cos(t),e.sin(t)),cotdFactory=e=>t=>e.rdiv(e.cos(t),e.sin(t)),asinFactory=e=>t=>e.mul(e.onei(),e.log(e.sub(e.sqrt(e.sub(e.one(),e.power(t,e.two()))),e.mul(e.onei(),t)))),asindFactory=e=>t=>e.rad2deg(e.asin(t)),acosFactory=e=>t=>e.sub(e.pidiv2(),e.asin(t)),acosdFactory=e=>t=>e.rad2deg(e.acos(t)),atanFactory=e=>t=>e.mul(e.minusonediv2i(),e.log(e.rdiv(e.sub(e.onei(),t),e.add(e.onei(),t)))),atan2Factory=(e,t)=>(r,n)=>{const i=e.div(e.add(e.mul(r.re,n.re),e.mul(r.im,n.im)),e.add(e.mul(n.re,n.re),e.mul(n.im,n.im))),a=e.div(e.sub(e.mul(r.im,n.re),e.mul(r.re,n.im)),e.add(e.mul(n.re,n.re),e.mul(n.im,n.im)));return t.create(e.mul(e.create(.5),e.atan(e.div(e.mul(e.create(2),i),e.sub(e.sub(e.create(1),e.mul(i,i)),e.mul(a,a))))),e.mul(e.create(-1/4),e.ln(e.div(e.add(e.mul(e.sub(e.create(1),a),e.sub(e.create(1),a)),e.mul(i,i)),e.add(e.mul(e.add(e.create(1),a),e.add(e.create(1),a)),e.mul(i,i))))))},atandFactory=e=>t=>e.rad2deg(e.atan(t)),acscFactory=e=>t=>e.asin(e.rdiv(e.one(),t)),acscdFactory=e=>t=>e.rad2deg(e.acsc(t)),asecFactory=e=>t=>e.acos(e.rdiv(e.one(),t)),asecdFactory=e=>t=>e.rad2deg(e.asec(t)),acotFactory=e=>t=>e.atan(e.rdiv(e.one(),t)),acotdFactory=e=>t=>e.rad2deg(e.acot(t)),sinhFactory=(e,t)=>r=>new t(e.mul(e.sinh(r.re),e.cos(r.im)),e.mul(e.cosh(r.re),e.sin(r.im))),coshFactory=(e,t)=>r=>new t(e.mul(e.cosh(r.re),e.cos(r.im)),e.mul(e.sinh(r.re),e.sin(r.im))),tanhFactory=e=>t=>e.rdiv(e.sinh(t),e.cosh(t)),cschFactory=e=>t=>e.rdiv(e.one(),e.sinh(t)),sechFactory=e=>t=>e.rdiv(e.one(),e.cosh(t)),cothFactory=e=>t=>e.rdiv(e.cosh(t),e.sinh(t)),asinhFactory=e=>t=>e.log(e.add(e.sqrt(e.add(e.one(),e.power(t,e.two()))),t)),acoshFactory=e=>t=>e.log(e.add(e.sqrt(e.add(e.minusone(),e.power(t,e.two()))),t)),atanhFactory=e=>t=>e.mul(e.onediv2(),e.log(e.rdiv(e.add(e.one(),t),e.sub(e.one(),t)))),acschFactory=e=>t=>e.rdiv(e.one(),e.asinh(t)),asechFactory=e=>t=>e.rdiv(e.one(),e.acosh(t)),acothFactory=e=>t=>e.rdiv(e.one(),e.atanh(t)),gammaFactory=e=>t=>{const r=["0.99999999999980993","676.5203681218851","-1259.1392167224028","771.32342877765313","-176.61502916214059","12.507343278686905","-0.13857109526572012","9.9843695780195716e-6","1.5056327351493116e-7"];if(e.realLessThan(t,.5))return e.rdiv(e.pi(),e.mul(e.sin(e.mul(e.pi(),t)),e.gamma(e.sub(e.one(),t))));{t=e.sub(t,e.one());let n=new e(r[0]);const i=e.add(t,new e(r.length-1.5));for(let i=1;i<r.length;i++)n=e.add(n,e.rdiv(new e(r[i]),e.add(t,new e(i))));return e.mul(e.mul(e.sqrt2pi(),e.power(i,e.add(t,new e(.5)))),e.mul(e.exp(e.neg(i)),n))}},factorialFactory=(e,t)=>r=>{if(!(t.realGreaterThanOrEqualTo(r,0)&&t.realIsInteger(r)&&t.imagIsZero(r)))throw new Error("factorial: all N must be real non-negative integers");const n=t.gamma(t.add(new t(e.round(r.re)),t.one()));return t.realApply(n,t.applyFunction.trunc),n},applyFunctionFactory=e=>({fix:t=>e.trunc(t),ceil:t=>e.ceil(t),floor:t=>e.floor(t),round:t=>e.round(t),sign:t=>e.create(e.sign(t)),trunc:t=>e.trunc(t)}),mapFunctionFactory=e=>({real:e.real,imag:e.imag,logical:e.logical,abs:e.abs,arg:e.arg,conj:e.conj,fix:e.fix,ceil:e.ceil,floor:e.floor,round:e.round,sign:e.sign,sqrt:e.sqrt,exp:e.exp,log:e.log,log2:e.log2,log10:e.log10,deg2rad:e.deg2rad,rad2deg:e.rad2deg,sin:e.sin,sind:e.sind,cos:e.cos,cosd:e.cosd,tan:e.tan,tand:e.tand,csc:e.csc,cscd:e.cscd,sec:e.sec,secd:e.secd,cot:e.cot,cotd:e.cotd,asin:e.asin,asind:e.asind,acos:e.acos,acosd:e.acosd,atan:e.atan,atand:e.atand,acsc:e.acsc,acscd:e.acscd,asec:e.asec,asecd:e.asecd,acot:e.acot,acotd:e.acotd,sinh:e.sinh,cosh:e.cosh,tanh:e.tanh,csch:e.csch,sech:e.sech,coth:e.coth,asinh:e.asinh,acosh:e.acosh,atanh:e.atanh,acsch:e.acsch,asech:e.asech,acoth:e.acoth,gamma:e.gamma,factorial:e.factorial}),twoArgFunctionFactory=e=>({root:e.root,hypot:e.hypot,power:e.power,logb:e.logb,atan2:e.atan2}),defaultSettings={precision:15,precisionCompare:0,rounding:roundingMode.ROUND_HALF_EVEN,toExpPos:21,toExpNeg:-7,minE:-324,maxE:308,modulo:roundingMode.ROUND_DOWN,crypto:!1};Math.add=(e,t)=>e+t,Math.sub=(e,t)=>e-t,Math.neg=e=>-e,Math.mul=(e,t)=>e*t,Math.div=(e,t)=>e/t,Math.mod=(e,t)=>e%t,Math.ln=Math.log,Math.create=e=>Number(e),Math.MINUSONE=-1,Math.ZERO=0,Math.TWO=2,Math.PI_DEG=180,Math.INF=1/0,Math.unparse=e=>0===e?Object.is(e,-0)?"-0":"0":e.toString(),Math.isZero=e=>0===e,Math.isNeg=e=>0===e?Object.is(e,-0):e<0,Math.isNaN=Number.isNaN,Math.isFinite=Number.isFinite;class ComplexNumber{static LOGICAL=numberClass.LOGICAL;static REAL=numberClass.REAL;static COMPLEX=numberClass.COMPLEX;static defaultSettings=Object.assign({},defaultSettings);static settings=this.defaultSettings;static isInstanceOf=e=>e instanceof ComplexNumber;static set=e=>{};re;im;type;parent;static setNumberType=setNumberTypeFactory(ComplexNumber);constructor(e,t,r,n){this.re=e?Number(e):0,this.im=t?Number(t):0,this.type=r??ComplexNumber.COMPLEX,n&&(this.parent=n),ComplexNumber.setNumberType(this)}static create=(e,t,r,n)=>new ComplexNumber(e,t,r,n);static realSet=(e,t)=>{e.re=Number(t)};static imagSet=(e,t)=>{e.im=Number(t)};static realApply=(e,t)=>{e.re=t(e.re)};static imagApply=(e,t)=>{e.im=t(e.im)};static from=e=>new ComplexNumber(e.re,e.im,e.type);static real=e=>new ComplexNumber(e.re);static imag=e=>new ComplexNumber(e.im);static isComplexValue=e=>0!==e.im;static isRealValue=e=>0===e.im;static realIsInteger=e=>Number.isInteger(e.re);static imagIsInteger=e=>Number.isInteger(e.im);static realIsFinite=e=>Number.isFinite(e.re);static imagIsFinite=e=>Number.isFinite(e.im);static realIsNaN=e=>Number.isNaN(e.re);static imagIsNaN=e=>Number.isNaN(e.im);static realIsNegative=e=>e.re<0||Object.is(e.re,-0);static imagIsNegative=e=>e.im<0||Object.is(e.im,-0);static realIsZero=e=>0===e.re;static imagIsZero=e=>0===e.im;static realIsPositive=e=>e.re>=0;static imagIsPositive=e=>e.im>=0;static realToNumber=e=>e.re;static toBoolean=e=>e.type===ComplexNumber.LOGICAL?Boolean(e.re):Boolean(e.re)||Boolean(e.im);static imagToNumber=e=>e.im;static realLessThan=(e,t)=>e.re<Number(t);static imagLessThan=(e,t)=>e.im<Number(t);static realLessThanOrEqualTo=(e,t)=>e.re<=Number(t);static imagLessThanOrEqualTo=(e,t)=>e.im<=Number(t);static realEquals=(e,t)=>e.re===Number(t);static imagEquals=(e,t)=>e.im===Number(t);static realGreaterThanOrEqualTo=(e,t)=>e.re>=Number(t);static imagGreaterThanOrEqualTo=(e,t)=>e.im>=Number(t);static realGreaterThan=(e,t)=>e.re>Number(t);static imagGreaterThan=(e,t)=>e.im>Number(t);static parse=parseFactory(ComplexNumber);static precedence=precedenceFactory(ComplexNumber);static unparseValue=unparseValueFactory(Math,ComplexNumber);static unparse=unparseFactory(ComplexNumber);static toString=toStringFactory(ComplexNumber);toString(){return ComplexNumber.toString(this)}static unparseMathMLValue=unparseMathMLValueFactory(Math,ComplexNumber);static unparseMathML=unparseMathMLFactory(ComplexNumber);static copy=copyFactory(ComplexNumber);copy=()=>new ComplexNumber(this.re,this.im,this.type);static toMaxPrecisionValue=e=>{const t=this.settings.precision-this.settings.precisionCompare;return Number(Number(e.toPrecision(t)).toFixed(t))};static toMaxPrecision=toMaxPrecisionFactory(ComplexNumber);static epsilonValue(){return Math.max(Math.pow(10,-this.settings.precision+this.settings.precisionCompare),Number.EPSILON)}static epsilon=epsilonFactory(ComplexNumber);static random=e=>{if(void 0!==e&&15!==e){if(e<15)return new ComplexNumber(Math.random().toPrecision(e));throw new Error(`invalid number of significant digits: ${e}`)}return new ComplexNumber(Math.random())};static eq=equalsFactory(ComplexNumber,!0);static ne=equalsFactory(ComplexNumber,!1);static compareValue=(e,t,r)=>{switch(e){case"lt":return t<r;case"lte":return t<=r;case"eq":return t===r;case"gte":return t>=r;case"gt":return t>r}};static cmp=cmpFactory(ComplexNumber);static minMaxArrayReal=minMaxArrayRealFactory(ComplexNumber);static minMaxArrayRealWithIndex=minMaxArrayRealWithIndexFactory(ComplexNumber);static minMaxArrayComplex=minMaxArrayComplexFactory(ComplexNumber);static minMaxArrayComplexWithIndex=minMaxArrayComplexWithIndexFactory(ComplexNumber);static min=minMaxFactory(ComplexNumber,"lt");static minWise=minMaxWiseFactory(ComplexNumber,"lt");static max=minMaxFactory(ComplexNumber,"gte");static maxWise=minMaxWiseFactory(ComplexNumber,"gte");static lt=comparisonFactory(ComplexNumber,"lt");static le=comparisonFactory(ComplexNumber,"lte");static gt=comparisonFactory(ComplexNumber,"gt");static ge=comparisonFactory(ComplexNumber,"gte");static false=()=>new ComplexNumber(0,0,ComplexNumber.LOGICAL);static true=()=>new ComplexNumber(1,0,ComplexNumber.LOGICAL);static logical=logicalFactory(ComplexNumber);static toLogical=e=>ComplexNumber.logical(e);toLogical=()=>ComplexNumber.logical(this);static and=andFactory(ComplexNumber);static or=orFactory(ComplexNumber);static xor=xorFactory(ComplexNumber);static not=notFactory(ComplexNumber);static zero=literalFactory(ComplexNumber,0,0);static one=literalFactory(ComplexNumber,1,0);static onediv2=literalFactory(ComplexNumber,.5,0);static minusonediv2=literalFactory(ComplexNumber,-.5,0);static minusone=literalFactory(ComplexNumber,-1,0);static pi=literalFactory(ComplexNumber,Math.PI,0);static pidiv2=literalFactory(ComplexNumber,Math.PI/2,0);static onei=literalFactory(ComplexNumber,0,1);static onediv2i=literalFactory(ComplexNumber,0,.5);static minusonediv2i=literalFactory(ComplexNumber,0,-.5);static minusonei=literalFactory(ComplexNumber,0,-1);static two=literalFactory(ComplexNumber,2,0);static sqrt2pi=literalFactory(ComplexNumber,Math.sqrt(2*Math.PI),0);static e=literalFactory(ComplexNumber,Math.E,0);static NaN_0=literalFactory(ComplexNumber,NaN,0);static inf_0=literalFactory(ComplexNumber,1/0,0);static add=(e,t)=>new ComplexNumber(e.re+t.re,e.im+t.im);static sub=(e,t)=>new ComplexNumber(e.re-t.re,e.im-t.im);static neg=e=>new ComplexNumber(-e.re,-e.im);static mul=mulFactory(Math,ComplexNumber);static mulAndSumTo=mulAndSumToFactory(Math,ComplexNumber);static rdiv=rdivFactory(Math,ComplexNumber);static ldiv=ldivFactory(Math,ComplexNumber);static inv=invFactory(Math,ComplexNumber);static power=powerFactory(Math,ComplexNumber);static root=rootFactory(ComplexNumber);static absValue=absValueFactory(Math);static abs2Value=abs2ValueFactory(Math);static abs=absFactory(Math,ComplexNumber);static abs2=abs2Factory(Math,ComplexNumber);static hypot=hypotFactory(ComplexNumber);static arg=argFactory(Math,ComplexNumber);static conj=conjFactory(Math,ComplexNumber);static mod=modFactory(Math,ComplexNumber);static rem=remFactory(Math,ComplexNumber);static fix=fixFactory(Math,ComplexNumber);static ceil=ceilFactory(Math,ComplexNumber);static floor=floorFactory(Math,ComplexNumber);static round=roundFactory(Math,ComplexNumber);static sign=signFactory(Math,ComplexNumber);static sqrt=sqrtFactory(Math,ComplexNumber);static exp=expFactory(Math,ComplexNumber);static log=logFactory(Math,ComplexNumber);static logb=logbFactory(Math,ComplexNumber);static log2=log2Factory(ComplexNumber);static log10=log10Factory(ComplexNumber);static deg2rad=deg2radFactory(Math,ComplexNumber);static rad2deg=rad2degFactory(Math,ComplexNumber);static sin=sinFactory(Math,ComplexNumber);static sind=sindFactory(ComplexNumber);static cos=cosFactory(Math,ComplexNumber);static cosd=cosdFactory(ComplexNumber);static tan=tanFactory(ComplexNumber);static tand=tandFactory(ComplexNumber);static csc=cscFactory(ComplexNumber);static cscd=cscdFactory(ComplexNumber);static sec=secFactory(ComplexNumber);static secd=secdFactory(ComplexNumber);static cot=cotFactory(ComplexNumber);static cotd=cotdFactory(ComplexNumber);static asin=asinFactory(ComplexNumber);static asind=asindFactory(ComplexNumber);static acos=acosFactory(ComplexNumber);static acosd=acosdFactory(ComplexNumber);static atan=atanFactory(ComplexNumber);static atan2=atan2Factory(Math,ComplexNumber);static atand=atandFactory(ComplexNumber);static acsc=acscFactory(ComplexNumber);static acscd=acscdFactory(ComplexNumber);static asec=asecFactory(ComplexNumber);static asecd=asecdFactory(ComplexNumber);static acot=acotFactory(ComplexNumber);static acotd=acotdFactory(ComplexNumber);static sinh=sinhFactory(Math,ComplexNumber);static cosh=coshFactory(Math,ComplexNumber);static tanh=tanhFactory(ComplexNumber);static csch=cschFactory(ComplexNumber);static sech=sechFactory(ComplexNumber);static coth=cothFactory(ComplexNumber);static asinh=asinhFactory(ComplexNumber);static acosh=acoshFactory(ComplexNumber);static atanh=atanhFactory(ComplexNumber);static acsch=acschFactory(ComplexNumber);static asech=asechFactory(ComplexNumber);static acoth=acothFactory(ComplexNumber);static gamma=gammaFactory(ComplexNumber);static factorial=factorialFactory(Math,ComplexNumber);static applyFunction=applyFunctionFactory(Math);static mapFunction=mapFunctionFactory(ComplexNumber);static twoArgFunction=twoArgFunctionFactory(ComplexNumber)}ComplexNumber.set(ComplexNumber.defaultSettings);const src_ComplexNumber={ComplexNumber},ComplexDecimal_defaultSettings={precision:336,rounding:Decimal.ROUND_HALF_DOWN,toExpPos:20,toExpNeg:-7,minE:-9e15,maxE:9e15,modulo:Decimal.ROUND_DOWN,crypto:!1};Decimal.set(ComplexDecimal_defaultSettings),Decimal.create=e=>new Decimal(e),Decimal.neg=e=>e.neg(),Decimal.MINUSONE=new Decimal(-1),Decimal.ZERO=new Decimal(0),Decimal.TWO=new Decimal(2),Decimal.PI=Decimal.acos(-1),Decimal.PI_DEG=new Decimal(180),Decimal.INF=new Decimal(1/0),Decimal.unparse=e=>e.valueOf(),Decimal.isZero=e=>e.isZero(),Decimal.isNeg=e=>e.isNeg(),Decimal.isNaN=e=>e.isNaN(),Decimal.isFinite=e=>e.isFinite();class ComplexDecimal{static LOGICAL=numberClass.LOGICAL;static REAL=numberClass.REAL;static COMPLEX=numberClass.COMPLEX;static defaultSettings=Object.assign({precisionCompare:7},ComplexDecimal_defaultSettings);static settings=ComplexDecimal.defaultSettings;static isInstanceOf=e=>e instanceof ComplexDecimal;static set=e=>{const t={};ComplexConfigKeyTable.forEach(r=>{void 0!==e[r]&&(this.settings[r]="precisionCompare"!==r?t[r]=e[r]:e[r])}),Object.keys(t).length>0&&Decimal.set(t)};re;im;type;parent;static setNumberType=setNumberTypeFactory(ComplexDecimal);constructor(e,t,r,n){this.re=new Decimal(e||0),this.im=new Decimal(t||0),this.type=r??ComplexDecimal.COMPLEX,this.parent=n??void 0,ComplexDecimal.setNumberType(this)}static create=createFactory(ComplexDecimal);static realSet=(e,t)=>{e.re=new Decimal(t)};static imagSet=(e,t)=>{e.im=new Decimal(t)};static realApply=(e,t)=>{e.re=t(e.re)};static imagApply=(e,t)=>{e.im=t(e.im)};static from=e=>new ComplexDecimal(e.re,e.im,e.type,e.parent);static real=e=>new ComplexDecimal(e.re);static imag=e=>new ComplexDecimal(e.im);static isComplexValue=e=>!e.im.isZero();static isRealValue=e=>e.im.isZero();static realIsInteger=e=>e.re.isInteger();static imagIsInteger=e=>e.im.isInteger();static realIsFinite=e=>e.re.isFinite();static imagIsFinite=e=>e.im.isFinite();static realIsNaN=e=>e.re.isNaN();static imagIsNaN=e=>e.im.isNaN();static realIsNegative=e=>e.re.isNegative();static imagIsNegative=e=>e.im.isNegative();static realIsZero=e=>e.re.isZero();static imagIsZero=e=>e.im.isZero();static realIsPositive=e=>e.re.isPositive();static imagIsPositive=e=>e.im.isPositive();static realToNumber=e=>e.re.toNumber();static toBoolean=e=>e.type===ComplexDecimal.LOGICAL?Boolean(e.re.toNumber()):Boolean(e.re.toNumber())||Boolean(e.im.toNumber());static imagToNumber=e=>e.im.toNumber();static realLessThan=(e,t)=>e.re.lt(t);static imagLessThan=(e,t)=>e.im.lt(t);static realLessThanOrEqualTo=(e,t)=>e.re.lte(t);static imagLessThanOrEqualTo=(e,t)=>e.im.lte(t);static realEquals=(e,t)=>e.re.eq(t);static imagEquals=(e,t)=>e.im.eq(t);static realGreaterThanOrEqualTo=(e,t)=>e.re.gte(t);static imagGreaterThanOrEqualTo=(e,t)=>e.im.gte(t);static realGreaterThan=(e,t)=>e.re.gt(t);static imagGreaterThan=(e,t)=>e.im.gt(t);static parse=parseFactory(ComplexDecimal);static precedence=precedenceFactory(ComplexDecimal);static unparseValue=unparseValueFactory(Decimal,ComplexDecimal);static unparse=unparseFactory(ComplexDecimal);static toString=toStringFactory(ComplexDecimal);toString(){return ComplexDecimal.toString(this)}static unparseMathMLValue=unparseMathMLValueFactory(Decimal,ComplexDecimal);static unparseMathML=unparseMathMLFactory(ComplexDecimal);static copy=copyFactory(ComplexDecimal);copy=()=>new ComplexDecimal(this.re,this.im,this.type);static toMaxPrecisionValue=e=>{const t=this.settings.precision-this.settings.precisionCompare;return e.toSignificantDigits(t).toDecimalPlaces(t)};static toMaxPrecision=toMaxPrecisionFactory(ComplexDecimal);static epsilonValue=()=>Decimal.pow(10,-this.settings.precision+this.settings.precisionCompare);static epsilon=epsilonFactory(ComplexDecimal);static random=e=>new ComplexDecimal(Decimal.random(e));static eq=equalsFactory(ComplexDecimal,!0);static ne=equalsFactory(ComplexDecimal,!1);static compareValue=(e,t,r)=>t[e](r);static cmp=cmpFactory(ComplexDecimal);static minMaxArrayReal=minMaxArrayRealFactory(ComplexDecimal);static minMaxArrayRealWithIndex=minMaxArrayRealWithIndexFactory(ComplexDecimal);static minMaxArrayComplex=minMaxArrayComplexFactory(ComplexDecimal);static minMaxArrayComplexWithIndex=minMaxArrayComplexWithIndexFactory(ComplexDecimal);static min=minMaxFactory(ComplexDecimal,"lt");static minWise=minMaxWiseFactory(ComplexDecimal,"lt");static max=minMaxFactory(ComplexDecimal,"gte");static maxWise=minMaxWiseFactory(ComplexDecimal,"gte");static lt=comparisonFactory(ComplexDecimal,"lt");static le=comparisonFactory(ComplexDecimal,"lte");static gt=comparisonFactory(ComplexDecimal,"gt");static ge=comparisonFactory(ComplexDecimal,"gte");static false=literalFactory(ComplexDecimal,0,0,ComplexDecimal.LOGICAL);static true=literalFactory(ComplexDecimal,1,0,ComplexDecimal.LOGICAL);static logical=logicalFactory(ComplexDecimal);static toLogical=e=>ComplexDecimal.logical(e);toLogical=()=>ComplexDecimal.logical(this);static and=andFactory(ComplexDecimal);static or=orFactory(ComplexDecimal);static xor=xorFactory(ComplexDecimal);static not=notFactory(ComplexDecimal);static zero=literalFactory(ComplexDecimal,0,0);static one=literalFactory(ComplexDecimal,1,0);static onediv2=literalFactory(ComplexDecimal,.5,0);static minusonediv2=literalFactory(ComplexDecimal,-.5,0);static minusone=literalFactory(ComplexDecimal,-1,0);static pi=literalFactory(ComplexDecimal,Decimal.acos(-1),0);static pidiv2=literalFactory(ComplexDecimal,Decimal.div(Decimal.acos(-1),2),0);static onei=literalFactory(ComplexDecimal,0,1);static onediv2i=literalFactory(ComplexDecimal,0,.5);static minusonediv2i=literalFactory(ComplexDecimal,0,-.5);static minusonei=literalFactory(ComplexDecimal,0,-1);static two=literalFactory(ComplexDecimal,2,0);static sqrt2pi=literalFactory(ComplexDecimal,Decimal.sqrt(Decimal.mul(2,Decimal.acos(-1))),0);static e=literalFactory(ComplexDecimal,Decimal.exp(1),0);static NaN_0=literalFactory(ComplexDecimal,NaN,0);static inf_0=literalFactory(ComplexDecimal,1/0,0);static add=(e,t)=>new ComplexDecimal(Decimal.add(e.re,t.re),Decimal.add(e.im,t.im));static sub=(e,t)=>new ComplexDecimal(Decimal.sub(e.re,t.re),Decimal.sub(e.im,t.im));static neg=e=>new ComplexDecimal(e.re.neg(),e.im.neg());static mul=mulFactory(Decimal,ComplexDecimal);static mulAndSumTo=mulAndSumToFactory(Decimal,ComplexDecimal);static rdiv=rdivFactory(Decimal,ComplexDecimal);static ldiv=ldivFactory(Decimal,ComplexDecimal);static inv=invFactory(Decimal,ComplexDecimal);static power=powerFactory(Decimal,ComplexDecimal);static root=rootFactory(ComplexDecimal);static absValue=absValueFactory(Decimal);static abs2Value=abs2ValueFactory(Decimal);static abs=absFactory(Decimal,ComplexDecimal);static abs2=abs2Factory(Decimal,ComplexDecimal);static hypot=hypotFactory(ComplexDecimal);static arg=argFactory(Decimal,ComplexDecimal);static conj=conjFactory(Decimal,ComplexDecimal);static mod=modFactory(Decimal,ComplexDecimal);static rem=remFactory(Decimal,ComplexDecimal);static fix=fixFactory(Decimal,ComplexDecimal);static ceil=ceilFactory(Decimal,ComplexDecimal);static floor=floorFactory(Decimal,ComplexDecimal);static round=roundFactory(Decimal,ComplexDecimal);static sign=signFactory(Decimal,ComplexDecimal);static sqrt=sqrtFactory(Decimal,ComplexDecimal);static exp=expFactory(Decimal,ComplexDecimal);static log=logFactory(Decimal,ComplexDecimal);static logb=logbFactory(Decimal,ComplexDecimal);static log2=log2Factory(ComplexDecimal);static log10=log10Factory(ComplexDecimal);static deg2rad=deg2radFactory(Decimal,ComplexDecimal);static rad2deg=rad2degFactory(Decimal,ComplexDecimal);static sin=sinFactory(Decimal,ComplexDecimal);static sind=sindFactory(ComplexDecimal);static cos=cosFactory(Decimal,ComplexDecimal);static cosd=cosdFactory(ComplexDecimal);static tan=tanFactory(ComplexDecimal);static tand=tandFactory(ComplexDecimal);static csc=cscFactory(ComplexDecimal);static cscd=cscdFactory(ComplexDecimal);static sec=secFactory(ComplexDecimal);static secd=secdFactory(ComplexDecimal);static cot=cotFactory(ComplexDecimal);static cotd=cotdFactory(ComplexDecimal);static asin=asinFactory(ComplexDecimal);static asind=asindFactory(ComplexDecimal);static acos=acosFactory(ComplexDecimal);static acosd=acosdFactory(ComplexDecimal);static atan=atanFactory(ComplexDecimal);static atan2=atan2Factory(Decimal,ComplexDecimal);static atand=atandFactory(ComplexDecimal);static acsc=acscFactory(ComplexDecimal);static acscd=acscdFactory(ComplexDecimal);static asec=asecFactory(ComplexDecimal);static asecd=asecdFactory(ComplexDecimal);static acot=acotFactory(ComplexDecimal);static acotd=acotdFactory(ComplexDecimal);static sinh=sinhFactory(Decimal,ComplexDecimal);static cosh=coshFactory(Decimal,ComplexDecimal);static tanh=tanhFactory(ComplexDecimal);static csch=cschFactory(ComplexDecimal);static sech=sechFactory(ComplexDecimal);static coth=cothFactory(ComplexDecimal);static asinh=asinhFactory(ComplexDecimal);static acosh=acoshFactory(ComplexDecimal);static atanh=atanhFactory(ComplexDecimal);static acsch=acschFactory(ComplexDecimal);static asech=asechFactory(ComplexDecimal);static acoth=acothFactory(ComplexDecimal);static gamma=gammaFactory(ComplexDecimal);static factorial=factorialFactory(Decimal,ComplexDecimal);static applyFunction=applyFunctionFactory(Decimal);static mapFunction=mapFunctionFactory(ComplexDecimal);static twoArgFunction=twoArgFunctionFactory(ComplexDecimal)}ComplexDecimal.set(ComplexDecimal.defaultSettings);const src_ComplexDecimal={ComplexDecimal},toNumber=e=>e instanceof Decimal?e.toNumber():Number(e);class Complex{static _engineBackend;static _engine;static get engineBackend(){return this._engineBackend}static get engine(){return this._engine}static set engine(e){switch(this._engine=e,e){case"number":this._engineBackend=ComplexNumber;break;case"decimal":this._engineBackend=ComplexDecimal;break;default:throw new Error(`invalid complex backend engine: '${e}'.`)}ComplexInterfaceStaticKeyTable.forEach(e=>{this[e]=this._engineBackend[e]}),this.set(this.defaultSettings)}static LOGICAL;static REAL;static COMPLEX;static defaultSettings;static settings;static isInstanceOf;static set;static setNumberType;static create;static realSet;static imagSet;static realApply;static imagApply;static from;static real;static imag;static isComplexValue;static isRealValue;static realIsFinite;static imagIsFinite;static realIsNaN;static imagIsNaN;static realIsInteger;static imagIsInteger;static realIsNegative;static imagIsNegative;static realIsZero;static imagIsZero;static realIsPositive;static imagIsPositive;static realToNumber;static toBoolean;static imagToNumber;static realLessThan;static imagLessThan;static realLessThanOrEqualTo;static imagLessThanOrEqualTo;static realEquals;static imagEquals;static realGreaterThanOrEqualTo;static imagGreaterThanOrEqualTo;static realGreaterThan;static imagGreaterThan;static parse;static precedence;static unparseValue;static unparse;static toString;static unparseMathMLValue;static unparseMathML;static copy;static toMaxPrecisionValue;static toMaxPrecision;static epsilon;static random;static eq;static ne;static cmp;static minMaxArrayReal;static minMaxArrayRealWithIndex;static minMaxArrayComplex;static minMaxArrayComplexWithIndex;static min;static minWise;static max;static maxWise;static lt;static le;static gt;static ge;static false;static true;static toLogical;static logical;static and;static or;static xor;static not;static zero;static one;static onediv2;static minusonediv2;static minusone;static pi;static pidiv2;static onei;static onediv2i;static minusonediv2i;static minusonei;static two;static sqrt2pi;static e;static NaN_0;static inf_0;static add;static sub;static neg;static mul;static mulAndSumTo;static rdiv;static ldiv;static inv;static power;static root;static abs;static abs2;static hypot;static arg;static conj;static mod;static rem;static fix;static ceil;static floor;static round;static sign;static sqrt;static exp;static log;static logb;static log2;static log10;static deg2rad;static rad2deg;static sin;static sind;static cos;static cosd;static tan;static tand;static csc;static cscd;static sec;static secd;static cot;static cotd;static asin;static asind;static acos;static acosd;static atan;static atan2;static atand;static acsc;static acscd;static asec;static asecd;static acot;static acotd;static sinh;static cosh;static tanh;static csch;static sech;static coth;static asinh;static acosh;static atanh;static acsch;static asech;static acoth;static gamma;static factorial;static applyFunction;static mapFunction;static twoArgFunction}Complex.engine="decimal";const src_Complex={Complex},singleQuoteCharacter="'",doubleQuoteCharacter='"',stringClass=3;class CharString{str;quote;static STRING=stringClass;type=CharString.STRING;parent;constructor(e,t=doubleQuoteCharacter){this.str=e,this.quote=t}static create=(e,t='"')=>new CharString(e,t);static isInstanceOf=e=>e instanceof CharString;static copy=e=>new CharString(e.str,e.quote);copy(){return new CharString(this.str,this.quote)}static parse=e=>new CharString(e);static unparse=(e,t=0)=>e.str;static toString=e=>e.str;toString(){return this.str}static unparseEscaped=e=>{let t=JSON.stringify(e.str);return t=t.substring(1,t.length-2).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'"'+t+'"'};static unparseMathML=(e,t=0)=>"<mi><pre>"+e.str+"</pre></mi>";static unparseEscapedMathML=e=>{let t=JSON.stringify(e.str);return t=t.substring(1,t.length-2).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'<mi><pre>"'+t+'"</pre></mi>'};static logical=e=>e.str?Complex.true():Complex.false();static toLogical=e=>CharString.logical(e);toLogical(){return CharString.logical(this)}}const src_CharString={singleQuoteCharacter,doubleQuoteCharacter,stringClass,CharString};class FunctionHandle{static FUNCTION_HANDLE=5;type=FunctionHandle.FUNCTION_HANDLE;parent;id;commat;parameter;expression;static isInstanceOf=e=>e instanceof FunctionHandle;constructor(e=null,t=!1,r=null,n=null){this.id=e,this.commat=t,this.parameter=r??[],this.expression=n}static create=(e=null,t=!1,r=null,n=null)=>new FunctionHandle(e,t,r,n);static unparse=(e,t,r=0)=>e.id?(e.commat?"@":"")+e.id:"@("+e.parameter.map(e=>t.Unparse(e)).join(",")+") "+t.Unparse(e.expression);static toString=e=>e.id?(e.commat?"@":"")+e.id:"@anonymous function handle";toString(){return FunctionHandle.toString(this)}static unparseMathML=(e,t,r=0)=>e.id?`${e.commat?"<mo>@</mo><mi>":""}${e.id}</mi>`:'<mo>@</mo><mo fence="true" stretchy="true">(</mo>'+e.parameter.map(e=>t.UnparserMathML(e)).join("<mo>,</mo>")+'<mo fence="true" stretchy="true">)</mo><mspace width="0.8em"/>'+t.UnparserMathML(e.expression);static copy=e=>{const t=new FunctionHandle(e.id,e.commat,e.parameter,e.expression);return t.parent=e.parent,t};copy(){const e=new FunctionHandle(this.id,this.commat,this.parameter,this.expression);return e.parent=this.parent,e}static toLogical=e=>Complex.false();toLogical(){return Complex.false()}}const src_FunctionHandle={FunctionHandle};class Structure{static STRUCTURE=4;type=Structure.STRUCTURE;parent;field;static invalidReferenceMessage="value cannot be indexed with .";static isInstanceOf=e=>e instanceof Structure;constructor(e){if(this.field={},Array.isArray(e)){let t=this;for(let r=0;r<e.length-1;r++)t.field[e[r]]=new Structure({}),t=t.field[e[r]];t.field[e[e.length-1]]=MultiArray.emptyArray()}else for(const t in e)this.field[t]=e[t].copy()}static isStructure=e=>e instanceof Structure||e instanceof MultiArray&&!e.isCell&&e.dimension[0]>0&&e.dimension[1]>0&&e.array[0][0]instanceof Structure;static setField=(e,t,r)=>{let n=e;for(let e=0;e<t.length-1;e++)n.field[t[e]]=new Structure({}),n=n.field[t[e]];n.field[t[t.length-1]]=r??MultiArray.emptyArray()};static setNewField=(e,t,r)=>{let n=e;for(let e=0;e<t.length-1;e++){if(!(n.field[t[e]]instanceof Structure)){if(void 0!==n.field[t[e]]&&!MultiArray.isEmpty(n.field[t[e]]))throw new EvalError(Structure.invalidReferenceMessage);n.field[t[e]]=new Structure({})}n=n.field[t[e]]}n.field[t[t.length-1]]=r??MultiArray.emptyArray()};static getField=(e,t)=>{if(e instanceof Structure){let r,n=e;for(r=0;r<t.length-1&&n instanceof Structure&&void 0!==n.field[t[r]];r++)n=n.field[t[r]];if(r===t.length-1&&n instanceof Structure&&void 0!==n.field[t[t.length-1]])return n.field[t[t.length-1]];throw new EvalError(Structure.invalidReferenceMessage)}throw new EvalError(Structure.invalidReferenceMessage)};static getFields=(e,t)=>e instanceof MultiArray&&e.array.length>0&&e.array[0].length>0&&e.array[0][0]instanceof Structure?MultiArray.linearize(e).map(e=>Structure.getField(e,t)):[Structure.getField(e,t)];static unparse=(e,t,r=0)=>`struct {\n${Object.entries(e.field).map(e=>`${e[0]}: ${t.Unparse(e[1])}`).join("\n")}\n}`;static unparseMathML=(e,t,r=0)=>{let n='<mtr><mtd columnspan="2"><mtext>struct {</mtext></mtd></mtr>';return n+=Object.entries(e.field).map(e=>`<mtr><mtd><mi>${e[0]}</mi><mo>:</mo></mtd><mtd>${t.UnparserMathML(e[1])}</mtd></mtr>`).join(""),n+='<mtr><mtd columnspan="2"><mtext>}</mtext></mtd></mtr>',`<mtable>${n}</mtable>`};static copy=e=>{const t=new Structure({});for(const r in e.field)t.field[r]=e.field[r].copy();return t};copy(){return Structure.copy(this)}static cloneFields=e=>{const t=new Structure({});return Object.keys(e.field).forEach(e=>{t.field[e]=MultiArray.emptyArray()}),t};static toLogical=e=>Object.keys(e.field).length>0?Complex.true():Complex.false();toLogical(){return Structure.toLogical(this)}static setEmptyField=(e,t)=>{if(!(e.array[0][0]instanceof Structure))throw new EvalError(Structure.invalidReferenceMessage);if(!e.isCell&&!(t in e.array[0][0].field))for(let r=0;r<e.array.length;r++)for(let n=0;n<e.dimension[1];n++)e.array[r][n].field[t]=MultiArray.emptyArray()}}const src_Structure={Structure};class AST{static nodeString;static nodeNumber;static firstRow;static appendRow;static emptyArray;static reload=()=>{AST.nodeString=CharString.create,AST.nodeNumber=Complex.parse,AST.firstRow=MultiArray.firstRow,AST.appendRow=MultiArray.appendRow,AST.emptyArray=MultiArray.emptyArray};static omitAnswerTable=["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--","CMDWLIST","IF"];static omitAnswer=e=>AST.omitAnswerTable.includes(e.type)||e.omitAnswer;static nodeLiteral=e=>({type:e});static nodeIdentifier=e=>({type:"IDENT",id:e.replace(/(\r\n|[\n\r])|[\ ]/gm,"")});static nodeCmdWList=(e,t)=>({type:"CMDWLIST",id:e.id,args:t?t.list:[]});static nodeIndexExpr=(e,t=null,r="()")=>({type:"IDX",expr:e,args:t?t.list:[],delim:r});static nodeRange=(e,t,r)=>({type:"RANGE",start_:e,stop_:t,stride_:r??null});static nodeOp=(e,t,r)=>{switch(e){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":return{type:e,left:t,right:r};case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":return{type:e,right:t};case".'":case"'":case"_++":case"_--":return{type:e,left:t};default:return{type:`INVALID:${e}`}}};static nodeListFirst=e=>{if(e){const t={type:"LIST",list:[e]};return e.parent=t,t}return{type:"LIST",list:[]}};static appendNodeList=(e,t)=>(t.parent=e,e.list.push(t),e);static nodeList=e=>({type:"LIST",list:e});static nodeFirstRow=(e=null,t)=>e?AST.firstRow(e.list,t):AST.emptyArray(t);static nodeAppendRow=(e,t=null)=>t?AST.appendRow(e,t.list):e;static nodeIndirectRef=(e,t)=>"."===e.type?(e.field.push(t),e):{type:".",obj:e,field:[t]};static nodeReturnList=(e,t)=>({type:"RETLIST",selector:e,...void 0===t?{handler:e=>({length:e})}:"function"==typeof t?{handler:t}:t});static throwErrorIfGreaterThanReturnList=(e,t)=>{if(t>e)throw new EvalError(`element number ${e+1} undefined in return list`)};static reduceToFirstIfReturnList=e=>{if("RETLIST"===e.type){const t=void 0!==e.handler?e.selector(e.handler(1),0):e.selector({length:1},0);return t.parent=e.parent,t}return e};static throwInvalidCallError=(e,t=!0)=>{if(t)throw new SyntaxError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)};static nodeFunctionHandle=(e=null,t=null,r=null)=>new FunctionHandle(e?e.id:null,!0,t?t.list:[],r);static nodeFunction=(e,t,r,n,i)=>({type:"FCN",id:e.id,return:t.list,parameter:r.list,arguments:n.list,statements:i.list});static nodeArgumentValidation=(e,t,r=null,n,i=null)=>({name:e,size:t.list,class:r,functions:n.list,default:i});static nodeArguments=(e,t)=>({attribute:e,validation:t.list});static nodeDeclarationFirst=e=>({type:e,list:[]});static nodeAppendDeclaration=(e,t)=>(e.list.push(t),e);static nodeIfBegin=(e,t)=>({type:"IF",expression:[e],then:[t],else:null});static nodeIfAppendElse=(e,t)=>(e.else=t.else,e);static nodeIfAppendElseIf=(e,t)=>(e.expression.push(t.expression),e.then.push(t.then),e);static nodeElseIf=(e,t)=>({expression:e,then:t});static nodeElse=e=>({else:e})}const src_AST={AST};class MultiArray{dimension;get dimensionR(){return[this.dimension[0],...this.dimension.slice(2)]}array;type;static isInstanceOf=e=>e instanceof MultiArray;static LOGICAL=Complex.LOGICAL;static REAL=Complex.REAL;static COMPLEX=Complex.COMPLEX;static STRING=CharString.STRING;static STRUCTURE=Structure.STRUCTURE;static FUNCTION_HANDLE=FunctionHandle.FUNCTION_HANDLE;isCell;parent;constructor(e,t,r){if(e)if(this.dimension=e.slice(),MultiArray.appendSingletonTail(this.dimension,2),MultiArray.removeSingletonTail(this.dimension),t)if("function"==typeof t)this.array=Array.from({length:e[0]*e.slice(2).reduce((e,t)=>e*t,1)},(r,n)=>Array.from({length:e[1]},(r,i)=>t(...MultiArray.rowColumnToSubscript(e,n,i))));else if(Array.isArray(t)&&Array.isArray(t[0]))this.array=t.map(e=>e.map(e=>e.copy()));else{if(this.array=new Array(this.dimensionR.reduce((e,t)=>e*t,1)),t instanceof MultiArray||t instanceof Structure)for(let e=0;e<this.array.length;e++){this.array[e]=new Array(this.dimension[1]);for(let r=0;r<this.dimension[1];r++)this.array[e][r]=t.copy()}else for(let e=0;e<this.array.length;e++)this.array[e]=new Array(this.dimension[1]).fill(t);this.type=t.type}else this.array=Array.from({length:e[0]*e.slice(2).reduce((e,t)=>e*t,1)},t=>Array.from({length:e[1]},e=>Complex.zero())),this.type=-1;else this.dimension=[0,0],this.array=[],this.type=-1;this.isCell=r??!1}static isScalar=e=>!(e instanceof MultiArray&&e.dimension.reduce((e,t)=>e*t,1)>1);static isRowVector=e=>e instanceof MultiArray&&2===e.dimension.length&&1===e.dimension[0];static toRowVector=e=>{const t=new MultiArray([1,e.length]);return t.array[0]=e.slice(),t};static fromRowVector=e=>e.array[0];static isColumnVector=e=>e instanceof MultiArray&&2===e.dimension.length&&1===e.dimension[1];static toColumnVector=e=>{const t=new MultiArray([e.length,1]);return t.array.map((t,r,n)=>n[r][0]=e[r]),t};static fromColumnVector=e=>e.array.map(e=>e[0]);static toDiagonalMatrix=e=>{const t=new MultiArray([e.length,e.length]);return t.array.map((t,r,n)=>n[r][r]=e[r]),t};static isVector=e=>e instanceof MultiArray&&2===e.dimension.length&&(1===e.dimension[0]||1===e.dimension[1]);static isMatrix=e=>!(e instanceof MultiArray)||2===e.dimension.length;static isEmpty=e=>e instanceof MultiArray&&0===e.dimension.reduce((e,t)=>e*t,1);static isCellArray=e=>e instanceof MultiArray&&e.isCell;static isComplexMultiArray=e=>{let t=!1;for(let r=0;r<e.dimensionR.reduce((e,t)=>e*t,1);r++)for(let n=0;n<e.dimension[1];n++)if(Complex.isComplexValue(e.array[r][n])){t=!0;break}return t};static setType=e=>{e.type=Math.max(...e.array.map(e=>Math.max(...e.map(e=>e.type))))};static arrayEquals=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]);static rangeArray=e=>{const t=[];for(let r=1;r<=e;r++)t.push(r);return t};static linearIndexToSubscript=(e,t)=>e.map((r,n)=>Math.floor(t/e.slice(0,n).reduce((e,t)=>e*t,1))%r+1);static subscriptToLinearIndex=(e,t)=>t.reduce((t,r,n)=>t+(r-1)*e.slice(0,n).reduce((e,t)=>e*t,1),0);static linearIndexToMultiArrayRowColumn=(e,t,r)=>{const n=e*t,i=r%n;return[Math.floor(r/n)*e+i%e,Math.floor(i/e)]};static subscriptToMultiArrayRowColumn=(e,t)=>{const r=t.reduce((t,r,n)=>t+(r-1)*e.slice(0,n).reduce((e,t)=>e*t,1),0),n=e[0]*e[1],i=r%n;return[Math.floor(r/n)*e[0]+i%e[0],Math.floor(i/e[0])]};static rowColumnToLinearIndex=(e,t,r)=>Math.floor(t/e[0])*e[0]*e[1]+r*e[0]+t%e[0];static rowColumnToSubscript=(e,t,r)=>{const n=Math.floor(t/e[0])*e[0]*e[1]+r*e[0]+t%e[0];return e.map((t,r)=>Math.floor(n/e.slice(0,r).reduce((e,t)=>e*t,1))%t+1)};static computeStrides=e=>{const t=new Array(e.length);let r=1;for(let n=0;n<e.length;n++)t[n]=r,r*=e[n];return t};static getStride=(e,t)=>e.dimension.slice(t+1).reduce((e,t)=>e*t,1);static pageSlice=(e,t)=>{const r=e.dimension;if(r.length<=2)return e.array;const[n,i]=r.slice(-2),a=r.slice(0,-2).reduce((e,t)=>e*t,1);if(t>=a)throw new RangeError(`pageSlice: invalid page index ${t}/${a}`);const s=MultiArray.flatten(e),o=t*n*i,l=[];for(let e=0;e<n;e++){const t=[];for(let r=0;r<i;r++)t.push(s[o+e+r*n]);l.push(t)}return l};static setPage=(e,t,r)=>{const[n,i,...a]=e.dimension,s=a.reduce((e,t)=>e*t,1)||1;if(t>=s)throw new RangeError(`setPage: invalid page index ${t}/${s}`);const o=t*n;for(let t=0;t<n;t++)e.array[o+t].splice(0,i,...r[t])};static toFlatArray=e=>{const t=e.dimension,r=t.reduce((e,t)=>e*t,1),n=new Array(r);for(let i=0;i<r;i++){const[r,a]=MultiArray.linearIndexToMultiArrayRowColumn(t[0],t[1],i);if(!e.array[r]||void 0===e.array[r][a])throw new Error(`toFlatArray: missing element at linear ${i} -> array[${r}][${a}] is undefined.`);n[i]=e.array[r][a]}return n};static fromFlatArray=(e,t)=>{const r=e.dimension,n=r.reduce((e,t)=>e*t,1);if(t.length!==n)throw new Error(`fromFlatArray: length mismatch (flat ${t.length} vs expected ${n}).`);const i=r[0],a=r.slice(2).reduce((e,t)=>e*t,1),s=i*Math.max(1,a);if(!Array.isArray(e.array)||e.array.length!==s){e.array=new Array(s);for(let t=0;t<s;t++)e.array[t]=new Array(r[1]).fill(void 0)}for(let i=0;i<n;i++){const[n,a]=MultiArray.linearIndexToMultiArrayRowColumn(r[0],r[1],i);e.array[n][a]=t[i]}};static sameSizeExcept=(e,t)=>{const r=e.dimension,n=t.dimension;if(r.length!==n.length)return!1;let i=!0;for(let e=0;e<r.length;e++)if(r[e]!==n[e]){i=!1;break}if(i)return!0;for(let e=0;e<r.length;e++)if(3===r[e]&&3===n[e]){let t=!0;for(let i=0;i<r.length;i++)if(i!==e&&r[i]!==n[i]){t=!1;break}if(t)return!0}return!1};static ind2subNumber=(e,t)=>(e=[...e,t+1]).map((r,n)=>Math.floor((t-1)/e.slice(0,n).reduce((e,t)=>e*t,1))%r).map(e=>e+1);static linearLength=e=>e.array.length*e.dimension[1];static getDimension=(e,t)=>t<e.dimension.length?e.dimension[t]:1;static removeSingletonTail=e=>{let t=e.length-1;for(;1===e[t]&&t>1;)e.pop(),t--};static appendSingletonTail=(e,t)=>{t>e.length&&e.push(...new Array(t-e.length).fill(1))};static firstNonSingleDimension=e=>{if(!e.dimension||0===e.dimension.length)return 0;const t=e.dimension.findIndex(e=>e>1);return t>=0?t:0};static firstRow=(e,t)=>{const r=new MultiArray([1,e.length]);return r.array[0]=e,r.isCell=t??!1,r};static appendRow=(e,t)=>(e.array.push(t),e.dimension[0]++,e);static unparse=(e,t,r=0)=>{const n=e=>e.map(e=>t.Unparse(e)).join()+";\n";let i="";if(0===e.dimension.reduce((e,t)=>e*t,1))return`${e.isCell?"{ }":"[ ]"}(${e.dimension.join("x")})`;if(e.dimension.length>2){let t="";for(let r=0;r<e.array.length;r+=e.dimension[0])i=e.array.slice(r,r+e.dimension[0]).map(n).join(""),i=i.substring(0,i.length-2),t+=`${e.isCell?"{":"["}${i}${e.isCell?"}":"]"} (:,:,${MultiArray.linearIndexToSubscript(e.dimensionR,r).slice(1).join()})\n`;return t}return i=e.array.map(n).join(""),i=i.substring(0,i.length-2),`${e.isCell?"{":"["}${i}${e.isCell?"}":"]"}`};toString(){return`array ${this.dimension.join("x")}`}static unparseMathML=(e,t,r=0)=>{const n=e=>`<mtr>${e.map(e=>`<mtd>${t.UnparserMathML(e)}</mtd>`).join("")}</mtr>`,i=t=>`<mrow><mo fence="true" stretchy="true">${e.isCell?"{":"["}</mo><mtable>${t}</mtable><mo fence="true" stretchy="true">${e.isCell?"}":"]"}</mo></mrow>`;if(0===e.dimension.reduce((e,t)=>e*t,1))return`${i('<mspace width="0.5em"/>')}<mo fence="true" stretchy="true">(</mo><mn>${e.dimension.join("</mn><mi>&times;</mi><mn>")}</mn><mo fence="true" stretchy="true">)</mo>`;if(e.dimension.length>2){let t="";for(let r=0;r<e.array.length;r+=e.dimension[0]){const a=e.array.slice(r,r+e.dimension[0]).map(n).join(""),s=MultiArray.linearIndexToSubscript(e.dimensionR,r).slice(1).map(e=>`<mn>${e}</mn>`).join("<mo>,</mo>");t+=`<mtr><mtd><msub>${i(a)}<mrow><mo fence="true" stretchy="true">(</mo><mo>:</mo><mo>,</mo><mo>:</mo><mo>,</mo>${s}<mo fence="true" stretchy="true">)</mo></mrow></msub></mtd></mtr>`}return`<mtable>${t}</mtable>`}return i(e.array.map(n).join(""))};static fromCharString=e=>{if(e.str.length>0){const t=new MultiArray([1,e.str.length]);return t.array=[e.str.split("").map(e=>Complex.create(e.charCodeAt(0)))],t.type=Complex.REAL,MultiArray.MultiArrayToScalar(t)}return MultiArray.emptyArray()};static flatten=e=>{const t=[];for(let r=0;r<e.array[0].length;r++)for(let n=0;n<e.array.length;n++)t.push(e.array[n][r]);return t};static linearize=e=>{if(e instanceof MultiArray){const t=[];for(let r=0;r<e.array.length;r+=e.dimension[0])for(let n=0;n<e.dimension[1];n++)t.push(...e.array.slice(r,r+e.dimension[0]).map(e=>e[n]));return t}return[e]};static emptyArray=e=>{const t=new MultiArray([0,0]);return t.isCell=e??!1,t};static scalarToMultiArrayWithTest=(e,t)=>{if(e instanceof MultiArray&&t)return e;{const t=new MultiArray([1,1]);return t.array[0]=[e],t.type=e.type??-1,t}};static scalarToMultiArray=e=>MultiArray.scalarToMultiArrayWithTest(e,!e.isCell);static scalarOrCellToMultiArray=e=>MultiArray.scalarToMultiArrayWithTest(e,!0);static MultiArrayToScalar=e=>e instanceof MultiArray&&2===e.dimension.length&&1===e.dimension[0]&&1===e.dimension[1]?e.array[0][0]:e;static firstElement=e=>e instanceof MultiArray&&e.dimension.reduce((e,t)=>e*t,1)>0?e.array[0][0]:e;static firstVector=e=>e instanceof MultiArray?1===e.dimension[0]?e.array[0]:e.array.map(e=>e[0]):[e];static copy=e=>{const t=new MultiArray(e.dimension);return t.array=e.array.map(e=>e.map(e=>e.copy())),t.type=e.type,t};copy(){const e=new MultiArray(this.dimension);return e.array=this.array.map(e=>e.map(e=>e.copy())),e.type=this.type,e}static toLogical=e=>{for(let t=0;t<e.array.length;t++){const r=e.array[t];for(let t=0;t<e.dimension[1];t++){const e=r[t].toLogical();if(Complex.realEquals(e,0))return Complex.false()}}return Complex.true()};toLogical(){for(let e=0;e<this.array.length;e++){const t=this.array[e];for(let e=0;e<this.dimension[1];e++){const r=t[e].toLogical();if(Complex.realEquals(r,0))return Complex.false()}}return Complex.true()}static expand=(e,t)=>{let r=e.dimension.slice(),n=t.slice();r.length<n.length&&(r=r.concat(new Array(n.length-r.length).fill(1))),n.length<r.length&&(n=n.concat(new Array(r.length-n.length).fill(1)));const i=n.map((e,t)=>Math.max(e,r[t]));if(MultiArray.arrayEquals(r,i))return;const a=e.array[0][0]instanceof Structure?Structure.cloneFields(e.array[0][0]):Complex.zero(),s=new MultiArray(i,a);for(let t=0;t<MultiArray.linearLength(e);t++){const[r,n]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t),i=MultiArray.linearIndexToSubscript(e.dimension,t),[a,o]=MultiArray.subscriptToMultiArrayRowColumn(s.dimension,i);s.array[a][o]=e.array[r][n]}MultiArray.removeSingletonTail(s.dimension),e.dimension=s.dimension,e.array=s.array};static reshape=(e,t,r=-1)=>{const n=e.dimension.reduce((e,t)=>e*t,1),i=t.slice();if(-1!==r){i[r]=1;const e=i.reduce((e,t)=>e*t,1);if(!(e<=n&&Number.isInteger(n/e)))throw new Error(`reshape: SIZE is not divisible by the product of known dimensions (= ${e})`);i[r]=n/e}else if(n!==i.reduce((e,t)=>e*t,1))throw new Error(`reshape: can't reshape ${e.dimension.join("x")} array to ${i.join("x")} array`);let a;return e.dimension[1]===i[1]?(a=MultiArray.copy(e),a.dimension=i):(a=new MultiArray(i),MultiArray.rawMapLinearIndex(e,(e,t)=>{const[r,n]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);return a.array[r][n]=e,e})),a.type=e.type,MultiArray.removeSingletonTail(a.dimension),a};static expandRange=(e,t,r)=>{const n=[],i=r?Complex.realToNumber(r):1;for(let r=Complex.realToNumber(e),a=0;i>0?r<=Complex.realToNumber(t):r>=Complex.realToNumber(t);r+=i,a++)n[a]=Complex.create(r);const a=new MultiArray([1,n.length]);return a.array=[n],MultiArray.setType(a),a};static expandColon=e=>{const t=new MultiArray([e,1]);for(let r=0;r<e;r++)t.array[r]=[Complex.create(r+1)];return MultiArray.setType(t),t};static haveAnyComplex=e=>{for(let t=0;t<e.dimension[0];t++)for(let r=0;r<e.dimension[1];r++)if(!Complex.imagIsZero(e.array[t][r]))return!0;return!1};static testInteger=(e,t,r,n)=>{const i=(e,t,r)=>{throw new RangeError((e?e+": ":"")+t+" must be "+r)};if(Complex.realIsInteger(e)&&!Complex.realLessThan(e,1)||i(t,r,"either integers greater than or equal 1 or logicals."),!Complex.imagEquals(e,0))throw i(t,r,"real."),new RangeError((t?t+": ":"")+r+" must be real.");const a=Complex.realToNumber(e),s=typeof n;return"undefined"!==s&&("number"===s?a>n&&i(t,r,"less than or equal to "+n+" "):(a<n[0]&&i(t,r,"greater than or equal to"+n[0]+" "),a>n&&i(t,r,"less than or equal to"+n[1]+" "))),a};static testIndex=(e,t)=>{if(!Complex.realIsInteger(e)||Complex.realLessThan(e,1))throw new RangeError((t?`${t}: `:"")+"subscripts must be either integers greater than or equal 1 or logicals.");if(!Complex.imagEquals(e,0))throw new RangeError((t?`${t}: `:"")+"subscripts must be real.");return Complex.realToNumber(e)};static testIndexBound=(e,t,r,n)=>{const i=MultiArray.testIndex(e,n);if(i>t)throw new RangeError(`${n?`${n}: `:""}out of bound ${t} (dimensions are ${r.join("x")}).`);return i};static parseSubscript=(e,t,r,n)=>{const i=t.map(e=>MultiArray.testIndex(e,`${r||""}${n?"("+t.map(e=>n.Unparse(e)).join()+")":""}`)),a=(t,n)=>{const a=e=>e>4?`...[x${e}]...`:new Array(e).fill("_").join(),s=a(t),o=a(i.length-t-1);throw new RangeError(`${r||""}(${s}${s?",":""}${i[t]}${o?",":""}${o}): out of bound ${n} (dimensions are ${e.join("x")}).`)},s=i.slice();if(MultiArray.removeSingletonTail(s),s.length>e.length){const t=i.map((t,r)=>t>e[r]).indexOf(!0);t>=0&&a(t,1)}let o;if(i.length<e.length){o=e.slice();const t=i.map((t,r)=>t>e[r]).indexOf(!0);if(t>=0)if(t===i.length-1){const e=o.slice(i.length-1).reduce((e,t)=>e*t,1);i[i.length-1]>e&&a(t,e)}else a(t,o[t])}else{o=e.concat(new Array(i.length-e.length).fill(1));const t=i.map((t,r)=>t>e[r]).indexOf(!0);t>=0&&a(t,o[t])}return s.reduce((t,r,n)=>t+(r-1)*e.slice(0,n).reduce((e,t)=>e*t,1),0)};static scalarOpMultiArray=(e,t,r)=>{const n=new MultiArray(r.dimension);return n.array=r.array.map(r=>r.map(r=>Complex[e](t,r))),MultiArray.setType(n),n};static MultiArrayOpScalar=(e,t,r)=>{const n=new MultiArray(t.dimension);return n.array=t.array.map(t=>t.map(t=>Complex[e](t,r))),MultiArray.setType(n),n};static leftOperation=(e,t)=>{const r=new MultiArray(t.dimension);return r.array=t.array.map(t=>t.map(t=>Complex[e](t))),MultiArray.setType(r),r};static elementWiseOperation=(e,t,r)=>{let n=t.dimension.slice(),i=r.dimension.slice();const a=Math.max(n.length,i.length);for(;n.length<a;)n.push(1);for(;i.length<a;)i.push(1);const s=new Array(a),o=new Array(a),l=new Array(a);for(let t=0;t<a;t++){const r=n[t],a=i[t];if(r===a)s[t]=r,o[t]=l[t]=!1;else if(1===r)s[t]=a,o[t]=!0,l[t]=!1;else{if(1!==a)throw new EvalError(`operator ${e}: nonconformant arguments (op1 is ${n.join("x")}, op2 is ${i.join("x")}).`);s[t]=r,o[t]=!1,l[t]=!0}}const c=MultiArray.computeStrides(n),u=MultiArray.computeStrides(i),m=MultiArray.computeStrides(s),h=s.reduce((e,t)=>e*t,1),p=new MultiArray(s),d=n[0],x=d*(n[1]||1),C=i[0],f=C*(i[1]||1),g=s[0],_=g*(s[1]||1);for(let n=0;n<h;n++){let i=0,h=0;for(let e=0;e<a;e++){const t=Math.floor(n/m[e])%s[e],r=o[e]?0:t,a=l[e]?0:t;i+=r*c[e],h+=a*u[e]}const y=Math.floor(i/x),A=i-y*x,E=y*d+A%d,L=Math.floor(A/d),T=Math.floor(h/f),M=h-T*f,b=T*C+M%C,S=Math.floor(M/C),N=Math.floor(n/_),w=n-N*_,I=N*g+w%g,P=Math.floor(w/g);p.array[I][P]=Complex[e](t.array[E][L],r.array[b][S])}return MultiArray.setType(p),p};static rawMap=(e,t)=>{const r=new MultiArray(e.dimension);return r.array=e.array.map(e=>e.map(t)),MultiArray.setType(r),r};static rawMapRowColumn=(e,t)=>{const r=new MultiArray(e.dimension);return r.array=e.array.map((e,r)=>e.map((e,n)=>t(e,r,n))),MultiArray.setType(r),r};static rawMapLinearIndex=(e,t)=>{const r=new MultiArray(e.dimension);return r.array=e.array.map((r,n)=>r.map((r,i)=>t(r,Math.floor(n/e.dimension[0])*e.dimension[0]*e.dimension[1]+i*e.dimension[0]+n%e.dimension[0],n,i))),MultiArray.setType(r),r};static alongDimensionMap=(e,t,r)=>{const n=new MultiArray(t.dimension);if(e>=t.dimension.length)n.array=t.array.map((e,t)=>e.map((e,n)=>r(e,0,t,n)));else{const i=t.dimension.slice();i[e]=1;const a=i.reduce((e,t)=>e*t,1),s=i.map(e=>MultiArray.rangeArray(e));for(let o=0;o<a;o++)for(let a=1;a<=t.dimension[e];a++){const l=s.slice();l[e]=[a];const c=MultiArray.linearIndexToSubscript(i,o).map((e,t)=>l[t][e-1]),[u,m]=MultiArray.subscriptToMultiArrayRowColumn(t.dimension,c);n.array[u]||(n.array[u]=[]),n.array[u][m]=r(t.array[u][m],c[e]-1,u,m)}}return MultiArray.setType(n),n};static sizeAlongDimension=(e,t)=>{const r=void 0!==t?Complex.realToNumber(MultiArray.firstElement(t))-1:Math.max(0,MultiArray.firstNonSingleDimension(e));return e.dimension[r]};static getElementAlongDimension=(e,t,r)=>{const n=e.dimension;if(t<0||t>=n.length)throw new RangeError(`getElementAlongDimension: invalid dimension ${t} for array of ${n.length}D`);if(r<0||r>=n[t])throw new RangeError(`getElementAlongDimension: index ${r} out of bounds for dimension ${t} of size ${n[t]}`);const i=new Array(n.length).fill(1);i[t]=r+1;const a=MultiArray.subscriptToLinearIndex(n,i),[s,o]=MultiArray.linearIndexToMultiArrayRowColumn(n[0],n[1],a);return e.array[s][o]};static divideElementByScalar=(e,t)=>MultiArray.isInstanceOf(e)?MultiArray.rawMap(e,e=>Complex.rdiv(e,t)):Complex.rdiv(e,t);static getMeanElementForPosition=(e,t,r)=>MultiArray.isInstanceOf(e)?MultiArray.getElementAlongDimension(e,t,r-1):e;static reduceToArray=(e,t)=>{if(e>=t.dimension.length)return t;{const r=t.dimension.slice();r[e]=1;const n=new MultiArray(r),i=t.dimension.slice();i[e]=1;const a=i.reduce((e,t)=>e*t,1);for(let r=1;r<=t.dimension[e];r++){const i=t.dimension.slice();i[e]=1;const s=i.map(e=>MultiArray.rangeArray(e));s[e]=[r];for(let e=0;e<a;e++){const a=MultiArray.linearIndexToSubscript(i,e).map((e,t)=>s[t][e-1]),o=MultiArray.subscriptToLinearIndex(t.dimension,a),[l,c]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],o),[u,m]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e);1===r?n.array[u][m]=[t.array[l][c]]:n.array[u][m].push(t.array[l][c])}}return n.type=t.type,n}};static reduce=(e,t,r,n)=>{if(e>=t.dimension.length)return t;{const i=t.dimension.slice();i[e]=1;const a=new MultiArray(i),s=t.dimension.slice();s[e]=1;const o=s.reduce((e,t)=>e*t,1),l=s.map(e=>MultiArray.rangeArray(e));for(let e=0;e<o;e++){const i=MultiArray.linearIndexToSubscript(s,e).map((e,t)=>l[t][e-1]),o=MultiArray.subscriptToLinearIndex(t.dimension,i),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],o),[m,h]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[m][h]=n?r(n,t.array[c][u],e):t.array[c][u]}for(let n=2;n<=t.dimension[e];n++){const i=t.dimension.slice();i[e]=1;const s=i.map(e=>MultiArray.rangeArray(e));s[e]=[n];for(let n=0;n<o;n++){const o=MultiArray.linearIndexToSubscript(i,n).map((e,t)=>s[t][e-1]),l=MultiArray.subscriptToLinearIndex(t.dimension,o),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],l),[m,h]=MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],n),p=MultiArray.linearIndexToSubscript(a.dimension,n);p[e]=1;const[d,x]=MultiArray.subscriptToMultiArrayRowColumn(a.dimension,p);a.array[m][h]=r(a.array[d][x],t.array[c][u],n)}}return MultiArray.setType(a),MultiArray.MultiArrayToScalar(a)}};static concatenate=(e,t,...r)=>{const n=[],i=r.map(t=>{const r=t.dimension.slice();return MultiArray.appendSingletonTail(r,e+1),n.push(r[e]),r[e]=0,r});if(!i.every(e=>MultiArray.arrayEquals(e,i[0])))throw new EvalError(`${t}: dimension mismatch`);const a=i[0].slice();a[e]=n.reduce((e,t)=>e+t,0);const s=new MultiArray(a);return r.forEach((t,r)=>{const i=n.slice(0,r).reduce((e,t)=>e+t,0);for(let r=0;r<MultiArray.linearLength(t);r++){const n=t.dimension.slice();MultiArray.appendSingletonTail(n,e+1);const a=MultiArray.linearIndexToSubscript(n,r);a[e]+=i;const[o,l]=MultiArray.subscriptToMultiArrayRowColumn(s.dimension,a),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r);s.array[o][l]=t.array[c][u]}}),MultiArray.setType(s),s};static splitLastDimension(e){const t=[],r=e.dimension[e.dimension.length-1];for(let n=0;n<r;n++){const i=e.array.length/r,a=new MultiArray(e.dimension.slice(0,-1));a.array=e.array.slice(n*i,(n+1)*i),t.push(a)}return t}static evaluateRecursive(e,t,r=!1,n=""){return e.dimension.length>2?MultiArray.concatenate(e.dimension.length-1,"evaluate",...MultiArray.splitLastDimension(e).map(e=>MultiArray.evaluate(e))):MultiArray.concatenate(0,"evaluate",...e.array.map(e=>MultiArray.concatenate(1,"evaluate",...e.map(e=>MultiArray.scalarToMultiArray(t?t.Evaluator(e,r,n):e)))))}static evaluate=(e,t,r=!1,n="")=>{if(MultiArray.isEmpty(e))return e;{const i=MultiArray.evaluateRecursive(e,t,r,n);return i.isCell=e.isCell,MultiArray.setType(i),i}};static getElements=(e,t,r,n)=>{let i;if(0===n.length)return e;{const a=n.map(e=>MultiArray.linearize(e)),s=a.map(e=>e.length);i=1===n.length&&n[0]instanceof MultiArray?new MultiArray(n[0].dimension):new MultiArray(s.length>1?s:[s[0],1]);for(let n=0;n<s.reduce((e,t)=>e*t,1);n++){const o=MultiArray.linearIndexToSubscript(s,n).map((e,t)=>a[t][e-1]),l=MultiArray.parseSubscript(e.dimension,o,t),[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],l),[m,h]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],n);r.length>0?i.array[m][h]=Structure.getField(e.array[c][u],r):i.array[m][h]=e.array[c][u]}return MultiArray.setType(i),i}};static getElementsLogical=(e,t,r,n)=>{const i=new MultiArray,a=MultiArray.linearize(e),s=MultiArray.linearize(n).map(e=>Complex.realToNumber(e)),o=MultiArray.isRowVector(n);if(o&&(i.array[0]=[]),s.length>a.length)throw new EvalError(`${t}(${s.length}): out of bound ${a.length} (dimensions are ${e.dimension.join("x")})`);for(let e=0;e<a.length;e++)s[e]&&(o?i.array[0].push(a[e]):i.array.push([a[e]]));return i.dimension=o?[1,i.array[0].length]:[i.array.length,1],i};static setElements=(e,t,r,n,i,a,s)=>{if(0===n.length)throw new RangeError("invalid empty index list.");{const o=MultiArray.linearize(i),l=1===n.length,c=n.map(e=>MultiArray.linearize(e)),u=c.map(e=>e.length),m=c.map(e=>e.map(e=>MultiArray.testIndex(e,`${a||""}${s?"("+c.map(e=>e.map(e=>s.Unparse(e))).join()+")":""}`))).map(e=>Math.max(...e));if(1!==o.length&&o.length!==u.reduce((e,t)=>e*t,1))throw new RangeError(`=: nonconformant arguments (op1 is ${u.join("x")}, op2 is ${i.dimension.join("x")})`);if(void 0!==e[t])if(e[t].node instanceof MultiArray)if(l){if(m[0]>MultiArray.linearLength(e[t].node))throw new RangeError("Invalid resizing operation or ambiguous assignment to an out-of-bounds array element.")}else MultiArray.expand(e[t].node,m);else{const r=e[t].node,n=r instanceof Structure?Structure.cloneFields(r):Complex.zero();e[t]=l?{node:new MultiArray([1,m[0]],n)}:{node:new MultiArray(m,n)},e[t].node.array[0][0]=r}else{const n=r.length>0?new Structure(r):Complex.zero();e[t]=l?{node:new MultiArray([1,m[0]],n)}:{node:new MultiArray(m,n)}}const h=e[t].node;r.length>0&&Structure.setEmptyField(h,r[0]);const p=e[t].node.dimension.slice();for(let e=0;e<u.reduce((e,t)=>e*t,1);e++){const t=MultiArray.linearIndexToSubscript(u,e),n=t.map((e,r)=>MultiArray.testIndex(c[r][e-1],`${a||""}${s?"("+t.map(e=>s.Unparse(Complex.create(e))).join()+")":""}`)),i=MultiArray.subscriptToLinearIndex(p,n),[l,m]=MultiArray.linearIndexToMultiArrayRowColumn(p[0],p[1],i);r.length>0?Structure.setField(h.array[l][m],r,1===o.length?o[0]:o[e]):h.array[l][m]=1===o.length?o[0]:o[e]}}};static setElementsLogical=(e,t,r,n,i)=>{const a=MultiArray.linearize(i),s=n.map(e=>Complex.realToNumber(e)),o=s.reduce((e,t)=>e+t,0);if(o!==a.length)throw new EvalError(`=: nonconformant arguments (op1 is ${o}x1, op2 is ${i.dimension[0]}x${i.dimension[1]})`);if(void 0===e[t]||e[t]instanceof FunctionHandle||!(e[t]instanceof MultiArray))throw new EvalError(`${t}(_): invalid matrix indexing.`);{const n=e[t].node;for(let e=0,t=0,i=0;e<n.dimension[1];e++)for(let o=0;o<n.dimension[0];o++,i++)s[i]&&(r.length>0?Structure.setField(n.array[o][e],r,a[t]):n.array[o][e]=a[t],t++)}};static reduceFactory=(e,t,r)=>{switch(t){case"reduce":return void 0!==r?(t,n)=>{const i=MultiArray.scalarToMultiArray(t),a=void 0!==n?Complex.realToNumber(MultiArray.firstElement(n))-1:Math.max(0,MultiArray.firstNonSingleDimension(i));return MultiArray.reduce(a,i,e,r)}:(t,r)=>{const n=MultiArray.scalarToMultiArray(t),i=void 0!==r?Complex.realToNumber(MultiArray.firstElement(r))-1:Math.max(0,MultiArray.firstNonSingleDimension(n));return MultiArray.reduce(i,n,e)};case"cumulative":return void 0!==r?(t,n)=>{const i=MultiArray.scalarToMultiArray(t),a=void 0!==n?Complex.realToNumber(MultiArray.firstElement(n))-1:MultiArray.firstNonSingleDimension(i),s=MultiArray.alongDimensionMap(a,i,(o=void 0,(t,n)=>o=e(0===n?r:o,t)));var o;return MultiArray.setType(s),s}:(t,r)=>{const n=MultiArray.scalarToMultiArray(t),i=void 0!==r?Complex.realToNumber(MultiArray.firstElement(r))-1:MultiArray.firstNonSingleDimension(n),a=MultiArray.alongDimensionMap(i,n,(s=void 0,(t,r)=>s=0===r?t:e(s,t)));var s;return MultiArray.setType(a),a};case"cumcomparison":return(t,r)=>{const n=MultiArray.scalarToMultiArray(t),i=r?Complex.realToNumber(MultiArray.firstElement(r))-1:MultiArray.firstNonSingleDimension(n),a=new MultiArray(n.dimension);let s,o;const l=MultiArray.alongDimensionMap(i,n,(t,r,n,i)=>(0===r?(s=t,o=Complex.one()):Complex.realToNumber(Complex[e](t,s))&&(s=t,o=Complex.create(r+1)),a.array[n][i]=o,s));return MultiArray.setType(l),MultiArray.setType(a),AST.nodeReturnList((e,t)=>1===e.length?MultiArray.MultiArrayToScalar(l):2===e.length?MultiArray.MultiArrayToScalar(0===t?l:a):void AST.throwErrorIfGreaterThanReturnList(2,e.length),e=>({length:e}))};case"comparison":const n="lt"===e?"min":"max";return(...t)=>{const r=(t,r)=>{const n=MultiArray.reduceToArray(r,t),i=new MultiArray(n.dimension),a=new MultiArray(n.dimension);for(let t=0;t<a.array.length;t++)for(let r=0;r<a.array[t].length;r++){const s=n.array[t][r];let o=s[0],l=1;for(let t=1;t<s.length;t++){const r=s[t];Complex.realToNumber(Complex[e](r,o))&&(o=r,l=t+1)}i.array[t][r]=o,a.array[t][r]=Complex.create(l)}return MultiArray.setType(i),MultiArray.setType(a),AST.nodeReturnList((e,t)=>1===e.length?MultiArray.MultiArrayToScalar(i):2===e.length?MultiArray.MultiArrayToScalar(0===t?i:a):void AST.throwErrorIfGreaterThanReturnList(2,e.length),e=>({length:e}))};switch(t.length){case 1:{const e=MultiArray.scalarToMultiArray(t[0]);return r(e,MultiArray.firstNonSingleDimension(e))}case 2:{const e=MultiArray.scalarToMultiArray(t[0]),i=t[1];if(MultiArray.isScalar(i))return r(e,MultiArray.testInteger(i,"reduceFactory","dimension",[1,1/0])-1);const a=MultiArray.scalarToMultiArray(i);return MultiArray.elementWiseOperation(n+"Wise",e,a)}case 3:if(!MultiArray.isEmpty(t[1]))throw new Error(`${n}: second argument must be [] or omitted`);return r(MultiArray.scalarToMultiArray(t[0]),Complex.realToNumber(MultiArray.firstElement(t[2]))-1);default:AST.throwInvalidCallError(n)}};default:throw TypeError(`reduceFactory: invalid type argument: ${t}`)}}}const src_MultiArray={MultiArray},BLASConfigKeyTable=["blockThreshold","blockSize"],BLAS_defaultSettings={blockThreshold:1e5,blockSize:64};class BLAS{static defaultSettings=Object.assign({},BLAS_defaultSettings);static settings=BLAS.defaultSettings;static set=e=>{Object.entries(e).forEach(e=>{if(!BLASConfigKeyTable.includes(e[0]))throw new Error(`BLAS.set: invalid configuration parameter: ${e[0]}`);BLAS.settings[e[0]]=e[1]})};static axpy=(e,t,r)=>{const n=t.length,i=t[0].length;for(let a=0;a<n;a++){const n=t[a],s=r[a];for(let t=0;t<i;t++)s[t]=Complex.add(s[t],Complex.mul(e,n[t]))}return r};static scal=(e,t,r,n)=>{if(Complex.realToNumber(Complex.eq(e,Complex.zero())))for(let e=r;e<n;e++)t[e]=Complex.zero();else if(!Complex.realToNumber(Complex.eq(e,Complex.one())))for(let i=r;i<n;i++)t[i]=Complex.mul(e,t[i])};static copy=e=>{if(Array.isArray(e))return Array.isArray(e[0])?Array.from({length:e.length},(t,r)=>Array.from({length:e[0].length},(t,n)=>Complex.copy(e[r][n]))):Array.from({length:e.length},(t,r)=>Complex.copy(e[r]));throw new Error("BLAS.copy: invalid argument")};static dotu=(e,t)=>{const r=e.length;let n=Complex.zero();for(let i=0;i<r;i++)Complex.mulAndSumTo(n,e[i],t[i]);return n};static dot=BLAS.dotu;static dotc=(e,t)=>{const r=e.length;let n=Complex.zero();for(let i=0;i<r;i++)Complex.mulAndSumTo(n,Complex.conj(e[i]),t[i]);return n};static nrm2sq=(e,t,r,n)=>{let i=Complex.zero();for(let a=r;a<n;a++)Complex.mulAndSumTo(i,e.array[a][t],Complex.conj(e.array[a][t]));return Complex.create(i.re)};static nrm2=e=>{let t=Complex.zero(),r=Complex.one();for(let n=0;n<e.length;n++){const i=e[n],a=Complex.abs(Complex.real(i)),s=Complex.abs(Complex.imag(i));if(Complex.toBoolean(Complex.ne(a,Complex.zero())))if(Complex.lt(t,a)){const e=Complex.rdiv(t,a);r=Complex.add(Complex.one(),Complex.mul(r,Complex.mul(e,e))),t=a}else{const e=Complex.rdiv(a,t);r=Complex.add(r,Complex.mul(e,e))}if(Complex.toBoolean(Complex.ne(s,Complex.zero())))if(Complex.lt(t,s)){const e=Complex.rdiv(t,s);r=Complex.add(Complex.one(),Complex.mul(r,Complex.mul(e,e))),t=s}else{const e=Complex.rdiv(s,t);r=Complex.add(r,Complex.mul(e,e))}}return Complex.toBoolean(Complex.eq(t,Complex.zero()))?Complex.zero():Complex.mul(t,Complex.sqrt(r))};static gemv=(e,t,r,n,i,a,s,o,l,c,u,m="N")=>{const h="N"===m?t:r,p="N"===m?r:t;for(let e=0;e<h;e++)o[l+e]=Complex.eq(u,Complex.zero())?Complex.zero():Complex.eq(u,Complex.one())?o[l+e]:Complex.mul(u,o[l+e]);for(let t=0;t<h;t++){let r=Complex.zero();for(let o=0;o<p;o++){const l="N"===m?e[n+t][i+o]:"T"===m?e[n+o][i+t]:Complex.conj(e[n+o][i+t]);Complex.mulAndSumTo(r,l,a[s+o])}Complex.mulAndSumTo(o[l+t],c,r)}};static trsv=(e,t,r)=>{const n=e.length;if(e.some(e=>e.length!==n))throw new Error("BLAS.trsv: A must be square.");if(t.length!==n)throw new Error("BLAS.trsv: x has incompatible dimension.");const i=Array.from({length:n},(e,r)=>[t[r]]);return BLAS.trsm(e,i,{side:"left",uplo:r.uplo,transA:r.transA,unitDiagonal:r.unitDiagonal}).map(e=>e[0])};static ger=(e,t,r,n,i,a,s,o,l,c,u,m)=>{if(!Complex.realIsZero(Complex.abs(a)))for(let h=0;h<n;h++){const n=s[o+h][l],p=Complex.mul(a,n),d=e[t+h];for(let e=0;e<i;e++)Complex.mulAndSumTo(d[r+e],p,Complex.conj(c[u+e][m]))}};static geru=(e,t,r,n,i,a)=>{if(!Complex.realIsZero(Complex.abs(r)))for(let s=0;s<e.length;s++){const o=e[s],l=n[i+s];for(let e=0;e<t.length;e++)Complex.mulAndSumTo(l[a+e],r,Complex.mul(o,t[e]))}};static gerc=(e,t,r,n,i=0,a=0)=>{for(let s=0;s<e.length;s++){const o=e[s],l=n[i+s];for(let e=0;e<t.length;e++)l[a+e]=Complex.add(l[a+e],Complex.mul(r,Complex.mul(o,Complex.conj(t[e]))))}};static gerc_nd=(e,t,r)=>{const n=[];for(let t=0;t<MultiArray.linearLength(e);t++){const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);n.push(e.array[r][i])}const i=[];for(let e=0;e<MultiArray.linearLength(t);e++){const[r,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);i.push(t.array[r][n])}const a=n.length,s=i.length;if(r.dimension[0]!==a||r.dimension[1]!==s)throw new Error(`BLAS.gerc_nd: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${a}, y is ${s})`);for(let e=0;e<a;e++){const t=Complex.conj(n[e]);for(let n=0;n<s;n++){const a=Complex.mul(t,i[n]);r.array[e][n]?r.array[e][n]=Complex.add(r.array[e][n],a):r.array[e][n]=Complex.copy(a)}}MultiArray.setType(r)};static gerc_nd_direct=(e,t,r)=>{const n=MultiArray.linearLength(e),i=MultiArray.linearLength(t);if(r.dimension[0]!==n||r.dimension[1]!==i)throw new Error(`BLAS.gerc_nd_direct: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${n}, y is ${i})`);e.dimension[0],e.dimension[1],t.dimension[0],t.dimension[1],r.dimension[0],r.dimension[1];for(let a=0;a<n;a++){const[s,o]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1]||1,a),l=Complex.conj(e.array[s][o]);for(let e=0;e<i;e++){const[i,s]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1]||1,e),o=t.array[i][s],[c,u]=MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],a+e*n);r.array[c][u]?r.array[c][u]=Complex.add(r.array[c][u],Complex.mul(l,o)):r.array[c][u]=Complex.mul(l,o)}}MultiArray.setType(r)};static gemm_kernel=(e,t,r,n,i,a,s,o,l)=>{for(let c=n;c<i;c++){const n=e[c],i=r[c];for(let e=a;e<s;e++){let r=i[e]??Complex.zero();for(let i=o;i<l;i++)Complex.mulAndSumTo(r,n[i],t[i][e]);i[e]=r}}};static gemm=(e,t,r,n,i,a,s,o,l)=>{if(Complex.realIsZero(Complex.abs(e)))for(let e=0;e<r;e++){const t=o[e];for(let e=0;e<a;e++)t[e]=Complex.mul(s,t[e])}else{if(!Complex.eq(s,Complex.one()))for(let e=0;e<r;e++){const t=o[e];for(let e=0;e<a;e++)t[e]=Complex.mul(s,t[e])}if(r*n*a>BLAS.settings.blockThreshold)for(let e=0;e<r;e+=l??BLAS.settings.blockSize){const s=Math.min(e+(l??BLAS.settings.blockSize),r);for(let r=0;r<n;r+=l??BLAS.settings.blockSize){const c=Math.min(r+(l??BLAS.settings.blockSize),n);for(let n=0;n<a;n+=l??BLAS.settings.blockSize){const u=Math.min(n+(l??BLAS.settings.blockSize),a);BLAS.gemm_kernel(t,i,o,e,s,n,u,r,c)}}}else for(let s=0;s<r;s++){const r=t[s],l=o[s];for(let t=0;t<a;t++){let a=Complex.zero();for(let e=0;e<n;e++)Complex.mulAndSumTo(a,r[e],i[e][t]);l[t]=Complex.add(l[t],Complex.mul(e,a))}}}};static gemm_block=(e,t,r,n,i,a)=>{const s=e.length,o=e[0]?.length??0,l=t.length,c=t[0]?.length??0;if(o!==l)throw new Error("BLAS.gemm_block: inner dimensions mismatch A.cols != B.rows");if(r.length!==s||r[0]?.length!==c)throw new Error("BLAS.gemm_block: output dimension mismatch with C");if(Complex.realIsZero(Complex.abs(n))){if(Complex.realIsZero(Complex.abs(i)))for(let e=0;e<s;e++)for(let t=0;t<c;t++)r[e][t]=Complex.zero();else if(Complex.toBoolean(Complex.ne(i,Complex.one())))for(let e=0;e<s;e++)for(let t=0;t<c;t++)r[e][t]=Complex.mul(i,r[e][t]);return}const u=Math.max(1,Math.floor(a??BLAS.settings.blockSize));for(let a=0;a<s;a+=u){const l=Math.min(a+u,s);for(let s=0;s<c;s+=u){const m=Math.min(s+u,c);for(let e=a;e<l;e++)for(let t=s;t<m;t++)Complex.realIsZero(Complex.abs(i))?r[e][t]=Complex.zero():Complex.toBoolean(Complex.ne(i,Complex.one()))&&(r[e][t]=Complex.mul(i,r[e][t]));for(let i=0;i<o;i+=u){const c=Math.min(i+u,o);for(let o=a;o<l;o++){const a=e[o],l=r[o];for(let e=i;e<c;e++){const r=a[e];if(!Complex.realIsZero(Complex.abs(r)))for(let i=s;i<m;i++){const a=Complex.mul(r,t[e][i]),s=Complex.mul(n,a);l[i]=Complex.add(l[i],s)}}}}}}};static trsm=(e,t,r)=>{const n=r?.side??"left",i=r?.uplo??"upper",a=r?.transA??"N",s=r?.unitDiagonal??!1,o=t.length,l=t[0]?.length??0;if(e.length!==e[0]?.length)throw new Error("BLAS.trsm: A must be square.");if("left"===n&&e.length!==o||"right"===n&&e.length!==l)throw new Error("BLAS.trsm: nonconformant dimensions.");const c=t.map(e=>e.map(e=>e)),u=(t,r)=>"N"===a?e[t][r]:"T"===a?e[r][t]:Complex.conj(e[r][t]);if("left"===n)if("upper"===i&&"N"===a||"lower"===i&&"N"!==a)for(let e=0;e<l;e++)for(let t=o-1;t>=0;t--){let r=c[t][e];for(let n=t+1;n<o;n++)r=Complex.sub(r,Complex.mul(u(t,n),c[n][e]));s||(r=Complex.rdiv(r,u(t,t))),c[t][e]=r}else for(let e=0;e<l;e++)for(let t=0;t<o;t++){let r=c[t][e];for(let n=0;n<t;n++)r=Complex.sub(r,Complex.mul(u(t,n),c[n][e]));s||(r=Complex.rdiv(r,u(t,t))),c[t][e]=r}else if("upper"===i&&"N"===a||"lower"===i&&"N"!==a)for(let e=0;e<o;e++)for(let t=0;t<l;t++){let r=c[e][t];for(let n=0;n<t;n++)r=Complex.sub(r,Complex.mul(c[e][n],u(n,t)));s||(r=Complex.rdiv(r,u(t,t))),c[e][t]=r}else for(let e=0;e<o;e++)for(let t=l-1;t>=0;t--){let r=c[e][t];for(let n=t+1;n<l;n++)r=Complex.sub(r,Complex.mul(c[e][n],u(n,t)));s||(r=Complex.rdiv(r,u(t,t))),c[e][t]=r}return c};static functions={axpy:BLAS.axpy,scal:BLAS.scal,copy:BLAS.copy,dotu:BLAS.dotu,dotc:BLAS.dotc,nrm2sq:BLAS.nrm2sq,nrm2:BLAS.nrm2,gemv:BLAS.gemv,trsv:BLAS.trsv,ger:BLAS.ger,geru:BLAS.geru,gerc:BLAS.gerc,gerc_nd:BLAS.gerc_nd,gerc_nd_direct:BLAS.gerc_nd_direct,gemm_kernel:BLAS.gemm_kernel,gemm:BLAS.gemm,gemm_block:BLAS.gemm_block,trsm:BLAS.trsm}}const src_BLAS={BLAS};class MathOperation{static copy=e=>Complex.isInstanceOf(e)?Complex.copy(e):MultiArray.isInstanceOf(e)?MultiArray.copy(e):CharString.isInstanceOf(e)?CharString.copy(e):Structure.isInstanceOf(e)?Structure.copy(e):FunctionHandle.copy(e);static elementWiseOperation=(e,t,r)=>{if(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),CharString.isInstanceOf(r)&&(r=MultiArray.fromCharString(r)),Complex.isInstanceOf(t)&&Complex.isInstanceOf(r))return Complex[e](t,r);if(Complex.isInstanceOf(t)&&MultiArray.isInstanceOf(r))return MultiArray.scalarOpMultiArray(e,t,r);if(MultiArray.isInstanceOf(t)&&Complex.isInstanceOf(r))return MultiArray.MultiArrayOpScalar(e,t,r);if(MultiArray.isInstanceOf(t)&&MultiArray.isInstanceOf(r))return MultiArray.elementWiseOperation(e,t,r);throw new EvalError(`binary operator '${e}' not implemented for 'scalar struct' operands.`)};static leftOperation=(e,t)=>{if(CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(t))return Complex[e](t);if(MultiArray.isInstanceOf(t))return MultiArray.leftOperation(e,t);throw new EvalError(`unary operator '${e}' not implemented for 'scalar struct' operands.`)};static plus=(e,t)=>MathOperation.elementWiseOperation("add",e,t);static minus=(e,t)=>MathOperation.elementWiseOperation("sub",e,t);static mod=(e,t)=>MathOperation.elementWiseOperation("mod",e,t);static rem=(e,t)=>MathOperation.elementWiseOperation("rem",e,t);static times=(e,t)=>MathOperation.elementWiseOperation("mul",e,t);static mtimes=(e,t)=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t)?Complex.mul(e,t):Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(t)?MultiArray.scalarOpMultiArray("mul",e,t):MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t)?MultiArray.MultiArrayOpScalar("mul",e,t):LinearAlgebra.mul(e,t));static rdivide=(e,t)=>MathOperation.elementWiseOperation("rdiv",e,t);static mrdivide=(e,t)=>{if(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t))return Complex.rdiv(e,t);if(Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(t))return MultiArray.scalarOpMultiArray("mul",e,LinearAlgebra.inv(t));if(MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t))return MultiArray.scalarOpMultiArray("mul",Complex.inv(t),e);{const r=LinearAlgebra.inv(t),n=new MultiArray([e.dimension[0],r.dimension[1]]);return BLAS.gemm(Complex.one(),e.array,e.dimension[0],e.dimension[1],r.array,r.dimension[1],Complex.zero(),n.array),n}};static ldivide=(e,t)=>MathOperation.elementWiseOperation("ldiv",e,t);static mldivide=(e,t)=>{if(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t))return Complex.ldiv(e,t);if(Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(t))return MultiArray.scalarOpMultiArray("ldiv",e,t);if(MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t))throw new EvalError(`operator \\: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is 1x1).`);if(e.dimension[1]===t.dimension[0])return LAPACK.mldivide(e,t).X;throw new EvalError(`operator \\: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is ${t.dimension.join("x")}).`)};static power=(e,t)=>MathOperation.elementWiseOperation("power",e,t);static mpower=(e,t)=>{if(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t))return Complex.power(e,t);if(MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t))return LinearAlgebra.power(e,t);throw new Error("invalid exponent in '^'.")};static uplus=e=>MathOperation.leftOperation("copy",e);static uminus=e=>MathOperation.leftOperation("neg",e);static transpose=e=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),MultiArray.isInstanceOf(e)?LinearAlgebra.transpose(e):e.copy());static ctranspose=e=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),Complex.isInstanceOf(e)?Complex.conj(e):MultiArray.isInstanceOf(e)?LinearAlgebra.ctranspose(e):e.copy());static lt=(e,t)=>MathOperation.elementWiseOperation("lt",e,t);static le=(e,t)=>MathOperation.elementWiseOperation("le",e,t);static eq=(e,t)=>MathOperation.elementWiseOperation("eq",e,t);static ge=(e,t)=>MathOperation.elementWiseOperation("ge",e,t);static gt=(e,t)=>MathOperation.elementWiseOperation("gt",e,t);static ne=(e,t)=>MathOperation.elementWiseOperation("ne",e,t);static mand=(e,t)=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t)?Complex.and(e,t):Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(t)?Complex.and(e,MultiArray.toLogical(t)):MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t)?Complex.and(MultiArray.toLogical(e),t):Complex.and(MultiArray.toLogical(e),MultiArray.toLogical(t)));static mor=(e,t)=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),CharString.isInstanceOf(t)&&(t=MultiArray.fromCharString(t)),Complex.isInstanceOf(e)&&Complex.isInstanceOf(t)?Complex.or(e,t):Complex.isInstanceOf(e)&&MultiArray.isInstanceOf(t)?Complex.or(e,MultiArray.toLogical(t)):MultiArray.isInstanceOf(e)&&Complex.isInstanceOf(t)?Complex.or(MultiArray.toLogical(e),t):Complex.or(MultiArray.toLogical(e),MultiArray.toLogical(t)));static not=e=>(CharString.isInstanceOf(e)&&(e=MultiArray.fromCharString(e)),Complex.isInstanceOf(e)?Complex.not(e):MultiArray.isInstanceOf(e)?Complex.not(MultiArray.toLogical(e)):Structure.isInstanceOf(e)?Complex.not(Structure.toLogical(e)):Complex.not(FunctionHandle.toLogical(e)));static and=(e,t)=>MathOperation.elementWiseOperation("and",e,t);static or=(e,t)=>MathOperation.elementWiseOperation("or",e,t);static xor=(e,t)=>MathOperation.elementWiseOperation("xor",e,t);static unaryOperations={uplus:MathOperation.uplus,uminus:MathOperation.uminus,not:MathOperation.not,transpose:MathOperation.transpose,ctranspose:MathOperation.ctranspose};static binaryOperations={minus:MathOperation.minus,mod:MathOperation.mod,rem:MathOperation.rem,rdivide:MathOperation.rdivide,mrdivide:MathOperation.mrdivide,ldivide:MathOperation.ldivide,mldivide:MathOperation.mldivide,power:MathOperation.power,mpower:MathOperation.mpower,le:MathOperation.le,ge:MathOperation.ge,gt:MathOperation.gt,eq:MathOperation.eq,ne:MathOperation.ne};static leftAssociativeMultipleOperations={plus:MathOperation.plus,times:MathOperation.times,mtimes:MathOperation.mtimes,and:MathOperation.and,or:MathOperation.or,xor:MathOperation.xor}}const src_MathOperation={MathOperation};var antlr4_web=__webpack_require__(168),MathJSLabLexer=__webpack_require__(207);class MathJSLabParser extends antlr4_web.iX{static GLOBAL=1;static PERSISTENT=2;static IF=3;static ENDIF=4;static END=5;static ENDRANGE=6;static ELSEIF=7;static ELSE=8;static SWITCH=9;static ENDSWITCH=10;static CASE=11;static OTHERWISE=12;static WHILE=13;static ENDWHILE=14;static DO=15;static UNTIL=16;static FOR=17;static ENDFOR=18;static PARFOR=19;static ENDPARFOR=20;static BREAK=21;static CONTINUE=22;static RETURN=23;static FUNCTION=24;static ENDFUNCTION=25;static TRY=26;static CATCH=27;static END_TRY_CATCH=28;static UNWIND_PROTECT=29;static UNWIND_PROTECT_CLEANUP=30;static END_UNWIND_PROTECT=31;static CLASSDEF=32;static ENDCLASSDEF=33;static ENUMERATION=34;static ENDENUMERATION=35;static PROPERTIES=36;static ENDPROPERTIES=37;static EVENTS=38;static ENDEVENTS=39;static METHODS=40;static ENDMETHODS=41;static WSPACE=42;static STRING=43;static ARGUMENTS=44;static PLUS=45;static MINUS=46;static MUL=47;static DIV=48;static EQ=49;static COLON=50;static SEMICOLON=51;static COMMA=52;static DOT=53;static TILDE=54;static EXCLAMATION=55;static COMMAT=56;static LPAREN=57;static RPAREN=58;static LBRACKET=59;static RBRACKET=60;static LCURLYBR=61;static RCURLYBR=62;static LEFTDIV=63;static ADD_EQ=64;static SUB_EQ=65;static MUL_EQ=66;static DIV_EQ=67;static LEFTDIV_EQ=68;static POW_EQ=69;static EMUL_EQ=70;static EDIV_EQ=71;static ELEFTDIV_EQ=72;static EPOW_EQ=73;static AND_EQ=74;static OR_EQ=75;static EXPR_AND_AND=76;static EXPR_OR_OR=77;static EXPR_AND=78;static EXPR_OR=79;static EXPR_LT=80;static EXPR_LE=81;static EXPR_EQ=82;static EXPR_NE=83;static EXPR_GE=84;static EXPR_GT=85;static EMUL=86;static EDIV=87;static ELEFTDIV=88;static PLUS_PLUS=89;static MINUS_MINUS=90;static POW=91;static EPOW=92;static TRANSPOSE=93;static HERMITIAN=94;static DQSTRING=95;static IDENTIFIER=96;static FLOAT_NUMBER=97;static NUMBER_DOT_OP=98;static SPACE_OR_CONTINUATION=99;static NEWLINE=100;static BLOCK_COMMENT_START=101;static COMMENT_LINE=102;static INVALID=103;static SINGLEQ_STRING=104;static SINGLEQ_NL=105;static SINGLEQ_SINGLEQ=106;static SINGLEQ_END=107;static DOUBLEQ_STRING=108;static DOUBLEQ_NL=109;static DOUBLEQ_DOUBLEQ=110;static DOUBLEQ_ESCAPE=111;static DOUBLEQ_ESCAPE_OTHER=112;static DOUBLEQ_ESCAPE_OCT=113;static DOUBLEQ_ESCAPE_HEX=114;static DOUBLEQ_ESCAPE_UNICODE=115;static DOUBLEQ_END=116;static BLOCK_COMMENT_START_AGAIN=117;static BLOCK_COMMENT_END=118;static BLOCK_COMMENT_LINE=119;static BLOCK_COMMENT_EOF=120;static SKIP_SPACE=121;static SKIP_COMMENT_LINE=122;static EXIT_AT_NEWLINE=123;static EXIT_AT_EOF=124;static UNQUOTED_STRING=125;static EOF=antlr4_web.ou.EOF;static RULE_input=0;static RULE_global_list=1;static RULE_list=2;static RULE_statement=3;static RULE_word_list_cmd=4;static RULE_identifier=5;static RULE_string=6;static RULE_number=7;static RULE_end_range=8;static RULE_constant=9;static RULE_matrix=10;static RULE_matrix_row=11;static RULE_fcn_handle=12;static RULE_anon_fcn_handle=13;static RULE_primary_expr=14;static RULE_magic_colon=15;static RULE_magic_tilde=16;static RULE_list_element=17;static RULE_arg_list=18;static RULE_oper_expr=19;static RULE_power_expr=20;static RULE_colon_expr=21;static RULE_simple_expr=22;static RULE_expression=23;static RULE_command=24;static RULE_declaration=25;static RULE_declaration_element=26;static RULE_select_command=27;static RULE_if_command=28;static RULE_elseif_clause=29;static RULE_else_clause=30;static RULE_param_list=31;static RULE_param_list_elt=32;static RULE_return_list=33;static RULE_function=34;static RULE_arguments_block_list=35;static RULE_arguments_block=36;static RULE_args_validation_list=37;static RULE_arg_validation=38;static RULE_sep_no_nl=39;static RULE_nl=40;static RULE_sep=41;static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","SKIP_SPACE","SKIP_COMMENT_LINE","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static ruleNames=["input","global_list","list","statement","word_list_cmd","identifier","string","number","end_range","constant","matrix","matrix_row","fcn_handle","anon_fcn_handle","primary_expr","magic_colon","magic_tilde","list_element","arg_list","oper_expr","power_expr","colon_expr","simple_expr","expression","command","declaration","declaration_element","select_command","if_command","elseif_clause","else_clause","param_list","param_list_elt","return_list","function","arguments_block_list","arguments_block","args_validation_list","arg_validation","sep_no_nl","nl","sep"];get grammarFileName(){return"MathJSLabParser.g4"}get literalNames(){return MathJSLabParser.literalNames}get symbolicNames(){return MathJSLabParser.symbolicNames}get ruleNames(){return MathJSLabParser.ruleNames}get serializedATN(){return MathJSLabParser._serializedATN}createFailedPredicateException(e,t){return new antlr4_web.eP(this,e,t)}constructor(e){super(e),this._interp=new antlr4_web.re(this,MathJSLabParser._ATN,MathJSLabParser.DecisionsToDFA,new antlr4_web.tD)}input(){let e,t=new InputContext(this,this._ctx,this.state);this.enterRule(t,0,MathJSLabParser.RULE_input);try{switch(this.state=96,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,2,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=85,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=84,this.sep()),this.state=87,this.match(MathJSLabParser.EOF),t.node=null;break;case 2:this.enterOuterAlt(t,2),this.state=90,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=89,this.sep()),this.state=92,this.global_list(),this.state=93,this.match(MathJSLabParser.EOF),t.node=t.global_list().node}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}global_list(){let e,t=new Global_listContext(this,this._ctx,this.state);this.enterRule(t,2,MathJSLabParser.RULE_global_list);try{let r;for(this.enterOuterAlt(t,1),this.state=98,this.statement(),t.statement(t.i).node.start={line:t.statement(t.i).start.line,column:t.statement(t.i).start.column},t.statement(t.i).node.stop={line:this._input.LT(1).column>0?this._input.LT(1).line:this._input.LT(1).line-1,column:this._input.LT(1).column>0?this._input.LT(1).column-1:1/0},t.node=AST.nodeListFirst(t.statement(t.i++).node),this.state=106,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=100,this.sep(),this.state=101,this.statement(),t.statement(t.i).node.start={line:t.statement(t.i).start.line,column:t.statement(t.i).start.column},t.statement(t.i).node.stop={line:this._input.LT(1).column>0?this._input.LT(1).line:this._input.LT(1).line-1,column:this._input.LT(1).column>0?this._input.LT(1).column-1:1/0},";"===t.sep(t.i-1).getText()[0]&&(t.node.list[t.node.list.length-1].omitOutput=!0),t.node=AST.appendNodeList(t.node,t.statement(t.i++).node)),this.state=108,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);this.state=110,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=109,this.sep()),t.sep(t.i-1)&&";"===t.sep(t.i-1).getText()[0]&&(t.node.list[t.node.list.length-1].omitOutput=!0)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}list(){let e,t=new ListContext(this,this._ctx,this.state);this.enterRule(t,4,MathJSLabParser.RULE_list);try{let r;for(this.enterOuterAlt(t,1),this.state=114,this.statement(),t.node=AST.nodeListFirst(t.statement(t.i++).node),this.state=122,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,5,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=116,this.sep(),this.state=117,this.statement(),";"===t.sep(t.i-1).getText()[0]&&(t.node.list[t.node.list.length-1].omitOutput=!0),t.node=AST.appendNodeList(t.node,t.statement(t.i++).node)),this.state=124,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,5,this._ctx);this.state=126,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=125,this.sep()),t.sep(t.i-1)&&";"===t.sep(t.i-1).getText()[0]&&(t.node.list[t.node.list.length-1].omitOutput=!0)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}statement(){let e=new StatementContext(this,this._ctx,this.state);this.enterRule(e,6,MathJSLabParser.RULE_statement);try{switch(this.state=139,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,7,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=130,this.expression(),e.node=e.expression().node;break;case 2:this.enterOuterAlt(e,2),this.state=133,this.command(),e.node=e.command().node;break;case 3:this.enterOuterAlt(e,3),this.state=136,this.word_list_cmd(),e.node=e.word_list_cmd().node}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}word_list_cmd(){let e,t=new Word_list_cmdContext(this,this._ctx,this.state);this.enterRule(t,8,MathJSLabParser.RULE_word_list_cmd);try{for(this.enterOuterAlt(t,1),this.state=141,this.identifier(),this.state=147,this._errHandler.sync(this),e=this._input.LA(1);43===e||125===e;)this.state=142,this.string_(),0===t.i?t.node=AST.nodeListFirst(t.string_(t.i++).node):AST.appendNodeList(t.node,t.string_(t.i++).node),this.state=149,this._errHandler.sync(this),e=this._input.LA(1);t.node=AST.nodeCmdWList(t.identifier().node,t.node)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}identifier(){let e=new IdentifierContext(this,this._ctx,this.state);this.enterRule(e,10,MathJSLabParser.RULE_identifier);try{this.enterOuterAlt(e,1),this.state=152,this.match(MathJSLabParser.IDENTIFIER),e.node=AST.nodeIdentifier(e.IDENTIFIER().getText())}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}string_(){let e=new StringContext(this,this._ctx,this.state);this.enterRule(e,12,MathJSLabParser.RULE_string);try{switch(this.state=159,this._errHandler.sync(this),this._input.LA(1)){case 43:this.enterOuterAlt(e,1);{this.state=155,this.match(MathJSLabParser.STRING);const t=e.STRING().getText();e.node=AST.nodeString(t.substring(1,t.length-1),t[0])}break;case 125:this.enterOuterAlt(e,2),this.state=157,this.match(MathJSLabParser.UNQUOTED_STRING),e.node=AST.nodeString(e.UNQUOTED_STRING().getText());break;default:throw new antlr4_web.X2(this)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}number_(){let e=new NumberContext(this,this._ctx,this.state);this.enterRule(e,14,MathJSLabParser.RULE_number);try{this.enterOuterAlt(e,1),this.state=161,this.match(MathJSLabParser.FLOAT_NUMBER),e.node=AST.nodeNumber(e.FLOAT_NUMBER().getText())}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}end_range(){let e=new End_rangeContext(this,this._ctx,this.state);this.enterRule(e,16,MathJSLabParser.RULE_end_range);try{this.enterOuterAlt(e,1),this.state=164,this.match(MathJSLabParser.ENDRANGE),e.node=AST.nodeLiteral("ENDRANGE")}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}constant(){let e=new ConstantContext(this,this._ctx,this.state);this.enterRule(e,18,MathJSLabParser.RULE_constant);try{switch(this.state=176,this._errHandler.sync(this),this._input.LA(1)){case 97:this.enterOuterAlt(e,1),this.state=167,this.number_(),e.node=e.number_().node;break;case 43:case 125:this.enterOuterAlt(e,2),this.state=170,this.string_(),e.node=e.string_().node;break;case 6:this.enterOuterAlt(e,3),this.state=173,this.end_range(),e.node=e.end_range().node;break;default:throw new antlr4_web.X2(this)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}matrix(){let e,t=new MatrixContext(this,this._ctx,this.state);this.enterRule(t,20,MathJSLabParser.RULE_matrix);try{let r;switch(this.state=224,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,17,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=178,this.match(MathJSLabParser.LBRACKET),this.state=179,this.match(MathJSLabParser.RBRACKET),t.node=AST.emptyArray();break;case 2:for(this.enterOuterAlt(t,2),this.state=181,this.match(MathJSLabParser.LBRACKET),this.state=182,this.matrix_row(),t.node=AST.nodeFirstRow(t.matrix_row(t.i++).node),this.state=193,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,12,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;){if(1===r){switch(this.state=186,this._errHandler.sync(this),this._input.LA(1)){case 51:this.state=184,this.match(MathJSLabParser.SEMICOLON);break;case 100:this.state=185,this.nl();break;default:throw new antlr4_web.X2(this)}this.state=188,this.matrix_row(),t.node=AST.nodeAppendRow(t.node,t.matrix_row(t.i++).node)}this.state=195,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,12,this._ctx)}this.state=197,this._errHandler.sync(this),e=this._input.LA(1),100===e&&(this.state=196,this.nl()),this.state=199,this.match(MathJSLabParser.RBRACKET);break;case 3:this.enterOuterAlt(t,3),this.state=201,this.match(MathJSLabParser.LCURLYBR),this.state=202,this.match(MathJSLabParser.RCURLYBR),t.node=AST.emptyArray(!0);break;case 4:for(this.enterOuterAlt(t,4),this.state=204,this.match(MathJSLabParser.LCURLYBR),this.state=205,this.matrix_row(),t.node=AST.nodeFirstRow(t.matrix_row(t.i++).node,!0),this.state=216,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;){if(1===r){switch(this.state=209,this._errHandler.sync(this),this._input.LA(1)){case 51:this.state=207,this.match(MathJSLabParser.SEMICOLON);break;case 100:this.state=208,this.nl();break;default:throw new antlr4_web.X2(this)}this.state=211,this.matrix_row(),t.node=AST.nodeAppendRow(t.node,t.matrix_row(t.i++).node)}this.state=218,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx)}this.state=220,this._errHandler.sync(this),e=this._input.LA(1),100===e&&(this.state=219,this.nl()),this.state=222,this.match(MathJSLabParser.RCURLYBR)}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}matrix_row(){let e,t=new Matrix_rowContext(this,this._ctx,this.state);this.enterRule(t,22,MathJSLabParser.RULE_matrix_row);try{let r;switch(this.state=245,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,21,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=226,e=this._input.LA(1),42!==e&&52!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=null;break;case 2:for(this.enterOuterAlt(t,2),this.state=229,this._errHandler.sync(this),e=this._input.LA(1),42!==e&&52!==e||(this.state=228,e=this._input.LA(1),42!==e&&52!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())),this.state=231,this.list_element(),t.node=AST.nodeListFirst(t.list_element(t.i++).node),this.state=239,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,19,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=233,e=this._input.LA(1),42!==e&&52!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=234,this.list_element(),t.node=AST.appendNodeList(t.node,t.list_element(t.i++).node)),this.state=241,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,19,this._ctx);this.state=243,this._errHandler.sync(this),e=this._input.LA(1),42!==e&&52!==e||(this.state=242,e=this._input.LA(1),42!==e&&52!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}fcn_handle(){let e=new Fcn_handleContext(this,this._ctx,this.state);this.enterRule(e,24,MathJSLabParser.RULE_fcn_handle);try{this.enterOuterAlt(e,1),this.state=247,this.match(MathJSLabParser.COMMAT),this.state=248,this.identifier(),e.node=AST.nodeFunctionHandle(e.identifier().node)}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}anon_fcn_handle(){let e=new Anon_fcn_handleContext(this,this._ctx,this.state);this.enterRule(e,26,MathJSLabParser.RULE_anon_fcn_handle);try{this.enterOuterAlt(e,1),this.state=251,this.match(MathJSLabParser.COMMAT),this.state=252,this.param_list(),this.state=253,this.expression(),e.node=AST.nodeFunctionHandle(null,e.param_list().node,e.expression().node)}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}primary_expr(){let e=new Primary_exprContext(this,this._ctx,this.state);this.enterRule(e,28,MathJSLabParser.RULE_primary_expr);try{switch(this.state=273,this._errHandler.sync(this),this._input.LA(1)){case 96:this.enterOuterAlt(e,1),this.state=256,this.identifier(),e.node=e.identifier().node;break;case 6:case 43:case 97:case 125:this.enterOuterAlt(e,2),this.state=259,this.constant(),e.node=e.constant().node;break;case 56:this.enterOuterAlt(e,3),this.state=262,this.fcn_handle(),e.node=e.fcn_handle().node;break;case 59:case 61:this.enterOuterAlt(e,4),this.state=265,this.matrix(),e.node=e.matrix().node;break;case 57:this.enterOuterAlt(e,5),this.state=268,this.match(MathJSLabParser.LPAREN),this.state=269,this.expression(),this.state=270,this.match(MathJSLabParser.RPAREN),e.node=AST.nodeOp("()",e.expression().node);break;default:throw new antlr4_web.X2(this)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}magic_colon(){let e=new Magic_colonContext(this,this._ctx,this.state);this.enterRule(e,30,MathJSLabParser.RULE_magic_colon);try{this.enterOuterAlt(e,1),this.state=275,this.match(MathJSLabParser.COLON),e.node=AST.nodeLiteral(":")}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}magic_tilde(){let e=new Magic_tildeContext(this,this._ctx,this.state);this.enterRule(e,32,MathJSLabParser.RULE_magic_tilde);try{this.enterOuterAlt(e,1),this.state=278,this.match(MathJSLabParser.TILDE),e.node=AST.nodeLiteral("<~>")}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}list_element(){let e=new List_elementContext(this,this._ctx,this.state);this.enterRule(e,34,MathJSLabParser.RULE_list_element);try{switch(this.state=290,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,23,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=281,this.expression(),e.node=e.expression().node;break;case 2:this.enterOuterAlt(e,2),this.state=284,this.magic_colon(),e.node=e.magic_colon().node;break;case 3:this.enterOuterAlt(e,3),this.state=287,this.magic_tilde(),e.node=e.magic_tilde().node}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arg_list(){let e,t=new Arg_listContext(this,this._ctx,this.state);this.enterRule(t,36,MathJSLabParser.RULE_arg_list);try{for(this.enterOuterAlt(t,1),this.state=292,this.list_element(),t.node=AST.nodeListFirst(t.list_element(t.i++).node),this.state=300,this._errHandler.sync(this),e=this._input.LA(1);52===e;)this.state=294,this.match(MathJSLabParser.COMMA),this.state=295,this.list_element(),t.node=AST.appendNodeList(t.node,t.list_element(t.i++).node),this.state=302,this._errHandler.sync(this),e=this._input.LA(1)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}oper_expr(e){void 0===e&&(e=0);let t,r=this._ctx,n=this.state,i=new Oper_exprContext(this,this._ctx,n),a=i,s=38;this.enterRecursionRule(i,38,MathJSLabParser.RULE_oper_expr,e);try{let e;switch(this.enterOuterAlt(i,1),this.state=315,this._errHandler.sync(this),this._input.LA(1)){case 6:case 43:case 56:case 57:case 59:case 61:case 96:case 97:case 125:this.state=304,this.primary_expr(),i.node=i.primary_expr().node;break;case 45:case 46:case 89:case 90:this.state=307,i._op=this._input.LT(1),t=this._input.LA(1),45!==t&&46!==t&&89!==t&&90!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=308,this.oper_expr(4),i.node=AST.nodeOp(i._op.text+"_",i.oper_expr(0).node);break;case 54:case 55:this.state=311,i._op=this._input.LT(1),t=this._input.LA(1),54!==t&&55!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=312,this.oper_expr(3),i.node=AST.nodeOp(i._op.text,i.oper_expr(0).node);break;default:throw new antlr4_web.X2(this)}for(this._ctx.stop=this._input.LT(-1),this.state=365,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,29,this._ctx);2!==e&&e!==antlr4_web.MG.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),a=i,this.state=363,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,28,this._ctx)){case 1:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=317,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=318,i._op=this._input.LT(1),t=this._input.LA(1),!(t-47&-32)&&1<<t-47&65539||!(t-86&-32)&&1<<t-86&7?(this._errHandler.reportMatch(this),this.consume()):i._op=this._errHandler.recoverInline(this),this.state=319,this.oper_expr(3),i.node=AST.nodeOp(i._op.text,i.oper_expr(0).node,i.oper_expr(1).node);break;case 2:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=322,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=323,i._op=this._input.LT(1),t=this._input.LA(1),45!==t&&46!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=324,this.oper_expr(2),i.node=AST.nodeOp(i._op.text,i.oper_expr(0).node,i.oper_expr(1).node);break;case 3:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=327,!this.precpred(this._ctx,11))throw this.createFailedPredicateException("this.precpred(this._ctx, 11)");this.state=328,i._op=this._input.LT(1),t=this._input.LA(1),89!==t&&90!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOp("_"+i._op.text,i.oper_expr(0).node);break;case 4:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=330,!this.precpred(this._ctx,10))throw this.createFailedPredicateException("this.precpred(this._ctx, 10)");this.state=331,this.match(MathJSLabParser.LPAREN),this.state=333,this._errHandler.sync(this),t=this._input.LA(1),(6===t||!(t-43&-32)&&1<<t-43&358541||!(t-89&-32)&&1<<t-89&387||125===t)&&(this.state=332,this.arg_list()),this.state=335,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndexExpr(i.oper_expr(0).node,i.arg_list()?i.arg_list().node:null,"()");break;case 5:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=337,!this.precpred(this._ctx,9))throw this.createFailedPredicateException("this.precpred(this._ctx, 9)");this.state=338,this.match(MathJSLabParser.LCURLYBR),this.state=340,this._errHandler.sync(this),t=this._input.LA(1),(6===t||!(t-43&-32)&&1<<t-43&358541||!(t-89&-32)&&1<<t-89&387||125===t)&&(this.state=339,this.arg_list()),this.state=342,this.match(MathJSLabParser.RCURLYBR),i.node=AST.nodeIndexExpr(i.oper_expr(0).node,i.arg_list()?i.arg_list().node:null,"{}");break;case 6:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=344,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=345,i._op=this._input.LT(1),t=this._input.LA(1),93!==t&&94!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOp(i._op.text,i.oper_expr(0).node);break;case 7:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=347,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=348,this.match(MathJSLabParser.DOT),this.state=349,this.match(MathJSLabParser.IDENTIFIER),i.node=AST.nodeIndirectRef(i.oper_expr(0).node,i.IDENTIFIER().getText());break;case 8:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=351,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=352,this.match(MathJSLabParser.DOT),this.state=353,this.match(MathJSLabParser.LPAREN),this.state=354,this.expression(),this.state=355,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndirectRef(i.oper_expr(0).node,i.expression().node);break;case 9:if(i=new Oper_exprContext(this,r,n),this.pushNewRecursionContext(i,s,MathJSLabParser.RULE_oper_expr),this.state=358,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=359,i._op=this._input.LT(1),t=this._input.LA(1),91!==t&&92!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=360,this.power_expr(0),i.node=AST.nodeOp(i._op.text,i.oper_expr(0).node,i.power_expr().node)}this.state=367,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,29,this._ctx)}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;i.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return i}power_expr(e){void 0===e&&(e=0);let t,r=this._ctx,n=this.state,i=new Power_exprContext(this,this._ctx,n),a=i;this.enterRecursionRule(i,40,MathJSLabParser.RULE_power_expr,e);try{let e;switch(this.enterOuterAlt(i,1),this.state=380,this._errHandler.sync(this),this._input.LA(1)){case 6:case 43:case 56:case 57:case 59:case 61:case 96:case 97:case 125:this.state=369,this.primary_expr(),i.node=i.primary_expr().node;break;case 45:case 46:case 89:case 90:this.state=372,i._op=this._input.LT(1),t=this._input.LA(1),45!==t&&46!==t&&89!==t&&90!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=373,this.power_expr(2),i.node=AST.nodeOp(i._op.text+"_",i.power_expr().node);break;case 54:case 55:this.state=376,i._op=this._input.LT(1),t=this._input.LA(1),54!==t&&55!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=377,this.power_expr(1),i.node=AST.nodeOp(i._op.text,i.power_expr().node);break;default:throw new antlr4_web.X2(this)}for(this._ctx.stop=this._input.LT(-1),this.state=412,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,34,this._ctx);2!==e&&e!==antlr4_web.MG.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),a=i,this.state=410,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,33,this._ctx)){case 1:if(i=new Power_exprContext(this,r,n),this.pushNewRecursionContext(i,40,MathJSLabParser.RULE_power_expr),this.state=382,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=383,i._op=this._input.LT(1),t=this._input.LA(1),89!==t&&90!==t?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),i.node=AST.nodeOp("_"+i._op.text,i.power_expr().node);break;case 2:if(i=new Power_exprContext(this,r,n),this.pushNewRecursionContext(i,40,MathJSLabParser.RULE_power_expr),this.state=385,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=386,this.match(MathJSLabParser.LPAREN),this.state=388,this._errHandler.sync(this),t=this._input.LA(1),(6===t||!(t-43&-32)&&1<<t-43&358541||!(t-89&-32)&&1<<t-89&387||125===t)&&(this.state=387,this.arg_list()),this.state=390,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndexExpr(i.power_expr().node,i.arg_list()?i.arg_list().node:null,"()");break;case 3:if(i=new Power_exprContext(this,r,n),this.pushNewRecursionContext(i,40,MathJSLabParser.RULE_power_expr),this.state=392,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=393,this.match(MathJSLabParser.LCURLYBR),this.state=395,this._errHandler.sync(this),t=this._input.LA(1),(6===t||!(t-43&-32)&&1<<t-43&358541||!(t-89&-32)&&1<<t-89&387||125===t)&&(this.state=394,this.arg_list()),this.state=397,this.match(MathJSLabParser.RCURLYBR),i.node=AST.nodeIndexExpr(i.power_expr().node,i.arg_list()?i.arg_list().node:null,"{}");break;case 4:if(i=new Power_exprContext(this,r,n),this.pushNewRecursionContext(i,40,MathJSLabParser.RULE_power_expr),this.state=399,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=400,this.match(MathJSLabParser.DOT),this.state=401,this.match(MathJSLabParser.IDENTIFIER),i.node=AST.nodeIndirectRef(i.power_expr().node,i.IDENTIFIER().getText());break;case 5:if(i=new Power_exprContext(this,r,n),this.pushNewRecursionContext(i,40,MathJSLabParser.RULE_power_expr),this.state=403,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=404,this.match(MathJSLabParser.DOT),this.state=405,this.match(MathJSLabParser.LPAREN),this.state=406,this.expression(),this.state=407,this.match(MathJSLabParser.RPAREN),i.node=AST.nodeIndirectRef(i.power_expr().node,i.expression().node)}this.state=414,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,34,this._ctx)}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;i.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return i}colon_expr(){let e=new Colon_exprContext(this,this._ctx,this.state);this.enterRule(e,42,MathJSLabParser.RULE_colon_expr);try{this.enterOuterAlt(e,1),this.state=415,this.oper_expr(0),this.state=416,this.match(MathJSLabParser.COLON),this.state=417,this.oper_expr(0),this.state=420,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,35,this._ctx)&&(this.state=418,this.match(MathJSLabParser.COLON),this.state=419,this.oper_expr(0)),e.oper_expr(2)?e.node=AST.nodeRange(e.oper_expr(0).node,e.oper_expr(2).node,e.oper_expr(1).node):e.node=AST.nodeRange(e.oper_expr(0).node,e.oper_expr(1).node)}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}simple_expr(e){void 0===e&&(e=0);let t,r=this._ctx,n=this.state,i=new Simple_exprContext(this,this._ctx,n),a=i;this.enterRecursionRule(i,44,MathJSLabParser.RULE_simple_expr,e);try{let e;switch(this.enterOuterAlt(i,1),this.state=431,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,36,this._ctx)){case 1:this.state=425,this.oper_expr(0),i.node=i.oper_expr().node;break;case 2:this.state=428,this.colon_expr(),i.node=i.colon_expr().node}for(this._ctx.stop=this._input.LT(-1),this.state=460,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,38,this._ctx);2!==e&&e!==antlr4_web.MG.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),a=i,this.state=458,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,37,this._ctx)){case 1:if(i=new Simple_exprContext(this,r,n),this.pushNewRecursionContext(i,44,MathJSLabParser.RULE_simple_expr),this.state=433,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=434,i._op=this._input.LT(1),t=this._input.LA(1),t-80&-32||!(1<<t-80&63)?i._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=435,this.simple_expr(6),i.node=AST.nodeOp(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 2:if(i=new Simple_exprContext(this,r,n),this.pushNewRecursionContext(i,44,MathJSLabParser.RULE_simple_expr),this.state=438,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=439,i._op=this.match(MathJSLabParser.EXPR_AND),this.state=440,this.simple_expr(5),i.node=AST.nodeOp(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 3:if(i=new Simple_exprContext(this,r,n),this.pushNewRecursionContext(i,44,MathJSLabParser.RULE_simple_expr),this.state=443,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=444,i._op=this.match(MathJSLabParser.EXPR_OR),this.state=445,this.simple_expr(4),i.node=AST.nodeOp(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 4:if(i=new Simple_exprContext(this,r,n),this.pushNewRecursionContext(i,44,MathJSLabParser.RULE_simple_expr),this.state=448,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=449,i._op=this.match(MathJSLabParser.EXPR_AND_AND),this.state=450,this.simple_expr(3),i.node=AST.nodeOp(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node);break;case 5:if(i=new Simple_exprContext(this,r,n),this.pushNewRecursionContext(i,44,MathJSLabParser.RULE_simple_expr),this.state=453,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=454,i._op=this.match(MathJSLabParser.EXPR_OR_OR),this.state=455,this.simple_expr(2),i.node=AST.nodeOp(i._op.text,i.simple_expr(0).node,i.simple_expr(1).node)}this.state=462,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,38,this._ctx)}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;i.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return i}expression(){let e,t=new ExpressionContext(this,this._ctx,this.state);this.enterRule(t,46,MathJSLabParser.RULE_expression);try{switch(this.state=474,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,39,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=463,this.simple_expr(0),t.node=t.simple_expr().node;break;case 2:this.enterOuterAlt(t,2),this.state=466,this.simple_expr(0),this.state=467,t._op=this._input.LT(1),e=this._input.LA(1),e-49&-32||!(1<<e-49&134184961)?t._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=468,this.expression(),t.node=AST.nodeOp(t._op.text,t.simple_expr().node,t.expression().node);break;case 3:this.enterOuterAlt(t,3),this.state=471,this.anon_fcn_handle(),t.node=t.anon_fcn_handle().node}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}command(){let e=new CommandContext(this,this._ctx,this.state);this.enterRule(e,48,MathJSLabParser.RULE_command);try{switch(this.state=485,this._errHandler.sync(this),this._input.LA(1)){case 1:case 2:this.enterOuterAlt(e,1),this.state=476,this.declaration(),e.node=e.declaration().node;break;case 3:this.enterOuterAlt(e,2),this.state=479,this.select_command(),e.node=e.select_command().node;break;case 24:this.enterOuterAlt(e,3),this.state=482,this.function_(),e.node=e.function_().node;break;default:throw new antlr4_web.X2(this)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}declaration(){let e,t=new DeclarationContext(this,this._ctx,this.state);this.enterRule(t,50,MathJSLabParser.RULE_declaration);try{switch(this.enterOuterAlt(t,1),this.state=491,this._errHandler.sync(this),this._input.LA(1)){case 1:this.state=487,this.match(MathJSLabParser.GLOBAL),t.node=AST.nodeDeclarationFirst("GLOBAL");break;case 2:this.state=489,this.match(MathJSLabParser.PERSISTENT),t.node=AST.nodeDeclarationFirst("PERSIST");break;default:throw new antlr4_web.X2(this)}this.state=496,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=493,this.declaration_element(),t.node=AST.nodeAppendDeclaration(t.node,t.declaration_element(t.i++)),this.state=498,this._errHandler.sync(this),e=this._input.LA(1)}while(96===e)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}declaration_element(){let e=new Declaration_elementContext(this,this._ctx,this.state);this.enterRule(e,52,MathJSLabParser.RULE_declaration_element);try{switch(this.state=508,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,43,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=500,this.identifier(),e.node=e.identifier().node;break;case 2:this.enterOuterAlt(e,2),this.state=503,this.identifier(),this.state=504,this.match(MathJSLabParser.EQ),this.state=505,this.expression(),e.node=AST.nodeOp("=",e.identifier().node,e.expression().node)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}select_command(){let e=new Select_commandContext(this,this._ctx,this.state);this.enterRule(e,54,MathJSLabParser.RULE_select_command);try{this.enterOuterAlt(e,1),this.state=510,this.if_command(),e.node=e.if_command().node}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}if_command(){let e,t=new If_commandContext(this,this._ctx,this.state);this.enterRule(t,56,MathJSLabParser.RULE_if_command);try{for(this.enterOuterAlt(t,1),this.state=513,this.match(MathJSLabParser.IF),this.state=514,this.expression(),this.state=516,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=515,this.sep()),this.state=519,this._errHandler.sync(this),e=this._input.LA(1),(!(-32&e)&&1<<e&16777294||!(e-43&-32)&&1<<e-43&358413||!(e-89&-32)&&1<<e-89&387||125===e)&&(this.state=518,this.list()),t.node=AST.nodeIfBegin(t.expression().node,t.list()?t.list().node:AST.nodeListFirst()),this.state=527,this._errHandler.sync(this),e=this._input.LA(1);7===e;)this.state=522,this.elseif_clause(),t.node=AST.nodeIfAppendElseIf(t.node,t.elseif_clause(t.i++).node),this.state=529,this._errHandler.sync(this),e=this._input.LA(1);this.state=531,this._errHandler.sync(this),e=this._input.LA(1),8===e&&(this.state=530,this.else_clause()),t.else_clause()&&(t.node=AST.nodeIfAppendElse(t.node,t.else_clause().node)),this.state=534,e=this._input.LA(1),4!==e&&5!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}elseif_clause(){let e,t=new Elseif_clauseContext(this,this._ctx,this.state);this.enterRule(t,58,MathJSLabParser.RULE_elseif_clause);try{this.enterOuterAlt(t,1),this.state=536,this.match(MathJSLabParser.ELSEIF),this.state=538,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=537,this.sep()),this.state=540,this.expression(),this.state=542,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=541,this.sep()),this.state=545,this._errHandler.sync(this),e=this._input.LA(1),(!(-32&e)&&1<<e&16777294||!(e-43&-32)&&1<<e-43&358413||!(e-89&-32)&&1<<e-89&387||125===e)&&(this.state=544,this.list()),t.node=AST.nodeElseIf(t.expression().node,t.list()?t.list().node:AST.nodeListFirst())}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}else_clause(){let e,t=new Else_clauseContext(this,this._ctx,this.state);this.enterRule(t,60,MathJSLabParser.RULE_else_clause);try{this.enterOuterAlt(t,1),this.state=549,this.match(MathJSLabParser.ELSE),this.state=551,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=550,this.sep()),this.state=554,this._errHandler.sync(this),e=this._input.LA(1),(!(-32&e)&&1<<e&16777294||!(e-43&-32)&&1<<e-43&358413||!(e-89&-32)&&1<<e-89&387||125===e)&&(this.state=553,this.list()),t.node=AST.nodeElse(t.list()?t.list().node:AST.nodeListFirst())}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}param_list(){let e,t=new Param_listContext(this,this._ctx,this.state);this.enterRule(t,62,MathJSLabParser.RULE_param_list);try{if(this.enterOuterAlt(t,1),this.state=558,this.match(MathJSLabParser.LPAREN),t.node=AST.nodeListFirst(),this.state=571,this._errHandler.sync(this),e=this._input.LA(1),54===e||96===e)for(this.state=560,this.param_list_elt(),t.node=AST.appendNodeList(t.node,t.param_list_elt(t.i++).node),this.state=568,this._errHandler.sync(this),e=this._input.LA(1);52===e;)this.state=562,this.match(MathJSLabParser.COMMA),this.state=563,this.param_list_elt(),t.node=AST.appendNodeList(t.node,t.param_list_elt(t.i++).node),this.state=570,this._errHandler.sync(this),e=this._input.LA(1);this.state=573,this.match(MathJSLabParser.RPAREN)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}param_list_elt(){let e=new Param_list_eltContext(this,this._ctx,this.state);this.enterRule(e,64,MathJSLabParser.RULE_param_list_elt);try{switch(this.state=581,this._errHandler.sync(this),this._input.LA(1)){case 96:this.enterOuterAlt(e,1),this.state=575,this.declaration_element(),e.node=e.declaration_element().node;break;case 54:this.enterOuterAlt(e,2),this.state=578,this.magic_tilde(),e.node=e.magic_tilde().node;break;default:throw new antlr4_web.X2(this)}}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}return_list(){let e,t=new Return_listContext(this,this._ctx,this.state);this.enterRule(t,66,MathJSLabParser.RULE_return_list);try{switch(this.state=602,this._errHandler.sync(this),this._input.LA(1)){case 96:this.enterOuterAlt(t,1),this.state=583,this.identifier(),t.node=AST.nodeListFirst(t.identifier(0).node);break;case 59:if(this.enterOuterAlt(t,2),this.state=586,this.match(MathJSLabParser.LBRACKET),t.node=AST.nodeListFirst(),this.state=599,this._errHandler.sync(this),e=this._input.LA(1),96===e)for(this.state=588,this.identifier(),t.node=AST.appendNodeList(t.node,t.identifier(t.i++).node),this.state=596,this._errHandler.sync(this),e=this._input.LA(1);52===e;)this.state=590,this.match(MathJSLabParser.COMMA),this.state=591,this.identifier(),t.node=AST.appendNodeList(t.node,t.identifier(t.i++).node),this.state=598,this._errHandler.sync(this),e=this._input.LA(1);this.state=601,this.match(MathJSLabParser.RBRACKET);break;default:throw new antlr4_web.X2(this)}}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}function_(){let e,t=new FunctionContext(this,this._ctx,this.state);this.enterRule(t,68,MathJSLabParser.RULE_function);try{this.enterOuterAlt(t,1),this.state=604,this.match(MathJSLabParser.FUNCTION),this.state=608,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,59,this._ctx)&&(this.state=605,this.return_list(),this.state=606,this.match(MathJSLabParser.EQ)),this.state=610,this.identifier(),this.state=612,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,60,this._ctx)&&(this.state=611,this.param_list()),this.state=615,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=614,this.sep()),this.state=618,this._errHandler.sync(this),e=this._input.LA(1),44===e&&(this.state=617,this.arguments_block_list()),this.state=621,this._errHandler.sync(this),e=this._input.LA(1),(!(-32&e)&&1<<e&16777294||!(e-43&-32)&&1<<e-43&358413||!(e-89&-32)&&1<<e-89&387||125===e)&&(this.state=620,this.list()),this.state=623,e=this._input.LA(1),e- -1&-32||!(1<<e- -1&67108929)?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=AST.nodeFunction(t.identifier().node,t.return_list()?t.return_list().node:AST.nodeListFirst(),t.param_list()?t.param_list().node:AST.nodeListFirst(),t.arguments_block_list()?t.arguments_block_list().node:AST.nodeListFirst(),t.list()?t.list().node:AST.nodeListFirst())}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arguments_block_list(){let e,t=new Arguments_block_listContext(this,this._ctx,this.state);this.enterRule(t,70,MathJSLabParser.RULE_arguments_block_list);try{let r;for(this.enterOuterAlt(t,1),this.state=626,this.arguments_block(),t.node=AST.nodeListFirst(t.arguments_block(t.i++).node),this.state=636,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,65,this._ctx);2!==r&&r!==antlr4_web.MG.INVALID_ALT_NUMBER;)1===r&&(this.state=629,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=628,this.sep()),this.state=631,this.arguments_block(),t.node=AST.appendNodeList(t.node,t.arguments_block(t.i++).node)),this.state=638,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,65,this._ctx);this.state=640,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=639,this.sep())}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arguments_block(){let e,t=new Arguments_blockContext(this,this._ctx,this.state);this.enterRule(t,72,MathJSLabParser.RULE_arguments_block);try{this.enterOuterAlt(t,1),this.state=642,this.match(MathJSLabParser.ARGUMENTS),this.state=644,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=643,this.sep()),this.state=650,this._errHandler.sync(this),e=this._input.LA(1),57===e&&(this.state=646,this.match(MathJSLabParser.LPAREN),this.state=647,this.identifier(),this.state=648,this.match(MathJSLabParser.RPAREN)),this.state=652,this.args_validation_list(),this.state=654,this._errHandler.sync(this),e=this._input.LA(1),51!==e&&52!==e&&100!==e||(this.state=653,this.sep()),this.state=656,this.match(MathJSLabParser.END),t.node=AST.nodeArguments(t.identifier()?t.identifier().node:null,t.args_validation_list().node)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}args_validation_list(){let e=new Args_validation_listContext(this,this._ctx,this.state);this.enterRule(e,74,MathJSLabParser.RULE_args_validation_list);try{let t;for(this.enterOuterAlt(e,1),this.state=659,this.arg_validation(),e.node=AST.nodeListFirst(e.arg_validation(e.i++).node),this.state=667,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,70,this._ctx);2!==t&&t!==antlr4_web.MG.INVALID_ALT_NUMBER;)1===t&&(this.state=661,this.sep(),this.state=662,this.arg_validation(),e.node=AST.appendNodeList(e.node,e.arg_validation(e.i++).node)),this.state=669,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,70,this._ctx)}catch(t){if(!(t instanceof antlr4_web.Dj))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arg_validation(){let e,t=new Arg_validationContext(this,this._ctx,this.state);this.enterRule(t,76,MathJSLabParser.RULE_arg_validation);try{this.enterOuterAlt(t,1),this.state=670,this.identifier(),this.state=675,this._errHandler.sync(this),e=this._input.LA(1),57===e&&(this.state=671,this.match(MathJSLabParser.LPAREN),this.state=672,this.arg_list(),this.state=673,this.match(MathJSLabParser.RPAREN)),this.state=678,this._errHandler.sync(this),e=this._input.LA(1),96===e&&(this.state=677,this.identifier()),this.state=684,this._errHandler.sync(this),e=this._input.LA(1),61===e&&(this.state=680,this.match(MathJSLabParser.LCURLYBR),this.state=681,this.arg_list(),this.state=682,this.match(MathJSLabParser.RCURLYBR)),this.state=688,this._errHandler.sync(this),e=this._input.LA(1),49===e&&(this.state=686,this.match(MathJSLabParser.EQ),this.state=687,this.expression()),t.node=AST.nodeArgumentValidation(t.identifier(0).node,t.LPAREN()?t.arg_list(0).node:AST.nodeListFirst(),t.identifier(1)?t.identifier(1).node:AST.nodeListFirst(),t.LCURLYBR()?t.LPAREN()?t.arg_list(1).node:t.arg_list(0).node:AST.nodeListFirst(),t.expression()?t.expression().node:null)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}sep_no_nl(){let e,t=new Sep_no_nlContext(this,this._ctx,this.state);this.enterRule(t,78,MathJSLabParser.RULE_sep_no_nl);try{this.enterOuterAlt(t,1),this.state=693,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=692,e=this._input.LA(1),51!==e&&52!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=695,this._errHandler.sync(this),e=this._input.LA(1)}while(51===e||52===e)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}nl(){let e,t=new NlContext(this,this._ctx,this.state);this.enterRule(t,80,MathJSLabParser.RULE_nl);try{this.enterOuterAlt(t,1),this.state=698,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=697,this.match(MathJSLabParser.NEWLINE),this.state=700,this._errHandler.sync(this),e=this._input.LA(1)}while(100===e)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}sep(){let e,t=new SepContext(this,this._ctx,this.state);this.enterRule(t,82,MathJSLabParser.RULE_sep);try{this.enterOuterAlt(t,1),this.state=703,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=702,e=this._input.LA(1),51!==e&&52!==e&&100!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=705,this._errHandler.sync(this),e=this._input.LA(1)}while(51===e||52===e||100===e)}catch(e){if(!(e instanceof antlr4_web.Dj))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}sempred(e,t,r){switch(t){case 19:return this.oper_expr_sempred(e,r);case 20:return this.power_expr_sempred(e,r);case 22:return this.simple_expr_sempred(e,r)}return!0}oper_expr_sempred(e,t){switch(t){case 0:return this.precpred(this._ctx,2);case 1:return this.precpred(this._ctx,1);case 2:return this.precpred(this._ctx,11);case 3:return this.precpred(this._ctx,10);case 4:return this.precpred(this._ctx,9);case 5:return this.precpred(this._ctx,8);case 6:return this.precpred(this._ctx,7);case 7:return this.precpred(this._ctx,6);case 8:return this.precpred(this._ctx,5)}return!0}power_expr_sempred(e,t){switch(t){case 9:return this.precpred(this._ctx,7);case 10:return this.precpred(this._ctx,6);case 11:return this.precpred(this._ctx,5);case 12:return this.precpred(this._ctx,4);case 13:return this.precpred(this._ctx,3)}return!0}simple_expr_sempred(e,t){switch(t){case 14:return this.precpred(this._ctx,5);case 15:return this.precpred(this._ctx,4);case 16:return this.precpred(this._ctx,3);case 17:return this.precpred(this._ctx,2);case 18:return this.precpred(this._ctx,1)}return!0}static _serializedATN=[4,1,125,708,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,1,0,3,0,86,8,0,1,0,1,0,1,0,3,0,91,8,0,1,0,1,0,1,0,1,0,3,0,97,8,0,1,1,1,1,1,1,1,1,1,1,1,1,5,1,105,8,1,10,1,12,1,108,9,1,1,1,3,1,111,8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,5,2,121,8,2,10,2,12,2,124,9,2,1,2,3,2,127,8,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,140,8,3,1,4,1,4,1,4,1,4,5,4,146,8,4,10,4,12,4,149,9,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,3,6,160,8,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,3,9,177,8,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,3,10,187,8,10,1,10,1,10,1,10,5,10,192,8,10,10,10,12,10,195,9,10,1,10,3,10,198,8,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,3,10,210,8,10,1,10,1,10,1,10,5,10,215,8,10,10,10,12,10,218,9,10,1,10,3,10,221,8,10,1,10,1,10,3,10,225,8,10,1,11,1,11,1,11,3,11,230,8,11,1,11,1,11,1,11,1,11,1,11,1,11,5,11,238,8,11,10,11,12,11,241,9,11,1,11,3,11,244,8,11,3,11,246,8,11,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,3,14,274,8,14,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,3,17,291,8,17,1,18,1,18,1,18,1,18,1,18,1,18,5,18,299,8,18,10,18,12,18,302,9,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,3,19,316,8,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,3,19,334,8,19,1,19,1,19,1,19,1,19,1,19,3,19,341,8,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,5,19,364,8,19,10,19,12,19,367,9,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,381,8,20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,389,8,20,1,20,1,20,1,20,1,20,1,20,3,20,396,8,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,5,20,411,8,20,10,20,12,20,414,9,20,1,21,1,21,1,21,1,21,1,21,3,21,421,8,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,22,1,22,3,22,432,8,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,5,22,459,8,22,10,22,12,22,462,9,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,475,8,23,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,486,8,24,1,25,1,25,1,25,1,25,3,25,492,8,25,1,25,1,25,1,25,4,25,497,8,25,11,25,12,25,498,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,509,8,26,1,27,1,27,1,27,1,28,1,28,1,28,3,28,517,8,28,1,28,3,28,520,8,28,1,28,1,28,1,28,1,28,5,28,526,8,28,10,28,12,28,529,9,28,1,28,3,28,532,8,28,1,28,1,28,1,28,1,29,1,29,3,29,539,8,29,1,29,1,29,3,29,543,8,29,1,29,3,29,546,8,29,1,29,1,29,1,30,1,30,3,30,552,8,30,1,30,3,30,555,8,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,5,31,567,8,31,10,31,12,31,570,9,31,3,31,572,8,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,3,32,582,8,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,5,33,595,8,33,10,33,12,33,598,9,33,3,33,600,8,33,1,33,3,33,603,8,33,1,34,1,34,1,34,1,34,3,34,609,8,34,1,34,1,34,3,34,613,8,34,1,34,3,34,616,8,34,1,34,3,34,619,8,34,1,34,3,34,622,8,34,1,34,1,34,1,34,1,35,1,35,1,35,3,35,630,8,35,1,35,1,35,1,35,5,35,635,8,35,10,35,12,35,638,9,35,1,35,3,35,641,8,35,1,36,1,36,3,36,645,8,36,1,36,1,36,1,36,1,36,3,36,651,8,36,1,36,1,36,3,36,655,8,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,5,37,666,8,37,10,37,12,37,669,9,37,1,38,1,38,1,38,1,38,1,38,3,38,676,8,38,1,38,3,38,679,8,38,1,38,1,38,1,38,1,38,3,38,685,8,38,1,38,1,38,3,38,689,8,38,1,38,1,38,1,39,4,39,694,8,39,11,39,12,39,695,1,40,4,40,699,8,40,11,40,12,40,700,1,41,4,41,704,8,41,11,41,12,41,705,1,41,0,3,38,40,44,42,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,0,14,2,0,42,42,52,52,2,0,45,46,89,90,1,0,54,55,3,0,47,48,63,63,86,88,1,0,45,46,1,0,89,90,1,0,93,94,1,0,91,92,1,0,80,85,2,0,49,49,64,75,1,0,4,5,2,1,5,5,25,25,1,0,51,52,2,0,51,52,100,100,768,0,96,1,0,0,0,2,98,1,0,0,0,4,114,1,0,0,0,6,139,1,0,0,0,8,141,1,0,0,0,10,152,1,0,0,0,12,159,1,0,0,0,14,161,1,0,0,0,16,164,1,0,0,0,18,176,1,0,0,0,20,224,1,0,0,0,22,245,1,0,0,0,24,247,1,0,0,0,26,251,1,0,0,0,28,273,1,0,0,0,30,275,1,0,0,0,32,278,1,0,0,0,34,290,1,0,0,0,36,292,1,0,0,0,38,315,1,0,0,0,40,380,1,0,0,0,42,415,1,0,0,0,44,431,1,0,0,0,46,474,1,0,0,0,48,485,1,0,0,0,50,491,1,0,0,0,52,508,1,0,0,0,54,510,1,0,0,0,56,513,1,0,0,0,58,536,1,0,0,0,60,549,1,0,0,0,62,558,1,0,0,0,64,581,1,0,0,0,66,602,1,0,0,0,68,604,1,0,0,0,70,626,1,0,0,0,72,642,1,0,0,0,74,659,1,0,0,0,76,670,1,0,0,0,78,693,1,0,0,0,80,698,1,0,0,0,82,703,1,0,0,0,84,86,3,82,41,0,85,84,1,0,0,0,85,86,1,0,0,0,86,87,1,0,0,0,87,88,5,0,0,1,88,97,6,0,-1,0,89,91,3,82,41,0,90,89,1,0,0,0,90,91,1,0,0,0,91,92,1,0,0,0,92,93,3,2,1,0,93,94,5,0,0,1,94,95,6,0,-1,0,95,97,1,0,0,0,96,85,1,0,0,0,96,90,1,0,0,0,97,1,1,0,0,0,98,99,3,6,3,0,99,106,6,1,-1,0,100,101,3,82,41,0,101,102,3,6,3,0,102,103,6,1,-1,0,103,105,1,0,0,0,104,100,1,0,0,0,105,108,1,0,0,0,106,104,1,0,0,0,106,107,1,0,0,0,107,110,1,0,0,0,108,106,1,0,0,0,109,111,3,82,41,0,110,109,1,0,0,0,110,111,1,0,0,0,111,112,1,0,0,0,112,113,6,1,-1,0,113,3,1,0,0,0,114,115,3,6,3,0,115,122,6,2,-1,0,116,117,3,82,41,0,117,118,3,6,3,0,118,119,6,2,-1,0,119,121,1,0,0,0,120,116,1,0,0,0,121,124,1,0,0,0,122,120,1,0,0,0,122,123,1,0,0,0,123,126,1,0,0,0,124,122,1,0,0,0,125,127,3,82,41,0,126,125,1,0,0,0,126,127,1,0,0,0,127,128,1,0,0,0,128,129,6,2,-1,0,129,5,1,0,0,0,130,131,3,46,23,0,131,132,6,3,-1,0,132,140,1,0,0,0,133,134,3,48,24,0,134,135,6,3,-1,0,135,140,1,0,0,0,136,137,3,8,4,0,137,138,6,3,-1,0,138,140,1,0,0,0,139,130,1,0,0,0,139,133,1,0,0,0,139,136,1,0,0,0,140,7,1,0,0,0,141,147,3,10,5,0,142,143,3,12,6,0,143,144,6,4,-1,0,144,146,1,0,0,0,145,142,1,0,0,0,146,149,1,0,0,0,147,145,1,0,0,0,147,148,1,0,0,0,148,150,1,0,0,0,149,147,1,0,0,0,150,151,6,4,-1,0,151,9,1,0,0,0,152,153,5,96,0,0,153,154,6,5,-1,0,154,11,1,0,0,0,155,156,5,43,0,0,156,160,6,6,-1,0,157,158,5,125,0,0,158,160,6,6,-1,0,159,155,1,0,0,0,159,157,1,0,0,0,160,13,1,0,0,0,161,162,5,97,0,0,162,163,6,7,-1,0,163,15,1,0,0,0,164,165,5,6,0,0,165,166,6,8,-1,0,166,17,1,0,0,0,167,168,3,14,7,0,168,169,6,9,-1,0,169,177,1,0,0,0,170,171,3,12,6,0,171,172,6,9,-1,0,172,177,1,0,0,0,173,174,3,16,8,0,174,175,6,9,-1,0,175,177,1,0,0,0,176,167,1,0,0,0,176,170,1,0,0,0,176,173,1,0,0,0,177,19,1,0,0,0,178,179,5,59,0,0,179,180,5,60,0,0,180,225,6,10,-1,0,181,182,5,59,0,0,182,183,3,22,11,0,183,193,6,10,-1,0,184,187,5,51,0,0,185,187,3,80,40,0,186,184,1,0,0,0,186,185,1,0,0,0,187,188,1,0,0,0,188,189,3,22,11,0,189,190,6,10,-1,0,190,192,1,0,0,0,191,186,1,0,0,0,192,195,1,0,0,0,193,191,1,0,0,0,193,194,1,0,0,0,194,197,1,0,0,0,195,193,1,0,0,0,196,198,3,80,40,0,197,196,1,0,0,0,197,198,1,0,0,0,198,199,1,0,0,0,199,200,5,60,0,0,200,225,1,0,0,0,201,202,5,61,0,0,202,203,5,62,0,0,203,225,6,10,-1,0,204,205,5,61,0,0,205,206,3,22,11,0,206,216,6,10,-1,0,207,210,5,51,0,0,208,210,3,80,40,0,209,207,1,0,0,0,209,208,1,0,0,0,210,211,1,0,0,0,211,212,3,22,11,0,212,213,6,10,-1,0,213,215,1,0,0,0,214,209,1,0,0,0,215,218,1,0,0,0,216,214,1,0,0,0,216,217,1,0,0,0,217,220,1,0,0,0,218,216,1,0,0,0,219,221,3,80,40,0,220,219,1,0,0,0,220,221,1,0,0,0,221,222,1,0,0,0,222,223,5,62,0,0,223,225,1,0,0,0,224,178,1,0,0,0,224,181,1,0,0,0,224,201,1,0,0,0,224,204,1,0,0,0,225,21,1,0,0,0,226,227,7,0,0,0,227,246,6,11,-1,0,228,230,7,0,0,0,229,228,1,0,0,0,229,230,1,0,0,0,230,231,1,0,0,0,231,232,3,34,17,0,232,239,6,11,-1,0,233,234,7,0,0,0,234,235,3,34,17,0,235,236,6,11,-1,0,236,238,1,0,0,0,237,233,1,0,0,0,238,241,1,0,0,0,239,237,1,0,0,0,239,240,1,0,0,0,240,243,1,0,0,0,241,239,1,0,0,0,242,244,7,0,0,0,243,242,1,0,0,0,243,244,1,0,0,0,244,246,1,0,0,0,245,226,1,0,0,0,245,229,1,0,0,0,246,23,1,0,0,0,247,248,5,56,0,0,248,249,3,10,5,0,249,250,6,12,-1,0,250,25,1,0,0,0,251,252,5,56,0,0,252,253,3,62,31,0,253,254,3,46,23,0,254,255,6,13,-1,0,255,27,1,0,0,0,256,257,3,10,5,0,257,258,6,14,-1,0,258,274,1,0,0,0,259,260,3,18,9,0,260,261,6,14,-1,0,261,274,1,0,0,0,262,263,3,24,12,0,263,264,6,14,-1,0,264,274,1,0,0,0,265,266,3,20,10,0,266,267,6,14,-1,0,267,274,1,0,0,0,268,269,5,57,0,0,269,270,3,46,23,0,270,271,5,58,0,0,271,272,6,14,-1,0,272,274,1,0,0,0,273,256,1,0,0,0,273,259,1,0,0,0,273,262,1,0,0,0,273,265,1,0,0,0,273,268,1,0,0,0,274,29,1,0,0,0,275,276,5,50,0,0,276,277,6,15,-1,0,277,31,1,0,0,0,278,279,5,54,0,0,279,280,6,16,-1,0,280,33,1,0,0,0,281,282,3,46,23,0,282,283,6,17,-1,0,283,291,1,0,0,0,284,285,3,30,15,0,285,286,6,17,-1,0,286,291,1,0,0,0,287,288,3,32,16,0,288,289,6,17,-1,0,289,291,1,0,0,0,290,281,1,0,0,0,290,284,1,0,0,0,290,287,1,0,0,0,291,35,1,0,0,0,292,293,3,34,17,0,293,300,6,18,-1,0,294,295,5,52,0,0,295,296,3,34,17,0,296,297,6,18,-1,0,297,299,1,0,0,0,298,294,1,0,0,0,299,302,1,0,0,0,300,298,1,0,0,0,300,301,1,0,0,0,301,37,1,0,0,0,302,300,1,0,0,0,303,304,6,19,-1,0,304,305,3,28,14,0,305,306,6,19,-1,0,306,316,1,0,0,0,307,308,7,1,0,0,308,309,3,38,19,4,309,310,6,19,-1,0,310,316,1,0,0,0,311,312,7,2,0,0,312,313,3,38,19,3,313,314,6,19,-1,0,314,316,1,0,0,0,315,303,1,0,0,0,315,307,1,0,0,0,315,311,1,0,0,0,316,365,1,0,0,0,317,318,10,2,0,0,318,319,7,3,0,0,319,320,3,38,19,3,320,321,6,19,-1,0,321,364,1,0,0,0,322,323,10,1,0,0,323,324,7,4,0,0,324,325,3,38,19,2,325,326,6,19,-1,0,326,364,1,0,0,0,327,328,10,11,0,0,328,329,7,5,0,0,329,364,6,19,-1,0,330,331,10,10,0,0,331,333,5,57,0,0,332,334,3,36,18,0,333,332,1,0,0,0,333,334,1,0,0,0,334,335,1,0,0,0,335,336,5,58,0,0,336,364,6,19,-1,0,337,338,10,9,0,0,338,340,5,61,0,0,339,341,3,36,18,0,340,339,1,0,0,0,340,341,1,0,0,0,341,342,1,0,0,0,342,343,5,62,0,0,343,364,6,19,-1,0,344,345,10,8,0,0,345,346,7,6,0,0,346,364,6,19,-1,0,347,348,10,7,0,0,348,349,5,53,0,0,349,350,5,96,0,0,350,364,6,19,-1,0,351,352,10,6,0,0,352,353,5,53,0,0,353,354,5,57,0,0,354,355,3,46,23,0,355,356,5,58,0,0,356,357,6,19,-1,0,357,364,1,0,0,0,358,359,10,5,0,0,359,360,7,7,0,0,360,361,3,40,20,0,361,362,6,19,-1,0,362,364,1,0,0,0,363,317,1,0,0,0,363,322,1,0,0,0,363,327,1,0,0,0,363,330,1,0,0,0,363,337,1,0,0,0,363,344,1,0,0,0,363,347,1,0,0,0,363,351,1,0,0,0,363,358,1,0,0,0,364,367,1,0,0,0,365,363,1,0,0,0,365,366,1,0,0,0,366,39,1,0,0,0,367,365,1,0,0,0,368,369,6,20,-1,0,369,370,3,28,14,0,370,371,6,20,-1,0,371,381,1,0,0,0,372,373,7,1,0,0,373,374,3,40,20,2,374,375,6,20,-1,0,375,381,1,0,0,0,376,377,7,2,0,0,377,378,3,40,20,1,378,379,6,20,-1,0,379,381,1,0,0,0,380,368,1,0,0,0,380,372,1,0,0,0,380,376,1,0,0,0,381,412,1,0,0,0,382,383,10,7,0,0,383,384,7,5,0,0,384,411,6,20,-1,0,385,386,10,6,0,0,386,388,5,57,0,0,387,389,3,36,18,0,388,387,1,0,0,0,388,389,1,0,0,0,389,390,1,0,0,0,390,391,5,58,0,0,391,411,6,20,-1,0,392,393,10,5,0,0,393,395,5,61,0,0,394,396,3,36,18,0,395,394,1,0,0,0,395,396,1,0,0,0,396,397,1,0,0,0,397,398,5,62,0,0,398,411,6,20,-1,0,399,400,10,4,0,0,400,401,5,53,0,0,401,402,5,96,0,0,402,411,6,20,-1,0,403,404,10,3,0,0,404,405,5,53,0,0,405,406,5,57,0,0,406,407,3,46,23,0,407,408,5,58,0,0,408,409,6,20,-1,0,409,411,1,0,0,0,410,382,1,0,0,0,410,385,1,0,0,0,410,392,1,0,0,0,410,399,1,0,0,0,410,403,1,0,0,0,411,414,1,0,0,0,412,410,1,0,0,0,412,413,1,0,0,0,413,41,1,0,0,0,414,412,1,0,0,0,415,416,3,38,19,0,416,417,5,50,0,0,417,420,3,38,19,0,418,419,5,50,0,0,419,421,3,38,19,0,420,418,1,0,0,0,420,421,1,0,0,0,421,422,1,0,0,0,422,423,6,21,-1,0,423,43,1,0,0,0,424,425,6,22,-1,0,425,426,3,38,19,0,426,427,6,22,-1,0,427,432,1,0,0,0,428,429,3,42,21,0,429,430,6,22,-1,0,430,432,1,0,0,0,431,424,1,0,0,0,431,428,1,0,0,0,432,460,1,0,0,0,433,434,10,5,0,0,434,435,7,8,0,0,435,436,3,44,22,6,436,437,6,22,-1,0,437,459,1,0,0,0,438,439,10,4,0,0,439,440,5,78,0,0,440,441,3,44,22,5,441,442,6,22,-1,0,442,459,1,0,0,0,443,444,10,3,0,0,444,445,5,79,0,0,445,446,3,44,22,4,446,447,6,22,-1,0,447,459,1,0,0,0,448,449,10,2,0,0,449,450,5,76,0,0,450,451,3,44,22,3,451,452,6,22,-1,0,452,459,1,0,0,0,453,454,10,1,0,0,454,455,5,77,0,0,455,456,3,44,22,2,456,457,6,22,-1,0,457,459,1,0,0,0,458,433,1,0,0,0,458,438,1,0,0,0,458,443,1,0,0,0,458,448,1,0,0,0,458,453,1,0,0,0,459,462,1,0,0,0,460,458,1,0,0,0,460,461,1,0,0,0,461,45,1,0,0,0,462,460,1,0,0,0,463,464,3,44,22,0,464,465,6,23,-1,0,465,475,1,0,0,0,466,467,3,44,22,0,467,468,7,9,0,0,468,469,3,46,23,0,469,470,6,23,-1,0,470,475,1,0,0,0,471,472,3,26,13,0,472,473,6,23,-1,0,473,475,1,0,0,0,474,463,1,0,0,0,474,466,1,0,0,0,474,471,1,0,0,0,475,47,1,0,0,0,476,477,3,50,25,0,477,478,6,24,-1,0,478,486,1,0,0,0,479,480,3,54,27,0,480,481,6,24,-1,0,481,486,1,0,0,0,482,483,3,68,34,0,483,484,6,24,-1,0,484,486,1,0,0,0,485,476,1,0,0,0,485,479,1,0,0,0,485,482,1,0,0,0,486,49,1,0,0,0,487,488,5,1,0,0,488,492,6,25,-1,0,489,490,5,2,0,0,490,492,6,25,-1,0,491,487,1,0,0,0,491,489,1,0,0,0,492,496,1,0,0,0,493,494,3,52,26,0,494,495,6,25,-1,0,495,497,1,0,0,0,496,493,1,0,0,0,497,498,1,0,0,0,498,496,1,0,0,0,498,499,1,0,0,0,499,51,1,0,0,0,500,501,3,10,5,0,501,502,6,26,-1,0,502,509,1,0,0,0,503,504,3,10,5,0,504,505,5,49,0,0,505,506,3,46,23,0,506,507,6,26,-1,0,507,509,1,0,0,0,508,500,1,0,0,0,508,503,1,0,0,0,509,53,1,0,0,0,510,511,3,56,28,0,511,512,6,27,-1,0,512,55,1,0,0,0,513,514,5,3,0,0,514,516,3,46,23,0,515,517,3,82,41,0,516,515,1,0,0,0,516,517,1,0,0,0,517,519,1,0,0,0,518,520,3,4,2,0,519,518,1,0,0,0,519,520,1,0,0,0,520,521,1,0,0,0,521,527,6,28,-1,0,522,523,3,58,29,0,523,524,6,28,-1,0,524,526,1,0,0,0,525,522,1,0,0,0,526,529,1,0,0,0,527,525,1,0,0,0,527,528,1,0,0,0,528,531,1,0,0,0,529,527,1,0,0,0,530,532,3,60,30,0,531,530,1,0,0,0,531,532,1,0,0,0,532,533,1,0,0,0,533,534,6,28,-1,0,534,535,7,10,0,0,535,57,1,0,0,0,536,538,5,7,0,0,537,539,3,82,41,0,538,537,1,0,0,0,538,539,1,0,0,0,539,540,1,0,0,0,540,542,3,46,23,0,541,543,3,82,41,0,542,541,1,0,0,0,542,543,1,0,0,0,543,545,1,0,0,0,544,546,3,4,2,0,545,544,1,0,0,0,545,546,1,0,0,0,546,547,1,0,0,0,547,548,6,29,-1,0,548,59,1,0,0,0,549,551,5,8,0,0,550,552,3,82,41,0,551,550,1,0,0,0,551,552,1,0,0,0,552,554,1,0,0,0,553,555,3,4,2,0,554,553,1,0,0,0,554,555,1,0,0,0,555,556,1,0,0,0,556,557,6,30,-1,0,557,61,1,0,0,0,558,559,5,57,0,0,559,571,6,31,-1,0,560,561,3,64,32,0,561,568,6,31,-1,0,562,563,5,52,0,0,563,564,3,64,32,0,564,565,6,31,-1,0,565,567,1,0,0,0,566,562,1,0,0,0,567,570,1,0,0,0,568,566,1,0,0,0,568,569,1,0,0,0,569,572,1,0,0,0,570,568,1,0,0,0,571,560,1,0,0,0,571,572,1,0,0,0,572,573,1,0,0,0,573,574,5,58,0,0,574,63,1,0,0,0,575,576,3,52,26,0,576,577,6,32,-1,0,577,582,1,0,0,0,578,579,3,32,16,0,579,580,6,32,-1,0,580,582,1,0,0,0,581,575,1,0,0,0,581,578,1,0,0,0,582,65,1,0,0,0,583,584,3,10,5,0,584,585,6,33,-1,0,585,603,1,0,0,0,586,587,5,59,0,0,587,599,6,33,-1,0,588,589,3,10,5,0,589,596,6,33,-1,0,590,591,5,52,0,0,591,592,3,10,5,0,592,593,6,33,-1,0,593,595,1,0,0,0,594,590,1,0,0,0,595,598,1,0,0,0,596,594,1,0,0,0,596,597,1,0,0,0,597,600,1,0,0,0,598,596,1,0,0,0,599,588,1,0,0,0,599,600,1,0,0,0,600,601,1,0,0,0,601,603,5,60,0,0,602,583,1,0,0,0,602,586,1,0,0,0,603,67,1,0,0,0,604,608,5,24,0,0,605,606,3,66,33,0,606,607,5,49,0,0,607,609,1,0,0,0,608,605,1,0,0,0,608,609,1,0,0,0,609,610,1,0,0,0,610,612,3,10,5,0,611,613,3,62,31,0,612,611,1,0,0,0,612,613,1,0,0,0,613,615,1,0,0,0,614,616,3,82,41,0,615,614,1,0,0,0,615,616,1,0,0,0,616,618,1,0,0,0,617,619,3,70,35,0,618,617,1,0,0,0,618,619,1,0,0,0,619,621,1,0,0,0,620,622,3,4,2,0,621,620,1,0,0,0,621,622,1,0,0,0,622,623,1,0,0,0,623,624,7,11,0,0,624,625,6,34,-1,0,625,69,1,0,0,0,626,627,3,72,36,0,627,636,6,35,-1,0,628,630,3,82,41,0,629,628,1,0,0,0,629,630,1,0,0,0,630,631,1,0,0,0,631,632,3,72,36,0,632,633,6,35,-1,0,633,635,1,0,0,0,634,629,1,0,0,0,635,638,1,0,0,0,636,634,1,0,0,0,636,637,1,0,0,0,637,640,1,0,0,0,638,636,1,0,0,0,639,641,3,82,41,0,640,639,1,0,0,0,640,641,1,0,0,0,641,71,1,0,0,0,642,644,5,44,0,0,643,645,3,82,41,0,644,643,1,0,0,0,644,645,1,0,0,0,645,650,1,0,0,0,646,647,5,57,0,0,647,648,3,10,5,0,648,649,5,58,0,0,649,651,1,0,0,0,650,646,1,0,0,0,650,651,1,0,0,0,651,652,1,0,0,0,652,654,3,74,37,0,653,655,3,82,41,0,654,653,1,0,0,0,654,655,1,0,0,0,655,656,1,0,0,0,656,657,5,5,0,0,657,658,6,36,-1,0,658,73,1,0,0,0,659,660,3,76,38,0,660,667,6,37,-1,0,661,662,3,82,41,0,662,663,3,76,38,0,663,664,6,37,-1,0,664,666,1,0,0,0,665,661,1,0,0,0,666,669,1,0,0,0,667,665,1,0,0,0,667,668,1,0,0,0,668,75,1,0,0,0,669,667,1,0,0,0,670,675,3,10,5,0,671,672,5,57,0,0,672,673,3,36,18,0,673,674,5,58,0,0,674,676,1,0,0,0,675,671,1,0,0,0,675,676,1,0,0,0,676,678,1,0,0,0,677,679,3,10,5,0,678,677,1,0,0,0,678,679,1,0,0,0,679,684,1,0,0,0,680,681,5,61,0,0,681,682,3,36,18,0,682,683,5,62,0,0,683,685,1,0,0,0,684,680,1,0,0,0,684,685,1,0,0,0,685,688,1,0,0,0,686,687,5,49,0,0,687,689,3,46,23,0,688,686,1,0,0,0,688,689,1,0,0,0,689,690,1,0,0,0,690,691,6,38,-1,0,691,77,1,0,0,0,692,694,7,12,0,0,693,692,1,0,0,0,694,695,1,0,0,0,695,693,1,0,0,0,695,696,1,0,0,0,696,79,1,0,0,0,697,699,5,100,0,0,698,697,1,0,0,0,699,700,1,0,0,0,700,698,1,0,0,0,700,701,1,0,0,0,701,81,1,0,0,0,702,704,7,13,0,0,703,702,1,0,0,0,704,705,1,0,0,0,705,703,1,0,0,0,705,706,1,0,0,0,706,83,1,0,0,0,78,85,90,96,106,110,122,126,139,147,159,176,186,193,197,209,216,220,224,229,239,243,245,273,290,300,315,333,340,363,365,380,388,395,410,412,420,431,458,460,474,485,491,498,508,516,519,527,531,538,542,545,551,554,568,571,581,596,599,602,608,612,615,618,621,629,636,640,644,650,654,667,675,678,684,688,695,700,705];static __ATN;static get _ATN(){return MathJSLabParser.__ATN||(MathJSLabParser.__ATN=(new antlr4_web.fr).deserialize(MathJSLabParser._serializedATN)),MathJSLabParser.__ATN}static DecisionsToDFA=MathJSLabParser._ATN.decisionToState.map((e,t)=>new antlr4_web.M8(e,t))}class InputContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}EOF(){return this.getToken(MathJSLabParser.EOF,0)}sep(){return this.getTypedRuleContext(SepContext,0)}global_list(){return this.getTypedRuleContext(Global_listContext,0)}get ruleIndex(){return MathJSLabParser.RULE_input}}class Global_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}statement_list(){return this.getTypedRuleContexts(StatementContext)}statement(e){return this.getTypedRuleContext(StatementContext,e)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}get ruleIndex(){return MathJSLabParser.RULE_global_list}}class ListContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}statement_list(){return this.getTypedRuleContexts(StatementContext)}statement(e){return this.getTypedRuleContext(StatementContext,e)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}get ruleIndex(){return MathJSLabParser.RULE_list}}class StatementContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(ExpressionContext,0)}command(){return this.getTypedRuleContext(CommandContext,0)}word_list_cmd(){return this.getTypedRuleContext(Word_list_cmdContext,0)}get ruleIndex(){return MathJSLabParser.RULE_statement}}class Word_list_cmdContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}string__list(){return this.getTypedRuleContexts(StringContext)}string_(e){return this.getTypedRuleContext(StringContext,e)}get ruleIndex(){return MathJSLabParser.RULE_word_list_cmd}}class IdentifierContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}IDENTIFIER(){return this.getToken(MathJSLabParser.IDENTIFIER,0)}get ruleIndex(){return MathJSLabParser.RULE_identifier}}class StringContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}STRING(){return this.getToken(MathJSLabParser.STRING,0)}UNQUOTED_STRING(){return this.getToken(MathJSLabParser.UNQUOTED_STRING,0)}get ruleIndex(){return MathJSLabParser.RULE_string}}class NumberContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}FLOAT_NUMBER(){return this.getToken(MathJSLabParser.FLOAT_NUMBER,0)}get ruleIndex(){return MathJSLabParser.RULE_number}}class End_rangeContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}ENDRANGE(){return this.getToken(MathJSLabParser.ENDRANGE,0)}get ruleIndex(){return MathJSLabParser.RULE_end_range}}class ConstantContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}number_(){return this.getTypedRuleContext(NumberContext,0)}string_(){return this.getTypedRuleContext(StringContext,0)}end_range(){return this.getTypedRuleContext(End_rangeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_constant}}class MatrixContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}LBRACKET(){return this.getToken(MathJSLabParser.LBRACKET,0)}RBRACKET(){return this.getToken(MathJSLabParser.RBRACKET,0)}matrix_row_list(){return this.getTypedRuleContexts(Matrix_rowContext)}matrix_row(e){return this.getTypedRuleContext(Matrix_rowContext,e)}nl_list(){return this.getTypedRuleContexts(NlContext)}nl(e){return this.getTypedRuleContext(NlContext,e)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(e){return this.getToken(MathJSLabParser.SEMICOLON,e)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}get ruleIndex(){return MathJSLabParser.RULE_matrix}}class Matrix_rowContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}WSPACE_list(){return this.getTokens(MathJSLabParser.WSPACE)}WSPACE(e){return this.getToken(MathJSLabParser.WSPACE,e)}list_element_list(){return this.getTypedRuleContexts(List_elementContext)}list_element(e){return this.getTypedRuleContext(List_elementContext,e)}get ruleIndex(){return MathJSLabParser.RULE_matrix_row}}class Fcn_handleContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}get ruleIndex(){return MathJSLabParser.RULE_fcn_handle}}class Anon_fcn_handleContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}COMMAT(){return this.getToken(MathJSLabParser.COMMAT,0)}param_list(){return this.getTypedRuleContext(Param_listContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_anon_fcn_handle}}class Primary_exprContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}constant(){return this.getTypedRuleContext(ConstantContext,0)}fcn_handle(){return this.getTypedRuleContext(Fcn_handleContext,0)}matrix(){return this.getTypedRuleContext(MatrixContext,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}get ruleIndex(){return MathJSLabParser.RULE_primary_expr}}class Magic_colonContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}COLON(){return this.getToken(MathJSLabParser.COLON,0)}get ruleIndex(){return MathJSLabParser.RULE_magic_colon}}class Magic_tildeContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}get ruleIndex(){return MathJSLabParser.RULE_magic_tilde}}class List_elementContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(ExpressionContext,0)}magic_colon(){return this.getTypedRuleContext(Magic_colonContext,0)}magic_tilde(){return this.getTypedRuleContext(Magic_tildeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_list_element}}class Arg_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}list_element_list(){return this.getTypedRuleContexts(List_elementContext)}list_element(e){return this.getTypedRuleContext(List_elementContext,e)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}get ruleIndex(){return MathJSLabParser.RULE_arg_list}}class Oper_exprContext extends antlr4_web.Pg{node;_op;constructor(e,t,r){super(t,r),this.parser=e}primary_expr(){return this.getTypedRuleContext(Primary_exprContext,0)}oper_expr_list(){return this.getTypedRuleContexts(Oper_exprContext)}oper_expr(e){return this.getTypedRuleContext(Oper_exprContext,e)}PLUS_PLUS(){return this.getToken(MathJSLabParser.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(MathJSLabParser.MINUS_MINUS,0)}PLUS(){return this.getToken(MathJSLabParser.PLUS,0)}MINUS(){return this.getToken(MathJSLabParser.MINUS,0)}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}EXCLAMATION(){return this.getToken(MathJSLabParser.EXCLAMATION,0)}MUL(){return this.getToken(MathJSLabParser.MUL,0)}DIV(){return this.getToken(MathJSLabParser.DIV,0)}LEFTDIV(){return this.getToken(MathJSLabParser.LEFTDIV,0)}EMUL(){return this.getToken(MathJSLabParser.EMUL,0)}EDIV(){return this.getToken(MathJSLabParser.EDIV,0)}ELEFTDIV(){return this.getToken(MathJSLabParser.ELEFTDIV,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}arg_list(){return this.getTypedRuleContext(Arg_listContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}TRANSPOSE(){return this.getToken(MathJSLabParser.TRANSPOSE,0)}HERMITIAN(){return this.getToken(MathJSLabParser.HERMITIAN,0)}DOT(){return this.getToken(MathJSLabParser.DOT,0)}IDENTIFIER(){return this.getToken(MathJSLabParser.IDENTIFIER,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}power_expr(){return this.getTypedRuleContext(Power_exprContext,0)}POW(){return this.getToken(MathJSLabParser.POW,0)}EPOW(){return this.getToken(MathJSLabParser.EPOW,0)}get ruleIndex(){return MathJSLabParser.RULE_oper_expr}}class Power_exprContext extends antlr4_web.Pg{node;_op;constructor(e,t,r){super(t,r),this.parser=e}primary_expr(){return this.getTypedRuleContext(Primary_exprContext,0)}power_expr(){return this.getTypedRuleContext(Power_exprContext,0)}PLUS_PLUS(){return this.getToken(MathJSLabParser.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(MathJSLabParser.MINUS_MINUS,0)}PLUS(){return this.getToken(MathJSLabParser.PLUS,0)}MINUS(){return this.getToken(MathJSLabParser.MINUS,0)}TILDE(){return this.getToken(MathJSLabParser.TILDE,0)}EXCLAMATION(){return this.getToken(MathJSLabParser.EXCLAMATION,0)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}arg_list(){return this.getTypedRuleContext(Arg_listContext,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}DOT(){return this.getToken(MathJSLabParser.DOT,0)}IDENTIFIER(){return this.getToken(MathJSLabParser.IDENTIFIER,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_power_expr}}class Colon_exprContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}oper_expr_list(){return this.getTypedRuleContexts(Oper_exprContext)}oper_expr(e){return this.getTypedRuleContext(Oper_exprContext,e)}COLON_list(){return this.getTokens(MathJSLabParser.COLON)}COLON(e){return this.getToken(MathJSLabParser.COLON,e)}get ruleIndex(){return MathJSLabParser.RULE_colon_expr}}class Simple_exprContext extends antlr4_web.Pg{node;_op;constructor(e,t,r){super(t,r),this.parser=e}oper_expr(){return this.getTypedRuleContext(Oper_exprContext,0)}colon_expr(){return this.getTypedRuleContext(Colon_exprContext,0)}simple_expr_list(){return this.getTypedRuleContexts(Simple_exprContext)}simple_expr(e){return this.getTypedRuleContext(Simple_exprContext,e)}EXPR_LT(){return this.getToken(MathJSLabParser.EXPR_LT,0)}EXPR_LE(){return this.getToken(MathJSLabParser.EXPR_LE,0)}EXPR_GT(){return this.getToken(MathJSLabParser.EXPR_GT,0)}EXPR_GE(){return this.getToken(MathJSLabParser.EXPR_GE,0)}EXPR_EQ(){return this.getToken(MathJSLabParser.EXPR_EQ,0)}EXPR_NE(){return this.getToken(MathJSLabParser.EXPR_NE,0)}EXPR_AND(){return this.getToken(MathJSLabParser.EXPR_AND,0)}EXPR_OR(){return this.getToken(MathJSLabParser.EXPR_OR,0)}EXPR_AND_AND(){return this.getToken(MathJSLabParser.EXPR_AND_AND,0)}EXPR_OR_OR(){return this.getToken(MathJSLabParser.EXPR_OR_OR,0)}get ruleIndex(){return MathJSLabParser.RULE_simple_expr}}class ExpressionContext extends antlr4_web.Pg{node;_op;constructor(e,t,r){super(t,r),this.parser=e}simple_expr(){return this.getTypedRuleContext(Simple_exprContext,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}ADD_EQ(){return this.getToken(MathJSLabParser.ADD_EQ,0)}SUB_EQ(){return this.getToken(MathJSLabParser.SUB_EQ,0)}MUL_EQ(){return this.getToken(MathJSLabParser.MUL_EQ,0)}EMUL_EQ(){return this.getToken(MathJSLabParser.EMUL_EQ,0)}DIV_EQ(){return this.getToken(MathJSLabParser.DIV_EQ,0)}EDIV_EQ(){return this.getToken(MathJSLabParser.EDIV_EQ,0)}LEFTDIV_EQ(){return this.getToken(MathJSLabParser.LEFTDIV_EQ,0)}ELEFTDIV_EQ(){return this.getToken(MathJSLabParser.ELEFTDIV_EQ,0)}POW_EQ(){return this.getToken(MathJSLabParser.POW_EQ,0)}EPOW_EQ(){return this.getToken(MathJSLabParser.EPOW_EQ,0)}AND_EQ(){return this.getToken(MathJSLabParser.AND_EQ,0)}OR_EQ(){return this.getToken(MathJSLabParser.OR_EQ,0)}anon_fcn_handle(){return this.getTypedRuleContext(Anon_fcn_handleContext,0)}get ruleIndex(){return MathJSLabParser.RULE_expression}}class CommandContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}declaration(){return this.getTypedRuleContext(DeclarationContext,0)}select_command(){return this.getTypedRuleContext(Select_commandContext,0)}function_(){return this.getTypedRuleContext(FunctionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_command}}class DeclarationContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}GLOBAL(){return this.getToken(MathJSLabParser.GLOBAL,0)}PERSISTENT(){return this.getToken(MathJSLabParser.PERSISTENT,0)}declaration_element_list(){return this.getTypedRuleContexts(Declaration_elementContext)}declaration_element(e){return this.getTypedRuleContext(Declaration_elementContext,e)}get ruleIndex(){return MathJSLabParser.RULE_declaration}}class Declaration_elementContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_declaration_element}}class Select_commandContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}if_command(){return this.getTypedRuleContext(If_commandContext,0)}get ruleIndex(){return MathJSLabParser.RULE_select_command}}class If_commandContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}IF(){return this.getToken(MathJSLabParser.IF,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDIF(){return this.getToken(MathJSLabParser.ENDIF,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}elseif_clause_list(){return this.getTypedRuleContexts(Elseif_clauseContext)}elseif_clause(e){return this.getTypedRuleContext(Elseif_clauseContext,e)}else_clause(){return this.getTypedRuleContext(Else_clauseContext,0)}get ruleIndex(){return MathJSLabParser.RULE_if_command}}class Elseif_clauseContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}ELSEIF(){return this.getToken(MathJSLabParser.ELSEIF,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_elseif_clause}}class Else_clauseContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}ELSE(){return this.getToken(MathJSLabParser.ELSE,0)}sep(){return this.getTypedRuleContext(SepContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_else_clause}}class Param_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}param_list_elt_list(){return this.getTypedRuleContexts(Param_list_eltContext)}param_list_elt(e){return this.getTypedRuleContext(Param_list_eltContext,e)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}get ruleIndex(){return MathJSLabParser.RULE_param_list}}class Param_list_eltContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}declaration_element(){return this.getTypedRuleContext(Declaration_elementContext,0)}magic_tilde(){return this.getTypedRuleContext(Magic_tildeContext,0)}get ruleIndex(){return MathJSLabParser.RULE_param_list_elt}}class Return_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(IdentifierContext)}identifier(e){return this.getTypedRuleContext(IdentifierContext,e)}LBRACKET(){return this.getToken(MathJSLabParser.LBRACKET,0)}RBRACKET(){return this.getToken(MathJSLabParser.RBRACKET,0)}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}get ruleIndex(){return MathJSLabParser.RULE_return_list}}class FunctionContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}FUNCTION(){return this.getToken(MathJSLabParser.FUNCTION,0)}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}ENDFUNCTION(){return this.getToken(MathJSLabParser.ENDFUNCTION,0)}EOF(){return this.getToken(MathJSLabParser.EOF,0)}return_list(){return this.getTypedRuleContext(Return_listContext,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}param_list(){return this.getTypedRuleContext(Param_listContext,0)}sep(){return this.getTypedRuleContext(SepContext,0)}arguments_block_list(){return this.getTypedRuleContext(Arguments_block_listContext,0)}list(){return this.getTypedRuleContext(ListContext,0)}get ruleIndex(){return MathJSLabParser.RULE_function}}class Arguments_block_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}arguments_block_list(){return this.getTypedRuleContexts(Arguments_blockContext)}arguments_block(e){return this.getTypedRuleContext(Arguments_blockContext,e)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}get ruleIndex(){return MathJSLabParser.RULE_arguments_block_list}}class Arguments_blockContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}ARGUMENTS(){return this.getToken(MathJSLabParser.ARGUMENTS,0)}args_validation_list(){return this.getTypedRuleContext(Args_validation_listContext,0)}END(){return this.getToken(MathJSLabParser.END,0)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}identifier(){return this.getTypedRuleContext(IdentifierContext,0)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}get ruleIndex(){return MathJSLabParser.RULE_arguments_block}}class Args_validation_listContext extends antlr4_web.Pg{node;i=0;constructor(e,t,r){super(t,r),this.parser=e}arg_validation_list(){return this.getTypedRuleContexts(Arg_validationContext)}arg_validation(e){return this.getTypedRuleContext(Arg_validationContext,e)}sep_list(){return this.getTypedRuleContexts(SepContext)}sep(e){return this.getTypedRuleContext(SepContext,e)}get ruleIndex(){return MathJSLabParser.RULE_args_validation_list}}class Arg_validationContext extends antlr4_web.Pg{node;constructor(e,t,r){super(t,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(IdentifierContext)}identifier(e){return this.getTypedRuleContext(IdentifierContext,e)}LPAREN(){return this.getToken(MathJSLabParser.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(Arg_listContext)}arg_list(e){return this.getTypedRuleContext(Arg_listContext,e)}RPAREN(){return this.getToken(MathJSLabParser.RPAREN,0)}LCURLYBR(){return this.getToken(MathJSLabParser.LCURLYBR,0)}RCURLYBR(){return this.getToken(MathJSLabParser.RCURLYBR,0)}EQ(){return this.getToken(MathJSLabParser.EQ,0)}expression(){return this.getTypedRuleContext(ExpressionContext,0)}get ruleIndex(){return MathJSLabParser.RULE_arg_validation}}class Sep_no_nlContext extends antlr4_web.Pg{constructor(e,t,r){super(t,r),this.parser=e}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(e){return this.getToken(MathJSLabParser.SEMICOLON,e)}get ruleIndex(){return MathJSLabParser.RULE_sep_no_nl}}class NlContext extends antlr4_web.Pg{constructor(e,t,r){super(t,r),this.parser=e}NEWLINE_list(){return this.getTokens(MathJSLabParser.NEWLINE)}NEWLINE(e){return this.getToken(MathJSLabParser.NEWLINE,e)}get ruleIndex(){return MathJSLabParser.RULE_nl}}class SepContext extends antlr4_web.Pg{constructor(e,t,r){super(t,r),this.parser=e}COMMA_list(){return this.getTokens(MathJSLabParser.COMMA)}COMMA(e){return this.getToken(MathJSLabParser.COMMA,e)}SEMICOLON_list(){return this.getTokens(MathJSLabParser.SEMICOLON)}SEMICOLON(e){return this.getToken(MathJSLabParser.SEMICOLON,e)}NEWLINE_list(){return this.getTokens(MathJSLabParser.NEWLINE)}NEWLINE(e){return this.getToken(MathJSLabParser.NEWLINE,e)}get ruleIndex(){return MathJSLabParser.RULE_sep}}class LexerErrorListener extends antlr4_web.pG{syntaxError(e,t,r,n,i,a){if("mismatched input '' expecting {';', SP}"!==i&&"missing ';' at ''"!==i&&"mismatched input '' expecting "!==i)throw new SyntaxError(`${i} (${r}:${n})`)}}const src_LexerErrorListener={LexerErrorListener};class ParserErrorListener extends antlr4_web.pG{syntaxError(e,t,r,n,i,a){if("mismatched input '' expecting {';', SP}"!==i&&"missing ';' at ''"!==i&&"mismatched input '' expecting"!==i)throw new SyntaxError(`${i} (${r}:${n})`)}}const src_ParserErrorListener={ParserErrorListener};function substSymbol(e){const t=["alpha","beta","gamma","delta","epsilon","zeta","eta","theta","iota","kappa","lambda","mu","nu","xi","omicron","pi","rho","sigma","tau","upsilon","phi","chi","psi","omega"],r=[["alfa","alpha"],["Alfa","Alpha"],["gama","gamma"],["Gama","Gamma"],["épsilon","epsilon"],["Épsilon","Epsilon"],["dzeta","zeta"],["Dzeta","Zeta"],["teta","theta"],["Teta","Theta"],["capa","kappa"],["Capa","Kappa"],["kapa","kappa"],["Kapa","Kappa"],["mi","mu"],["Mi","Mu"],["ni","nu"],["Ni","Nu"],["csi","xi"],["Csi","Xi"],["ksi","xi"],["Ksi","Xi"],["ômicron","omicron"],["Ômicron","Omicron"],["ómicron","omicron"],["Ómicron","Omicron"],["ro","rho"],["Ro","Rho"],["rô","rho"],["Rô","Rho"],["úpsilon","upsilon"],["Úpsilon","Upsilon"],["ipsilon","upsilon"],["Ipsilon","Upsilon"],["ípsilon","upsilon"],["Ípsilon","Upsilon"],["ypsilon","upsilon"],["Ypsilon","Upsilon"],["ýpsilon","upsilon"],["Ýpsilon","Upsilon"],["fi","phi"],["Fi","Phi"],["qui","chi"],["Qui","Chi"],["ômega","omega"],["Ômega","Omega"]];let n;for(let t=0;t<r.length;t++)n=new RegExp("([^a-zA-Z0-9])("+r[t][0]+")(?![a-zA-Z0-9;])","g"),e=e.replace(n,"$1"+r[t][1]),n=new RegExp("^("+r[t][0]+")(?![a-zA-Z0-9;])","g"),e=e.replace(n,r[t][1]);for(let r=0;r<t.length;r++)n=new RegExp("([^a-zA-Z0-9])(["+t[r][0]+t[r][0].toUpperCase()+"]"+t[r].substring(1)+")(?![a-zA-Z0-9;])","g"),e=e.replace(n,"$1&$2;"),n=new RegExp("^(["+t[r][0]+t[r][0].toUpperCase()+"]"+t[r].substring(1)+")(?![a-zA-Z0-9;])","g"),e=e.replace(n,"&$1;");return e.replace(/^[Ii]nf$/,"&infin;").replace(/^NaN$|^nan$/,"<b>NaN</b>")}const src_substSymbol={substSymbol};class CoreFunctions{static throwErrorIfCellArray=(e,t)=>{if(MultiArray.isInstanceOf(t)&&t.isCell)throw new Error(`${e}: wrong type argument 'cell'`)};static isempty=(e,...t)=>(AST.throwInvalidCallError("isempty",!(void 0!==e&&0===t.length)),MultiArray.isEmpty(e)?Complex.true():Complex.false());static isscalar=(e,...t)=>(AST.throwInvalidCallError("isscalar",!(void 0!==e&&0===t.length)),MultiArray.isScalar(e)?Complex.true():Complex.false());static ismatrix=(e,...t)=>(AST.throwInvalidCallError("ismatrix",!(void 0!==e&&0===t.length)),MultiArray.isMatrix(e)?Complex.true():Complex.false());static isvector=(e,...t)=>(AST.throwInvalidCallError("isvector",!(void 0!==e&&0===t.length)),MultiArray.isVector(e)?Complex.true():Complex.false());static iscell=(e,...t)=>(AST.throwInvalidCallError("iscell",!(void 0!==e&&0===t.length)),MultiArray.isCellArray(e)?Complex.true():Complex.false());static isrow=(e,...t)=>(AST.throwInvalidCallError("isrow",!(void 0!==e&&0===t.length)),MultiArray.isRowVector(e)?Complex.true():Complex.false());static iscolumn=(e,...t)=>(AST.throwInvalidCallError("iscolumn",!(void 0!==e&&0===t.length)),MultiArray.isColumnVector(e)?Complex.true():Complex.false());static isstruct=(e,...t)=>(AST.throwInvalidCallError("isstruct",!(void 0!==e&&0===t.length)),Structure.isStructure(e)?Complex.true():Complex.false());static ndims=(e,...t)=>(AST.throwInvalidCallError("ndims",!(void 0!==e&&0===t.length)),Complex.create(MultiArray.scalarToMultiArray(e).dimension.length));static rows=(e,...t)=>(AST.throwInvalidCallError("rows",!(void 0!==e&&0===t.length)),Complex.create(MultiArray.scalarToMultiArray(e).dimension[0]));static columns=(e,...t)=>(AST.throwInvalidCallError("columns",!(void 0!==e&&0===t.length)),Complex.create(MultiArray.scalarToMultiArray(e).dimension[1]));static Length=(e,...t)=>(AST.throwInvalidCallError("length",!(void 0!==e&&0===t.length)),Complex.create(Math.max(...MultiArray.scalarToMultiArray(e).dimension)));static numel=(e,...t)=>{if(0===t.length)return MultiArray.isInstanceOf(e)?Complex.create(MultiArray.linearLength(e)):Complex.one();{const r=MultiArray.scalarToMultiArray(e),n=t.map((e,t)=>MultiArray.isInstanceOf(e)?MultiArray.linearLength(e):CharString.isInstanceOf(e)&&":"===e.str&&t<r.dimension.length?r.dimension[t]:1);return Complex.create(n.reduce((e,t)=>e*t,1))}};static ind2sub=(e,t)=>(AST.throwInvalidCallError("ind2sub",!(void 0!==e&&void 0!==t)),AST.nodeReturnList((r,n)=>{if(1===r.length)return t;{let i=MultiArray.linearize(e).map(e=>Complex.realToNumber(e)),a=!1;r.length>i.length?(MultiArray.appendSingletonTail(i,r.length),a=!0):i=i.slice(0,r.length-1);const s=MultiArray.scalarToMultiArray(t),o=new MultiArray(s.dimension),l=s.array.map(e=>e.map(e=>MultiArray.ind2subNumber(i,Complex.realToNumber(e))));return n===r.length-1&&a?o.array=l.map(e=>e.map(e=>Complex.create(e[r.length]))):o.array=l.map(e=>e.map(e=>Complex.create(e[n]))),o.type=Complex.REAL,MultiArray.MultiArrayToScalar(o)}}));static sub2ind=(e,...t)=>{AST.throwInvalidCallError("sub2ind",t.length<1);const r=MultiArray.linearize(e).map(e=>Complex.realToNumber(e)),n=t.map(e=>MultiArray.scalarToMultiArray(e));for(let e=1;e<n.length;e++)if(!MultiArray.arrayEquals(n[0].dimension,n[e].dimension))throw new Error("sub2ind: all subscripts must be of the same size.");MultiArray.appendSingletonTail(r,n.length);const i=new MultiArray(n[0].dimension);for(let e=0;e<MultiArray.linearLength(n[0]);e++){const t=n.map(t=>{const[r,n]=MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);return t.array[r][n]}),a=MultiArray.parseSubscript(r,t,"index "),[s,o]=MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e);i.array[s][o]=Complex.create(a+1)}return MultiArray.MultiArrayToScalar(i)};static size=(e,...t)=>{AST.throwInvalidCallError("size",!(void 0!==e));const r=e=>{const t=Complex.realToNumber(e);if(t<1||!Complex.realIsInteger(e))throw new Error(`size: requested dimension DIM (= ${t}) out of range. DIM must be a positive integer.`);return t},n=MultiArray.isInstanceOf(e)?e.dimension.slice():[1,1];if(0===t.length){const e=new MultiArray([1,n.length]);return e.array[0]=n.map(e=>Complex.create(e)),e.type=Complex.REAL,e}{const e=1===t.length&&MultiArray.isInstanceOf(t[0])?MultiArray.linearize(t[0]).map(e=>r(e)):t.map(e=>r(MultiArray.firstElement(e)));MultiArray.appendSingletonTail(n,Math.max(...e));const i=new MultiArray([1,e.length]);return i.array[0]=e.map(e=>Complex.create(n[e-1])),i.type=Complex.REAL,MultiArray.MultiArrayToScalar(i)}};static colon=(...e)=>2===e.length?MultiArray.expandRange(MultiArray.firstElement(e[0]),MultiArray.firstElement(e[1])):3===e.length?MultiArray.expandRange(MultiArray.firstElement(e[0]),MultiArray.firstElement(e[2]),MultiArray.firstElement(e[1])):void AST.throwInvalidCallError("colon");static linspace=(...e)=>{let t=[],r=[],n=Complex.one();const i=()=>{const n="linspace: START, END must be scalars or vectors.";if(MultiArray.isInstanceOf(e[0])){if(!MultiArray.isVector(e[0]))throw new Error(n);t=MultiArray.linearize(e[0])}else t=[e[0]];if(MultiArray.isInstanceOf(e[1])){if(!MultiArray.isVector(e[1]))throw new Error(n);r=MultiArray.linearize(e[1])}else r=[e[1]]};if(2===e.length)i(),n=Complex.create(100);else if(3===e.length){if(i(),n=MultiArray.MultiArrayToScalar(e[2]),MultiArray.isInstanceOf(n))throw new Error("linspace: N must be a scalar.")}else AST.throwInvalidCallError("linspace");if(t.length!==r.length)throw new Error("linspace: vectors must be of equal length");Complex.realApply(n,Complex.applyFunction.floor),Complex.realIsNegative(n)&&Complex.realSet(n,0),Complex.imagSet(n,0);const a=new MultiArray([t.length,Complex.realToNumber(n)]);for(let e=0;e<t.length;e++){const i=Complex.rdiv(Complex.sub(r[e],t[e]),Complex.sub(n,Complex.one()));a.array[e][0]=t[e];for(let r=1;r<Complex.realToNumber(n)-1;r++)a.array[e][r]=Complex.add(t[e],Complex.mul(Complex.create(r),i));a.array[e][Complex.realToNumber(n)-1]=r[e]}return MultiArray.MultiArrayToScalar(a)};static logspace=(...e)=>{let t=[],r=[],n=Complex.one();const i=()=>{const n="logspace: START, END must be scalars or vectors.";if(MultiArray.isInstanceOf(e[0])){if(!MultiArray.isVector(e[0]))throw new Error(n);t=MultiArray.linearize(e[0])}else t=[e[0]];if(MultiArray.isInstanceOf(e[1])){if(!MultiArray.isVector(e[1]))throw new Error(n);r=MultiArray.linearize(e[1])}else r=[e[1]]};if(2===e.length)i(),n=Complex.create(50);else if(3===e.length){if(i(),n=MultiArray.MultiArrayToScalar(e[2]),MultiArray.isInstanceOf(n))throw new Error("logspace: N must be a scalar.")}else AST.throwInvalidCallError("linspace");if(t.length!==r.length)throw new Error("logspace: vectors must be of equal length");Complex.realApply(n,Complex.applyFunction.floor),Complex.realIsNegative(n)&&Complex.realSet(n,0),Complex.imagSet(n,0);const a=new MultiArray([t.length,Complex.realToNumber(n)]);for(let e=0;e<t.length;e++){Complex.realToNumber(Complex.eq(r[e],Complex.pi()))&&(r[e]=Complex.log10(Complex.pi()));const i=Complex.rdiv(Complex.sub(r[e],t[e]),Complex.sub(n,Complex.one()));a.array[e][0]=Complex.power(Complex.create(10),t[e]);for(let r=1;r<Complex.realToNumber(n)-1;r++)a.array[e][r]=Complex.power(Complex.create(10),Complex.add(t[e],Complex.mul(Complex.create(r),i)));a.array[e][Complex.realToNumber(n)-1]=Complex.power(Complex.create(10),r[e])}return MultiArray.MultiArrayToScalar(a)};static meshgrid=(...e)=>{AST.throwInvalidCallError("meshgrid",e.length>3||e.length<1);const t=[];for(let r=0;r<3&&e.length>r;r++)if(MultiArray.isInstanceOf(e[r])){if(!MultiArray.isVector(e[r]))throw new Error("meshgrid: arguments must be vectors.");t[r]=MultiArray.firstVector(e[r])}else t[r]=[e[r]];return AST.nodeReturnList((e,r)=>{if(e.length>3)throw new Error("meshgrid: function called with too many outputs.");const n=t;for(;n.length<e.length;)n[n.length]=n[n.length-1];const i=e.length>2?new MultiArray([n[1].length,n[0].length,n[2].length]):new MultiArray([n[1].length,n[0].length]);switch(r){case 0:for(let e=0;e<i.array.length;e++)i.array[e]=n[0];case 1:for(let e=0;e<i.array.length;e+=i.dimension[0])for(let t=0;t<i.dimension[0];t++)i.array[e+t]=new Array(i.dimension[1]).fill(n[1][t]);case 2:for(let e=0,t=0;e<i.array.length;e+=i.dimension[0],t++)for(let r=0;r<i.dimension[0];r++)i.array[e+r]=new Array(i.dimension[1]).fill(n[2][t])}return MultiArray.MultiArrayToScalar(i)})};static ndgrid=(...e)=>{const t=[];for(let r=0;r<e.length;r++)if(MultiArray.isInstanceOf(e[r])){if(!MultiArray.isVector(e[r]))throw new Error("ndgrid: arguments must be vectors.");t[r]=e[r]}else t[r]=MultiArray.scalarToMultiArray(e[r]);return AST.nodeReturnList((e,r)=>{const n=t;if(1===n.length)for(;n.length<e.length;)n[n.length]=n[n.length-1];if(e.length>n.length)throw new Error("ndgrid: function called with too many outputs.");const i=n.map(e=>e.dimension[0]*e.dimension[1]),a=new Array(n.length).fill(1);return a[r]=i[r],i[r]=1,MultiArray.evaluate(new MultiArray(i,MultiArray.reshape(n[r],a)))})};static repmat=(e,...t)=>{let r;if(1===t.length)r=MultiArray.firstVector(t[0]);else{const e=new Array(t.length);if(r=t.map((t,r)=>{const n=MultiArray.MultiArrayToScalar(t);return e[r]=MultiArray.isInstanceOf(n)?1:0,n}),e.reduce((e,t)=>e+t,0))throw new Error("repmat: all input arguments must be scalar.")}return MultiArray.evaluate(new MultiArray(r.map(e=>Complex.realToNumber(e)),e))};static reshape=(e,...t)=>{if(t.length<1)throw new Error("invalid call to reshape");const r=MultiArray.scalarToMultiArray(e);let n=-1;1===t.length&&MultiArray.isInstanceOf(t[0])&&(t=MultiArray.linearize(t[0]));const i=t.map((e,t)=>{if(MultiArray.isEmpty(e)){if(n<0)return n=t,1;throw new Error("reshape: only a single dimension can be unknown.")}return Complex.realToNumber(MultiArray.firstElement(e))});return MultiArray.reshape(r,i,n)};static squeeze=(...e)=>(AST.throwInvalidCallError("squeeze",1!==e.length),MultiArray.isInstanceOf(e[0])&&!e[0].isCell&&e[0].dimension.length>2?MultiArray.reshape(e[0],e[0].dimension.filter(e=>1!==e)):e[0]);static newFilled=(e,t,...r)=>{let n;if(0===r.length)return e;if(1===r.length){const e=MultiArray.scalarToMultiArray(r[0]);if(e.dimension.length>2||1!==e.dimension[0])throw new Error(`${t} (A): use ${t} (size (A)) instead.`);n=e.array[0].map(e=>Complex.realToNumber(e)),1===n.length&&(n[n.length]=n[0])}else n=r.map(e=>{if(MultiArray.isInstanceOf(e))throw new Error(`${t}: dimensions must be scalars.`);return Complex.realToNumber(e)});return MultiArray.MultiArrayToScalar(new MultiArray(n,e))};static newFilledEach=(e,...t)=>{let r;if(1===t.length)r=MultiArray.linearize(t[0]).map(e=>Complex.realToNumber(e));else{if(0===t.length)return e(0);r=t.map(e=>Complex.realToNumber(MultiArray.firstElement(e)))}1===r.length&&(r[r.length]=r[0]);const n=new MultiArray(r);for(let t=0;t<MultiArray.linearLength(n);t++){const[r,i]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[r][i]=e(t)}return MultiArray.setType(n),MultiArray.MultiArrayToScalar(n)};static zeros=(...e)=>CoreFunctions.newFilled(Complex.zero(),"zeros",...e);static ones=(...e)=>CoreFunctions.newFilled(Complex.one(),"ones",...e);static rand=(...e)=>CoreFunctions.newFilledEach(()=>Complex.random(),...e);static randi=(e,...t)=>{let r,n;if(MultiArray.isInstanceOf(e)){const t=MultiArray.linearize(e);if(t.length>1)r=t[0],n=t[1];else{if(!(t.length>0))throw new Error("bounds(1): out of bound 0 (dimensions are 0x0)");r=Complex.zero(),n=t[0]}}else r=Complex.zero(),n=e;if(!Complex.realIsInteger(r)||!Complex.realIsInteger(n))throw new Error("randi: must be integer bounds.");if(Complex.gt(n,r))return CoreFunctions.newFilledEach(Complex.realEquals(r,0)?()=>Complex.round(Complex.mul(n,Complex.random())):()=>Complex.round(Complex.add(Complex.mul(Complex.sub(n,r),Complex.random()),r)),...t);throw Complex.realEquals(r,0)?new Error("randi: require imax >= 1."):new Error("randi: require imax > imin.")};static cat=(e,...t)=>MultiArray.concatenate(Complex.realToNumber(MultiArray.firstElement(e))-1,"cat",...t.map(e=>MultiArray.scalarToMultiArray(e)));static horzcat=(...e)=>MultiArray.concatenate(1,"horzcat",...e.map(e=>MultiArray.scalarToMultiArray(e)));static vertcat=(...e)=>MultiArray.concatenate(0,"vertcat",...e.map(e=>MultiArray.scalarToMultiArray(e)));static all=MultiArray.reduceFactory((e,t)=>Complex.and(e,t),"reduce",Complex.one());static any=MultiArray.reduceFactory((e,t)=>Complex.or(e,t),"reduce",Complex.zero());static sum=MultiArray.reduceFactory((e,t)=>Complex.add(e,t),"reduce",Complex.zero());static prod=MultiArray.reduceFactory((e,t)=>Complex.mul(e,t),"reduce",Complex.one());static sumsq=MultiArray.reduceFactory((e,t)=>Complex.add(e,Complex.mul(t,t)),"reduce",Complex.zero());static cumsum=MultiArray.reduceFactory((e,t)=>Complex.add(e,t),"cumulative");static cumprod=MultiArray.reduceFactory((e,t)=>Complex.mul(e,t),"cumulative");static min=MultiArray.reduceFactory("lt","comparison");static max=MultiArray.reduceFactory("gt","comparison");static cummin=MultiArray.reduceFactory("lt","cumcomparison");static cummax=MultiArray.reduceFactory("gt","cumcomparison");static mean=(e,t)=>{const r=MultiArray.scalarToMultiArray(e),n=void 0!==t?Complex.realToNumber(MultiArray.firstElement(t))-1:MultiArray.firstNonSingleDimension(r),i=CoreFunctions.sum(r,Complex.create(n+1)),a=Complex.create(r.dimension[n]);return MultiArray.divideElementByScalar(i,a)};static variance=(e,t,r)=>{const n=MultiArray.scalarToMultiArray(e);let i,a=0;if(void 0!==t){const e=MultiArray.firstElement(t);if(Complex.realIsInteger(e)&&Complex.realToNumber(e)>=1&&void 0===r)i=Complex.realToNumber(e)-1;else if(a=1===Complex.realToNumber(e)?1:0,void 0!==r){const e=MultiArray.firstElement(r);i=MultiArray.testInteger(e,"var","DIM",[1,1/0])-1}else i=MultiArray.firstNonSingleDimension(n)}else if(void 0!==r){const e=MultiArray.firstElement(r);i=MultiArray.testInteger(e,"var","DIM",[1,1/0])-1}else i=MultiArray.firstNonSingleDimension(n);const s=n.dimension[i];if(s<=1)return Complex.zero();const o=MultiArray.reduce(i,n,(e,t)=>Complex.add(e,t),Complex.zero()),l=MultiArray.divideElementByScalar(o,Complex.create(s));let c;MultiArray.isInstanceOf(o)?c=o.dimension.slice():(c=n.dimension.slice(),c[i]=1);const u=new MultiArray(c),m=c.length>2?c.slice(2).reduce((e,t)=>e*t,1):1,h=c[0]*Math.max(1,m),p=c[1]??1;u.array=new Array(h);for(let e=0;e<h;e++)u.array[e]=new Array(p);const d=n.dimension.reduce((e,t)=>e*t,1);for(let e=0;e<d;e++){const t=MultiArray.linearIndexToSubscript(n.dimension,e).slice();let r;if(t[i]=1,MultiArray.isInstanceOf(l)){const e=l,n=MultiArray.subscriptToLinearIndex(e.dimension,t),[i,a]=MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n);r=e.array[i][a]}else r=l;const[a,s]=MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e),o=n.array[a][s],m=Complex.sub(o,r),h=Complex.mul(m,m),p=MultiArray.subscriptToLinearIndex(c,t),[d,x]=MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],p),C=u.array[d][x];u.array[d][x]=null==C?Complex.copy(h):Complex.add(C,h)}const x=Complex.create(s-(0===a?1:0)),C=MultiArray.divideElementByScalar(u,x);return MultiArray.isInstanceOf(C)&&MultiArray.setType(C),C};static std=(e,t,r)=>{const n=CoreFunctions.variance(e,t,r);if(MultiArray.isInstanceOf(n)){const e=MultiArray.rawMap(n,e=>Complex.sqrt(e));return MultiArray.setType(e),e}return Complex.sqrt(n)};static struct=(...e)=>{const t='struct: additional arguments must occur as "field", VALUE pairs';if(0===e.length)return new Structure({});if(1===e.length){if(MultiArray.isInstanceOf(e[0])&&MultiArray.isEmpty(e[0]))return MultiArray.emptyArray();if(Structure.isInstanceOf(e[0]))return e[0].copy();throw new Error(t)}{if(e.length%2!=0)throw new Error(t);const r={};for(let n=0;n<e.length;n+=2){if(!CharString.isInstanceOf(e[n]))throw new Error(t);r[e[n].str]=e[n+1]}return new Structure(r)}};static norm=(...e)=>{if(1===e.length)return null;if(2===e.length){if(MultiArray.isInstanceOf(e[0])&&CharString.isInstanceOf(e[1])&&"fro"===e[1].str){const t=e[0];let r=Complex.zero();const n=t.dimension[0],i=t.dimension[1],a=t.array;for(let e=0;e<n;e++){const t=a[e];for(let e=0;e<i;e++){const n=t[e],i=Complex.abs(n);Complex.realToNumber(i),r=Complex.add(r,Complex.mul(i,i))}}return Complex.sqrt(r)}return null}AST.throwInvalidCallError("norm")};static functions={isempty:CoreFunctions.isempty,isscalar:CoreFunctions.isscalar,ismatrix:CoreFunctions.ismatrix,isvector:CoreFunctions.isvector,iscell:CoreFunctions.iscell,isrow:CoreFunctions.isrow,iscolumn:CoreFunctions.iscolumn,isstruct:CoreFunctions.isstruct,ndims:CoreFunctions.ndims,rows:CoreFunctions.rows,columns:CoreFunctions.columns,length:CoreFunctions.Length,numel:CoreFunctions.numel,ind2sub:CoreFunctions.ind2sub,sub2ind:CoreFunctions.sub2ind,size:CoreFunctions.size,colon:CoreFunctions.colon,linspace:CoreFunctions.linspace,logspace:CoreFunctions.logspace,meshgrid:CoreFunctions.meshgrid,ndgrid:CoreFunctions.ndgrid,repmat:CoreFunctions.repmat,reshape:CoreFunctions.reshape,squeeze:CoreFunctions.squeeze,zeros:CoreFunctions.zeros,ones:CoreFunctions.ones,rand:CoreFunctions.rand,randi:CoreFunctions.randi,cat:CoreFunctions.cat,horzcat:CoreFunctions.horzcat,vertcat:CoreFunctions.vertcat,all:CoreFunctions.all,any:CoreFunctions.any,sum:CoreFunctions.sum,prod:CoreFunctions.prod,sumsq:CoreFunctions.sumsq,max:CoreFunctions.max,min:CoreFunctions.min,mean:CoreFunctions.mean,cumsum:CoreFunctions.cumsum,cumprod:CoreFunctions.cumprod,cummin:CoreFunctions.cummin,cummax:CoreFunctions.cummax,var:CoreFunctions.variance,std:CoreFunctions.std,struct:CoreFunctions.struct}}const src_CoreFunctions={CoreFunctions};class Configuration{static roundingName=roundingName;static moduloName=moduloName;static configuration={blockThreshold:{set:e=>BLAS.set({blockThreshold:MultiArray.testInteger(e,"configure","blockThreshold configuration parameter")}),setDefault:()=>BLAS.set({blockThreshold:BLAS.defaultSettings.blockThreshold}),get:()=>Complex.create(BLAS.settings.blockThreshold)},blockSize:{set:e=>BLAS.set({blockSize:MultiArray.testInteger(e,"configure","blockSize configuration parameter")}),setDefault:()=>BLAS.set({blockSize:BLAS.defaultSettings.blockSize}),get:()=>Complex.create(BLAS.settings.blockSize)},real:{set:e=>Complex.engine=e.str,setDefault:()=>Complex.engine="decimal",get:()=>new CharString(Complex.engine)},precision:{set:e=>Complex.set({precision:Complex.realToNumber(e)}),setDefault:()=>Complex.set({precision:Complex.defaultSettings.precision}),get:()=>Complex.create(Complex.settings.precision)},precisionCompare:{set:e=>Complex.set({precisionCompare:Complex.realToNumber(e)}),setDefault:()=>Complex.set({precisionCompare:Complex.defaultSettings.precisionCompare}),get:()=>Complex.create(Complex.settings.precisionCompare)},rounding:{set:e=>{const t=Configuration.roundingName.indexOf(e.str);if(!(t>0))throw new Error(`configure: invalid rounding mode: ${e.str}`);Complex.set({rounding:t})},setDefault:()=>Complex.set({rounding:Complex.defaultSettings.rounding}),get:()=>new CharString(Configuration.roundingName[Complex.settings.rounding])},toExpPos:{set:e=>Complex.set({toExpPos:Complex.realToNumber(e)}),setDefault:()=>Complex.set({toExpPos:Complex.defaultSettings.toExpPos}),get:()=>Complex.create(Complex.settings.toExpPos)},toExpNeg:{set:e=>Complex.set({toExpNeg:Complex.realToNumber(e)}),setDefault:()=>Complex.set({toExpNeg:Complex.defaultSettings.toExpNeg}),get:()=>Complex.create(Complex.settings.toExpNeg)},minE:{set:e=>Complex.set({minE:Complex.realToNumber(e)}),setDefault:()=>Complex.set({minE:Complex.defaultSettings.minE}),get:()=>Complex.create(Complex.settings.minE)},maxE:{set:e=>Complex.set({maxE:Complex.realToNumber(e)}),setDefault:()=>Complex.set({maxE:Complex.defaultSettings.maxE}),get:()=>Complex.create(Complex.settings.maxE)},modulo:{set:e=>{const t=Configuration.moduloName.indexOf(e.str);if(!(t>0))throw new Error(`configure: invalid modulo mode: ${e.str}`);Complex.set({modulo:t})},setDefault:()=>Complex.set({modulo:Complex.defaultSettings.modulo}),get:()=>new CharString(Configuration.moduloName[Complex.settings.modulo])},crypto:{set:e=>Complex.set({crypto:Boolean(Complex.realToNumber(e))}),setDefault:()=>Complex.set({crypto:Complex.defaultSettings.crypto}),get:()=>Complex.create(Number(Complex.settings.crypto),0,Complex.LOGICAL)}};static configure(...e){const t=e=>{if(CharString.isInstanceOf(e[0])){if(!(e[0].str in Configuration.configuration))throw new ReferenceError(`configure: invalid configuration: '${e[0].str}'.`);Configuration.configuration[e[0].str].set(e[1])}else AST.throwInvalidCallError("configure")};if(0===e.length){for(const e in Configuration.configuration)Configuration.configuration[e].setDefault();return new CharString("All configuration set to default values.")}if(1===e.length&&MultiArray.isInstanceOf(e[0])){if(2===e[0].dimension[1])return e[0].array.forEach(e=>{t(e)}),new CharString(`${e[0].array.length} configuration values set.`);AST.throwInvalidCallError("configure")}else{if(2===e.length&&CharString.isInstanceOf(e[0]))return t(e),new CharString(`Configuration parameter '${e[0].str}' set to '${Configuration.configuration[e[0].str].get().toString()}'`);AST.throwInvalidCallError("configure")}}static getconfig(...e){let t;const r=Object.keys(Configuration.configuration),n=e=>{e.forEach((e,r)=>{const n=Configuration.configuration[e].get();t.array[r]=[new CharString(e),n]})};if(0===e.length)return t=new MultiArray([r.length,2],null,!0),n(r),t;if(1===e.length){const r=MultiArray.linearize(MultiArray.scalarToMultiArray(e[0])).map(e=>{if(CharString.isInstanceOf(e)&&e.str in Configuration.configuration)return e.str;throw new Error("getconfig: invalid configuration parameter.")});return t=new MultiArray([r.length,2],null,!0),n(r),t}AST.throwInvalidCallError("getconfig")}static functions={configure:Configuration.configure,getconfig:Configuration.getconfig}}const src_Configuration={Configuration};class MathML{static format={"+":(e,t)=>e+'<mo form="infix" stretchy="true">+</mo>'+t,"-":(e,t)=>e+'<mo form="infix" stretchy="true">-</mo>'+t,".*":(e,t)=>e+'<mo form="infix" stretchy="true">.*</mo>'+t,"./":(e,t)=>e+'<mo form="infix" stretchy="true">./</mo>'+t,".\\":(e,t)=>e+'<mo form="infix" stretchy="true">.\\</mo>'+t,"\\":(e,t)=>e+'<mo form="infix" stretchy="true">\\</mo>'+t,".^":(e,t)=>e+'<mo form="infix" stretchy="true">.^</mo>'+t,".**":(e,t)=>e+'<mo form="infix" stretchy="true">.**</mo>'+t,"<":(e,t)=>e+'<mo form="infix" stretchy="true">&lt;</mo>'+t,"<=":(e,t)=>e+'<mo form="infix" stretchy="true">&le;</mo>'+t,">":(e,t)=>e+'<mo form="infix" stretchy="true">&gt;</mo>'+t,">=":(e,t)=>e+'<mo form="infix" stretchy="true">&ge;</mo>'+t,"==":(e,t)=>e+'<mo form="infix" stretchy="true">==</mo>'+t,"!=":(e,t)=>e+'<mo form="infix" stretchy="true">&ne;</mo>'+t,"~=":(e,t)=>e+'<mo form="infix" stretchy="true">&ne;</mo>'+t,"&":(e,t)=>e+'<mo form="infix" stretchy="true">&amp;</mo>'+t,"|":(e,t)=>e+'<mo form="infix" stretchy="true">|</mo>'+t,"&&":(e,t)=>e+'<mo form="infix" stretchy="true">&amp;&amp;</mo>'+t,"||":(e,t)=>e+'<mo form="infix" stretchy="true">||</mo>'+t,"=":(e,t)=>e+'<mo form="infix" stretchy="true">=</mo>'+t,"+=":(e,t)=>e+'<mo form="infix" stretchy="true">+=</mo>'+t,"-=":(e,t)=>e+'<mo form="infix" stretchy="true">-=</mo>'+t,"*=":(e,t)=>e+'<mo form="infix" stretchy="true">*=</mo>'+t,"/=":(e,t)=>e+'<mo form="infix" stretchy="true">/=</mo>'+t,"\\=":(e,t)=>e+'<mo form="infix" stretchy="true">\\=</mo>'+t,"^=":(e,t)=>e+'<mo form="infix" stretchy="true">^=</mo>'+t,"**=":(e,t)=>e+'<mo form="infix" stretchy="true">**=</mo>'+t,".*=":(e,t)=>e+'<mo form="infix" stretchy="true">.*=</mo>'+t,"./=":(e,t)=>e+'<mo form="infix" stretchy="true">./=</mo>'+t,".\\=":(e,t)=>e+'<mo form="infix" stretchy="true">.\\=</mo>'+t,".^=":(e,t)=>e+'<mo form="infix" stretchy="true">.^=</mo>'+t,".**=":(e,t)=>e+'<mo form="infix" stretchy="true">.**=</mo>'+t,"&=":(e,t)=>e+'<mo form="infix" stretchy="true">&amp;=</mo>'+t,"|=":(e,t)=>e+'<mo form="infix" stretchy="true">|=</mo>'+t,"*":(e,t)=>e+'<mo form="infix" stretchy="true">&times;</mo>'+t,"+_":e=>'<mo form="prefix" stretchy="true">+</mo>'+e,"-_":e=>'<mo form="prefix" stretchy="true">-</mo>'+e,"++_":e=>'<mo form="prefix" stretchy="true">++</mo>'+e,"--_":e=>'<mo form="prefix" stretchy="true">--</mo>'+e,"_++":e=>e+'<mo form="postfix" stretchy="true">++</mo>',"_--":e=>e+'<mo form="postfix" stretchy="true">--</mo>',"!":e=>'<mo form="prefix" stretchy="true">!</mo>'+e,"~":e=>'<mo form="prefix" stretchy="true">~</mo>'+e,"/":(e,t)=>"<mfrac><mrow>"+e+"</mrow><mrow>"+t+"</mrow></mfrac>","^":(e,t)=>"<msup><mrow>"+e+"</mrow><mrow>"+t+"</mrow></msup>","**":(e,t)=>"<msup><mrow>"+e+"</mrow><mrow>"+t+"</mrow></msup>",".'":e=>"<msup><mrow>"+e+"</mrow><mrow><mi>T</mi></mrow></msup>","'":e=>"<msup><mrow>"+e+"</mrow><mrow><mi>H</mi></mrow></msup>","()":(e,t,r)=>'<mo fence="true" stretchy="true">'+e+"</mo>"+t+'<mo fence="true" stretchy="true">'+r+"</mo>",IDENT:e=>"<mi>"+e+"</mi>",".":(e,t)=>e+"<mo>.</mo>"+t.join("<mo>.</mo>"),LIST:e=>"<mtable>"+e.map(e=>"<mtr><mtd>"+e+"</mtd></mtr>").join("")+"</mtable>",RANGE:(...e)=>e.length?e.join("<mo>:</mo>"):"<mo>:</mo>",ENDRANGE:()=>"<mi>end</mi>",":":()=>"<mo>:</mo>","<~>":()=>"<mo>~</mo>",IDX:(e,t,r,n)=>e+'<mrow><mo fence="true" stretchy="true">'+t+"</mo>"+r.join("<mo>,</mo>")+'<mo fence="true" stretchy="true">'+n+"</mo></mrow>",RETLIST:()=>"<mi>RETLIST</mi>",CMDWLIST:(e,t)=>"<mrow><mtext>"+e+"</mtext> "+t.join(" ")+"</mrow>",INVALID:()=>"<mi>invalid</mi>",UNDEFINED:()=>"<mi>undefined tree</mi>",ERROR:()=>"<mi>error</mi>",math:(e,t)=>'<math xmlns = "http://www.w3.org/1998/Math/MathML" display="'+t+'">'+e+"</math>",errorReplace:e=>e.replace(/\<mo\>\(\<\/mo\>\<mi\>error\<\/mi\><\mi\>error\<\/mi\>\<mi\>i\<\/mi\>\<mo\>\)\<\/mo\>/gi,"<mi>error</mi>"),abs:(...e)=>'<mrow><mo fence="true" stretchy="true">|</mo>'+e[0]+'<mo fence="true" stretchy="true">|</mo></mrow>',conj:(...e)=>'<mover accent="true"><mrow>'+e[0]+'</mrow><mo stretchy="true">‾</mo></mover>',sqrt:(...e)=>"<msqrt><mrow>"+e[0]+"</mrow></msqrt>",root:(...e)=>"<mroot><mrow>"+e[0]+"</mrow><mrow>"+e[1]+"</mrow></mroot>",exp:(...e)=>"<msup><mi>e</mi><mrow>"+e[0]+"</mrow></msup>",logb:(...e)=>"<mrow><msub><mi>log</mi><mrow>"+e[0]+"</mrow></msub><mrow>"+e[1]+"</mrow></mrow>",log2:(...e)=>"<mrow><msub><mi>log</mi><mrow><mn>2</mn></mrow></msub><mrow>"+e[0]+"</mrow></mrow>",log10:(...e)=>"<mrow><msub><mi>log</mi><mrow><mn>10</mn></mrow></msub><mrow>"+e[0]+"</mrow></mrow>",gamma:(...e)=>'<mi>&Gamma;</mi><mrow><mo fence="true" stretchy="true">(</mo>'+e[0]+'<mo fence="true" stretchy="true">)</mo></mrow>',factorial:(...e)=>"<mrow>"+e[0]+'</mrow><mo format="postfix" stretchy="true">!</mo>'}}const format=MathML.format,src_MathML={format,MathML};class Evaluator{static response={EXTERNAL:-2,WARNING:-1,OK:0,LEX_ERROR:1,PARSER_ERROR:2,EVAL_ERROR:3};_debug=!1;get debug(){return this._debug}set debug(e){this._debug=e}nativeNameTable;_nativeNameTableList;get nativeNameTableList(){return this._nativeNameTableList}aliasNameTable;_nameTable={};get nameTable(){return this._nameTable}undefinedReferenceTable={};builtInFunctionTable={};get builtInFunctionList(){return Object.keys(this.builtInFunctionTable)}_localTable={};get localTable(){return this._localTable}commandWordListTable={clear:{func:(...e)=>this.Clear(...e)},__operators__:{func:(...e)=>{const t=Object.keys(this.opTable).sort(),r=new MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new CharString(e)]),r}},__keywords__:{func:(...e)=>{const t=MathJSLabLexer.A.keywordNames.slice(1).sort(),r=new MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new CharString(e)]),r}},__builtins__:{func:(...e)=>{const t=new MultiArray([this.builtInFunctionList.length,1],null,!0);return t.array=this.builtInFunctionList.sort().map(e=>[new CharString(e)]),t}},__list_functions__:{func:(...e)=>MultiArray.emptyArray(!0)},localfunctions:{func:(...e)=>MultiArray.emptyArray(!0)},__dump_symtab_info__:{func:(...e)=>MultiArray.emptyArray(!0)}};_exitStatus;get exitStatus(){return this._exitStatus}incDecOpFactory(e,t){return e?e=>{if("IDENT"===e.type){if(void 0!==this._nameTable[e.id])return this._nameTable[e.id].node=MathOperation[t](this._nameTable[e.id].node,Complex.one()),this._nameTable[e.id].node;throw new EvalError(`in ${"plus"===t?"++":"--"}${e.id}, ${e.id} must be defined first.`)}throw new SyntaxError(`invalid prefixed ${"plus"===t?"increment":"decrement"} variable.`)}:e=>{if("IDENT"===e.type){if(void 0!==this._nameTable[e.id]){const r=MathOperation.copy(this._nameTable[e.id].node);return this._nameTable[e.id].node=MathOperation[t](this._nameTable[e.id].node,Complex.one()),r}throw new EvalError(`in ${e.id}${"plus"===t?"++":"--"}, ${e.id} must be defined first.`)}throw new SyntaxError(`invalid postfixed ${"plus"===t?"increment":"decrement"} variable.`)}}opTable={"+":MathOperation.plus,"-":MathOperation.minus,".*":MathOperation.times,"*":MathOperation.mtimes,"./":MathOperation.rdivide,"/":MathOperation.mrdivide,".\\":MathOperation.ldivide,"\\":MathOperation.mldivide,".^":MathOperation.power,"^":MathOperation.mpower,"+_":MathOperation.uplus,"-_":MathOperation.uminus,".'":MathOperation.transpose,"'":MathOperation.ctranspose,"<":MathOperation.lt,"<=":MathOperation.le,"==":MathOperation.eq,">=":MathOperation.ge,">":MathOperation.gt,"!=":MathOperation.ne,"&":MathOperation.and,"|":MathOperation.or,"!":MathOperation.not,"&&":MathOperation.mand,"||":MathOperation.mor,"++_":this.incDecOpFactory(!0,"plus"),"--_":this.incDecOpFactory(!0,"minus"),"_++":this.incDecOpFactory(!1,"plus"),"_--":this.incDecOpFactory(!1,"minus")};static precedence=[["min","=","+=","-=","*=","/=","\\="],["||"],["&&"],["|"],["&"],["!=","<",">","<=",">="],["+","-"],[".*","*","./","/",".\\","\\"],["^",".**","**",".'","'"],["!","~","-_","+_"],["preMax","_.^","_.**","_^","_**","__.'","__'","__++"],["max","()","IDENT","ENDRANGE",":","<~>","."]];_precedenceTable;get precedenceTable(){return this._precedenceTable}loadPrecedenceTable(){this._precedenceTable={},Evaluator.precedence.forEach((e,t)=>{e.forEach(e=>{this._precedenceTable[e]=t+1})}),this._precedenceTable["**"]=this._precedenceTable["^"],this._precedenceTable[".**"]=this._precedenceTable[".^"],this._precedenceTable["_**"]=this._precedenceTable["_^"],this._precedenceTable["_.**"]=this._precedenceTable["_.^"],this._precedenceTable["~="]=this._precedenceTable["!="],this._precedenceTable["~"]=this._precedenceTable["!"]}nodePrecedence(e){if("number"==typeof e.type)return Complex.isInstanceOf(e)?Complex.precedence(e,this):this._precedenceTable.max;if("IDX"===e.type){const t=this._aliasNameFunction(e.expr.id);return"IDENT"===e.expr.type&&t in this.builtInFunctionTable&&(this.builtInFunctionTable[t].UnparserMathML||t in MathML.format)?this._precedenceTable.max:this._precedenceTable.preMax}return"RANGE"===e.type?e.start_&&e.stop_?this._precedenceTable.min:this._precedenceTable.max:this._precedenceTable[e.type]||0}functions={unparse:e=>new CharString(this.Unparse(e))};unparseMathMLFunctions={logb:e=>{let t=this.UnparserMathML(e.args[1]);return this.nodePrecedence(e.args[1])<this._precedenceTable.max&&(t=MathML.format["()"]("(",t,")")),MathML.format.logb(this.UnparserMathML(e.args[0]),t)},log2:e=>{let t=this.UnparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this._precedenceTable.max&&(t=MathML.format["()"]("(",t,")")),MathML.format.log2(t)},log10:e=>{let t=this.UnparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this._precedenceTable.max&&(t=MathML.format["()"]("(",t,")")),MathML.format.log10(t)},factorial:e=>{let t=this.UnparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this._precedenceTable.max&&(t=MathML.format["()"]("(",t,")")),MathML.format.factorial(t)}};_aliasNameFunction=e=>e;set aliasNameFunction(e){this._aliasNameFunction=e}get aliasNameFunction(){return this._aliasNameFunction}loadEvaluator(e){this._exitStatus=Evaluator.response.OK,this._nameTable={},this.undefinedReferenceTable={},this._localTable={},this.loadNativeNameTable(),AST.reload();for(const e in this.functions)this.defineFunction(e,this.functions[e]);for(const e in MathOperation.leftAssociativeMultipleOperations)this.defineLeftAssociativeMultipleOperationFunction(e,MathOperation.leftAssociativeMultipleOperations[e]);for(const e in MathOperation.binaryOperations)this.defineBinaryOperatorFunction(e,MathOperation.binaryOperations[e]);for(const e in MathOperation.unaryOperations)this.defineUnaryOperatorFunction(e,MathOperation.unaryOperations[e]);for(const e in Complex.mapFunction)this.defineFunction(e,Complex.mapFunction[e],!0);for(const e in Complex.twoArgFunction)this.defineFunction(e,Complex.twoArgFunction[e]);for(const e in Configuration.functions)this.defineFunction(e,Configuration.functions[e]);for(const e in CoreFunctions.functions)this.defineFunction(e,CoreFunctions.functions[e]);for(const e in LinearAlgebra.functions)this.defineFunction(e,LinearAlgebra.functions[e]);for(const e in this.unparseMathMLFunctions)this.builtInFunctionTable[e].UnparserMathML=this.unparseMathMLFunctions[e];e?(e.aliasNameTable?(this.aliasNameTable=e.aliasNameTable,this._aliasNameFunction=e=>{let t=!1,r="";for(const n in this.aliasNameTable)if(this.aliasNameTable[n].test(e)){t=!0,r=n;break}return t?r:e}):this._aliasNameFunction=e=>e,e.externalFunctionTable&&Object.assign(this.builtInFunctionTable,e.externalFunctionTable),e.externalCmdWListTable&&Object.assign(this.commandWordListTable,e.externalCmdWListTable)):this._aliasNameFunction=e=>e}constructor(e){this.opTable["**"]=this.opTable["^"],this.opTable[".**"]=this.opTable[".^"],this.opTable["~="]=this.opTable["!="],this.opTable["~"]=this.opTable["!"],this.loadPrecedenceTable(),this.loadEvaluator(e)}static Create=e=>new Evaluator(e);Parse(e){const t=antlr4_web.iH.fromString(e),r=new MathJSLabLexer.A(t);r.commandNames=Object.keys(this.commandWordListTable);const n=new antlr4_web.jB(r),i=new MathJSLabParser(n);return i.buildParseTrees=!0,r.removeErrorListeners(),r.addErrorListener(new LexerErrorListener),i.removeErrorListeners(),i.addErrorListener(new ParserErrorListener),this._debug,i.input().node}loadNativeNameTable(){this.nativeNameTable={false:Complex.false(),true:Complex.true(),i:Complex.onei(),I:Complex.onei(),j:Complex.onei(),J:Complex.onei(),e:Complex.e(),pi:Complex.pi(),inf:Complex.inf_0(),Inf:Complex.inf_0(),nan:Complex.NaN_0(),NaN:Complex.NaN_0()},this._nativeNameTableList=Object.keys(this.nativeNameTable);for(const e in this.nativeNameTable)this._nameTable[e]={node:this.nativeNameTable[e]}}Restart(){this.loadEvaluator()}Clear(...e){0===e.length?this.Restart():e.forEach(e=>{delete this._nameTable[e],delete this.builtInFunctionTable[e],this._nativeNameTableList.includes(e)&&(this._nameTable[e]={node:this.nativeNameTable[e]})})}validateAssignment(e,t,r,n){const i="invalid left hand side of assignment";if("IDENT"===e.type)return[{id:e.id,index:[],field:[]}];if("IDX"===e.type&&"IDENT"===e.expr.type)return[{id:e.expr.id,index:e.args,field:[]}];if("."===e.type){const t=e.field.map(e=>{if("string"==typeof e)return e;{const t=AST.reduceToFirstIfReturnList(this.Evaluator(e,r,n));if(CharString.isInstanceOf(t))return t.str;throw new EvalError(`${i}: dynamic structure field names must be strings.`)}});if("IDENT"===e.obj.type)return[{id:e.obj.id,index:[],field:t}];if("IDX"===e.obj.type&&"IDENT"===e.obj.expr.type)return[{id:e.obj.expr.id,index:e.obj.args,field:t}];throw new EvalError(`${i}.`)}if("<~>"===e.type)return[{id:"~",index:[],field:[]}];if(t&&MultiArray.isRowVector(e))return e.array[0].map(e=>this.validateAssignment(e,!1,r,n)[0]);throw new EvalError(`${i}.`)}defineFunction(e,t,r=!1,n=[]){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:r,ev:n,func:t}}defineUnaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(...r)=>{if(1===r.length)return t(r[0]);throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}defineBinaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(r,...n)=>{if(1===n.length)return t(r,n[0]);throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}defineLeftAssociativeMultipleOperationFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(r,...n)=>{if(1===n.length)return t(r,n[0]);if(n.length>1){let e=t(r,n[0]);for(let r=1;r<n.length;r++)e=t(e,n[r]);return e}throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}toBoolean(e){const t=MultiArray.isInstanceOf(e)?MultiArray.toLogical(e):e;return Complex.isInstanceOf(e)?Boolean(Complex.realToNumber(t)||Complex.imagToNumber(t)):!!t.str}solveUndefined(e){if(void 0!==this.undefinedReferenceTable[e]){this.undefinedReferenceTable[e]=this.undefinedReferenceTable[e].filter((e,t,r)=>e&&r.indexOf(e)===t);let t=this.undefinedReferenceTable[e].slice();const r=[];this.undefinedReferenceTable[e].forEach((e,n)=>{if(void 0!==this._nameTable[e])try{this._nameTable[e].node=AST.reduceToFirstIfReturnList(this.Evaluator(this._nameTable[e].node)),delete this._nameTable[e].undefined,t[n]=void 0,r.push(e)}catch(r){if(r instanceof ReferenceError){const i=r.message.match(/^'([^']+)'\s+undefined\.?$/);i&&(t[n]=i[1],this._nameTable[e].undefined=i[1])}}else t[n]=void 0}),this.undefinedReferenceTable[e]=t.filter(e=>e),r.forEach(e=>this.solveUndefined(e))}}Evaluator(e,t=!1,r=""){if(this._debug&&console.log(`Evaluator(\ntree:${JSON.stringify(e,(e,t)=>"parent"!==e?t:null!==t||"root",2)},\nlocal:${t},\nfname:${r});`),!e)return null;if(Complex.isInstanceOf(e)||FunctionHandle.isInstanceOf(e)||CharString.isInstanceOf(e)||Structure.isInstanceOf(e))return e;if(MultiArray.isInstanceOf(e))return MultiArray.evaluate(e,this,t,r);switch(e.type){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":return e.left.parent=e,e.right.parent=e,this.opTable[e.type](AST.reduceToFirstIfReturnList(this.Evaluator(e.left,t,r)),AST.reduceToFirstIfReturnList(this.Evaluator(e.right,t,r)));case"()":return e.right.parent=e,AST.reduceToFirstIfReturnList(this.Evaluator(e.right,t,r));case"!":case"~":case"+_":case"-_":return e.right.parent=e,this.opTable[e.type](AST.reduceToFirstIfReturnList(this.Evaluator(e.right,t,r)));case"++_":case"--_":return e.right.parent=e,this.opTable[e.type](e.right);case".'":case"'":return e.left.parent=e,this.opTable[e.type](AST.reduceToFirstIfReturnList(this.Evaluator(e.left,t,r)));case"_++":case"_--":return e.left.parent=e,this.opTable[e.type](e.left);case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{e.left.parent=e,e.right.parent=e;const n=this.validateAssignment(e.left,!0,t,r),i=e.type.substring(0,e.type.length-1);if(n.length>1&&i.length>0)throw new EvalError("computed multiple assignment not allowed.");let a,s,o;try{a=this.Evaluator(e.right,!1,r)}catch(t){if(o=t,a=e.right,t instanceof ReferenceError){const e=t.message.match(/^'([^']+)'\s+undefined\.?$/);e&&(s=e[1])}}if("RETLIST"!==a.type){const e=a;a=AST.nodeReturnList((t,r)=>{if(0===r)return e;AST.throwErrorIfGreaterThanReturnList(t.length,r)})}const l=AST.nodeListFirst(),c=a.handler(n.length);for(let u=0;u<n.length;u++){const{id:m,index:h,field:p}=n[u];if("~"!==m)if(0===h.length){const t=a.selector(c,u);t.parent=e.right;const r=i.length?void 0!==o?AST.nodeOp(i,AST.nodeIdentifier(m),t):this.Evaluator(AST.nodeOp(i,AST.nodeIdentifier(m),t)):t;try{if(p.length>0){if(void 0===this._nameTable[m]&&(this._nameTable[m]={node:new Structure({})}),!Structure.isInstanceOf(this._nameTable[m].node))throw new EvalError("in indexed assignment.");Structure.setNewField(this._nameTable[m].node,p,AST.reduceToFirstIfReturnList(r)),AST.appendNodeList(l,AST.nodeOp("=",AST.nodeIdentifier(m),this._nameTable[m].node))}else if(s?(void 0!==this.undefinedReferenceTable[s]?this.undefinedReferenceTable[s].push(m):this.undefinedReferenceTable[s]=[m],this._nameTable[m]={undefined:s,node:AST.reduceToFirstIfReturnList(r)}):this._nameTable[m]={node:AST.reduceToFirstIfReturnList(r)},this.solveUndefined(m),AST.appendNodeList(l,AST.nodeOp("=",AST.nodeIdentifier(m),this._nameTable[m].node)),o)throw o}catch(e){throw this._nameTable[m]={node:r},e}}else{if(i){if(void 0!==this._nameTable[m]){if(FunctionHandle.isInstanceOf(this._nameTable[m].node))throw new EvalError("can't perform indexed assignment for function handle type.");if(1===h.length){const e=AST.reduceToFirstIfReturnList(this.Evaluator(h[0],t,r));MultiArray.isInstanceOf(e)&&e.type===Complex.LOGICAL?MultiArray.setElementsLogical(this._nameTable,m,p,MultiArray.linearize(e),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(AST.nodeOp(i,MultiArray.getElementsLogical(this._nameTable[m].node,m,p,e),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u))))),!1,r)))):MultiArray.setElements(this._nameTable,m,p,[e],MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(AST.nodeOp(i,MultiArray.getElements(this._nameTable[m].node,m,p,[e]),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u))))),!1,r))))}else MultiArray.setElements(this._nameTable,m,p,h.map(e=>AST.reduceToFirstIfReturnList(this.Evaluator(e))),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(AST.nodeOp(i,MultiArray.getElements(this._nameTable[m].node,m,p,h),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u))))),!1,r))));AST.appendNodeList(l,AST.nodeOp("=",AST.nodeIdentifier(m),this._nameTable[m].node));continue}throw new EvalError(`in computed assignment ${m}(index) OP= X, ${m} must be defined first.`)}if(1===h.length){h[0].parent=e.left,h[0].index=0;const n=AST.reduceToFirstIfReturnList(this.Evaluator(h[0],t,r));MultiArray.isInstanceOf(n)&&n.type===Complex.LOGICAL?MultiArray.setElementsLogical(this._nameTable,m,p,MultiArray.linearize(n),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u))))):MultiArray.setElements(this._nameTable,m,p,[n],MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u)))))}else MultiArray.setElements(this._nameTable,m,p,h.map((t,r)=>(t.parent=e.left,t.index=r,AST.reduceToFirstIfReturnList(this.Evaluator(t)))),MultiArray.scalarToMultiArray(AST.reduceToFirstIfReturnList(this.Evaluator(a.selector(c,u)))));AST.appendNodeList(l,AST.nodeOp("=",AST.nodeIdentifier(m),this._nameTable[m].node))}}return null===e.parent||null===e.parent.parent?1===l.list.length?l.list[0]:l:l.list[0].right}case"IDENT":if(t&&this._localTable[r]&&this._localTable[r][e.id])return this._localTable[r][e.id].parent=e,this._localTable[r][e.id];if(void 0!==this._nameTable[e.id])return this._nameTable[e.id].node.parent=e,this._nameTable[e.id].node;if(this._aliasNameFunction(e.id)in this.builtInFunctionTable){const t=FunctionHandle.create(e.id);return t.parent=e,t}throw new ReferenceError(`'${e.id}' undefined.`);case".":{const n=Structure.getFields(AST.reduceToFirstIfReturnList(this.Evaluator(e.obj,t,r)),e.field.map(e=>{if("string"==typeof e)return e;{const n=AST.reduceToFirstIfReturnList(this.Evaluator(e,t,r));if(CharString.isInstanceOf(n))return n.str;throw new EvalError("Dynamic structure field names must be strings.")}}));return 1===n.length?n[0]:AST.nodeList(n)}case"LIST":{const n={type:"LIST",list:new Array(e.list.length),parent:null===e.parent?null:e};for(let i=0,a=0;i<e.list.length;i++,a++){"IDENT"!==e.list[i].type||t&&this._localTable[r]&&this._localTable[r][e.list[i].id]||e.list[i].id in this._nameTable||!(Object.keys(this.commandWordListTable).indexOf(e.list[i].id)>=0)||(e.list[i].type="CMDWLIST",e.list[i].args=[]),e.list[i].parent=n,e.list[i].index=a;const s=AST.reduceToFirstIfReturnList(this.Evaluator(e.list[i],t,r));if("LIST"===s.type)for(let t=0;t<s.list.length;t++,a++)s.list[t].parent=n,s.list[t].index=a,n.list[a]=s.list[t],null!==e.parent||AST.omitAnswer(n.list[a])||(this._nameTable.ans={node:n.list[a]});else n.list[a]=s,null!==e.parent||AST.omitAnswer(n.list[a])||(this._nameTable.ans={node:n.list[a]})}return n}case"RANGE":return e.start_.parent=e,e.stop_.parent=e,e.stride_&&(e.stride_.parent=e),MultiArray.expandRange(AST.reduceToFirstIfReturnList(this.Evaluator(e.start_,t,r)),AST.reduceToFirstIfReturnList(this.Evaluator(e.stop_,t,r)),e.stride_?AST.reduceToFirstIfReturnList(this.Evaluator(e.stride_,t,r)):null);case"ENDRANGE":{let n=e.parent,i=e.index;for(;null!==n&&"IDX"!==n.type;)i=n.index,n=n.parent;if(n&&"IDX"===n.type){const e=AST.reduceToFirstIfReturnList(this.Evaluator(n.expr,t,r));return MultiArray.isInstanceOf(e)?1===n.args.length?Complex.create(MultiArray.linearLength(e)):Complex.create(MultiArray.getDimension(e,i)):Complex.one()}throw new SyntaxError("indeterminate end of range. The word 'end' to refer a value is valid only in indexing.")}case":":if("IDX"===e.parent.type){const n=AST.reduceToFirstIfReturnList(this.Evaluator(e.parent.expr,t,r));return MultiArray.isInstanceOf(n)?1===e.parent.args.length?MultiArray.expandColon(MultiArray.linearLength(n)):MultiArray.expandColon(MultiArray.getDimension(n,e.index)):Complex.one()}throw new SyntaxError("indeterminate colon. The colon to refer a range is valid only in indexing.");case"IDX":{if(void 0===e.expr)throw new ReferenceError(`'${e.id}' undefined.`);e.expr.parent=e;const n=AST.reduceToFirstIfReturnList(this.Evaluator(e.expr,t,r));if(FunctionHandle.isInstanceOf(n)){if(n.id){const i=this._aliasNameFunction(n.id),a=e.args.map((n,a)=>(n.parent=e,n.index=a,this.builtInFunctionTable[i].ev.length>0&&a<this.builtInFunctionTable[i].ev.length&&!this.builtInFunctionTable[i].ev[a]?n:AST.reduceToFirstIfReturnList(this.Evaluator(n,t,r))));if(this.builtInFunctionTable[i].mapper&&1!==a.length)throw new EvalError(`Invalid call to ${i}. Type 'help ${n.id}' to see correct usage.`);return this.builtInFunctionTable[i].mapper&&1===a.length&&MultiArray.isInstanceOf(a[0])?MultiArray.rawMap(a[0],this.builtInFunctionTable[i].func):this.builtInFunctionTable[i].func(...a)}{if(n.parameter.length!==e.args.length)throw new EvalError(`invalid number of arguments in function ${e.expr.id}.`);const t=e.expr.id+"_"+globalThis.crypto.randomUUID();this._localTable[t]={};for(let i=0;i<e.args.length;i++)e.args[i].parent=e,e.args[i].index=i,this._localTable[t][n.parameter[i].id]=AST.reduceToFirstIfReturnList(this.Evaluator(e.args[i],!0,r));const i=AST.reduceToFirstIfReturnList(this.Evaluator(n.expression,!0,t));return delete this._localTable[t],i}}{if(!("{}"!==e.delim||MultiArray.isInstanceOf(n)&&n.isCell))throw new EvalError("matrix cannot be indexed with {");let i;const a=MultiArray.scalarOrCellToMultiArray(n);if(1===e.args.length){e.args[0].parent=e,e.args[0].index=0;const n=AST.reduceToFirstIfReturnList(this.Evaluator(e.args[0],t,r));i=MultiArray.isInstanceOf(n)&&n.type===Complex.LOGICAL?MultiArray.getElementsLogical(a,e.expr.id,[],n):MultiArray.getElements(a,e.expr.id,[],[n])}else i=MultiArray.getElements(a,e.expr.id,[],e.args.map((n,i)=>(n.parent=e,n.index=i,AST.reduceToFirstIfReturnList(this.Evaluator(n,t,r)))));return i.parent=e,a.isCell&&"()"===e.delim?(i.isCell=!0,i):MultiArray.MultiArrayToScalar(i)}}case"CMDWLIST":{const t=this.commandWordListTable[e.id].func(...e.args.map(e=>e.str));return void 0!==t?t:e}case"IF":for(let n=0;n<e.expression.length;n++)if(e.expression[n].parent=e,this.toBoolean(AST.reduceToFirstIfReturnList(this.Evaluator(e.expression[n],t,r))))return e.then[n].parent=e,AST.reduceToFirstIfReturnList(this.Evaluator(e.then[n],t,r));return e.else?(e.else.parent=e,AST.reduceToFirstIfReturnList(this.Evaluator(e.else,t,r))):{type:"LIST",list:[],parent:e};default:throw new EvalError(`evaluating undefined type '${e.type}'.`)}}Evaluate(e){try{return this._exitStatus=Evaluator.response.OK,e.parent=null,this.Evaluator(e)}catch(e){throw this._exitStatus=Evaluator.response.EVAL_ERROR,e}}Execute(e){return this.Evaluate(this.Parse(e))}Unparse(e,t=0){const r=(e,t)=>{const r=this.nodePrecedence(t),n=this.Unparse(t.left,r);return(this.nodePrecedence(t.right)<r?"("+n+")":n)+e},n=(e,t)=>{const r=this.nodePrecedence(t),n=this.Unparse(t.right,r);return e+(this.nodePrecedence(t.right)<r?"("+n+")":n)};try{if(!e)return"";if(void 0===e)return"<UNDEFINED>";if(Complex.isInstanceOf(e))return Complex.unparse(e,this,t);if(CharString.isInstanceOf(e))return CharString.unparse(e,t);if(MultiArray.isInstanceOf(e))return MultiArray.unparse(e,this,t);if(Structure.isInstanceOf(e))return Structure.unparse(e,this,t);if(FunctionHandle.isInstanceOf(e))return FunctionHandle.unparse(e,this,t);switch(e.type){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const t=this.nodePrecedence(e),r=this.Unparse(e.left,t),n=this.Unparse(e.right,t);return(this.nodePrecedence(e.left)<t?"("+r+")":r)+e.type+(this.nodePrecedence(e.right)<t?"("+n+")":n)}case"()":{const r=this.nodePrecedence(e.right),n=this.Unparse(e.right,r);return r<t?"("+n+")":n}case"!":case"~":return n(e.type,e);case"+_":return n("+",e);case"-_":return n("-",e);case"++_":return n("++",e);case"--_":return n("--",e);case".'":case"'":return r(e.type,e);case"_++":return r("++",e);case"_--":return r("--",e);case"IDENT":return e.id;case".":return this.Unparse(e.obj)+"."+e.field.map(e=>"string"==typeof e?e:"("+this.Unparse(e)+")").join(".");case"LIST":return e.list.map(e=>this.Unparse(e)).join("\n")+"\n";case"RANGE":return e.start_&&e.stop_?e.stride_?this.Unparse(e.start_)+":"+this.Unparse(e.stride_)+":"+this.Unparse(e.stop_):this.Unparse(e.start_)+":"+this.Unparse(e.stop_):":";case"ENDRANGE":return"end";case":":return":";case"<~>":return"~";case"IDX":return this.Unparse(e.expr)+e.delim[0]+e.args.map(e=>this.Unparse(e)).join(",")+e.delim[1];case"RETLIST":return"<RETLIST>";case"CMDWLIST":return(e.id+" "+e.args.map(e=>this.Unparse(e)).join(" ")).trimEnd();case"IF":let i="IF "+this.Unparse(e.expression[0])+"\n";i+=this.Unparse(e.then[0])+"\n";for(let t=1;t<e.expression.length;t++)i+="ELSEIF "+this.Unparse(e.expression[t])+"\n",i+=this.Unparse(e.then[t])+"\n";return e.else&&(i+="ELSE\n"+this.Unparse(e.else)+"\n"),i+="ENDIF",i;default:return"<INVALID>"}}catch(e){return"<ERROR>"}}UnparserMathML(e,t=0){try{if(!e)return MathML.format.UNDEFINED();if(void 0===e)return MathML.format.UNDEFINED();if(Complex.isInstanceOf(e))return Complex.unparseMathML(e,this,t);if(CharString.isInstanceOf(e))return CharString.unparseMathML(e,t);if(MultiArray.isInstanceOf(e))return MultiArray.unparseMathML(e,this,t);if(Structure.isInstanceOf(e))return Structure.unparseMathML(e,this,t);if(FunctionHandle.isInstanceOf(e))return FunctionHandle.unparseMathML(e,this,t);switch(e.type){case"()":{const r=this.nodePrecedence(e.right),n=this.UnparserMathML(e.right,r);return r<t?MathML.format["()"]("(",n,")"):n}case"+":case"-":case"*":case".*":case"./":case".\\":case"\\":case".^":case".**":case"<":case">":case"==":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":case"<=":case">=":case"!=":case"~=":{const t=this.nodePrecedence(e),r=this.UnparserMathML(e.left,t),n=this.UnparserMathML(e.right,t);return MathML.format[e.type](this.nodePrecedence(e.left)<t?MathML.format["()"]("(",r,")"):r,this.nodePrecedence(e.right)<t?MathML.format["()"]("(",n,")"):n)}case"/":return MathML.format[e.type](this.UnparserMathML(e.left),this.UnparserMathML(e.right));case"**":case"^":return MathML.format[e.type](this.UnparserMathML(e.left,this._precedenceTable["_"+e.type]),this.UnparserMathML(e.right));case"!":case"~":case"+_":case"-_":case"++_":case"--_":return MathML.format[e.type](this.UnparserMathML(e.right));case"_++":case"_--":case".'":case"'":return MathML.format[e.type](this.UnparserMathML(e.left,this._precedenceTable["_"+e.type]));case"IDENT":return MathML.format.IDENT(substSymbol(e.id));case".":return MathML.format["."](this.UnparserMathML(e.obj),e.field.map(e=>"string"==typeof e?MathML.format.IDENT(e):MathML.format["()"]("(",this.UnparserMathML(e),")")));case"LIST":return MathML.format.LIST(e.list.map(e=>this.UnparserMathML(e)));case"RANGE":return e.start_&&e.stop_?e.stride_?MathML.format.RANGE(this.UnparserMathML(e.start_),this.UnparserMathML(e.stride_),this.UnparserMathML(e.stop_)):MathML.format.RANGE(this.UnparserMathML(e.start_),this.UnparserMathML(e.stop_)):MathML.format.RANGE();case"ENDRANGE":case":":case"<~>":return MathML.format[e.type]();case"IDX":if(0===e.args.length)return MathML.format.IDX(this.UnparserMathML(e.expr),e.delim[0],[],e.delim[1]);{let r;if("IDENT"===e.expr.type){const t=this._aliasNameFunction(e.expr.id);r=t in this.builtInFunctionTable&&this.builtInFunctionTable[t].UnparserMathML?this.builtInFunctionTable[t].UnparserMathML(e):t in this.builtInFunctionTable&&t in MathML.format?MathML.format[t](...e.args.map(e=>this.UnparserMathML(e))):MathML.format.IDX(MathML.format.IDENT(substSymbol(e.expr.id)),e.delim[0],e.args.map(e=>this.UnparserMathML(e)),e.delim[1])}else r=MathML.format.IDX(this.UnparserMathML(e.expr,t),e.delim[0],e.args.map(e=>this.UnparserMathML(e)),e.delim[1]);return this.nodePrecedence(e)>t?r:MathML.format["()"]("(",r,")")}case"RETLIST":return MathML.format.RETLIST();case"CMDWLIST":return MathML.format.CMDWLIST(e.id,e.args.map(e=>this.UnparserMathML(e)));case"IF":const r=e.expression.map((t,r)=>`<mtr><mtd><mo>${0===r?"<b>if</b>":"<b>elseif</b>"}</mo></mtd><mtd>${this.UnparserMathML(e.expression[0])}</mtd></mtr><mtr><mtd></mtd><mtd>${this.UnparserMathML(e.then[0])}</mtd></mtr>`),n=e.else?`<mtr><mtd><mo><b>else</b></mo></mtd></mtr><mtr><mtd></mtd><mtd>${this.UnparserMathML(e.else)}</mtd></mtr>`:"";return`<mtable>${r.join("")}${n}<mtr><mtd><mo><b>endif</b></mo></mtd></mtr></mtable>`;default:return MathML.format.INVALID()}}catch(e){if(this._debug)throw e;return MathML.format.ERROR()}}UnparseMathML(e,t="block"){let r=this.UnparserMathML(e);return r?MathML.format.math(MathML.format.errorReplace(r),t):"<b>Unparse error.</b>"}ToMathML(e,t="block"){return this.UnparseMathML(this.Parse(e),t)}}const src_Evaluator={Evaluator},LAPACKConfigKeyTable=["maxIterationFactor"],LAPACKunused_defaultSettings={maxIterationFactor:1e3};class LAPACKunused{static defaultSettings=Object.assign({},LAPACKunused_defaultSettings);static settings=LAPACKunused.defaultSettings;static set=e=>{Object.entries(e).forEach(e=>{if(!LAPACKConfigKeyTable.includes(e[0]))throw new Error(`LAPACK.set: invalid configuration parameter: ${e[0]}`);LAPACK.settings[e[0]]=e[1]})};static laswp=(e,t,r,n,i,a,s)=>{const o=e.dimension[0],l=e.dimension[1],c=2===e.dimension.length?1:e.dimension.slice(2).reduce((e,t)=>e*t,1),u=void 0===a?0:a,m=void 0===s?l-1:s;if(!n||0===n.length)return;const h=0===Math.min(...n);if(i>0)for(let a=t;a<=r;a+=i){const t=a-1,r=n[a-1],i=h?r:r-1;if(i!==t)for(let r=0;r<c;r++){const n=r*o+t,a=r*o+i;for(let t=u;t<=m;t++){const r=e.array[n][t];e.array[n][t]=e.array[a][t],e.array[a][t]=r}}}else for(let a=t;a>=r;a+=i){const t=a-1,r=n[a-1],i=h?r:r-1;if(i!==t)for(let r=0;r<c;r++){const n=r*o+t,a=r*o+i;for(let t=u;t<=m;t++){const r=e.array[n][t];e.array[n][t]=e.array[a][t],e.array[a][t]=r}}}};static laswp_rows=(e,t,r)=>{const n=t+1,i=n,a=[];a[n-1]=r+1,LAPACKunused.laswp(e,n,i,a,1)};static laswp_cols=(e,t,r)=>{const n=e.dimension,i=n[0]*(2===n.length?1:n.slice(2).reduce((e,t)=>e*t,1));for(let n=0;n<i;n++){const i=e.array[n][t];e.array[n][t]=e.array[n][r],e.array[n][r]=i}};static eye=(...e)=>{const t=e.flat(),r=t[0],n=t[1];if(2===t.length)return Array.from({length:r},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero()));{const e=t.slice(2).reduce((e,t)=>e*t,1);return Array.from({length:r*e},(e,t)=>{const i=t%r;return Array.from({length:n},(e,t)=>i===t?Complex.one():Complex.zero())})}};static zeros=(...e)=>{const t=e.flat();return Array.from({length:t[0]*t.slice(2).reduce((e,t)=>e*t,1)},e=>Array.from({length:t[1]},e=>Complex.zero()))};static lassq=e=>{const t=e.dimension[0],r=e.dimension[1];let n=Complex.zero(),i=Complex.one();for(let a=0;a<t;a++)for(let t=0;t<r;t++){const r=e.array[a][t];if(!Complex.realIsZero(r)){const e=Complex.abs(r);if(Complex.lt(n,e)){if(!Complex.realIsZero(n)){const t=Complex.rdiv(n,e);Complex.mulAndSumTo(i,i,Complex.mul(t,t))}n=e}else{const t=Complex.rdiv(e,n);Complex.mulAndSumTo(i,t,t)}}}return{scale:n,sumsq:i}};static lange=(e,t)=>{const r=t.dimension[0],n=t.dimension[1];switch(e){case"F":{const{scale:e,sumsq:r}=LAPACK.lassq(t);return Complex.realIsZero(e)?Complex.zero():Complex.mul(e,Complex.sqrt(r))}case"M":{let e=Complex.zero();for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=Complex.abs(t.array[i][r]);Complex.lt(e,n)&&(e=n)}return e}default:throw new Error(`lange: norm '${e}' not implemented`)}};static triu_inplace=e=>{const t=e.dimension.length>2?e.dimension.slice(2).reduce((e,t)=>e*t,1):1,r=e.dimension[0];for(let n=0;n<t;n++){const t=n*r;for(let r=0;r<e.dimension[0];r++){const n=e.array[t+r];for(let t=0;t<Math.min(r,e.dimension[1]);t++)n[t]=Complex.zero()}}MultiArray.setType(e)};static tril_inplace=e=>{const t=e.dimension.length>2?e.dimension.slice(2).reduce((e,t)=>e*t,1):1,r=e.dimension[0];for(let n=0;n<t;n++){const t=n*r;for(let r=0;r<e.dimension[0];r++){const n=e.array[t+r];for(let t=r+1;t<e.dimension[1];t++)n[t]=Complex.zero()}}MultiArray.setType(e)};static trsm_left_upper_block=(e,t,r)=>{const n=e.dimension[1];for(let i=t+r;i<n;i++)for(let n=r-1;n>=0;n--){const a=t+n;let s=e.array[a][i];for(let o=n+1;o<r;o++){const r=e.array[a][t+o],n=e.array[t+o][i];s=Complex.sub(s,Complex.mul(r,n))}const o=e.array[a][t+n];e.array[a][i]=Complex.rdiv(s,o)}};static lapmt_matrix=e=>{const t=e.length,r=new MultiArray([t,t]);for(let n=0;n<t;n++){const t=e[n];r.array[t][n]=Complex.one()}return MultiArray.setType(r),r};static larfg_vector=e=>{const t=e.length;if(0===t)return{tau:Complex.zero(),v:[],phi:Complex.one(),alpha:Complex.zero()};const r=e[0];let n=Complex.zero();for(let r=1;r<t;r++){const t=Complex.abs(e[r]);Complex.mulAndSumTo(n,t,t)}const i=Complex.abs(r),a=Complex.realIsZero(i)?Complex.one():Complex.rdiv(r,i);if(1===t||Complex.realIsZero(Complex.abs(n))){const e=Complex.zero(),n=new Array(t);n[0]=Complex.one();for(let e=1;e<t;e++)n[e]=Complex.zero();return{tau:e,v:n,phi:a,alpha:r}}{const i=Complex.sqrt(Complex.add(Complex.mul(r,Complex.conj(r)),n)),s=Complex.mul(Complex.neg(a),i),o=Complex.rdiv(Complex.sub(s,r),s),l=Complex.sub(r,s),c=new Array(t);c[0]=Complex.one();for(let r=1;r<t;r++)c[r]=Complex.rdiv(e[r],l);return{tau:o,v:c,phi:a,alpha:s}}};static larfg_apply=(e,t,r)=>{let n;n="L"===e?t.dimension[0]:t.dimension[1];const{tau:i,v:a,alpha:s}=LAPACK.larfg(e,t,n,r);return Complex.realIsZero(Complex.abs(i))||LAPACK.larf(e,t,a,i,r,r),{tau:i,v:a,alpha:s}};static larfg_left_nd=(e,t)=>{const r=e.dimension,n=r.length>2?r.slice(2).reduce((e,t)=>e*t,1):1,i=r[0],a=r[0],{tau:s,v:o,alpha:l}=LAPACK.larfg("L",e,i,t);if(Complex.realIsZero(Complex.abs(s)))return{tau:s,v:o,alpha:l};for(let l=0;l<n;l++){const n=l*a;for(let a=0;a<r[1];a++){let r=Complex.zero();for(let s=t;s<i;s++){const i=n+s;r=Complex.add(r,Complex.mul(Complex.conj(o[s-t]),e.array[i][a]))}r=Complex.mul(s,r);for(let s=t;s<i;s++){const i=n+s;e.array[i][a]=Complex.sub(e.array[i][a],Complex.mul(o[s-t],r))}}}return MultiArray.setType(e),{tau:s,v:o,alpha:l}};static larfg_right_nd=(e,t)=>{const r=e.dimension,n=r.length>2?r.slice(2).reduce((e,t)=>e*t,1):1,i=r[1],a=r[0],{tau:s,v:o,alpha:l}=LAPACK.larfg("R",e,i,t);if(Complex.realIsZero(Complex.abs(s)))return{tau:s,v:o,alpha:l};for(let l=0;l<n;l++){const n=l*a;for(let a=0;a<r[0];a++){const r=e.array[n+a];let l=Complex.zero();for(let e=t;e<i;e++)l=Complex.add(l,Complex.mul(r[e],o[e-t]));l=Complex.mul(s,l);for(let e=t;e<i;e++)r[e]=Complex.sub(r[e],Complex.mul(l,Complex.conj(o[e-t])))}}return MultiArray.setType(e),{tau:s,v:o,alpha:l}};static larfg_nd=(e,t,r)=>"L"===e?LAPACKunused.larfg_left_nd(t,r):LAPACKunused.larfg_right_nd(t,r);static larf_left_block_anterior=(e,t,r,n,i,a)=>{if(Complex.realIsZero(Complex.abs(r)))return;const s=e.dimension[0],o=e.dimension[1],l="number"==typeof a?Math.min(a,o):o,c=t.length,u=Math.max(0,Math.min(c,s-n));for(let a=i;a<l;a++){let i=Complex.zero();for(let r=0;r<u;r++)Complex.mulAndSumTo(i,Complex.conj(t[r]),e.array[n+r][a]);if(i=Complex.mul(r,i),!Complex.realIsZero(Complex.abs(i)))for(let r=0;r<u;r++){const s=Complex.mul(t[r],i);e.array[n+r][a]=Complex.sub(e.array[n+r][a],s)}}};static larf_left_block=(e,t,r,n,i,a)=>{if(Complex.realIsZero(Complex.abs(r)))return;const s=e.dimension[0],o=e.dimension[1],l=t.length;if(n<0||n>=s)throw new Error("larf_left_block: invalid rowStart");if(i<0||i>=o)throw new Error("larf_left_block: invalid colStart");if(l!==s-n)throw new Error("larf_left_block: v length must equal m - rowStart");const c=Math.max(1,Math.floor(a??BLAS.settings.blockSize)),u=new MultiArray([l,1]);for(let e=0;e<l;e++)u.array[e][0]=t[e];const m=new MultiArray([1,l]);for(let e=0;e<l;e++)m.array[0][e]=Complex.conj(t[e]);for(let t=i;t<o;t+=c){const i=Math.min(t+c,o)-t,a=new MultiArray([l,i]);for(let r=0;r<l;r++)for(let s=0;s<i;s++)a.array[r][s]=e.array[n+r][t+s];const s=new MultiArray([1,i]);BLAS.gemm_block(m.array,a.array,s.array,Complex.one(),Complex.zero(),c);for(let e=0;e<i;e++)s.array[0][e]=Complex.mul(r,s.array[0][e]);for(let e=0;e<l;e++){const t=u.array[e][0];if(!Complex.realIsZero(Complex.abs(t)))for(let r=0;r<i;r++){const n=Complex.mul(t,s.array[0][r]);a.array[e][r]=Complex.sub(a.array[e][r],n)}}for(let r=0;r<l;r++)for(let s=0;s<i;s++)e.array[n+r][t+s]=a.array[r][s]}};static larf_right_conj_block=(e,t,r,n,i,a)=>{if(Complex.realIsZero(Complex.abs(r)))return;const s=e.dimension[0],o=e.dimension[1],l=t.length;if(n<0||n>=s)throw new Error("larf_right_conj_block: invalid rowStart");if(i<0||i>=o)throw new Error("larf_right_conj_block: invalid colStart");if(i+l>o)throw new Error("larf_right_conj_block: block exceeds matrix columns");const c=Math.max(1,Math.floor(a??BLAS.settings.blockSize)),u=new MultiArray([l,1]);for(let e=0;e<l;e++)u.array[e][0]=Complex.conj(t[e]);for(let a=n;a<s;a+=c){const n=Math.min(a+c,s)-a,o=new MultiArray([n,l]);for(let t=0;t<n;t++)for(let r=0;r<l;r++)o.array[t][r]=e.array[a+t][i+r];const m=new MultiArray([n,1]);BLAS.gemm_block(o.array,u.array,m.array,Complex.one(),Complex.zero(),c);const h=Complex.conj(r);for(let e=0;e<n;e++)m.array[e][0]=Complex.mul(h,m.array[e][0]);for(let e=0;e<n;e++){const r=m.array[e][0];if(!Complex.realIsZero(Complex.abs(r)))for(let n=0;n<l;n++){const i=Complex.mul(r,t[n]);o.array[e][n]=Complex.sub(o.array[e][n],i)}}for(let t=0;t<n;t++)for(let r=0;r<l;r++)e.array[a+t][i+r]=o.array[t][r]}};static larf_right_conj=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=e.dimension[0],s=(e.dimension[1],t.length);for(let o=n;o<a;o++){let n=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(n,e.array[o][i+r],Complex.conj(t[r]));const a=Complex.mul(n,Complex.conj(r));if(!Complex.realIsZero(Complex.abs(a)))for(let r=0;r<s;r++)e.array[o][i+r]=Complex.sub(e.array[o][i+r],Complex.mul(a,t[r]))}};static larf_right_conj_return=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return MultiArray.copy(e);const a=e.dimension[0],s=(e.dimension[1],t.length),o=MultiArray.copy(e);for(let l=n;l<a;l++){let n=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(n,e.array[l][i+r],Complex.conj(t[r]));const a=Complex.mul(n,Complex.conj(r));if(!Complex.realIsZero(Complex.abs(a)))for(let r=0;r<s;r++)o.array[l][i+r]=Complex.sub(e.array[l][i+r],Complex.mul(a,t[r]))}return MultiArray.setType(o),o};static larf_left_nd=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=e.dimension,s=a.length>2?a.slice(2).reduce((e,t)=>e*t,1):1,o=a[0];for(let l=0;l<s;l++){const s=l*o;for(let o=i;o<a[1];o++){let i=Complex.zero();for(let r=0;r<t.length;r++){const a=s+n+r;i=Complex.add(i,Complex.mul(Complex.conj(t[r]),e.array[a][o]))}i=Complex.mul(r,i);for(let r=0;r<t.length;r++){const a=s+n+r;e.array[a][o]=Complex.sub(e.array[a][o],Complex.mul(t[r],i))}}}MultiArray.setType(e)};static larf_right_nd=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=e.dimension,s=a.length>2?a.slice(2).reduce((e,t)=>e*t,1):1,o=a[0];for(let l=0;l<s;l++){const s=l*o;for(let o=n;o<a[0];o++){const n=s+o,a=e.array[n];let l=Complex.zero();for(let e=0;e<t.length;e++)l=Complex.add(l,Complex.mul(a[i+e],t[e]));l=Complex.mul(r,l);for(let e=0;e<t.length;e++)a[i+e]=Complex.sub(a[i+e],Complex.mul(l,Complex.conj(t[e])))}}MultiArray.setType(e)};static larf_nd=(e,t,r,n,i,a)=>"L"===e?LAPACKunused.larf_left_nd(t,r,n,i,a):LAPACKunused.larf_right_nd(t,r,n,i,a);static getf2=(e,t,r,n)=>{const i=e.dimension[0],a=e.dimension[1],s=Math.min(t+r,Math.min(i,a));for(let r=t;r<s;r++){let t=r,s=Complex.abs(e.array[r][r]);for(let n=r+1;n<i;n++){const i=Complex.abs(e.array[n][r]);Complex.toBoolean(Complex.gt(i,s))&&(s=i,t=n)}n[r]=t,t!==r&&LAPACKunused.laswp_rows(e,r,t);const o=e.array[r][r];if(!Complex.toBoolean(Complex.eq(Complex.abs(o),Complex.zero()))){for(let t=r+1;t<i;t++)e.array[t][r]=Complex.rdiv(e.array[t][r],o);for(let t=r+1;t<i;t++){const n=e.array[t][r],i=e.array[t],s=e.array[r];for(let e=r+1;e<a;e++)i[e]=Complex.sub(i[e],Complex.mul(n,s[e]))}}}};static getrf=(e,t)=>{const r=e.dimension[0],n=e.dimension[1],i=Math.min(r,n),a=new Array(i);for(let e=0;e<i;e++)a[e]=e;let s=0;for(let o=0;o<i;o+=t??BLAS.settings.blockSize){const l=Math.min(t??BLAS.settings.blockSize,i-o);LAPACK.getf2(e.array,o,l,a);for(let t=o;t<o+l&&t<i;t++){const r=a[t];if(r!==t&&s++,r!==t&&o>0)for(let n=0;n<o;n++){const i=e.array[t][n];e.array[t][n]=e.array[r][n],e.array[r][n]=i}}const c=l,u=r-(o+c),m=n-(o+c);if(o+c<n){const t=e.array,r=[];for(let e=0;e<u;e++){const n=o+c+e,i=new Array(c);for(let e=0;e<c;e++)i[e]=t[n][o+e];r.push(i)}const n=[];for(let e=0;e<c;e++){const r=o+e,i=new Array(m);for(let e=0;e<m;e++)i[e]=t[r][o+c+e];n.push(i)}const i=[];for(let e=0;e<u;e++){const r=o+c+e,n=new Array(m);for(let e=0;e<m;e++)n[e]=t[r][o+c+e];i.push(n)}BLAS.gemm(Complex.neg(Complex.one()),r,u,c,n,m,Complex.one(),i);for(let e=0;e<u;e++){const r=o+c+e;for(let n=0;n<m;n++)t[r][o+c+n]=i[e][n]}for(let e=0;e<c;e++){const r=o+e;for(let i=0;i<m;i++)t[r][o+c+i]=n[e][i]}for(let e=0;e<u;e++){const n=o+c+e;for(let i=0;i<c;i++)t[n][o+i]=r[e][i]}}}return MultiArray.setType(e),{LU:e,piv:a,swaps:s}};static gemm_blocked=(e,t,r,n=64)=>{const i=t+r,a=t+r,s=e.dimension[0]-(t+r),o=e.dimension[1]-(t+r);if(s<=0||o<=0)return;const l=r,c=n;for(let r=0;r<s;r+=c){const n=Math.min(r+c,s);for(let s=0;s<o;s+=c){const u=Math.min(s+c,o);for(let o=r;o<n;o++){const r=i+o,n=e.array[r];for(let r=s;r<u;r++){let s=Complex.zero();for(let n=0;n<l;n++){const l=e.array[i+o][t+n],c=e.array[t+n][a+r];s=Complex.add(s,Complex.mul(l,c))}n[a+r]=Complex.sub(n[a+r],s)}}}}};static getrf_blocked=(e,t)=>{const r=e.dimension[0],n=e.dimension[1],i=Math.min(r,n),a=new Array(i);for(let e=0;e<i;e++)a[e]=e;const s={swaps:0},o={info:0};for(let l=0;l<i;l+=t??BLAS.settings.blockSize){const c=Math.min(t??BLAS.settings.blockSize,i-l);LAPACK.getf2(e.array,l,c,a,s,o),l+c<n&&LAPACK.trsm_left_upper_block(e.array,l,c),l+c<r&&l+c<n&&LAPACK.gemm_blocked(e.array,l,c)}return{LU:e,piv:a,info:o.info,swaps:s.swaps}};static getrs=(e,t,r)=>{const n=e.dimension[0],i=e.dimension[1],a=r.dimension[1]??1,s=MultiArray.copy(r);for(let e=0;e<t.length;e++){const r=t[e];if(r!==e)if("function"==typeof MultiArray.swapRows)MultiArray.swapRows(s,e,r);else{const t=s.array[e];s.array[e]=s.array[r],s.array[r]=t}}for(let t=0;t<a;t++)for(let r=0;r<n;r++){let n=s.array[r][t];for(let a=0;a<r&&a<i;a++)n=Complex.sub(n,Complex.mul(e.array[r][a],s.array[a][t]));s.array[r][t]=n}for(let t=0;t<a;t++)for(let r=Math.min(i,n)-1;r>=0;r--){let n=s.array[r][t];for(let a=r+1;a<i;a++)n=Complex.sub(n,Complex.mul(e.array[r][a],s.array[a][t]));const a=e.array[r][r];s.array[r][t]=Complex.rdiv(n,a)}return MultiArray.setType(s),s};static sytrd=(e,t)=>{const r=e.dimension[0],n=new Array(r),i=new Array(r-1),a=new Array(r-1);for(let s=0;s<r-1;s++){const o=r-s-1,l=new Array(o);for(let t=0;t<o;t++)l[t]=Complex.copy(e.array[s+1+t][s]);const{alpha:c,v:u,tau:m}=LAPACK.larfg_original(l);a[s]=m,i[s]=c,e.array[s+1][s]=c;for(let t=1;t<o;t++)e.array[s+1+t][s]=u[t];Complex.realIsZero(Complex.abs(m))||t(e,u,Complex.conj(m),s+1,s+1),n[s]=Complex.copy(e.array[s][s])}return n[r-1]=Complex.copy(e.array[r-1][r-1]),{diag:n,offdiag:i,taus:a}};static ungtr0=(e,t)=>{const r=e.dimension[0],n=new MultiArray([r,r]);n.array=LAPACK.eye([r,r]);for(let i=r-2;i>=0;i--){const a=t[i];if(Complex.realIsZero(Complex.abs(a)))continue;const s=r-i-1,o=new Array(s);o[0]=Complex.one();for(let t=1;t<s;t++)o[t]=Complex.copy(e.array[i+1+t][i]);const l=new Array(r);for(let e=0;e<r;e++){let t=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(t,Complex.conj(o[r]),n.array[i+1+r][e]);l[e]=t}for(let e=0;e<s;e++){const t=Complex.mul(a,o[e]);for(let a=0;a<r;a++)n.array[i+1+e][a]=Complex.sub(n.array[i+1+e][a],Complex.mul(t,l[a]))}}return n};static ungtr=(e,t)=>{const r=e.dimension[0],n=new MultiArray([r,r]);n.array=LAPACK.eye([r,r]);for(let i=r-2;i>=0;i--){const a=t[i];if(Complex.realIsZero(Complex.abs(a)))continue;const s=r-i-1,o=new Array(s);o[0]=Complex.one();for(let t=1;t<s;t++)o[t]=Complex.copy(e.array[i+1+t][i]);const l=new Array(r);for(let e=0;e<r;e++){let t=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(t,Complex.conj(o[r]),n.array[i+1+r][e]);l[e]=t}for(let e=0;e<s;e++){const t=Complex.mul(a,o[e]);for(let a=0;a<r;a++)n.array[i+1+e][a]=Complex.sub(n.array[i+1+e][a],Complex.mul(t,l[a]))}}return n};static sytrd_debug=e=>{console.log("\n===== DEBUG: LAPACK.sytrd_debug =====\n");const t=e.dimension[0],r=MultiArray.copy(e),{diag:n,offdiag:i,taus:a}=LAPACK.sytrd(e,LAPACK.her2_zhtrd_update);console.log("Diag D ="),console.log("Offdiag E ="),console.log("Taus =");let s=new MultiArray([t,t]);s.array=LAPACK.eye(t,t);for(let r=t-2;r>=0;r--){const n=t-r-1,i=new Array(n);for(let t=0;t<n;t++)i[t]=e.array[r+1+t][r];const o=a[r];Complex.realIsZero(Complex.abs(o))||LAPACK.larf_left(s,i,o,r+1,0)}const o=new MultiArray([t,t]);for(let e=0;e<t;e++)o.array[e][e]=n[e],e<t-1&&(o.array[e][e+1]=i[e],o.array[e+1][e]=i[e]);console.log("\nMatriz T reconstruída:");const l=Evaluator.Create();console.log(MultiArray.unparse(o,l));const c=MathOperation.mtimes(LinearAlgebra.transpose(s),MathOperation.mtimes(r,s));console.log("\nMatriz Qᵀ * A * Q ="),console.log(MultiArray.unparse(c,l)),console.log("\nElementos fora da banda tridiagonal (devem ≈ 0):");for(let e=0;e<t;e++)for(let r=0;r<t;r++)Math.abs(Complex.realToNumber(c.array[e][r]))>1e-7&&Math.abs(e-r)>1&&console.log("\n===== FIM DEBUG SYTRD =====\n");return{diag:n,offdiag:i,taus:a,Q:s,T:o,QtA:c}};static sytrd_blocked=(e,t)=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("sytrd_blocked: A must be square");const n=new Array(r),i=new Array(r),a=new Array(r);if(0===r)return{diag:n,offdiag:i,taus:a};if(1===r)return n[0]=e.array[0][0],i[0]=Complex.zero(),a[0]=Complex.zero(),{diag:n,offdiag:i,taus:a};const s=Math.max(1,Math.floor(t??BLAS.settings.blockSize));for(let t=0;t<r-1;t+=s){const o=Math.min(s,r-1-t);for(let l=0;l<o;l++){const o=t+l,c=r-o-1,u=new Array(c);for(let t=0;t<c;t++)u[t]=e.array[o+1+t][o];const m=LAPACK.larfg_original(u),h=m.v,p=m.tau,d=m.alpha;a[o]=p,n[o]=e.array[o][o],i[o]=d;for(let t=0;t<c;t++)e.array[o+1+t][o]=h[t];if(Complex.realIsZero(Complex.abs(p)))continue;const x=o+1,C=o+1;LAPACKunused.larf_left_block(e,h,p,x,C,s),LAPACKunused.larf_right_conj_block(e,h,p,x,C,s)}}return n[r-1]=e.array[r-1][r-1],i[r-1]=Complex.zero(),a[r-1]=Complex.zero(),{diag:n,offdiag:i,taus:a}};static sytrd_blocked_w=(e,t)=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("sytrd_blocked_w: A must be square");const n=new Array(r),i=new Array(r),a=new Array(r);if(0===r)return{diag:n,offdiag:i,taus:a};if(1===r)return n[0]=e.array[0][0],i[0]=Complex.zero(),a[0]=Complex.zero(),{diag:n,offdiag:i,taus:a};const s=Math.max(1,Math.floor(t??BLAS.settings.blockSize));for(let t=0;t<r-1;t+=s){const o=Math.min(s,r-1-t),l=new Array(r-t-1),c=new Array(r-t-1);for(let e=0;e<r-t-1;e++)l[e]=new Array(o).fill(Complex.zero()),c[e]=new Array(o).fill(Complex.zero());for(let s=0;s<o;s++){const o=t+s,u=r-o-1,m=new Array(u);for(let t=0;t<u;t++)m[t]=e.array[o+1+t][o];const h=LAPACK.larfg_original(m),p=h.v,d=h.tau,x=h.alpha;a[o]=d,n[o]=e.array[o][o],i[o]=x;for(let t=0;t<u;t++)e.array[o+1+t][o]=p[t],l[t][s]=p[t];if(!Complex.realIsZero(Complex.abs(d)))for(let t=0;t<u;t++){let r=Complex.zero();for(let n=0;n<=t;n++)r=Complex.add(r,Complex.mul(l[n][s],Complex.conj(e.array[o+1+n][o+1+t])));c[t][s]=Complex.mul(d,r)}}for(let n=0;n<r-t-1;n++)for(let i=n;i<r-t-1;i++){let r=Complex.zero(),a=Complex.zero();for(let e=0;e<o;e++)r=Complex.add(r,Complex.mul(l[n][e],Complex.conj(c[i][e]))),a=Complex.add(a,Complex.mul(c[n][e],Complex.conj(l[i][e])));e.array[t+1+n][t+1+i]=Complex.sub(e.array[t+1+n][t+1+i],Complex.add(r,a)),n!==i&&(e.array[t+1+i][t+1+n]=Complex.conj(e.array[t+1+n][t+1+i]))}}return n[r-1]=e.array[r-1][r-1],i[r-1]=Complex.zero(),a[r-1]=Complex.zero(),{diag:n,offdiag:i,taus:a}};static steqr_values=(e,t,r)=>{const{D:n}=LAPACK.steqr_vectors(e,t,r);return n};static steqr_vectors_1=(e,t,r)=>{const n=e.length,i=r??1e3*n,a=e.slice(),s=t.slice();let o=n-1,l=0;const c=new MultiArray([n,n]);for(c.array=LAPACK.eye(n,n);o>0&&l<i;){let e=o-1;for(;e>=0&&Complex.realIsZero(Complex.abs(s[e]));)e--;if(e<0){o--;continue}const t=a[o-1],r=a[o],i=s[o-1],u=Complex.mul(Complex.sub(t,r),Complex.onediv2()),m=Complex.add(r,Complex.rdiv(Complex.mul(i,i),Complex.add(u,Complex.sign(u))));let h=Complex.sub(a[0],m),p=s[0];for(let e=0;e<o;e++){const t=Complex.sqrt(Complex.add(Complex.mul(h,h),Complex.mul(p,p))),r=Complex.rdiv(h,t),i=Complex.rdiv(p,t);for(let t=0;t<n;t++){const n=c.array[e][t],a=c.array[e+1][t];c.array[e][t]=Complex.add(Complex.mul(r,n),Complex.mul(i,a)),c.array[e+1][t]=Complex.sub(Complex.mul(r,a),Complex.mul(i,n))}e>0&&(s[e-1]=Complex.mul(t,Complex.sign(s[e-1])));const l=a[e],u=a[e+1],m=s[e];a[e]=Complex.add(Complex.add(Complex.mul(Complex.mul(r,r),l),Complex.mul(Complex.mul(i,i),u)),Complex.mul(Complex.mul(Complex.mul(r,i),m),Complex.two())),a[e+1]=Complex.add(Complex.add(Complex.mul(Complex.mul(i,i),l),Complex.mul(Complex.mul(r,r),u)),Complex.mul(Complex.mul(Complex.mul(r,i),m),Complex.create(-2))),s[e]=Complex.sub(Complex.mul(Complex.mul(r,i),Complex.sub(u,l)),m),e<o-1&&(h=s[e],p=Complex.mul(i,s[e+1]),s[e+1]=Complex.mul(r,s[e+1]))}l++}const u=MultiArray.toColumnVector(a);return MultiArray.setType(u),MultiArray.setType(c),{D:u,V:c}};static steqr_vectors_0=(e,t,r)=>{const n=e.length,i=r??Math.max(LAPACK.settings.maxIterationFactor,n*LAPACK.settings.maxIterationFactor),a=new Array(n),s=new Array(n);for(let t=0;t<n;t++)a[t]=Complex.realToNumber(e[t]);for(let e=0;e<n-1;e++)s[e]=Complex.realToNumber(t[e]);s[n-1]=0;const o=new MultiArray([n,n]),l=LAPACK.eye(n,n);o.array=l;const c=Number.EPSILON||2220446049250313e-31,u=a.slice(),m=s.slice();let h=n-1,p=0;const d=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.create(1):Complex.create(0)));let x=!1;try{for(;h>0&&p<i;){let e=h-1;for(;e>=0;){if(Math.abs(m[e])<=100*c*(Math.abs(u[e])+Math.abs(u[e+1]))){m[e]=0;break}e--}if(e<0&&(e=0),e===h){h--;continue}let t=0;for(;e<h&&t<i&&p<i;){t++,p++;const e=u[h],r=u[h-1],i=m[h-1],a=(r-e)/2,s=Math.hypot(a,i),o=a+(a>=0?s:-s),l=0===o?e-Math.abs(i):e+i*i/o;let x=u[0]-l,C=m[0],f=0;for(let e=0;e<h;e++){const t=Math.hypot(x,C);if(0===t){e<h-1&&(x=m[e],C=0);continue}const r=x/t,i=C/t,a=Complex.create(r),s=Complex.create(i);for(let t=0;t<n;t++){const r=d[e][t],n=d[e+1][t],i=Complex.add(Complex.mul(a,r),Complex.mul(s,n)),o=Complex.sub(Complex.mul(a,n),Complex.mul(s,r));d[e][t]=i,d[e+1][t]=o}e>0&&(m[e-1]=f);const o=u[e],l=u[e+1],c=m[e],p=r*c-i*((l-o)/2),g=o+2*i*r*c,_=l-2*i*r*c;if(u[e]=g,u[e+1]=_,m[e]=p,e<h-1){const t=m[e+1];f=i*t,m[e+1]=r*t,x=m[e],C=f}else f=0*i,x=m[e],C=0}h-1>=0&&(m[h-1]=f);for(let e=0;e<h;e++){const t=100*c*(Math.abs(u[e])+Math.abs(u[e+1]));Math.abs(m[e])<=t&&(m[e]=0)}for(;h>0&&0===m[h-1];)h--}}}catch(e){x=!0}const C=u.slice(),f=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)f.array[e][t]=d[e][t];MultiArray.setType(f);const g=(()=>{const e=Array.from({length:n},()=>Array(n).fill(0));for(let t=0;t<n;t++)e[t][t]=a[t],t<n-1&&(e[t][t+1]=s[t],e[t+1][t]=s[t]);const t=Array.from({length:n},(e,t)=>Array(n).fill(0));for(let e=0;e<n;e++)for(let r=0;r<n;r++)t[e][r]=Complex.realToNumber(f.array[e][r]);const r=Array.from({length:n},()=>Array(n).fill(0));for(let i=0;i<n;i++)for(let a=0;a<n;a++)if(0!==e[i][a])for(let s=0;s<n;s++)r[i][s]+=e[i][a]*t[a][s];const i=Array.from({length:n},()=>Array(n).fill(0));for(let e=0;e<n;e++)for(let r=0;r<n;r++)i[e][r]=t[e][r]*C[r];let o=0;for(let e=0;e<n;e++)for(let t=0;t<n;t++){const n=r[e][t]-i[e][t];o+=n*n}return Math.sqrt(o)})(),_=1e-8*Math.max(1,g);if(x||!(g<=_)){const e=Array.from({length:n},()=>Array(n).fill(0));for(let t=0;t<n;t++)e[t][t]=a[t],t<n-1&&(e[t][t+1]=s[t],e[t+1][t]=s[t]);const t=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?1:0)),r=1e-12,l=Math.max(50,Math.floor(i/Math.max(1,n))),c=e=>{let t=0;for(let r=0;r<n;r++)for(let i=r+1;i<n;i++)t+=e[r][i]*e[r][i];return Math.sqrt(t)};for(let i=0;i<l;i++){let i=!1;for(let a=0;a<n-1;a++)for(let s=a+1;s<n;s++){const o=e[a][s];if(Math.abs(o)<=r)continue;const l=e[a][a],c=e[s][s],u=.5*Math.atan2(2*o,c-l),m=Math.cos(u),h=Math.sin(u);for(let t=0;t<n;t++)if(t!==a&&t!==s){const r=e[t][a],n=e[t][s];e[t][a]=m*r-h*n,e[a][t]=e[t][a],e[t][s]=h*r+m*n,e[s][t]=e[t][s]}const p=m*m*l-2*h*m*o+h*h*c,d=h*h*l+2*h*m*o+m*m*c;e[a][a]=p,e[s][s]=d,e[a][s]=0,e[s][a]=0;for(let e=0;e<n;e++){const r=t[e][a],n=t[e][s];t[e][a]=m*r-h*n,t[e][s]=h*r+m*n}i=!0}if(!i)break;if(c(e)<=r)break}const u=new MultiArray([n,1]);for(let t=0;t<n;t++)u.array[t][0]=Complex.create(e[t][t]);for(let e=0;e<n;e++)for(let r=0;r<n;r++)o.array[e][r]=Complex.create(t[e][r]);return MultiArray.setType(u),MultiArray.setType(o),{D:u,V:o}}const y=C.map((e,t)=>({val:e,i:t})).sort((e,t)=>e.val-t.val),A=y.map(e=>e.val),E=Array.from({length:n},()=>Array(n).fill(Complex.create(0)));for(let e=0;e<n;e++){const t=y[e].i;for(let r=0;r<n;r++)E[r][e]=f.array[r][t]}const L=new MultiArray([n,1]);for(let e=0;e<n;e++)L.array[e][0]=Complex.create(A[e]);return o.array=E,MultiArray.setType(L),MultiArray.setType(o),{D:L,V:o}};static steqr_vectors_2=(e,t,r)=>{const n=e.length,i=r??Math.max(LAPACK.settings.maxIterationFactor,n*LAPACK.settings.maxIterationFactor),a=e.map(e=>Complex.real(e)),s=t.map(e=>Complex.real(e));s[n-1]=Complex.zero();const o=new MultiArray([n,n]);o.array=LAPACK.eye(n,n);const l=Complex.epsilon(),c=Complex.create(100),u=a.slice(),m=s.slice();let h=n-1,p=0;const d=LAPACK.eye(n,n);let x=!1;try{for(;h>0&&p<i;){let e=h-1;for(;e>=0;){const t=Complex.abs(m[e]),r=Complex.mul(Complex.mul(l,c),Complex.add(Complex.abs(u[e]),Complex.abs(u[e+1])));if(Complex.toBoolean(Complex.le(t,r))){m[e]=Complex.zero();break}e--}if(e<0&&(e=0),e===h){h--;continue}let t=0;for(;e<h&&t<i&&p<i;){t++,p++;const e=u[h],r=u[h-1],i=m[h-1],a=Complex.rdiv(Complex.sub(r,e),Complex.two()),s=Complex.hypot(a,i),o=Complex.add(a,Complex.toBoolean(Complex.ge(a,Complex.zero()))?s:Complex.neg(s)),x=Complex.toBoolean(Complex.eq(o,Complex.zero()))?Complex.sub(e,Complex.abs(i)):Complex.add(e,Complex.rdiv(Complex.mul(i,i),o));let C=Complex.sub(u[0],x),f=m[0],g=Complex.zero();for(let e=0;e<h;e++){const t=Complex.hypot(C,f);if(Complex.toBoolean(Complex.eq(t,Complex.zero()))){e<h-1&&(C=m[e],f=Complex.zero());continue}const r=Complex.rdiv(C,t),i=Complex.rdiv(f,t),a=r,s=i;for(let t=0;t<n;t++){const r=d[e][t],n=d[e+1][t],i=Complex.add(Complex.mul(a,r),Complex.mul(s,n)),o=Complex.sub(Complex.mul(a,n),Complex.mul(s,r));d[e][t]=i,d[e+1][t]=o}e>0&&(m[e-1]=g);const o=u[e],l=u[e+1],c=m[e],p=Complex.sub(Complex.mul(r,c),Complex.mul(i,Complex.rdiv(Complex.sub(l,o),Complex.two()))),x=Complex.add(o,Complex.mul(Complex.two(),Complex.mul(i,Complex.mul(r,c)))),_=Complex.sub(l,Complex.mul(Complex.two(),Complex.mul(i,Complex.mul(r,c))));if(u[e]=x,u[e+1]=_,m[e]=p,e<h-1){const t=m[e+1];g=Complex.mul(i,t),m[e+1]=Complex.mul(r,t),C=m[e],f=g}else g=Complex.mul(i,Complex.zero()),C=m[e],f=Complex.zero()}h-1>=0&&(m[h-1]=g);for(let e=0;e<h;e++){const t=Complex.mul(l,Complex.mul(c,Complex.add(Complex.abs(u[e]),Complex.abs(u[e+1]))));Complex.toBoolean(Complex.le(Complex.abs(m[e]),t))&&(m[e]=Complex.zero())}for(;h>0&&Complex.toBoolean(Complex.eq(m[h-1],Complex.zero()));)h--}}}catch(e){x=!0}const C=u.slice(),f=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)f.array[e][t]=d[e][t];MultiArray.setType(f);const g=(()=>{const e=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let t=0;t<n;t++)e[t][t]=a[t],t<n-1&&(e[t][t+1]=s[t],e[t+1][t]=s[t]);const t=Array.from({length:n},(e,t)=>Array(n).fill(Complex.zero()));for(let e=0;e<n;e++)for(let r=0;r<n;r++)t[e][r]=f.array[e][r];const r=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let i=0;i<n;i++)for(let a=0;a<n;a++)if(Complex.toBoolean(Complex.ne(e[i][a],Complex.zero())))for(let s=0;s<n;s++)Complex.mulAndSumTo(r[i][s],e[i][a],t[a][s]);const i=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let e=0;e<n;e++)for(let r=0;r<n;r++)i[e][r]=Complex.mul(t[e][r],C[r]);let o=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++){const n=Complex.sub(r[e][t],i[e][t]);Complex.mulAndSumTo(o,n,n)}return Complex.sqrt(o)})(),_=Complex.mul(Complex.create(1e-8),Complex.max(Complex.one(),g));if(x||!Complex.toBoolean(Complex.le(g,_))){const e=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let t=0;t<n;t++)e[t][t]=a[t],t<n-1&&(e[t][t+1]=s[t],e[t+1][t]=s[t]);const t=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero())),r=Complex.create(1e-12),l=Math.max(50,Math.floor(i/Math.max(1,n))),c=e=>{let t=Complex.zero();for(let r=0;r<n;r++)for(let i=r+1;i<n;i++)Complex.mulAndSumTo(t,e[r][i],e[r][i]);return Complex.sqrt(t)};for(let i=0;i<l;i++){let i=!1;for(let a=0;a<n-1;a++)for(let s=a+1;s<n;s++){const o=e[a][s];if(Complex.toBoolean(Complex.le(Complex.abs(o),r)))continue;const l=e[a][a],c=e[s][s],u=Complex.mul(Complex.onediv2(),Complex.atan2(Complex.mul(Complex.two(),o),Complex.sub(c,l))),m=Complex.cos(u),h=Complex.sin(u);for(let t=0;t<n;t++)if(t!==a&&t!==s){const r=e[t][a],n=e[t][s];e[t][a]=Complex.sub(Complex.mul(m,r),Complex.mul(h,n)),e[a][t]=e[t][a],e[t][s]=Complex.add(Complex.mul(h,r),Complex.mul(m,n)),e[s][t]=e[t][s]}const p=Complex.add(Complex.sub(Complex.mul(Complex.mul(m,m),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),h),m),o)),Complex.mul(Complex.mul(h,h),c)),d=Complex.add(Complex.add(Complex.mul(Complex.mul(h,h),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),h),m),o)),Complex.mul(Complex.mul(m,m),c));e[a][a]=p,e[s][s]=d,e[a][s]=Complex.zero(),e[s][a]=Complex.zero();for(let e=0;e<n;e++){const r=t[e][a],n=t[e][s];t[e][a]=Complex.sub(Complex.mul(m,r),Complex.mul(h,n)),t[e][s]=Complex.add(Complex.mul(h,r),Complex.mul(m,n))}i=!0}if(!i)break;if(c(e)<=r)break}const u=new MultiArray([n,1]);for(let t=0;t<n;t++)u.array[t][0]=e[t][t];for(let e=0;e<n;e++)for(let r=0;r<n;r++)o.array[e][r]=t[e][r];return MultiArray.setType(u),MultiArray.setType(o),{D:u,V:o}}const y=C.map((e,t)=>({val:e,i:t})).sort((e,t)=>Complex.realToNumber(Complex.sub(e.val,t.val))),A=y.map(e=>e.val),E=Array.from({length:n},()=>Array(n).fill(Complex.create(0)));for(let e=0;e<n;e++){const t=y[e].i;for(let r=0;r<n;r++)E[r][e]=f.array[r][t]}const L=new MultiArray([n,1]);for(let e=0;e<n;e++)L.array[e][0]=A[e];return o.array=E,MultiArray.setType(L),MultiArray.setType(o),{D:L,V:o}};static numeric_jacobi_symmetric_dense=(e,t,r)=>{const n=e.length;if(0===n)return{Dnum:[],Vnum:[]};if(1===n)return{Dnum:[e[0]],Vnum:[[Complex.one()]]};const i=Array.from({length:n},()=>Array(n).fill(0));for(let r=0;r<n;r++)if(i[r][r]=e[r],r<n-1){const e=t[r];i[r][r+1]=e,i[r+1][r]=e}const a=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?1:0)),s=Number.EPSILON||2220446049250313e-31,o=Math.max(50,Math.min(5e3,Math.floor(r/Math.max(1,n)))),l=e=>{let t=0;for(let r=0;r<n;r++)for(let i=r+1;i<n;i++)t+=e[r][i]*e[r][i];return Math.sqrt(t)};for(let e=0;e<o;e++){let e=!1;for(let t=0;t<n-1;t++)for(let r=t+1;r<n;r++){const o=i[t][r],l=1e-15*(Math.abs(i[t][t])+Math.abs(i[r][r]))+s;if(Math.abs(o)<=l)continue;const c=i[t][t],u=i[r][r],m=2*o;if(0===m)continue;const h=(u-c)/m,p=(h>=0?1:-1)/(Math.abs(h)+Math.sqrt(1+h*h)),d=1/Math.sqrt(1+p*p),x=p*d;for(let e=0;e<n;e++)if(e!==t&&e!==r){const n=i[e][t],a=i[e][r];i[e][t]=d*n-x*a,i[t][e]=i[e][t],i[e][r]=x*n+d*a,i[r][e]=i[e][r]}const C=d*d*c-2*x*d*o+x*x*u,f=x*x*c+2*x*d*o+d*d*u;i[t][t]=C,i[r][r]=f,i[t][r]=0,i[r][t]=0;for(let e=0;e<n;e++){const n=a[e][t],i=a[e][r];a[e][t]=d*n-x*i,a[e][r]=x*n+d*i}e=!0}if(!e)break;if(l(i)<=1e-14)break}const c=new Array(n);for(let e=0;e<n;e++)c[e]=i[e][e];return{Dnum:c,Vnum:Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>Complex.create(a[t][r])))}};static tridiag_her_to_dense=(e,t)=>{const r=e.length,n=Array.from({length:r},()=>Array.from({length:r},()=>Complex.zero()));for(let i=0;i<r;i++)n[i][i]=Complex.copy(e[i]),i<r-1&&(n[i][i+1]=Complex.copy(t[i]),n[i+1][i]=Complex.conj(t[i]));return n};static compute_residual_numeric=(e,t,r)=>{const n=e.length,i=Array.from({length:n},()=>Array(n).fill(0));for(let e=0;e<n;e++)for(let r=0;r<n;r++)i[e][r]=Complex.realToNumber(t.array[e][r]);const a=Array.from({length:n},()=>Array(n).fill(0));for(let t=0;t<n;t++)a[t][t]=Complex.realToNumber(Complex.real(e[t][t])),t<n-1&&(a[t][t+1]=Complex.realToNumber(Complex.real(e[t][t+1])),a[t+1][t]=a[t][t+1]);const s=Array.from({length:n},()=>Array(n).fill(0));for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=a[e][t];if(0!==r)for(let a=0;a<n;a++)s[e][a]+=r*i[t][a]}const o=Array.from({length:n},()=>Array(n).fill(0));for(let e=0;e<n;e++)for(let t=0;t<n;t++)o[e][t]=i[e][t]*r[t];let l=0;for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=s[e][t]-o[e][t];l+=r*r}return Math.sqrt(l)};static compute_residual_complex=(e,t,r)=>{const n=e.length;let i=0;for(let a=0;a<n;a++)for(let s=0;s<n;s++){let o=Complex.zero();for(let r=0;r<n;r++)Complex.mulAndSumTo(o,e[a][r],t.array[r][s]);const l="number"==typeof r[0]?Complex.create(r[s]):r[s],c=Complex.mul(t.array[a][s],l),u=Complex.sub(o,c),m=Complex.realToNumber(Complex.abs(u));i+=m*m}return Math.sqrt(i)};static column_pivot=(e,t,r=0,n=e.length)=>{const i=e.slice(r,n).map(e=>Complex.abs(e[t])),a=i.reduce((e,t,r,n)=>Complex.toBoolean(Complex.gt(t,n[e]))?r:e,0);return{pivotRow:a,pivotAbs:i[a],pivotIsZero:Complex.realIsZero(i[a])}};static normalize_eigenvector_phases=(e,t=!0)=>{const r=e.length,n=e[0].length;for(let i=0;i<n;i++){const{pivotRow:n,pivotAbs:a,pivotIsZero:s}=LAPACK.column_pivot(e,i);if(s)continue;const o=e[n][i];let l=Complex.rdiv(Complex.conj(o),a);t&&Complex.realLessThan(Complex.mul(o,l),0)&&(l=Complex.neg(l));for(let t=0;t<r;t++)e[t][i]=Complex.mul(e[t][i],l)}};static test_orthonormality=e=>{const t=e.dimension[0],r=Array.from({length:t},()=>Array(t).fill(0));for(let n=0;n<t;n++)for(let i=0;i<t;i++){let a=0;for(let r=0;r<t;r++)a+=Complex.realToNumber(Complex.mul(Complex.conj(e.array[r][n]),e.array[r][i]));r[n][i]=a}let n=0,i=0;for(let e=0;e<t;e++)for(let a=0;a<t;a++)e===a?i=Math.max(i,Math.abs(1-r[e][e])):n=Math.max(n,Math.abs(r[e][a]));return{maxOffDiag:n,maxDiagDeviation:i}};static test_residual=(e,t,r)=>{const n=e.length,i=new Array(n);for(let e=0;e<n;e++)i[e]=r.array[e][0];return LAPACKunused.compute_residual_complex(e,t,i)};static diag_eigenpairs=(e,t,r)=>{const n=e.length,i=[];for(let a=0;a<n;a++){const s=new Array(n);for(let e=0;e<n;e++)s[e]=t.array[e][a];const o=new Array(n).fill(Complex.zero());for(let t=0;t<n;t++){let r=Complex.zero();for(let i=0;i<n;i++)r=Complex.add(r,Complex.mul(e[t][i],s[i]));o[t]=r}let l=Complex.zero();for(let e=0;e<n;e++)l=Complex.add(l,Complex.mul(Complex.conj(s[e]),o[e]));let c=Complex.zero();for(let e=0;e<n;e++)c=Complex.add(c,Complex.mul(Complex.conj(s[e]),s[e]));const u=Complex.rdiv(l,c),m=r.array[a][0],h=Complex.sub(m,u),p=Complex.realToNumber(Complex.abs(h));let d=0;for(let e=0;e<n;e++){const t=o[e],r=Complex.mul(m,s[e]),n=Complex.sub(t,r),i=Complex.realToNumber(Complex.abs(n));d+=i*i}const x=Math.sqrt(d);i.push({j:a,lambda:m,rq:u,abs_lambda_minus_rq:p,resnorm:x})}return i.forEach(e=>{}),i};static match_evals_to_rayleighs=(e,t)=>{const r=e.length,n=(e.map((e,t)=>({val:e,i:t,re:Complex.realToNumber(Complex.real(e))})),t.map((e,t)=>({val:e,i:t,re:Complex.realToNumber(Complex.real(e))})),Array(r).fill(!1)),i=[];for(let a=0;a<r;a++){let s=-1,o=1/0;for(let i=0;i<r;i++){if(n[i])continue;const r=Complex.sub(e[a],t[i]),l=Complex.realToNumber(Complex.abs(r));l<o&&(o=l,s=i)}s>=0&&(n[s]=!0,i.push({evalIndex:a,rqIndex:s,diff:o}))}return console.log("match_evals_to_rayleighs mapping:"),i.forEach(r=>{const n=Complex.realToNumber(Complex.real(e[r.evalIndex])),i=Complex.realToNumber(Complex.real(t[r.rqIndex]));console.log(`eval idx=${r.evalIndex} (val=${n})  -> rq idx=${r.rqIndex} (val=${i})  diff=${r.diff}`)}),i};static steqr_vectors_original=(e,t,r)=>{const n=e.length,i=r??Math.max(1e3,1e3*n),a=new Array(n),s=new Array(n);for(let r=0;r<n-1;r++)a[r]=Complex.copy(e[r]),s[r]=Complex.copy(t[r]);a[n-1]=Complex.copy(e[n-1]),s[n-1]=Complex.zero();let o=!1;for(let e=0;e<n;e++){if(Complex.isComplexValue(a[e])){o=!0;break}if(e<n-1&&Complex.isComplexValue(s[e])){o=!0;break}}console.log("----- State of tridiagonal about to be solved -----"),console.log("# Arguments:"),console.log("# Prepare Dwork and Ework:"),console.log("# Input is complex?:"),console.log("  needComplexPath =",o??!1);const l=new Array(n),c=new Array(n),u=new Array(n);if(o){l[0]=Complex.one();for(let e=0;e<n-1;e++){const t=s[e],r=Complex.abs(t);if(Complex.realIsZero(r))l[e+1]=Complex.copy(l[e]);else{const n=Complex.mul(Complex.conj(l[e]),t);l[e+1]=Complex.rdiv(r,n);const i=Complex.realToNumber(Complex.abs(l[e+1]));0!==i&&Math.abs(i-1)>1e-12&&(l[e+1]=Complex.rdiv(l[e+1],Complex.abs(l[e+1])))}}console.log("# Phases u[] for Hermitian -> real-offdiag transform");for(let e=0;e<n;e++)c[e]=Complex.realToNumber(a[e]);for(let e=0;e<n-1;e++){const t=Complex.mul(Complex.conj(l[e]),Complex.mul(s[e],l[e+1]));u[e]=Complex.realToNumber(Complex.abs(t))}}else{for(let e=0;e<n;e++)c[e]=Complex.realToNumber(a[e]);for(let e=0;e<n-1;e++)u[e]=Complex.realToNumber(s[e])}u[n-1]=0,console.log("  Dnum = [",c.map(e=>e.toString()).join(", "),"]"),console.log("  Enum = [",u.map(e=>e.toString()).join(", "),"]");const m=new MultiArray([n,n]);m.array=LAPACK.eye(n,n);const h=LAPACKunused.numeric_jacobi_symmetric_dense(c,u,i);console.log("# LAPACK.numeric_jacobi_symmetric_dense(Dnum, Enum, maxIts)"),console.log("  core.Dnum:",JSON.stringify(h.Dnum));const p=h.Dnum.slice(),d=h.Vnum.map(e=>e.map(e=>Complex.copy(e)));if(o)for(let e=0;e<n;e++){const t=l[e];for(let r=0;r<n;r++)d[e][r]=Complex.mul(t,d[e][r])}const x=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)x.array[e][t]=Complex.copy(d[e][t]);MultiArray.setType(x);const C=p.map(e=>Complex.create(e));LAPACK.normalize_eigenvector_phases(x.array);const f=LAPACKunused.tridiag_her_to_dense(a,s),g=C.slice(),_=LAPACKunused.compute_residual_complex(f,x,g);if(_>1e-8*Math.max(1,_)){const e=LAPACK.jacobi_symmetric_hermitian(f,Math.max(50,Math.floor(i/Math.max(1,n))),1e-12),t=new MultiArray([n,1]);for(let r=0;r<n;r++)t.array[r][0]=e.D[r];for(let t=0;t<n;t++)for(let r=0;r<n;r++)m.array[t][r]=e.V[t][r];const r=e.D.map((e,t)=>({val:e,i:t})).sort((e,t)=>Complex.realToNumber(Complex.sub(e.val,t.val))),a=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let t=0;t<n;t++){const i=r[t].i;for(let r=0;r<n;r++)a[r][t]=e.V[r][i]}for(let e=0;e<n;e++)for(let t=0;t<n;t++)m.array[e][t]=a[e][t];LAPACK.normalize_eigenvector_phases(m.array);const s=new MultiArray([n,1]);for(let e=0;e<n;e++)s.array[e][0]=r[e].val;return MultiArray.setType(s),MultiArray.setType(m),{D:s,V:m,complex:o}}const y=C.map((e,t)=>({val:e,i:t})).sort((e,t)=>Complex.realToNumber(e.val)-Complex.realToNumber(t.val)),A=y.map(e=>e.val),E=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let e=0;e<n;e++){const t=y[e].i;for(let r=0;r<n;r++)E[r][e]=Complex.copy(x.array[r][t])}for(let e=0;e<n;e++)for(let t=0;t<n;t++)m.array[e][t]=Complex.copy(E[e][t]);LAPACK.normalize_eigenvector_phases(m.array);const L=new MultiArray([n,1]);for(let e=0;e<n;e++)L.array[e][0]=Complex.copy(A[e]);return MultiArray.setType(L),MultiArray.setType(m),{D:L,V:m,complex:o}};static steqr_vectors=(e,t,r)=>{const n=e.length,i=r??Math.max(1e3,1e3*n),a=new Array(n),s=new Array(n);for(let r=0;r<n-1;r++)a[r]=Complex.copy(e[r]),s[r]=Complex.copy(t[r]);a[n-1]=Complex.copy(e[n-1]),s[n-1]=Complex.zero();let o=!1;for(let e=0;e<n;e++){if(Complex.isComplexValue(a[e])){o=!0;break}if(e<n-1&&Complex.isComplexValue(s[e])){o=!0;break}}const l=new Array(n),c=new Array(n),u=new Array(n);if(o){l[0]=Complex.one();for(let e=0;e<n-1;e++){const t=s[e],r=Complex.abs(t);if(Complex.realIsZero(r))l[e+1]=Complex.copy(l[e]);else{const n=Complex.rdiv(Complex.conj(t),r);l[e+1]=Complex.mul(l[e],n);const i=Complex.realToNumber(Complex.abs(l[e+1]));0!==i&&Math.abs(i-1)>1e-12&&(l[e+1]=Complex.rdiv(l[e+1],Complex.abs(l[e+1])))}}for(let e=0;e<n;e++)c[e]=Complex.realToNumber(a[e]);for(let e=0;e<n-1;e++){const t=Complex.mul(Complex.conj(l[e]),Complex.mul(s[e],l[e+1]));u[e]=Complex.realToNumber(Complex.abs(t))}}else{for(let e=0;e<n;e++)c[e]=Complex.realToNumber(a[e]);for(let e=0;e<n-1;e++)u[e]=Complex.realToNumber(s[e])}u[n-1]=0;const m=LAPACK.eye(n,n),h=LAPACKunused.numeric_jacobi_symmetric_dense(c,u,i),p=h.Dnum.slice(),d=h.Vnum.map(e=>e.map(e=>Complex.copy(e)));if(o)for(let e=0;e<n;e++){const t=l[e];for(let r=0;r<n;r++)d[e][r]=Complex.mul(t,d[e][r])}const x=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)x.array[e][t]=Complex.copy(d[e][t]);MultiArray.setType(x);const C=p.map(e=>Complex.create(e));LAPACK.normalize_eigenvector_phases(x.array);const f=LAPACKunused.tridiag_her_to_dense(a,s),g=C.slice(),_=LAPACKunused.compute_residual_complex(f,x,g);if(_>1e-8*Math.max(1,_)){const e=LAPACK.jacobi_symmetric_hermitian(f,Math.max(50,Math.floor(i/Math.max(1,n))),1e-12),t=new MultiArray([n,1]);for(let r=0;r<n;r++)t.array[r][0]=e.D[r];for(let t=0;t<n;t++)for(let r=0;r<n;r++)m[t][r]=e.V[t][r];const r=e.D.map((e,t)=>({val:e,i:t})).sort((e,t)=>Complex.realToNumber(Complex.sub(e.val,t.val))),a=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let t=0;t<n;t++){const i=r[t].i;for(let r=0;r<n;r++)a[r][t]=e.V[r][i]}for(let e=0;e<n;e++)for(let t=0;t<n;t++)m[e][t]=a[e][t];return LAPACK.normalize_eigenvector_phases(m),{D:r.map(e=>e.val),V:m,complex:o}}const y=C.map((e,t)=>({val:e,i:t})).sort((e,t)=>Complex.realToNumber(e.val)-Complex.realToNumber(t.val)),A=y.map(e=>e.val),E=Array.from({length:n},()=>Array(n).fill(Complex.zero()));for(let e=0;e<n;e++){const t=y[e].i;for(let r=0;r<n;r++)E[r][e]=Complex.copy(x.array[r][t])}for(let e=0;e<n;e++)for(let t=0;t<n;t++)m[e][t]=Complex.copy(E[e][t]);LAPACK.normalize_eigenvector_phases(m);const L=new MultiArray([n,1]);for(let e=0;e<n;e++)L.array[e][0]=Complex.copy(A[e]);return MultiArray.setType(L),{D:A,V:m,complex:o}};static orgtr_blocked_w=(e,t,r)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("orgtr_blocked_w: A must be square");const i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n);const a=Math.max(1,Math.floor(r??BLAS.settings.blockSize));for(let r=n-2;r>=0;r-=a){const s=Math.min(a,r+1),o=new Array(n-r-1),l=new Array(n-r-1);for(let e=0;e<n-r-1;e++)o[e]=new Array(s).fill(Complex.zero()),l[e]=new Array(s).fill(Complex.zero());for(let t=0;t<s;t++){const i=r-s+1+t,a=n-i-1;for(let r=0;r<a;r++)o[r][t]=e.array[i+1+r][i]}for(let e=0;e<s;e++){const a=r-s+1+e,c=t[a],u=n-a-1;if(!Complex.realIsZero(Complex.abs(c)))for(let t=0;t<u;t++){let r=Complex.zero();for(let n=0;n<=t;n++)r=Complex.add(r,Complex.mul(o[n][e],Complex.conj(i.array[a+1+n][a+1+t])));l[t][e]=Complex.mul(c,r)}}for(let e=0;e<n-r-1;e++)for(let t=0;t<n;t++){let n=Complex.zero(),a=Complex.zero();for(let i=0;i<s;i++)n=Complex.add(n,Complex.mul(o[e][i],Complex.conj(l[t-r-1+e]?.[i]??Complex.zero()))),a=Complex.add(a,Complex.mul(l[e][i],Complex.conj(o[t-r-1+e]?.[i]??Complex.zero())));i.array[r+1+e][t]=Complex.sub(i.array[r+1+e][t],Complex.add(n,a))}}return i};static eig_symmetric=(e,t=!1)=>{e.dimension[0];const r=MultiArray.copy(e),{diag:n,offdiag:i,taus:a}=LAPACK.sytrd(r,LAPACK.her2_zhtrd_update);if(t){let e=LAPACK.ungtr(r,a);const{D:t,V:s}=LAPACK.steqr_vectors(n,i),o=new MultiArray([s.length,s[0].length]);return o.array=s,e=MathOperation.mtimes(e,o),{D:MultiArray.toDiagonalMatrix(t),V:e}}return{D:MultiArray.toColumnVector(LAPACK.steqr_vectors(n,i).D)}};static eig_symmetric0=(e,t=!1,r)=>{const n=e.dimension[0],i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd(i,LAPACK.her2_zhtrd_update);if(!t){const e=LAPACK.steqr_vectors(a,s,r);return{D:MultiArray.toColumnVector(e.D)}}const l=LAPACK.steqr_vectors(a,s,r),c=new MultiArray([n,n]);c.array=LAPACK.eye(n,n);for(let e=n-2;e>=0;e--){const t=n-e-1,r=[Complex.one()];for(let n=1;n<t;n++)r[n]=i.array[e+1+n][e];const a=o[e];Complex.realIsZero(Complex.abs(a))||LAPACK.larf_left(c,r,a,e+1,0)}const u=new MultiArray([c.dimension[0],l.V[0].length]);return BLAS.gemm(Complex.one(),c.array,c.dimension[0],c.dimension[1],l.V,l.V[0].length,Complex.zero(),u.array),LAPACK.normalize_eigenvector_phases(u.array),MultiArray.setType(u),{D:MultiArray.toDiagonalMatrix(l.D),V:u}};static eig_symmetric1=(e,t=!1,r=1e4)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("eig_symmetric: matrix must be square.");const i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd(i,LAPACK.her2_zhtrd_update),l=new Array(n),c=new Array(n);for(let e=0;e<n;e++)l[e]=Complex.realToNumber(a[e]),c[e]=e<n-1?Complex.realToNumber(s[e]):0;const u=LAPACKunused.numeric_jacobi_symmetric_dense(l,c,r),m=u.Dnum.slice(),h=u.Vnum.map(e=>e.map(e=>Complex.realToNumber(e))),p=LAPACK.ungtr(i,o),d=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let r=Complex.zero();for(let i=0;i<n;i++)Complex.mulAndSumTo(r,p.array[t][i],Complex.create(h[i][e]));d.array[t][e]=r}return console.log(m.map(e=>e.toString()).join()),{D:m,V:d}};static eig_symmetric2=(e,t=!1,r)=>{const n=e.dimension[0],i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd(i,LAPACK.larf_left);if(!t){const e=LAPACK.steqr_vectors(a,s,r);return{D:MultiArray.toColumnVector(e.D)}}const l=LAPACK.steqr_vectors(a,s,r),c=new MultiArray([n,n]);c.array=LAPACK.eye(n,n);for(let e=n-2;e>=0;e--){const t=n-e-1,r=[Complex.one()];for(let n=1;n<t;n++)r[n]=i.array[e+1+n][e];const a=o[e];Complex.realIsZero(Complex.abs(a))||LAPACK.larf_left(c,r,a,e+1,0)}const u=new MultiArray([c.dimension[0],l.V[0].length]);return BLAS.gemm(Complex.one(),c.array,c.dimension[0],c.dimension[1],l.V,l.V[0].length,Complex.zero(),u.array),LAPACK.normalize_eigenvector_phases(u.array),MultiArray.setType(u),{D:MultiArray.toDiagonalMatrix(l.D),V:u}};static eig_symmetric3=(e,t="asc")=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("eig_symmetric: A must be square");const n=MultiArray.copy(e),{diag:i,offdiag:a,taus:s}=LAPACK.sytrd(n,LAPACK.larf_left),o=LAPACK.steqr_vectors(i,a),l=new Array(r);for(let e=0;e<r;e++)l[e]=o.D[e];const c=o.V,u=LAPACK.orgtr(n,s),m=new MultiArray([r,r]);for(let e=0;e<r;e++)for(let t=0;t<r;t++)m.array[e][t]=Complex.zero();for(let e=0;e<r;e++)for(let t=0;t<r;t++){const n=u.array[e][t];for(let i=0;i<r;i++)m.array[e][i]=Complex.add(m.array[e][i],Complex.mul(n,c[t][i]))}const h=Array.from({length:r},(e,t)=>t);"none"!==t&&h.sort((e,r)=>{const n=Math.abs(Complex.realToNumber(l[e])),i=Math.abs(Complex.realToNumber(l[r]));return"asc"===t?n-i:i-n});const p=h.map(e=>l[e]),d=new MultiArray([r,r]);for(let e=0;e<r;e++)for(let t=0;t<r;t++)d.array[e][t]=m.array[e][h[t]];MultiArray.setType(d);const x=new MultiArray([r,r]);for(let e=0;e<r;e++)for(let t=0;t<r;t++)x.array[e][t]=Complex.zero();for(let e=0;e<r;e++)x.array[e][e]=p[e];return MultiArray.setType(x),{V:d,D:x,evals:p}};static eig_symmetric4=(e,t=!1,r=1e4)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("eig_symmetric: matrix must be square.");const i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd(i,LAPACK.her2_zhtrd_update),l=new Array(n),c=new Array(n);for(let e=0;e<n;e++)l[e]=Complex.realToNumber(a[e]),c[e]=e<n-1?Complex.realToNumber(s[e]):0;const u=LAPACKunused.numeric_jacobi_symmetric_dense(l,c,r);console.log("# LAPACK.numeric_jacobi_symmetric_dense(Dnum, Enum, maxIts)"),console.log("  core.Dnum:",JSON.stringify(u.Dnum));const m=u.Dnum.slice();if(!t)return{D:MultiArray.toColumnVector(m.map(e=>Complex.create(e)))};const h=new MultiArray([n,n]);h.array=u.Vnum;const p=LAPACK.ungtr(i,o),d=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++){let r=Complex.zero();for(let i=0;i<n;i++)r=Complex.add(r,Complex.mul(p.array[t][i],h.array[i][e]));d.array[t][e]=r}LAPACK.normalize_eigenvector_phases(d.array),MultiArray.setType(d);const x=Evaluator.Create();return console.log(MultiArray.unparse(e,x)),console.log(`eigenvalues: [${m.map(e=>e.toString()).join(", ")}]`),{D:MultiArray.toDiagonalMatrix(m.map(e=>Complex.create(e))),V:d}};static eig_symmetric5=(e,t=!1,r=1e4)=>{const n=e.dimension[0],i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd(i,LAPACK.her2_zhtrd_update);if(!t){const e=LAPACK.steqr_vectors(a,s,r);return{D:MultiArray.toColumnVector(e.D)}}const l=new Array(n),c=new Array(n);for(let e=0;e<n;e++)l[e]=Complex.realToNumber(Complex.real(a[e])),c[e]=e<n-1?Complex.realToNumber(Complex.real(s[e])):0;const u=LAPACKunused.numeric_jacobi_symmetric_dense(l,c,r),m=u.Dnum.slice(),h=u.Vnum.map(e=>e.slice());if(!t){const e=new MultiArray([n,1]);for(let t=0;t<n;t++)e.array[t][0]=Complex.create(m[t]);return MultiArray.setType(e),{D:e}}const p=LAPACK.ungtr(i,o),d=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=h[e][t];d.array[e][t]=Complex.create(Complex.realToNumber(r))}MultiArray.setType(d);const x=new MultiArray([n,n]);BLAS.gemm(Complex.one(),p.array,p.dimension[0],p.dimension[1],d.array,d.dimension[1],Complex.zero(),x.array);const C=m.map((e,t)=>({val:e,i:t})).sort((e,t)=>e.val-t.val),f=C.map(e=>e.val),g=new MultiArray([n,n]);for(let e=0;e<n;e++){const t=C[e].i;for(let r=0;r<n;r++){const n=x.array[r][t];g.array[r][e]=Complex.copy(n)}}MultiArray.setType(g),LAPACK.normalize_eigenvector_phases(g.array,!0);const _=new MultiArray([n,1]);for(let e=0;e<n;e++)_.array[e][0]=Complex.create(f[e]);return MultiArray.setType(_),{D:_,V:g}};static eig_symmetric_blocked=(e,t="asc",r)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("eig_symmetric_blocked: A must be square");const i=MultiArray.copy(e),{diag:a,offdiag:s,taus:o}=LAPACK.sytrd_blocked_w(i,r??BLAS.settings.blockSize),l=LAPACK.orgtr_blocked_w(i,o,r??BLAS.settings.blockSize),c=LAPACK.steqr_vectors(a,s),u=MultiArray.toColumnVector(c.D),m=new MultiArray([c.V.length,c.V[0].length]);m.array=c.V;const h=new Array(n);for(let e=0;e<n;e++)h[e]=u.array[e][0];const p=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)p.array[e][t]=Complex.zero();BLAS.gemm_block(l.array,m.array,p.array,Complex.one(),Complex.zero(),r??BLAS.settings.blockSize),MultiArray.setType(p);const d=Array.from({length:n},(e,t)=>t);"none"!==t&&d.sort((e,r)=>{const n=Complex.realToNumber(h[e]),i=Complex.realToNumber(h[r]);return"asc"===t?n-i:i-n});const x=new Array(n),C=new MultiArray([n,n]);for(let e=0;e<n;e++)for(let t=0;t<n;t++)C.array[e][t]=Complex.zero();for(let e=0;e<n;e++){const t=d[e];x[e]=h[t];for(let r=0;r<n;r++)C.array[r][e]=p.array[r][t]}return MultiArray.setType(C),{D:x,V:C}};static jacobi_complex_hermitian_dense_1=(e,t=1e3,r=1e-14)=>{const n=e.length,i=Array.from({length:n},(t,r)=>Array.from({length:n},(t,n)=>Complex.copy(e[r][n]))),a=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero())),s=Number(t),o=Number(r);for(let e=0;e<s;e++){let e=0;for(let t=0;t<n;t++)for(let r=t+1;r<n;r++){const s=i[t][r],l=Complex.realToNumber(Complex.abs(s));if(e+=l*l,l<=o)continue;const c=i[t][t],u=i[r][r],m=Complex.sub(u,c),h=Complex.realToNumber(m)/(2*l),p=(h>=0?1:-1)/(Math.abs(h)+Math.sqrt(1+h*h)),d=1/Math.sqrt(1+p*p),x=p*d,C=Complex.rdiv(s,Complex.abs(s)),f=Complex.mul(Complex.create(x,0),C);for(let e=0;e<n;e++)if(e!==t&&e!==r){const n=i[e][t],a=i[e][r];i[e][t]=Complex.sub(Complex.mul(Complex.create(d,0),n),Complex.mul(Complex.conj(f),a)),i[t][e]=Complex.conj(i[e][t]),i[e][r]=Complex.add(Complex.mul(f,n),Complex.mul(Complex.create(d,0),a)),i[r][e]=Complex.conj(i[e][r])}const g=d*d,_=x*x;i[t][t]=Complex.sub(Complex.add(Complex.mul(Complex.create(g,0),c),Complex.mul(Complex.create(_,0),u)),Complex.mul(Complex.create(2*d*x,0),Complex.abs(s))),i[r][r]=Complex.add(Complex.add(Complex.mul(Complex.create(_,0),c),Complex.mul(Complex.create(g,0),u)),Complex.mul(Complex.create(2*d*x,0),Complex.abs(s))),i[t][r]=Complex.zero(),i[r][t]=Complex.zero();for(let e=0;e<n;e++){const n=a[e][t],i=a[e][r];a[e][t]=Complex.sub(Complex.mul(Complex.create(d,0),n),Complex.mul(Complex.conj(f),i)),a[e][r]=Complex.add(Complex.mul(f,n),Complex.mul(Complex.create(d,0),i))}}if(Math.sqrt(e)<o)break}const l=new Array(n);for(let e=0;e<n;e++)l[e]=Complex.copy(i[e][e]);return LAPACK.normalize_eigenvector_phases(a),{D:l,V:a}};static jacobi_hermitian_2x2=(e,t,r)=>{const n=Complex.abs(t);if(Complex.realIsZero(n))return{c:Complex.one(),s:Complex.zero()};const i=Complex.rdiv(t,n),a=Complex.realToNumber(Complex.real(e)),s=(Complex.realToNumber(Complex.real(r))-a)/(2*Complex.realToNumber(n)),o=s>=0?1/(s+Math.sqrt(1+s*s)):-1/(-s+Math.sqrt(1+s*s)),l=1/Math.sqrt(1+o*o),c=o*l;return{c:Complex.create(l,0),s:Complex.mul(Complex.create(c,0),i)}};static jacobi_complex_hermitian_dense=(e,t=1e3,r=1e-14)=>{const n=e.length;if(0===n)return{D:[],V:[]};const i=Array.from({length:n},(t,r)=>Array.from({length:n},(t,n)=>Complex.copy(e[r][n]))),a=LAPACK.eye([n,n]),s=toNumber(r),o=toNumber(t),l=()=>{let e=0;for(let t=0;t<n;t++)for(let r=t+1;r<n;r++){const n=Complex.realToNumber(Complex.abs(i[t][r]));e+=2*n*n}return Math.sqrt(e)};let c=0;for(let e=0;e<n;e++){const t=Complex.realToNumber(Complex.abs(i[e][e]));c+=t*t}c=Math.max(Math.sqrt(c),1);for(let e=0;e<o&&!(l()<s*c);e++)for(let e=0;e<n-1;e++)for(let t=e+1;t<n;t++){const r=i[e][t];if(Complex.realToNumber(Complex.abs(r))<s)continue;const{c:o,s:l}=LAPACKunused.jacobi_hermitian_2x2(i[e][e],i[e][t],i[t][t]);for(let r=0;r<n;r++){const n=i[r][e],a=i[r][t];i[r][e]=Complex.add(Complex.mul(n,o),Complex.mul(a,l)),i[r][t]=Complex.add(Complex.mul(a,o),Complex.mul(n,Complex.neg(Complex.conj(l))))}for(let r=0;r<n;r++){const n=i[e][r],a=i[t][r];i[e][r]=Complex.add(Complex.mul(n,o),Complex.mul(a,Complex.conj(l))),i[t][r]=Complex.add(Complex.mul(a,o),Complex.mul(n,Complex.neg(l)))}i[e][t]=Complex.zero(),i[t][e]=Complex.zero(),i[e][e]=Complex.create(i[e][e].re),i[t][t]=Complex.create(i[t][t].re);for(let r=0;r<n;r++){const n=a[r][e],i=a[r][t];a[r][e]=Complex.add(Complex.mul(n,o),Complex.mul(i,l)),a[r][t]=Complex.add(Complex.mul(i,o),Complex.mul(n,Complex.neg(Complex.conj(l))))}}const u=new Array(n);for(let e=0;e<n;e++)u[e]=Complex.create(i[e][e].re);return{D:u,V:a}};static jacobi_symmetric_hermitian=(e,t,r)=>{const n=e.length,i=LAPACK.eye([n,n]),a=r??1e-12,s=t??Math.max(50,Math.floor(1e3/Math.max(1,n))),o=e=>{let t=0;for(let r=0;r<n;r++)for(let i=r+1;i<n;i++){const n=Complex.abs(e[r][i]),a=Complex.realToNumber(n);t+=a*a}return Math.sqrt(t)};for(let t=0;t<s;t++){let t=!1;for(let r=0;r<n-1;r++)for(let s=r+1;s<n;s++){const o=e[r][s];if(Complex.realToNumber(Complex.le(Complex.abs(o),Complex.create(a))))continue;const l=e[r][r],c=e[s][s],u=Complex.realToNumber(Complex.real(o)),m=Complex.realToNumber(Complex.real(l)),h=Complex.realToNumber(Complex.real(c)),p=.5*Math.atan2(2*u,h-m),d=Math.cos(p),x=Math.sin(p);for(let t=0;t<n;t++){if(t===r||t===s)continue;const n=e[t][r],i=e[t][s];e[t][r]=Complex.sub(Complex.mul(Complex.create(d),n),Complex.mul(Complex.create(x),i)),e[r][t]=Complex.conj(e[t][r]),e[t][s]=Complex.add(Complex.mul(Complex.create(x),n),Complex.mul(Complex.create(d),i)),e[s][t]=Complex.conj(e[t][s])}e[r][r]=Complex.add(Complex.sub(Complex.mul(Complex.create(d*d),l),Complex.mul(Complex.create(2*x*d),o)),Complex.mul(Complex.create(x*x),c)),e[s][s]=Complex.add(Complex.add(Complex.mul(Complex.create(x*x),l),Complex.mul(Complex.create(2*x*d),o)),Complex.mul(Complex.create(d*d),c)),e[r][s]=Complex.zero(),e[s][r]=Complex.zero();for(let e=0;e<n;e++){const t=i[e][r],n=i[e][s];i[e][r]=Complex.sub(Complex.mul(Complex.create(d),t),Complex.mul(Complex.create(x),n)),i[e][s]=Complex.add(Complex.mul(Complex.create(x),t),Complex.mul(Complex.create(d),n))}t=!0}if(!t)break;if(o(e)<=a)break}const l=new Array(n);for(let t=0;t<n;t++)l[t]=e[t][t];return{D:l,V:i}};static jacobi_real_symmetric_structured_2n=(e,t=1e3,r=1e-12)=>{const n=e.length,i=n/2,a=LAPACK.eye([n,n]);for(let s=0;s<t;s++){let t=0;for(let s=0;s<i;s++)for(let o=s+1;o<i;o++){const l=Complex.realToNumber(e[s][o]);if(t=Math.max(t,Math.abs(l)),Math.abs(l)<r)continue;const c=Complex.realToNumber(e[s][s]),u=(Complex.realToNumber(e[o][o])-c)/(2*l),m=u>=0?1/(u+Math.sqrt(1+u*u)):-1/(-u+Math.sqrt(1+u*u)),h=1/Math.sqrt(1+m*m),p=m*h;for(let t=0;t<n;t++){let r=Complex.realToNumber(e[s][t]),n=Complex.realToNumber(e[o][t]);e[s][t]=Complex.create(h*r-p*n),e[o][t]=Complex.create(p*r+h*n),r=Complex.realToNumber(e[s+i][t]),n=Complex.realToNumber(e[o+i][t]),e[s+i][t]=Complex.create(h*r-p*n),e[o+i][t]=Complex.create(p*r+h*n)}for(let t=0;t<n;t++){let r=Complex.realToNumber(e[t][s]),n=Complex.realToNumber(e[t][o]);e[t][s]=Complex.create(h*r-p*n),e[t][o]=Complex.create(p*r+h*n),r=Complex.realToNumber(e[t][s+i]),n=Complex.realToNumber(e[t][o+i]),e[t][s+i]=Complex.create(h*r-p*n),e[t][o+i]=Complex.create(p*r+h*n)}for(let e=0;e<n;e++){let t=Complex.realToNumber(a[e][s]),r=Complex.realToNumber(a[e][o]);a[e][s]=Complex.create(h*t-p*r),a[e][o]=Complex.create(p*t+h*r),t=Complex.realToNumber(a[e][s+i]),r=Complex.realToNumber(a[e][o+i]),a[e][s+i]=Complex.create(h*t-p*r),a[e][o+i]=Complex.create(p*t+h*r)}}if(t<r)break}const s=new Array(i);for(let t=0;t<i;t++)s[t]=e[t][t];return{D:s,V:a}};static jacobi_hermitian_real2n=(e,t=1e3,r=1e-12)=>{const n=LAPACK.hermitian_to_real2n(e),{D:i,V:a}=LAPACK.jacobi_real_symmetric_dense(n,t,r);return{D:i,V:LAPACK.real2n_to_complex_eigenvectors(a)}};static jacobi_hermitian_real2n_direct=(e,t,r=1e3,n=1e-12)=>{const i=LAPACK.tridiagonal_hermitian_to_dense(e,t),a=LAPACK.hermitian_to_real2n(i),{D:s,V:o}=LAPACK.jacobi_real_symmetric_dense(a,r,n);return{D:s,V:LAPACK.real2n_to_complex_eigenvectors(o)}};static numeric_jacobi_hermitian_via_real2n_final=(e,t=1e3,r=1e-12)=>{const n=e.dimension[0],i=LAPACK.hermitian_to_real2n(e.array),{D:a,V:s}=LAPACKunused.jacobi_real_symmetric_structured_2n(i,t,r),o=s,l=new MultiArray([n,n]);for(let e=0;e<n;e++){let t=Complex.zero();for(let r=0;r<n;r++){const i=o[r][e],a=o[r+n][e];l.array[r][e]=Complex.create(i.re,a.re),t=Complex.add(t,Complex.add(Complex.mul(i,i),Complex.mul(a,a)))}const r=Complex.sqrt(t);for(let t=0;t<n;t++)l.array[t][e]=Complex.rdiv(l.array[t][e],r)}return{D:a,Z:l}};static jacobi_hermitian_dense=(e,t,r)=>{const n=e.array.length,i=new MultiArray([n,n]),a=new MultiArray([n,n],Complex.zero());for(let t=0;t<n;t++)for(let r=0;r<n;r++)i.array[t][r]=e.array[t][r],a.array[t][r]=t===r?Complex.create(1):Complex.zero();for(let e=0;e<r;e++){let e=0;for(let r=0;r<n-1;r++)for(let s=r+1;s<n;s++){const o=i.array[r][s],l=Complex.realToNumber(Complex.abs(o));if(e+=l,l<=t)continue;const c=Complex.realToNumber(i.array[r][r]),u=Complex.realToNumber(i.array[s][s]),m=o,h=l,p=(u-c)/(2*h),d=0===p?1:Math.sign(p)/(Math.abs(p)+Math.sqrt(1+p*p)),x=1/Math.sqrt(1+d*d),C=d*x,f=Complex.rdiv(m,Complex.create(h)),g=Complex.mul(f,Complex.create(C));for(let e=0;e<n;e++)if(e!==r&&e!==s){const t=i.array[e][r],n=i.array[e][s],a=Complex.sub(Complex.mul(t,Complex.create(x)),Complex.mul(Complex.conj(g),n)),o=Complex.add(Complex.mul(n,Complex.create(x)),Complex.mul(g,t));i.array[e][r]=a,i.array[r][e]=Complex.conj(a),i.array[e][s]=o,i.array[s][e]=Complex.conj(o)}const _=x*x,y=d*d*_,A=_*c-2*x*C*h+y*u,E=y*c+2*x*C*h+_*u;i.array[r][r]=Complex.create(A),i.array[s][s]=Complex.create(E),i.array[r][s]=Complex.zero(),i.array[s][r]=Complex.zero();for(let e=0;e<n;e++){const t=a.array[e][r],n=a.array[e][s];a.array[e][r]=Complex.add(Complex.mul(t,Complex.create(x)),Complex.mul(g,n)),a.array[e][s]=Complex.sub(Complex.mul(n,Complex.create(x)),Complex.mul(Complex.conj(g),t))}}if(e<t)break}return{A:i,Z:a}};static numeric_jacobi_hermitian_direct=(e,t,r=100,n=1e-12)=>{const i=e.length,a=new MultiArray([i,i],Complex.zero());for(let r=0;r<i;r++)a.array[r][r]=e[r],r<i-1&&(a.array[r][r+1]=t[r],a.array[r+1][r]=Complex.conj(t[r]));const s=new MultiArray([i,i]);s.array=LAPACK.eye([i,i]);for(let e=0;e<r;e++){let e=0;for(let t=0;t<i-1;t++)for(let r=t+1;r<i;r++){const i=a.array[t][r],o=Complex.realToNumber(Complex.abs(i));e+=o*o,o>n&&LAPACKunused.jacobi_rotate_hermitian(a,s,t,r)}if(Math.sqrt(e)<n)break}const o=new Array(i);for(let e=0;e<i;e++)o[e]=a.array[e][e];return{D_work:o,Z:s}};static jacobi_hermitian_full=(e,t=50,r=1e-12)=>{const n=e.dimension[0],i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n);for(let a=0;a<t;a++){let t=0;for(let a=0;a<n;a++)for(let s=a+1;s<n;s++){const n=e.array[a][s],o=Complex.realToNumber(Complex.abs(n));t=Math.max(t,o),o>r&&LAPACKunused.jacobi_hermitian_rotation(e,i,a,s)}if(t<r)break}return i};static numeric_jacobi_hermitian_direct_02=(e,t,r=1e3,n=1e-12)=>{const i=e.length,a=new MultiArray([i,i]);for(let e=0;e<i;e++)for(let t=0;t<i;t++)a.array[e][t]=Complex.zero();for(let r=0;r<i;r++)a.array[r][r]=Complex.copy(e[r]),r<i-1&&(a.array[r][r+1]=Complex.copy(t[r]),a.array[r+1][r]=Complex.conj(t[r]));const s=new MultiArray([2*i,2*i]);for(let e=0;e<i;e++)for(let t=0;t<i;t++){const r=a.array[e][t],n=Complex.real(r),o=Complex.imag(r);s.array[e][t]=n,s.array[e][t+i]=Complex.neg(o),s.array[e+i][t]=o,s.array[e+i][t+i]=n}const{V:o}=LAPACK.jacobi_real_symmetric_dense(s.array,r,n),l=new Array(i);for(let e=0;e<i;e++)l[e]=Complex.real(s.array[e][e]);const c=new MultiArray([i,i]);for(let e=0;e<i;e++)for(let t=0;t<i;t++){const r=o[t][e],n=Complex.neg(o[t][e+i]);c.array[t][e]=Complex.create(r.re,n.re)}return{D_work:l,Z:c}};static numeric_jacobi_hermitian_direct_03=(e,t,r=1e3,n=1e-12)=>{const i=e.length,a=new MultiArray([i,i],Complex.zero());for(let r=0;r<i;r++)a.array[r][r]=e[r],r<i-1&&(a.array[r][r+1]=t[r],a.array[r+1][r]=Complex.conj(t[r]));const{A:s,Z:o}=LAPACKunused.jacobi_hermitian_dense(a,n,r),l=new Array(i);for(let e=0;e<i;e++)l[e]=s.array[e][e];return{D_work:l,Z:o}};static jacobiHermitian2x2=(e,t,r,n=1e-14)=>{const i=Complex.abs(r);if(Complex.realToNumber(i)<n)return{c:1,s:Complex.zero()};const a=Complex.rdiv(r,i),s=(t-e)/(2*Complex.realToNumber(i)),o=s>=0?1/(s+Math.sqrt(1+s*s)):-1/(-s+Math.sqrt(1+s*s)),l=1/Math.sqrt(1+o*o),c=o*l;return{c:l,s:Complex.mul(Complex.create(c),Complex.conj(a))}};static jacobi_hermitian_rotation=(e,t,r,n)=>{const i=e.dimension[0],a=e.array[r][r],s=e.array[n][n],o=e.array[r][n];if(0===Complex.abs(o).re)return;const l=Complex.arg(o),c=Complex.exp(Complex.create(0,-l));for(let r=0;r<i;r++)e.array[r][n]=Complex.mul(e.array[r][n],c),e.array[n][r]=Complex.conj(e.array[r][n]),t.array[r][n]=Complex.mul(t.array[r][n],c);const u=Complex.realToNumber(e.array[r][n]),m=(Complex.realToNumber(s)-Complex.realToNumber(a))/2,h=Math.sign(m)*u/(Math.abs(m)+Math.sqrt(m*m+u*u)),p=1/Math.sqrt(1+h*h),d=p*h;for(let t=0;t<i;t++){const i=e.array[t][r],a=e.array[t][n];e.array[t][r]=Complex.add(Complex.mul(Complex.create(p),i),Complex.mul(Complex.create(d),a)),e.array[t][n]=Complex.add(Complex.mul(Complex.create(-d),i),Complex.mul(Complex.create(p),a))}for(let t=0;t<i;t++){const i=e.array[r][t],a=e.array[n][t];e.array[r][t]=Complex.add(Complex.mul(Complex.create(p),i),Complex.mul(Complex.create(d),a)),e.array[n][t]=Complex.add(Complex.mul(Complex.create(-d),i),Complex.mul(Complex.create(p),a))}for(let e=0;e<i;e++){const i=t.array[e][r],a=t.array[e][n];t.array[e][r]=Complex.add(Complex.mul(Complex.create(p),i),Complex.mul(Complex.create(d),a)),t.array[e][n]=Complex.add(Complex.mul(Complex.create(-d),i),Complex.mul(Complex.create(p),a))}};static jacobi_rotate_hermitian=(e,t,r,n)=>{const i=e.array[r][r],a=e.array[n][n],s=e.array[r][n],o=Complex.realToNumber(i),l=Complex.realToNumber(a),c=Complex.realToNumber(Complex.abs(s));if(0===c)return;const u=l-o,m=0===u?1:Math.sign(u)*c/(Math.abs(u)+Math.sqrt(u*u+4*c*c)),h=1/Math.sqrt(1+m*m),p=h*m,d=Complex.rdiv(s,Complex.create(c)),x=Complex.mul(d,Complex.create(p)),C=Complex.create(h),f=x,g=Complex.conj(x),_=e.dimension[0];for(let t=0;t<_;t++)if(t!==r&&t!==n){const i=e.array[t][r],a=e.array[t][n],s=Complex.add(Complex.mul(C,i),Complex.mul(f,a)),o=Complex.sub(Complex.mul(C,a),Complex.mul(g,i));e.array[t][r]=s,e.array[r][t]=Complex.conj(s),e.array[t][n]=o,e.array[n][t]=Complex.conj(o)}const y=Math.sqrt(u*u+4*c*c);e.array[r][r]=Complex.create(.5*(o+l-y)),e.array[n][n]=Complex.create(.5*(o+l+y)),e.array[r][n]=Complex.zero(),e.array[n][r]=Complex.zero();for(let e=0;e<_;e++){const i=t.array[e][r],a=t.array[e][n];t.array[e][r]=Complex.add(Complex.mul(C,i),Complex.mul(f,a)),t.array[e][n]=Complex.sub(Complex.mul(C,a),Complex.mul(g,i))}};static apply_givens_right_Z=(e,t,r,n)=>{const i=e.length,a=Complex.conj(n);for(let s=0;s<i;s++){const i=e[s][t],o=e[s][t+1];e[s][t]=Complex.sub(Complex.mul(i,r),Complex.mul(a,o)),e[s][t+1]=Complex.add(Complex.mul(n,i),Complex.mul(o,r))}};static apply_givens_left_tridiagonal=(e,t,r,n,i)=>{const a=e[r],s=e[r+1],o=t[r];e[r]=Complex.add(Complex.mul(Complex.conj(n),Complex.mul(n,a)),Complex.mul(Complex.conj(i),Complex.mul(i,s))),e[r+1]=Complex.add(Complex.mul(Complex.conj(i),Complex.mul(i,a)),Complex.mul(Complex.conj(n),Complex.mul(n,s))),t[r]=Complex.mul(Complex.conj(n),Complex.sub(Complex.mul(n,o),Complex.mul(i,s)))};static apply_givens_tridiagonal_hermitian=(e,t,r,n,i)=>{const a=e[r],s=e[r+1],o=t[r],l=Complex.add(Complex.mul(n,Complex.mul(n,a)),Complex.add(Complex.mul(i,Complex.mul(Complex.conj(i),s)),Complex.sub(Complex.mul(n,Complex.mul(o,i)),Complex.mul(Complex.conj(i),Complex.mul(Complex.conj(o),n))))),c=Complex.add(Complex.mul(Complex.conj(i),Complex.mul(i,a)),Complex.add(Complex.mul(n,Complex.mul(n,s)),Complex.sub(Complex.mul(Complex.conj(i),Complex.mul(o,n)),Complex.mul(n,Complex.mul(Complex.conj(o),i))))),u=Complex.add(Complex.mul(n,Complex.mul(o,n)),Complex.sub(Complex.mul(n,Complex.mul(s,i)),Complex.mul(Complex.conj(i),Complex.mul(a,n))));e[r]=l,e[r+1]=c,t[r]=u};static apply_givens_right_tridiagonal=(e,t,r,n,i)=>{if(0===r)return;const a=t[r-1];t[r-1]=Complex.add(Complex.mul(a,n),Complex.mul(i,e[r]))};static compute_complex_givens=(e,t)=>{if(Complex.realEquals(Complex.abs(t),0))return{c:Complex.one(),s:Complex.zero(),r:e};const r=Complex.abs(e),n=Complex.abs(t),i=Complex.sqrt(Complex.add(Complex.mul(r,r),Complex.mul(n,n)));return{c:Complex.rdiv(e,i),s:Complex.rdiv(t,i),r:i}};static complexGivens=(e,t)=>{if(Complex.eq(t,Complex.zero()))return{c:Complex.one(),s:Complex.zero(),r:e};const r=Complex.abs(e),n=Complex.abs(t),i=Complex.sqrt(Complex.add(Complex.mul(r,r),Complex.mul(n,n)));return{c:Complex.rdiv(e,i),s:Complex.rdiv(t,i),r:i}};static applyGivensToZ=(e,t,r,n)=>{const i=e.dimension[0],a=Complex.conj(r),s=Complex.conj(n);for(let o=0;o<i;o++){const i=e.array[o][t],l=e.array[o][t+1];e.array[o][t]=Complex.sub(Complex.mul(i,r),Complex.mul(l,s)),e.array[o][t+1]=Complex.add(Complex.mul(i,n),Complex.mul(l,a))}};static applyGivensTridiagonal=(e,t,r,n,i)=>{const a=Complex.conj(n),s=Complex.conj(i),o=e[r],l=e[r+1],c=t[r],u=r+1<t.length?t[r+1]:Complex.zero();e[r]=Complex.add(Complex.mul(a,Complex.mul(n,o)),Complex.add(Complex.mul(a,Complex.mul(i,c)),Complex.add(Complex.mul(s,Complex.mul(n,Complex.conj(c))),Complex.mul(s,Complex.mul(i,l))))),e[r+1]=Complex.add(Complex.mul(s,Complex.mul(i,o)),Complex.add(Complex.mul(s,Complex.mul(n,c)),Complex.add(Complex.mul(a,Complex.mul(i,Complex.conj(c))),Complex.mul(a,Complex.mul(n,l))))),t[r]=Complex.add(Complex.mul(a,Complex.mul(n,c)),Complex.sub(Complex.mul(s,Complex.mul(n,l)),Complex.mul(a,Complex.mul(i,o)))),r+1<t.length&&(t[r+1]=Complex.add(Complex.mul(n,u),Complex.mul(i,Complex.sub(l,o))))};static complex_gram_schmidt=e=>{const t=e.dimension[0];for(let r=0;r<t;r++){for(let n=0;n<r;n++){let i=Complex.zero();for(let a=0;a<t;a++)i=Complex.add(i,Complex.mul(Complex.conj(e.array[a][n]),e.array[a][r]));for(let a=0;a<t;a++)e.array[a][r]=Complex.sub(e.array[a][r],Complex.mul(i,e.array[a][n]))}let n=Complex.zero();for(let i=0;i<t;i++)n=Complex.add(n,Complex.abs2(e.array[i][r]));const i=Complex.sqrt(n);for(let n=0;n<t;n++)e.array[n][r]=Complex.rdiv(e.array[n][r],i)}};static implicitQRStepTridiagonalHermitian=(e,t,r,n,i)=>{};static numeric_qr_sweep_tridiagonal_hermitian=(e,t,r,n,i)=>{const a=Complex.mul(Complex.sub(e[n],e[n+1]),Complex.create(.5)),s=Complex.abs(a),o=Complex.mul(Complex.abs(t[n]),Complex.abs(t[n])),l=Complex.realGreaterThanOrEqualTo(a,0)?Complex.one():Complex.minusone(),c=Complex.sub(e[n+1],Complex.rdiv(Complex.mul(l,o),Complex.add(s,Complex.sqrt(Complex.add(Complex.mul(s,s),o)))));let u=Complex.sub(e[r],c),m=t[r];for(let a=r;a<=n;a++){const{c:s,s:o,r:l}=LAPACKunused.compute_complex_givens(u,m);a>r&&(t[a-1]=l),LAPACKunused.apply_givens_left_tridiagonal(e,t,a,s,o),LAPACKunused.apply_givens_right_tridiagonal(e,t,a,s,o),i&&LAPACKunused.apply_givens_right_Z(i,a,s,o),a<n&&(u=t[a],m=Complex.neg(Complex.mul(o,t[a+1])),t[a+1]=Complex.mul(s,t[a+1]))}};static numeric_qr_bulge_chasing_hermitian_1=(e,t,r=1e3)=>{const n=e.length;if(0===n)return{D:[],V:[]};if(1===n)return{D:[Complex.copy(e[0])],V:[[Complex.one()]]};const i=e.map(Complex.copy),a=t.map(Complex.copy),s=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero())),o=LAPACK.tridiagonal_hermitian_to_dense(i,a);new MultiArray([n,n]).array=o;const l=()=>{const e=new MultiArray([s.length,s[0].length]);e.array=s;const t=LinearAlgebra.ctranspose(e),r=new MultiArray([n,n]);r.array=LAPACK.tridiagonal_hermitian_to_dense(i,a);const o=MathOperation.mtimes(MathOperation.mtimes(t,r),e),l=new MultiArray([n,n]);l.array=LAPACK.tridiagonal_hermitian_to_dense(i,a);const c=MathOperation.minus(l,o);console.log("||T - Zᴴ·T0·Z|| ≈",(e=>{let t=Complex.zero();for(let r=0;r<n;r++)for(let i=0;i<n;i++){const n=e.array[r][i];t=Complex.add(t,Complex.mul(n,Complex.conj(n)))}return Math.sqrt(Complex.realToNumber(t))})(c))},c=Number.EPSILON||2220446049250313e-31;let u=0;for(;u<r;){let e=0;for(;e<n-1&&Complex.realLessThanOrEqualTo(Complex.abs(a[e]),c);)e++;if(e>=n-1)break;let t=e;for(;t<n-1&&Complex.realGreaterThan(Complex.abs(a[t]),c);)t++;const r=i[t-1],o=i[t],m=a[t-1],h=Complex.mul(Complex.sub(r,o),Complex.create(.5)),p=Complex.abs(h),d=Complex.power(Complex.abs(m),Complex.create(2)),x=Complex.add(p,Complex.sqrt(Complex.add(Complex.mul(p,p),d))),C=Complex.realGreaterThanOrEqualTo(h,0)?Complex.one():Complex.minusone(),f=Complex.sub(o,Complex.rdiv(Complex.mul(C,d),x));let g=Complex.sub(i[e],f),_=a[e];for(let r=e;r<t;r++){const e=Complex.sqrt(Complex.add(Complex.mul(g,Complex.conj(g)),Complex.mul(_,Complex.conj(_))));if(Complex.realIsZero(e))continue;const n=Complex.rdiv(g,e),o=Complex.rdiv(_,e),c=i[r],u=i[r+1];i[r]=Complex.add(Complex.mul(Complex.conj(n),Complex.mul(n,c)),Complex.mul(Complex.conj(o),Complex.mul(o,u))),i[r+1]=Complex.add(Complex.mul(Complex.conj(o),Complex.mul(o,c)),Complex.mul(Complex.conj(n),Complex.mul(n,u))),a[r]=Complex.zero(),r<t-1&&(g=a[r+1],_=a[r+2]||Complex.zero()),LAPACKunused.apply_givens_right_Z(s,r,n,o),l()}u++}return{D:i,V:s}};static numeric_qr_bulge_chasing_hermitian=(e,t,r=1e3)=>{const n=e.length,i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n),Number.EPSILON;for(let a=0;a<r;a++){let r=!0;for(let a=0;a<n-1;a++){if(Complex.realIsZero(Complex.real(t[a]))&&Complex.realIsZero(Complex.imag(t[a])))continue;r=!1;const s=Complex.sqrt(Complex.add(Complex.power(Complex.abs(e[a]),Complex.create(2)),Complex.power(Complex.abs(t[a]),Complex.create(2)))),o=Complex.rdiv(e[a],s),l=Complex.rdiv(t[a],s),c=e[a],u=e[a+1];e[a]=Complex.add(Complex.mul(Complex.conj(o),Complex.mul(o,c)),Complex.mul(Complex.conj(l),Complex.mul(l,u))),e[a+1]=Complex.add(Complex.mul(l,c),Complex.mul(o,u)),t[a]=Complex.zero();const m=Complex.conj(l);for(let e=0;e<n;e++){const t=i.array[e][a],r=i.array[e][a+1],n=Complex.sub(Complex.mul(t,o),Complex.mul(m,r)),s=Complex.add(Complex.mul(l,t),Complex.mul(o,r));i.array[e][a]=n,i.array[e][a+1]=s}}if(r)break}return i.array};static numeric_steqr_tridiagonal_bulge=(e,t,r=1e3)=>{const n=e.length;if(0===n)return{D:[],V:[]};if(1===n)return{D:[Complex.copy(e[0])],V:[[Complex.one()]]};const i=e.map(Complex.copy),a=t.map(Complex.copy),s=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero())),o=Number.EPSILON||2220446049250313e-31;let l=0;for(;l<r;){let e=0;for(;e<n-1&&Complex.realLessThanOrEqualTo(Complex.abs(a[e]),o);)e++;if(e>=n-1)break;let t=e;for(;t<n-1&&Complex.realGreaterThan(Complex.abs(a[t]),o);)t++;const r=i[t-1],c=i[t],u=a[t-1],m=Complex.mul(Complex.sub(r,c),Complex.create(.5)),h=Complex.abs(m),p=Complex.power(Complex.abs(u),Complex.create(2)),d=Complex.add(h,Complex.sqrt(Complex.add(Complex.mul(h,h),p))),x=Complex.realGreaterThanOrEqualTo(m,0)?Complex.one():Complex.minusone(),C=Complex.sub(c,Complex.rdiv(Complex.mul(x,p),d));let f=Complex.sub(i[e],C),g=a[e];for(let r=e;r<t;r++){const e=Complex.sqrt(Complex.add(Complex.mul(f,Complex.conj(f)),Complex.mul(g,Complex.conj(g))));if(Complex.realIsZero(e))continue;const n=Complex.rdiv(f,e),o=Complex.rdiv(g,e),l=i[r],c=i[r+1];i[r]=Complex.add(Complex.mul(Complex.conj(n),Complex.mul(n,l)),Complex.mul(Complex.conj(o),Complex.mul(o,c))),i[r+1]=Complex.add(Complex.mul(Complex.conj(o),Complex.mul(o,l)),Complex.mul(Complex.conj(n),Complex.mul(n,c))),a[r]=Complex.zero(),r<t-1&&(f=a[r+1],g=a[r+2]||Complex.zero()),LAPACKunused.apply_givens_right_Z(s,r,n,o)}l++}return{D:i,V:s}};static numeric_qr_bulge_chasing_hermitian_refined=(e,t,r=1e3,n=1e-12)=>{const i=e.length,a=new MultiArray([i,i]);a.array=LAPACK.eye(i,i);for(let s=0;s<r;s++){let r=!0;for(let s=0;s<i-1;s++){if(Complex.realLessThan(Complex.real(t[s]),n)&&Complex.realLessThan(Complex.imag(t[s]),n)){t[s]=Complex.zero();continue}r=!1;const o=e[s],l=t[s],c=Complex.sqrt(Complex.add(Complex.mul(Complex.conj(o),o),Complex.mul(Complex.conj(l),l))),u=Complex.realIsZero(Complex.real(c))&&Complex.realIsZero(Complex.imag(c))?Complex.one():Complex.rdiv(o,c),m=Complex.realIsZero(Complex.real(c))&&Complex.realIsZero(Complex.imag(c))?Complex.zero():Complex.rdiv(l,c),h=e[s],p=e[s+1],d=Complex.conj(u),x=Complex.conj(m);e[s]=Complex.add(Complex.mul(d,Complex.mul(u,h)),Complex.mul(x,Complex.mul(m,p))),e[s+1]=Complex.add(Complex.mul(m,h),Complex.mul(u,p)),t[s]=Complex.zero();for(let e=0;e<i;e++){const t=a.array[e][s],r=a.array[e][s+1],n=Complex.sub(Complex.mul(t,u),Complex.mul(x,r)),i=Complex.add(Complex.mul(m,t),Complex.mul(u,r));a.array[e][s]=n,a.array[e][s+1]=i}}let s=Complex.zero();for(let e=0;e<i-1;e++)s=Complex.realGreaterThan(Complex.abs(t[e]),Complex.abs(s).re)?t[e]:s;if(r||Complex.realLessThan(Complex.abs(s),n))break}return a.array};static numeric_qr_hermitian_tridiagonal=(e,t,r=1e3,n=1e-12)=>{const i=e.length,a=new MultiArray([i,i]);a.array=LAPACK.eye(i,i);for(let s=0;s<r;s++){let r=i-1;for(;r>0&&Complex.realToNumber(Complex.abs(t[r-1]))<=n*Complex.realToNumber(Complex.add(Complex.abs(e[r]),Complex.abs(e[r-1])));)t[r-1]=Complex.zero(),r--;if(0===r)break;let s=r-1;for(;s>0&&Complex.realToNumber(Complex.abs(t[s-1]))>n*Complex.realToNumber(Complex.add(Complex.abs(e[s]),Complex.abs(e[s-1])));)s--;const o=Complex.rdiv(Complex.sub(e[r-1],e[r]),Complex.create(2)),l=Complex.abs(t[r-1]),c=Complex.add(Complex.abs(o),Complex.sqrt(Complex.add(Complex.mul(o,o),Complex.mul(l,l)))),u=Complex.sub(e[r],Complex.rdiv(Complex.mul(Complex.sign(o),Complex.mul(l,l)),c));let m=Complex.sub(e[s],u),h=t[s];for(let n=s;n<r;n++){const{c:i,s}=LAPACKunused.complexGivens(m,h);LAPACKunused.applyGivensTridiagonal(e,t,n,i,s),LAPACKunused.applyGivensToZ(a,n,i,s),n<r-1&&(m=t[n],h=t[n+1])}}return a.array};static qr_step_tridiagonal_hermitian=(e,t,r)=>{const n=e.length;for(let i=0;i<n-1;i++){const a=e[i],s=t[i];if(Complex.realToNumber(Complex.abs(s))<1e-14)continue;const o=Complex.sqrt(Complex.add(Complex.mul(Complex.conj(a),a),Complex.mul(Complex.conj(s),s))),l=Complex.rdiv(a,o),c=Complex.rdiv(s,o),u=Complex.conj(l),m=Complex.conj(c);{const r=e[i],a=t[i],s=e[i+1],o=i+1<n-1?t[i+1]:Complex.zero();e[i]=Complex.add(Complex.mul(u,r),Complex.mul(m,a)),t[i]=Complex.zero(),e[i+1]=Complex.sub(Complex.mul(l,s),Complex.mul(c,o)),i+1<n-1&&(t[i+1]=Complex.mul(l,o))}{const t=e[i],r=e[i+1];e[i]=Complex.add(Complex.mul(l,t),Complex.mul(m,r)),e[i+1]=Complex.sub(Complex.mul(u,r),Complex.mul(c,t))}for(let e=0;e<n;e++){const t=r[e][i],n=r[e][i+1];r[e][i]=Complex.sub(Complex.mul(t,l),Complex.mul(n,m)),r[e][i+1]=Complex.add(Complex.mul(t,c),Complex.mul(n,l))}}};static qr_hermitian_tridiagonal=(e,t,r,n)=>{const i=e.length,a=new MultiArray([i,i]);a.array=LAPACK.eye(i,i);for(let s=0;s<n;s++){let n=i-1;for(;n>0&&Complex.realToNumber(Complex.abs(t[n-1]))<=r;)t[n-1]=Complex.zero(),n--;if(0===n)break;let s=n-1;for(;s>0&&Complex.realToNumber(Complex.abs(t[s-1]))>r;)s--;const o=Complex.rdiv(Complex.sub(e[n-1],e[n]),Complex.create(2)),l=Complex.abs(t[n-1]),c=Complex.add(Complex.abs(o),Complex.sqrt(Complex.add(Complex.mul(o,o),Complex.mul(l,l)))),u=Complex.sub(e[n],Complex.rdiv(Complex.mul(Complex.sign(o),Complex.mul(l,l)),c));let m=Complex.sub(e[s],u),h=t[s];for(let e=s;e<n;e++){const{c:r,s:i}=LAPACKunused.complexGivens(m,h);LAPACKunused.applyGivensToZ(a,e,r,i),e<n-1&&(m=t[e],h=t[e+1])}}return a.array};static numeric_tridiagonal_hermitian_bulge_chasing=(e,t,r=50)=>{const n=e.length,i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n);const a=Number.EPSILON||2220446049250313e-31,s=e.map(e=>Complex.copy(e)),o=t.map(e=>Complex.copy(e)),l=e=>Complex.realLessThanOrEqualTo(Complex.abs(e),a);for(let e=0;e<r;e++){for(let e=0;e<n-1;e++){if(l(o[e]))continue;const t=s[e],r=o[e],a=Complex.sqrt(Complex.add(Complex.power(Complex.abs(t),Complex.two()),Complex.power(Complex.abs(r),Complex.two())));if(Complex.realIsZero(a))continue;const c=Complex.rdiv(t,a),u=Complex.rdiv(r,a),m=s[e],h=s[e+1];if(s[e]=Complex.add(Complex.mul(Complex.conj(c),Complex.mul(c,m)),Complex.mul(Complex.conj(u),Complex.mul(u,h))),s[e+1]=Complex.add(Complex.mul(Complex.conj(u),Complex.mul(u,m)),Complex.mul(Complex.conj(c),Complex.mul(c,h))),o[e]=Complex.zero(),e+1<n-1){const t=Complex.mul(Complex.conj(c),o[e+1]);o[e+1]=Complex.mul(Complex.conj(u),o[e+1]),o[e+1]=Complex.add(o[e+1],t)}LAPACKunused.apply_givens_right_Z(i.array,e,c,u)}if(o.every(e=>l(e)))break}return{D:s,E:o,Z:i}};static zsteqr=(e,t,r,n=1e-14,i=50*e.length)=>{const a=e.length;if(0===a)return{D:[],Z:r};if(t.length!==a-1)throw new Error("ZSTEQR: E must have length n-1");const s=Complex.create(toNumber(n)),o=Complex.one(),l=Complex.zero(),c=e.map(e=>Complex.copy(e)),u=t.map(e=>Complex.copy(e));for(let e=0;e<a;e++){let t=0;for(;;){let n=e;for(;n<a-1;n++){const e=Complex.abs(u[n]),t=Complex.add(Complex.abs(c[n]),Complex.abs(c[n+1]));if(Complex.realToNumber(e)<=Complex.realToNumber(Complex.mul(s,t))){u[n]=Complex.zero();break}}if(n===e)break;if(++t>toNumber(i))throw new Error("ZSTEQR: failed to converge");const m=c[e],h=c[e+1],p=u[e],d=Complex.create(2),x=Complex.rdiv(Complex.sub(h,m),Complex.mul(d,p)),C=Complex.realToNumber(x)>=0?o:Complex.neg(o),f=Complex.sqrt(Complex.add(Complex.mul(x,x),o)),g=Complex.add(x,Complex.mul(C,f)),_=Complex.sub(m,Complex.rdiv(Complex.mul(p,p),g));let y=Complex.sub(c[e],_),A=l,E=o;for(let t=e;t<n;t++){const e=Complex.mul(A,u[t]),n=Complex.mul(E,u[t]);let i;Complex.realToNumber(Complex.abs(e))>=Complex.realToNumber(Complex.abs(y))?(E=Complex.rdiv(y,e),i=Complex.sqrt(Complex.add(Complex.mul(E,E),o)),u[t]=Complex.mul(e,i),A=Complex.rdiv(o,i),E=Complex.mul(E,A)):(A=Complex.rdiv(e,y),i=Complex.sqrt(Complex.add(Complex.mul(A,A),o)),u[t]=Complex.mul(y,i),E=Complex.rdiv(o,i),A=Complex.mul(A,E));const s=Complex.sub(c[t+1],_),l=Complex.add(Complex.mul(Complex.sub(c[t],s),A),Complex.mul(Complex.create(2),Complex.mul(E,n)));if(c[t]=Complex.add(s,Complex.mul(A,l)),y=Complex.sub(Complex.mul(E,l),n),c[t+1]=Complex.add(y,_),r)for(let e=0;e<a;e++){const n=r[e][t],i=r[e][t+1];r[e][t]=Complex.add(Complex.mul(n,E),Complex.mul(i,A)),r[e][t+1]=Complex.add(Complex.mul(i,E),Complex.mul(n,Complex.neg(A)))}}}}for(let e=0;e<a-1;e++){let t=e,n=c[e];for(let r=e+1;r<a;r++)Complex.realToNumber(c[r])<Complex.realToNumber(n)&&(t=r,n=c[r]);if(t!==e&&([c[e],c[t]]=[c[t],c[e]],r))for(let n=0;n<a;n++)[r[n][e],r[n][t]]=[r[n][t],r[n][e]]}for(let e=0;e<a;e++)c[e]=Complex.create(c[e].re);return{D:c,Z:r}}}const src_LAPACKunused={LAPACKunused},EXPECT_TOL=1e-14,MAX_ITERACTION=1e3,DEFAULT_EIG_TOL=null,defaulTestOptions={maxIter:MAX_ITERACTION,tol:EXPECT_TOL,real:!1,frobenius:!0,print:!0,Aid:"A",Bid:"B",Cid:"C",Did:"D",Eid:"E",Fid:"F",Gid:"G",Hid:"H",Iid:"I",Jid:"J",Kid:"K",Lid:"L",Mid:"M",Nid:"N",Oid:"O",Pid:"P",Qid:"Q",Rid:"R",Sid:"S",Tid:"T",Uid:"U",Vid:"V",Wid:"W",Xid:"X",Yid:"Y",Zid:"Z"};class LAPACKtest{static setTestOptions=e=>{const t={};return Object.assign(t,defaulTestOptions),Object.assign(t,e),t};static rand=()=>Math.random()-.5;static randomReal=()=>Complex.create(LAPACKtest.rand());static randomComplex=()=>Complex.create(LAPACKtest.rand(),LAPACKtest.rand());static randomHermitian=(e,t=!0)=>{const r=Array.from({length:e},()=>Array.from({length:e}));for(let n=0;n<e;n++){r[n][n]=LAPACKtest.randomReal();for(let i=n+1;i<e;i++){const e=t?LAPACKtest.randomReal():LAPACKtest.randomComplex();r[n][i]=e,r[i][n]=t?e:Complex.conj(e)}}return r};static frobenius_norm=e=>{e=LAPACKtest.array_to_multiarray(e);let t=Complex.zero();const[r,n]=e.dimension;for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=e.array[i][r];Complex.mulAndSumTo(t,n,Complex.conj(n))}return Complex.realToNumber(Complex.sqrt(t))};static print_matrix=(e,t="M",r=Evaluator.Create())=>{e=LAPACKtest.array_to_multiarray(e),console.log(`${t} = ${MultiArray.unparse(e,r)}`)};static array_to_multiarray=e=>{if(!(e instanceof MultiArray)){const t=new MultiArray([e.length,e[0].length]);t.array=e,e=t}return e};static array_or_vector_to_diagonal_multiarray=e=>{if(!(e instanceof MultiArray)){if(!Array.isArray(e)||0===e.length)throw new Error("Invalid matrix/vector input");if(Array.isArray(e[0])){const t=new MultiArray([e.length,e[0].length]);t.array=e,e=t}else{const t=new MultiArray([e.length,e.length]);t.array=LAPACK.diag(e),e=t}}return e};static testHermitian=(e,t={})=>{e=LAPACKtest.array_to_multiarray(e);const{print:r,tol:n,Aid:i}=LAPACKtest.setTestOptions(t),a=MathOperation.minus(e,MathOperation.ctranspose(e)),s=LAPACKtest.frobenius_norm(a),o=`${i} − ${i}ᴴ`;return r&&console.log(`\n[Hermitian test]\n|| ${o} ||_F = ${LAPACKtest.frobenius_norm(a).toExponential(6)}\ntolerance = ${n.toExponential(6)}`),{dim:e.dimension,norm:s,expression:o}};static testUnitarity=(e,t={})=>{e=LAPACKtest.array_to_multiarray(e);const{print:r,frobenius:n,tol:i,Vid:a}=LAPACKtest.setTestOptions(t),s=MathOperation.ctranspose(e),o=MathOperation.mtimes(s,e),l=e.dimension[1],c=new MultiArray([l,l]);c.array=LAPACK.eye([l,l]);const u=MathOperation.minus(o,c);let m=Complex.zero();for(let e=0;e<l;e++)for(let t=0;t<l;t++)m=Complex.max(m,Complex.abs(u.array[e][t]));m=Complex.realToNumber(m);const h=`${a}ᴴ·${a} − I`;let p=0;return n&&(p=LAPACKtest.frobenius_norm(MathOperation.minus(o,c))),r&&console.log("\n[Unitarity test]\n"+(n?`|| ${h} ||_F = ${p.toExponential(6)}\n`:"")+`max |error| = ${m.toExponential(6)}\n`+`tolerance = ${i.toExponential(6)}`),n?{dim:e.dimension,norm:p,maxErr:m,expression:h}:{dim:e.dimension,maxErr:m,expression:h}};static testOrthogonal=(e,t={})=>{e=LAPACKtest.array_to_multiarray(e);const{tol:r,print:n,frobenius:i,Vid:a}=LAPACKtest.setTestOptions(t),[s,o]=e.dimension;let l;i&&(l=new MultiArray([o,o]));let c,u=Complex.zero();for(let t=0;t<o;t++)for(let r=0;r<o;r++){let n=Complex.zero();for(let i=0;i<o;i++)Complex.mulAndSumTo(n,e.array[i][t],e.array[i][r]);const a=t===r?Complex.one():Complex.zero(),s=Complex.sub(n,a);i&&(l.array[t][r]=s),u=Complex.max(u,Complex.abs(s))}i&&(c=LAPACKtest.frobenius_norm(l));const m=`${a}ᵀ·${a} − I`;return n&&console.log("\n[Orthogonality test]\n"+(i?`|| ${m} ||_F = ${c.toExponential(6)}\n`:"")+`max |error| = ${Complex.realToNumber(u).toExponential(6)}\n`+`tolerance = ${r.toExponential(6)}`),i?{dim:[s,o],norm:c,maxErr:Complex.realToNumber(u),expression:m}:{dim:[s,o],maxErr:Complex.realToNumber(u),expression:m}};static testRealEigenvalues=(e,t={})=>{e=LAPACKtest.array_or_vector_to_diagonal_multiarray(e);const{tol:r,print:n,Did:i}=LAPACKtest.setTestOptions(t),a=e.dimension[0];let s=Complex.zero();for(let t=0;t<a;t++)s=Complex.max(s,Complex.abs(Complex.imag(e.array[t][t])));return s=Complex.realToNumber(s),n&&console.log(`\n[Eigenvalue reality test]\nmax |Im(${i})| = ${s.toExponential(6)}\ntolerance = ${r.toExponential(6)}`),{dim:e.dimension,maxErr:s}};static testOffDiagonal=(e,t={})=>{e=LAPACKtest.array_or_vector_to_diagonal_multiarray(e);const{tol:r,print:n,frobenius:i,Did:a}=LAPACKtest.setTestOptions(t),s=e.dimension[0];let o=Complex.zero(),l=Complex.zero();for(let t=0;t<s;t++)for(let r=0;r<s;r++)if(t!==r){const n=e.array[t][r];Complex.mulAndSumTo(o,n,Complex.conj(n)),l=Complex.max(l,Complex.abs(n))}l=Complex.realToNumber(l);let c=0;return i&&(c=Complex.realToNumber(Complex.sqrt(o))),n&&console.log("\n[Off-diagonal test]\n"+(i?`|| offdiag(${a}) ||_F = ${c.toExponential(6)}\n`:"")+`max |offdiag| = ${l.toExponential(6)}\n`+`tolerance = ${r.toExponential(6)}`),i?{dim:e.dimension,norm:c,maxErr:l}:{dim:e.dimension,maxErr:l}};static testTridiagonality=(e,t={})=>{e=LAPACKtest.array_to_multiarray(e);const{tol:r,print:n,frobenius:i,Did:a}=LAPACKtest.setTestOptions(t),s=e.dimension[0];let o=Complex.zero(),l=Complex.zero();for(let t=0;t<s;t++)for(let r=0;r<s;r++)if(Math.abs(t-r)>1){const n=e.array[t][r];Complex.mulAndSumTo(o,n,Complex.conj(n)),l=Complex.max(l,Complex.abs(n))}l=Complex.realToNumber(l);let c=0;return i&&(c=Complex.realToNumber(Complex.sqrt(o))),n&&console.log("\n[Off-tridiagonal test]\n"+(i?`|| offtridiag(${a}) ||_F = ${c.toExponential(6)}\n`:"")+`max |offtridiag| = ${l.toExponential(6)}\n`+`tolerance = ${r.toExponential(6)}`),i?{dim:e.dimension,norm:c,maxErr:l}:{dim:e.dimension,maxErr:l}};static testEigenResidual=(e,t,r,n={})=>{e=LAPACKtest.array_to_multiarray(e),t=LAPACKtest.array_to_multiarray(t),r=LAPACKtest.array_or_vector_to_diagonal_multiarray(r);const{print:i,frobenius:a,tol:s,Aid:o,Did:l,Vid:c}=LAPACKtest.setTestOptions(n),u=MathOperation.mtimes(e,t),m=MathOperation.mtimes(t,r),h=MathOperation.minus(u,m);let p=Complex.zero();const[d,x]=h.dimension;for(let e=0;e<d;e++)for(let t=0;t<x;t++)p=Complex.max(p,Complex.abs(h.array[e][t]));p=Complex.realToNumber(p);let C=0;return a&&(C=LAPACKtest.frobenius_norm(h)),i&&console.log("\n[Eigen residual test]\n"+(a?`|| ${o}·${c} − ${c}·${l} ||_F = ${C.toExponential(6)}\n`:"")+`max |error| = ${p.toExponential(6)}\n`+`tolerance = ${s.toExponential(6)}`),a?{norm:C,maxErr:p}:{maxErr:p}};static testHermitianTridiagonalReconstruction=(e,t,r,n={})=>{n=this.setTestOptions(n);const{print:i,Aid:a,Qid:s,Tid:o}=n;e=LAPACKtest.array_to_multiarray(e),t=LAPACKtest.array_to_multiarray(t),r=LAPACKtest.array_to_multiarray(r);const l=MathOperation.ctranspose(t),c=MathOperation.mtimes(t,r),u=MathOperation.mtimes(c,l),m=MathOperation.minus(e,u),h=`${a} − ${s}·${o}·${s}ᴴ`;i&&LAPACKtest.print_matrix(m,h);const p=LAPACKtest.frobenius_norm(m);return console.log(`|| ${h} ||_F = ${p.toExponential(6)}`),{norm:p}};static start_test_complex_tridiagonal=()=>{const e=Evaluator.Create(),t=[Complex.create(2),Complex.create(3),Complex.create(2.5),Complex.create(1.8)];return{evaluator:e,D_orig:t,E_orig:[Complex.create(.3,.4),Complex.create(.1,-.2),Complex.create(-.2,.5)],n:t.length}};static start_test_complex_tridiagonal_hermitian=()=>{const{evaluator:e,D_orig:t,E_orig:r,n}=LAPACKtest.start_test_complex_tridiagonal(),i=new MultiArray([n,n]);return i.array=LAPACK.tridiagonal_hermitian_to_dense(t,r),console.log("=== Matriz T0 ==="),console.log(MultiArray.unparse(i,e)),{evaluator:e,D_orig:t,E_orig:r,n,T0:i}};static start_test_complex_tridiagonal_hermitian_to_real2n=()=>{const{evaluator:e,D_orig:t,E_orig:r,n,T0:i}=LAPACKtest.start_test_complex_tridiagonal_hermitian(),a=LAPACK.hermitian_to_real2n(i.array),s=new MultiArray([a.length,a.length]);return s.array=a,console.log("=== Matriz T ==="),console.log(MultiArray.unparse(s,e)),{evaluator:e,D_orig:t,E_orig:r,n,T0:i,T:s}};static test_jacobi_hermitian_real2n_final=()=>{const{evaluator:e,n:t,T0:r,T:n}=LAPACKtest.start_test_complex_tridiagonal_hermitian_to_real2n(),{D:i,Z:a}=LAPACKunused.numeric_jacobi_hermitian_via_real2n_final(r,1e3,1e-12),s=new MultiArray([t,t]);s.array=LAPACK.diag(i);const o=LinearAlgebra.ctranspose(a),l=MathOperation.mtimes(MathOperation.mtimes(a,s),o);console.log("=== T reconstruída via Z·D·Zᴴ ==="),console.log(MultiArray.unparse(l,e));const c=MathOperation.minus(l,r);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(c,e));let u=Complex.zero();for(let e=0;e<t;e++)for(let r=0;r<t;r++){const t=c.array[e][r];u=Complex.add(u,Complex.abs2(t))}const m=Complex.sqrt(u);console.log("||T - Z·D·Zᴴ||_F =",Complex.unparse(m,e));const h=MathOperation.mtimes(LinearAlgebra.ctranspose(a),a);let p=0;for(let e=0;e<t;e++)for(let r=0;r<t;r++){const t=h.array[e][r];p+=(e===r?Complex.realToNumber(t)-1:Complex.realToNumber(t))**2+Complex.imagToNumber(t)**2}console.log("||ZᴴZ - I||_F =",Math.sqrt(p)),console.log("=== FIM DO TESTE Jacobi via Real 2n×2n FINAL ===")};static test_jacobi_hermitian_real2n=()=>{const{evaluator:e,n:t,T0:r}=LAPACKtest.start_test_complex_tridiagonal_hermitian_to_real2n(),{D:n,V:i}=LAPACKunused.jacobi_hermitian_real2n(r.array,1e3,1e-12),a=new MultiArray([t,t]);a.array=LAPACK.diag(n);const s=new MultiArray([i.length,i.length]);s.array=i;const o=LinearAlgebra.ctranspose(s),l=MathOperation.mtimes(MathOperation.mtimes(s,a),o);console.log("=== T reconstruída via V·D·Vᴴ ==="),console.log(MultiArray.unparse(l,e));const c=MathOperation.minus(l,r);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(c,e));let u=Complex.zero();for(let e=0;e<t;e++)for(let r=0;r<t;r++){const t=c.array[e][r];u=Complex.add(u,Complex.abs2(t))}const m=Complex.sqrt(u);console.log("||T - V·D·Vᴴ||_F =",Complex.unparse(m,e));const h=MathOperation.mtimes(LinearAlgebra.ctranspose(s),s);let p=0;for(let e=0;e<t;e++)for(let r=0;r<t;r++){const t=h.array[e][r];p+=(e===r?Complex.realToNumber(t)-1:Complex.realToNumber(t))**2+Complex.imagToNumber(t)**2}console.log("||VᴴV - I||_F =",Math.sqrt(p)),console.log("=== FIM DO TESTE Jacobi via Real 2n×2n ===")};static test_jacobi_hermitian_real2n_direct=()=>{console.log("=== INÍCIO DO TESTE Jacobi (jacobi_hermitian_real2n_direct) ===");const{evaluator:e,D_orig:t,E_orig:r,T0:n}=LAPACKtest.start_test_complex_tridiagonal_hermitian_to_real2n(),{D:i,V:a}=LAPACKunused.jacobi_hermitian_real2n_direct(t,r,1e3,1e-12),s=new MultiArray([a.length,a.length]);s.array=a;const o=s.dimension[0],l=new MultiArray([o,o]);l.array=LAPACK.diag(i);const c=LinearAlgebra.ctranspose(s),u=MathOperation.mtimes(MathOperation.mtimes(s,l),c);console.log("=== T reconstruída via V·D·Vᴴ ==="),console.log(MultiArray.unparse(u,e));const m=MathOperation.minus(u,n);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(m,e));let h=Complex.zero();for(let e=0;e<o;e++)for(let t=0;t<o;t++){const r=m.array[e][t];h=Complex.add(h,Complex.abs2(r))}const p=Complex.sqrt(h);console.log("||T - V·D·Vᴴ||_F =",Complex.unparse(p,e));const d=MathOperation.mtimes(LinearAlgebra.ctranspose(s),s);let x=0;for(let e=0;e<o;e++)for(let t=0;t<o;t++){const r=d.array[e][t];x+=(e===t?Complex.realToNumber(r)-1:Complex.realToNumber(r))**2+Complex.imagToNumber(r)**2}console.log("||VᴴV - I||_F =",Math.sqrt(x)),console.log("=== FIM DO TESTE Jacobi (jacobi_hermitian_real2n_direct) ===")};static test_jacobi_hermitian_via_real2n=()=>{const{evaluator:e,n:t,T0:r,T:n}=LAPACKtest.start_test_complex_tridiagonal_hermitian_to_real2n(),{D:i,V:a}=LAPACK.jacobi_real_symmetric_dense(n.array,1e3,1e-12),s=new MultiArray([a.length/2,a.length/2]);s.array=LAPACK.real2n_to_complex_eigenvectors(a);const o=new MultiArray([t,t]);o.array=LAPACK.diag(i);const l=LinearAlgebra.ctranspose(s),c=MathOperation.mtimes(MathOperation.mtimes(s,o),l);console.log("=== T reconstruída via Z·D·Zᴴ ==="),console.log(MultiArray.unparse(c,e));const u=MathOperation.minus(c,r);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(u,e));let m=Complex.zero();for(let e=0;e<t;e++)for(let r=0;r<t;r++){const t=u.array[e][r];m=Complex.add(m,Complex.abs2(t))}const h=Complex.sqrt(m);console.log("||T - Z·D·Zᴴ||_F =",Complex.unparse(h,e));const p=MathOperation.mtimes(LinearAlgebra.ctranspose(s),s);console.log("||ZᴴZ - I||_F =",(()=>{let e=0;for(let r=0;r<t;r++)for(let n=0;n<t;n++){const t=p.array[r][n];e+=(r===n?Complex.realToNumber(t)-1:Complex.realToNumber(t))**2+Complex.imagToNumber(t)**2}return Math.sqrt(e)})()),console.log("=== FIM DO TESTE Jacobi via Real 2n×2n ===")};static test_jacobi_complex_hermitian_dense=()=>{const e=()=>Math.random()-.5,t=()=>Complex.create(e(),e()),r=r=>{const n=Array.from({length:r},()=>Array.from({length:r}));for(let i=0;i<r;i++){n[i][i]=Complex.create(e(),0);for(let e=i+1;e<r;e++){const r=t();n[i][e]=r,n[e][i]=Complex.conj(r)}}return n},n=(e,t)=>{const r=e.length,n=Array.from({length:r},()=>Array.from({length:r},()=>Complex.zero()));for(let i=0;i<r;i++)for(let a=0;a<r;a++){let s=Complex.zero();for(let n=0;n<r;n++)Complex.mulAndSumTo(s,e[i][n],t[n][a]);n[i][a]=s}return n},i=e=>{const t=e.length,r=Array.from({length:t},()=>Array.from({length:t}));for(let n=0;n<t;n++)for(let i=0;i<t;i++)r[i][n]=Complex.conj(e[n][i]);return r},a=e=>{let t=0;const r=e.length;for(let n=0;n<r;n++)for(let i=0;i<r;i++){const r=Complex.realToNumber(Complex.abs(e[n][i]));t+=r*r}return Math.sqrt(t)},s=[2,3,5];for(const e of s){console.log("===================================="),console.log(`Jacobi Hermitian Complex Test (n = ${e})`);const t=r(e),{D:s,V:o}=LAPACKunused.jacobi_complex_hermitian_dense(t),l=i(o),c=n(l,o);for(let t=0;t<e;t++)c[t][t]=Complex.sub(c[t][t],Complex.one());const u=a(c),m=n(t,o),h=n(l,m);for(let t=0;t<e;t++)h[t][t]=Complex.sub(h[t][t],s[t]);let p=0;for(let t=0;t<e;t++)for(let r=0;r<e;r++)if(t!==r){const e=Complex.realToNumber(Complex.abs(h[t][r]));p+=e*e}const d=Math.sqrt(p);let x=0;for(let t=0;t<e;t++)x=Math.max(x,Math.abs(toNumber(s[t].im)));console.log("max |Im(lambda)| =",x.toExponential(3)),console.log("||VᴴV − I||_F   =",u.toExponential(3)),console.log("||offdiag(VᴴAV)|| =",d.toExponential(3))}};static test_jacobi_hermitian_full(){const e=Evaluator.Create(),t=[2,3,2.5,1.8].map(e=>Complex.create(e)),r=[Complex.create(.3,.4),Complex.create(.1,-.2),Complex.create(-.2,.5)],n=t.length,i=LAPACK.tridiagonal_hermitian_to_dense(t,r),a=new MultiArray([n,n]);a.array=i;const s=new MultiArray([n,n]);s.array=JSON.parse(JSON.stringify(a.array));const o=LAPACKunused.jacobi_hermitian_full(a,50,1e-12),l=LinearAlgebra.ctranspose(o),c=new MultiArray([n,n]);c.array=LAPACK.diag(Array.from({length:n},(e,t)=>a.array[t][t]));const u=MathOperation.mtimes(MathOperation.mtimes(o,c),l),m=MathOperation.minus(u,s);let h=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++)h=Complex.add(h,Complex.abs2(m.array[e][t]));const p=Complex.sqrt(h);console.log("||T - Z·D·Zᴴ||_F =",Complex.unparse(p,e));const d=MathOperation.mtimes(l,o),x=new MultiArray([n,n]);x.array=LAPACK.eye(n,n);const C=MathOperation.minus(d,x);let f=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++)f=Complex.add(f,Complex.abs2(C.array[e][t]));const g=Complex.sqrt(f);console.log("||ZᴴZ - I||_F =",Complex.unparse(g,e))}static test_numeric_jacobi_hermitian_direct=()=>{const{evaluator:e,D_orig:t,E_orig:r,n,T0:i}=LAPACKtest.start_test_complex_tridiagonal_hermitian(),{D_work:a,Z:s}=LAPACKunused.numeric_jacobi_hermitian_direct(t,r,1e3,1e-12),o=new MultiArray([n,n]);o.array=LAPACK.diag(a);const l=LinearAlgebra.ctranspose(s),c=MathOperation.mtimes(MathOperation.mtimes(s,o),l);console.log("=== T reconstruída via Z·D·Zᴴ ==="),console.log(MultiArray.unparse(c,e));const u=MathOperation.minus(c,i);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(u,e));let m=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++)m=Complex.add(m,Complex.abs2(u.array[e][t]));const h=Complex.sqrt(m);console.log("||T - Z·D·Zᴴ||_F =",Complex.unparse(h,e));const p=MathOperation.mtimes(l,s);let d=0;for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=p.array[e][t],n=e===t?Complex.realToNumber(r)-1:Complex.realToNumber(r);d+=n*n+Complex.imagToNumber(r)*Complex.imagToNumber(r)}console.log("||ZᴴZ - I||_F =",Math.sqrt(d)),console.log("=== FIM DO TESTE Jacobi Hermitiano Direto ===")};static test_apply_givens_tridiagonal=()=>{const{evaluator:e,D_orig:t,E_orig:r,T0:n}=LAPACKtest.start_test_complex_tridiagonal_hermitian(),i=t,a=r,{c:s,s:o}=LAPACKunused.complexGivens(Complex.sub(i[0],i[1]),a[0]);LAPACKunused.applyGivensTridiagonal(i,a,0,s,o);const l=new MultiArray([3,3]);l.array=LAPACK.tridiagonal_hermitian_to_dense(i,a);const c=new MultiArray([3,3]);c.array=LAPACK.eye(3,3),c.array[0][0]=s,c.array[0][1]=o,c.array[1][0]=Complex.neg(Complex.conj(o)),c.array[1][1]=Complex.conj(s);const u=LinearAlgebra.ctranspose(c),m=MathOperation.mtimes(MathOperation.mtimes(u,n),c),h=MathOperation.minus(l,m);console.log("T1 − Gᴴ·T0·G (deve ser ~0):"),console.log(MultiArray.unparse(h,e))};static test_numeric_qr_hermitian_tridiagonal=()=>{const e=Evaluator.Create(),t=[2,3,2.5,1.8].map(e=>Complex.create(e)),r=[Complex.create(.3,.4),Complex.create(.1,-.2),Complex.create(-.2,.5)],n=t.length,i=new MultiArray([n,n]);i.array=LAPACK.tridiagonal_hermitian_to_dense(t,r);const a=t.map(e=>Complex.copy(e)),s=r.map(e=>Complex.copy(e)),o=LAPACKunused.numeric_qr_hermitian_tridiagonal(a,s,2e3,1e-12),l=new MultiArray([n,n]);l.array=o;const c=new MultiArray([n,n]);c.array=LAPACK.diag(a);const u=LinearAlgebra.ctranspose(l),m=MathOperation.mtimes(MathOperation.mtimes(l,c),u),h=MathOperation.minus(m,i);let p=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++)p=Complex.add(p,Complex.abs2(h.array[e][t]));console.log("||T − Z·D·Zᴴ||_F =",Complex.unparse(Complex.sqrt(p),e));const d=MathOperation.mtimes(u,l);let x=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=e===t?Complex.one():Complex.zero();x=Complex.add(x,Complex.abs2(Complex.sub(d.array[e][t],r)))}console.log("||ZᴴZ − I||_F =",Complex.unparse(Complex.sqrt(x),e))};static test_qr_hermitian_tridiagonal_full(){const e=Evaluator.Create(),t=[Complex.create(2),Complex.create(3),Complex.create(2.5),Complex.create(1.8)],r=[Complex.create(.3,.4),Complex.create(.1,-.2),Complex.create(-.2,.5)],n=t.length,i=t.map(e=>Complex.copy(e)),a=r.map(e=>Complex.copy(e)),s=LAPACK.tridiagonal_hermitian_to_dense(t,r),o=new MultiArray([n,n]);o.array=s,console.log("=== T original ==="),console.log(MultiArray.unparse(o,e));const l=new MultiArray([n,n]);l.array=LAPACK.eye(n,n);for(let e=0;e<50;e++)LAPACKunused.qr_step_tridiagonal_hermitian(i,a,l.array);const c=new MultiArray([n,n]);c.array=LAPACK.diag(i);const u=LinearAlgebra.ctranspose(l),m=MathOperation.mtimes(MathOperation.mtimes(l,c),u);console.log("=== T reconstruída (Z·D·Zᴴ) ==="),console.log(MultiArray.unparse(m,e));const h=MathOperation.minus(m,o);console.log("=== Diferença Trec - T original ==="),console.log(MultiArray.unparse(h,e));let p=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=h.array[e][t];p=Complex.add(p,Complex.abs2(r))}const d=Complex.sqrt(p);console.log("||T - Z·D·Zᴴ||_F =",Complex.unparse(d,e));const x=MathOperation.mtimes(u,l),C=new MultiArray([n,n]);C.array=LAPACK.eye(n,n);const f=MathOperation.minus(x,C);let g=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=f.array[e][t];g=Complex.add(g,Complex.abs2(r))}const _=Complex.sqrt(g);console.log("||ZᴴZ − I||_F =",Complex.unparse(_,e)),console.log("=== FIM DO TESTE QR HERMITIANO ===")}static test_tridiagonal_similarity=(e,t)=>{const r=e.length,n=Evaluator.Create(),i=LAPACK.tridiagonal_hermitian_to_dense(e,t),a=new MultiArray([r,r]);a.array=i;const{D:s,V:o}=LAPACKunused.numeric_steqr_tridiagonal_bulge(e,t,2e3),l=new MultiArray([r,r]);l.array=o;const c=new MultiArray([r,r]);c.array=LAPACK.diag(s);const u=LinearAlgebra.ctranspose(l),m=MathOperation.mtimes(MathOperation.mtimes(u,c),l),h=MathOperation.minus(m,a);let p=Complex.zero();for(let e=0;e<r;e++)for(let t=0;t<r;t++){const r=h.array[e][t];p=Complex.add(p,Complex.power(Complex.abs(r),Complex.create(2)))}p=Complex.sqrt(p),console.log("T original:"),console.log(MultiArray.unparse(a,n)),console.log("T reconstruída (Zᴴ·D·Z):"),console.log(MultiArray.unparse(m,n)),console.log("Diferença T_approx - T0:"),console.log(MultiArray.unparse(h,n)),console.log("Norma Frobenius da diferença:",Complex.unparse(Complex.real(p),n))};static test_orthonormality=e=>{const t=e.dimension[0],r=Array.from({length:t},()=>Array(t).fill(0));for(let n=0;n<t;n++)for(let i=0;i<t;i++){let a=0;for(let r=0;r<t;r++)a+=Complex.realToNumber(Complex.mul(Complex.conj(e.array[r][n]),e.array[r][i]));r[n][i]=a}let n=0,i=0;for(let e=0;e<t;e++)for(let a=0;a<t;a++)e===a?i=Math.max(i,Math.abs(1-r[e][e])):n=Math.max(n,Math.abs(r[e][a]));return{maxOffDiag:n,maxDiagDeviation:i}};static diag_eigenpairs=(e,t,r)=>{const n=e.length,i=[];for(let a=0;a<n;a++){const s=new Array(n);for(let e=0;e<n;e++)s[e]=t.array[e][a];const o=new Array(n).fill(Complex.zero());for(let t=0;t<n;t++){let r=Complex.zero();for(let i=0;i<n;i++)r=Complex.add(r,Complex.mul(e[t][i],s[i]));o[t]=r}let l=Complex.zero();for(let e=0;e<n;e++)l=Complex.add(l,Complex.mul(Complex.conj(s[e]),o[e]));let c=Complex.zero();for(let e=0;e<n;e++)c=Complex.add(c,Complex.mul(Complex.conj(s[e]),s[e]));const u=Complex.rdiv(l,c),m=r.array[a][0],h=Complex.sub(m,u),p=Complex.realToNumber(Complex.abs(h));let d=0;for(let e=0;e<n;e++){const t=o[e],r=Complex.mul(m,s[e]),n=Complex.sub(t,r),i=Complex.realToNumber(Complex.abs(n));d+=i*i}const x=Math.sqrt(d);i.push({j:a,lambda:m,rq:u,abs_lambda_minus_rq:p,resnorm:x})}return i.forEach(e=>{}),i};static match_evals_to_rayleighs=(e,t)=>{const r=e.length,n=(e.map((e,t)=>({val:e,i:t,re:Complex.realToNumber(Complex.real(e))})),t.map((e,t)=>({val:e,i:t,re:Complex.realToNumber(Complex.real(e))})),Array(r).fill(!1)),i=[];for(let a=0;a<r;a++){let s=-1,o=1/0;for(let i=0;i<r;i++){if(n[i])continue;const r=Complex.sub(e[a],t[i]),l=Complex.realToNumber(Complex.abs(r));l<o&&(o=l,s=i)}s>=0&&(n[s]=!0,i.push({evalIndex:a,rqIndex:s,diff:o}))}return console.log("match_evals_to_rayleighs mapping:"),i.forEach(r=>{const n=Complex.realToNumber(Complex.real(e[r.evalIndex])),i=Complex.realToNumber(Complex.real(t[r.rqIndex]));console.log(`eval idx=${r.evalIndex} (val=${n})  -> rq idx=${r.rqIndex} (val=${i})  diff=${r.diff}`)}),i};static test_numeric_qr_bulge_chasing_hermitian=()=>{const e=Evaluator.Create(),t=[2,3,2.5,1.8].map(e=>Complex.create(e)),r=[Complex.create(.3,.4),Complex.create(.1,-.2),Complex.create(-.2,.5)],n=t.length,i=LAPACK.tridiagonal_hermitian_to_dense(t,r),a=new MultiArray([n,n]);a.array=i,console.log("=== T original ==="),console.log(MultiArray.unparse(a,e));const s=t.map(e=>Complex.copy(e)),o=r.map(e=>Complex.copy(e)),l=LAPACKunused.numeric_qr_bulge_chasing_hermitian_refined(s,o,1e3,1e-12),c=new MultiArray([n,n]);c.array=l;const u=new MultiArray([n,n]);u.array=LAPACK.diag(s);const m=LinearAlgebra.ctranspose(c),h=MathOperation.mtimes(MathOperation.mtimes(c,u),m);console.log("=== T reconstruída (Z·D·Zᴴ) ==="),console.log(MultiArray.unparse(h,e));const p=MathOperation.minus(h,a);let d=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++)d=Complex.add(d,Complex.abs2(p.array[e][t]));console.log("||T − Z·D·Zᴴ||_F =",Complex.unparse(Complex.sqrt(d),e));const x=MathOperation.mtimes(m,c);let C=Complex.zero();for(let e=0;e<n;e++)for(let t=0;t<n;t++){const r=e===t?Complex.one():Complex.zero(),n=Complex.sub(x.array[e][t],r);C=Complex.add(C,Complex.abs2(n))}console.log("||ZᴴZ − I||_F =",Complex.unparse(Complex.sqrt(C),e));let f=Complex.zero();for(let e=0;e<o.length;e++)f=Complex.add(f,Complex.abs2(o[e]));console.log("||offdiag(T_final)||_2 =",Complex.unparse(Complex.sqrt(f),e));const g=LAPACK.tridiagonal_hermitian_to_dense(s,o),_=new MultiArray([n,n]);_.array=g,console.log("=== T final implícito (D_work, E_work) ==="),console.log(MultiArray.unparse(_,e)),console.log("=== FIM DO TESTE ===")};static test_complex_givens_unitarity=()=>{const e=Evaluator.Create(),t=Complex.create(2,-1),r=Complex.create(.5,.8),{c:n,s:i}=LAPACKunused.complexGivens(t,r),a=new MultiArray([2,2]);a.array=[[n,i],[Complex.neg(Complex.conj(i)),Complex.conj(n)]];const s=LinearAlgebra.ctranspose(a),o=MathOperation.mtimes(s,a);console.log("Gᴴ·G (deve ser identidade):"),console.log(MultiArray.unparse(o,e))};static test_apply_givens_to_Z=()=>{const e=Evaluator.Create(),t=new MultiArray([4,4]);t.array=LAPACK.eye(4,4);const{c:r,s:n}=LAPACKunused.complexGivens(Complex.create(1.2,-.4),Complex.create(.7,.9));LAPACKunused.applyGivensToZ(t,1,r,n);const i=LinearAlgebra.ctranspose(t),a=MathOperation.mtimes(i,t);console.log("Zᴴ·Z após uma rotação:"),console.log(MultiArray.unparse(a,e))}}const src_LAPACKtest={LAPACKtest},LAPACK_LAPACKConfigKeyTable=["maxIterationFactor"],LAPACK_defaultSettings={maxIterationFactor:1e3};class LAPACK{static defaultSettings=Object.assign({},LAPACK_defaultSettings);static settings=LAPACK.defaultSettings;static set=e=>{Object.entries(e).forEach(e=>{if(!LAPACK_LAPACKConfigKeyTable.includes(e[0]))throw new Error(`LAPACK.set: invalid configuration parameter: ${e[0]}`);LAPACK.settings[e[0]]=e[1]})};static isHermitian=e=>{const t=e.length;if(0===t)return!0;if(e[0].length!==t)return!1;const r=EXPECT_TOL;for(let n=0;n<t;n++){const i=e[n][n];if(Math.abs(toNumber(i.im))>r)return!1;for(let i=n+1;i<t;i++){const t=e[n][i],a=e[i][n],s=toNumber(t.re)-toNumber(a.re),o=toNumber(t.im)+toNumber(a.im);if(Math.hypot(s,o)>r)return!1}}return!0};static isPositiveDefinite=e=>{const t=e.length;if(0===t)return!0;if(e[0].length!==t)return!1;if(!LAPACK.isHermitian(e))return!1;const r=EXPECT_TOL,n=Array.from({length:t},(r,n)=>Array.from({length:t},(t,r)=>Complex.copy(e[n][r])));for(let e=0;e<t;e++){let i=n[e][e];for(let t=0;t<e;t++){const r=n[e][t];i=Complex.sub(i,Complex.mul(r,Complex.conj(r)))}if(Math.abs(toNumber(i.im))>r)return!1;if(toNumber(i.re)<=r)return!1;const a=Complex.create(Math.sqrt(toNumber(i.re)),0);n[e][e]=a;for(let r=e+1;r<t;r++){let t=n[r][e];for(let i=0;i<e;i++)t=Complex.sub(t,Complex.mul(n[r][i],Complex.conj(n[e][i])));n[r][e]=Complex.rdiv(t,a)}}return!0};static laswp=(e,t,r,n,i,a,s,o)=>{const l=t[0],c=t[1],u=2===t.length?1:t.slice(2).reduce((e,t)=>e*t,1),m=void 0===s?0:s,h=void 0===o?c-1:o;if(!i||0===i.length)return;const p=0===Math.min(...i);if(a>0)for(let t=r;t<=n;t+=a){const r=t-1,n=i[t-1],a=p?n:n-1;if(a!==r)for(let t=0;t<u;t++){const n=t*l+r,i=t*l+a;for(let t=m;t<=h;t++){const r=e[n][t];e[n][t]=e[i][t],e[i][t]=r}}}else for(let t=r;t>=n;t+=a){const r=t-1,n=i[t-1],a=p?n:n-1;if(a!==r)for(let t=0;t<u;t++){const n=t*l+r,i=t*l+a;for(let t=m;t<=h;t++){const r=e[n][t];e[n][t]=e[i][t],e[i][t]=r}}}};static laswp_rows=(e,t,r,n)=>{const i=r+1,a=i,s=[];s[i-1]=n+1,LAPACK.laswp(e,t,i,a,s,1)};static laswp_cols=(e,t,r,n)=>{const i=t[0]*(2===t.length?1:t.slice(2).reduce((e,t)=>e*t,1));for(let t=0;t<i;t++){const i=e[t][r];e[t][r]=e[t][n],e[t][n]=i}};static eye=(...e)=>{const t=e.flat(),r=t[0],n=t[1];if(2===t.length)return Array.from({length:r},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero()));{const e=t.slice(2).reduce((e,t)=>e*t,1);return Array.from({length:r*e},(e,t)=>{const i=t%r;return Array.from({length:n},(e,t)=>i===t?Complex.one():Complex.zero())})}};static fillFactory=e=>(...t)=>{const r=t.flat();return Array.from({length:r[0]*r.slice(2).reduce((e,t)=>e*t,1)},t=>Array.from({length:r[1]},e))};static zeros=LAPACK.fillFactory(e=>Complex.zero());static ones=LAPACK.fillFactory(e=>Complex.one());static diag=(e,t=0,...r)=>{const n=r.length>0?r.flat():[e.length,e.length],i=n[0],a=n[1];if(2===n.length)return Array.from({length:i},(r,n)=>Array.from({length:a},(r,i)=>n+t===i?e[n]:Complex.zero()));{const r=n.slice(2).reduce((e,t)=>e*t,1);return Array.from({length:i*r},(r,n)=>{const s=n%i;return Array.from({length:a},(r,n)=>s+t===n?e[s]:Complex.zero())})}};static from_diag=(e,t=0)=>{const r=[];for(let n=0;n<e.length-Math.abs(t);n++)r[n]=t>0?e[n][n+t]:e[n-t][n];return r};static lassq=e=>{const t=e.dimension[0],r=e.dimension[1];let n=Complex.zero(),i=Complex.one();for(let a=0;a<t;a++)for(let t=0;t<r;t++){const r=e.array[a][t];if(!Complex.realIsZero(r)){const e=Complex.abs(r);if(Complex.lt(n,e)){if(!Complex.realIsZero(n)){const t=Complex.rdiv(n,e);Complex.mulAndSumTo(i,i,Complex.mul(t,t))}n=e}else{const t=Complex.rdiv(e,n);Complex.mulAndSumTo(i,t,t)}}}return{scale:n,sumsq:i}};static lange=(e,t)=>{const r=t.dimension[0],n=t.dimension[1];switch(e){case"F":{const{scale:e,sumsq:r}=LAPACK.lassq(t);return Complex.realIsZero(e)?Complex.zero():Complex.mul(e,Complex.sqrt(r))}case"M":{let e=Complex.zero();for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=Complex.abs(t.array[i][r]);Complex.lt(e,n)&&(e=n)}return e}default:throw new Error(`lange: norm '${e}' not implemented`)}};static triu_inplace=e=>{const t=e.dimension.length>2?e.dimension.slice(2).reduce((e,t)=>e*t,1):1,r=e.dimension[0];for(let n=0;n<t;n++){const t=n*r;for(let r=0;r<e.dimension[0];r++){const n=e.array[t+r];for(let t=0;t<Math.min(r,e.dimension[1]);t++)n[t]=Complex.zero()}}MultiArray.setType(e)};static tril_inplace=e=>{const t=e.dimension.length>2?e.dimension.slice(2).reduce((e,t)=>e*t,1):1,r=e.dimension[0];for(let n=0;n<t;n++){const t=n*r;for(let r=0;r<e.dimension[0];r++){const n=e.array[t+r];for(let t=r+1;t<e.dimension[1];t++)n[t]=Complex.zero()}}MultiArray.setType(e)};static trsm_left_upper_block=(e,t,r)=>{const n=e[0].length;for(let i=t+r;i<n;i++)for(let n=r-1;n>=0;n--){const a=t+n;let s=e[a][i];for(let o=n+1;o<r;o++){const r=e[a][t+o],n=e[t+o][i];s=Complex.sub(s,Complex.mul(r,n))}const o=e[a][t+n];e[a][i]=Complex.rdiv(s,o)}};static lapmt_matrix=e=>{const t=e.length,r=new MultiArray([t,t]);for(let n=0;n<t;n++){const t=e[n];r.array[t][n]=Complex.one()}return MultiArray.setType(r),r};static lapmt_apply=(e,t)=>{const r=e.dimension[0],n=e.dimension[1];if(t.length!==n)throw new EvalError(`lapmt_apply: jpvt length (${t.length}) must match number of columns (${n}).`);const i=new Array(r);for(let t=0;t<r;t++)i[t]=e.array[t].slice();for(let a=0;a<n;a++){const n=t[a];for(let t=0;t<r;t++)e.array[t][a]=i[t][n]}MultiArray.setType(e)};static larfg_original=e=>{const t=e.length;if(0===t)return{tau:Complex.zero(),v:[],phi:Complex.one(),alpha:Complex.zero()};const r=e[0];let n=Complex.zero();for(let r=1;r<t;r++){const t=Complex.abs(e[r]);Complex.mulAndSumTo(n,t,t)}const i=Complex.abs(r),a=Complex.realIsZero(i)?Complex.one():Complex.rdiv(r,i);if(1===t||Complex.realIsZero(Complex.abs(n))){const e=Complex.zero(),n=new Array(t);n[0]=Complex.one();for(let e=1;e<t;e++)n[e]=Complex.zero();return{tau:e,v:n,phi:a,alpha:r}}{const i=Complex.sqrt(Complex.add(Complex.mul(r,Complex.conj(r)),n)),s=Complex.mul(Complex.neg(a),i),o=Complex.rdiv(Complex.sub(s,r),s),l=Complex.sub(r,s),c=new Array(t);c[0]=Complex.one();for(let r=1;r<t;r++)c[r]=Complex.rdiv(e[r],l);return{tau:o,v:c,phi:a,alpha:s}}};static larfg_complex(e,t){const r=t.length;let n=Complex.zero();for(let e=0;e<r;e++){const r=Complex.abs(t[e]);Complex.mulAndSumTo(n,r,r)}const i=Complex.sqrt(n);if(Complex.realIsZero(i)&&Complex.imagIsZero(e))return{alpha:e,tau:Complex.zero()};const a=Complex.abs(e),s=Complex.mul(a,a),o=Complex.sqrt(Complex.add(s,Complex.mul(i,i)));let l;if(Complex.realIsZero(a))l=Complex.neg(o);else{const t=Complex.rdiv(e,a);l=Complex.neg(Complex.mul(t,o))}const c=Complex.rdiv(Complex.sub(l,e),l),u=Complex.sub(e,l);for(let e=0;e<r;e++)t[e]=Complex.rdiv(t[e],u);return{alpha:l,tau:c}}static dotc_col=(e,t,r)=>{const n=e.dimension[0];if(r+1>=n)return Complex.zero();{const i=e.array.slice(r+1,n).map(e=>e[t]);return BLAS.dotc(i,i)}};static dotc_row=(e,t,r)=>{const n=e.dimension[1];if(r+1>=n)return Complex.zero();{const i=e.array[t].slice(r+1,n);return BLAS.dotc(i,i)}};static larfg_left=(e,t,r)=>{const n=t-r,i=e.array[r][r],a=LAPACK.dotc_col(e,r,r),s=Complex.abs(i),o=Complex.realIsZero(s)?Complex.one():Complex.rdiv(i,s);if(1===n||Complex.realIsZero(Complex.abs(a))){const e=Complex.zero(),t=new Array(n);t[0]=Complex.one();for(let e=1;e<n;e++)t[e]=Complex.zero();return{tau:e,v:t,phi:o,alpha:i}}{const t=Complex.sqrt(Complex.add(Complex.mul(i,Complex.conj(i)),a)),s=Complex.mul(Complex.neg(o),t),l=Complex.rdiv(Complex.sub(s,i),s),c=Complex.sub(i,s),u=new Array(n);u[0]=Complex.one();for(let t=1;t<n;t++)u[t]=Complex.rdiv(e.array[r+t][r],c);return{tau:l,v:u,phi:o,alpha:s}}};static larfg_right=(e,t,r)=>{const n=t-r,i=e.array[r][r];let a=Complex.zero();for(let t=1;t<n;t++){const n=e.array[r][r+t];a=Complex.add(a,Complex.mul(n,Complex.conj(n)))}const s=Complex.abs(i),o=Complex.realIsZero(s)?Complex.one():Complex.rdiv(i,s);if(1===n||Complex.realIsZero(Complex.abs(a))){const e=Complex.zero(),t=new Array(n).fill(Complex.zero());return t[0]=Complex.one(),{tau:e,v:t,phi:o,alpha:i}}const l=Complex.sqrt(Complex.add(Complex.mul(i,Complex.conj(i)),a)),c=Complex.mul(Complex.neg(o),l),u=Complex.rdiv(Complex.sub(c,i),c),m=new Array(n);m[0]=Complex.one();const h=Complex.sub(i,c);for(let t=1;t<n;t++)m[t]=Complex.rdiv(e.array[r][r+t],h);return{tau:u,v:m,phi:o,alpha:c}};static larfg_old=(e,t,r,n)=>{const i=r-n,a=t.array[n][n],s=Complex.abs(a),o=Complex.realIsZero(s)?Complex.one():Complex.rdiv(a,s),l="L"===e?LAPACK.dotc_col(t,n,n):LAPACK.dotc_row(t,n,n);if(1===i||Complex.realIsZero(Complex.abs(l))){const e=Complex.zero(),t=new Array(i).fill(Complex.zero());return t[0]=Complex.one(),{tau:e,v:t,phi:o,alpha:a}}const c=Complex.sqrt(Complex.add(Complex.mul(a,Complex.conj(a)),l)),u=Complex.mul(Complex.neg(o),c),m=Complex.rdiv(Complex.sub(u,a),u),h=Complex.sub(a,u),p=new Array(i);if(p[0]=Complex.one(),"L"===e)for(let e=1;e<i;e++)p[e]=Complex.rdiv(t.array[n+e][n],h);else for(let e=1;e<i;e++)p[e]=Complex.rdiv(t.array[n][n+e],h);return{tau:m,v:p,phi:o,alpha:u}};static larfg=(e,t,r,n)=>{const i=r-n,a=new Array(i);if(a[0]=t.array[n][n],"L"===e)for(let e=1;e<i;e++)a[e]=t.array[n+e][n];else for(let e=1;e<i;e++)a[e]=t.array[n][n+e];const s=a[0],o=Complex.abs(s),l=Complex.realIsZero(o)?Complex.one():Complex.rdiv(s,o);let c=Complex.zero();for(let e=1;e<i;e++)c=Complex.add(c,Complex.mul(a[e],Complex.conj(a[e])));if(1===i||Complex.realIsZero(Complex.abs(c))){const e=Complex.zero(),t=new Array(i).fill(Complex.zero());return t[0]=Complex.one(),{tau:e,v:t,phi:l,alpha:s}}const u=Complex.sqrt(Complex.add(Complex.mul(s,Complex.conj(s)),c)),m=Complex.mul(Complex.neg(l),u),h=Complex.rdiv(Complex.sub(m,s),m),p=Complex.sub(s,m),d=new Array(i);d[0]=Complex.one();for(let e=1;e<i;e++)d[e]=Complex.rdiv(a[e],p);return{tau:h,v:d,phi:l,alpha:m}};static larfgLQ=(e,t,r)=>{const n=r-t,i=new Array(n);i[0]=e.array[t][t];for(let r=1;r<n;r++)i[r]=e.array[t][t+r];let a=Complex.zero();for(let e=1;e<n;e++)a=Complex.add(a,Complex.mul(i[e],Complex.conj(i[e])));if(1===n||Complex.realIsZero(Complex.abs(a))){const e=Complex.zero(),t=new Array(n).fill(Complex.zero());return t[0]=Complex.one(),{tau:e,v:t,alpha:i[0]}}const s=i[0],o=Complex.sqrt(Complex.add(Complex.mul(s,Complex.conj(s)),a)),l=Complex.neg(Complex.mul(s,Complex.rdiv(o,Complex.abs(o)))),c=Complex.rdiv(Complex.sub(l,s),l),u=Complex.sub(s,l),m=new Array(n);m[0]=Complex.one();for(let e=1;e<n;e++)m[e]=Complex.rdiv(i[e],u);return{tau:c,v:m,alpha:l}};static larf_left=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=t.length;for(let s=i;s<e.dimension[1];s++){let i=Complex.zero();for(let r=0;r<a;r++)Complex.mulAndSumTo(i,Complex.conj(t[r]),e.array[n+r][s]);if(i=Complex.mul(r,i),!Complex.realIsZero(Complex.abs(i)))for(let r=0;r<a;r++)e.array[n+r][s]=Complex.sub(e.array[n+r][s],Complex.mul(t[r],i))}};static larf(e,t,r,n,i,a){if(Complex.realIsZero(Complex.abs(n)))return;const s=t.dimension[0],o=t.dimension[1],l=r.length;if("L"===e){const e=new Array(o-a).fill(Complex.zero());for(let n=0;n<o-a;n++){let s=Complex.zero();for(let e=0;e<l;e++){const o=t.array[i+e][a+n];Complex.mulAndSumTo(s,Complex.conj(r[e]),o)}e[n]=s}for(let s=0;s<l;s++){const l=r[s],c=t.array[i+s];for(let t=0;t<o-a;t++)c[a+t]=Complex.sub(c[a+t],Complex.mul(n,Complex.mul(l,e[t])))}}else{const e=s-i,o=r.length,l=new Array(e);for(let n=0;n<e;n++){let e=Complex.zero();const s=t.array[i+n];for(let t=0;t<o;t++)Complex.mulAndSumTo(e,s[a+t],Complex.conj(r[t]));l[n]=e}for(let s=0;s<e;s++){const e=l[s];if(Complex.realIsZero(Complex.abs(e)))continue;const c=t.array[i+s];for(let t=0;t<o;t++)c[a+t]=Complex.sub(c[a+t],Complex.mul(n,Complex.mul(e,r[t])))}}}static larf_right=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=e.dimension[0],s=t.length;for(let o=n;o<a;o++){let n=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(n,e.array[o][i+r],Complex.conj(t[r]));if(n=Complex.mul(r,n),!Complex.realIsZero(Complex.abs(n)))for(let r=0;r<s;r++)e.array[o][i+r]=Complex.sub(e.array[o][i+r],Complex.mul(n,t[r]))}};static larf_right_adjoint=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=e.dimension[0],s=t.length,o=new Array(a-n).fill(Complex.zero());for(let r=n;r<a;r++){let a=Complex.zero();for(let n=0;n<s;n++)a=Complex.add(a,Complex.mul(e.array[r][i+n],t[n]));o[r-n]=a}const l=Complex.conj(r);for(let r=n;r<a;r++)for(let a=0;a<s;a++){const s=Complex.mul(l,Complex.mul(o[r-n],Complex.conj(t[a])));e.array[r][i+a]=Complex.sub(e.array[r][i+a],s)}};static larf_left_block=(e,t,r,n,i,a)=>{if(Complex.realIsZero(Complex.abs(r)))return;const s=e.dimension[0],o=e.dimension[1],l=t.length;if(n<0||n>=s)throw new Error("larf_left_block: invalid rowStart");if(i<0||i>=o)throw new Error("larf_left_block: invalid colStart");if(l!==s-n)throw new Error("larf_left_block: v length must equal m - rowStart");const c=Math.max(1,Math.floor(a??BLAS.settings.blockSize)),u=new MultiArray([l,1]);for(let e=0;e<l;e++)u.array[e][0]=t[e];const m=new MultiArray([1,l]);for(let e=0;e<l;e++)m.array[0][e]=Complex.conj(t[e]);for(let t=i;t<o;t+=c){const i=Math.min(t+c,o)-t,a=new MultiArray([l,i]);for(let r=0;r<l;r++)for(let s=0;s<i;s++)a.array[r][s]=e.array[n+r][t+s];const s=new MultiArray([1,i]);BLAS.gemm_block(m.array,a.array,s.array,Complex.one(),Complex.zero(),c);for(let e=0;e<i;e++)s.array[0][e]=Complex.mul(r,s.array[0][e]);for(let e=0;e<l;e++){const t=u.array[e][0];if(!Complex.realIsZero(Complex.abs(t)))for(let r=0;r<i;r++){const n=Complex.mul(t,s.array[0][r]);a.array[e][r]=Complex.sub(a.array[e][r],n)}}for(let r=0;r<l;r++)for(let s=0;s<i;s++)e.array[n+r][t+s]=a.array[r][s]}};static geqr2=e=>{const t=MultiArray.copy(e),r=t.dimension[0],n=t.dimension[1],i=Math.min(r,n),a=new Array(i),s=new Array(i);for(let e=0;e<i;e++){const{tau:i,v:o,phi:l,alpha:c}=LAPACK.larfg("L",t,r,e);t.array[e][e]=c;for(let r=1;r<o.length;r++)t.array[e+r][e]=Complex.mul(i,o[r]);e+1<n&&LAPACK.larf("L",t,o,i,e,e+1),a[e]=i,s[e]=l}return MultiArray.setType(t),{R:t,taus:a,phis:s}};static geqp2=e=>{const t=e.dimension[0],r=e.dimension[1],n=new Array(Math.min(t,r)),i=new Array(Math.min(t,r)),a=new Array(r);for(let e=0;e<r;e++)a[e]=e;const s=new Array(r),o=new Array(r);for(let t=0;t<r;t++){const r=BLAS.nrm2(e.array.map(e=>e[t]));s[t]=r,o[t]=r}const l=Math.min(t,r);for(let c=0;c<l;c++){let l=c,u=s[c];for(let e=c+1;e<r;e++)Complex.toBoolean(Complex.gt(s[e],u))&&(u=s[e],l=e);if(l!==c){for(let r=0;r<t;r++){const t=e.array[r][c];e.array[r][c]=e.array[r][l],e.array[r][l]=t}const r=s[c];s[c]=s[l],s[l]=r;const n=o[c];o[c]=o[l],o[l]=n;const i=a[c];a[c]=a[l],a[l]=i}const{tau:m,v:h,alpha:p,phi:d}=LAPACK.larfg("L",e,t,c);n[c]=m,i[c]=d,e.array[c][c]=p;for(let t=1;t<h.length;t++)e.array[c+t][c]=Complex.mul(m,h[t]);c+1<r&&LAPACK.larf("L",e,h,m,c,c+1);for(let n=c+1;n<r;n++){if(Complex.toBoolean(Complex.eq(s[n],Complex.zero())))continue;const r=Complex.abs(e.array[c][n]),i=Complex.rdiv(r,s[n]),a=Complex.sub(Complex.one(),Complex.mul(i,i)),l=Complex.toBoolean(Complex.gt(a,Complex.zero()))?a:Complex.zero();if(s[n]=Complex.mul(s[n],Complex.sqrt(l)),Complex.toBoolean(Complex.le(s[n],Complex.mul(Complex.onediv2(),o[n])))){const r=BLAS.nrm2(e.array.slice(c+1,t).map(e=>e[n]));s[n]=r,o[n]=r}}}return MultiArray.setType(e),{R:e,taus:n,phis:i,jpvt:a}};static geqp3=e=>{const t=MultiArray.copy(e),r=t.dimension[0],n=t.dimension[1],i=Math.min(r,n),a=new Array(i),s=new Array(i),o=new Array(n);for(let e=0;e<n;e++)o[e]=e;const l=new Array(n),c=new Array(n);for(let e=0;e<n;e++){let n=Complex.zero();for(let i=0;i<r;i++){const r=t.array[i][e],a=Complex.abs(r);Complex.mulAndSumTo(n,a,a)}const i=Complex.sqrt(n);l[e]=i,c[e]=i}for(let e=0;e<i;e++){let i=e,u=l[e];for(let t=e+1;t<n;t++)Complex.toBoolean(Complex.gt(l[t],u))&&(u=l[t],i=t);if(i!==e){for(let n=0;n<r;n++){const r=t.array[n][e];t.array[n][e]=t.array[n][i],t.array[n][i]=r}const n=o[e];o[e]=o[i],o[i]=n;const a=l[e];l[e]=l[i],l[i]=a;const s=c[e];c[e]=c[i],c[i]=s}const{tau:m,v:h,phi:p,alpha:d}=LAPACK.larfg("L",t,r,e);if(t.array[e][e]=d,Complex.realIsZero(Complex.abs(m)))for(let r=1;r<h.length;r++)t.array[e+r][e]=Complex.zero();else for(let r=1;r<h.length;r++)t.array[e+r][e]=Complex.mul(m,h[r]);e+1<n&&!Complex.realIsZero(Complex.abs(m))&&LAPACK.larf("L",t,h,m,e,e+1),a[e]=m,s[e]=p;for(let n=e;n>=0;n--){const e=r-n,i=new Array(e);i[0]=Complex.one();const s=a[n];if(Complex.realIsZero(Complex.abs(s)))for(let t=1;t<e;t++)i[t]=Complex.zero();else for(let r=1;r<e;r++)i[r]=Complex.rdiv(t.array[n+r][n],s)}for(let i=e+1;i<n;i++)if(Complex.toBoolean(Complex.ne(l[i],Complex.zero()))){const n=t.array[e][i],a=Complex.abs(n),s=Complex.sub(Complex.one(),Complex.rdiv(Complex.mul(a,a),Complex.mul(l[i],l[i]))),o=Complex.toBoolean(Complex.gt(s,Complex.zero()))?Complex.sqrt(s):Complex.zero(),u=Complex.mul(l[i],o),m=Complex.onediv2();if(Complex.toBoolean(Complex.le(u,Complex.mul(m,c[i])))){let n=Complex.zero();for(let a=e+1;a<r;a++){const e=t.array[a][i],r=Complex.abs(e);Complex.mulAndSumTo(n,r,r)}const a=Complex.sqrt(n);l[i]=a,c[i]=a}else l[i]=u}}return MultiArray.setType(t),{R:t,taus:a,phis:s,jpvt:o}};static gelq2_final=e=>{const t=MultiArray.copy(e),r=t.dimension[0],n=t.dimension[1],i=Math.min(r,n),a=new Array(i);for(let e=0;e<i;e++){const{tau:i,v:s,alpha:o}=LAPACK.larfgLQ(t,e,n);t.array[e][e]=o;for(let r=1;r<s.length;r++)t.array[e][e+r]=s[r];e+1<r&&!Complex.realIsZero(Complex.abs(i))&&LAPACK.larf("R",t,s,i,e+1,e),a[e]=i}return MultiArray.setType(t),{L:t,taus:a}};static gelq2=e=>{const t=e.dimension[0],r=e.dimension[1],n=Math.min(t,r),i=new Array(n),a=new Array(n);for(let s=0;s<n;s++){const{tau:n,v:o,alpha:l,phi:c}=LAPACK.larfg("R",e,r,s);i[s]=n,a[s]=c,e.array[s][s]=l;for(let t=1;t<o.length;t++)e.array[s][s+t]=o[t];s+1<t&&!Complex.realIsZero(Complex.abs(n))&&LAPACK.larf("R",e,o,n,s+1,s)}return MultiArray.setType(e),{L:e,taus:i,phis:a}};static gelq2_nova=e=>{const t=e.dimension[0],r=e.dimension[1],n=Math.min(t,r),i=new Array(n);for(let a=0;a<n;a++){const n=r-a,s=new MultiArray([1,n]);for(let t=0;t<n;t++)s.array[0][t]=e.array[a][a+t];const{tau:o,v:l,alpha:c}=LAPACK.larfg("R",s,n,0);i[a]=o,e.array[a][a]=c;for(let t=1;t<n;t++)e.array[a][a+t]=l[t];a+1<t&&!Complex.realIsZero(Complex.abs(o))&&LAPACK.larf("R",e,l,o,a+1,a)}return MultiArray.setType(e),{L:e,taus:i}};static gelq2_nao_funciona=e=>{const t=e.dimension[0],r=e.dimension[1],n=Math.min(t,r),i=new Array(n);for(let t=0;t<n;t++){const{tau:n,v:a,alpha:s}=LAPACK.larfg("R",e,r,t);i[t]=n,e.array[t][t]=s;for(let r=1;r<a.length;r++)e.array[t][t+r]=a[r];Complex.realIsZero(Complex.abs(n))||LAPACK.larf("R",e,a,n,t,t)}return LAPACK.tril_inplace(e),MultiArray.setType(e),{L:e,taus:i}};static orgqr=(e,t)=>{const r=e.dimension[0],n=e.dimension[1],i=Math.min(r,n),a=new MultiArray([r,r]);a.array=LAPACK.eye(r,r);for(let n=i-1;n>=0;n--){const i=r-n,s=[Complex.one()],o=t[n];if(Complex.realIsZero(Complex.abs(o)))for(let e=1;e<i;e++)s[e]=Complex.zero();else for(let t=1;t<i;t++)s[t]=Complex.rdiv(e.array[n+t][n],o);LAPACK.larf("L",a,s,o,n,0)}return MultiArray.setType(a),a};static orglq=(e,t)=>{const r=e.dimension[1],n=t.length,i=new MultiArray([r,r]);i.array=LAPACK.eye(r,r);for(let a=n-1;a>=0;a--){const n=t[a];if(Complex.realIsZero(Complex.abs(n)))continue;const s=r-a,o=new Array(s);o[0]=Complex.one();for(let t=1;t<s;t++)o[t]=e.array[a][a+t];LAPACK.larf("R",i,o,n,0,a)}return MultiArray.setType(i),i};static getf2=(e,t,r,n,i,a)=>{const s=[e.length,e[0].length],[o,l]=s,c=Math.min(t+r,Math.min(o,l));for(let r=t;r<c;r++){let t=r,c=Complex.abs(e[r][r]);for(let n=r+1;n<o;n++){const i=Complex.abs(e[n][r]);Complex.toBoolean(Complex.gt(i,c))&&(c=i,t=n)}n[r]=t,t!==r&&(LAPACK.laswp_rows(e,s,r,t),void 0!==i&&i.swaps++);const u=e[r][r];if(Complex.toBoolean(Complex.eq(Complex.abs(u),Complex.zero())))void 0!==a&&0===a.info&&(a.info=r+1);else{for(let t=r+1;t<o;t++)e[t][r]=Complex.rdiv(e[t][r],u);for(let t=r+1;t<o;t++){const n=e[t][r];if(Complex.toBoolean(Complex.eq(Complex.abs(n),Complex.zero())))continue;const i=e[t],a=e[r];for(let e=r+1;e<l;e++)i[e]=Complex.sub(i[e],Complex.mul(n,a[e]))}}}};static getrf=(e,t)=>{const r=e.length,n=e[0].length,i=Math.min(r,n),a=new Array(i);for(let e=0;e<i;e++)a[e]=e;const s={swaps:0},o={info:0};for(let l=0;l<i;l+=t??BLAS.settings.blockSize){const c=Math.min(t??BLAS.settings.blockSize,i-l);LAPACK.getf2(e,l,c,a,s,o);for(let t=l;t<l+c&&t<i;t++){const r=a[t];if(r!==t&&s.swaps++,r!==t&&l>0)for(let n=0;n<l;n++){const i=e[t][n];e[t][n]=e[r][n],e[r][n]=i}}const u=c,m=r-(l+u),h=n-(l+u);if(l+u<n){const t=e,r=[];for(let e=0;e<m;e++){const n=l+u+e,i=new Array(u);for(let e=0;e<u;e++)i[e]=t[n][l+e];r.push(i)}const n=[];for(let e=0;e<u;e++){const r=l+e,i=new Array(h);for(let e=0;e<h;e++)i[e]=t[r][l+u+e];n.push(i)}const i=[];for(let e=0;e<m;e++){const r=l+u+e,n=new Array(h);for(let e=0;e<h;e++)n[e]=t[r][l+u+e];i.push(n)}BLAS.gemm(Complex.neg(Complex.one()),r,m,u,n,h,Complex.one(),i);for(let e=0;e<m;e++){const r=l+u+e;for(let n=0;n<h;n++)t[r][l+u+n]=i[e][n]}for(let e=0;e<u;e++){const r=l+e;for(let i=0;i<h;i++)t[r][l+u+i]=n[e][i]}for(let e=0;e<m;e++){const n=l+u+e;for(let i=0;i<u;i++)t[n][l+i]=r[e][i]}}}return{LU:e,piv:a,swaps:s.swaps,info:o.info}};static getrf_blocked=(e,t)=>{const r=e.length,n=e[0].length,i=Math.min(r,n),a=new Array(i);for(let e=0;e<i;e++)a[e]=e;const s={swaps:0},o={info:0};for(let l=0;l<i;l+=t??BLAS.settings.blockSize){const c=Math.min(t??BLAS.settings.blockSize,i-l);LAPACK.getf2(e,l,c,a,s,o),l+c<n&&LAPACK.trsm_left_upper_block(e,l,c),l+c<r&&l+c<n&&LAPACK.gemm_blocked(e,l,c)}return{LU:e,piv:a,info:o.info,swaps:s.swaps}};static gemm_blocked=(e,t,r,n=64)=>{const i=t+r,a=t+r,s=e.length-(t+r),o=e[0].length-(t+r);if(s<=0||o<=0)return;const l=r,c=n;for(let r=0;r<s;r+=c){const n=Math.min(r+c,s);for(let s=0;s<o;s+=c){const u=Math.min(s+c,o);for(let o=r;o<n;o++){const r=e[i+o];for(let n=s;n<u;n++){let s=Complex.zero();for(let r=0;r<l;r++){const l=e[i+o][t+r],c=e[t+r][a+n];s=Complex.add(s,Complex.mul(l,c))}r[a+n]=Complex.sub(r[a+n],s)}}}}};static getrs=(e,t,r)=>{const n=e.length,i=e[0].length,a=r[0].length??1,s=BLAS.copy(r);for(let e=0;e<t.length;e++){const r=t[e];if(r!==e){const t=s[e];s[e]=s[r],s[r]=t}}for(let t=0;t<a;t++)for(let r=0;r<n;r++){let n=s[r][t];for(let a=0;a<r&&a<i;a++)n=Complex.sub(n,Complex.mul(e[r][a],s[a][t]));s[r][t]=n}for(let t=0;t<a;t++)for(let r=Math.min(i,n)-1;r>=0;r--){let n=s[r][t];for(let a=r+1;a<i;a++)n=Complex.sub(n,Complex.mul(e[r][a],s[a][t]));const a=e[r][r];s[r][t]=Complex.rdiv(n,a)}return s};static gesv=(e,t)=>{const r=BLAS.copy(e),n=BLAS.copy(t),{LU:i,piv:a,info:s}=LAPACK.getrf(r);return 0!==s?{X:n,info:s}:{X:LAPACK.getrs(i,a,n),info:0}};static posv=(e,t)=>{const r=BLAS.copy(e),n=BLAS.copy(t),{LU:i,piv:a,info:s}=LAPACK.getrf(r);if(0!==s)throw new Error(`posv: matrix is singular or not positive definite (info = ${s})`);return LAPACK.getrs(i,a,n)};static potrf=(e,t)=>{const r=t?.uplo??"lower",n=e.dimension[0];if(e.dimension[0]!==e.dimension[1])throw new Error("LAPACK.potrf: A must be square");const i=MultiArray.copy(e);if("lower"===r){for(let e=0;e<n;e++){let t=Complex.realToNumber(i.array[e][e]);for(let r=0;r<e;r++){const n=i.array[e][r];t-=Complex.realToNumber(Complex.mul(n,Complex.conj(n)))}if(t<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");i.array[e][e]=Complex.create(Math.sqrt(t));for(let t=e+1;t<n;t++){let r=i.array[t][e];for(let n=0;n<e;n++)r=Complex.sub(r,Complex.mul(i.array[t][n],Complex.conj(i.array[e][n])));i.array[t][e]=Complex.rdiv(r,i.array[e][e])}}for(let e=0;e<n;e++)for(let t=e+1;t<n;t++)i.array[e][t]=Complex.zero()}else{for(let e=0;e<n;e++){let t=Complex.realToNumber(i.array[e][e]);for(let r=0;r<e;r++){const n=i.array[r][e];t-=Complex.realToNumber(Complex.mul(n,Complex.conj(n)))}if(t<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");i.array[e][e]=Complex.create(Math.sqrt(t));for(let t=e+1;t<n;t++){let r=i.array[e][t];for(let n=0;n<e;n++)r=Complex.sub(r,Complex.mul(Complex.conj(i.array[n][e]),i.array[n][t]));i.array[e][t]=Complex.rdiv(r,i.array[e][e])}}for(let e=1;e<n;e++)for(let t=0;t<e;t++)i.array[e][t]=Complex.zero()}return MultiArray.setType(i),i};static sysv=(e,t)=>{const r=BLAS.copy(e),n=BLAS.copy(t),{LU:i,piv:a,info:s}=LAPACK.getrf(r);if(0!==s)throw new Error(`sysv: matrix is singular (info = ${s})`);return LAPACK.getrs(i,a,n)};static mldivide=(e,t)=>{const[r,n]=e.dimension,[i,a]=t.dimension;if(n!==i)throw new EvalError(`operator \\: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is ${t.dimension.join("x")}).`);let s,o,l;if(LAPACK.isHermitian(e.array))if(LAPACK.isPositiveDefinite(e.array)){const r=LAPACK.posv(e.array,t.array);s=new MultiArray([r.length,r[0].length]),s.array=r,o=0,l="posv"}else{const r=LAPACK.sysv(e.array,t.array);s=new MultiArray([r.length,r[0].length]),s.array=r,o=0,l="sysv"}else{const r=LAPACK.gesv(e.array,t.array);s=new MultiArray([r.X.length,r.X[0].length]),s.array=r.X,o=r.info,l="gesv"}return{X:s,info:o,solver:l}};static sytrd=(e,t)=>{const r=e.dimension[0],n=new Array(r),i=new Array(r-1),a=new Array(r-1);for(let s=0;s<r-1;s++){const o=r-s-1,l=new Array(o);for(let t=0;t<o;t++)l[t]=Complex.copy(e.array[s+1+t][s]);const{alpha:c,v:u,tau:m}=LAPACK.larfg_original(l);a[s]=m,i[s]=c,e.array[s+1][s]=c;for(let t=1;t<o;t++)e.array[s+1+t][s]=u[t];Complex.realIsZero(Complex.abs(m))||t(e,u,Complex.conj(m),s+1,s+1),n[s]=Complex.copy(e.array[s][s])}return n[r-1]=Complex.copy(e.array[r-1][r-1]),{diag:n,offdiag:i,taus:a}};static her2_zhtrd_update=(e,t,r,n,i)=>{if(Complex.realIsZero(Complex.abs(r)))return;const a=t.length,s=new Array(a);for(let o=0;o<a;o++){let l=Complex.zero();for(let r=0;r<a;r++)Complex.mulAndSumTo(l,e.array[n+o][i+r],t[r]);s[o]=Complex.mul(r,l)}let o=Complex.zero();for(let e=0;e<a;e++)Complex.mulAndSumTo(o,Complex.conj(t[e]),s[e]);const l=Complex.mul(Complex.minusonediv2(),Complex.mul(r,o));for(let e=0;e<a;e++)Complex.mulAndSumTo(s[e],l,t[e]);for(let r=0;r<a;r++)for(let o=r;o<a;o++){const a=Complex.add(Complex.mul(t[r],Complex.conj(s[o])),Complex.mul(s[r],Complex.conj(t[o]))),l=n+r,c=i+o;e.array[l][c]=Complex.sub(e.array[l][c],a),r!==o&&(e.array[c][l]=Complex.conj(e.array[l][c]))}};static hetrd=e=>LAPACK.sytrd(e,LAPACK.her2_zhtrd_update);static ungtr=(e,t)=>{const r=e.dimension[0],n=new MultiArray([r,r]);n.array=LAPACK.eye([r,r]);for(let i=r-2;i>=0;i--){const a=t[i];if(!a||Complex.realIsZero(Complex.abs(a)))continue;const s=r-i-1,o=new Array(s);o[0]=Complex.one();for(let t=1;t<s;t++)o[t]=Complex.copy(e.array[i+1+t][i]);const l=new Array(r);for(let e=0;e<r;e++){let t=Complex.zero();for(let r=0;r<s;r++)Complex.mulAndSumTo(t,Complex.conj(o[r]),n.array[i+1+r][e]);l[e]=t}for(let e=0;e<s;e++){const t=Complex.mul(a,o[e]);for(let a=0;a<r;a++)n.array[i+1+e][a]=Complex.sub(n.array[i+1+e][a],Complex.mul(t,l[a]))}}return n};static sytrd_blocked_w=(e,t)=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("sytrd_blocked_w: A must be square");const n=new Array(r),i=new Array(r),a=new Array(r);if(0===r)return{diag:n,offdiag:i,taus:a};if(1===r)return n[0]=e.array[0][0],i[0]=Complex.zero(),a[0]=Complex.zero(),{diag:n,offdiag:i,taus:a};const s=Math.max(1,Math.floor(t??BLAS.settings.blockSize));for(let t=0;t<r-1;t+=s){const o=Math.min(s,r-1-t),l=new Array(r-t-1),c=new Array(r-t-1);for(let e=0;e<r-t-1;e++)l[e]=new Array(o).fill(Complex.zero()),c[e]=new Array(o).fill(Complex.zero());for(let s=0;s<o;s++){const o=t+s,u=r-o-1,m=new Array(u);for(let t=0;t<u;t++)m[t]=e.array[o+1+t][o];const h=LAPACK.larfg_original(m),p=h.v,d=h.tau,x=h.alpha;a[o]=d,n[o]=e.array[o][o],i[o]=x;for(let t=0;t<u;t++)e.array[o+1+t][o]=p[t],l[t][s]=p[t];if(!Complex.realIsZero(Complex.abs(d)))for(let t=0;t<u;t++){let r=Complex.zero();for(let n=0;n<=t;n++)r=Complex.add(r,Complex.mul(l[n][s],Complex.conj(e.array[o+1+n][o+1+t])));c[t][s]=Complex.mul(d,r)}}for(let n=0;n<r-t-1;n++)for(let i=n;i<r-t-1;i++){let r=Complex.zero(),a=Complex.zero();for(let e=0;e<o;e++)r=Complex.add(r,Complex.mul(l[n][e],Complex.conj(c[i][e]))),a=Complex.add(a,Complex.mul(c[n][e],Complex.conj(l[i][e])));e.array[t+1+n][t+1+i]=Complex.sub(e.array[t+1+n][t+1+i],Complex.add(r,a)),n!==i&&(e.array[t+1+i][t+1+n]=Complex.conj(e.array[t+1+n][t+1+i]))}}return n[r-1]=e.array[r-1][r-1],i[r-1]=Complex.zero(),a[r-1]=Complex.zero(),{diag:n,offdiag:i,taus:a}};static tridiagonal_hermitian_to_dense=(e,t)=>{const r=e.length,n=Array.from({length:r},()=>Array.from({length:r},()=>Complex.zero()));for(let i=0;i<r;i++)n[i][i]=Complex.copy(e[i]),i<r-1&&(n[i][i+1]=Complex.copy(t[i]),n[i+1][i]=Complex.conj(t[i]));return n};static hermitian_to_real2n=e=>{const t=e.length,r=Array.from({length:2*t},e=>Array.from({length:2*t}));for(let n=0;n<t;n++)for(let i=0;i<t;i++){const a=e[n][i];r[n][i]=Complex.real(a),r[n][i+t]=Complex.neg(Complex.imag(a)),r[n+t][i]=Complex.imag(a),r[n+t][i+t]=Complex.real(a)}return r};static real2n_to_complex_eigenvectors=e=>{const t=e.length/2,r=Array.from({length:t},e=>Array.from({length:t}));for(let n=0;n<t;n++)for(let i=0;i<t;i++){const a=e[i][n],s=e[i+t][n];r[i][n]=Complex.create(a.re,s.re)}return r};static real2n_to_complex_eigenvalues=e=>{const t=e.length/2,r=new Array(t);for(let n=0;n<t;n++){const i=e[n].re,a=e[n+t].re;r[n]=Complex.create(i,a)}return r};static jacobi_real_symmetric_dense=(e,t=1e3,r=1e-14)=>{const n=e.length;if(0===n)return{D:[],V:[]};if(1===n)return{D:[e[0][0]],V:[[Complex.one()]]};const i=LAPACK.eye([n,n]);for(let a=0;a<toNumber(t);a++){let t=Complex.zero();for(let a=0;a<n-1;a++)for(let s=a+1;s<n;s++){const o=e[a][s];if(t=Complex.max(t,Complex.abs(o)),Complex.realLessThan(Complex.abs(o),r))continue;const l=e[a][a],c=e[s][s],u=Complex.mul(Complex.two(),o);if(Complex.toBoolean(Complex.eq(u,Complex.zero())))continue;const m=Complex.rdiv(Complex.sub(c,l),u),h=Complex.toBoolean(Complex.ge(m,Complex.zero()))?Complex.one():Complex.minusone(),p=Complex.rdiv(h,Complex.add(Complex.abs(m),Complex.sqrt(Complex.add(Complex.one(),Complex.mul(m,m))))),d=Complex.rdiv(Complex.one(),Complex.sqrt(Complex.add(Complex.one(),Complex.mul(p,p)))),x=Complex.mul(p,d);for(let t=0;t<n;t++)if(t!==a&&t!==s){const r=e[t][a],n=e[t][s];e[t][a]=Complex.sub(Complex.mul(d,r),Complex.mul(x,n)),e[a][t]=e[t][a],e[t][s]=Complex.add(Complex.mul(x,r),Complex.mul(d,n)),e[s][t]=e[t][s]}e[a][a]=Complex.add(Complex.sub(Complex.mul(Complex.mul(d,d),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),x),d),o)),Complex.mul(Complex.mul(x,x),c)),e[s][s]=Complex.add(Complex.add(Complex.mul(Complex.mul(x,x),l),Complex.mul(Complex.mul(Complex.mul(Complex.two(),x),d),o)),Complex.mul(Complex.mul(d,d),c)),e[a][s]=Complex.zero(),e[s][a]=Complex.zero();for(let e=0;e<n;e++){const t=i[e][a],r=i[e][s];i[e][a]=Complex.sub(Complex.mul(d,t),Complex.mul(x,r)),i[e][s]=Complex.add(Complex.mul(x,t),Complex.mul(d,r))}}if(Complex.realLessThan(t,r))break}return{D:LAPACK.from_diag(e),V:i}};static jacobi_symmetric_hermitian=(e,t,r)=>{const n=e.length,i=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.create(1):Complex.zero())),a=r??1e-12,s=t??Math.max(50,Math.floor(1e3/Math.max(1,n))),o=e=>{let t=0;for(let r=0;r<n;r++)for(let i=r+1;i<n;i++){const n=Complex.abs(e[r][i]),a=Complex.realToNumber(n);t+=a*a}return Math.sqrt(t)};for(let t=0;t<s;t++){let t=!1;for(let r=0;r<n-1;r++)for(let s=r+1;s<n;s++){const o=e[r][s];if(Complex.realToNumber(Complex.le(Complex.abs(o),Complex.create(a))))continue;const l=e[r][r],c=e[s][s],u=Complex.realToNumber(Complex.real(o)),m=Complex.realToNumber(Complex.real(l)),h=Complex.realToNumber(Complex.real(c)),p=.5*Math.atan2(2*u,h-m),d=Math.cos(p),x=Math.sin(p);for(let t=0;t<n;t++){if(t===r||t===s)continue;const n=e[t][r],i=e[t][s];e[t][r]=Complex.sub(Complex.mul(Complex.create(d),n),Complex.mul(Complex.create(x),i)),e[r][t]=Complex.conj(e[t][r]),e[t][s]=Complex.add(Complex.mul(Complex.create(x),n),Complex.mul(Complex.create(d),i)),e[s][t]=Complex.conj(e[t][s])}const C=Complex.add(Complex.sub(Complex.mul(Complex.create(d*d),l),Complex.mul(Complex.create(2*x*d),o)),Complex.mul(Complex.create(x*x),c)),f=Complex.add(Complex.add(Complex.mul(Complex.create(x*x),l),Complex.mul(Complex.create(2*x*d),o)),Complex.mul(Complex.create(d*d),c));e[r][r]=C,e[s][s]=f,e[r][s]=Complex.zero(),e[s][r]=Complex.zero();for(let e=0;e<n;e++){const t=i[e][r],n=i[e][s];i[e][r]=Complex.sub(Complex.mul(Complex.create(d),t),Complex.mul(Complex.create(x),n)),i[e][s]=Complex.add(Complex.mul(Complex.create(x),t),Complex.mul(Complex.create(d),n))}t=!0}if(!t)break;if(o(e)<=a)break}const l=new Array(n);for(let t=0;t<n;t++)l[t]=e[t][t];return{D:l,V:i}};static column_pivot=(e,t,r=0,n=e.length)=>{const i=e.slice(r,n).map(e=>Complex.abs(e[t])),a=i.reduce((e,t,r,n)=>Complex.toBoolean(Complex.gt(t,n[e]))?r:e,0);return{pivotRow:a,pivotAbs:i[a],pivotIsZero:Complex.realIsZero(i[a])}};static normalize_eigenvector_phases=(e,t=!0)=>{const r=e.length,n=e[0].length;for(let i=0;i<n;i++){const{pivotRow:n,pivotAbs:a,pivotIsZero:s}=LAPACK.column_pivot(e,i);if(s)continue;const o=e[n][i];let l=Complex.rdiv(Complex.conj(o),a);t&&Complex.realLessThan(Complex.mul(o,l),0)&&(l=Complex.neg(l));for(let t=0;t<r;t++)e[t][i]=Complex.mul(e[t][i],l)}};static steqr_vectors=(e,t,r=1e3*e.length)=>{const n=e.length,i=e.map(e=>Complex.copy(e)),a=t.map(e=>Complex.copy(e));a[n-1]=Complex.zero();let s=!1;for(let e=0;e<n;e++)if(Complex.isComplexValue(i[e])||e<n-1&&Complex.isComplexValue(a[e])){s=!0;break}const o=new Array(n);let l=i.slice(),c=new Array(n);if(s){o[0]=Complex.one();for(let e=0;e<n-1;e++){const t=a[e],r=Complex.abs(t);if(Complex.realIsZero(r))o[e+1]=Complex.copy(o[e]);else{const n=Complex.rdiv(Complex.conj(t),r);o[e+1]=Complex.mul(o[e],n)}}for(let e=0;e<n-1;e++){const t=Complex.mul(Complex.conj(o[e]),Complex.mul(a[e],o[e+1]));c[e]=Complex.abs(t)}}else for(let e=0;e<n-1;e++)c[e]=Complex.copy(a[e]);c[n-1]=Complex.zero();const u=LAPACK.tridiagonal_hermitian_to_dense(l,c),m=LAPACK.jacobi_real_symmetric_dense(u,r);let h=m.D.map(e=>Complex.copy(e)),p=m.V.map(e=>e.map(e=>Complex.copy(e)));if(s)for(let e=0;e<n;e++)for(let t=0;t<n;t++)p[e][t]=Complex.mul(o[e],p[e][t]);const d=h.map((e,t)=>({v:e,i:t})).sort((e,t)=>Complex.realToNumber(e.v)-Complex.realToNumber(t.v)),x=Array.from({length:n},()=>Array(n)),C=d.map(e=>e.v);for(let e=0;e<n;e++){const t=d[e].i;for(let r=0;r<n;r++)x[r][e]=Complex.copy(p[r][t])}return LAPACK.normalize_eigenvector_phases(x),{D:C,V:x,complex:s}};static steqr_vectors_tridiagonal=(e,t,r=1e3)=>{const n=e.length;if(0===n)return{D:[],V:[]};if(1===n)return{D:[Complex.copy(e[0])],V:[[Complex.one()]]};const i=e.map(e=>Complex.copy(e)),a=t.map(e=>Complex.copy(e)),s=Array.from({length:n},(e,t)=>Array.from({length:n},(e,r)=>t===r?Complex.one():Complex.zero())),o=Number.EPSILON||2220446049250313e-31;let l=0;for(;l<r;){let e=0;for(;e<n-1&&Complex.realLessThanOrEqualTo(Complex.abs(a[e]),o);)e++;if(e>=n-1)break;let t=e;for(;t<n-2&&Complex.realGreaterThan(Complex.abs(a[t]),o);)t++;const r=i[t],c=i[t+1],u=a[t],m=Complex.mul(Complex.sub(r,c),Complex.create(.5)),h=Complex.abs(m),p=Complex.power(Complex.abs(u),Complex.two()),d=Complex.add(h,Complex.sqrt(Complex.add(Complex.mul(h,h),p))),x=Complex.realGreaterThanOrEqualTo(m,0)?Complex.one():Complex.minusone(),C=Complex.sub(c,Complex.rdiv(Complex.mul(x,p),d));let f=Complex.sub(i[e],C),g=a[e];for(let r=e;r<=t;r++){const e=Complex.sqrt(Complex.add(Complex.power(Complex.abs(f),Complex.two()),Complex.power(Complex.abs(g),Complex.two())));if(Complex.realEquals(e,0))continue;const o=Complex.rdiv(f,e),l=Complex.rdiv(g,e),c=i[r],u=i[r+1];i[r]=Complex.add(Complex.mul(Complex.conj(o),Complex.mul(o,c)),Complex.mul(Complex.conj(l),Complex.mul(l,u))),i[r+1]=Complex.add(Complex.mul(Complex.conj(l),Complex.mul(l,c)),Complex.mul(Complex.conj(o),Complex.mul(o,u))),a[r]=Complex.zero(),r<t&&(f=a[r],g=a[r+1]);for(let e=0;e<n;e++){const t=s[e][r],n=s[e][r+1];s[e][r]=Complex.sub(Complex.mul(o,t),Complex.mul(l,n)),s[e][r+1]=Complex.add(Complex.mul(Complex.conj(l),t),Complex.mul(o,n))}}l++}return{D:i,V:s}};static steqr_values=(e,t,r)=>LAPACK.steqr_vectors(e,t,r).D;static orgtr=(e,t)=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("orgtr: A must be square");const n=new MultiArray([r,r]);n.array=LAPACK.eye(r,r);for(let i=r-2;i>=0;i--){const a=r-i-1,s=new Array(a);for(let t=0;t<a;t++)s[t]=e.array[i+1+t][i];const o=t[i];Complex.realIsZero(Complex.abs(o))||LAPACK.larf_left(n,s,o,i+1,0)}return MultiArray.setType(n),n};static orgtr_blocked=(e,t,r)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("orgtr_blocked: A must be square");const i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n);const a=Math.max(1,Math.floor(r??BLAS.settings.blockSize));for(let r=n-2-(n-2)%a;r>=0;r-=a){for(let s=Math.min(a,n-1-r)-1;s>=0;s--){const o=r+s,l=n-o-1;if(l<=0)continue;const c=new Array(l);for(let t=0;t<l;t++)c[t]=e.array[o+1+t][o];const u=t[o];Complex.realIsZero(Complex.abs(u))||LAPACK.larf_left_block(i,c,u,o+1,0,a)}if(0===r)break}return MultiArray.setType(i),i};static orgtr_blocked_w=(e,t,r)=>{const n=e.dimension[0];if(n!==e.dimension[1])throw new Error("orgtr_blocked_w: A must be square");const i=new MultiArray([n,n]);i.array=LAPACK.eye(n,n);const a=Math.max(1,Math.floor(r??BLAS.settings.blockSize));for(let r=n-2;r>=0;r-=a){const s=Math.min(a,r+1),o=new Array(n-r-1),l=new Array(n-r-1);for(let e=0;e<n-r-1;e++)o[e]=new Array(s).fill(Complex.zero()),l[e]=new Array(s).fill(Complex.zero());for(let t=0;t<s;t++){const i=r-s+1+t,a=n-i-1;for(let r=0;r<a;r++)o[r][t]=e.array[i+1+r][i]}for(let e=0;e<s;e++){const a=r-s+1+e,c=t[a],u=n-a-1;if(!Complex.realIsZero(Complex.abs(c)))for(let t=0;t<u;t++){let r=Complex.zero();for(let n=0;n<=t;n++)r=Complex.add(r,Complex.mul(o[n][e],Complex.conj(i.array[a+1+n][a+1+t])));l[t][e]=Complex.mul(c,r)}}for(let e=0;e<n-r-1;e++)for(let t=0;t<n;t++){let n=Complex.zero(),a=Complex.zero();for(let i=0;i<s;i++)n=Complex.add(n,Complex.mul(o[e][i],Complex.conj(l[t-r-1+e]?.[i]??Complex.zero()))),a=Complex.add(a,Complex.mul(l[e][i],Complex.conj(o[t-r-1+e]?.[i]??Complex.zero())));i.array[r+1+e][t]=Complex.sub(i.array[r+1+e][t],Complex.add(n,a))}}return i};static eig_symmetric=(e,t=!1)=>{e.dimension[0];const r=MultiArray.copy(e),{diag:n,offdiag:i,taus:a}=LAPACK.hetrd(r);if(t){let e=LAPACK.ungtr(r,a);const{D:t,V:s}=LAPACK.steqr_vectors(n,i),o=new MultiArray([s.length,s[0].length]);return o.array=s,e=MathOperation.mtimes(e,o),{D:MultiArray.toDiagonalMatrix(t),V:e}}return{D:MultiArray.toColumnVector(LAPACK.steqr_vectors(n,i).D)}};static eig_hermitian=(e,t=!1)=>{const r=e.dimension[0],n=MultiArray.copy(e);let i=!1;for(let e=0;e<r&&!i;e++)for(let t=0;t<r;t++){const r=n.array[e][t];if(!Complex.imagIsZero(r)){i=!0;break}}if(i){const{diag:e,offdiag:i,taus:a}=LAPACK.hetrd(n);if(!t){const{D:t}=LAPACK.steqr_vectors(e,i);return{D:MultiArray.toColumnVector(t)}}let s=LAPACK.ungtr(n,a);console.log("Q =",s);const{D:o,V:l}=LAPACK.steqr_vectors(e,i),c=new MultiArray([r,r]);return c.array=l,s=MathOperation.mtimes(s,c),{D:MultiArray.toDiagonalMatrix(o),V:s}}{const{diag:e,offdiag:i,taus:a}=LAPACK.hetrd(n);if(!t){const{D:t}=LAPACK.steqr_vectors(e,i);return{D:MultiArray.toColumnVector(t)}}let s=LAPACK.ungtr(n,a);const{D:o,V:l}=LAPACK.steqr_vectors(e,i),c=new MultiArray([r,r]);return c.array=l,s=MathOperation.mtimes(s,c),{D:MultiArray.toDiagonalMatrix(o),V:s}}};static functions={laswp:LAPACK.laswp,laswp_rows:LAPACK.laswp_rows,laswp_cols:LAPACK.laswp_cols,eye:LAPACK.eye,fillFactory:LAPACK.fillFactory,zeros:LAPACK.zeros,ones:LAPACK.ones,diag:LAPACK.diag,from_diag:LAPACK.from_diag,lassq:LAPACK.lassq,lange:LAPACK.lange,triu_inplace:LAPACK.triu_inplace,tril_inplace:LAPACK.tril_inplace,trsm_left_upper_block:LAPACK.trsm_left_upper_block,lapmt_matrix:LAPACK.lapmt_matrix,larfg:LAPACK.larfg,larf:LAPACK.larf,geqr2:LAPACK.geqr2,geqp2:LAPACK.geqp2,geqp3:LAPACK.geqp3,orgqr:LAPACK.orgqr,getf2:LAPACK.getf2,getrf:LAPACK.getrf,gemm_blocked:LAPACK.gemm_blocked,getrf_blocked:LAPACK.getrf_blocked,getrs:LAPACK.getrs,sytrd:LAPACK.sytrd,her2_zhtrd_update:LAPACK.her2_zhtrd_update,hetrd:LAPACK.hetrd,ungtr:LAPACK.ungtr,sytrd_blocked_w:LAPACK.sytrd_blocked_w,tridiagonal_hermitian_to_dense:LAPACK.tridiagonal_hermitian_to_dense,hermitian_to_real2n:LAPACK.hermitian_to_real2n,real2n_to_complex_eigenvectors:LAPACK.real2n_to_complex_eigenvectors,real2n_to_complex_eigenvalues:LAPACK.real2n_to_complex_eigenvalues,jacobi_real_symmetric_dense:LAPACK.jacobi_real_symmetric_dense,jacobi_symmetric_hermitian:LAPACK.jacobi_symmetric_hermitian,column_pivot:LAPACK.column_pivot,normalize_eigenvector_phases:LAPACK.normalize_eigenvector_phases,steqr_vectors:LAPACK.steqr_vectors,steqr_values:LAPACK.steqr_values,orgtr_blocked_w:LAPACK.orgtr_blocked_w,eig_symmetric:LAPACK.eig_symmetric,eig_hermitian:LAPACK.eig_hermitian}}const src_LAPACK={LAPACK},LinearAlgebraConfigKeyTable=["wasteLU","qrPhaseEpsilon"],LinearAlgebra_defaultSettings={wasteLU:1e-15,qrPhaseEpsilon:1e-300};class LinearAlgebra{static defaultSettings=Object.assign({},LinearAlgebra_defaultSettings);static settings=LinearAlgebra.defaultSettings;static set=e=>{Object.entries(e).forEach(e=>{if(!LinearAlgebraConfigKeyTable.includes(e[0]))throw new Error(`LinearAlgebra.set: invalid configuration parameter: ${e[0]}`);LinearAlgebra.settings[e[0]]=e[1]})};static eye=(...e)=>{let t=0,r=0;if(0===e.length)return Complex.one();if(1===e.length)if(MultiArray.isInstanceOf(e[0])){const n=MultiArray.linearize(e[0]);if(0===n.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");if(1===n.length)t=MultiArray.testIndex(n[0]),r=t;else{if(2!==n.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");t=MultiArray.testIndex(n[0]),r=MultiArray.testIndex(n[1])}}else t=MultiArray.testIndex(e[0]),r=t;else 2===e.length&&Complex.isInstanceOf(e[0])&&Complex.isInstanceOf(e[1])?(t=MultiArray.testIndex(e[0]),r=MultiArray.testIndex(e[1])):AST.throwInvalidCallError("eye");const n=new MultiArray([t,r],Complex.zero());for(let e=0;e<Math.min(n.dimension[0],n.dimension[1]);e++)n.array[e][e]=Complex.one();return n};static diag=(...e)=>{let t;if(e.length>0&&e.length<=3)if(MultiArray.isInstanceOf(e[0])){if(2!==e[0].dimension.length)throw new Error("Matrix must be 2-dimensional");if(1===e.length)if(1===e[0].dimension[0]&&e[0].dimension[1]>1){const r=e[0].dimension[1];t=new MultiArray([r,r]),t.array=LAPACK.diag(e[0].array[0])}else if(1===e[0].dimension[1]&&e[0].dimension[0]>1){const r=e[0].dimension[0];t=new MultiArray([r,r]),t.array=LAPACK.diag(e[0].array.map(e=>e[0]))}else t=MultiArray.toColumnVector(LAPACK.from_diag(e[0].array));else if(2===e.length){const r=Math.floor(Complex.realToNumber(MultiArray.firstElement(e[1])));if(1===e[0].dimension[0]&&e[0].dimension[1]>1){const n=e[0].dimension[1];t=new MultiArray([n,n]),t.array=LAPACK.diag(e[0].array[0],r)}else if(1===e[0].dimension[1]&&e[0].dimension[0]>1){const n=e[0].dimension[0];t=new MultiArray([n,n]),t.array=LAPACK.diag(e[0].array.map(e=>e[0]),r)}else t=MultiArray.toColumnVector(LAPACK.from_diag(e[0].array,r))}else{const r=Math.floor(Complex.realToNumber(MultiArray.firstElement(e[1]))),n=Math.floor(Complex.realToNumber(MultiArray.firstElement(e[2])));if(t=new MultiArray([r,n]),t.array=LAPACK.diag(e[0].array[0],0,[r,n]),1===e[0].dimension[0]&&e[0].dimension[1]>1)t.array=LAPACK.diag(e[0].array[0],0,r,n);else{if(!(1===e[0].dimension[1]&&e[0].dimension[0]>1))throw new Error("diag: V must be a vector");t.array=LAPACK.diag(e[0].array.map(e=>e[0]),0,r,n)}}}else t=new MultiArray([1,1],e[0].copy());else AST.throwInvalidCallError("diag");return t};static trace=e=>{if(2===e.dimension.length)return e.array.map((e,t)=>e[t]?e[t]:Complex.zero()).reduce((e,t)=>Complex.add(e,t),Complex.zero());throw new Error("trace: only valid on 2-D objects")};static applyTranspose=(e,t=e=>e)=>{if(2===e.dimension.length){const r=new MultiArray([e.dimension[1],e.dimension[0]]);for(let n=0;n<e.dimension[1];n++){r.array[n]=new Array(e.dimension[0]);for(let i=0;i<e.dimension[0];i++)r.array[n][i]=t(e.array[i][n]).copy()}return MultiArray.setType(r),r}throw new Error("transpose not defined for N-D objects")};static transpose=e=>LinearAlgebra.applyTranspose(e);static ctranspose=e=>LinearAlgebra.applyTranspose(e,e=>Complex.conj(e));static mul(e,t){if(e.dimension[1]!==t.dimension[0]||2!==e.dimension.length||2!==t.dimension.length)throw new EvalError(`operator *: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is ${t.dimension.join("x")}).`);{const r=new MultiArray([e.dimension[0],t.dimension[1]]);return BLAS.gemm(Complex.one(),e.array,e.dimension[0],e.dimension[1],t.array,t.dimension[1],Complex.zero(),r.array),MultiArray.setType(r),r}}static power=(e,t)=>{let r;if(Complex.realIsInteger(t)&&Complex.imagEquals(t,0)){if(r=Complex.realEquals(t,0)?LinearAlgebra.eye(Complex.create(e.dimension[0],0)):Complex.realGreaterThan(t,0)?MultiArray.copy(e):LinearAlgebra.inv(e),1!=Math.abs(Complex.realToNumber(t))){let e;for(let n=1;n<Math.abs(Complex.realToNumber(t));n++)e=new MultiArray([r.dimension[0],r.dimension[1]]),BLAS.gemm(Complex.one(),r.array,r.dimension[0],r.dimension[1],r.array,r.dimension[1],Complex.zero(),e.array);r=e}return r}throw new Error("exponent must be integer real in matrix '^'.")};static det=e=>{if(2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new EvalError("det: matrix must be square.");const t=e.dimension[0];if(0===t)return Complex.create(1,0);if(1===t)return e.array[0][0];if(2===t)return Complex.sub(Complex.mul(e.array[0][0],e.array[1][1]),Complex.mul(e.array[0][1],e.array[1][0]));const{U:r,swaps:n}=LinearAlgebra.luDecomposition(e);let i=Complex.one();for(let e=0;e<t;e++){const t=r.array[e][e];if(Complex.realIsZero(Complex.abs(t)))return Complex.zero();i=Complex.mul(i,t)}return n%2==1&&(i=Complex.neg(i)),i};static luDecomposition=e=>{const t=MultiArray.copy(e),{LU:r,piv:n,swaps:i}=LAPACK.getrf_blocked(t.array),a=t.dimension[0],s=t.dimension[1],o=Math.min(a,s),l=LinearAlgebra.eye(Complex.create(a));for(let e=0;e<o;e++)n[e]!==e&&LAPACK.laswp_rows(l.array,l.dimension,e,n[e]);const c=new MultiArray([a,a]),u=new MultiArray([a,s]);for(let e=0;e<a;e++)for(let r=0;r<s;r++)e>r?(c.array[e][r]=t.array[e][r],u.array[e][r]=Complex.zero()):e===r?(c.array[e][r]=Complex.one(),u.array[e][r]=t.array[e][r]):(c.array[e][r]=Complex.zero(),u.array[e][r]=t.array[e][r]);return{L:c,U:u,P:l,swaps:i}};static lu=e=>{if(!e||2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new Error("PLU decomposition can only be applied to square matrices.");return AST.nodeReturnList((e,t)=>{if(1===e.length)return e.U;switch(t){case 0:return e.L;case 1:return e.U;case 2:return e.P}},t=>{const{L:r,U:n,P:i}=LinearAlgebra.luDecomposition(e);return{length:t,L:r,U:n,P:i}})};static inv=e=>{if(!e||2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new Error("inv: matrix must be square.");const t=MultiArray.copy(e),{LU:r,piv:n,info:i,swaps:a}=LAPACK.getrf_blocked(t.array);if(0!==i){const t=e.dimension[0],r=new MultiArray([t,t]);for(let e=0;e<t;e++)for(let n=0;n<t;n++)r.array[e][n]=Complex.inf_0();return MultiArray.setType(r),r}{const t=e.dimension[0],i=LAPACK.eye([t,t]),a=LAPACK.getrs(r,n,i),s=new MultiArray([a.length,a[0].length]);return s.array=a,MultiArray.setType(s),s}};static gauss=(e,t)=>{if(e.dimension.length>2||e.dimension[0]!==e.dimension[1])throw new Error("invalid dimensions in function gauss.");const r=MultiArray.copy(e);let n,i,a;for(Math.min(t.dimension[0],t.dimension[1])===t.dimension[1]&&(t=LinearAlgebra.transpose(t)),n=0;n<r.dimension[0];n++)r.array[n].push(t.array[0][n]);const s=r.dimension[0];for(n=0;n<s;n++){let e=Complex.abs(r.array[n][n]),t=n;for(i=n+1;i<s;i++)Complex.realGreaterThan(Complex.abs(r.array[i][n]),e.re)&&(e=Complex.abs(r.array[i][n]),t=i);for(i=n;i<s+1;i++){const e=r.array[t][i];r.array[t][i]=r.array[n][i],r.array[n][i]=e}for(i=n+1;i<s;i++){const e=Complex.rdiv(Complex.neg(r.array[i][n]),r.array[n][n]);for(a=n;a<s+1;a++)r.array[i][a]=n===a?Complex.zero():Complex.add(r.array[i][a],Complex.mul(e,r.array[n][a]))}}const o=new MultiArray([1,s],Complex.zero());for(n=s-1;n>-1;n--)for(o.array[0][n]=Complex.rdiv(r.array[n][s],r.array[n][n]),i=n-1;i>-1;i--)r.array[i][s]=Complex.sub(r.array[i][s],Complex.mul(r.array[i][n],o.array[0][n]));return MultiArray.setType(o),o};static dot=(e,t,r)=>{if(!MultiArray.arrayEquals(e.dimension,t.dimension))throw new Error("dot: A and B must have the same size.");let n;if(n=void 0!==r?MultiArray.testIndex(r,"dot")-1:MultiArray.firstNonSingleDimension(e),n<0||n>=e.dimension.length)throw new Error("dot: dimension argument out of range.");const i=e.dimension,a=i.length,s=i.reduce((e,t)=>e*t,1),o=new Array(a);o[0]=1;for(let e=1;e<a;e++)o[e]=o[e-1]*i[e-1];const l=[...i];l[n]=1;const c=l.reduce((e,t)=>e*t,1),u=new Array(a);u[0]=1;for(let e=1;e<a;e++)u[e]=u[e-1]*l[e-1];const m=new MultiArray(l),h=l.slice(2).reduce((e,t)=>e*t,1),p=l[0]*Math.max(1,h),d=l[1]??1;m.array=new Array(p);for(let e=0;e<p;e++)m.array[e]=new Array(d);const x=i[0]*i[1],C=l[0]*l[1];for(let r=0;r<s;r++){let s=0;for(let e=0;e<a;e++){const t=Math.floor(r/o[e])%i[e];e!==n&&(s+=t*u[e])}const c=Math.floor(r/x),h=r-c*x,p=c*i[0]+h%i[0],d=Math.floor(h/i[0]);if(!e.array[p]||void 0===e.array[p][d])throw new Error(`dot_fast: invalid access to A at physical [${p},${d}] (linIdx=${r}).`);if(!t.array[p]||void 0===t.array[p][d])throw new Error(`dot_fast: invalid access to B at physical [${p},${d}] (linIdx=${r}).`);const f=e.array[p][d],g=t.array[p][d],_=Complex.mul(Complex.conj(f),g),y=Math.floor(s/C),A=s-y*C,E=y*l[0]+A%l[0],L=Math.floor(A/l[0]);void 0===m.array[E][L]||null===m.array[E][L]?m.array[E][L]=Complex.copy(_):m.array[E][L]=Complex.add(m.array[E][L],_)}return MultiArray.setType(m),1===c?m.array[0][0]:m};static cross=(e,t,r)=>{const n=e.dimension.slice(),i=t.dimension.slice();let a;if(void 0!==r){let e;if("object"==typeof r&&null!==r&&("dimension"in r||"array"in r))try{const t=MultiArray.linearize(r);if(t&&t.length>0){const r=t[0];e=Number(r&&"object"==typeof r&&"re"in r?r.re:r)}else e=void 0}catch(t){e=void 0}else e=Number("object"==typeof r&&null!==r&&"re"in r?r.re:r);if(void 0===e||!Number.isFinite(e))throw new EvalError(`cross: invalid dimension ${String(r)}.`);const t=Math.floor(e);if(t<1)throw new EvalError(`cross: invalid dimension ${String(r)}.`);a=t-1}const s=Math.max(n.length,i.length,void 0!==a?a+1:0),o=n.slice(),l=i.slice();for(;o.length<s;)o.push(1);for(;l.length<s;)l.push(1);if(void 0===a&&(a=o.findIndex(e=>3===e),-1===a))throw new EvalError("cross: no dimension of length 3 found and dim not specified.");for(let e=0;e<s;e++)if(e!==a&&o[e]!==l[e])throw new EvalError("cross: A and B must have the same size, except along the operation dimension.");const c=o[a]??1,u=l[a]??1;if(3!==c||3!==u)throw new EvalError(`cross: inputs must have length 3 along the operation dimension (got ${c} and ${u}).`);const m=MultiArray.linearize(e),h=MultiArray.linearize(t),p=m.length,d=new Array(p),x=o.slice(0,a).reduce((e,t)=>e*t,1),C=o[a],f=x*C,g=Math.floor(p/f);if(3!==C)throw new EvalError(`cross: internal error, block length along dim ${a+1} must be 3.`);for(let e=0;e<g;e++){const t=e*f;for(let e=0;e<x;e++){const r=t+0*x+e,n=t+1*x+e,i=t+2*x+e;d[r]=Complex.sub(Complex.mul(m[n],h[i]),Complex.mul(m[i],h[n])),d[n]=Complex.sub(Complex.mul(m[i],h[r]),Complex.mul(m[r],h[i])),d[i]=Complex.sub(Complex.mul(m[r],h[n]),Complex.mul(m[n],h[r]))}}const _=new MultiArray(n);1===_.dimension.length&&_.dimension.push(1);for(let e=0;e<m.length;e++){const[t,r]=MultiArray.linearIndexToMultiArrayRowColumn(_.dimension[0],_.dimension[1],e);_.array[t][r]=d[e]??Complex.zero()}return MultiArray.setType(_),_};static kron=(e,t)=>{if(!e||e.dimension.length<2||!t||t.dimension.length<2)throw new Error("kron: inputs must be at least 2-D arrays");const r=e.dimension[0],n=e.dimension[1],i=t.dimension[0],a=t.dimension[1],s=new MultiArray([r*i,n*a]);for(let o=0;o<r;o++)for(let r=0;r<n;r++){const n=e.array[o][r];for(let e=0;e<i;e++)for(let l=0;l<a;l++){const c=t.array[e][l],u=Complex.mul(n,c);s.array[o*i+e][r*a+l]=u}}return MultiArray.setType(s),s};static qrPhaseNormalize=(e,t,r)=>{const n=Math.min(t.dimension[0],t.dimension[1]);for(let i=0;i<n;i++){if(Complex.realIsZero(Complex.abs(t.array[i][i])))continue;const n=Complex.neg(e[i]);for(let e=i;e<t.dimension[1];e++)t.array[i][e]=Complex.rdiv(t.array[i][e],n);if(void 0!==r)for(let e=0;e<r.dimension[0];e++)r.array[e][i]=Complex.mul(r.array[e][i],n)}if(Complex.imagGreaterThan(Complex.abs(t.array[0][0]),LinearAlgebra.settings.qrPhaseEpsilon))throw new Error("Phase normalization error: R(1,1) should be real.");if(Complex.realGreaterThan(t.array[0][0],0)){for(let e=0;e<t.dimension[1];e++)t.array[0][e]=Complex.neg(t.array[0][e]);if(void 0!==r)for(let e=0;e<r.dimension[0];e++)r.array[e][0]=Complex.neg(r.array[e][0])}};static lqPhaseNormalize=(e,t,r)=>{const n=Math.min(t.dimension[0],t.dimension[1]);for(let i=0;i<n;i++){const n=e[i];if(!Complex.realIsZero(Complex.abs(n))){for(let e=i;e<t.dimension[1];e++)t.array[i][e]=Complex.mul(t.array[i][e],n);if(r){const e=Complex.conj(n);for(let t=0;t<r.dimension[0];t++)r.array[t][i]=Complex.mul(r.array[t][i],e)}}}};static qrDecomposition=(e,t)=>{switch(t){case 1:{const{R:t,phis:r}=LAPACK.geqr2(e);return MultiArray.haveAnyComplex(t)&&LinearAlgebra.qrPhaseNormalize(r,t),{R:t}}case 2:{const{R:t,taus:r,phis:n}=LAPACK.geqr2(e),i=LAPACK.orgqr(t,r);return LAPACK.triu_inplace(t),MultiArray.haveAnyComplex(t)&&LinearAlgebra.qrPhaseNormalize(n,t,i),{Q:i,R:t}}case 3:{const{R:t,taus:r,phis:n,jpvt:i}=LAPACK.geqp3(e),a=LAPACK.orgqr(t,r);LAPACK.triu_inplace(t);const s=LAPACK.lapmt_matrix(i);return MultiArray.haveAnyComplex(t)&&LinearAlgebra.qrPhaseNormalize(n,t,a),{Q:a,R:t,P:s}}}};static qr=e=>{if(!e||2!==e.dimension.length)throw new Error("QR decomposition can only be applied to 2D matrices.");return AST.nodeReturnList((e,t)=>{if(1===e.length){if(0===t)return e.R}else if(2===e.length){if(0===t)return e.Q;if(1===t)return e.R}else if(3===e.length){if(0===t)return e.Q;if(1===t)return e.R;if(2===t)return e.P}},t=>{if(AST.throwErrorIfGreaterThanReturnList(3,t),1===t){const{R:r}=LinearAlgebra.qrDecomposition(e,1);return{length:t,R:r}}if(2===t){const{Q:r,R:n}=LinearAlgebra.qrDecomposition(e,2);return{length:t,R:n,Q:r}}{const{Q:r,R:n,P:i}=LinearAlgebra.qrDecomposition(e,3);return{length:t,R:n,Q:r,P:i}}})};static eigDecomposition_original=(e,t,r=32,n="asc")=>{if(!e||!e.dimension||2!==e.dimension.length)throw new Error("eigDecomposition: A must be a 2D MultiArray");const i=e.dimension[0];if(i!==e.dimension[1])throw new Error("eigDecomposition: A must be square");const a=MultiArray.copy(e),{diag:s,offdiag:o,taus:l}=LAPACK.sytrd_blocked_w(a,r);if(!Array.isArray(s)||!Array.isArray(o))throw new Error("eigDecomposition: sytrd_blocked_w did not return diag/offdiag arrays");if(1===t){const e=MultiArray.toColumnVector(LAPACK.steqr_values(s,o));if(!e||!e.array||e.dimension[0]!==i)throw new Error("eigDecomposition: steqr_values returned invalid MultiArray");if("none"===n)return MultiArray.setType(e),{values:e};const t=new Array(i);for(let r=0;r<i;r++)t[r]=e.array[r][0];const r=Array.from({length:i},(e,t)=>t).sort((e,r)=>{const i=Complex.realToNumber(t[e]),a=Complex.realToNumber(t[r]);return"asc"===n?i-a:a-i}).map(e=>t[e]),a=MultiArray.toColumnVector(r);return MultiArray.setType(a),{values:a}}{const e=LAPACK.steqr_vectors(s,o);if(!e||!e.D||!e.V)throw new Error("eigDecomposition: steqr_vectors returned invalid result");const c=MultiArray.toDiagonalMatrix(e.D),u=new MultiArray([e.V.length,e.V[0].length]);if(u.array=e.V,c.dimension[0]!==i)throw new Error("eigDecomposition: steqr_vectors returned D of unexpected size");if(u.dimension[0]!==i||u.dimension[1]!==i)throw new Error("eigDecomposition: steqr_vectors returned V of unexpected shape");const m=LAPACK.orgtr_blocked_w(a,l,r),h=new MultiArray([i,i]);for(let e=0;e<i;e++)for(let t=0;t<i;t++)h.array[e][t]=Complex.zero();BLAS.gemm_block(m.array,u.array,h.array,Complex.one(),Complex.zero(),r),MultiArray.setType(h);const p=new Array(i);for(let e=0;e<i;e++)p[e]=c.array[e][0];const d="none"===n?Array.from({length:i},(e,t)=>t):Array.from({length:i},(e,t)=>t).sort((e,t)=>{const r=Complex.realToNumber(p[e]),i=Complex.realToNumber(p[t]);return"asc"===n?r-i:i-r}),x=d.map(e=>p[e]),C=MultiArray.toColumnVector(x),f=new MultiArray([i,i]);for(let e=0;e<i;e++){const t=d[e];for(let r=0;r<i;r++)f.array[r][e]=h.array[r][t]}if(MultiArray.setType(C),MultiArray.setType(f),2===t)return{values:C,vectors:f};{const e=new MultiArray([i,i]);for(let t=0;t<i;t++)for(let r=0;r<i;r++)e.array[t][r]=Complex.zero();for(let t=0;t<i;t++)e.array[t][t]=s[t],t<i-1&&(e.array[t][t+1]=o[t],e.array[t+1][t]=Complex.conj(o[t]));return MultiArray.setType(e),{values:C,vectors:f,T:e}}}};static eigDecomposition=(e,t,r="asc",n)=>{const i=e.dimension[0],a=MultiArray.copy(e),{diag:s,offdiag:o,taus:l}=LAPACK.sytrd(a,LAPACK.larf_left);if(1===t){const{D:e}=LAPACK.steqr_vectors(s,o,1e4),t=Array.from({length:i},(e,t)=>t).sort((t,n)=>{const i=Complex.realToNumber(e[t]),a=Complex.realToNumber(e[n]);return"asc"===r?i-a:a-i}).map(t=>e[t]),n=MultiArray.toColumnVector(t);return MultiArray.setType(n),{values:n}}{const{D:e,V:t}=LAPACK.steqr_vectors_tridiagonal(s,o,1e4),r=new MultiArray([t.length,t[0].length]);return r.array=t,{values:MultiArray.toDiagonalMatrix(e),vectors:r}}};static eig=e=>AST.nodeReturnList((e,t)=>{if(1===e.length){if(0===t)return e.values}else if(2===e.length){if(0===t)return e.vectors;if(1===t)return e.values}else if(3===e.length){if(0===t)return e.vectors;if(1===t)return e.values;if(2===t)return e.T}},t=>{if(AST.throwErrorIfGreaterThanReturnList(3,t),1===t){const{D:r}=LAPACK.eig_hermitian(e);return{length:t,values:r}}if(2===t){const{D:r,V:n}=LAPACK.eig_hermitian(e,!0);return{length:t,values:r,vectors:n}}{const{values:r,vectors:n,T:i}=LinearAlgebra.eigDecomposition(e,3);return{length:t,values:r,vectors:n,T:i}}});static test(e){return AST.nodeReturnList((e,t)=>{if(1===e.length){if(0===t)return Complex.zero()}else if(2===e.length){if(0===t)return Complex.zero();if(1===t)return Complex.one()}else if(3===e.length){if(0===t)return Complex.zero();if(1===t)return Complex.one();if(2===t)return Complex.two()}},e=>({length:e}))}static functions={eye:LinearAlgebra.eye,diag:LinearAlgebra.diag,trace:LinearAlgebra.trace,det:LinearAlgebra.det,inv:LinearAlgebra.inv,gauss:LinearAlgebra.gauss,lu:LinearAlgebra.lu,dot:LinearAlgebra.dot,cross:LinearAlgebra.cross,kron:LinearAlgebra.kron,qr:LinearAlgebra.qr,eig:LinearAlgebra.eig,test:LinearAlgebra.test}}const src_LinearAlgebra={LinearAlgebra};class SymbolTable{variableTable;functionTable;builtInTable;aliasNameFunction;parent;child;scope;constructor(e,t,r,n,i){const a=void 0!==r?r:null;a&&a.child.push(this),this.variableTable={},this.functionTable={},this.builtInTable=e,this.aliasNameFunction=t,this.parent=a,this.child=[],this.scope=n??null,void 0!==i&&(i.symtab=this)}lookupVariable(e){let t=this;for(;null!==t;){if(void 0!==t.variableTable[e])return[t.variableTable[e],t.scope];t=t.parent}return null}insertVariable(e,t){return this.variableTable[e]=t,[this.variableTable[e],this.scope]}lookupFunction(e){let t=this;for(;null!==t;){if(void 0!==t.functionTable[e])return[t.functionTable[e],t.scope];t=t.parent}return null}insertFunction(e,t){return this.functionTable[e]=t,[this.functionTable[e],this.scope]}}const src_SymbolTable={SymbolTable};export{AST,CharString,Complex,ComplexDecimal,ComplexNumber,Configuration,CoreFunctions,Decimal,Evaluator,FunctionHandle,LinearAlgebra,MathML,MathOperation,MultiArray,Structure,SymbolTable,doubleQuoteCharacter,singleQuoteCharacter,stringClass};