mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
2 lines • 1.1 MB
JavaScript
/*! For license information please see mathjslab.node.cjs2015.js.LICENSE.txt */
(()=>{var __webpack_modules__={3110(e,t,r){var n;!function(){"use strict";var s,i,a,o=9e15,l=1e9,c="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",h="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",d={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},m=!0,p="[DecimalError] ",f=p+"Invalid argument: ",g=p+"Precision limit exceeded",y=p+"crypto unavailable",x="[object Decimal]",C=Math.floor,E=Math.pow,v=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,A=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,S=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,_=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,b=1e7,T=u.length-1,M=h.length-1,N={toStringTag:x};function I(e){var t,r,n,s=e.length-1,i="",a=e[0];if(s>0){for(i+=a,t=1;t<s;t++)(r=7-(n=e[t]+"").length)&&(i+=$(r)),i+=n;(r=7-(n=(a=e[t])+"").length)&&(i+=$(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return i+a}function L(e,t,r){if(e!==~~e||e<t||e>r)throw Error(f+e)}function w(e,t,r,n){var s,i,a,o;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=7,s=0):(s=Math.ceil((t+1)/7),t%=7),i=E(10,7-t),o=e[s]%i|0,null==n?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==i||r>3&&o+1==i/2)&&(e[s+1]/i/100|0)==E(10,t-2)-1||(o==i/2||0==o)&&!(e[s+1]/i/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),a=(n||r<4)&&9999==o||!n&&r>3&&4999==o):a=((n||r<4)&&o+1==i||!n&&r>3&&o+1==i/2)&&(e[s+1]/i/1e3|0)==E(10,t-3)-1,a}function O(e,t,r){for(var n,s,i=[0],a=0,o=e.length;a<o;){for(s=i.length;s--;)i[s]*=t;for(i[0]+=c.indexOf(e.charAt(a++)),n=0;n<i.length;n++)i[n]>r-1&&(void 0===i[n+1]&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}N.absoluteValue=N.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},N.ceil=function(){return D(new this.constructor(this),this.e+1,2)},N.clampedTo=N.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(f+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},N.comparedTo=N.cmp=function(e){var t,r,n,s,i=this,a=i.d,o=(e=new i.constructor(e)).d,l=i.s,c=e.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(i.e!==e.e)return i.e>e.e^l<0?1:-1;for(t=0,r=(n=a.length)<(s=o.length)?n:s;t<r;++t)if(a[t]!==o[t])return a[t]>o[t]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1},N.cosine=N.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())+7,n.rounding=1,r=function(e,t){var r,n,s;if(t.isZero())return t;(n=t.d.length)<32?s=(1/K(4,r=Math.ceil(n/3))).toString():(r=16,s="2.3283064365386962890625e-10"),e.precision+=r,t=J(e,1,t.times(s),new e(1));for(var i=r;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return e.precision-=r,t}(n,Z(n,r)),n.precision=e,n.rounding=t,D(2==a||3==a?r.neg():r,e,t,!0)):new n(1):new n(NaN)},N.cubeRoot=N.cbrt=function(){var e,t,r,n,s,i,a,o,l,c,u=this,h=u.constructor;if(!u.isFinite()||u.isZero())return new h(u);for(m=!1,(i=u.s*E(u.s*u,1/3))&&Math.abs(i)!=1/0?n=new h(i.toString()):(r=I(u.d),(i=((e=u.e)-r.length+1)%3)&&(r+=1==i||-2==i?"0":"00"),i=E(r,1/3),e=C((e+1)/3)-(e%3==(e<0?-1:2)),(n=new h(r=i==1/0?"5e"+e:(r=i.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=u.s),a=(e=h.precision)+3;;)if(c=(l=(o=n).times(o).times(o)).plus(u),n=R(c.plus(u).times(o),c.plus(l),a+2,1),I(o.d).slice(0,a)===(r=I(n.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(s||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,e+1,1),t=!n.times(n).times(n).eq(u));break}if(!s&&(D(o,e+1,0),o.times(o).times(o).eq(u))){n=o;break}a+=4,s=1}return m=!0,D(n,e,h.rounding,t)},N.decimalPlaces=N.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-C(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},N.dividedBy=N.div=function(e){return R(this,new this.constructor(e))},N.dividedToIntegerBy=N.divToInt=function(e){var t=this.constructor;return D(R(this,new t(e),0,1,1),t.precision,t.rounding)},N.equals=N.eq=function(e){return 0===this.cmp(e)},N.floor=function(){return D(new this.constructor(this),this.e+1,3)},N.greaterThan=N.gt=function(e){return this.cmp(e)>0},N.greaterThanOrEqualTo=N.gte=function(e){var t=this.cmp(e);return 1==t||0===t},N.hyperbolicCosine=N.cosh=function(){var e,t,r,n,s,i=this,a=i.constructor,o=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return o;r=a.precision,n=a.rounding,a.precision=r+Math.max(i.e,i.sd())+4,a.rounding=1,(s=i.d.length)<32?t=(1/K(4,e=Math.ceil(s/3))).toString():(e=16,t="2.3283064365386962890625e-10"),i=J(a,1,i.times(t),new a(1),!0);for(var l,c=e,u=new a(8);c--;)l=i.times(i),i=o.minus(l.times(u.minus(l.times(u))));return D(i,a.precision=r,a.rounding=n,!0)},N.hyperbolicSine=N.sinh=function(){var e,t,r,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(t=i.precision,r=i.rounding,i.precision=t+Math.max(s.e,s.sd())+4,i.rounding=1,(n=s.d.length)<3)s=J(i,2,s,s,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,s=J(i,2,s=s.times(1/K(5,e)),s,!0);for(var a,o=new i(5),l=new i(16),c=new i(20);e--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(c))))}return i.precision=t,i.rounding=r,D(s,t,r,!0)},N.hyperbolicTangent=N.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,R(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},N.inverseCosine=N.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,s=t.rounding;return-1!==r?0===r?e.isNeg()?V(t,n,s):new t(0):new t(NaN):e.isZero()?V(t,n+4,s).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=s,e.times(2))},N.inverseHyperbolicCosine=N.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,m=!1,r=r.times(r).minus(1).sqrt().plus(r),m=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},N.inverseHyperbolicSine=N.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,m=!1,r=r.times(r).plus(1).sqrt().plus(r),m=!0,n.precision=e,n.rounding=t,r.ln())},N.inverseHyperbolicTangent=N.atanh=function(){var e,t,r,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(e=i.precision,t=i.rounding,n=s.sd(),Math.max(n,e)<2*-s.e-1?D(new i(s),e,t,!0):(i.precision=r=n-s.e,s=R(s.plus(1),new i(1).minus(s),r+e,1),i.precision=e+4,i.rounding=1,s=s.ln(),i.precision=e,i.rounding=t,s.times(.5))):new i(NaN)},N.inverseSine=N.asin=function(){var e,t,r,n,s=this,i=s.constructor;return s.isZero()?new i(s):(t=s.abs().cmp(1),r=i.precision,n=i.rounding,-1!==t?0===t?((e=V(i,r+4,n).times(.5)).s=s.s,e):new i(NaN):(i.precision=r+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=r,i.rounding=n,s.times(2)))},N.inverseTangent=N.atan=function(){var e,t,r,n,s,i,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&h+4<=M)return(a=V(u,h+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new u(NaN);if(h+4<=M)return(a=V(u,h+4,d).times(.5)).s=c.s,a}for(u.precision=o=h+10,u.rounding=1,e=r=Math.min(28,o/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(m=!1,t=Math.ceil(o/7),n=1,l=c.times(c),a=new u(c),s=c;-1!==e;)if(s=s.times(l),i=a.minus(s.div(n+=2)),s=s.times(l),void 0!==(a=i.plus(s.div(n+=2))).d[t])for(e=t;a.d[e]===i.d[e]&&e--;);return r&&(a=a.times(2<<r-1)),m=!0,D(a,u.precision=h,u.rounding=d,!0)},N.isFinite=function(){return!!this.d},N.isInteger=N.isInt=function(){return!!this.d&&C(this.e/7)>this.d.length-2},N.isNaN=function(){return!this.s},N.isNegative=N.isNeg=function(){return this.s<0},N.isPositive=N.isPos=function(){return this.s>0},N.isZero=function(){return!!this.d&&0===this.d[0]},N.lessThan=N.lt=function(e){return this.cmp(e)<0},N.lessThanOrEqualTo=N.lte=function(e){return this.cmp(e)<1},N.logarithm=N.log=function(e){var t,r,n,s,i,a,o,l,c=this,u=c.constructor,h=u.precision,d=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)i=!0;else{for(s=r[0];s%10==0;)s/=10;i=1!==s}if(m=!1,a=z(c,o=h+5),n=t?k(u,o+10):z(e,o),w((l=R(a,n,o,1)).d,s=h,d))do{if(a=z(c,o+=10),n=t?k(u,o+10):z(e,o),l=R(a,n,o,1),!i){+I(l.d).slice(s+1,s+15)+1==1e14&&(l=D(l,h+1,0));break}}while(w(l.d,s+=10,d));return m=!0,D(l,h,d)},N.minus=N.sub=function(e){var t,r,n,s,i,a,o,l,c,u,h,d,p=this,f=p.constructor;if(e=new f(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new f(e.d||p.s!==e.s?p:NaN):e=new f(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,d=e.d,o=f.precision,l=f.rounding,!c[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!c[0])return new f(3===l?-0:0);e=new f(p)}return m?D(e,o,l):e}if(r=C(e.e/7),u=C(p.e/7),c=c.slice(),i=u-r){for((h=i<0)?(t=c,i=-i,a=d.length):(t=d,r=u,a=c.length),i>(n=Math.max(Math.ceil(o/7),a)+2)&&(i=n,t.length=1),t.reverse(),n=i;n--;)t.push(0);t.reverse()}else{for((h=(n=c.length)<(a=d.length))&&(a=n),n=0;n<a;n++)if(c[n]!=d[n]){h=c[n]<d[n];break}i=0}for(h&&(t=c,c=d,d=t,e.s=-e.s),a=c.length,n=d.length-a;n>0;--n)c[a++]=0;for(n=d.length;n>i;){if(c[--n]<d[n]){for(s=n;s&&0===c[--s];)c[s]=b-1;--c[s],c[n]+=b}c[n]-=d[n]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=P(c,r),m?D(e,o,l):e):new f(3===l?-0:0)},N.modulo=N.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]?D(new n(r),n.precision,n.rounding):(m=!1,9==n.modulo?(t=R(r,e.abs(),0,3,1)).s*=e.s:t=R(r,e,0,n.modulo,1),t=t.times(e),m=!0,r.minus(t))},N.naturalExponential=N.exp=function(){return q(this)},N.naturalLogarithm=N.ln=function(){return z(this)},N.negated=N.neg=function(){var e=new this.constructor(this);return e.s=-e.s,D(e)},N.plus=N.add=function(e){var t,r,n,s,i,a,o,l,c,u,h=this,d=h.constructor;if(e=new d(e),!h.d||!e.d)return h.s&&e.s?h.d||(e=new d(e.d||h.s===e.s?h:NaN)):e=new d(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.minus(e);if(c=h.d,u=e.d,o=d.precision,l=d.rounding,!c[0]||!u[0])return u[0]||(e=new d(h)),m?D(e,o,l):e;if(i=C(h.e/7),n=C(e.e/7),c=c.slice(),s=i-n){for(s<0?(r=c,s=-s,a=u.length):(r=u,n=i,a=c.length),s>(a=(i=Math.ceil(o/7))>a?i+1:a+1)&&(s=a,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for((a=c.length)-(s=u.length)<0&&(s=a,r=u,u=c,c=r),t=0;s;)t=(c[--s]=c[s]+u[s]+t)/b|0,c[s]%=b;for(t&&(c.unshift(t),++n),a=c.length;0==c[--a];)c.pop();return e.d=c,e.e=P(c,n),m?D(e,o,l):e},N.precision=N.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(f+e);return r.d?(t=U(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},N.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},N.sine=N.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())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:J(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=J(e,2,t=t.times(1/K(5,r)),t);for(var s,i=new e(5),a=new e(16),o=new e(20);r--;)s=t.times(t),t=t.times(i.plus(s.times(a.times(s).minus(o))));return t}(n,Z(n,r)),n.precision=e,n.rounding=t,D(a>2?r.neg():r,e,t,!0)):new n(NaN)},N.squareRoot=N.sqrt=function(){var e,t,r,n,s,i,a=this,o=a.d,l=a.e,c=a.s,u=a.constructor;if(1!==c||!o||!o[0])return new u(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(m=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=I(o)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=C((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=(i=n).plus(R(a,i,r+2,1)).times(.5),I(i.d).slice(0,r)===(t=I(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(s||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(D(n,l+1,1),e=!n.times(n).eq(a));break}if(!s&&(D(i,l+1,0),i.times(i).eq(a))){n=i;break}r+=4,s=1}return m=!0,D(n,l,u.rounding,e)},N.tangent=N.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=R(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,D(2==a||4==a?r.neg():r,e,t,!0)):new n(NaN)},N.times=N.mul=function(e){var t,r,n,s,i,a,o,l,c,u=this,h=u.constructor,d=u.d,p=(e=new h(e)).d;if(e.s*=u.s,!(d&&d[0]&&p&&p[0]))return new h(!e.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:d&&p?0*e.s:e.s/0);for(r=C(u.e/7)+C(e.e/7),(l=d.length)<(c=p.length)&&(i=d,d=p,p=i,a=l,l=c,c=a),i=[],n=a=l+c;n--;)i.push(0);for(n=c;--n>=0;){for(t=0,s=l+n;s>n;)o=i[s]+p[n]*d[s-n-1]+t,i[s--]=o%b|0,t=o/b|0;i[s]=(i[s]+t)%b|0}for(;!i[--a];)i.pop();return t?++r:i.shift(),e.d=i,e.e=P(i,r),m?D(e,h.precision,h.rounding):e},N.toBinary=function(e,t){return X(this,2,e,t)},N.toDecimalPlaces=N.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(L(e,0,l),void 0===t?t=n.rounding:L(t,0,8),D(r,e+r.e+1,t))},N.toExponential=function(e,t){var r,n=this,s=n.constructor;return void 0===e?r=F(n,!0):(L(e,0,l),void 0===t?t=s.rounding:L(t,0,8),r=F(n=D(new s(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},N.toFixed=function(e,t){var r,n,s=this,i=s.constructor;return void 0===e?r=F(s):(L(e,0,l),void 0===t?t=i.rounding:L(t,0,8),r=F(n=D(new i(s),e+s.e+1,t),!1,e+n.e+1)),s.isNeg()&&!s.isZero()?"-"+r:r},N.toFraction=function(e){var t,r,n,s,i,a,o,l,c,u,h,d,p=this,g=p.d,y=p.constructor;if(!g)return new y(p);if(c=r=new y(1),n=l=new y(0),a=(i=(t=new y(n)).e=U(g)-p.e-1)%7,t.d[0]=E(10,a<0?7+a:a),null==e)e=i>0?t:c;else{if(!(o=new y(e)).isInt()||o.lt(c))throw Error(f+o);e=o.gt(t)?i>0?t:c:o}for(m=!1,o=new y(I(g)),u=y.precision,y.precision=i=7*g.length*2;h=R(o,t,0,1,1),1!=(s=r.plus(h.times(n))).cmp(e);)r=n,n=s,s=c,c=l.plus(h.times(s)),l=s,s=t,t=o.minus(h.times(s)),o=s;return s=R(e.minus(r),n,0,1,1),l=l.plus(s.times(c)),r=r.plus(s.times(n)),l.s=c.s=p.s,d=R(c,n,i,1).minus(p).abs().cmp(R(l,r,i,1).minus(p).abs())<1?[c,n]:[l,r],y.precision=u,m=!0,d},N.toHexadecimal=N.toHex=function(e,t){return X(this,16,e,t)},N.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:L(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]?(m=!1,r=R(r,e,0,t,1).times(e),m=!0,D(r)):(e.s=r.s,r=e),r},N.toNumber=function(){return+this},N.toOctal=function(e,t){return X(this,8,e,t)},N.toPower=N.pow=function(e){var t,r,n,s,i,a,o=this,l=o.constructor,c=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(E(+o,c));if((o=new l(o)).eq(1))return o;if(n=l.precision,i=l.rounding,e.eq(1))return D(o,n,i);if((t=C(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return s=B(l,o,r,n),e.s<0?new l(1).div(s):D(s,n,i);if((a=o.s)<0){if(t<e.d.length-1)return new l(NaN);if(1&e.d[t]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(t=0!=(r=E(+o,c))&&isFinite(r)?new l(r+"").e:C(c*(Math.log("0."+I(o.d))/Math.LN10+o.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?a/0:0):(m=!1,l.rounding=o.s=1,r=Math.min(12,(t+"").length),(s=q(e.times(z(o,n+r)),n)).d&&w((s=D(s,n+5,1)).d,n,i)&&(t=n+10,+I((s=D(q(e.times(z(o,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(s=D(s,n+1,0))),s.s=a,m=!0,l.rounding=i,D(s,n,i))},N.toPrecision=function(e,t){var r,n=this,s=n.constructor;return void 0===e?r=F(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(L(e,1,l),void 0===t?t=s.rounding:L(t,0,8),r=F(n=D(new s(n),e,t),e<=n.e||n.e<=s.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},N.toSignificantDigits=N.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(L(e,1,l),void 0===t?t=r.rounding:L(t,0,8)),D(new r(this),e,t)},N.toString=function(){var e=this,t=e.constructor,r=F(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},N.truncated=N.trunc=function(){return D(new this.constructor(this),this.e+1,1)},N.valueOf=N.toJSON=function(){var e=this,t=e.constructor,r=F(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var R=function(){function e(e,t,r){var n,s=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+s,e[i]=n%r|0,s=n/r|0;return s&&e.unshift(s),e}function t(e,t,r,n){var s,i;if(r!=n)i=r>n?1:-1;else for(s=i=0;s<r;s++)if(e[s]!=t[s]){i=e[s]>t[s]?1:-1;break}return i}function r(e,t,r,n){for(var s=0;r--;)e[r]-=s,s=e[r]<t[r]?1:0,e[r]=s*n+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,s,a,o,l,c){var u,h,d,m,p,f,g,y,x,E,v,A,S,_,T,M,N,I,L,w,O=n.constructor,R=n.s==s.s?1:-1,F=n.d,P=s.d;if(!(F&&F[0]&&P&&P[0]))return new O(n.s&&s.s&&(F?!P||F[0]!=P[0]:P)?F&&0==F[0]||!P?0*R:R/0:NaN);for(c?(p=1,h=n.e-s.e):(c=b,p=7,h=C(n.e/p)-C(s.e/p)),L=P.length,N=F.length,E=(x=new O(R)).d=[],d=0;P[d]==(F[d]||0);d++);if(P[d]>(F[d]||0)&&h--,null==a?(_=a=O.precision,o=O.rounding):_=l?a+(n.e-s.e)+1:a,_<0)E.push(1),f=!0;else{if(_=_/p+2|0,d=0,1==L){for(m=0,P=P[0],_++;(d<N||m)&&_--;d++)T=m*c+(F[d]||0),E[d]=T/P|0,m=T%P|0;f=m||d<N}else{for((m=c/(P[0]+1)|0)>1&&(P=e(P,m,c),F=e(F,m,c),L=P.length,N=F.length),M=L,A=(v=F.slice(0,L)).length;A<L;)v[A++]=0;(w=P.slice()).unshift(0),I=P[0],P[1]>=c/2&&++I;do{m=0,(u=t(P,v,L,A))<0?(S=v[0],L!=A&&(S=S*c+(v[1]||0)),(m=S/I|0)>1?(m>=c&&(m=c-1),1==(u=t(g=e(P,m,c),v,y=g.length,A=v.length))&&(m--,r(g,L<y?w:P,y,c))):(0==m&&(u=m=1),g=P.slice()),(y=g.length)<A&&g.unshift(0),r(v,g,A,c),-1==u&&(u=t(P,v,L,A=v.length))<1&&(m++,r(v,L<A?w:P,A,c)),A=v.length):0===u&&(m++,v=[0]),E[d++]=m,u&&v[0]?v[A++]=F[M]||0:(v=[F[M]],A=1)}while((M++<N||void 0!==v[0])&&_--);f=void 0!==v[0]}E[0]||E.shift()}if(1==p)x.e=h,i=f;else{for(d=1,m=E[0];m>=10;m/=10)d++;x.e=d+h*p-1,D(x,l?a+x.e+1:a,o,f)}return x}}();function D(e,t,r,n){var s,i,a,o,l,c,u,h,d,p=e.constructor;e:if(null!=t){if(!(h=e.d))return e;for(s=1,o=h[0];o>=10;o/=10)s++;if((i=t-s)<0)i+=7,a=t,l=(u=h[d=0])/E(10,s-a-1)%10|0;else if((d=Math.ceil((i+1)/7))>=(o=h.length)){if(!n)break e;for(;o++<=d;)h.push(0);u=l=0,s=1,a=(i%=7)-7+1}else{for(u=o=h[d],s=1;o>=10;o/=10)s++;l=(a=(i%=7)-7+s)<0?0:u/E(10,s-a-1)%10|0}if(n=n||t<0||void 0!==h[d+1]||(a<0?u:u%E(10,s-a-1)),c=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(i>0?a>0?u/E(10,s-a):0:h[d-1])%10&1||r==(e.s<0?8:7)),t<1||!h[0])return h.length=0,c?(t-=e.e+1,h[0]=E(10,(7-t%7)%7),e.e=-t||0):h[0]=e.e=0,e;if(0==i?(h.length=d,o=1,d--):(h.length=d+1,o=E(10,7-i),h[d]=a>0?(u/E(10,s-a)%E(10,a)|0)*o:0),c)for(;;){if(0==d){for(i=1,a=h[0];a>=10;a/=10)i++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;i!=o&&(e.e++,h[0]==b&&(h[0]=1));break}if(h[d]+=o,h[d]!=b)break;h[d--]=0,o=1}for(i=h.length;0===h[--i];)h.pop()}return m&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function F(e,t,r){if(!e.isFinite())return G(e);var n,s=e.e,i=I(e.d),a=i.length;return t?(r&&(n=r-a)>0?i=i.charAt(0)+"."+i.slice(1)+$(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):s<0?(i="0."+$(-s-1)+i,r&&(n=r-a)>0&&(i+=$(n))):s>=a?(i+=$(s+1-a),r&&(n=r-s-1)>0&&(i=i+"."+$(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),r&&(n=r-a)>0&&(s+1===a&&(i+="."),i+=$(n))),i}function P(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function k(e,t,r){if(t>T)throw m=!0,r&&(e.precision=r),Error(g);return D(new e(u),t,1,!0)}function V(e,t,r){if(t>M)throw Error(g);return D(new e(h),t,r,!0)}function U(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function $(e){for(var t="";e--;)t+="0";return t}function B(e,t,r,n){var s,i=new e(1),a=Math.ceil(n/7+4);for(m=!1;;){if(r%2&&Y((i=i.times(t)).d,a)&&(s=!0),0===(r=C(r/2))){r=i.d.length-1,s&&0===i.d[r]&&++i.d[r];break}Y((t=t.times(t)).d,a)}return m=!0,i}function H(e){return 1&e.d[e.d.length-1]}function j(e,t,r){for(var n,s,i=new e(t[0]),a=0;++a<t.length;){if(!(s=new e(t[a])).s){i=s;break}((n=i.cmp(s))===r||0===n&&i.s===r)&&(i=s)}return i}function q(e,t){var r,n,s,i,a,o,l,c=0,u=0,h=0,d=e.constructor,p=d.rounding,f=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(m=!1,l=f):l=t,o=new d(.03125);e.e>-2;)e=e.times(o),h+=5;for(l+=n=Math.log(E(2,h))/Math.LN10*2+5|0,r=i=a=new d(1),d.precision=l;;){if(i=D(i.times(e),l,1),r=r.times(++u),I((o=a.plus(R(i,r,l,1))).d).slice(0,l)===I(a.d).slice(0,l)){for(s=h;s--;)a=D(a.times(a),l,1);if(null!=t)return d.precision=f,a;if(!(c<3&&w(a.d,l-n,p,c)))return D(a,d.precision=f,p,m=!0);d.precision=l+=10,r=i=o=new d(1),u=0,c++}a=o}}function z(e,t){var r,n,s,i,a,o,l,c,u,h,d,p=1,f=e,g=f.d,y=f.constructor,x=y.rounding,C=y.precision;if(f.s<0||!g||!g[0]||!f.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=f.s?NaN:g?0:f);if(null==t?(m=!1,u=C):u=t,y.precision=u+=10,n=(r=I(g)).charAt(0),!(Math.abs(i=f.e)<15e14))return c=k(y,u+2,C).times(i+""),f=z(new y(n+"."+r.slice(1)),u-10).plus(c),y.precision=C,null==t?D(f,C,x,m=!0):f;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=I((f=f.times(e)).d)).charAt(0),p++;for(i=f.e,n>1?(f=new y("0."+r),i++):f=new y(n+"."+r.slice(1)),h=f,l=a=f=R(f.minus(1),f.plus(1),u,1),d=D(f.times(f),u,1),s=3;;){if(a=D(a.times(d),u,1),I((c=l.plus(R(a,new y(s),u,1))).d).slice(0,u)===I(l.d).slice(0,u)){if(l=l.times(2),0!==i&&(l=l.plus(k(y,u+2,C).times(i+""))),l=R(l,new y(p),u,1),null!=t)return y.precision=C,l;if(!w(l.d,u-10,x,o))return D(l,y.precision=C,x,m=!0);y.precision=u+=10,c=a=f=R(h.minus(1),h.plus(1),u,1),d=D(f.times(f),u,1),s=o=1}l=c,s+=2}}function G(e){return String(e.s*e.s/0)}function W(e,t){var r,n,s;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(s=t.length;48===t.charCodeAt(s-1);--s);if(t=t.slice(n,s)){if(s-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),n<s){for(n&&e.d.push(+t.slice(0,n)),s-=7;n<s;)e.d.push(+t.slice(n,n+=7));n=7-(t=t.slice(n)).length}else n-=s;for(;n--;)t+="0";e.d.push(+t),m&&(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 Q(e,t){var r,n,i,a,o,l,c,u,h;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),_.test(t))return W(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(A.test(t))r=16,t=t.toLowerCase();else if(v.test(t))r=2;else{if(!S.test(t))throw Error(f+t);r=8}for((a=t.search(/p/i))>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),o=(a=t.indexOf("."))>=0,n=e.constructor,o&&(a=(l=(t=t.replace(".","")).length)-a,i=B(n,new n(r),a,2*a)),a=h=(u=O(t,r,b)).length-1;0===u[a];--a)u.pop();return a<0?new n(0*e.s):(e.e=P(u,h),e.d=u,m=!1,o&&(e=R(e,i,4*l)),c&&(e=e.times(Math.abs(c)<54?E(2,c):s.pow(2,c))),m=!0,e)}function J(e,t,r,n,s){var i,a,o,l,c=e.precision,u=Math.ceil(c/7);for(m=!1,l=r.times(r),o=new e(n);;){if(a=R(o.times(l),new e(t++*t++),c,1),o=s?n.plus(a):n.minus(a),n=R(a.times(l),new e(t++*t++),c,1),void 0!==(a=o.plus(n)).d[u]){for(i=u;a.d[i]===o.d[i]&&i--;);if(-1==i)break}i=o,o=n,n=a,a=i}return m=!0,a.d.length=u+1,a}function K(e,t){for(var r=e;--t;)r*=e;return r}function Z(e,t){var r,n=t.s<0,s=V(e,e.precision,1),i=s.times(.5);if((t=t.abs()).lte(i))return a=n?4:1,t;if((r=t.divToInt(s)).isZero())a=n?3:2;else{if((t=t.minus(r.times(s))).lte(i))return a=H(r)?n?2:3:n?4:1,t;a=H(r)?n?1:4:n?3:2}return t.minus(s).abs()}function X(e,t,r,n){var s,a,o,u,h,d,m,p,f,g=e.constructor,y=void 0!==r;if(y?(L(r,1,l),void 0===n?n=g.rounding:L(n,0,8)):(r=g.precision,n=g.rounding),e.isFinite()){for(y?(s=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):s=t,(o=(m=F(e)).indexOf("."))>=0&&(m=m.replace(".",""),(f=new g(1)).e=m.length-o,f.d=O(F(f),10,s),f.e=f.d.length),a=h=(p=O(m,10,s)).length;0==p[--h];)p.pop();if(p[0]){if(o<0?a--:((e=new g(e)).d=p,e.e=a,p=(e=R(e,f,r,n,0,s)).d,a=e.e,d=i),o=p[r],u=s/2,d=d||void 0!==p[r+1],d=n<4?(void 0!==o||d)&&(0===n||n===(e.s<0?3:2)):o>u||o===u&&(4===n||d||6===n&&1&p[r-1]||n===(e.s<0?8:7)),p.length=r,d)for(;++p[--r]>s-1;)p[r]=0,r||(++a,p.unshift(1));for(h=p.length;!p[h-1];--h);for(o=0,m="";o<h;o++)m+=c.charAt(p[o]);if(y){if(h>1)if(16==t||8==t){for(o=16==t?4:3,--h;h%o;h++)m+="0";for(h=(p=O(m,s,t)).length;!p[h-1];--h);for(o=1,m="1.";o<h;o++)m+=c.charAt(p[o])}else m=m.charAt(0)+"."+m.slice(1);m=m+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)m="0"+m;m="0."+m}else if(++a>h)for(a-=h;a--;)m+="0";else a<h&&(m=m.slice(0,a)+"."+m.slice(a))}else m=y?"0p+0":"0";m=(16==t?"0x":2==t?"0b":8==t?"0o":"")+m}else m=G(e);return e.s<0?"-"+m:m}function Y(e,t){if(e.length>t)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function se(e){return new this(e).asin()}function ie(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var r,n=this.precision,s=this.rounding,i=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?V(this,n,s):new this(0)).s=e.s:!e.d||t.isZero()?(r=V(this,i,1).times(.5)).s=e.s:t.s<0?(this.precision=i,this.rounding=1,r=this.atan(R(e,t,i,1)),t=V(this,i,1),this.precision=n,this.rounding=s,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(R(e,t,i,1)):(r=V(this,i,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function ue(e){return D(e=new this(e),e.e+1,2)}function he(e,t,r){return new this(e).clamp(t,r)}function de(e){if(!e||"object"!=typeof e)throw Error(p+"Object expected");var t,r,n,s=!0===e.defaults,i=["precision",1,l,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(r=i[t],s&&(this[r]=d[r]),void 0!==(n=e[r])){if(!(C(n)===n&&n>=i[t+1]&&n<=i[t+2]))throw Error(f+r+": "+n);this[r]=n}if(r="crypto",s&&(this[r]=d[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(f+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(y);this[r]=!0}else this[r]=!1}return this}function me(e){return new this(e).cos()}function pe(e){return new this(e).cosh()}function fe(e,t){return new this(e).div(t)}function ge(e){return new this(e).exp()}function ye(e){return D(e=new this(e),e.e+1,3)}function xe(){var e,t,r=new this(0);for(m=!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 m=!0,new this(1/0);r=t}return m=!0,r.sqrt()}function Ce(e){return e instanceof s||e&&e.toStringTag===x||!1}function Ee(e){return new this(e).ln()}function ve(e,t){return new this(e).log(t)}function Ae(e){return new this(e).log(2)}function Se(e){return new this(e).log(10)}function _e(){return j(this,arguments,-1)}function be(){return j(this,arguments,1)}function Te(e,t){return new this(e).mod(t)}function Me(e,t){return new this(e).mul(t)}function Ne(e,t){return new this(e).pow(t)}function Ie(e){var t,r,n,s,i=0,a=new this(1),o=[];if(void 0===e?e=this.precision:L(e,1,l),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));i<n;)(s=t[i])>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=s%1e7;else{if(!crypto.randomBytes)throw Error(y);for(t=crypto.randomBytes(n*=4);i<n;)(s=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((127&t[i+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,i):(o.push(s%1e7),i+=4);i=n/4}else for(;i<n;)o[i++]=1e7*Math.random()|0;for(e%=7,(n=o[--i])&&e&&(s=E(10,7-e),o[i]=(n/s|0)*s);0===o[i];i--)o.pop();if(i<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=7)o.shift();for(n=1,s=o[0];s>=10;s/=10)n++;n<7&&(r-=7-n)}return a.e=r,a.d=o,a}function Le(e){return D(e=new this(e),e.e+1,this.rounding)}function we(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Oe(e){return new this(e).sin()}function Re(e){return new this(e).sinh()}function De(e){return new this(e).sqrt()}function Fe(e,t){return new this(e).sub(t)}function Pe(){var e=0,t=arguments,r=new this(t[e]);for(m=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return m=!0,D(r,this.precision,this.rounding)}function ke(e){return new this(e).tan()}function Ve(e){return new this(e).tanh()}function Ue(e){return D(e=new this(e),e.e+1,1)}(s=function e(t){var r,n,s;function i(e){var t,r,n,s=this;if(!(s instanceof i))return new i(e);if(s.constructor=i,Ce(e))return s.s=e.s,void(m?!e.d||e.e>i.maxE?(s.e=NaN,s.d=null):e.e<i.minE?(s.e=0,s.d=[0]):(s.e=e.e,s.d=e.d.slice()):(s.e=e.e,s.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return s.s=1/e<0?-1:1,s.e=0,void(s.d=[0]);if(e<0?(e=-e,s.s=-1):s.s=1,e===~~e&&e<1e7){for(t=0,r=e;r>=10;r/=10)t++;return void(m?t>i.maxE?(s.e=NaN,s.d=null):t<i.minE?(s.e=0,s.d=[0]):(s.e=t,s.d=[e]):(s.e=t,s.d=[e]))}return 0*e!=0?(e||(s.s=NaN),s.e=NaN,void(s.d=null)):W(s,e.toString())}if("string"===n)return 45===(r=e.charCodeAt(0))?(e=e.slice(1),s.s=-1):(43===r&&(e=e.slice(1)),s.s=1),_.test(e)?W(s,e):Q(s,e);if("bigint"===n)return e<0?(e=-e,s.s=-1):s.s=1,W(s,e.toString());throw Error(f+e)}if(i.prototype=N,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=de,i.clone=e,i.isDecimal=Ce,i.abs=ee,i.acos=te,i.acosh=re,i.add=ne,i.asin=se,i.asinh=ie,i.atan=ae,i.atanh=oe,i.atan2=le,i.cbrt=ce,i.ceil=ue,i.clamp=he,i.cos=me,i.cosh=pe,i.div=fe,i.exp=ge,i.floor=ye,i.hypot=xe,i.ln=Ee,i.log=ve,i.log10=Se,i.log2=Ae,i.max=_e,i.min=be,i.mod=Te,i.mul=Me,i.pow=Ne,i.random=Ie,i.round=Le,i.sign=we,i.sin=Oe,i.sinh=Re,i.sqrt=De,i.sub=Fe,i.sum=Pe,i.tan=ke,i.tanh=Ve,i.trunc=Ue,void 0===t&&(t={}),t&&!0!==t.defaults)for(s=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<s.length;)t.hasOwnProperty(n=s[r++])||(t[n]=this[n]);return i.config(t),i}(d)).prototype.constructor=s,s.default=s.Decimal=s,u=new s(u),h=new s(h),void 0===(n=function(){return s}.call(t,r,t,e))||(e.exports=n)}()},7970(e){"use strict";e.exports=global},5323(e,t,r){"use strict";var n=r(7970);e.exports=function(){return"object"==typeof global&&global&&global.Math===Math&&global.Array===Array?global:n}},6109(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AST=void 0;const n=r(5956),s=r(845),i=r(1271),a=r(7679),o=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","()","!","~","+_","-_","++_","--_",".'","'","_++","_--"],l=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="],c=["()","!","~","+_","-_","++_","--_"],u=[".'","'","_++","_--"];class h{}t.AST=h,h.nodeString=n.CharString.create,h.nodeNumber=s.Complex.parse,h.firstRow=a.MultiArray.firstRow,h.appendRow=a.MultiArray.appendRow,h.emptyArray=a.MultiArray.emptyArray,h.reload=()=>{h.nodeString=n.CharString.create,h.nodeNumber=s.Complex.parse,h.firstRow=a.MultiArray.firstRow,h.appendRow=a.MultiArray.appendRow,h.emptyArray=a.MultiArray.emptyArray},h.nodeCopy=e=>Object.assign({},e),h.isNodeBase=e=>{if("object"!=typeof e||null===e||!("type"in e))return!1;const t=Reflect.get(e,"type");return"string"==typeof t||"number"==typeof t},h.isNodeIdentifier=e=>h.isNodeBase(e)&&"IDENT"===e.type&&"string"==typeof Reflect.get(e,"id"),h.isNodeList=e=>h.isNodeBase(e)&&"LIST"===e.type&&Array.isArray(Reflect.get(e,"list")),h.isNodeCmdWList=e=>h.isNodeBase(e)&&"CMDWLIST"===e.type&&"string"==typeof Reflect.get(e,"id")&&Array.isArray(Reflect.get(e,"args")),h.isNodeIndexExpr=e=>h.isNodeBase(e)&&"IDX"===e.type&&("()"===Reflect.get(e,"delim")||"{}"===Reflect.get(e,"delim"))&&Array.isArray(Reflect.get(e,"args")),h.isNodeSuperclassConstructor=e=>h.isNodeBase(e)&&"SUPERCLASS_CTOR"===e.type&&h.isNodeIdentifier(Reflect.get(e,"superclass"))&&Array.isArray(Reflect.get(e,"args")),h.isNodeRange=e=>h.isNodeBase(e)&&"RANGE"===e.type&&"start_"in e&&"stop_"in e,h.isNodeColon=e=>h.isNodeBase(e)&&":"===e.type,h.isNodeEndRange=e=>h.isNodeBase(e)&&"ENDRANGE"===e.type,h.isNodeIndirectRef=e=>h.isNodeBase(e)&&"."===e.type&&Array.isArray(Reflect.get(e,"field")),h.isNodeReturnList=e=>h.isNodeBase(e)&&"RETLIST"===e.type&&"function"==typeof Reflect.get(e,"selector")&&"function"==typeof Reflect.get(e,"handler"),h.isNodeIgnoredTarget=e=>h.isNodeBase(e)&&"<~>"===e.type,h.isNodeOperation=e=>h.isNodeBase(e)&&o.includes(e.type),h.isNodeBinaryOperation=e=>h.isNodeOperation(e)&&l.includes(e.type)&&"left"in e&&"right"in e,h.isNodePrefixOperation=e=>h.isNodeOperation(e)&&c.includes(e.type)&&"right"in e,h.isNodePostfixOperation=e=>h.isNodeOperation(e)&&u.includes(e.type)&&"left"in e,h.isNodeFunctionReturn=e=>h.isNodeIdentifier(e)||h.isNodeIgnoredTarget(e),h.isNodeDeclarationElement=e=>h.isNodeIdentifier(e)||h.isNodeDefaultedParameter(e),h.isNodeDefaultedParameter=e=>h.isNodeBinaryOperation(e)&&"="===e.type&&h.isNodeIdentifier(e.left),h.isNodeFunctionParameter=e=>h.isNodeIdentifier(e)||h.isNodeIgnoredTarget(e)||h.isNodeDefaultedParameter(e),h.isNodeAssignmentTarget=e=>h.isNodeIdentifier(e)||h.isNodeIgnoredTarget(e)||h.isNodeIndexExpr(e)||h.isNodeIndirectRef(e)||a.MultiArray.isInstanceOf(e),h.isNodeDeclaration=e=>h.isNodeBase(e)&&("GLOBAL"===e.type||"PERSIST"===e.type),h.isNodeImport=e=>h.isNodeBase(e)&&"IMPORT"===e.type&&Array.isArray(e.imports),h.isNodeStatement=e=>h.isNodeDeclaration(e)||h.isNodeImport(e)||h.isNodeBase(e)&&("RETURN"===e.type||"BREAK"===e.type||"CONTINUE"===e.type||"IF"===e.type||"SWITCH"===e.type||"WHILE"===e.type||"DO_UNTIL"===e.type||"FOR"===e.type||"SPMD"===e.type||"TRY"===e.type||"UNWIND_PROTECT"===e.type)||h.isNodeFunctionDefinition(e)||h.isNodeClassDef(e),h.isNodeClassMember=e=>h.isNodeClassSection(e)||h.isNodeClassAttribute(e)||h.isNodeClassProperty(e)||h.isNodeClassEvent(e)||h.isNodeClassEnumeration(e),h.isNodeProgramElement=e=>h.isStrictNodeExpr(e)||h.isNodeStatement(e)||h.isNodeClassMember(e),h.isNodeFunctionDefinition=e=>h.isNodeBase(e)&&"FCNDEF"===e.type,h.isNodeClassDef=e=>h.isNodeBase(e)&&"CLASSDEF"===e.type,h.isNodeMetaClass=e=>h.isNodeBase(e)&&"METACLASS"===e.type&&h.isNodeIdentifier(e.className),h.isRuntimeExpressionValue=e=>null!=e&&(a.MultiArray.isInstanceOf(e)||s.Complex.isInstanceOf(e)||n.CharString.isInstanceOf(e)||"object"==typeof e&&"number"==typeof e.type),h.isStrictNodeExpr=e=>h.isRuntimeExpressionValue(e)||h.isNodeBase(e)&&("VOID"===e.type||h.isNodeIdentifier(e)||h.isNodeCmdWList(e)||h.isNodeIndexExpr(e)||h.isNodeSuperclassConstructor(e)||h.isNodeMetaClass(e)||h.isNodeRange(e)||h.isNodeColon(e)||h.isNodeEndRange(e)||h.isNodeOperation(e)||h.isNodeIgnoredTarget(e)||h.isNodeIndirectRef(e)||h.isNodeImport(e)||h.isNodeReturnList(e)),h.isExpressionBoundaryValue=e=>h.isStrictNodeExpr(e)||h.isNodeList(e),h.requireStrictNodeExpr=(e,t="expression")=>{if(!h.isStrictNodeExpr(e))throw new TypeError(`${t} is not an expression node.`);return e},h.isNodeArguments=e=>h.isNodeBase(e)&&"ARGS"===e.type&&Array.isArray(e.validation),h.isNodeArgumentValidation=e=>h.isNodeBase(e)&&"ARGVALID"===e.type&&"name"in e&&Array.isArray(e.size),h.isNodeSwitchCase=e=>h.isNodeBase(e)&&"CASE"===e.type,h.isNodeClassSection=e=>h.isNodeBase(e)&&"CLASS_SECTION"===e.type,h.isNodeClassAttribute=e=>h.isNodeBase(e)&&"CLASS_ATTRIBUTE"===e.type,h.isNodeClassProperty=e=>h.isNodeBase(e)&&"CLASS_PROPERTY"===e.type,h.isNodeClassEvent=e=>h.isNodeBase(e)&&"CLASS_EVENT"===e.type,h.isNodeClassEnumeration=e=>h.isNodeBase(e)&&"CLASS_ENUMERATION"===e.type,h.nodeVoid=()=>({type:"VOID",omitAnswer:!0,omitOutput:!0}),h.nodeIdentifier=e=>({type:"IDENT",id:e.replace(/(\r\n|[\n\r])|[\ ]/gm,""),omitAnswer:!1,omitOutput:!1}),h.nodeMetaClass=e=>{const t={type:"METACLASS",className:e,omitAnswer:!1,omitOutput:!1};return t.className.parent=t,t},h.factoryExpression=(e,t,r=!1)=>r&&h.isNodeList(e)?e:h.requireStrictNodeExpr(e,t),h.factoryExpressionList=(e,t)=>e?e.list.map((e,r)=>h.factoryExpression(e,`${t}${r+1}`)):[],h.factoryCommandWordList=(e,t)=>e?e.list.map((e,r)=>{if(!n.CharString.isInstanceOf(e))throw new TypeError(`${t}${r+1} is not a command word.`);return e}):[],h.factoryNodeList=(e,t,r)=>e.list.map((e,n)=>{if(!t(e))throw new TypeError(`${r}${n+1} has invalid node type.`);return e}),h.factoryProgramElementList=(e,t)=>h.factoryNodeList(e,h.isNodeProgramElement,t),h.factoryArrayElementList=(e,t)=>h.factoryExpressionList(e,t),h.factoryArgumentClass=(e,t)=>{if(null===e||h.isNodeList(e)&&0===e.list.length)return e;if(!h.isNodeIdentifier(e)&&!h.isNodeMetaClass(e))throw new TypeError(`${t} has invalid node type.`);return e},h.nodeCmdWList=(e,t)=>{const r={type:"CMDWLIST",id:e.id,args:h.factoryCommandWordList(t,"command argument ")};return e.parent=r,r.args.forEach(e=>{e.parent=r}),r.omitAnswer=!0,r.omitOutput=!1,r},h.nodeEmptyCmdWList=e=>{var t;const r={type:"CMDWLIST",id:e.id,args:[],parent:e.parent,index:e.index,start:e.start,stop:e.stop,omitAnswer:!0,omitOutput:null!==(t=e.omitOutput)&&void 0!==t&&t};return e.parent=r,r},h.nodeIndexExpr=(e,t=null,r="()")=>{const n={type:"IDX",expr:h.factoryExpression(e,"indexed expression"),args:h.factoryExpressionList(t,"index argument "),delim:r,omitAnswer:!1,omitOutput:!1};return n.expr.parent=n,n.args.forEach((e,t)=>{h.isNodeBase(e)&&(e.parent=n,e.index=t)}),n},h.nodeSuperclassConstructor=(e,t,r=null)=>{const n={type:"SUPERCLASS_CTOR",instance:h.factoryExpression(e,"superclass constructor instance"),superclass:t,args:h.factoryExpressionList(r,"superclass constructor argument "),omitAnswer:!1,omitOutput:!1};return n.instance.parent=n,n.superclass.parent=n,n.args.forEach(e=>{h.isNodeBase(e)&&(e.parent=n)}),n},h.nodeRange=(e,t,r)=>{const n={type:"RANGE",start_:h.factoryExpression(e,"range start"),stop_:h.factoryExpression(t,"range stop"),stride_:r?h.factoryExpression(r,"range stride"):null,omitAnswer:!1,omitOutput:!1};return n.start_.parent=n,n.stop_.parent=n,r&&(n.stride_.parent=n),n},h.nodeColon=()=>({type:":",omitAnswer:!1,omitOutput:!1}),h.nodeEndRange=()=>({type:"ENDRANGE",omitAnswer:!1,omitOutput:!1}),h.omitAnswerNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]),h.assignmentNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]),h.anonymousFunctionForbiddenOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]),h.assertAnonymousFunctionExpression=e=>{if(h.isNodeOperation(e)&&h.anonymousFunctionForbiddenOperation.has(e.type))throw new SyntaxError("anonymous function bodies cannot contain assignment, increment, or decrement operators.");h.isNodeBinaryOperation(e)?(h.assertAnonymousFunctionExpression(e.left),h.assertAnonymousFunctionExpression(e.right)):h.isNodePrefixOperation(e)?h.assertAnonymousFunctionExpression(e.right):h.isNodePostfixOperation(e)?h.assertAnonymousFunctionExpression(e.left):h.isNodeIndexExpr(e)?(h.assertAnonymousFunctionExpression(e.expr),e.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeSuperclassConstructor(e)?(h.assertAnonymousFunctionExpression(e.instance),e.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeRange(e)?(h.assertAnonymousFunctionExpression(e.start_),h.assertAnonymousFunctionExpression(e.stop_),e.stride_&&h.assertAnonymousFunctionExpression(e.stride_)):h.isNodeIndirectRef(e)?(h.assertAnonymousFunctionExpression(e.obj),e.field.forEach(e=>{"string"!=typeof e&&h.assertAnonymousFunctionExpression(e)})):h.isNodeList(e)?e.list.forEach(h.assertAnonymousFunctionExpression):a.MultiArray.isInstanceOf(e)?a.MultiArray.linearize(e).forEach(h.assertAnonymousFunctionExpression):i.FunctionHandle.isInstanceOf(e)&&e.expression&&h.assertAnonymousFunctionExpression(e.expression)},h.assertFunctionSignatureList=(e,t,r,n)=>{const s=new Set;e.forEach((i,a)=>{if(h.isNodeIgnoredTarget(i))return;let o;if(h.isNodeDefaultedParameter(i)){if("parameter"!==r||"anonymous function"===n)throw new SyntaxError(`invalid ${r} list in ${n}.`);o=i.left.id}else{if(!h.isNodeIdentifier(i))throw new SyntaxError(`invalid ${r} list in ${n}.`);o=i.id}if(s.has(o))throw new SyntaxError(`duplicate ${r} name '${o}' in ${n}.`);if(s.add(o),o===t&&a!==e.length-1)throw new SyntaxError(`${t} must be the last ${r} in ${n}.`);if(h.isNodeDefaultedParameter(i)&&o===t)throw new SyntaxError(`${t} default value is not supported in ${n}.`)})},h.assertAnonymousFunctionParameters=e=>{h.assertFunctionSignatureList(e,"varargin","parameter","anonymous function")},h.nodeOperation=(e,t,r)=>{let n;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"|=":if(void 0===r)throw new TypeError(`right operand for ${e} is missing.`);n={type:e,left:h.factoryExpression(t,`left operand for ${e}`),right:h.factoryExpression(r,`right operand for ${e}`,h.assignmentNodeOperation.has(e))},n.left.parent=n,n.right.parent=n;break;case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":n={type:e,right:h.factoryExpression(t,`operand for ${e}`)},n.right.parent=n;break;case".'":case"'":case"_++":case"_--":n={type:e,left:h.factoryExpression(t,`operand for ${e}`)},n.left.parent=n;break;default:n={type:`INVALID:${e}`}}return n.omitAnswer=h.omitAnswerNodeOperation.has(n.type),n.omitOutput=!1,n},h.nodeDefaultedParameter=(e,t)=>{const r=h.nodeOperation("=",e,t);if(!h.isNodeDefaultedParameter(r))throw new TypeError("defaulted parameter has invalid node type.");return r},h.nodeIgnoredTarget=()=>({type:"<~>",omitAnswer:!0,omitOutput:!1}),h.nodeListFirst=e=>{const t={type:"LIST",list:e?[e]:[],omitAnswer:!1,omitOutput:!1};return e&&(t.list[0].parent=t),t},h.appendNodeList=(e,t)=>(t.parent=e,e.list.push(t),e),h.nodeList=e=>{const t={type:"LIST",list:e,omitAnswer:!1,omitOutput:!1};return t.list.forEach(e=>e.parent=t),t},h.nodeFirstRow=(e=null,t)=>e?h.firstRow(h.factoryArrayElementList(e,"array element "),t):h.emptyArray(t),h.nodeAppendRow=(e,t=null)=>t?h.appendRow(e,h.factoryArrayElementList(t,"array element ")):e,h.nodeIndirectRef=(e,t)=>{if(h.isNodeIndirectRef(e))return e.field.push("string"==typeof t?t:h.factoryExpression(t,"indirect reference field")),"string"!=typeof t&&(t.parent=e),e;{const r={type:".",obj:h.factoryExpression(e,"indirect reference object"),field:["string"==typeof t?t:h.factoryExpression(t,"indirect reference field")],omitAnswer:!1,omitOutput:!1};return r.obj.parent=r,"string"!=typeof t&&(t.parent=r),r}},h.nodeReturnList=(e,t)=>Object.assign({type:"RETLIST",selector:e},void 0===t?{handler:e=>({length:e})}:"function"==typeof t?{handler:t}:t),h.nodeCommaSeparatedReturnList=(e,t,r)=>{const n=h.nodeReturnList(t,r);return n.commaSeparated=!0,n.returnListLength=e,n},h.nodeBoundedReturnList=(e,t,r,n)=>h.nodeReturnList((r,s)=>(h.throwErrorIfGreaterThanReturnList(e,r.length,n),t(r,s)),t=>(h.throwErrorIfGreaterThanReturnList(e,t,n),r?r(t):{length:t})),h.ensureReturnList=e=>{if(h.isNodeReturnList(e))return e;const t=e;return h.nodeReturnList((e,r)=>{if(0===r)return t;throw h.throwErrorIfGreaterThanReturnList(1,r+1),new EvalError("unreachable return-list selector branch.")})},h.throwErrorIfGreaterThanReturnList=(e,t,r)=>{if(t>e){const t=`element number ${e+1} undefined in return list`;throw r&&r(t),new EvalError(t)}},h.reduceToFirstIfReturnList=e=>{if(h.isNodeReturnList(e)){const t=e.selector(e.handler(1),0);return t.parent=e.parent,t}return e},h.throwInvalidCallError=(e,t=!0,r)=>{if(t){const t=`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`;throw r&&r(t),new SyntaxError(t)}},h.nodeFunctionHandle=(e=null,t=null,r=null)=>{const n=t?h.factoryNodeList(t,h.isNodeFunctionParameter,"function handle parameter "):[],s=r?h.factoryExpression(r,"function handle expression"):null;e||(h.assertAnonymousFunctionParameters(n),s&&h.assertAnonymousFunctionExpression(s));const a=i.FunctionHandle.create(e?e.id:void 0,n,s);return a.parameter.forEach(e=>{e.parent=a}),a.expression&&(a.expression.parent=a),a},h.nodeFunctionDefinition=(e,t,r,n,s)=>{const i=h.factoryNodeList(t,h.isNodeFunctionReturn,"function return "),a=h.factoryNodeList(r,h.isNodeFunctionParameter,"function parameter "),o=h.factoryNodeList(n,h.isNodeArguments,"function arguments block "),l=h.factoryNodeList(s,h.isNodeProgramElement,"function statement "),c={type:"FCNDEF",id:e.id,mapper:1===a.length&&1===i.length,ev:new Array(a.length).fill(!0),func:null,return:t,parameter:r,arguments:n,statements:s,omitAnswer:!0,omitOutput:!0};return c.return.parent=c,c.parameter.parent=c,c.arguments.parent=c,c.statements.parent=c,i.forEach(e=>e.parent=c),a.forEach(e=>e.parent=c),o.forEach(e=>e.parent=c),l.forEach(e=>e.parent=c),c},h.nodeClassAttributeTable=e=>{var t,r;const n={};for(const s of e)null!==(t=n[r=s.id])&&void 0!==t||(n[r]=[]),n[s.id].push(s);return n},h.nodeClassSectionMemberGuard=e=>{switch(e){case"PROPERTIES":return h.isNodeClassProperty;case"METHODS":return h.isNodeFunctionDefinition;case"EVENTS":return h.isNodeClassEvent;case"ENUMERATION":return h.isNodeClassEnumeration;default:return e=>!1}},h.nodeArgumentValidation=(e,t,r=null,n,s=null)=>{const i={type:"ARGVALID",name:h.factoryExpression(e,"argument validation name"),size:h.factoryExpressionList(t,"argument validation size "),class:h.factoryArgumentClass(r,"argument validation class"),functions:h.factoryExpressionList(n,"argument validation function "),default:s?h.factoryExpression(s,"argument validation default"):null,omitAnswer:!0,omitOutput:!0};return i.name.parent=i,i.size.forEach(e=>{h.isNodeBase(e)&&(e.parent=i)}),i.class&&(i.class.parent=i),i.functions.forEach(e=>{h.isNodeBase(e)&&(e.parent=i)}),i.default&&(i.default.parent=i),i},h.nodeArguments=(e,t)=>{var r;const n=e?h.isNodeList(e)?h.factoryNodeList(e,h.isNodeIdentifier,"arguments block attribute "):[e]:[],s={type:"ARGS",attribute:null!==(r=n[0])&&void 0!==r?r:null,attributes:n,validation:h.factoryNodeList(t,h.isNodeArgumentValidation,"arguments validation "),omitAnswer:!0,omitOutput:!0};return s.attributes.forEach(e=>e.parent=s),s.validation.forEach(e=>e.parent=s),s},h.nodeDeclarationFirst=e=>({type:e,list:[],omitAnswer:!0,omitOutput:!0}),h.nodeReturn=()=>({type:"RETURN",omitAnswer:!0,omitOutput:!0}),h.nodeBreak=()=>({type:"BREAK",omitAnswer:!0,omitOutput:!0}),h.nodeContinue=()=>({type:"CONTINUE",omitAnswer:!0,omitOutput:!0}),h.getDeclarationNode=e=>"node"in e?e.node:e,h.nodeAppendDeclaration=(e,t)=>{const r=h.getDeclarationNode(t);if(!h.isNodeDeclarationElement(r))throw new TypeError("declaration entry has invalid node type.");return r.parent=e,e.list.push(r),e},h.nodeImport=()=>({type:"IMPORT",imports:[]}),h.nodeImportFirst=e=>{const t=h.nodeImport();return t.omitAnswer=!0,t.omitOutput=!0,h.nodeAppendImport(t,e)},h.nodeAppendImport=(e,t)=>(t.parent=e,t.index=e.imports.length,e.imports.push(t),e),h.nodeIfBegin=(e,t)=>{h.factoryProgramElementList(t,"if body ");const r={type:"IF",expression:[h.factoryExpression(e,"if condition")],then:[t],else:null,omitAnswer:!0,omitOutput:!0};return r.expression[0].parent=r,r.then[0].parent=r,r},h.nodeIfAppendElse=(e,t)=>(h.factoryProgramElementList(t.else,"else body "),e.else=t.else,e.else.parent=e,e),h.nodeIfAppendElseIf=(e,t)=>(h.factoryProgramElementList(t.then,"elseif body "),t.expression.parent=e,e.expression.push(t.expression),t.then.parent=e,e.then.push(t.then),e),h.nodeElseIf=(e,t)=>{h.factoryProgramElementList(t,"elseif body ");const r={type:"ELSEIF",expression:h.factoryExpression(e,"elseif condition"),then:t,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r},h.nodeElse=e=>{h.factoryProgramElementList(e,"else body ");const t={type:"ELSE",else:e,omitAnswer:!0,omitOutput:!0};return t.else.parent=t,t},h.nodeSwitch=(e,t,r=null)=>{r&&h.factoryProgramElementList(r,"otherwise body ");const n={type:"SWITCH",expression:h.factoryExpression(e,"switch expression"),cases:h.factoryNodeList(t,h.isNodeSwitchCase,"switch case "),otherwise:r,omitAnswer:!0,omitOutput:!0};return n.expression.parent=n,n.cases.forEach(e=>e.parent=n),n.otherwise&&(n.otherwise.parent=n),n},h.nodeSwitchCase=(e,t)=>{h.factoryProgramElementList(t,"case body ");const r={type:"CASE",expression:h.factoryExpression(e,"case expression"),then:t,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r},h.nodeWhile=(e,t)=>{h.factoryProgramElementList(t,"while body ");const r={type:"WHILE",expression:h.factoryExpression(e,"while condition"),body:t,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.body.parent=r,r},h.nodeDoUntil=(e,t)=>{h.factoryProgramElementList(e,"do body ");const r={type:"DO_UNTIL",body:e,expression:h.factoryExpression(t,"until condition"),omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.expression.parent=r,r},h.nodeFor=(e,t,r,n=!1,s=null)=>{h.factoryProgramElementList(r,"for body ");const i={type:"FOR",target:h.factoryExpression(e,"for target"),expression:h.factoryExpression(t,"for expression"),workers:s?h.factoryExpression(s,"for workers"):null,body:r,parallel:n,omitAnswer:!0,omitOutput:!0};return i.target.parent=i,i.expression.parent=i,i.workers&&(i.workers.parent=i),i.body.parent=i,i},h.nodeSpmd=(e,t=null)=>{h.factoryProgramElementList(e,"spmd body "),h.factoryExpressionList(t,"spmd worker ");const r={type:"SPMD",workers:t,body:e,omitAnswer:!0,omitOutput:!0};return r.workers&&(r.workers.parent=r),r.body.parent=r,r},h.nodeTry=(e,t=null,r=null)=>{h.factoryProgramElementList(e,"try body "),t&&h.factoryProgramElementList(t,"catch body ");const n={type:"TRY",body:e,catchIdentifier:r,catchBody:t,omitAnswer:!0,omitOutput:!0};return n.body.parent=n,n.catchIdentifier&&(n.catchIdentifier.parent=n),n.catchBody&&(n.catchBody.parent=n),n},h.nodeUnwindProtect=(e,t)=>{h.factoryProgramElementList(e,"unwind_protect body "),h.factoryProgramElementList(t,"unwind_protect cleanup ");const r={type:"UNWIND_PROTECT",body:e,cleanup:t,omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.cleanup.parent=r,r},h.nodeClassDef=(e,t,r=h.nodeListFirst(),n=h.nodeListFirst())=>{const s={type:"CLASSDEF",id:e.id,attributes:h.factoryNodeList(r,h.isNodeClassAttribute,"class attribute "),attributeTable:{},superclasses:h.factoryNodeList(n,h.isNodeIdentifier,"superclass "),sections:h.factoryNodeList(t,h.isNodeClassSection,"class section "),omitAnswer:!0,omitOutput:!0};return s.attributeTable=h.nodeClassAttributeTable(s.attributes),s.attributes.forEach(e=>e.parent=s),s.superclasses.forEach(e=>e.parent=s),s.sections.forEach(e=>e.parent=s),s},h.nodeClassSection=(e,t,r=h.nodeListFirst())=>{const n=h.factoryNodeList(t,h.nodeClassSectionMemberGuard(e),`${e.toLowerCase()} member `),s={type:"CLASS_SECTION",kind:e,attributes:h.factoryNodeList(r,h.isNodeClassAttribute,"class section attribute "),attributeTable:{},members:t,omitAnswer:!0,omitOutput:!0};return s.attributeTable=h.nodeClassAttributeTable(s.attributes),s.attributes.forEach(e=>e.parent=s),s.members.parent=s,n.forEach(e=>e.parent=s),s},h.nodeClassProperty=(e,t=h.nodeListFirst(),r=null,n=h.nodeListFirst(),s=null)=>{const i=t&&"LIST"!==t.type?h.factoryExpression(t,"argument validation default"):null,a=h.isNodeList(t)?t:h.nodeListFirst(),o=h.nodeArgumentValidation(e,a,r,n,null!=i?i:s),l={type:"CLASS_PROPERTY",id:e.id,validation:o,name:o.name,size:o.size,class:o.class,functions:o.functions,defaultValue:o.default,omitAnswer:!0,omitOutput:!0};return l.validation.parent=l,l},h.nodeClassEvent=e=>({type:"CLASS_EVENT",id:e.id,omitAnswer:!0,omitOutput:!0}),h.nodeClassEnumeration=(e,t=h.nodeListFirst())=>{const r={type:"CLASS_ENUMERATION",id:e.id,args:h.factoryExpressionList(t,"enumeration argument "),omitAnswer:!0,omitOutput:!0};return r.args.forEach(e=>{h.isNodeBase(e)&&(e.parent=r)}),r},h.nodeClassAttribute=(e,t=null)=>{const r={type:"CLASS_ATTRIBUTE",id:e.id,value:t?h.factoryExpression(t,"class attribute value"):null,omitAnswer:!0,omitOutput:!0};return r.value&&(r.value.parent=r),r},t.default={AST:h}},6115(e,t,r){"use strict";t.BLAS=t.cT=void 0;const n=r(845),s=r(7679);t.cT=["blockThreshold","blockSize"];const i=new Set(t.cT);class a{}t.BLAS=a,a.defaultSettings=Object.assign({},{blockThreshold:1e5,blockSize:64}),a.settings=a.defaultSettings,a.set=e=>{Object.entries(e).forEach(e=>{if(!i.has(e[0]))throw new Error(`BLAS.set: invalid configuration parameter: ${e[0]}`);a.settings[e[0]]=e[1]})},a.axpy=(e,t,r)=>{const s=t.length,i=t[0].length;for(let a=0;a<s;a++){const s=t[a],o=r[a];for(let t=0;t<i;t++)o[t]=n.Complex.add(o[t],n.Complex.mul(e,s[t]))}return r},a.scal=(e,t,r,s)=>{if(n.Complex.realToNumber(n.Complex.eq(e,n.Complex.zero())))for(let e=r;e<s;e++)t[e]=n.Complex.zero();else if(!n.Complex.realToNumber(n.Complex.eq(e,n.Complex.one())))for(let i=r;i<s;i++)t[i]=n.Complex.mul(e,t[i])},a.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,s)=>n.Complex.copy(e[r][s]))):Array.from({length:e.length},(t,r)=>n.Complex.copy(e[r]));throw new Error("BLAS.copy: invalid argument")},a.dotu=(e,t)=>{const r=e.length;let s=n.Complex.zero();for(let i=0;i<r;i++)n.Complex.mulAndSumTo(s,e[i],t[i]);return s},a.dot=a.dotu,a.dotc=(e,t)=>{const r=e.length;let s=n.Complex.zero();for(let i=0;i<r;i++)n.Complex.mulAndSumTo(s,n.Complex.conj(e[i]),t[i]);return s},a.nrm2sq=(e,t,r,s)=>{let i=n.Complex.zero();for(let a=r;a<s;a++)n.Complex.mulAndSumTo(i,e.array[a][t],n.Complex.conj(e.array[a][t]));return n.Complex.create(i.re)},a.nrm2=e=>{let t=n.Complex.zero(),r=n.Complex.one();for(let s=0;s<e.length;s++){const i=e[s],a=n.Complex.abs(n.Complex.real(i)),o=n.Complex.abs(n.Complex.imag(i));if(n.Complex.toBoolean(n.Complex.ne(a,n.Complex.zero())))if(n.Complex.lt(t,a)){const e=n.Complex.rdiv(t,a);r=n.Complex.add(n.Complex.one(),n.Complex.mul(r,n.Complex.mul(e,e))),t=a}else{const e=n.Complex.rdiv(a,t);r=n.Complex.add(r,n.Complex.mul(e,e))}if(n.Complex.toBoolean(n.Complex.ne(o,n.Complex.zero())))if(n.Complex.lt(t,o)){const e=n.Complex.rdiv(t,o);r=n.Complex.add(n.Complex.one(),n.Complex.mul(r,n.Complex.mul(e,e))),t=o}else{const e=n.Complex.rdiv(o,t);r=n.Complex.add(r,n.Complex.mul(e,e))}}return n.Complex.toBoolean(n.Complex.eq(t,n.Complex.zero()))?n.Complex.zero():n.Complex.mul(t,n.Complex.sqrt(r))},a.gemv=(e,t,r,s,i,a,o,l,c,u,h,d="N")=>{const m="N"===d?t:r,p="N"===d?r:t;for(let e=0;e<m;e++)l[c+e]=n.Complex.eq(h,n.Complex.zero())?n.Complex.zero():n.Complex.eq(h,n.Complex.one())?l[c+e]:n.Complex.mul(h,l[c+e]);for(let t=0;t<m;t++){let r=n.Complex.zero();for(let l=0;l<p;l++){const c="N"===d?e[s+t][i+l]:"T"===d?e[s+l][i+t]:n.Complex.conj(e[s+l][i+t]);n.Complex.mulAndSumTo(r,c,a[o+l])}n.Complex.mulAndSumTo(l[c+t],u,r)}},a.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 s=Array.from({length:n},(e,r)=>[t[r]]);return a.trsm(e,s,{side:"left",uplo:r.uplo,transA:r.transA,unitDiagonal:r.unitDiagonal}).map(e=>e[0])},a.ger=(e,t,r,s,i,a,o,l,c,u,h,d)=>{if(!n.Complex.realIsZero(n.Complex.abs(a)))for(let m=0;m<s;m++){const s=o[l+m][c],p=n.Complex.mul(a,s),f=e[t+m];for(let e=0;e<i;e++)n.Complex.mulAndSumTo(f[r+e],p,n.Complex.conj(u[h+e][d]))}},a.geru=(e,t,r,s,i,a)=>{if(!n.Complex.realIsZero(n.Complex.abs(r)))for(let o=0;o<e.length;o++){const l=e[o],c=s[i+o];for(let e=0;e<t.length;e++)n.Complex.mulAndSumTo(c[a+e],r,n.Complex.mul(l,t[e]))}},a.gerc=(e,t,r,s,i=0,a=0)=>{for(let o=0;o<e.length;o++){const l=e[o],c=s[i+o];for(let e=0;e<t.length;e++)c[a+e]=n.Complex.add(c[a+e],n.Complex.mul(r,n.Complex.mul(l,n.Complex.conj(t[e]))))}},a.gerc_nd=(e,t,r)=>{const i=[];for(let t=0;t<s.MultiArray.linearLength(e);t++){const[r,n]=s.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);i.push(e.array[r][n])}const a=[];for(let e=0;e<s.MultiArray.linearLength(t);e++){const[r,n]=s.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);a.push(t.array[r][n])}const o=i.length,l=a.length;if(r.dimension[0]!==o||r.dimension[1]!==l)throw new Error(`BLAS.gerc_nd: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${o}, y is ${l})`);for(let e=0;e<o;e++){const t=n.Complex.conj(i[e]);for(let s=0;s<l;s++){const i=n.Complex.mul(t,a[s]);r.array[e][s]?r.array[e][s]=n.Complex.add(r.array[e][s],i):r.array[e][s]=n.Complex.copy(i)}}s.MultiArray.setType(r)},a.gerc_nd_direct=(e,t,r)=>{const i=s.MultiArray.linearLength(e),a=s.MultiArray.linearLength(t);if(r.dimension[0]!==i||r.dimension[1]!==a)throw new Error(`BLAS.gerc_nd_direct: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${i}, y is ${a})`);e.dimension[0],e.dimension[1],t.dimension[0],t.dimension[1],r.dimension[0],r.dimension[1];for(let o=0;o<i;o++){const[l,c]=s.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1]||1,o),u=n.Complex.conj(e.array[l][c]);for(let e=0;e<a;e++){const[a,l]=s.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1]||1,e),c=t.array[a][l],[h,d]=s.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],o+e*i);r.array[h][d]?r.array[h][d]=n.Complex.add(r.array[h][d],n.Complex.mul(u,c)):r.array[h][d]=n.Complex.mul(u,c)}}s.MultiArray.setType(r)},a.gemm_kernel=(e,t,r,s,i,a,o,l,c)=>{var u;for(let h=s;h<i;h++){const s=e[h],i=r[h];for(let e=a;e<o;e++){let r=null!==(u=i[e])&&void 0!==u?u:n.Complex.zero();for(let i=l;i<c;i++)n.Complex.mulAndSumTo(r,s[i],t[i][e]);i[e]=r}}},a.gemm=(e,t,r,s,i,o,l,c,u)=>{if(n.Complex.realIsZero(n.Complex.abs(e)))for(let e=0;e<r;e++){const t=c[e];for(let e=0;e<o;e++)t[e]=n.Complex.mul(l,t[e])}else{if(!n.Complex.eq(l,n.Complex.one()))for(let e=0;e<r;e++){const t=c[e];for(let e=0;e<o;e++)t[e]=n.Complex.mul(l,t[e])}if(r*s*o>a.settings.blockThreshold)for(let e=0;e<r;e+=null!=u?u:a.settings.blockSize){const n=Math.min(e+(null!=u?u:a.settings.blockSize),r);for(let r=0;r<s;r+=null!=u?u:a.settings.blockSize){const l=Math.min(r+(null!=u?u:a.settings.blockSize),s);for(let s=0;s<o;s+=null!=u?u:a.settings.blockSize){const h=Math.min(s+(null!=u?u:a.settings.blockSize),o);a.gemm_kernel(t,i,c,e,n,s,h,r,l)}}}else for(let a=0;a<r;a++){const r=t[a],l=c[a];for(let t=0;t<o;t++){let a=n.Complex.zero();for(let e=0;e<s;e++)n.Complex.mulAndSumTo(a,r[e],i[e][t]);l[t]=n.Complex.add(l[t],n.Complex.mul(e,a))}}}},a.gemm_block=(e,t,r,s,i,o)=>{var l,c,u,h,d;const m=e.length,p=null!==(c=null===(l=e[0])||void 0===l?void 0:l.length)&&void 0!==c?c:0,f=t.length,g=null!==(h=null===(u=t[0])||void 0===u?void 0:u.length)&&void 0!==h?h:0;if(p!==f)throw new Error("BLAS.gemm_block: inner dimensions mismatch A.cols != B.rows");if(r.length!==m||(null===(d=r[0])||void 0===d?void 0:d.length)!==g)throw new Error("BLAS.gemm_block: output dimension mismatch with C");if(n.Complex.realIsZero(n.Complex.abs(s))){if(n.Complex.realIsZero(n.Complex.abs(i)))for(let e=0;e<m;e++)for(let t=0;t<g;t++)r[e][t]=n.Complex.zero();else if(n.Complex.toBoolean(n.Complex.ne(i,n.Complex.one())))for(let e=0;e<m;e++)for(let t=0;t<g;t++)r[e][t]=n.Complex.mul(i,r[e][t]);return}const y=Math.max(1,Math.floor(null!=o?o:a.settings.blockSize));for(let a=0;a<m;a+=y){const o=Math.min(a+y,m);for(let l=0;l<g;l+=y){const c=Math.min(l+y,g);for(let e=a;e<o;e++)for(let t=l;t<c;t++)n.Complex.realIsZero(n.Complex.abs(i))?r[e][t]=n.Complex.zero():n.Complex.toBoolean(n.Complex.ne(i,n.Complex.one()))&&(r[e][t]=n.Complex.mul(i,r[e][t]));for(let i=0;i<p;i+=y){const u=Math.min(i+y,p);for(let h=a;h<o;h++){const a=e[h],o=r[h];for(let e=i;e<u;e++){const r=a[e];if(!n.Complex.realIsZero(n.Complex.abs(r)))for(let i=l;i<c;i++){const a=n.Complex.mul(r,t[e][i]),l=n.Complex.mul(s,a);o[i]=n.Complex.add(o[i],l)}}}}}}},a.trsm=(e,t,r)=>{var s,i,a,o,l,c,u;const h=null!==(s=null==r?void 0:r.side)&&void 0!==s?s:"left",d=null!==(i=null==r?void 0:r.uplo)&&void 0!==i?i:"upper",m=null!==(a=null==r?void 0:r.transA)&&void 0!==a?a:"N",p=null!==(o=null==r?void 0:r.unitDiagonal)&&void 0!==o&&o,f=t.length,g=null!==(c=null===(l=t[0])||void 0===l?void 0:l.length)&&void 0!==c?c:0;if(e.length!==(null===(u=e[0])||void 0===u?void 0:u.length))throw new Error("BLAS.trsm: A must be square.");if("left"===h&&e.length!==f||"right"===h&&e.length!==g)throw new Error("BLAS.trsm: nonconformant dimensions.");const y=t.map(e=>e.map(e=>e)),x=(t,r)=>"N"===m?e[t][r]:"T"===m?e[r][t]:n.Complex.conj(e[r][t]);if("left"===h)if("upper"===d&&"N"===m||"lower"===d&&"N"!==m)for(let e=0;e<g;e++)for(let t=f-1;t>=0;t--){let r=y[t][e];for(let s=t+1;s<f;s++)r=n.Complex.sub(r,n.Complex.mul(x(t,s),y[s][e]));p||(r=n.Complex.rdiv(r,x(t,t))),y[t][e]=r}else for(let e=0;e<g;e++)for(let t=0;t<f;t++){let r=y[t][e];for(let s=0;s<t;s++)r=n.Complex.sub(r,n.Complex.mul(x(t,s),y[s][e]));p||(r=n.Complex.rdiv(r,x(t,t))),y[t][e]=r}else if("upper"===d&&"N"===m||"lower"===d&&"N"!==m)for(let e=0;e<f;e++)for(let t=0;t<g;t++){let r=y[e][t];for(let s=0;s<t;s++)r=n.Complex.sub(r,n.Complex.mul(y[e][s],x(s,t)));p||(r=n.Complex.rdiv(r,x(t,t))),y[e][t]=r}else for(let e=0;e<f;e++)for(let t=g-1;t>=0;t--){let r=y[e][t];for(let s=t+1;s<g;s++)r=n.Complex.sub(r,n.Complex.mul(y[e][s],x(s,t)));p||(r=n.Complex.rdiv(r,x(t,t))),y[e][t]=r}return y},a.functions={axpy:a.axpy,scal:a.scal,copy:a.copy,dotu:a.dotu,dotc:a.dotc,nrm2sq:a.nrm2sq,nrm2:a.nrm2,gemv:a.gemv,trsv:a.trsv,ger:a.ger,geru:a.geru,gerc:a.gerc,gerc_nd:a.gerc_nd,gerc_nd_direct:a.gerc_nd_direct,gemm_kernel:a.gemm_kernel,gemm:a.gemm,gemm_block:a.gemm_block,trsm:a.trsm}},3812(e,t){"use strict";t.CallFrame=void 0;t.CallFrame=class{constructor(e,t,r,n,s=0,i=0,a=[],o,l=[]){this.scope=e,this.func=t,this.callSite=r,this.name=n,this.nargin=s,this.nargout=i,this.inputArgs=a,this.parentFrame=o,this.outputMask=l}}},3225(e,t){"use strict";t.Callables=void 0;const r={builtin:e=>({type:"BUILTIN",node:e}),lambda:e=>({type:"LAMBDA",node:e}),functionDefinition:e=>({type:"FCNDEF",node:e}),staticMethod:e=>({type:"STATIC_METHOD",node:e}),fromFunctionNode(e){return"BUILTIN"===e.type?this.builtin(e):this.functionDefinition(e)},isBuiltin:e=>"BUILTIN"===e.type,isLambda:e=>"LAMBDA"===e.type,isFunctionDefinition:e=>"FCNDEF"===e.type,isStaticMethod:e=>"STATIC_METHOD"===e.type};t.Callables=r},5956(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CharString=t.stringClass=t.doubleQuoteCharacter=t.singleQuoteCharacter=void 0;const n=r(845);t.singleQuoteCharacter="'";const s='"';t.doubleQuoteCharacter=s,t.stringClass=3;class i{constructor(e,t=s){this.type=i.STRING,this.characters=e.split(""),this.quote=t}get str(){return this.characters.join("")}set str(e){this.characters=e.split("")}get length(){return this.characters.length}get dimension(){return[1,this.length]}copy(){return new i(this.str,this.quote)}vector(){return i.vector(this)}toCharacterScalars(){return i.toCharacterScalars(this)}characterAt(e){const t=this.characters[e];return void 0===t?void 0:new i(t,this.quote)}select(e){return new i(e.map(e=>this.characters[e]).filter(e=>void 0!==e).join(""),this.quote)}toString(){return this.str}toLogical(){return i.logical(this)}}t.CharString=i,i.STRING=3,i.create=(e,t='"')=>new i(e,t),i.isInstanceOf=e=>e instanceof i,i.isChar=e=>i.isInstanceOf(e)&&"'"===e.quote,i.isString=e=>i.isInstanceOf(e)&&e.quote===s,i.copy=e=>new i(e.str,e.quote),i.vector=e=>e.characters.slice(),i.toCharacterScalars=e=>e.characters.map(t=>new i(t,e.quote)),i.fromCharacterScalars=(e,t)=>{var r,n;return void 0===t&&(t=null!==(n=null===(r=e[0])||void 0===r?void 0:r.quote)&&void 0!==n?n:s),new i(e.map(e=>e.str).join(""),t)},i.fromNumericCode=(e,t=s)=>{const r=Math.max(0,Math.min(65535,Math.trunc(e)));return new i(String.fromCharCode(r),t)},i.parse=e=>new i(e),i.unparse=(e,t=0)=>e.str,i.toString=e=>e.str,i.unparseEscaped=e=>{let t=JSON.stringify(e.str);return t=t.substring(1,t.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'"'+t+'"'},i.unparseMathML=(e,t=0)=>"<mi><pre>"+e.str+"</pre></mi>",i.unparseEscapedMathML=e=>{let t=JSON.stringify(e.str);return t=t.substring(1,t.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'<mi><pre>"'+t+'"</pre></mi>'},i.logical=e=>e.str?n.Complex.true():n.Complex.false(),i.toLogical=e=>i.logical(e),t.default={singleQuoteCharacter:"'",doubleQuoteCharacter:s,stringClass:3,CharString:i}},9656(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassBoundMethod=void 0;class r{constructor(e,t){this.type=r.CLASS_BOUND_METHOD,this.instance=e,this.method=t}copy(){return r.copy(this)}}t.ClassBoundMethod=r,r.CLASS_BOUND_METHOD=8,r.isInstanceOf=e=>e instanceof r,r.bind=(e,t)=>new r(e,t),r.copy=e=>new r(e.instance,e.method),r.unparse=(e,t)=>`${e.instance.classDefinition.name}.${e.method.name} method`,t.default={ClassBoundMethod:r}},6816(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassDefinition=void 0;const n=r(6109),s=r(9283);class i{constructor(e){var t,r,n,a;this.type=i.CLASS_DEFINITION,this.ast=e,this.name=e.id;const o=this.name.lastIndexOf(".");this.packageName=o<0?"":this.name.slice(0,o),this.simpleName=o<0?this.name:this.name.slice(o+1),this.attributes=e.attributeTable;const l=s.ClassMember.hasAttribute(this.attributes,"Sealed");this.isHidden=s.ClassMember.hasAttribute(this.attributes,"Hidden"),this.isConstructOnLoad=s.ClassMember.hasAttribute(this.attributes,"ConstructOnLoad"),this.explicitHandleCompatible=s.ClassMember.attributeBooleanValue(null===(t=this.attributes.HandleCompatible)||void 0===t?void 0:t[0]),this.isHandleCompatible=!0===this.explicitHandleCompatible,this.inferiorClasses=null!==(n=s.ClassMember.classNameListFromAttribute(null===(r=this.attributes.InferiorClasses)||void 0===r?void 0:r[0]))&&void 0!==n?n:[];const c=s.ClassMember.classNameListFromAttribute(null===(a=this.attributes.AllowedSubclasses)||void 0===a?void 0:a[0]);this.allowedSubclasses=null!=c?c:[],this.hasAllowedSubclassesAttribute=null!==c,this.isBuiltinHandleClass="handle"===this.name,this.superclasses=e.superclasses.map(e=>e.id),this.superclassDefinitions=[],this.sections=e.sections,this.properties=[],this.propertyTable={},this.methods=[],this.staticMethods=[],this.instanceMethods=[],this.methodsByAccess={},this.methodTable={},this.events=[],this.enumerations=[],this.enumerationTable={},this.collectMembers(),this.isSealed=l||this.enumerations.length>0||this.hasAllowedSubclassesAttribute&&0===this.allowedSubclasses.length,this.isRestrictsSubclassing=this.isSealed||this.hasAllowedSubclassesAttribute||s.ClassMember.hasAttribute(this.attributes,"RestrictsSubclassing"),this.isAbstract=s.ClassMember.hasAttribute(this.attributes,"Abstract")||this.properties.some(e=>e.isAbstract)||this.methods.some(e=>e.isAbstract)}copy(){return i.copy(this)}validateLocalDefinition(e){this.validateSupportedAttributes(e),this.validateAccessAttributes(e),this.validateAttributeCombinations(e),this.validateDuplicateMembers(e),this.validatePropertyAccessors(e)}resolveSuperclasses(e,t){this.validateLocalDefinition(t),this.superclassDefinitions.length=0;for(const r of this.superclasses){if(i.sealedBuiltinSuperclassNames.has(r)&&t(`class ${this.name} cannot inherit from sealed class ${r}.`),i.builtinSuperclassNames.has(r))continue;r===this.name&&t(`class ${this.name} cannot inherit from itself.`);const n=e(r);n||t(`superclass '${r}' for class ${this.name} is not defined.`),n.isSealed&&t(`class ${this.name} cannot inherit from sealed class ${n.name}.`),n.allowedSubclasses.length>0&&!n.allowedSubclasses.includes(this.name)&&t(`class ${this.name} cannot inherit from class ${n.name}: subclass is not listed in AllowedSubclasses.`),this.superclassDefinitions.push(n)}this.validateInheritanceCycles(t),this.validateSealedMethodOverrides(t),this.validateInheritedMethodCompatibility(t),this.validateInheritedPropertyCompatibility(t),this.validateInheritedEventCompatibility(t),this.validateHandleCompatibility(t),this.validateResolvedClassRestrictions(t)}isSubclassOf(e){return this.superclassDefinitions.some(t=>t===e||t.isSubclassOf(e))}isSubclassOfName(e){return"handle"===e?this.isHandleClass():!!this.superclasses.includes(e)||this.superclassDefinitions.some(t=>t.name===e||t.isSubclassOfName(e))}isHandleClass(){return this.isBuiltinHandleClass||this.superclasses.includes("handle")||this.superclasses.includes("event.EventData")||this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(e=>e.isHandleClass())}isHandleCompatibleClass(){return this.isHandleClass()||this.isHandleCompatible}isSetGetClass(){return this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(e=>e.isSetGetClass())}isSetGetExactNamesClass(){return this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(e=>e.isSetGetExactNamesClass())}findSuperclass(e){for(const t of this.superclassDefinitions){if(t.name===e)return t;const r=t.findSuperclass(e);if(r)return r}}allProperties(){const e=i.firstByKey(this.superclassDefinitions.flatMap(e=>e.allProperties()),e=>e.name),t=new Set(this.properties.map(e=>e.name));return[...e.filter(e=>!t.has(e.name)),...this.properties]}allMethods(){const e=i.firstByKey(this.inheritedMethods(),e=>this.methodOverrideKey(e)),t=new Set(this.methods.map(e=>this.methodOverrideKey(e)));return[...e.filter(e=>!t.has(this.methodOverrideKey(e))),...this.methods]}inheritedMethods(){return this.superclassDefinitions.flatMap(e=>e.allMethods())}allEvents(){const e=i.firstByKey(this.superclassDefinitions.flatMap(e=>e.allEvents()),e=>e.name),t=new Set(this.events.map(e=>e.name));return[...e.filter(e=>!t.has(e.name)),...this.events]}allEnumerations(){const e=i.firstByKey(this.superclassDefinitions.flatMap(e=>e.allEnumerations()),e=>e.name),t=new Set(this.enumerations.map(e=>e.name));return[...e.filter(e=>!t.has(e.name)),...this.enumerations]}findProperty(e){var t;return null!==(t=this.propertyTable[e])&&void 0!==t?t:this.superclassDefinitions.map(t=>t.findProperty(e)).find(e=>Boolean(e))}findMethod(e,t=()=>!0){var r;const n=null===(r=this.methodTable[e])||void 0===r?void 0:r.find(t);return null!=n?n:this.superclassDefinitions.map(r=>r.findMethod(e,t)).find(e=>Boolean(e))}findConstructor(){var e,t,r;return null!==(t=null===(e=this.methodTable[this.name])||void 0===e?void 0:e.find(e=>!e.isStatic))&&void 0!==t?t:null===(r=this.methodTable[this.simpleName])||void 0===r?void 0:r.find(e=>!e.isStatic)}findEnumeration(e){var t;return null!==(t=this.enumerationTable[e])&&void 0!==t?t:this.superclassDefinitions.map(t=>t.findEnumeration(e)).find(e=>Boolean(e))}findEvent(e){var t;return null!==(t=this.events.find(t=>t.name===e))&&void 0!==t?t:this.superclassDefinitions.map(t=>t.findEvent(e)).find(e=>Boolean(e))}abstractMethodNames(){return new Set(this.unresolvedAbstractMethods().map(e=>e.name))}abstractPropertyNames(){return new Set(this.unresolvedAbstractProperties().map(e=>e.name))}unresolvedAbstractMethods(){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.unresolvedAbstractMethodEntries())e.set(r.key,r.method);for(const t of this.methods){const r=this.methodOverrideKey(t);t.isAbstract?e.set(r,t):e.delete(r)}return[...e.values()]}unresolvedAbstractProperties(){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.unresolvedAbstractPropertyEntries())e.set(r.key,r.property);for(const t of this.properties){const r=this.propertyOverrideKey(t);t.isAbstract?e.set(r,t):e.delete(r)}return[...e.values()]}isEffectivelyAbstract(){return this.isAbstract||this.unresolvedAbstractMethods().length>0||this.unresolvedAbstractProperties().length>0}unresolvedAbstractMethodEntries(){return this.unresolvedAbstractMethods().map(e=>({key:this.methodOverrideKey(e),method:e}))}unresolvedAbstractPropertyEntries(){return this.unresolvedAbstractProperties().map(e=>({key:this.propertyOverrideKey(e),property:e}))}methodOverrideKey(e){return`${e.isStatic?"static":"instance"}:${e.name}`}propertyOverrideKey(e){return e.name}validateSealedMethodOverrides(e){const t=new Map;for(const e of this.inheritedMethods())e.isSealed&&t.set(this.methodOverrideKey(e),e);for(const r of this.methods){const n=t.get(this.methodOverrideKey(r));n&&e(`method '${r.name}' in class ${this.name} cannot override sealed method from class ${n.classDefinition.name}.`)}}isPrivateMethodDefinition(e){return"private"===e.access}validateInheritedMethodCompatibility(e){var t,r,n,s;const i=new Map;for(const e of this.inheritedMethods()){const r=this.methodOverrideKey(e),n=null!==(t=i.get(r))&&void 0!==t?t:[];n.some(t=>t.classDefinition===e.classDefinition&&t.name===e.name&&t.isStatic===e.isStatic)||n.push(e),i.set(r,n)}for(const t of this.methods)for(const n of null!==(r=i.get(this.methodOverrideKey(t)))&&void 0!==r?r:[])this.isPrivateMethodDefinition(n)||t.access!==n.access&&e(`method '${t.name}' in class ${this.name} must match inherited Access from method in class ${n.classDefinition.name}.`);const a=new Set(this.methods.map(e=>this.methodOverrideKey(e)));for(const[t,r]of i){if(a.has(t))continue;const i=r.filter(e=>!e.isAbstract&&!this.isPrivateMethodDefinition(e));if(new Set(i.map(e=>e.classDefinition.name)).size<=1)continue;if(1===i.filter(e=>e.isSealed).length)continue;const o=null!==(s=null===(n=i[0])||void 0===n?void 0:n.name)&&void 0!==s?s:t.slice(t.indexOf(":")+1);e(`class ${this.name} inherits incompatible method '${o}' from multiple superclasses.`)}}validateSupportedAttributes(e){this.validateAttributeNames(this.attributes,i.classAttributes,`class ${this.name}`,e),this.validateDuplicateAttributes(this.attributes,`class ${this.name}`,e),this.validateBooleanAttributes(this.attributes,i.classBooleanAttributes,`class ${this.name}`,e),this.validateClassNameListAttributes(this.attributes,new Set(["AllowedSubclasses","InferiorClasses"]),`class ${this.name}`,e);for(const t of this.sections){const r=`${t.kind.toLowerCase()} section of class ${this.name}`;switch(t.kind){case"PROPERTIES":this.validateAttributeNames(t.attributeTable,i.propertyAttributes,r,e),this.validateBooleanAttributes(t.attributeTable,i.propertyBooleanAttributes,r,e),this.validatePositiveIntegerAttributes(t.attributeTable,new Set(["PartialMatchPriority"]),r,e);break;case"METHODS":this.validateAttributeNames(t.attributeTable,i.methodAttributes,r,e),this.validateBooleanAttributes(t.attributeTable,i.methodBooleanAttributes,r,e);break;case"EVENTS":this.validateAttributeNames(t.attributeTable,i.eventAttributes,r,e),this.validateBooleanAttributes(t.attributeTable,i.eventBooleanAttributes,r,e);break;case"ENUMERATION":this.validateAttributeNames(t.attributeTable,i.enumerationAttributes,r,e),this.validateBooleanAttributes(t.attributeTable,i.enumerationBooleanAttributes,r,e)}this.validateDuplicateAttributes(t.attributeTable,r,e)}}validateAttributeNames(e,t,r,n){for(const s of Object.keys(e))t.has(s)||n(`unsupported ${s} attribute for ${r}.`)}validateDuplicateAttributes(e,t,r){for(const[n,s]of Object.entries(e))s.length>1&&r(`duplicate ${n} attribute for ${t}.`)}validateBooleanAttributes(e,t,r,n){var i;for(const a of t){const t=null===(i=e[a])||void 0===i?void 0:i[0];t&&null===s.ClassMember.attributeBooleanValue(t)&&n(`invalid boolean ${a} attribute for ${r}.`)}}validateClassNameListAttributes(e,t,r,n){var i;for(const a of t){const t=null===(i=e[a])||void 0===i?void 0:i[0];t&&null===s.ClassMember.classNameListFromAttribute(t)&&n(`invalid class-name list ${a} attribute for ${r}.`)}}validatePositiveIntegerAttributes(e,t,r,n){var i;for(const a of t){const t=null===(i=e[a])||void 0===i?void 0:i[0];t&&null===s.ClassMember.positiveIntegerFromAttribute(t)&&n(`invalid positive integer ${a} attribute for ${r}.`)}}validateAccessAttributes(e){for(const t of this.sections){const r=`${t.kind.toLowerCase()} section of class ${this.name}`;switch(t.kind){case"PROPERTIES":s.ClassMember.validateAccessAttribute(t.attributeTable,"Access",r,e),s.ClassMember.validateAccessAttribute(t.attributeTable,"GetAccess",r,e),s.ClassMember.validateAccessAttribute(t.attributeTable,"SetAccess",r,e);break;case"METHODS":s.ClassMember.validateAccessAttribute(t.attributeTable,"Access",r,e);break;case"EVENTS":s.ClassMember.validateAccessAttribute(t.attributeTable,"Access",r,e),s.ClassMember.validateAccessAttribute(t.attributeTable,"ListenAccess",r,e),s.ClassMember.validateAccessAttribute(t.attributeTable,"NotifyAccess",r,e)}}}validateInheritanceCycles(e){var t;for(const r of this.superclassDefinitions){r===this&&e(`class ${this.name} cannot inherit from itself.`);const n=null!==(t=r.inheritanceCyclePath(this,[this.name,r.name],new Set([this])))&&void 0!==t?t:r.inheritanceNameCyclePath(this.name,[this.name,r.name],new Set([this.name]));n&&e(`circular class inheritance detected: ${n.join(" -> ")}.`)}}inheritanceCyclePath(e,t,r){if(this===e)return t;if(!r.has(this)){r.add(this);for(const n of this.superclassDefinitions){const s=n.inheritanceCyclePath(e,[...t,n.name],r);if(s)return s}}}inheritanceNameCyclePath(e,t,r){if(this.superclasses.includes(e))return[...t,e];if(!r.has(this.name)){r.add(this.name);for(const n of this.superclassDefinitions){const s=n.inheritanceNameCyclePath(e,[...t,n.name],r);if(s)return s}}}validatePropertyAccessors(e){const t=(t,r,s)=>{var i;if(!s)return void((null===(i=t.attributes[r])||void 0===i?void 0:i[0])&&e(`invalid ${r} attribute for property '${t.name}' in class ${this.name}.`));const a=this.findMethod(s,e=>!e.isStatic);a||e(`${r} method '${s}' for property '${t.name}' in class ${this.name} is not defined.`);const o=this.methodParameters(a).length,l=this.methodReturns(a),c=l.length;"GetMethod"!==r||1===o&&1===c&&!n.AST.isNodeIgnoredTarget(l[0])||e(`${r} method '${s}' for property '${t.name}' in class ${this.name} must declare one input and one output.`),"SetMethod"!==r||2===o&&1===c&&!n.AST.isNodeIgnoredTarget(l[0])||e(`${r} method '${s}' for property '${t.name}' in class ${this.name} must declare two inputs and one output.`)};for(const e of this.properties)t(e,"GetMethod",e.getMethodName),t(e,"SetMethod",e.setMethodName);for(const t of this.methods){const r=/^(get|set)\.(.+)$/.exec(t.name);if(!r)continue;const[,s,i]=r;this.findProperty(i)||e(`${s} accessor '${t.name}' in class ${this.name} does not match a class property.`),t.isStatic&&e(`${s} accessor '${t.name}' in class ${this.name} cannot be static.`);const a=this.methodParameters(t).length,o=this.methodReturns(t),l=o.length;"get"!==s||1===a&&1===l&&!n.AST.isNodeIgnoredTarget(o[0])||e(`get accessor '${t.name}' in class ${this.name} must declare one input and one output.`),"set"!==s||2===a&&1===l&&!n.AST.isNodeIgnoredTarget(o[0])||e(`set accessor '${t.name}' in class ${this.name} must declare two inputs and one output.`)}}validateResolvedClassRestrictions(e){this.events.length>0&&!this.isHandleClass()&&e(`class ${this.name} cannot define events because it is not a handle class.`),this.isSubclassOfName("event.EventData")&&!this.isConstructOnLoad&&e(`class ${this.name} must set ConstructOnLoad because it subclasses event.EventData.`);for(const t of this.properties)this.isSubclassOfName("event.EventData")&&i.eventDataInheritedPropertyNames.has(t.name)&&e(`class ${this.name} cannot redefine inherited event.EventData property '${t.name}'.`),t.isNonCopyable&&!this.isHandleClass()&&e(`NonCopyable property '${t.name}' in class ${this.name} requires a handle class.`),t.isAbortSet&&!this.isHandleClass()&&e(`AbortSet property '${t.name}' in class ${this.name} requires a handle class.`),1===t.partialMatchPriority||this.isSetGetClass()||e(`PartialMatchPriority property '${t.name}' in class ${this.name} requires matlab.mixin.SetGet.`)}validateHandleCompatibility(e){const t=this.superclasses.some(e=>i.builtinSuperclassNames.has(e))||this.superclassDefinitions.some(e=>e.isHandleClass()),r=this.superclassDefinitions.find(e=>!e.isHandleCompatibleClass());!1===this.explicitHandleCompatible&&t&&e(`class ${this.name} cannot set HandleCompatible to false while inheriting from a handle class.`),(!0===this.explicitHandleCompatible||t)&&r&&e(`class ${this.name} cannot combine handle semantics with non-handle-compatible superclass ${r.name}.`)}isPrivatePropertyDefinition(e){return"private"===e.getAccess&&"private"===e.setAccess}validateInheritedPropertyCompatibility(e){var t,r;const n=new Map;for(const e of this.superclassDefinitions)for(const r of e.allProperties()){const e=null!==(t=n.get(r.name))&&void 0!==t?t:[];e.some(e=>e.classDefinition===r.classDefinition&&e.name===r.name)||e.push(r),n.set(r.name,e)}for(const t of this.properties)for(const s of null!==(r=n.get(t.name))&&void 0!==r?r:[])s.isAbstract?t.getAccess===s.getAccess&&t.setAccess===s.setAccess||e(`property '${t.name}' in class ${this.name} must match inherited GetAccess and SetAccess from abstract property in class ${s.classDefinition.name}.`):this.isPrivatePropertyDefinition(s)||e(`property '${t.name}' in class ${this.name} cannot redefine inherited property from class ${s.classDefinition.name}.`);for(const[t,r]of n){const n=r.filter(e=>!e.isAbstract&&!this.isPrivatePropertyDefinition(e));new Set(n.map(e=>e.classDefinition.name)).size>1&&!this.properties.some(e=>e.name===t)&&e(`class ${this.name} inherits incompatible property '${t}' from multiple superclasses.`)}}isPrivateEventDefinition(e){return"private"===e.listenAccess&&"private"===e.notifyAccess}validateInheritedEventCompatibility(e){var t;const r=new Map;for(const e of this.superclassDefinitions)for(const n of e.allEvents()){const e=null!==(t=r.get(n.name))&&void 0!==t?t:[];e.some(e=>e.classDefinition===n.classDefinition&&e.name===n.name)||e.push(n),r.set(n.name,e)}for(const[t,n]of r){const r=n.filter(e=>!this.isPrivateEventDefinition(e));new Set(r.map(e=>e.classDefinition.name)).size>1&&e(`class ${this.name} inherits incompatible event '${t}' from multiple superclasses.`)}}validateAttributeCombinations(e){if(s.ClassMember.hasAttribute(this.attributes,"Abstract")&&s.ClassMember.hasAttribute(this.attributes,"Sealed")&&e(`class ${this.name} cannot be both abstract and sealed.`),this.isSealed){const t=this.methods.find(e=>e.isAbstract);t&&e(`sealed class ${this.name} cannot define abstract method '${t.name}'.`);const r=this.properties.find(e=>e.isAbstract);r&&e(`sealed class ${this.name} cannot define abstract property '${r.name}'.`)}for(const t of this.sections)"METHODS"===t.kind&&s.ClassMember.hasAttribute(t.attributeTable,"Abstract")&&s.ClassMember.hasAttribute(t.attributeTable,"Sealed")&&e(`methods section of class ${this.name} cannot be both abstract and sealed.`);for(const t of this.properties)t.isDependent&&t.isConstant&&e(`property '${t.name}' in class ${this.name} cannot be both dependent and constant.`),t.isAbstract&&t.isConstant&&e(`property '${t.name}' in class ${this.name} cannot be both abstract and constant.`),t.isAbstract&&t.getMethodName&&e(`abstract property '${t.name}' in class ${this.name} cannot define a GetMethod.`),t.isAbstract&&t.setMethodName&&e(`abstract property '${t.name}' in class ${this.name} cannot define a SetMethod.`),t.isDependent&&t.defaultValue&&e(`dependent property '${t.name}' in class ${this.name} cannot define a default value.`),t.isAbstract&&t.defaultValue&&e(`abstract property '${t.name}' in class ${this.name} cannot define a default value.`),t.isConstant&&!t.defaultValue&&e(`constant property '${t.name}' in class ${this.name} must define a default value.`);for(const t of this.methods){t.isAbstract&&t.node.statements.list.length>0&&e(`abstract method '${t.name}' in class ${this.name} cannot define a method body.`),t.isAbstract&&t.node.arguments.list.length>0&&e(`arguments blocks are not allowed in abstract method '${t.name}' of class ${this.name}.`),this.isConstructorMethodName(t.name)&&t.isStatic&&e(`constructor for class ${this.name} cannot be static.`),this.isConstructorMethodName(t.name)&&t.isAbstract&&e(`constructor for class ${this.name} cannot be abstract.`),"delete"===t.name&&t.node.arguments.list.length>0&&e(`arguments blocks are not allowed in delete method of class ${this.name}.`);const r=this.methodReturns(t);this.isConstructorMethodName(t.name)&&(1!==r.length||n.AST.isNodeIgnoredTarget(r[0]))&&e(`constructor for class ${this.name} must declare exactly one output.`),this.isConstructorMethodName(t.name)&&this.isConstructOnLoad&&!this.constructorAcceptsNoInputs(t)&&e(`ConstructOnLoad class ${this.name} constructor must support zero input arguments.`)}}constructorAcceptsNoInputs(e){return this.methodParameters(e).every(e=>n.AST.isNodeDefaultedParameter(e)||n.AST.isNodeIdentifier(e)&&"varargin"===e.id)}validateDuplicateMembers(e){this.validateDuplicateNames(this.properties.map(e=>e.name),"property",e),this.validateDuplicateNames(this.events.map(e=>e.name),"event",e),this.validateDuplicateNames(this.enumerations.map(e=>e.name),"enumeration member",e),this.validateDuplicateNames(this.methods.map(e=>this.methodOverrideKey(e)),"method",e,e=>e.slice(e.indexOf(":")+1)),this.validateCrossMemberNameConflicts(e)}validateCrossMemberNameConflicts(e){const t=new Map,r=(r,n)=>{r!==this.simpleName&&r!==this.name||e(`class ${this.name} cannot define ${n} with the same name as the class.`);const s=t.get(r);s&&e(`class ${this.name} has conflicting ${s} and ${n} named '${r}'.`),t.set(r,n)};for(const e of this.properties)r(e.name,"property");for(const e of this.methods)this.isConstructorMethodName(e.name)||e.name.startsWith("get.")||e.name.startsWith("set.")||r(e.name,"method");for(const e of this.events)r(e.name,"event");for(const e of this.enumerations)r(e.name,"enumeration member")}isConstructorMethodName(e){return e===this.name||e===this.simpleName}validateDuplicateNames(e,t,r,n=e=>e){const s=new Set;for(const i of e)s.has(i)&&r(`duplicate ${t} '${n(i)}' in class ${this.name}.`),s.add(i)}collectMembers(){for(const e of this.sections)switch(e.kind){case"PROPERTIES":this.collectProperties(e);break;case"METHODS":this.collectMethods(e);break;case"EVENTS":this.collectEvents(e);break;case"ENUMERATION":this.collectEnumerations(e)}}classSectionMembers(e,t){return e.members.list.map((r,n)=>{if(!t(r))throw new TypeError(`internal AST error: ${e.kind.toLowerCase()} member ${n+1} has invalid node type.`);return r})}checkedMethodHeaderList(e,t,r,n){return e.map((e,s)=>{if(!t(e))throw new TypeError(`internal AST error: method '${r}' ${n} ${s+1} has invalid node type.`);return e})}methodParameters(e){return this.checkedMethodHeaderList(e.node.parameter.list,n.AST.isNodeFunctionParameter,e.name,"parameter")}methodReturns(e){return this.checkedMethodHeaderList(e.node.return.list,n.AST.isNodeFunctionReturn,e.name,"return")}collectProperties(e){var t,r;const i=s.ClassMember.accessFromAttributes(e.attributeTable),a=s.ClassMember.hasAttribute(e.attributeTable,"Constant"),o=s.ClassMember.hasAttribute(e.attributeTable,"Dependent"),l=s.ClassMember.hasAttribute(e.attributeTable,"Abstract");for(const c of this.classSectionMembers(e,n.AST.isNodeClassProperty)){const n={name:c.id,node:c,defaultValue:c.defaultValue,size:c.size,class:c.class,functions:c.functions,section:e,attributes:e.attributeTable,access:i,getAccess:s.ClassMember.accessFromAttributes(e.attributeTable,"GetAccess",i),setAccess:s.ClassMember.accessFromAttributes(e.attributeTable,"SetAccess",i),getMethodName:s.ClassMember.methodNameFromAttribute(e.attributeTable,"GetMethod"),setMethodName:s.ClassMember.methodNameFromAttribute(e.attributeTable,"SetMethod"),isConstant:a,isDependent:o,isAbstract:l,isHidden:s.ClassMember.hasAttribute(e.attributeTable,"Hidden"),isTransient:s.ClassMember.hasAttribute(e.attributeTable,"Transient"),isNonCopyable:s.ClassMember.hasAttribute(e.attributeTable,"NonCopyable"),isGetObservable:s.ClassMember.hasAttribute(e.attributeTable,"GetObservable"),isSetObservable:s.ClassMember.hasAttribute(e.attributeTable,"SetObservable"),isAbortSet:s.ClassMember.hasAttribute(e.attributeTable,"AbortSet"),partialMatchPriority:null!==(r=s.ClassMember.positiveIntegerFromAttribute(null===(t=e.attributeTable.PartialMatchPriority)||void 0===t?void 0:t[0]))&&void 0!==r?r:1,classDefinition:this};this.properties.push(n),this.propertyTable[n.name]=n}}collectMethods(e){var t,r,i,a,o;const l=s.ClassMember.accessFromAttributes(e.attributeTable),c=s.ClassMember.hasAttribute(e.attributeTable,"Static"),u=s.ClassMember.hasAttribute(e.attributeTable,"Abstract"),h=s.ClassMember.hasAttribute(e.attributeTable,"Sealed"),d=s.ClassMember.hasAttribute(e.attributeTable,"Hidden");for(const s of this.classSectionMembers(e,n.AST.isNodeFunctionDefinition)){const n={name:s.id,node:s,section:e,attributes:e.attributeTable,access:l,isStatic:c,isAbstract:u,isSealed:h,isHidden:d,classDefinition:this};this.methods.push(n),(c?this.staticMethods:this.instanceMethods).push(n),null!==(t=(i=this.methodsByAccess)[l])&&void 0!==t||(i[l]=[]),this.methodsByAccess[l].push(n),null!==(r=(a=this.methodTable)[o=n.name])&&void 0!==r||(a[o]=[]),this.methodTable[n.name].push(n)}}collectEvents(e){const t=s.ClassMember.accessFromAttributes(e.attributeTable),r=s.ClassMember.accessFromAttributes(e.attributeTable,"ListenAccess",t),i=s.ClassMember.accessFromAttributes(e.attributeTable,"NotifyAccess",t),a=s.ClassMember.hasAttribute(e.attributeTable,"Hidden");for(const s of this.classSectionMembers(e,n.AST.isNodeClassEvent))this.events.push({name:s.id,node:s,section:e,attributes:e.attributeTable,access:t,listenAccess:r,notifyAccess:i,isHidden:a,classDefinition:this})}collectEnumerations(e){const t=s.ClassMember.hasAttribute(e.attributeTable,"Hidden");for(const r of this.classSectionMembers(e,n.AST.isNodeClassEnumeration)){const n={name:r.id,node:r,args:r.args,section:e,attributes:e.attributeTable,isHidden:t,classDefinition:this};this.enumerations.push(n),this.enumerationTable[n.name]=n}}}t.ClassDefinition=i,i.CLASS_DEFINITION=6,i.classAttributes=new Set(["Abstract","AllowedSubclasses","ConstructOnLoad","HandleCompatible","Hidden","InferiorClasses","RestrictsSubclassing","Sealed"]),i.propertyAttributes=new Set(["AbortSet","Abstract","Access","Constant","Dependent","GetAccess","GetMethod","GetObservable","Hidden","NonCopyable","PartialMatchPriority","SetAccess","SetMethod","SetObservable","Transient"]),i.methodAttributes=new Set(["Abstract","Access","Hidden","Sealed","Static"]),i.eventAttributes=new Set(["Hidden","ListenAccess","NotifyAccess"]),i.enumerationAttributes=new Set(["Hidden"]),i.classBooleanAttributes=new Set(["Abstract","ConstructOnLoad","HandleCompatible","Hidden","RestrictsSubclassing","Sealed"]),i.propertyBooleanAttributes=new Set(["AbortSet","Abstract","Constant","Dependent","GetObservable","Hidden","NonCopyable","SetObservable","Transient"]),i.methodBooleanAttributes=new Set(["Abstract","Hidden","Sealed","Static"]),i.eventBooleanAttributes=new Set(["Hidden"]),i.enumerationBooleanAttributes=new Set(["Hidden"]),i.builtinSuperclassNames=new Set(["handle","event.EventData","event.PropertyEvent","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"]),i.sealedBuiltinSuperclassNames=new Set(["event.PropertyEvent"]),i.eventDataInheritedPropertyNames=new Set(["Source","EventName"]),i.firstByKey=(e,t)=>{const r=new Set;return e.filter(e=>{const n=t(e);return!r.has(n)&&(r.add(n),!0)})},i.isInstanceOf=e=>e instanceof i,i.create=e=>new i(e),i.copy=e=>e,i.unparse=(e,t)=>t.Unparse(e.ast),t.default={ClassDefinition:i}},3226(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassEmptyMethod=void 0;class r{constructor(e){this.type=r.CLASS_EMPTY_METHOD,this.classDefinition=e}copy(){return r.copy(this)}}t.ClassEmptyMethod=r,r.CLASS_EMPTY_METHOD=14,r.isInstanceOf=e=>e instanceof r,r.bind=e=>new r(e),r.copy=e=>new r(e.classDefinition),r.unparse=(e,t)=>`${e.classDefinition.name}.empty static method`,t.default={ClassEmptyMethod:r}},7325(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassEnumerationValue=void 0;class r{constructor(e,t,n=[]){this.type=r.CLASS_ENUMERATION_VALUE,this.classDefinition=e,this.enumeration=t,this.args=n}copy(){return r.copy(this)}}t.ClassEnumerationValue=r,r.CLASS_ENUMERATION_VALUE=10,r.isInstanceOf=e=>e instanceof r,r.create=(e,t,n=[])=>new r(e,t,n),r.copy=e=>new r(e.classDefinition,e.enumeration,e.args.slice()),r.unparse=(e,t)=>`${e.classDefinition.name}.${e.enumeration.name}`,t.default={ClassEnumerationValue:r}},169(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassEventData=void 0;const n=r(5956);class s{constructor(e,t){this.type=s.CLASS_EVENT_DATA,this.source=e,this.eventName=t}copy(){return this}}t.ClassEventData=s,s.CLASS_EVENT_DATA=12,s.isInstanceOf=e=>e instanceof s,s.create=(e,t)=>new s(e,t),s.getProperty=(e,t)=>{switch(t){case"Source":return e.source;case"EventName":return void 0===e.eventName?void 0:n.CharString.create(e.eventName);default:return}},s.unparse=(e,t)=>e.source&&e.eventName?`event.EventData ${e.source.classDefinition.name}.${e.eventName}`:"event.EventData",t.default={ClassEventData:s}},5577(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassEventListener=void 0;class r{constructor(e,t,n,s=t,i="event.listener"){this.type=r.CLASS_EVENT_LISTENER,this.enabled=!0,this.recursive=!1,this.notifying=!1,this.deleted=!1,this.source=e,this.kind=i,this.eventName=t,this.listenerKey=s,this.callback=n}copy(){return this}}t.ClassEventListener=r,r.CLASS_EVENT_LISTENER=11,r.isInstanceOf=e=>e instanceof r,r.create=(e,t,n,s=t,i="event.listener")=>new r(e,t,n,s,i),r.isValid=e=>!e.deleted,r.delete=e=>{e.deleted=!0,e.enabled=!1},r.unparse=(e,t)=>`${e.kind} ${e.source.classDefinition.name}.${e.eventName}`,t.default={ClassEventListener:r}},9770(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassInstance=void 0;const n=r(6109),s=r(5577),i=r(5956),a=r(8146),o=r(7679),l=r(1604);class c{constructor(e,t={}){this.type=c.CLASS_INSTANCE,this.listeners={},this.deleted=!1,this.classDefinition=e,this.properties={};for(const[e,r]of Object.entries(t))this.properties[e]=c.runtimePropertyValue(e,r)}copy(){return c.copy(this)}}t.ClassInstance=c,c.CLASS_INSTANCE=7,c.isInstanceOf=e=>e instanceof c,c.runtimePropertyValue=(e,t)=>(0,a.runtimeExpressionValue)(t,e,"property",e=>{throw new Error(e)}),c.propertyClassNames=e=>null===e?[]:n.AST.isNodeIdentifier(e)?[e.id]:n.AST.isNodeList(e)?e.list.flatMap(e=>n.AST.isNodeIdentifier(e)?[e.id]:[]):[],c.implicitPropertyDefault=e=>{const t=c.propertyClassNames(e.class);return t.includes("char")?i.CharString.create("","'"):t.includes("string")?i.CharString.create("",'"'):t.includes("cell")?o.MultiArray.emptyArray(!0):o.MultiArray.emptyArray()},c.instantiate=(e,t)=>{const r={};for(const n of e.allProperties())n.isDependent||(r[n.name]=n.defaultValue?t(n.defaultValue):c.implicitPropertyDefault(n));return new c(e,r)},c.throwIfDeleted=e=>{if(e.deleted)throw new Error(`invalid or deleted object for class ${e.classDefinition.name}.`)},c.delete=e=>{e.classDefinition.isHandleClass()&&(e.deleted=!0)},c.isValid=e=>e.classDefinition.isHandleClass()&&!e.deleted,c.getProperty=(e,t)=>(c.throwIfDeleted(e),e.properties[t]),c.hasProperty=(e,t)=>l.RuntimeValue.hasOwnField(e.properties,t),c.setProperty=(e,t,r)=>{if(c.throwIfDeleted(e),!c.hasProperty(e,t))throw new Error(`unknown property '${t}' for class ${e.classDefinition.name}.`);e.properties[t]=c.runtimePropertyValue(t,r)},c.addListener=(e,t,r,n=t,i="event.listener")=>{var a,o;c.throwIfDeleted(e);const l=s.ClassEventListener.create(e,t,r,n,i);return null!==(a=(o=e.listeners)[n])&&void 0!==a||(o[n]=[]),e.listeners[n].push(l),l},c.listenersFor=(e,t)=>{var r,n;return c.throwIfDeleted(e),null!==(n=null===(r=e.listeners[t])||void 0===r?void 0:r.filter(e=>s.ClassEventListener.isValid(e)&&e.enabled).slice())&&void 0!==n?n:[]},c.copy=e=>{if(c.throwIfDeleted(e),e.classDefinition.isHandleClass())return e;const t={};for(const[r,n]of Object.entries(e.properties))t[r]=l.RuntimeValue.copy(n);return new c(e.classDefinition,t)},c.methodArgument=e=>(c.throwIfDeleted(e),e.classDefinition.isHandleClass()?e:c.copy(e)),c.unparse=(e,t)=>{const r=Object.keys(e.properties);return`${e.classDefinition.name} object${r.length>0?` with properties: ${r.join(",")}`:""}`},t.default={ClassInstance:c}},9283(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ClassMember=void 0;const s=r(6109),i=r(5956),a=r(7679);class o{}t.ClassMember=o,n=o,o.defaultAccess="public",o.isMetaClassNode=e=>s.AST.isNodeMetaClass(e),o.isNegatedAttributeNode=e=>s.AST.isNodePrefixOperation(e)&&("~"===e.type||"!"===e.type),o.classNameValue=e=>s.AST.isNodeIdentifier(e)?e.id:i.CharString.isInstanceOf(e)?e.str:n.isMetaClassNode(e)?e.className.id:null,o.hasAttribute=(e,t)=>{var r;return!0===n.attributeBooleanValue(null===(r=e[t])||void 0===r?void 0:r[0])},o.attributeBooleanValue=e=>{if(!e)return null;if(!e.value)return!0;const t=e.value;if(n.isNegatedAttributeNode(t))return!1;if(s.AST.isNodeIdentifier(t)){if("true"===t.id)return!0;if("false"===t.id)return!1}return null},o.isSupportedAccess=e=>{if("public"===e||"protected"===e||"private"===e)return!0;const t=/^\?[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/;if(t.test(e))return!0;if(e.startsWith("{")&&e.endsWith("}")){const r=e.slice(1,-1).split(",");return r.length>0&&r.every(e=>t.test(e))}return!1},o.attributeValue=e=>{if(!e||!e.value)return null;const t=e.value;if(s.AST.isNodeIdentifier(t))return t.id;if(i.CharString.isInstanceOf(t))return t.toString();if(n.isMetaClassNode(t))return`?${t.className.id}`;if(a.MultiArray.isInstanceOf(t)&&t.isCell){const e=a.MultiArray.linearize(t).map(e=>{const t=e;return n.isMetaClassNode(t)?`?${t.className.id}`:null});if(e.every(e=>"string"==typeof e))return`{${e.join(",")}}`}return null},o.classNameListFromAttribute=e=>{if(!e||!e.value)return null;const t=n.classNameValue(e.value);if(t)return[t];if(a.MultiArray.isInstanceOf(e.value)&&e.value.isCell){const t=a.MultiArray.linearize(e.value).map(e=>n.classNameValue(e));if(t.every(e=>Boolean(e)))return t}return null},o.positiveIntegerFromAttribute=e=>{const t=null==e?void 0:e.value;if(!t||void 0===t.re||void 0===t.im||0!==Number(t.im))return null;const r=Number(t.re);return Number.isInteger(r)&&r>0?r:null},o.accessFromAttributes=(e,t="Access",r=n.defaultAccess)=>{var s,i;return null!==(i=n.attributeValue(null===(s=e[t])||void 0===s?void 0:s[0]))&&void 0!==i?i:r},o.methodNameFromAttribute=(e,t)=>{var r;const s=n.attributeValue(null===(r=e[t])||void 0===r?void 0:r[0]);return s&&/^[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/.test(s)?s:null},o.validateAccessAttribute=(e,t,r,s)=>{var i;const a=null===(i=e[t])||void 0===i?void 0:i[0];if(!a)return;const o=n.attributeValue(a);o&&n.isSupportedAccess(o)||s(`invalid ${t} attribute for ${r}.`)},t.default={ClassMember:o}},7268(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassMetaEnumerationMember=t.ClassMetaEvent=t.ClassMetaMethod=t.ClassMetaProperty=t.ClassMetaMember=t.ClassMetaClass=t.ClassMetaObject=void 0;const n=r(5956),s=r(845),i=r(7679),a=r(5212),o=r(6109),l=e=>{const t=i.MultiArray.toColumnVector(e.map(e=>n.CharString.create(e)));return t.isCell=!0,t},c=e=>i.MultiArray.toColumnVector(e),u=e=>e?s.Complex.true():s.Complex.false(),h=()=>n.CharString.create(""),d=e=>l(Object.keys(e).sort()),m=e=>o.AST.isNodeIdentifier(e)?e.id:o.AST.isNodeIndirectRef(e)?`${m(e.obj)}.${String(e.field[0])}`:void 0,p=e=>{if(o.AST.isNodeList(e))return e.list.map(e=>p(e)).join(",");if(!o.AST.isStrictNodeExpr(e))return"";return m(e)||(n.CharString.isInstanceOf(e)?e.str:s.Complex.isInstanceOf(e)?e.toString():o.AST.isNodeIndexExpr(e)?`${p(e.expr)}(${e.args.map(e=>p(e)).join(",")})`:"")},f=e=>{const t=i.MultiArray.toColumnVector(e.map(e=>(e=>{var t,r,s;const o=null!==(r=null!==(t=e.default)&&void 0!==t?t:e.defaultValue)&&void 0!==r?r:null;return new a.Structure({Name:n.CharString.create(null!==(s=m(e.name))&&void 0!==s?s:""),Size:l(e.size.map(e=>p(e))),Class:e.class?n.CharString.create(p(e.class)):h(),Validators:l(e.functions.map(e=>p(e))),HasDefault:u(Boolean(o)),DefaultValue:null!=o?o:i.MultiArray.emptyArray()})})(e)));return t.isCell=!0,t},g=(e,t)=>e.node.arguments.list.flatMap(e=>{var r,n;return(null!==(n=null===(r=e.attribute)||void 0===r?void 0:r.id)&&void 0!==n?n:null)===t?e.validation:[]});class y{constructor(){this.type=y.CLASS_META}copy(){return y.copy(this)}}t.ClassMetaObject=y,y.CLASS_META=7,y.isInstanceOf=e=>e instanceof y,y.copy=e=>e,y.unparse=(e,t)=>`${e.kind} ${e.displayName()}`;class x extends y{constructor(e,t){super(),this.definition=e,this.propertyDefaultProvider=t,this.kind="meta.class"}displayName(){return this.definition.name}getProperty(e){switch(e){case"Name":return n.CharString.create(this.definition.name);case"Description":case"DetailedDescription":return h();case"SuperclassList":return c(this.definition.superclassDefinitions.map(e=>x.create(e,this.propertyDefaultProvider)));case"SuperClasses":return l(this.definition.superclasses);case"PropertyList":return c(this.definition.allProperties().map(e=>E.create(e,this.propertyDefaultProvider)));case"MethodList":return c(this.definition.allMethods().map(e=>v.create(e,this.propertyDefaultProvider)));case"EventList":return c(this.definition.allEvents().map(e=>A.create(e,this.propertyDefaultProvider)));case"EnumerationMemberList":return c(this.definition.allEnumerations().map(e=>S.create(e,this.propertyDefaultProvider)));case"Abstract":return u(this.definition.isEffectivelyAbstract());case"Sealed":return u(this.definition.isSealed);case"Hidden":return u(this.definition.isHidden);case"ConstructOnLoad":return u(this.definition.isConstructOnLoad);case"HandleCompatible":return u(this.definition.isHandleCompatibleClass());case"InferiorClasses":return l(this.definition.inferiorClasses);case"AllowedSubclasses":return l(this.definition.allowedSubclasses);case"ContainingPackage":return n.CharString.create(this.definition.packageName);case"RestrictsSubclassing":return u(this.definition.isRestrictsSubclassing);case"AttributeNames":return d(this.definition.attributes);default:return}}}t.ClassMetaClass=x,x.isInstanceOf=e=>e instanceof x,x.create=(e,t)=>new x(e,t);class C extends y{constructor(e,t){super(),this.member=e,this.propertyDefaultProvider=t}displayName(){return`${this.member.classDefinition.name}.${this.member.name}`}commonProperty(e){switch(e){case"Name":return n.CharString.create(this.member.name);case"DefiningClass":return x.create(this.member.classDefinition,this.propertyDefaultProvider);case"Hidden":return u("isHidden"in this.member&&this.member.isHidden);case"Description":case"DetailedDescription":return h();case"AttributeNames":return d(this.member.attributes);default:return}}}t.ClassMetaMember=C;class E extends C{constructor(e,t){super(e,t),this.property=e,this.defaultProvider=t,this.kind="meta.property"}defaultValue(){var e,t,r;return this.property.defaultValue?null!==(t=null===(e=this.defaultProvider)||void 0===e?void 0:e.call(this,this.property))&&void 0!==t?t:(r=this.property.defaultValue,o.AST.isRuntimeExpressionValue(r)?r:n.CharString.create(p(r))):null}getProperty(e){var t;const r=this.commonProperty(e);if(void 0!==r)return r;switch(e){case"GetAccess":return n.CharString.create(this.property.getAccess);case"SetAccess":return n.CharString.create(this.property.setAccess);case"Access":return n.CharString.create(this.property.access);case"Constant":return u(this.property.isConstant);case"Dependent":return u(this.property.isDependent);case"Abstract":return u(this.property.isAbstract);case"Transient":return u(this.property.isTransient);case"GetObservable":return u(this.property.isGetObservable);case"SetObservable":return u(this.property.isSetObservable);case"AbortSet":return u(this.property.isAbortSet);case"HasDefault":return u(Boolean(this.property.defaultValue));case"DefaultValue":return null!==(t=this.defaultValue())&&void 0!==t?t:i.MultiArray.emptyArray();case"Validation":return f(this.property.size.length>0||this.property.class||this.property.functions.length>0||this.property.defaultValue?[{name:this.property.node.name,size:this.property.size,class:this.property.class,functions:this.property.functions,defaultValue:this.defaultValue()}]:[]);case"GetMethod":return this.property.getMethodName?n.CharString.create(this.property.getMethodName):i.MultiArray.emptyArray();case"SetMethod":return this.property.setMethodName?n.CharString.create(this.property.setMethodName):i.MultiArray.emptyArray();case"NonCopyable":return u(this.property.isNonCopyable);case"PartialMatchPriority":return s.Complex.create(this.property.partialMatchPriority);default:return}}}t.ClassMetaProperty=E,E.isInstanceOf=e=>e instanceof E,E.create=(e,t)=>new E(e,t);class v extends C{constructor(e,t){super(e,t),this.method=e,this.kind="meta.method"}getProperty(e){const t=this.commonProperty(e);if(void 0!==t)return t;switch(e){case"Access":return n.CharString.create(this.method.access);case"Static":return u(this.method.isStatic);case"Abstract":return u(this.method.isAbstract);case"Sealed":return u(this.method.isSealed);case"InputNames":return l(this.method.node.parameter.list.flatMap(e=>o.AST.isNodeIdentifier(e)?[e.id]:o.AST.isNodeDefaultedParameter(e)?[e.left.id]:[]));case"OutputNames":return l((()=>this.method.node.return.list.flatMap(e=>o.AST.isNodeIdentifier(e)?[e.id]:[]))());case"InputValidation":return f(g(this.method,null));case"OutputValidation":return f(g(this.method,"Output"));case"RepeatingInputValidation":return f(g(this.method,"Repeating"));default:return}}}t.ClassMetaMethod=v,v.create=(e,t)=>new v(e,t);class A extends C{constructor(e,t){super(e,t),this.event=e,this.kind="meta.event"}getProperty(e){const t=this.commonProperty(e);if(void 0!==t)return t;switch(e){case"ListenAccess":return n.CharString.create(this.event.listenAccess);case"NotifyAccess":return n.CharString.create(this.event.notifyAccess);case"Access":return n.CharString.create(this.event.access);default:return}}}t.ClassMetaEvent=A,A.create=(e,t)=>new A(e,t);class S extends C{constructor(e,t){super(e,t),this.enumeration=e,this.kind="meta.EnumerationMember"}getProperty(e){const t=this.commonProperty(e);return void 0!==t?t:"ConstructorArguments"===e?0===this.enumeration.args.length?i.MultiArray.emptyArray():l(this.enumeration.args.map(e=>p(e))):void 0}}t.ClassMetaEnumerationMember=S,S.create=(e,t)=>new S(e,t),t.default={ClassMetaObject:y,ClassMetaClass:x,ClassMetaMember:C,ClassMetaProperty:E,ClassMetaMethod:v,ClassMetaEvent:A,ClassMetaEnumerationMember:S}},482(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassPropertyEvent=void 0;const n=r(5956),s=r(169);class i extends s.ClassEventData{constructor(e,t,r=t,n=e){super(e,r),this.type=i.CLASS_PROPERTY_EVENT,this.propertyName=t,this.affectedObject=e,this.propertySource=n}copy(){return this}}t.ClassPropertyEvent=i,i.CLASS_PROPERTY_EVENT=13,i.isInstanceOf=e=>e instanceof i,i.create=(e,t,r=(null!=t?t:""),n)=>new i(e,null!=t?t:"",r,null!=n?n:e),i.getProperty=(e,t)=>{if(!i.isInstanceOf(e))return s.ClassEventData.getProperty(e,t);switch(t){case"Source":return e.propertySource;case"AffectedObject":return e.affectedObject;case"PropertyName":return n.CharString.create(e.propertyName);default:return s.ClassEventData.getProperty(e,t)}},i.unparse=(e,t)=>i.isInstanceOf(e)?`event.PropertyEvent ${e.affectedObject.classDefinition.name}.${e.propertyName}`:s.ClassEventData.unparse(e,t),t.default={ClassPropertyEvent:i}},8986(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClassStaticMethod=void 0;class r{constructor(e,t){this.type=r.CLASS_STATIC_METHOD,this.classDefinition=e,this.method=t}copy(){return r.copy(this)}}t.ClassStaticMethod=r,r.CLASS_STATIC_METHOD=9,r.isInstanceOf=e=>e instanceof r,r.bind=(e,t)=>new r(e,t),r.copy=e=>new r(e.classDefinition,e.method),r.unparse=(e,t)=>`${e.classDefinition.name}.${e.method.name} static method`,t.default={ClassStaticMethod:r}},845(e,t,r){"use strict";var n,s=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),a=0;a<r.length;a++)"default"!==r[a]&&s(t,e,r[a]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.toNumber=t.Complex=void 0;const o=a(r(5142)),l=r(3428),c=r(3826);t.toNumber=e=>e instanceof c.Decimal?e.toNumber():Number(e);class u{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=l.ComplexNumber;break;case"decimal":this._engineBackend=c.ComplexDecimal;break;default:throw new Error(`invalid complex backend engine: '${e}'.`)}o.ComplexInterfaceStaticKeyTable.forEach(e=>{const t=this._engineBackend;this[e]=t[e]}),this.set(this.defaultSettings)}}t.Complex=u,u.engine="decimal",t.default={Complex:u}},4034(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexConfigKeyTable=void 0,t.ComplexConfigKeyTable=["precision","precisionCompare","rounding","toExpPos","minE","maxE","toExpNeg","modulo","crypto"]},3826(e,t,r){"use strict";var n,s,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return a(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexDecimal=t.Decimal=void 0;const l=r(3110);Object.defineProperty(t,"Decimal",{enumerable:!0,get:function(){return l.Decimal}});const c=o(r(5142)),u={precision:336,rounding:l.Decimal.ROUND_HALF_DOWN,toExpPos:20,toExpNeg:-7,minE:-9e15,maxE:9e15,modulo:l.Decimal.ROUND_DOWN,crypto:!1};l.Decimal.set(u);const h=l.Decimal;h.create=e=>new l.Decimal(e),h.neg=e=>e.neg(),h.MINUSONE=new l.Decimal(-1),h.ZERO=new l.Decimal(0),h.TWO=new l.Decimal(2),h.PI=l.Decimal.acos(-1),h.PI_DEG=new l.Decimal(180),h.INF=new l.Decimal(1/0),h.unparse=e=>e.valueOf(),h.isZero=e=>e.isZero(),h.isNeg=e=>e.isNeg(),h.isNaN=e=>e.isNaN(),h.isFinite=e=>e.isFinite();const d=(e,t,r)=>{e[t]=r};class m{constructor(e,t,r,n){this.copy=()=>new s(this.re,this.im,this.type),this.toLogical=()=>s.logical(this),this.re=void 0!==e?new l.Decimal(e):new l.Decimal(0),this.im=void 0!==t?new l.Decimal(t):new l.Decimal(0),this.type=null!=r?r:s.COMPLEX,this.parent=null!=n?n:void 0,s.setNumberType(this)}toString(){return s.toString(this)}}t.ComplexDecimal=m,s=m,m.LOGICAL=c.numberClass.LOGICAL,m.REAL=c.numberClass.REAL,m.COMPLEX=c.numberClass.COMPLEX,m.defaultSettings=Object.assign({precisionCompare:7},u),m.settings=s.defaultSettings,m.isInstanceOf=e=>e instanceof s,m.set=e=>{const t={};c.ComplexConfigKeyTable.forEach(r=>{if(void 0!==e[r]){const n=e[r];"precisionCompare"!==r?(d(s.settings,r,n),((e,t,r)=>{e[t]=r})(t,r,n)):d(s.settings,r,n)}}),Object.keys(t).length>0&&l.Decimal.set(t)},m.setNumberType=c.setNumberTypeFactory(s),m.create=c.createFactory(s),m.realSet=(e,t)=>{e.re=new l.Decimal(t)},m.imagSet=(e,t)=>{e.im=new l.Decimal(t)},m.realApply=(e,t)=>{e.re=t(e.re)},m.imagApply=(e,t)=>{e.im=t(e.im)},m.from=e=>new s(e.re,e.im,e.type,e.parent),m.real=e=>new s(e.re),m.imag=e=>new s(e.im),m.isComplexValue=e=>!e.im.isZero(),m.isRealValue=e=>e.im.isZero(),m.realIsInteger=e=>e.re.isInteger(),m.imagIsInteger=e=>e.im.isInteger(),m.realIsFinite=e=>e.re.isFinite(),m.imagIsFinite=e=>e.im.isFinite(),m.realIsNaN=e=>e.re.isNaN(),m.imagIsNaN=e=>e.im.isNaN(),m.realIsNegative=e=>e.re.isNegative(),m.imagIsNegative=e=>e.im.isNegative(),m.realIsZero=e=>e.re.isZero(),m.imagIsZero=e=>e.im.isZero(),m.realIsPositive=e=>e.re.isPositive(),m.imagIsPositive=e=>e.im.isPositive(),m.realToNumber=e=>e.re.toNumber(),m.toBoolean=e=>e.type===s.LOGICAL?Boolean(e.re.toNumber()):Boolean(e.re.toNumber())||Boolean(e.im.toNumber()),m.imagToNumber=e=>e.im.toNumber(),m.realLessThan=(e,t)=>e.re.lt(t),m.imagLessThan=(e,t)=>e.im.lt(t),m.realLessThanOrEqualTo=(e,t)=>e.re.lte(t),m.imagLessThanOrEqualTo=(e,t)=>e.im.lte(t),m.realEquals=(e,t)=>e.re.eq(t),m.imagEquals=(e,t)=>e.im.eq(t),m.realGreaterThanOrEqualTo=(e,t)=>e.re.gte(t),m.imagGreaterThanOrEqualTo=(e,t)=>e.im.gte(t),m.realGreaterThan=(e,t)=>e.re.gt(t),m.imagGreaterThan=(e,t)=>e.im.gt(t),m.parse=c.parseFactory(s),m.precedence=c.precedenceFactory(s),m.unparseValue=c.unparseValueFactory(l.Decimal,s),m.unparse=c.unparseFactory(s),m.toString=c.toStringFactory(s),m.unparseMathMLValue=c.unparseMathMLValueFactory(l.Decimal,s),m.unparseMathML=c.unparseMathMLFactory(s),m.copy=c.copyFactory(s),m.toMaxPrecisionValue=e=>{const t=s.settings.precision-s.settings.precisionCompare;return e.toSignificantDigits(t).toDecimalPlaces(t)},m.toMaxPrecision=c.toMaxPrecisionFactory(s),m.epsilonValue=()=>l.Decimal.pow(10,-s.settings.precision+s.settings.precisionCompare),m.epsilon=c.epsilonFactory(s),m.random=e=>new s(l.Decimal.random(e)),m.eq=c.equalsFactory(s,!0),m.ne=c.equalsFactory(s,!1),m.compareValue=(e,t,r)=>t[e](r),m.cmp=c.cmpFactory(s),m.minMaxArrayReal=c.minMaxArrayRealFactory(s),m.minMaxArrayRealWithIndex=c.minMaxArrayRealWithIndexFactory(s),m.minMaxArrayComplex=c.minMaxArrayComplexFactory(s),m.minMaxArrayComplexWithIndex=c.minMaxArrayComplexWithIndexFactory(s),m.min=c.minMaxFactory(s,"lt"),m.minWise=c.minMaxWiseFactory(s,"lt"),m.max=c.minMaxFactory(s,"gte"),m.maxWise=c.minMaxWiseFactory(s,"gte"),m.lt=c.comparisonFactory(s,"lt"),m.le=c.comparisonFactory(s,"lte"),m.gt=c.comparisonFactory(s,"gt"),m.ge=c.comparisonFactory(s,"gte"),m.false=c.literalFactory(s,0,0,s.LOGICAL),m.true=c.literalFactory(s,1,0,s.LOGICAL),m.logical=c.logicalFactory(s),m.toLogical=e=>s.logical(e),m.and=c.andFactory(s),m.or=c.orFactory(s),m.xor=c.xorFactory(s),m.not=c.notFactory(s),m.zero=c.literalFactory(s,0,0),m.one=c.literalFactory(s,1,0),m.onediv2=c.literalFactory(s,.5,0),m.minusonediv2=c.literalFactory(s,-.5,0),m.minusone=c.literalFactory(s,-1,0),m.pi=c.literalFactory(s,l.Decimal.acos(-1),0),m.pidiv2=c.literalFactory(s,l.Decimal.div(l.Decimal.acos(-1),2),0),m.onei=c.literalFactory(s,0,1),m.onediv2i=c.literalFactory(s,0,.5),m.minusonediv2i=c.literalFactory(s,0,-.5),m.minusonei=c.literalFactory(s,0,-1),m.two=c.literalFactory(s,2,0),m.sqrt2pi=c.literalFactory(s,l.Decimal.sqrt(l.Decimal.mul(2,l.Decimal.acos(-1))),0),m.e=c.literalFactory(s,l.Decimal.exp(1),0),m.NaN_0=c.literalFactory(s,NaN,0),m.inf_0=c.literalFactory(s,1/0,0),m.add=(e,t)=>new s(l.Decimal.add(e.re,t.re),l.Decimal.add(e.im,t.im)),m.sub=(e,t)=>new s(l.Decimal.sub(e.re,t.re),l.Decimal.sub(e.im,t.im)),m.neg=e=>new s(e.re.neg(),e.im.neg()),m.mul=c.mulFactory(l.Decimal,s),m.mulAndSumTo=c.mulAndSumToFactory(l.Decimal,s),m.rdiv=c.rdivFactory(l.Decimal,s),m.ldiv=c.ldivFactory(l.Decimal,s),m.inv=c.invFactory(l.Decimal,s),m.power=c.powerFactory(l.Decimal,s),m.root=c.rootFactory(s),m.absValue=c.absValueFactory(l.Decimal),m.abs2Value=c.abs2ValueFactory(l.Decimal),m.abs=c.absFactory(l.Decimal,s),m.abs2=c.abs2Factory(l.Decimal,s),m.hypot=c.hypotFactory(s),m.arg=c.argFactory(l.Decimal,s),m.conj=c.conjFactory(l.Decimal,s),m.mod=c.modFactory(l.Decimal,s),m.rem=c.remFactory(l.Decimal,s),m.fix=c.fixFactory(l.Decimal,s),m.ceil=c.ceilFactory(l.Decimal,s),m.floor=c.floorFactory(l.Decimal,s),m.round=c.roundFactory(l.Decimal,s),m.sign=c.signFactory(l.Decimal,s),m.sqrt=c.sqrtFactory(l.Decimal,s),m.exp=c.expFactory(l.Decimal,s),m.log=c.logFactory(l.Decimal,s),m.logb=c.logbFactory(l.Decimal,s),m.log2=c.log2Factory(s),m.log10=c.log10Factory(s),m.deg2rad=c.deg2radFactory(l.Decimal,s),m.rad2deg=c.rad2degFactory(l.Decimal,s),m.sin=c.sinFactory(l.Decimal,s),m.sind=c.sindFactory(s),m.cos=c.cosFactory(l.Decimal,s),m.cosd=c.cosdFactory(s),m.tan=c.tanFactory(s),m.tand=c.tandFactory(s),m.csc=c.cscFactory(s),m.cscd=c.cscdFactory(s),m.sec=c.secFactory(s),m.secd=c.secdFactory(s),m.cot=c.cotFactory(s),m.cotd=c.cotdFactory(s),m.asin=c.asinFactory(s),m.asind=c.asindFactory(s),m.acos=c.acosFactory(s),m.acosd=c.acosdFactory(s),m.atan=c.atanFactory(s),m.atan2=c.atan2Factory(l.Decimal,s),m.atand=c.atandFactory(s),m.acsc=c.acscFactory(s),m.acscd=c.acscdFactory(s),m.asec=c.asecFactory(s),m.asecd=c.asecdFactory(s),m.acot=c.acotFactory(s),m.acotd=c.acotdFactory(s),m.sinh=c.sinhFactory(l.Decimal,s),m.cosh=c.coshFactory(l.Decimal,s),m.tanh=c.tanhFactory(s),m.csch=c.cschFactory(s),m.sech=c.sechFactory(s),m.coth=c.cothFactory(s),m.asinh=c.asinhFactory(s),m.acosh=c.acoshFactory(s),m.atanh=c.atanhFactory(s),m.acsch=c.acschFactory(s),m.asech=c.asechFactory(s),m.acoth=c.acothFactory(s),m.gamma=c.gammaFactory(s),m.factorial=c.factorialFactory(l.Decimal,s),m.applyFunction=c.applyFunctionFactory(l.Decimal),m.mapFunction=c.mapFunctionFactory(s),m.twoArgFunction=c.twoArgFunctionFactory(s),m.set(m.defaultSettings),t.default={ComplexDecimal:m}},5142(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.remFactory=t.modFactory=t.conjFactory=t.argFactory=t.hypotFactory=t.abs2Factory=t.absFactory=t.abs2ValueFactory=t.absValueFactory=t.rootFactory=t.powerFactory=t.invFactory=t.ldivFactory=t.rdivFactory=t.mulAndSumToFactory=t.mulFactory=t.literalFactory=t.notFactory=t.xorFactory=t.orFactory=t.andFactory=t.logicalFactory=t.comparisonFactory=t.minMaxWiseFactory=t.minMaxFactory=t.minMaxArrayComplexWithIndexFactory=t.minMaxArrayComplexFactory=t.minMaxArrayRealWithIndexFactory=t.minMaxArrayRealFactory=t.cmpFactory=t.equalsFactory=t.epsilonFactory=t.copyFactory=t.toMaxPrecisionFactory=t.unparseMathMLFactory=t.unparseMathMLValueFactory=t.toStringFactory=t.unparseFactory=t.unparseValueFactory=t.precedenceFactory=t.parseFactory=t.createFactory=t.setNumberTypeFactory=t.numberClass=t.moduloName=t.roundingName=t.roundingMode=t.ComplexInterfaceStaticKeyTable=t.ComplexInterfaceKeyTable=t.ComplexConfigKeyTable=void 0,t.acothFactory=t.asechFactory=t.acschFactory=t.atanhFactory=t.acoshFactory=t.asinhFactory=t.cothFactory=t.sechFactory=t.cschFactory=t.tanhFactory=t.coshFactory=t.sinhFactory=t.acotdFactory=t.acotFactory=t.asecdFactory=t.asecFactory=t.acscdFactory=t.acscFactory=t.atandFactory=t.atan2Factory=t.atanFactory=t.acosdFactory=t.acosFactory=t.asindFactory=t.asinFactory=t.cotdFactory=t.cotFactory=t.secdFactory=t.secFactory=t.cscdFactory=t.cscFactory=t.tandFactory=t.tanFactory=t.cosdFactory=t.cosFactory=t.sindFactory=t.sinFactory=t.rad2degFactory=t.deg2radFactory=t.log10Factory=t.log2Factory=t.logbFactory=t.logFactory=t.expFactory=t.sqrtFactory=t.signFactory=t.roundFactory=t.floorFactory=t.ceilFactory=t.fixFactory=void 0,t.twoArgFunctionFactory=t.mapFunctionFactory=t.applyFunctionFactory=t.factorialFactory=t.gammaFactory=void 0;var n=r(4034);Object.defineProperty(t,"ComplexConfigKeyTable",{enumerable:!0,get:function(){return n.ComplexConfigKeyTable}});var s=r(3139);Object.defineProperty(t,"ComplexInterfaceKeyTable",{enumerable:!0,get:function(){return s.ComplexInterfaceKeyTable}});var i=r(5377);Object.defineProperty(t,"ComplexInterfaceStaticKeyTable",{enumerable:!0,get:function(){return i.ComplexInterfaceStaticKeyTable}}),t.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},t.roundingName=["up","down","ceil","floor","half_up","half_down","half_even","half_ceil","half_floor"],t.moduloName=["up","down",void 0,"floor",void 0,void 0,"half_even",void 0,void 0,"euclid"],t.numberClass={LOGICAL:0,REAL:1,COMPLEX:2},t.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},t.createFactory=e=>(t,r,n,s)=>new e(t,r,n,s),t.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)},t.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["()"]},t.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)?"-":"")+"∞"},t.unparseFactory=e=>(t,r,n=0)=>{if(t.type!==e.LOGICAL){const s=e.toMaxPrecision(t);if(e.realIsZero(s)||e.imagIsZero(s)){if(e.realIsZero(s)){if(e.imagIsZero(s)){if(e.realIsNegative(s)||e.imagIsNegative(s)){if(e.realIsNegative(s)&&e.imagIsNegative(s)){const e="-0";return n>r.precedenceTable["-_"]?"("+e+")":e}if(e.realIsNegative(s)&&!e.imagIsNegative(s)){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(s,1)?"":e.imagEquals(s,-1)?"-":e.unparseValue(s.im))+"i";return n>(e.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+t+")":t}}{const t=e.unparseValue(s.re);return n>(e.realIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+t+")":t}}{const t=e.unparseValue(s.re)+(e.imagGreaterThan(s,0)?"+":"")+(e.imagEquals(s,1)?"":e.imagEquals(s,-1)?"-":e.unparseValue(s.im))+"i";return n>r.precedenceTable["+"]?"("+t+")":t}}return e.realIsZero(t)?"false":"true"},t.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"},t.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>⋅</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>∞</mi>"},t.unparseMathMLFactory=e=>(t,r,n=0)=>{if(t.type!==e.LOGICAL){const s=e.toMaxPrecision(t);if(e.realIsZero(s)||e.imagIsZero(s)){if(e.realIsZero(s)){if(e.imagIsZero(s)){if(e.realIsNegative(s)||e.imagIsNegative(s)){if(e.realIsNegative(s)&&e.imagIsNegative(s)){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(s)&&!e.imagIsNegative(s)){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(s,1)?"":e.imagEquals(s,-1)?"<mo>-</mo>":e.unparseMathMLValue(s.im))+"<mi>i</mi>";return n>(e.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(s.re);return n>(e.realIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(s.re)+(e.imagGreaterThan(s,0)?"<mo>+</mo>":"")+(e.imagEquals(s,1)?"":e.imagEquals(s,-1)?"<mo>-</mo>":e.unparseMathMLValue(s.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>"},t.toMaxPrecisionFactory=e=>t=>new e(e.toMaxPrecisionValue(t.re),e.toMaxPrecisionValue(t.im)),t.copyFactory=e=>t=>new e(t.re,t.im,t.type),t.epsilonFactory=e=>()=>new e(e.epsilonValue()),t.equalsFactory=(e,t=!0)=>t?(t,r)=>{const n=e.toMaxPrecision(t),s=e.toMaxPrecision(r);return e.realEquals(n,s.re)&&e.imagEquals(n,s.im)?e.true():e.false()}:(t,r)=>{const n=e.toMaxPrecision(t),s=e.toMaxPrecision(r);return e.realEquals(n,s.re)&&e.imagEquals(n,s.im)?e.false():e.true()},t.cmpFactory=e=>(t,r,n)=>{const s=e.toMaxPrecision(r),i=e.toMaxPrecision(n);if(e.imagIsZero(s)&&e.imagIsZero(i))return e.compareValue(t,s.re,i.re)?e.true():e.false();const a=e.toMaxPrecisionValue(e.abs(r).re),o=e.toMaxPrecisionValue(e.abs(n).re);return e.compareValue("eq",a,o)?e.compareValue(t,e.toMaxPrecisionValue(e.arg(r).re),e.toMaxPrecisionValue(e.arg(n).re))?e.true():e.false():e.compareValue(t,a,o)?e.true():e.false()},t.minMaxArrayRealFactory=e=>(t,...r)=>r.reduce((r,n)=>e.compareValue(t,r.re,n.re)?r:n,r[0]),t.minMaxArrayRealWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,s,i)=>e.compareValue(t,r.re,s.re)?r:(n=i,s),r[r.length-1]),n]},t.minMaxArrayComplexFactory=e=>(t,...r)=>r.reduce((r,n)=>{const s=e.abs(r).re,i=e.abs(n).re;return e.compareValue("eq",s,i)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,s,i)?r:n},r[0]),t.minMaxArrayComplexWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,s,i)=>{const a=e.abs(r).re,o=e.abs(s).re;return e.compareValue("eq",a,o)?e.compareValue(t,e.arg(r).re,e.arg(s).re)?r:(n=i,s):e.compareValue(t,a,o)?r:(n=i,s)},r[r.length-1]),n]},t.minMaxFactory=(e,t)=>(r,n)=>{if(e.imagIsZero(r)&&e.imagIsZero(n))return e.compareValue(t,r.re,n.re)?r:n;{const s=e.abs(r).re,i=e.abs(n).re;return e.compareValue("eq",s,i)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,s,i)?r:n}},t.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 s=e.abs(r).re,i=e.abs(n).re;return e.compareValue("eq",s,i)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,s,i)?r:n}},t.comparisonFactory=(e,t)=>(r,n)=>e.cmp(t,r,n),t.logicalFactory=e=>t=>{const r=e.toMaxPrecision(t);return new e(e.realIsZero(r)&&e.imagIsZero(r)?0:1,0,e.LOGICAL)},t.andFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),s=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)||e.realIsZero(s)&&e.imagIsZero(s)?e.false():e.true()},t.orFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),s=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&e.realIsZero(s)&&e.imagIsZero(s)?e.false():e.true()},t.xorFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),s=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&(!e.realIsZero(s)||!e.imagIsZero(s))||(!e.realIsZero(n)||!e.imagIsZero(n))&&e.realIsZero(s)&&e.imagIsZero(s)?e.true():e.false()},t.notFactory=e=>t=>{const r=e.toMaxPrecision(t);return e.realIsZero(r)&&e.imagIsZero(r)?e.true():e.false()},t.literalFactory=(e,t,r,n)=>()=>new e(t,r,n),t.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))),t.mulAndSumToFactory=(e,t)=>(r,n,s)=>(t.imagIsZero(n)&&t.imagIsZero(s)&&t.imagIsZero(r)?r.re=e.add(r.re,e.mul(n.re,s.re)):(r.re=e.add(r.re,e.sub(e.mul(n.re,s.re),e.mul(n.im,s.im))),r.im=e.add(r.im,e.add(e.mul(n.re,s.im),e.mul(n.im,s.re)))),r),t.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 s=e.add(e.mul(n.re,n.re),e.mul(n.im,n.im));return e.isFinite(s)?e.isZero(s)?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)),s),e.div(e.sub(e.mul(r.im,n.re),e.mul(r.re,n.im)),s)):e.isNaN(s)?(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)}},t.ldivFactory=(e,r)=>{const n=(0,t.rdivFactory)(e,r);return(e,t)=>n(t,e)},t.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()},t.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 s=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,t.realIsZero(r)?e.ZERO:r.re),i=e.add(e.mul(r.re,r.re),e.mul(r.im,r.im)),a=e.mul(e.pow(i,e.div(n.re,e.TWO)),e.exp(e.mul(e.mul(e.MINUSONE,n.im),s))),o=e.add(e.mul(n.re,s),e.mul(e.div(n.im,e.TWO),e.ln(i)));return new t(e.mul(a,e.cos(o)),t.imagIsZero(r)&&t.imagIsZero(n)&&(t.realGreaterThanOrEqualTo(n,1)||t.realLessThanOrEqualTo(n,-1))?0:e.mul(a,e.sin(o)))}},t.rootFactory=e=>(t,r)=>e.power(t,e.inv(r)),t.absValueFactory=e=>t=>e.sqrt(e.add(e.mul(t.re,t.re),e.mul(t.im,t.im))),t.abs2ValueFactory=e=>t=>e.add(e.mul(t.re,t.re),e.mul(t.im,t.im)),t.absFactory=(e,t)=>r=>t.imagIsZero(r)?new t(e.abs(r.re)):new t(t.absValue(r)),t.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))},t.hypotFactory=e=>(t,r)=>new e(e.absValue(new e(e.absValue(t),e.absValue(r)))),t.argFactory=(e,t)=>r=>new t(e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),0),t.conjFactory=(e,t)=>r=>new t(r.re,e.neg(r.im)),t.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))},t.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))},t.fixFactory=(e,t)=>r=>new t(e.trunc(r.re),e.trunc(r.im)),t.ceilFactory=(e,t)=>r=>new t(e.ceil(r.re),e.ceil(r.im)),t.floorFactory=(e,t)=>r=>new t(e.floor(r.re),e.floor(r.im)),t.roundFactory=(e,t)=>r=>new t(e.round(r.re),e.round(r.im)),t.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))),t.sqrtFactory=(e,t)=>r=>{const n=t.absValue(r),s=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re);return new t(e.mul(e.sqrt(n),e.cos(e.div(s,e.TWO))),e.mul(e.sqrt(n),e.sin(e.div(s,e.TWO))))},t.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))),t.logFactory=(e,t)=>r=>new t(e.ln(t.absValue(r)),e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re)),t.logbFactory=(e,t)=>(r,n)=>{const s=t.absValue(r);if(e.isZero(s))return t.zero();{const i=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),a=t.absValue(n),o=e.atan2(t.imagIsZero(n)?e.ZERO:n.im,n.re),l=e.add(e.mul(e.ln(s),e.ln(s)),e.mul(i,i));return new t(e.div(e.add(e.mul(e.ln(a),e.ln(s)),e.mul(o,i)),l),e.div(e.sub(e.mul(o,e.ln(s)),e.mul(e.ln(a),i)),l))}},t.log2Factory=e=>t=>e.logb(new e(2),t),t.log10Factory=e=>t=>e.logb(new e(10),t),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)),t.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)),t.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))),t.sindFactory=e=>t=>e.sin(e.deg2rad(t)),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)))),t.cosdFactory=e=>t=>e.cos(e.deg2rad(t)),t.tanFactory=e=>t=>e.rdiv(e.sin(t),e.cos(t)),t.tandFactory=e=>t=>e.tan(e.deg2rad(t)),t.cscFactory=e=>t=>e.rdiv(e.one(),e.sin(t)),t.cscdFactory=e=>t=>e.csc(e.deg2rad(t)),t.secFactory=e=>t=>e.rdiv(e.one(),e.cos(t)),t.secdFactory=e=>t=>e.sec(e.deg2rad(t)),t.cotFactory=e=>t=>e.rdiv(e.cos(t),e.sin(t)),t.cotdFactory=e=>t=>e.rdiv(e.cos(t),e.sin(t)),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)))),t.asindFactory=e=>t=>e.rad2deg(e.asin(t)),t.acosFactory=e=>t=>e.sub(e.pidiv2(),e.asin(t)),t.acosdFactory=e=>t=>e.rad2deg(e.acos(t)),t.atanFactory=e=>t=>e.mul(e.minusonediv2i(),e.log(e.rdiv(e.sub(e.onei(),t),e.add(e.onei(),t)))),t.atan2Factory=(e,t)=>(r,n)=>{const s=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))),i=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),s),e.sub(e.sub(e.create(1),e.mul(s,s)),e.mul(i,i))))),e.mul(e.create(-1/4),e.ln(e.div(e.add(e.mul(e.sub(e.create(1),i),e.sub(e.create(1),i)),e.mul(s,s)),e.add(e.mul(e.add(e.create(1),i),e.add(e.create(1),i)),e.mul(s,s))))))},t.atandFactory=e=>t=>e.rad2deg(e.atan(t)),t.acscFactory=e=>t=>e.asin(e.rdiv(e.one(),t)),t.acscdFactory=e=>t=>e.rad2deg(e.acsc(t)),t.asecFactory=e=>t=>e.acos(e.rdiv(e.one(),t)),t.asecdFactory=e=>t=>e.rad2deg(e.asec(t)),t.acotFactory=e=>t=>e.atan(e.rdiv(e.one(),t)),t.acotdFactory=e=>t=>e.rad2deg(e.acot(t)),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))),t.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))),t.tanhFactory=e=>t=>e.rdiv(e.sinh(t),e.cosh(t)),t.cschFactory=e=>t=>e.rdiv(e.one(),e.sinh(t)),t.sechFactory=e=>t=>e.rdiv(e.one(),e.cosh(t)),t.cothFactory=e=>t=>e.rdiv(e.cosh(t),e.sinh(t)),t.asinhFactory=e=>t=>e.log(e.add(e.sqrt(e.add(e.one(),e.power(t,e.two()))),t)),t.acoshFactory=e=>t=>e.log(e.add(e.sqrt(e.add(e.minusone(),e.power(t,e.two()))),t)),t.atanhFactory=e=>t=>e.mul(e.onediv2(),e.log(e.rdiv(e.add(e.one(),t),e.sub(e.one(),t)))),t.acschFactory=e=>t=>e.rdiv(e.one(),e.asinh(t)),t.asechFactory=e=>t=>e.rdiv(e.one(),e.acosh(t)),t.acothFactory=e=>t=>e.rdiv(e.one(),e.atanh(t)),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 s=e.add(t,new e(r.length-1.5));for(let s=1;s<r.length;s++)n=e.add(n,e.rdiv(new e(r[s]),e.add(t,new e(s))));return e.mul(e.mul(e.sqrt2pi(),e.power(s,e.add(t,new e(.5)))),e.mul(e.exp(e.neg(s)),n))}},t.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},t.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)}),t.mapFunctionFactory=e=>({real:e.real,imag:e.imag,logical:e.logical,abs:e.abs,arg:e.arg,angle: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}),t.twoArgFunctionFactory=e=>({root:e.root,hypot:e.hypot,power:e.power,logb:e.logb,atan2:e.atan2})},3139(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexInterfaceKeyTable=void 0,t.ComplexInterfaceKeyTable=["re","im","type","parent","copy","toString","toLogical"]},5377(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexInterfaceStaticKeyTable=void 0,t.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"]},3428(e,t,r){"use strict";var n,s,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return a(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexNumber=void 0;const l=o(r(5142)),c={precision:15,precisionCompare:0,rounding:l.roundingMode.ROUND_HALF_EVEN,toExpPos:21,toExpNeg:-7,minE:-324,maxE:308,modulo:l.roundingMode.ROUND_DOWN,crypto:!1},u=Math;u.add=(e,t)=>e+t,u.sub=(e,t)=>e-t,u.neg=e=>-e,u.mul=(e,t)=>e*t,u.div=(e,t)=>e/t,u.mod=(e,t)=>e%t,u.ln=Math.log,u.create=e=>Number(e),u.MINUSONE=-1,u.ZERO=0,u.TWO=2,u.PI_DEG=180,u.INF=1/0,u.unparse=e=>0===e?Object.is(e,-0)?"-0":"0":e.toString(),u.isZero=e=>0===e,u.isNeg=e=>0===e?Object.is(e,-0):e<0,u.isNaN=Number.isNaN,u.isFinite=Number.isFinite;class h{constructor(e,t,r,n){this.copy=()=>new s(this.re,this.im,this.type),this.toLogical=()=>s.logical(this),this.re=void 0!==e?Number(e):0,this.im=void 0!==t?Number(t):0,this.type=null!=r?r:s.COMPLEX,n&&(this.parent=n),s.setNumberType(this)}toString(){return s.toString(this)}static epsilonValue(){return Math.max(Math.pow(10,-this.settings.precision+this.settings.precisionCompare),Number.EPSILON)}}t.ComplexNumber=h,s=h,h.LOGICAL=l.numberClass.LOGICAL,h.REAL=l.numberClass.REAL,h.COMPLEX=l.numberClass.COMPLEX,h.defaultSettings=Object.assign({},c),h.settings=s.defaultSettings,h.isInstanceOf=e=>e instanceof s,h.set=e=>{},h.setNumberType=l.setNumberTypeFactory(s),h.create=(e,t,r,n)=>new s(e,t,r,n),h.realSet=(e,t)=>{e.re=Number(t)},h.imagSet=(e,t)=>{e.im=Number(t)},h.realApply=(e,t)=>{e.re=t(e.re)},h.imagApply=(e,t)=>{e.im=t(e.im)},h.from=e=>new s(e.re,e.im,e.type),h.real=e=>new s(e.re),h.imag=e=>new s(e.im),h.isComplexValue=e=>0!==e.im,h.isRealValue=e=>0===e.im,h.realIsInteger=e=>Number.isInteger(e.re),h.imagIsInteger=e=>Number.isInteger(e.im),h.realIsFinite=e=>Number.isFinite(e.re),h.imagIsFinite=e=>Number.isFinite(e.im),h.realIsNaN=e=>Number.isNaN(e.re),h.imagIsNaN=e=>Number.isNaN(e.im),h.realIsNegative=e=>e.re<0||Object.is(e.re,-0),h.imagIsNegative=e=>e.im<0||Object.is(e.im,-0),h.realIsZero=e=>0===e.re,h.imagIsZero=e=>0===e.im,h.realIsPositive=e=>e.re>=0,h.imagIsPositive=e=>e.im>=0,h.realToNumber=e=>e.re,h.toBoolean=e=>e.type===s.LOGICAL?Boolean(e.re):Boolean(e.re)||Boolean(e.im),h.imagToNumber=e=>e.im,h.realLessThan=(e,t)=>e.re<Number(t),h.imagLessThan=(e,t)=>e.im<Number(t),h.realLessThanOrEqualTo=(e,t)=>e.re<=Number(t),h.imagLessThanOrEqualTo=(e,t)=>e.im<=Number(t),h.realEquals=(e,t)=>e.re===Number(t),h.imagEquals=(e,t)=>e.im===Number(t),h.realGreaterThanOrEqualTo=(e,t)=>e.re>=Number(t),h.imagGreaterThanOrEqualTo=(e,t)=>e.im>=Number(t),h.realGreaterThan=(e,t)=>e.re>Number(t),h.imagGreaterThan=(e,t)=>e.im>Number(t),h.parse=l.parseFactory(s),h.precedence=l.precedenceFactory(s),h.unparseValue=l.unparseValueFactory(Math,s),h.unparse=l.unparseFactory(s),h.toString=l.toStringFactory(s),h.unparseMathMLValue=l.unparseMathMLValueFactory(Math,s),h.unparseMathML=l.unparseMathMLFactory(s),h.copy=l.copyFactory(s),h.toMaxPrecisionValue=e=>{const t=s.settings.precision-s.settings.precisionCompare;return Number(Number(e.toPrecision(t)).toFixed(t))},h.toMaxPrecision=l.toMaxPrecisionFactory(s),h.epsilon=l.epsilonFactory(s),h.random=e=>{if(void 0!==e&&15!==e){if(e<15)return new s(Math.random().toPrecision(e));throw new Error(`invalid number of significant digits: ${e}`)}return new s(Math.random())},h.eq=l.equalsFactory(s,!0),h.ne=l.equalsFactory(s,!1),h.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}},h.cmp=l.cmpFactory(s),h.minMaxArrayReal=l.minMaxArrayRealFactory(s),h.minMaxArrayRealWithIndex=l.minMaxArrayRealWithIndexFactory(s),h.minMaxArrayComplex=l.minMaxArrayComplexFactory(s),h.minMaxArrayComplexWithIndex=l.minMaxArrayComplexWithIndexFactory(s),h.min=l.minMaxFactory(s,"lt"),h.minWise=l.minMaxWiseFactory(s,"lt"),h.max=l.minMaxFactory(s,"gte"),h.maxWise=l.minMaxWiseFactory(s,"gte"),h.lt=l.comparisonFactory(s,"lt"),h.le=l.comparisonFactory(s,"lte"),h.gt=l.comparisonFactory(s,"gt"),h.ge=l.comparisonFactory(s,"gte"),h.false=()=>new s(0,0,s.LOGICAL),h.true=()=>new s(1,0,s.LOGICAL),h.logical=l.logicalFactory(s),h.toLogical=e=>s.logical(e),h.and=l.andFactory(s),h.or=l.orFactory(s),h.xor=l.xorFactory(s),h.not=l.notFactory(s),h.zero=l.literalFactory(s,0,0),h.one=l.literalFactory(s,1,0),h.onediv2=l.literalFactory(s,.5,0),h.minusonediv2=l.literalFactory(s,-.5,0),h.minusone=l.literalFactory(s,-1,0),h.pi=l.literalFactory(s,Math.PI,0),h.pidiv2=l.literalFactory(s,Math.PI/2,0),h.onei=l.literalFactory(s,0,1),h.onediv2i=l.literalFactory(s,0,.5),h.minusonediv2i=l.literalFactory(s,0,-.5),h.minusonei=l.literalFactory(s,0,-1),h.two=l.literalFactory(s,2,0),h.sqrt2pi=l.literalFactory(s,Math.sqrt(2*Math.PI),0),h.e=l.literalFactory(s,Math.E,0),h.NaN_0=l.literalFactory(s,NaN,0),h.inf_0=l.literalFactory(s,1/0,0),h.add=(e,t)=>new s(e.re+t.re,e.im+t.im),h.sub=(e,t)=>new s(e.re-t.re,e.im-t.im),h.neg=e=>new s(-e.re,-e.im),h.mul=l.mulFactory(Math,s),h.mulAndSumTo=l.mulAndSumToFactory(Math,s),h.rdiv=l.rdivFactory(Math,s),h.ldiv=l.ldivFactory(Math,s),h.inv=l.invFactory(Math,s),h.power=l.powerFactory(Math,s),h.root=l.rootFactory(s),h.absValue=l.absValueFactory(Math),h.abs2Value=l.abs2ValueFactory(Math),h.abs=l.absFactory(Math,s),h.abs2=l.abs2Factory(Math,s),h.hypot=l.hypotFactory(s),h.arg=l.argFactory(Math,s),h.conj=l.conjFactory(Math,s),h.mod=l.modFactory(Math,s),h.rem=l.remFactory(Math,s),h.fix=l.fixFactory(Math,s),h.ceil=l.ceilFactory(Math,s),h.floor=l.floorFactory(Math,s),h.round=l.roundFactory(Math,s),h.sign=l.signFactory(Math,s),h.sqrt=l.sqrtFactory(Math,s),h.exp=l.expFactory(Math,s),h.log=l.logFactory(Math,s),h.logb=l.logbFactory(Math,s),h.log2=l.log2Factory(s),h.log10=l.log10Factory(s),h.deg2rad=l.deg2radFactory(Math,s),h.rad2deg=l.rad2degFactory(Math,s),h.sin=l.sinFactory(Math,s),h.sind=l.sindFactory(s),h.cos=l.cosFactory(Math,s),h.cosd=l.cosdFactory(s),h.tan=l.tanFactory(s),h.tand=l.tandFactory(s),h.csc=l.cscFactory(s),h.cscd=l.cscdFactory(s),h.sec=l.secFactory(s),h.secd=l.secdFactory(s),h.cot=l.cotFactory(s),h.cotd=l.cotdFactory(s),h.asin=l.asinFactory(s),h.asind=l.asindFactory(s),h.acos=l.acosFactory(s),h.acosd=l.acosdFactory(s),h.atan=l.atanFactory(s),h.atan2=l.atan2Factory(Math,s),h.atand=l.atandFactory(s),h.acsc=l.acscFactory(s),h.acscd=l.acscdFactory(s),h.asec=l.asecFactory(s),h.asecd=l.asecdFactory(s),h.acot=l.acotFactory(s),h.acotd=l.acotdFactory(s),h.sinh=l.sinhFactory(Math,s),h.cosh=l.coshFactory(Math,s),h.tanh=l.tanhFactory(s),h.csch=l.cschFactory(s),h.sech=l.sechFactory(s),h.coth=l.cothFactory(s),h.asinh=l.asinhFactory(s),h.acosh=l.acoshFactory(s),h.atanh=l.atanhFactory(s),h.acsch=l.acschFactory(s),h.asech=l.asechFactory(s),h.acoth=l.acothFactory(s),h.gamma=l.gammaFactory(s),h.factorial=l.factorialFactory(Math,s),h.applyFunction=l.applyFunctionFactory(Math),h.mapFunction=l.mapFunctionFactory(s),h.twoArgFunction=l.twoArgFunctionFactory(s),h.set(h.defaultSettings),t.default={ComplexNumber:h}},9947(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Configuration=void 0;const n=r(5956),s=r(5142),i=r(845),a=r(7679),o=r(6109),l=r(6115);class c{static configure(...e){const t=(e,t)=>{if(n.CharString.isInstanceOf(e)){const r=c.configurationEntry(e.str);if(!r)throw new ReferenceError(`configure: invalid configuration: '${e.str}'.`);r.set(t)}else o.AST.throwInvalidCallError("configure")};if(0===e.length){for(const e in c.configuration)c.configuration[e].setDefault();return new n.CharString("All configuration set to default values.")}if(1===e.length&&a.MultiArray.isInstanceOf(e[0])){if(2===e[0].dimension[1])return e[0].array.forEach(e=>{t(e[0],e[1])}),new n.CharString(`${e[0].array.length} configuration values set.`);o.AST.throwInvalidCallError("configure")}else{if(2===e.length&&n.CharString.isInstanceOf(e[0]))return t(e[0],e[1]),new n.CharString(`Configuration parameter '${e[0].str}' set to '${c.configuration[e[0].str].get().toString()}'`);o.AST.throwInvalidCallError("configure")}}static getconfig(...e){let t;const r=Object.keys(c.configuration),s=e=>{e.forEach((e,r)=>{const s=c.configuration[e].get();t.array[r]=[new n.CharString(e),s]})};if(0===e.length)return t=new a.MultiArray([r.length,2],null,!0),s(r),t;if(1===e.length){const r=a.MultiArray.linearize(a.MultiArray.scalarToMultiArray(e[0])).map(e=>{if(n.CharString.isInstanceOf(e)&&e.str in c.configuration)return e.str;throw new Error("getconfig: invalid configuration parameter.")});return t=new a.MultiArray([r.length,2],null,!0),s(r),t}o.AST.throwInvalidCallError("getconfig")}}t.Configuration=c,c.roundingName=s.roundingName,c.moduloName=s.moduloName,c.configuration={blockThreshold:{set:e=>l.BLAS.set({blockThreshold:a.MultiArray.testInteger(c.requireComplex(e),"configure","blockThreshold configuration parameter")}),setDefault:()=>l.BLAS.set({blockThreshold:l.BLAS.defaultSettings.blockThreshold}),get:()=>i.Complex.create(l.BLAS.settings.blockThreshold)},blockSize:{set:e=>l.BLAS.set({blockSize:a.MultiArray.testInteger(c.requireComplex(e),"configure","blockSize configuration parameter")}),setDefault:()=>l.BLAS.set({blockSize:l.BLAS.defaultSettings.blockSize}),get:()=>i.Complex.create(l.BLAS.settings.blockSize)},real:{set:e=>i.Complex.engine=c.requireCharString(e).str,setDefault:()=>i.Complex.engine="decimal",get:()=>new n.CharString(i.Complex.engine)},precision:{set:e=>i.Complex.set({precision:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({precision:i.Complex.defaultSettings.precision}),get:()=>i.Complex.create(i.Complex.settings.precision)},precisionCompare:{set:e=>i.Complex.set({precisionCompare:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({precisionCompare:i.Complex.defaultSettings.precisionCompare}),get:()=>i.Complex.create(i.Complex.settings.precisionCompare)},rounding:{set:e=>{const t=c.requireCharString(e),r=c.roundingName.indexOf(t.str);if(!(r>0))throw new Error(`configure: invalid rounding mode: ${t.str}`);i.Complex.set({rounding:r})},setDefault:()=>i.Complex.set({rounding:i.Complex.defaultSettings.rounding}),get:()=>new n.CharString(c.roundingName[i.Complex.settings.rounding])},toExpPos:{set:e=>i.Complex.set({toExpPos:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({toExpPos:i.Complex.defaultSettings.toExpPos}),get:()=>i.Complex.create(i.Complex.settings.toExpPos)},toExpNeg:{set:e=>i.Complex.set({toExpNeg:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({toExpNeg:i.Complex.defaultSettings.toExpNeg}),get:()=>i.Complex.create(i.Complex.settings.toExpNeg)},minE:{set:e=>i.Complex.set({minE:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({minE:i.Complex.defaultSettings.minE}),get:()=>i.Complex.create(i.Complex.settings.minE)},maxE:{set:e=>i.Complex.set({maxE:i.Complex.realToNumber(c.requireComplex(e))}),setDefault:()=>i.Complex.set({maxE:i.Complex.defaultSettings.maxE}),get:()=>i.Complex.create(i.Complex.settings.maxE)},modulo:{set:e=>{const t=c.requireCharString(e),r=c.moduloName.indexOf(t.str);if(!(r>0))throw new Error(`configure: invalid modulo mode: ${t.str}`);i.Complex.set({modulo:r})},setDefault:()=>i.Complex.set({modulo:i.Complex.defaultSettings.modulo}),get:()=>new n.CharString(c.moduloName[i.Complex.settings.modulo])},crypto:{set:e=>i.Complex.set({crypto:Boolean(i.Complex.realToNumber(c.requireComplex(e)))}),setDefault:()=>i.Complex.set({crypto:i.Complex.defaultSettings.crypto}),get:()=>i.Complex.create(Number(i.Complex.settings.crypto),0,i.Complex.LOGICAL)}},c.requireComplex=e=>{if(i.Complex.isInstanceOf(e))return e;throw o.AST.throwInvalidCallError("configure"),new Error("unreachable")},c.requireCharString=e=>{if(n.CharString.isInstanceOf(e))return e;throw o.AST.throwInvalidCallError("configure"),new Error("unreachable")},c.configurationEntry=e=>c.configuration[e],c.configureSignature={inputs:{arity:-2,min:0,max:2,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]},{name:"value",optional:!0}]},outputs:{arity:1}},c.getconfigSignature={inputs:{arity:-1,min:0,max:1,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]}]},outputs:{arity:1}},c.functions={configure:{func:c.configure,signature:c.configureSignature},getconfig:{func:c.getconfig,signature:c.getconfigSignature}},t.default={Configuration:c}},7162(e,t,r){"use strict";t.ContinueSignal=t.BreakSignal=t.ReturnSignal=t.Context=void 0;const n=r(6109),s=r(5956),i=r(845),a=r(1271),o=r(7679),l=r(5212),c=r(6816),u=r(9770),h=r(9656),d=r(8986),m=r(3226),p=r(5577),f=r(2981),g=r(3812),y=r(3225),x=r(491),C=r(5273),E=r(9217),v=r(6028),A=r(1201),S=r(8146),_=r(1604);class b extends Error{constructor(){super("return"),this.name="ReturnSignal"}}t.ReturnSignal=b;class T extends Error{constructor(){super("break"),this.name="BreakSignal"}}t.BreakSignal=T;class M extends Error{constructor(){super("continue"),this.name="ContinueSignal"}}t.ContinueSignal=M;class N{loadContext(e,t){e?this.globalScope=e:(this.globalScope=f.Scope.create(),this.globalScope.nameTable=Object.create(null),this.globalScope.functionTable=Object.create(null),this.globalScope.undefinedReferenceTable=Object.create(null)),this.globalNameSet=new Set,this.globalInitializedNameSet=new Set,this.callStack=null!=t?t:[new g.CallFrame(this.globalScope)]}constructor(e,t,r,n=Object.create(null),s=!0,i=new Set,a=new Set,o=[],l=[],c=[],u=[],h=[]){this.interpreter=e,this.globalScope=t,this.builtInFunctionTable=n,this.allowForwardReference=s,this.globalNameSet=i,this.globalInitializedNameSet=a,this.forwardReferenceTargetStack=o,this.requestedOutputCountStack=l,this.requestedOutputMaskStack=c,this.commaListExpansionStack=u,this.classAccessStack=h,this.callStack=[],this.aliasNameFunction=e=>e,this.loadContext(t,r)}setAliasNameTable(e){if(e){this.aliasNameTable=Object.create(null);for(const[t,r]of Object.entries(e))this.aliasNameTable[t]=r;this.aliasNameFunction=e=>{for(const[t,r]of Object.entries(this.aliasNameTable))if(r.test(e))return t;return e}}else this.aliasNameFunction=e=>e}get builtInFunctionList(){return Object.keys(this.builtInFunctionTable)}get currentFrame(){return this.callStack[this.callStack.length-1]}get currentScope(){return this.currentFrame.scope}resolveName(e){return this.currentScope.resolveName(e)}resolveSymbol(e,t=this.currentScope,r={}){var n,s,i,a,o,l,u;const h=null===(n=r.variables)||void 0===n||n,d=null===(s=r.classes)||void 0===s||s,m=null===(i=r.loadClasses)||void 0===i||i,p=null===(a=r.loadFunctions)||void 0===a||a,f=null===(o=r.functions)||void 0===o||o,g=null===(l=r.imports)||void 0===l||l,y=this.aliasNameFunction(e),x=r=>{var n;const s=this.aliasNameFunction(r);if(d){const r=this.resolveClassDefinitionByExactName(s,t,!1);if(r)return{kind:"class",name:e,resolvedName:s,source:"import",classDefinition:r}}if(f){const r=t.resolveFunction(s);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:e,resolvedName:s,source:"BUILTIN"===r.type?"builtin":"import",functionDefinition:r};if(p){const r=null===(n=this.interpreter)||void 0===n?void 0:n.loadFunctionDefinition(s,t);if(r)return{kind:"function",name:e,resolvedName:s,source:"import",functionDefinition:r}}}if(d&&m){const r=this.resolveClassDefinitionByExactName(s,t,!0);if(r)return{kind:"class",name:e,resolvedName:s,source:"import",classDefinition:r}}};if(h){const r=t.resolveName(y);if(r&&void 0!==r.node&&!c.ClassDefinition.isInstanceOf(r.node))return{kind:"variable",name:e,resolvedName:y,source:"local",entry:r}}if(d){const r=this.resolveClassDefinitionByExactName(y,t,!1);if(r)return{kind:"class",name:e,resolvedName:y,source:"local",classDefinition:r}}if(f){const r=t.resolveFunction(y);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:e,resolvedName:y,source:"BUILTIN"===r.type?"builtin":"local",functionDefinition:r};if(p){const r=null===(u=this.interpreter)||void 0===u?void 0:u.loadFunctionDefinition(y,t);if(r)return{kind:"function",name:e,resolvedName:y,source:"local",functionDefinition:r}}}if(d&&m){const r=this.resolveClassDefinitionByExactName(y,t,!0);if(r)return{kind:"class",name:e,resolvedName:y,source:"local",classDefinition:r}}if(g&&!y.includes(".")){const e=[...new Map(t.importedNameCandidates(y).map(x).filter(e=>void 0!==e).map(e=>[e.resolvedName,e])).values()];if(e.length>1&&this.throwEvalError(`imported name '${y}' is ambiguous: ${e.map(e=>e.resolvedName).join(", ")}.`),1===e.length)return e[0]}if(f){const t=this.builtInFunctionTable[y];if(t)return{kind:"builtin",name:e,resolvedName:y,source:"builtin",functionDefinition:t}}}resolveFunction(e,t=this.currentScope){var r;return null===(r=this.resolveSymbol(e,t,{variables:!1,classes:!1}))||void 0===r?void 0:r.functionDefinition}resolveClassDefinition(e,t=this.currentScope){var r;return null===(r=this.resolveSymbol(e,t,{variables:!1,functions:!1}))||void 0===r?void 0:r.classDefinition}resolveClassDefinitionByExactName(e,t=this.currentScope,r=!0){var n,s;const i=t.resolveName(e);if(i&&c.ClassDefinition.isInstanceOf(i.node))return i.node;if(!r)return;const a=null===(n=this.interpreter)||void 0===n?void 0:n.loadClassDefinition(e,t);if(!a)return;const o=null!==(s=this.globalScope)&&void 0!==s?s:t;return this.defineClassDefinition(a,o),a}defineImport(e,t=this.currentScope){const r=e.trim(),n=r.endsWith(".*")?r.slice(0,-2):void 0;r&&(n||r.includes("."))&&""!==n||this.throwSyntaxError("import: imported name must be qualified."),t.defineImport(e)}assignName(e,t){this.currentScope.defineName(e,t)}resolvedIdentifierExpression(e,t,r){const n=(0,S.expressionValue)(e.node,t,"Identifier value",e=>this.throwEvalError(e));return n.parent=r,n}unresolvedCallTargetExpression(e){return n.AST.isNodeIdentifier(e)||this.throwEvalError("invalid unresolved call target."),e}assignFunction(e,t){this.currentScope.defineFunction(e,t)}defineClassDefinition(e,t=this.currentScope){return t.defineName(e.name,e),e}createChildScope(e=this.currentScope){return f.Scope.create(e)}pushForwardReferenceTargets(e){this.forwardReferenceTargetStack.push(e)}popForwardReferenceTargets(){return this.forwardReferenceTargetStack.pop()}pushRequestedOutputCount(e){this.requestedOutputCountStack.push(e)}popRequestedOutputCount(){return this.requestedOutputCountStack.pop()}pushRequestedOutputMask(e){this.requestedOutputMaskStack.push({depth:this.requestedOutputCountStack.length,mask:e.slice()})}popRequestedOutputMask(){var e;return null===(e=this.requestedOutputMaskStack.pop())||void 0===e?void 0:e.mask}get requestedOutputCount(){var e;return null!==(e=this.requestedOutputCountStack[this.requestedOutputCountStack.length-1])&&void 0!==e?e:1}requestedOutputMask(e=this.requestedOutputCount){const t=this.requestedOutputMaskStack[this.requestedOutputMaskStack.length-1],r=(null==t?void 0:t.depth)===this.requestedOutputCountStack.length?t.mask:void 0;return Array.from({length:e},(e,t)=>{var n;return null===(n=null==r?void 0:r[t])||void 0===n||n})}pushCommaListExpansion(e=!0){this.commaListExpansionStack.push(e)}popCommaListExpansion(){return this.commaListExpansionStack.pop()}get commaListExpansionEnabled(){var e;return null!==(e=this.commaListExpansionStack[this.commaListExpansionStack.length-1])&&void 0!==e&&e}canAccessClassMember(e,t="public"){if("public"===t)return!0;if("private"===t)return this.classAccessStack.includes(e);if("protected"===t)return this.classAccessStack.some(t=>t===e||t.isSubclassOf(e));const r=t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).split(","):[t];return r.every(e=>e.startsWith("?"))?r.some(e=>{const t=e.slice(1);return this.classAccessStack.some(e=>e.name===t||e.isSubclassOfName(t))}):this.classAccessStack.includes(e)}currentClassAccessName(){var e,t,r;const n=null===(e=this.classAccessStack[this.classAccessStack.length-1])||void 0===e?void 0:e.name;if(n)return n;for(let e=this.callStack.length-1;e>=0;e--){const n=null===(r=null===(t=this.callStack[e].func)||void 0===t?void 0:t.node)||void 0===r?void 0:r.className;if(n)return n}return""}withClassAccess(e,t){this.classAccessStack.push(e);try{return t()}finally{this.classAccessStack.pop()}}get currentForwardReferenceTargets(){var e;return null!==(e=this.forwardReferenceTargetStack[this.forwardReferenceTargetStack.length-1])&&void 0!==e?e:[]}getUndefinedReferenceChain(e,t){const r=[e],n=new Set(r);let s=e;for(;;){const e=this.getNextUndefinedReference(s,t);if(!e)return r;if(r.push(e),n.has(e))return r;n.add(e),s=e}}getNextUndefinedReference(e,t){const r=t.resolveName(e);if(!r)return;const n=this.findPendingIdentifier(r.node,t,r.undefinedReference);return null!=n?n:r.undefinedReference}findPendingIdentifier(e,t,r,s=new WeakSet){if(!e||"object"!=typeof e)return;if(s.has(e))return;s.add(e);const i=e;if(n.AST.isNodeIdentifier(e)){const n=t.resolveName(e.id);if((null==n?void 0:n.undefinedReference)||!n&&e.id===r)return e.id}for(const e of Object.keys(i)){if("parent"===e||"start"===e||"stop"===e)continue;const n=i[e];if(Array.isArray(n))for(const e of n){const n=this.findPendingIdentifier(e,t,r,s);if(n)return n}else{const e=this.findPendingIdentifier(n,t,r,s);if(e)return e}}}throwIfCircularReference(e,t){const r=this.getUndefinedReferenceChain(e,t),n=r[r.length-1],s=r.slice(0,-1).indexOf(n);s>=0&&this.throwCircularReferenceError(r.slice(s));const i=this.currentForwardReferenceTargets.find(e=>r.includes(e));i&&this.throwCircularReferenceError([...r.slice(0,r.indexOf(i)+1),e])}resolveCallable(e){var t,r,n;if(a.FunctionHandle.isInstanceOf(e)){if(e.id){const s=null!==(t=e.closure)&&void 0!==t?t:this.currentScope,i=this.resolveSymbol(e.id,s,{variables:!1,classes:!1}),a=null==i?void 0:i.functionDefinition;if(e.disallowNestedResolution&&"FCNDEF"===(null==a?void 0:a.type)&&(null===(r=a.attributes)||void 0===r?void 0:r.nested)&&this.throwReferenceError(`'${e.id}' undefined.`),a)return y.Callables.fromFunctionNode(a);const o=null===(n=this.interpreter)||void 0===n?void 0:n.resolveStaticMethod(e.id,s);if(o)return y.Callables.staticMethod(o);a||this.throwReferenceError(`'${e.id}' undefined.`)}if(a.FunctionHandle.isAnonymous(e))return y.Callables.lambda(e)}}resolveIdentifier(e,t){var r;const s=e.id,i=this.resolveSymbol(s,t,{classes:!1,functions:!1,imports:!1});if("variable"===(null==i?void 0:i.kind)){const r=i.entry;return this.allowForwardReference&&r.undefinedReference&&(this.throwIfCircularReference(s,t),this.throwUndefinedReferenceError(r.undefinedReference)),this.resolvedIdentifierExpression(r,s,e)}if("nargin"===s&&!n.AST.isNodeIndexExpr(e.parent))return this.currentFunctionArgumentCount(s);if("nargout"===s&&!n.AST.isNodeIndexExpr(e.parent))return this.currentFunctionOutputCount(s);if("meta"===s)return new l.Structure({class:new l.Structure({fromName:a.FunctionHandle.create("__meta_class_fromName")})});const o=this.resolveSymbol(s,t,{variables:!1});switch(null==o?void 0:o.kind){case"variable":{const r=o.entry;return this.allowForwardReference&&r.undefinedReference&&(this.throwIfCircularReference(s,t),this.throwUndefinedReferenceError(r.undefinedReference)),this.resolvedIdentifierExpression(r,s,e)}case"class":return o.classDefinition.parent=e,o.classDefinition;case"function":case"builtin":if(n.AST.isNodeIndexExpr(e.parent)){const t=a.FunctionHandle.create(o.resolvedName);return t.parent=e,t}if("builtin"===o.kind&&N.bareZeroArgumentBuiltins.has(s))return this.callCallable(y.Callables.builtin(o.functionDefinition),[],e);n.AST.throwInvalidCallError(s,!0,e=>this.throwSyntaxError(e))}const c=n.AST.isNodeIndexExpr(e.parent)?null===(r=this.interpreter)||void 0===r?void 0:r.resolveStaticMethod(s,t):void 0;return c?(c.parent=e,c):n.AST.isNodeIndexExpr(e.parent)?this.unresolvedCallTargetExpression(e):void this.throwUndefinedReferenceError(s)}expandCommaSeparatedList(e){var t;if(!n.AST.isNodeReturnList(e)||!e.commaSeparated)return[this.reducedCommaListScalar(e)];const r=null!==(t=e.returnListLength)&&void 0!==t?t:e.handler(0).length,s=e.handler(r),i=[];for(let t=0;t<r;t++)i.push(e.selector(s,t));return i}reducedCommaListScalar(e){return n.AST.reduceToFirstIfReturnList(e)}evaluateCommaListExpression(e){this.pushRequestedOutputCount(1),this.pushCommaListExpansion();try{return this.expandCommaSeparatedList(this.rawEvaluationResult(e,this.currentScope))}finally{this.popCommaListExpansion(),this.popRequestedOutputCount()}}expandCommaListArguments(e){return e.flatMap(e=>this.expressionValues(this.evaluateCommaListExpression(e),"arg"))}evaluateExpandedArgument(e,t="arg"){return this.expressionValues(this.evaluateCommaListExpression(e),t)}evaluateArgs(e,t,r){return e.flatMap((e,t)=>{if("all"===r)return this.evaluateExpandedArgument(e);const n=r;return n.length>0&&t<n.length&&!n[t]?[e]:this.evaluateExpandedArgument(e)})}evaluateBuiltInArgs(e,t,r){if("feval"===e.id||"builtin"===e.id)return t.length>0?[this.evaluateArgs([t[0]],r,"all")[0],...t.slice(1)]:[];if("set"!==this.aliasNameFunction(e.id))return this.evaluateArgs(t,r,e.ev);const i=[];return t.forEach((t,a)=>{if(a>0&&n.AST.isNodeBinaryOperation(t)&&"="===t.type&&n.AST.isNodeIdentifier(t.left))return i.push(new s.CharString(t.left.id)),void i.push(...this.evaluateArgs([t.right],r,e.ev));i.push(...this.evaluateArgs([t],r,e.ev))}),i}throwEvalError(e){throw new A.EvalError(e,this.getStackTrace())}throwReferenceError(e){throw new A.ReferenceError(e,this.getStackTrace())}throwUndefinedReferenceError(e){throw new A.UndefinedReferenceError(e,this.getStackTrace())}throwCircularReferenceError(e){throw new A.CircularReferenceError(e,this.getStackTrace())}throwSyntaxError(e){throw new A.SyntaxError(e,this.getStackTrace())}getCurrentFunctionDefinition(){return E.FunctionStack.currentFunctionDefinition(this.callStack)}isInsideUserFunction(){return void 0!==this.getCurrentFunctionDefinition()}currentFunctionSourceName(){var e;for(let t=this.callStack.length-1;t>=0;t--){const r=null===(e=this.callStack[t].func)||void 0===e?void 0:e.node,n=r&&"object"==typeof r&&"sourceName"in r?r.sourceName:void 0;if(n)return"string"==typeof n?n:""}return""}getCurrentFunctionCountFrame(){return E.FunctionStack.currentFunctionCountFrame(this.callStack)}getCallerWorkspace(e=!1,t=!1){return E.FunctionStack.callerWorkspace(this.callStack,this.globalScope,e=>f.Scope.create(e),e,t)}resolveWorkspace(e,t=!1,r=!1){return v.FunctionWorkspace.resolveWorkspace(e,this.globalScope,this.getCallerWorkspace(t,r),e=>this.throwSyntaxError(e))}currentFunctionArgumentCount(e){const t=E.FunctionStack.currentArgumentCount(this.callStack);return void 0===t&&this.throwEvalError(`${e} is only valid inside a function.`),i.Complex.create(t)}currentFunctionArgumentCountOrZero(){var e;return i.Complex.create(null!==(e=E.FunctionStack.currentArgumentCount(this.callStack))&&void 0!==e?e:0)}currentFunctionOutputCount(e){const t=E.FunctionStack.currentOutputCount(this.callStack);return void 0===t&&this.throwEvalError(`${e} is only valid inside a function.`),i.Complex.create(t)}currentFunctionOutputCountOrZero(){var e;return i.Complex.create(null!==(e=E.FunctionStack.currentOutputCount(this.callStack))&&void 0!==e?e:0)}currentFunctionOutputIsRequested(e){const t=this.getCurrentFunctionCountFrame();t||this.throwEvalError("isargout is only valid inside a function.");const r=e=>{var r,n;i.Complex.isInstanceOf(e)&&i.Complex.imagIsZero(e)||this.throwEvalError("isargout: argument must be a positive integer.");const s=i.Complex.realToNumber(e);return(!Number.isInteger(s)||s<1)&&this.throwEvalError("isargout: argument must be a positive integer."),s<=t.nargout&&(null===(n=null===(r=t.outputMask)||void 0===r?void 0:r[s-1])||void 0===n||n)?i.Complex.true():i.Complex.false()};if(o.MultiArray.isInstanceOf(e)){const t=new o.MultiArray(e.dimension,void 0,!1);for(let n=0;n<o.MultiArray.linearLength(e);n++){const[s,i]=o.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n);t.array[s][i]=r(e.array[s][i])}return o.MultiArray.setType(t),t}return r(e)}currentFunctionInputName(e,t=!0,r){const n=this.getCurrentFunctionCountFrame();return n||this.throwEvalError("inputname is only valid inside a function."),v.FunctionWorkspace.inputName(n.inputArgs,e,e=>this.throwSyntaxError(e),t,r)}currentFunctionName(){return E.FunctionStack.currentFunctionName(this.callStack)}declarePersistent(e,t,r){const n=this.getCurrentFunctionDefinition();n||this.throwSyntaxError("persistent declaration is only valid inside a function."),v.FunctionWorkspace.declarePersistent(e,t,n,r)}loadPersistentVariables(e,t){v.FunctionWorkspace.loadPersistentVariables(e,t)}storePersistentVariables(e,t){v.FunctionWorkspace.storePersistentVariables(e,t)}declareGlobal(e,t,r){var n;const s=null!==(n=r.globalDeclarationTarget)&&void 0!==n?n:r;v.FunctionWorkspace.declareGlobal(e,t,this.globalNameSet,this.globalScope.nameTable,s.nameTable,this.globalInitializedNameSet)}clearGlobalVariables(e){v.FunctionWorkspace.clearGlobalVariables(this.globalNameSet,this.globalScope,this.callStack.map(e=>e.scope),e)}clearClassDefinitions(){var e;const t=[this.globalScope,...this.callStack.map(e=>e.scope)].filter(e=>void 0!==e);for(const r of t)for(const t of Object.keys(r.nameTable))c.ClassDefinition.isInstanceOf(null===(e=r.nameTable[t])||void 0===e?void 0:e.node)&&r.removeName(t)}clearCurrentVariables(e){const t=this.nativeNameSet instanceof Set?this.nativeNameSet:new Set,r=e||Object.keys(this.currentScope.nameTable);for(const e of r){const r=this.currentScope.nameTable[e];t.has(e)||c.ClassDefinition.isInstanceOf(null==r?void 0:r.node)||this.currentScope.removeName(e)}}resolveCallSite(e){let t=e;for(;t;){if(t.start)return t;t=t.parent}}static debugIdentifier(e){const t=null==e?void 0:e.id;return"string"==typeof t?t:void 0}builtInInputSignatures(e){return x.FunctionSignature.inputSignatures(e)}builtInOutputSignatures(e){return x.FunctionSignature.outputSignatures(e)}builtInDeclaredArity(e){return x.FunctionSignature.declaredArity(e)}validateBuiltInInputArity(e,t){n.AST.throwInvalidCallError(e.id,!x.FunctionSignature.inputArityIsValid(e,t),e=>this.throwSyntaxError(e))}validateBuiltInInputParameters(e,t){n.AST.throwInvalidCallError(e.id,!x.FunctionSignature.inputParametersAreValid(e,t),e=>this.throwSyntaxError(e))}valueDimensions(e){return _.RuntimeValue.dimensions(e)}sizeReturnList(e){const t=this.valueDimensions(e),r=this.requestedOutputMask(Math.max(this.requestedOutputCount,t.length)),s=e=>{var t;return null===(t=r[e])||void 0===t||t};return n.AST.nodeReturnList((e,t)=>{const r=e[`dim${t}`];return void 0===r&&n.AST.throwErrorIfGreaterThanReturnList(e.length,t+1,e=>this.throwEvalError(e)),r},e=>{const r=t.slice();o.MultiArray.appendSingletonTail(r,Math.max(e,2));const n={length:e};for(let t=0;t<e;t++){if(!s(t))continue;const a=t===e-1?r.slice(t).reduce((e,t)=>e*t,1):r[t];n[`dim${t}`]=i.Complex.create(a)}return n})}callClassBuiltinMethod(e,t,r){const s=this.aliasNameFunction(e.id);if(n.AST.isNodeIdentifier(r)&&"builtin"===r.id)return;if(!N.classBuiltinMethodFunctionNames.has(s)||0===t.length)return;const i=t[0];if(!u.ClassInstance.isInstanceOf(i))return;const a=i.classDefinition.findMethod(s,e=>!e.isStatic);if(!a)return;this.canAccessClassMember(a.classDefinition,a.access)||this.throwEvalError(`method '${s}' has ${a.access} access for class ${i.classDefinition.name}.`);const o=t.slice(1).map((e,t)=>(0,S.expressionValue)(e,`argument ${t+2}`,"Argument value",e=>this.throwEvalError(e)));return this.callClassInstanceMethod(i,a,o,r)}callFunctionDefinition(e,t,r,n){var s,i,a;const o=e.node,{inputLayout:l,returnLayout:c,callArguments:u,inputDefaults:h}=C.FunctionCall.prepareFunctionCall(o,t,n,{nameValueParameters:e=>this.interpreter.getFunctionNameValueParameters(e),splitCallArguments:(e,t)=>this.interpreter.splitFunctionCallNameValueArguments(e,t),expandPositionalArguments:e=>this.expandCommaListArguments(e),inputDefaults:e=>this.interpreter.getFunctionInputArgumentDefaults(e),outputRepeatingName:e=>this.interpreter.getFunctionOutputRepeatingName(e),throwEvalError:e=>this.throwEvalError(e)}),d=f.Scope.create(null!==(s=o.definingScope)&&void 0!==s?s:this.currentScope);d.assignExistingParentNames=Boolean(null===(i=o.attributes)||void 0===i?void 0:i.nested),this.interpreter.configureFunctionWorkspace(o,d),C.FunctionCall.initializeFixedReturnSlots(c.returnNames,d.nameTable);const m=e=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},p=C.FunctionCall.evaluateCallArguments(u.positional,r,m,e=>this.throwEvalError(e),0,!0),y=C.FunctionCall.evaluateNameValueArguments(u.named,r,m,e=>this.throwEvalError(e));C.FunctionCall.bindPositionalInputs(o,l,p,h,(e,t)=>d.defineName(e,t),(e,t)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,d,"default argument")}finally{this.popRequestedOutputCount()}},e=>this.throwEvalError(e)),this.interpreter.bindFunctionNameValueArguments(o,d,y),C.FunctionCall.bindVarargin(l,p,(e,t)=>d.defineName(e,t)),C.FunctionCall.bindVarargout(c,n,(e,t)=>d.defineName(e,t));const x=u.positional.length+t.length-(null!==(a=u.rawPositionalCount)&&void 0!==a?a:u.positional.length);let E;this.pushCallStackFrame(new g.CallFrame(d,e,this.resolveCallSite(r),o.id,x,n,t,void 0,this.requestedOutputMask(n))),this.loadPersistentVariables(o,d);try{this.interpreter.applyScopedImports(o.statements,d),this.interpreter.registerNestedFunctions(o,d),this.interpreter.validateFunctionInputArguments(o,d),this.interpreter.validateFunctionRepeatingArguments(o,d,C.FunctionCall.expressionArgumentValues(p.slice(l.positionalParamCount),"repeating argument",e=>this.throwEvalError(e)));try{o.statements.list.length>0&&this.evaluatedExecutionResult(o.statements,d)}catch(e){if(!(e instanceof b))throw e}const e=this.requestedOutputMask(n);this.interpreter.validateFunctionOutputArguments(o,d,n,e),E=C.FunctionCall.createReturnList(c,d.nameTable,e=>this.throwEvalError(e),e)}finally{this.storePersistentVariables(o,d),this.popCallStackFrame()}return E}instantiateClassDefaults(e){const t=u.ClassInstance.instantiate(e,e=>{this.pushRequestedOutputCount(1);try{return this.runtimeExpressionValue(this.evaluatedExecutionResult(e,this.currentScope),"property default")}finally{this.popRequestedOutputCount()}});return this.interpreter.validateClassInstancePropertyDefaults(t,this.currentScope),t}constructClassInstance(e,t,r){if(e.isEffectivelyAbstract()){const t=[...e.unresolvedAbstractMethods().map(e=>e.name),...e.unresolvedAbstractProperties().map(e=>e.name)];this.throwEvalError(t.length>0?`cannot instantiate abstract class ${e.name}: missing implementations for ${t.join(", ")}.`:`cannot instantiate abstract class ${e.name}.`)}const n=this.instantiateClassDefaults(e);return this.constructClassInstanceWithInstance(e,n,t,r)}constructSuperclassInstance(e,t,r,n){return e.classDefinition.isSubclassOf(t)||this.throwEvalError(`class ${t.name} is not a superclass of class ${e.classDefinition.name}.`),this.constructClassInstanceWithInstance(t,e,r,n)}constructClassInstanceWithInstance(e,t,r,n){var s,i,a;const o=e.findConstructor();if(!o)return r.length>0&&this.throwEvalError(`constructor for class ${e.name} accepts no input arguments.`),t;this.ensureConcreteClassMethod(o);const l=o.node,{inputLayout:c,returnLayout:h,callArguments:d,inputDefaults:m}=C.FunctionCall.prepareFunctionCall(l,r,1,{nameValueParameters:e=>this.interpreter.getFunctionNameValueParameters(e),splitCallArguments:(e,t)=>this.interpreter.splitFunctionCallNameValueArguments(e,t),expandPositionalArguments:e=>this.expandCommaListArguments(e),inputDefaults:e=>this.interpreter.getFunctionInputArgumentDefaults(e),outputRepeatingName:e=>this.interpreter.getFunctionOutputRepeatingName(e),throwEvalError:e=>this.throwEvalError(e)}),p=f.Scope.create(null!==(s=l.definingScope)&&void 0!==s?s:this.currentScope);this.interpreter.configureFunctionWorkspace(l,p),C.FunctionCall.initializeFixedReturnSlots(h.returnNames,p.nameTable);const x=h.returnNames[0];x&&"<~>"!==x.type&&p.defineName(x.id,t);const E=e=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},v=C.FunctionCall.evaluateCallArguments(d.positional,n,E,e=>this.throwEvalError(e),0,!0),A=C.FunctionCall.evaluateNameValueArguments(d.named,n,E,e=>this.throwEvalError(e));C.FunctionCall.bindPositionalInputs(l,c,v,m,(e,t)=>p.defineName(e,t),(e,t)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,p,"default argument")}finally{this.popRequestedOutputCount()}},e=>this.throwEvalError(e)),this.interpreter.bindFunctionNameValueArguments(l,p,A),C.FunctionCall.bindVarargin(c,v,(e,t)=>p.defineName(e,t)),C.FunctionCall.bindVarargout(h,1,(e,t)=>p.defineName(e,t));const S=y.Callables.fromFunctionNode(l),_=d.positional.length+r.length-(null!==(i=d.rawPositionalCount)&&void 0!==i?i:d.positional.length);this.pushCallStackFrame(new g.CallFrame(p,S,this.resolveCallSite(n),l.id,_,1,r)),this.loadPersistentVariables(l,p),this.classAccessStack.push(e);try{this.interpreter.applyScopedImports(l.statements,p),this.interpreter.registerNestedFunctions(l,p),this.interpreter.validateFunctionInputArguments(l,p),this.interpreter.validateFunctionRepeatingArguments(l,p,C.FunctionCall.expressionArgumentValues(v.slice(c.positionalParamCount),"repeating argument",e=>this.throwEvalError(e)));try{l.statements.list.length>0&&this.evaluatedExecutionResult(l.statements,p)}catch(e){if(!(e instanceof b))throw e}this.interpreter.validateFunctionOutputArguments(l,p,1)}finally{this.classAccessStack.pop(),this.storePersistentVariables(l,p),this.popCallStackFrame()}if(!x||"<~>"===x.type)return t;const T=null===(a=p.nameTable[x.id])||void 0===a?void 0:a.node;return u.ClassInstance.isInstanceOf(T)&&(T.classDefinition===e||T.classDefinition.isSubclassOf(e))||this.throwEvalError(`constructor for class ${e.name} must return an object of class ${e.name}.`),T}callClassInstanceMethod(e,t,r,n){t.isAbstract&&this.throwEvalError(`cannot call abstract method '${t.name}' for class ${t.classDefinition.name}.`),this.ensureConcreteClassMethod(t);try{u.ClassInstance.throwIfDeleted(e)}catch(e){this.throwEvalError(e.message)}return this.withClassAccess(t.classDefinition,()=>this.callFunctionDefinition(y.Callables.functionDefinition(t.node),[this.classMethodReceiverArgument(e),...r],n,this.requestedOutputCount))}classMethodReceiverArgument(e){return(0,S.expressionValue)(u.ClassInstance.methodArgument(e),"obj","Argument value",e=>this.throwEvalError(e))}callClassStaticMethod(e,t,r){return e.isAbstract&&this.throwEvalError(`cannot call abstract method '${e.name}' for class ${e.classDefinition.name}.`),this.ensureConcreteClassMethod(e),this.withClassAccess(e.classDefinition,()=>this.callFunctionDefinition(y.Callables.functionDefinition(e.node),t,r,this.requestedOutputCount))}ensureConcreteClassMethod(e){var t,r;if(!(null===(t=e.node.attributes)||void 0===t?void 0:t.prototype))return;const n=null===(r=this.interpreter)||void 0===r?void 0:r.loadClassMethodDefinition(e.classDefinition.name,e.name,this.currentScope);n||this.throwEvalError(`method '${e.name}' for class ${e.classDefinition.name} is declared without a body.`),this.validateLoadedClassMethodSignature(e,n),e.node=n}validateLoadedClassMethodSignature(e,t){t.parameter.list.length===e.node.parameter.list.length&&t.return.list.length===e.node.return.list.length||this.throwEvalError(`method '${e.name}' for class ${e.classDefinition.name} external definition does not match its classdef prototype.`)}callClassEmptyMethod(e,t,r){const n=this.evaluateArgs(t,r,"all"),s=(0===n.length?[i.Complex.zero(),i.Complex.zero()]:1===n.length&&o.MultiArray.isInstanceOf(n[0])?o.MultiArray.linearize(n[0]):n).map(t=>(i.Complex.isInstanceOf(t)&&i.Complex.imagEquals(t,0)&&i.Complex.realIsInteger(t)&&!i.Complex.realLessThan(t,0)||this.throwEvalError(`${e.classDefinition.name}.empty dimensions must be nonnegative integer scalars.`),i.Complex.realToNumber(t)));return 0===s.length&&this.throwEvalError(`${e.classDefinition.name}.empty requires at least one dimension.`),s.some(e=>0===e)||this.throwEvalError(`${e.classDefinition.name}.empty requires at least one zero dimension.`),new o.MultiArray(s)}expressionValues(e,t){return(0,S.expressionValues)(e,t,"Argument value",e=>this.throwEvalError(e))}expressionValue(e,t){return(0,S.expressionValue)(e,t,"Argument value",e=>this.throwEvalError(e))}runtimeExpressionValue(e,t){return(0,S.runtimeExpressionValue)(e,t,"Argument value",e=>this.throwEvalError(e))}evaluatedExecutionResult(e,t=this.currentScope){return n.AST.reduceToFirstIfReturnList(this.rawEvaluationResult(e,t))}rawEvaluationResult(e,t=this.currentScope){return this.interpreter.Evaluator(e,t)}evaluatedExpressionValue(e,t,r){return this.expressionValue(this.evaluatedExecutionResult(e,t),r)}returnExpression(e,t){return(0,S.expressionValue)(e,t,"Return value",e=>this.throwEvalError(e))}returnExpressions(e,t){return(0,S.expressionValues)(e,t,"Return value",e=>this.throwEvalError(e))}scalarArrayReturnExpression(e,t){return this.returnExpression(o.MultiArray.MultiArrayToScalar(e),t)}allVoidArrayResults(e){return o.MultiArray.linearize(e).every(e=>n.AST.isNodeBase(e)&&"VOID"===e.type)}reducedClassMethodResult(e,t,r,s){this.pushRequestedOutputCount(1);try{return n.AST.reduceToFirstIfReturnList(this.callClassInstanceMethod(e,t,r,s))}finally{this.popRequestedOutputCount()}}classInstanceArrayElement(e,t,r,n){const s=e.array[t][r];return u.ClassInstance.isInstanceOf(s)||this.throwUndefinedReferenceError(n),s}callClassBoundMethodArray(e,t,r){const s=o.MultiArray.linearize(e);if(s.length>0&&s.every(e=>h.ClassBoundMethod.isInstanceOf(e)&&"delete"===e.method.name)){for(const e of s)h.ClassBoundMethod.isInstanceOf(e)||this.throwEvalError("internal error: bound method array contains a non-method value."),this.deleteClassInstance(e.instance,r);return n.AST.nodeVoid()}const i=new o.MultiArray(e.dimension);for(let n=0;n<o.MultiArray.linearLength(e);n++){const[s,a]=o.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n),l=e.array[s][a];h.ClassBoundMethod.isInstanceOf(l)||this.throwEvalError("internal error: bound method array contains a non-method value."),i.array[s][a]=this.reducedClassMethodResult(l.instance,l.method,t,r)}if(o.MultiArray.setType(i),this.allVoidArrayResults(i))return n.AST.nodeVoid();if(this.requestedOutputCount>1){const e=o.MultiArray.linearize(i);return this.valueReturnList(e)}return this.scalarArrayReturnExpression(i,"ans")}callClassBoundMethodValue(e,t,r){return h.ClassBoundMethod.isInstanceOf(e)?this.callClassInstanceMethod(e.instance,e.method,t,r):this.callClassBoundMethodArray(e,t,r)}callFunctionalClassMethodArray(e,t,r,s){if(0!==o.MultiArray.linearLength(t)&&o.MultiArray.linearize(t).every(e=>u.ClassInstance.isInstanceOf(e))||this.throwUndefinedReferenceError(e),"delete"===e){for(let r=0;r<o.MultiArray.linearLength(t);r++){const[n,i]=o.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r);this.deleteClassInstance(this.classInstanceArrayElement(t,n,i,e),s)}return n.AST.nodeVoid()}const i=new o.MultiArray(t.dimension);for(let n=0;n<o.MultiArray.linearLength(t);n++){const[a,l]=o.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],n),c=this.classInstanceArrayElement(t,a,l,e),u=c.classDefinition.findMethod(e,e=>!e.isStatic);u||this.throwEvalError(`unknown method '${e}' for class ${c.classDefinition.name}.`),this.canAccessClassMember(u.classDefinition,u.access)||this.throwEvalError(`method '${e}' has ${u.access} access for class ${c.classDefinition.name}.`),i.array[a][l]=this.reducedClassMethodResult(c,u,r,s)}if(o.MultiArray.setType(i),this.allVoidArrayResults(i))return n.AST.nodeVoid();if(this.requestedOutputCount>1){const e=o.MultiArray.linearize(i);return this.valueReturnList(e)}return this.scalarArrayReturnExpression(i,"ans")}deleteClassInstance(e,t){e.classDefinition.isHandleClass()||this.throwEvalError("delete is only supported for handle class instances.");try{u.ClassInstance.throwIfDeleted(e)}catch(e){this.throwEvalError(e.message)}const r=e.classDefinition.findMethod("delete",e=>!e.isStatic);return r&&this.callClassInstanceMethod(e,r,[],t),u.ClassInstance.delete(e),n.AST.nodeVoid()}evaluateFunctionalClassMethodReceiver(e,t){if(0===e.length)return;const r=e[0];if(!this.interpreter)return r;let s;n.AST.isNodeBase(r)&&(r.parent=t,r.index=0),this.pushRequestedOutputCount(1);try{s=this.evaluatedExpressionValue(r,this.currentScope,"method receiver")}finally{this.popRequestedOutputCount()}return s}isFunctionalClassMethodReceiver(e){return u.ClassInstance.isInstanceOf(e)||p.ClassEventListener.isInstanceOf(e)||o.MultiArray.isInstanceOf(e)&&o.MultiArray.linearLength(e)>0&&o.MultiArray.linearize(e).every(e=>u.ClassInstance.isInstanceOf(e)||p.ClassEventListener.isInstanceOf(e))}callFunctionalClassMethod(e,t,r,s=this.evaluateFunctionalClassMethodReceiver(t,r)){if(s||this.throwUndefinedReferenceError(e),"delete"===e&&p.ClassEventListener.isInstanceOf(s))return p.ClassEventListener.delete(s),n.AST.nodeVoid();if("delete"===e&&o.MultiArray.isInstanceOf(s)&&o.MultiArray.linearLength(s)>0&&o.MultiArray.linearize(s).every(p.ClassEventListener.isInstanceOf)){for(const e of o.MultiArray.linearize(s))p.ClassEventListener.isInstanceOf(e)||this.throwEvalError("internal error: event listener array contains a non-listener value."),p.ClassEventListener.delete(e);return n.AST.nodeVoid()}if(o.MultiArray.isInstanceOf(s)&&o.MultiArray.linearLength(s)>0&&o.MultiArray.linearize(s).every(e=>u.ClassInstance.isInstanceOf(e)))return this.callFunctionalClassMethodArray(e,s,t.slice(1),r);if(u.ClassInstance.isInstanceOf(s)||this.throwUndefinedReferenceError(e),"delete"===e)return this.deleteClassInstance(s,r);const i=s.classDefinition.findMethod(e,e=>!e.isStatic);return i||this.throwEvalError(`unknown method '${e}' for class ${s.classDefinition.name}.`),this.canAccessClassMember(i.classDefinition,i.access)||this.throwEvalError(`method '${e}' has ${i.access} access for class ${s.classDefinition.name}.`),this.callClassInstanceMethod(s,i,t.slice(1),r)}callCallable(e,t,r){var n;const s=this.requestedOutputCount;switch(e.type){case"BUILTIN":{const n=e.node,i=this.aliasNameFunction(n.id),a=this.callCallableFunctionalOperatorOverload(n,t,r);if(a)return a;const l=this.evaluateBuiltInArgs(n,t,r);this.validateBuiltInInputArity(n,l.length),this.pushCallStackFrame(new g.CallFrame(this.currentScope,e,this.resolveCallSite(r),n.id,l.length,s,t));try{const e=this.callClassBuiltinMethod(n,l,r);return void 0!==e?e:(this.validateBuiltInInputParameters(n,l),n.mapper&&1!==l.length&&this.throwEvalError(`Invalid call to ${i}.`),"size"===i&&1===l.length&&s>1?this.sizeReturnList(l[0]):n.mapper&&1===l.length&&o.MultiArray.isInstanceOf(l[0])?o.MultiArray.rawMap(l[0],n.func):n.func(...l))}finally{this.popCallStackFrame()}}case"LAMBDA":{const i=e.node,o=i.parameter,{hasVarargin:l,fixedParamCount:c}=C.FunctionCall.lambdaInputLayout(o),u=this.expandCommaListArguments(t);C.FunctionCall.validateLambdaInputArity(u.length,l,c,e=>this.throwEvalError(e));const h=f.Scope.create(null!==(n=i.closure)&&void 0!==n?n:this.currentScope);this.configureAnonymousFunctionWorkspace(i,h),C.FunctionCall.bindLambdaInputs(o,u,r,l,c,(e,t)=>h.defineName(e,t),e=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},e=>this.throwEvalError(e)),this.pushCallStackFrame(new g.CallFrame(h,e,this.resolveCallSite(r),a.FunctionHandle.toString(i),u.length,s,t,void 0,this.requestedOutputMask(s)));try{return this.rawEvaluationResult(i.expression,h)}finally{this.popCallStackFrame()}}case"FCNDEF":return this.callFunctionDefinition(e,t,r,s);case"STATIC_METHOD":return this.callClassStaticMethod(e.node.method,t,r);default:throw new Error("Invalid callable.")}}configureAnonymousFunctionWorkspace(e,t){const r=new Set;for(const t of e.parameter)n.AST.isNodeIdentifier(t)&&r.add(t.id);this.collectAnonymousExpressionNames(e.expression,r),t.allowStaticWorkspaceNames(r)}collectAnonymousExpressionNames(e,t,r=new WeakSet){if(!e||"object"!=typeof e||r.has(e))return;r.add(e),n.AST.isNodeIdentifier(e)&&t.add(e.id);const s=e;for(const[e,n]of Object.entries(s))if("parent"!==e&&"start"!==e&&"stop"!==e)if(Array.isArray(n))for(const e of n)this.collectAnonymousExpressionNames(e,t,r);else this.collectAnonymousExpressionNames(n,t,r)}valueReturnList(e){const t=this.requestedOutputMask(e.length),r=e=>{var r;return null===(r=t[e])||void 0===r||r};return n.AST.nodeCommaSeparatedReturnList(e.length,(e,t)=>{const r=e[`out${t}`];return void 0===r&&n.AST.throwErrorIfGreaterThanReturnList(t,t+1,e=>this.throwEvalError(e)),r},t=>{n.AST.throwErrorIfGreaterThanReturnList(e.length,t,e=>this.throwEvalError(e));const s={length:t};for(let n=0;n<t;n++)r(n)&&(s[`out${n}`]=this.returnExpression(e[n],`out${n+1}`));return s})}callFunctionalOperatorOverload(e,t,r){var n;if("()"===t.delim&&"callable"===e.kind&&y.Callables.isBuiltin(e.callable)&&N.operatorFunctionNames.has(e.callable.node.id))return null===(n=this.interpreter)||void 0===n?void 0:n.callFunctionalOperatorOverload(e.callable.node,r,t)}callCallableFunctionalOperatorOverload(e,t,r){var s;if((!n.AST.isNodeIdentifier(r)||"builtin"!==r.id)&&N.operatorFunctionNames.has(e.id))return null===(s=this.interpreter)||void 0===s?void 0:s.callFunctionalOperatorOverload(e,t,r)}resolveCallDispatch(e,t,r=[]){const s=this.resolveCallable(e);if(!s&&a.FunctionHandle.isInstanceOf(e))throw new Error("Unexpected non-callable FunctionHandle.");if(s)return{kind:"callable",callable:s,expr:e};if(h.ClassBoundMethod.isInstanceOf(e))return{kind:"bound-method",expr:e};if(o.MultiArray.isInstanceOf(e)&&o.MultiArray.linearLength(e)>0&&o.MultiArray.linearize(e).every(e=>h.ClassBoundMethod.isInstanceOf(e)))return{kind:"bound-method-array",expr:e};if(d.ClassStaticMethod.isInstanceOf(e))return{kind:"static-method",expr:e};if(m.ClassEmptyMethod.isInstanceOf(e))return{kind:"empty-method",expr:e};if(c.ClassDefinition.isInstanceOf(e))return{kind:"constructor",expr:e};if(n.AST.isNodeIdentifier(e)&&"()"===t.delim){const n=this.evaluateFunctionalClassMethodReceiver(r,t);return this.isFunctionalClassMethodReceiver(n)?{kind:"functional-class-method",expr:e,functionalName:e.id,functionalReceiver:n}:{kind:"undefined-function",expr:e,functionalName:e.id}}return{kind:"indexing",expr:e}}applyCallDispatch(e,t,r){switch(e.kind){case"callable":return this.callCallable(e.callable,t,r);case"bound-method":return this.callClassInstanceMethod(e.expr.instance,e.expr.method,t,r);case"bound-method-array":return this.callClassBoundMethodArray(e.expr,t,r);case"static-method":return this.callClassStaticMethod(e.expr.method,t,r);case"empty-method":return this.callClassEmptyMethod(e.expr,t,r);case"constructor":return this.constructClassInstance(e.expr,t,r);case"functional-class-method":return this.callFunctionalClassMethod(e.functionalName,t,r,e.functionalReceiver);case"undefined-function":this.throwUndefinedReferenceError(e.functionalName);case"indexing":return}}applyNativeIndexing(e,t,r){const n=()=>{const e=this.evaluateArgs(t,r,"all").map(e=>{var t,n;return null!==(n=null===(t=this.interpreter)||void 0===t?void 0:t.convertIndexArgument(e,r))&&void 0!==n?n:e});return o.MultiArray.indexArguments(e)};if(s.CharString.isInstanceOf(e)){"{}"===r.delim&&this.throwEvalError("matrix cannot be indexed with {");const t=o.MultiArray.characterVectorFromCharString(e),s=n(),i=o.MultiArray.getElements(t,r.expr.id,[],s);return i.parent=r,o.MultiArray.charStringFromCharacterVectorResult(i,e.quote)}"{}"!==r.delim||o.MultiArray.isInstanceOf(e)&&e.isCell||this.throwEvalError("matrix cannot be indexed with {");const i=o.MultiArray.scalarOrCellToMultiArray(e),a=n(),l=o.MultiArray.getElements(i,r.expr.id,[],a);if(l.parent=r,i.isCell&&"()"===r.delim)return o.MultiArray.isInstanceOf(l)||this.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),l.isCell=!0,l;if(i.isCell&&"{}"===r.delim&&(this.requestedOutputCount>1||this.commaListExpansionEnabled)){const e=o.MultiArray.linearize(l);if(e.length>1)return this.valueReturnList(this.returnExpressions(e,"out"))}return o.MultiArray.MultiArrayToScalar(l)}apply(e,t,r){this.interpreter.debug&&console.log("[APPLY]",{exprType:null==e?void 0:e.type,isFunctionHandle:a.FunctionHandle.isInstanceOf(e),exprId:N.debugIdentifier(e),delim:r.delim,argsCount:t.length});const n=this.resolveCallDispatch(e,r,t),s=this.callFunctionalOperatorOverload(n,r,t);if(s)return s;this.interpreter.debug&&console.log("[DISPATCH]",n.kind,"callable"===n.kind?n.callable.type:"");return this.applyCallDispatch(n,t,r)||(this.interpreter.debug&&console.warn("[FALLBACK → INDEX]",{exprType:null==e?void 0:e.type,exprId:N.debugIdentifier(e)}),this.applyNativeIndexing(e,t,r))}defineBuiltInFunction(e,t,r=!1,n=[],s){this.builtInFunctionTable[e]={type:"BUILTIN",id:e,mapper:r,ev:n,func:t,definingScope:this.globalScope,signature:s}}assignBuiltInFunctionTable(e){e&&Object.assign(this.builtInFunctionTable,e)}defineUnaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",id:e,mapper:!1,ev:[],func:(...r)=>{if(1===r.length)return t(r[0]);this.throwEvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:1},outputs:{arity:1}}}}defineBinaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",id:e,mapper:!1,ev:[],func:(r,...n)=>{if(1===n.length)return t(r,n[0]);this.throwEvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:2},outputs:{arity:1}}}}defineLeftAssociativeMultipleOperationFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",id:e,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}this.throwEvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:-2},outputs:{arity:1}}}}pushCallStackFrame(e){const t=this.currentFrame;e.parentFrame=t,this.callStack.push(e)}popCallStackFrame(){return this.callStack.pop()}getStackTrace(){return this.callStack.filter(e=>void 0!==e.func).slice().reverse()}}t.Context=N,N.bareZeroArgumentBuiltins=new Set(["lastwarn","lasterr","lasterror","localfunctions","mfilename"]),N.operatorFunctionNames=new Set(["uplus","uminus","not","transpose","ctranspose","minus","mod","rem","rdivide","mrdivide","ldivide","mldivide","power","mpower","lt","le","ge","gt","eq","ne","plus","times","mtimes","and","or","xor","colon","cat","horzcat","vertcat"]),N.classBuiltinMethodFunctionNames=new Set(["size","numel","length","ndims","rows","columns","isempty","isequal","double","char","logical","cell","cellstr","num2cell","cell2mat","cell2struct","mat2cell","isscalar","ismatrix","isvector","isrow","iscolumn","iscell","iscellstr","isstruct","struct","fieldnames","properties","methods","events","enumeration","superclasses","isfield","isprop","ismethod","numfields","getfield","setfield","rmfield","orderfields","struct2cell","ischar","isstring","issparse","full","sparse","spalloc","nnz","nzmax","nonzeros","isnan","isinf","isfinite","isfloat","isinteger","isnumeric","islogical","isreal","isobject","isvalid","find","ind2sub","sub2ind","sort","all","any","sum","prod","sumsq","cumsum","cumprod","min","max","cummin","cummax","mean","var","std","linspace","logspace","meshgrid","ndgrid","zeros","ones","rand","randi","repmat","reshape","squeeze","flip","fliplr","flipud","rot90","permute","ipermute","circshift","shiftdim","norm"]),N.create=(e,t,r)=>new N(e,t,r)},3717(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CoreFunctions=void 0;const n=r(5956),s=r(845),i=r(7679),a=r(5212),o=r(6816),l=r(9770),c=r(7325),u=r(5577),h=r(7268),d=r(6109),m=r(9170),p=r(8146),f=r(7673),g=r(1604),y=r(227);class x{}t.CoreFunctions=x,x.throwErrorIfCellArray=(e,t)=>{if(i.MultiArray.isInstanceOf(t)&&t.isCell)throw new Error(`${e}: wrong type argument 'cell'`)},x.classInstancesIn=e=>i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).filter(l.ClassInstance.isInstanceOf),x.validateObjectArrayConcatenation=(e,t)=>{let r;for(const n of t.flatMap(e=>x.classInstancesIn(e)))if(r){if(n.classDefinition!==r)throw new Error(`${e}: object arrays must contain objects of the same class.`)}else r=n.classDefinition},x.isemptySignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isempty=(e,...t)=>(d.AST.throwInvalidCallError("isempty",!(void 0!==e&&0===t.length)),g.RuntimeValue.isEmpty(e)?s.Complex.true():s.Complex.false()),x.isscalarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isscalar=(e,...t)=>(d.AST.throwInvalidCallError("isscalar",!(void 0!==e&&0===t.length)),g.RuntimeValue.isScalar(e)?s.Complex.true():s.Complex.false()),x.ismatrixSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.ismatrix=(e,...t)=>(d.AST.throwInvalidCallError("ismatrix",!(void 0!==e&&0===t.length)),g.RuntimeValue.isMatrix(e)?s.Complex.true():s.Complex.false()),x.isvectorSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isvector=(e,...t)=>(d.AST.throwInvalidCallError("isvector",!(void 0!==e&&0===t.length)),g.RuntimeValue.isVector(e)?s.Complex.true():s.Complex.false()),x.iscellSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.iscell=(e,...t)=>(d.AST.throwInvalidCallError("iscell",!(void 0!==e&&0===t.length)),i.MultiArray.isCellArray(e)?s.Complex.true():s.Complex.false()),x.issparseSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.issparse=(e,...t)=>(d.AST.throwInvalidCallError("issparse",!(void 0!==e&&0===t.length)),s.Complex.false()),x.fullSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.full=(e,...t)=>(d.AST.throwInvalidCallError("full",!(void 0!==e&&0===t.length)),g.RuntimeValue.copy(e)),x.isNonzeroElement=e=>s.Complex.isInstanceOf(e)?0!==s.Complex.realToNumber(e)||0!==s.Complex.imagToNumber(e):n.CharString.isInstanceOf(e)?e.str.length>0&&e.str.split("").some(e=>0!==e.charCodeAt(0)):i.MultiArray.isInstanceOf(e)?i.MultiArray.linearize(e).some(x.isNonzeroElement):null!=e,x.nnzSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.nnz=(e,...t)=>(d.AST.throwInvalidCallError("nnz",!(void 0!==e&&0===t.length)),s.Complex.create(i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).filter(x.isNonzeroElement).length)),x.nzmaxSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.nzmax=(e,...t)=>(d.AST.throwInvalidCallError("nzmax",!(void 0!==e&&0===t.length)),x.nnz(e)),x.nonzerosSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.nonzeros=(e,...t)=>(d.AST.throwInvalidCallError("nonzeros",!(void 0!==e&&0===t.length)),i.MultiArray.MultiArrayToScalar(i.MultiArray.toColumnVector(i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).filter(x.isNonzeroElement).map(g.RuntimeValue.copy)))),x.sparseDimension=(e,t,r)=>{const n=i.MultiArray.MultiArrayToScalar(e);if(!s.Complex.isInstanceOf(n)||!s.Complex.imagIsZero(n)||!s.Complex.realIsInteger(n)||s.Complex.realToNumber(n)<0)throw new Error(`${t}: argument ${r} must be a nonnegative integer scalar.`);return s.Complex.realToNumber(n)},x.sparseTripletValues=(e,t,r,n)=>{const s=i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e));if(s.length===t)return s.map(g.RuntimeValue.copy);if(1===s.length)return new Array(t).fill(void 0).map(()=>g.RuntimeValue.copy(s[0]));throw new Error(`${r}: argument ${n} must be scalar or match the sparse triplet count.`)},x.sparseSubscripts=(e,t,r,n)=>x.sparseTripletValues(e,t,r,n).map(e=>{if(!s.Complex.isInstanceOf(e)||!s.Complex.imagIsZero(e)||!s.Complex.realIsInteger(e)||s.Complex.realToNumber(e)<1)throw new Error(`${r}: argument ${n} must contain positive integer subscripts.`);return s.Complex.realToNumber(e)}),x.sparseSignature={inputs:{arity:-6,min:1,max:6,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}},x.sparse=(...e)=>{if(d.AST.throwInvalidCallError("sparse",e.length<1||e.length>6),1===e.length)return g.RuntimeValue.copy(e[0]);if(2===e.length)return new i.MultiArray([x.sparseDimension(e[0],"sparse",1),x.sparseDimension(e[1],"sparse",2)],s.Complex.zero());const t=Math.max(...e.slice(0,3).map(e=>i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).length)),r=x.sparseSubscripts(e[0],t,"sparse",1),a=x.sparseSubscripts(e[1],t,"sparse",2),o=x.sparseTripletValues(e[2],t,"sparse",3),l=e.length>=5?x.sparseDimension(e[3],"sparse",4):r.reduce((e,t)=>Math.max(e,t),0),c=e.length>=5?x.sparseDimension(e[4],"sparse",5):a.reduce((e,t)=>Math.max(e,t),0);if(6===e.length&&n.CharString.isInstanceOf(e[5])&&!["sum","unique"].includes(e[5].str))throw new Error("sparse: option must be 'sum' or 'unique'.");const u=6===e.length&&n.CharString.isInstanceOf(e[5])&&"unique"===e[5].str,h=new i.MultiArray([l,c],s.Complex.zero());for(let e=0;e<t;e++){if(r[e]>l||a[e]>c)throw new Error("sparse: subscript indices out of range.");const t=r[e]-1,n=a[e]-1,i=o[e],d=h.array[t][n];h.array[t][n]=!u&&s.Complex.isInstanceOf(d)&&s.Complex.isInstanceOf(i)?s.Complex.add(d,i):g.RuntimeValue.copy(i)}return i.MultiArray.setType(h),i.MultiArray.MultiArrayToScalar(h)},x.spallocSignature={inputs:[{arity:3,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:4,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"typename",classes:["char","string"],allowedStrings:["double","single","logical"]}]}],outputs:{arity:1}},x.spalloc=(e,t,r,a,...o)=>{d.AST.throwInvalidCallError("spalloc",!(void 0!==e&&void 0!==t&&void 0!==r&&0===o.length));const l=x.sparseDimension(e,"spalloc",1),c=x.sparseDimension(t,"spalloc",2);if(x.sparseDimension(r,"spalloc",3),!(void 0===a||n.CharString.isInstanceOf(a)&&["double","single","logical"].includes(a.str)))throw new Error("spalloc: typename must be 'double', 'single', or 'logical'.");const u=n.CharString.isInstanceOf(a)&&"logical"===a.str?s.Complex.false():s.Complex.zero();return i.MultiArray.MultiArrayToScalar(new i.MultiArray([l,c],u))},x.isrowSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isrow=(e,...t)=>(d.AST.throwInvalidCallError("isrow",!(void 0!==e&&0===t.length)),g.RuntimeValue.isRowVector(e)?s.Complex.true():s.Complex.false()),x.iscolumnSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.iscolumn=(e,...t)=>(d.AST.throwInvalidCallError("iscolumn",!(void 0!==e&&0===t.length)),g.RuntimeValue.isColumnVector(e)?s.Complex.true():s.Complex.false()),x.isstructSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isstruct=(e,...t)=>(d.AST.throwInvalidCallError("isstruct",!(void 0!==e&&0===t.length)),a.Structure.isStructure(e)?s.Complex.true():s.Complex.false()),x.ischarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.ischar=(e,...t)=>{d.AST.throwInvalidCallError("ischar",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e);return r&&m.FunctionValidation.matchesClass(r,"char")?s.Complex.true():s.Complex.false()},x.isstringSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isstring=(e,...t)=>{d.AST.throwInvalidCallError("isstring",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e);return r&&m.FunctionValidation.matchesClass(r,"string")?s.Complex.true():s.Complex.false()},x.iscellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.iscellstr=(e,...t)=>(d.AST.throwInvalidCallError("iscellstr",!(void 0!==e&&0===t.length)),x.cellStringElements(e).accepted?s.Complex.true():s.Complex.false()),x.cellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.cellstr=(e,...t)=>{if(d.AST.throwInvalidCallError("cellstr",!(void 0!==e&&0===t.length)),n.CharString.isInstanceOf(e)){const t=i.MultiArray.toColumnVector([new n.CharString(e.str,"'")]);return t.isCell=!0,t}if(i.MultiArray.isInstanceOf(e)&&e.isCell){if(!x.cellStringElements(e).accepted)throw new EvalError("cellstr: C must be a cell array of character vectors.");return g.RuntimeValue.copy(e)}if(i.MultiArray.isInstanceOf(e)&&!e.isCell){if(0===i.MultiArray.linearLength(e))return i.MultiArray.emptyArray(!0);const t=i.MultiArray.linearize(e);if(t.every(n.CharString.isString)){const t=i.MultiArray.rawMap(e,e=>new n.CharString(e.str,"'"));return t.isCell=!0,t}if(2===e.dimension.length&&t.every(n.CharString.isChar)){const t=i.MultiArray.toColumnVector(e.array.map(e=>new n.CharString(e.map(e=>e.str).join("").trimEnd(),"'")));return t.isCell=!0,t}}throw new EvalError("cellstr: input must be a string, character array, or cell array of character vectors.")},x.charSignature={inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}},x.char=(...e)=>{var t,r,s;d.AST.throwInvalidCallError("char",0===e.length);const a=e.flatMap(e=>x.charRows(e));if(0===a.length)return i.MultiArray.emptyArray();if(1===a.length)return n.CharString.fromCharacterScalars(a[0]);const o=a.reduce((e,t)=>Math.max(e,t.length),0),l=new i.MultiArray([a.length,o]);for(let e=0;e<a.length;e++){const i=null!==(r=null===(t=a[e][0])||void 0===t?void 0:t.quote)&&void 0!==r?r:"'";for(let t=0;t<o;t++)l.array[e][t]=null!==(s=a[e][t])&&void 0!==s?s:n.CharString.create(" ",i)}return i.MultiArray.setType(l),l},x.charElement=(e,t="'")=>{if(n.CharString.isInstanceOf(e))return e;if(s.Complex.isInstanceOf(e)){if(0!==s.Complex.imagToNumber(e))throw new Error("char: numeric character codes must be real.");return n.CharString.fromNumericCode(s.Complex.realToNumber(e),t)}throw new Error("char: invalid conversion input.")},x.charRows=e=>{if(n.CharString.isInstanceOf(e))return[e.toCharacterScalars()];if(s.Complex.isInstanceOf(e))return[[x.charElement(e)]];if(i.MultiArray.isInstanceOf(e)&&!e.isCell&&2===e.dimension.length)return e.array.map(e=>e.map(e=>x.charElement(e)));const t=x.cellStringElements(e);if(t.accepted)return t.values.map(e=>e.toCharacterScalars());throw new Error("char: invalid conversion input.")},x.cellStringElements=e=>{if(!i.MultiArray.isInstanceOf(e)||!e.isCell)return{accepted:!1,values:[]};const t=i.MultiArray.linearize(e);return t.every(n.CharString.isChar)?{accepted:!0,values:t}:{accepted:!1,values:[]}},x.doubleSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.double=(e,...t)=>{if(d.AST.throwInvalidCallError("double",!(void 0!==e&&0===t.length)),n.CharString.isInstanceOf(e))return i.MultiArray.fromCharString(e);if(s.Complex.isInstanceOf(e))return x.doubleElement(e);if(i.MultiArray.isInstanceOf(e)&&!e.isCell){const t=new i.MultiArray(e.dimension);return t.array=e.array.map(e=>e.map(e=>x.doubleElement(e))),t.type=0===i.MultiArray.linearLength(t)?s.Complex.REAL:t.type,i.MultiArray.linearLength(t)>0&&i.MultiArray.setType(t),i.MultiArray.MultiArrayToScalar(t)}throw new Error("double: invalid conversion input.")},x.doubleElement=e=>{if(s.Complex.isInstanceOf(e))return s.Complex.create(s.Complex.realToNumber(e),s.Complex.imagToNumber(e));if(n.CharString.isInstanceOf(e)&&1===e.length)return s.Complex.create(e.str.charCodeAt(0));throw new Error("double: invalid conversion input.")},x.logicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.logical=(e,...t)=>{if(d.AST.throwInvalidCallError("logical",!(void 0!==e&&0===t.length)),n.CharString.isInstanceOf(e))return x.logical(i.MultiArray.fromCharString(e));if(s.Complex.isInstanceOf(e))return x.logicalElement(e);if(i.MultiArray.isInstanceOf(e)&&!e.isCell){const t=new i.MultiArray(e.dimension);return t.array=e.array.map(e=>e.map(e=>x.logicalElement(e))),t.type=s.Complex.LOGICAL,i.MultiArray.linearLength(t)>0&&i.MultiArray.setType(t),i.MultiArray.MultiArrayToScalar(t)}throw new Error("logical: invalid conversion input.")},x.logicalElement=e=>{if(s.Complex.isInstanceOf(e)){if(!s.Complex.imagIsZero(e)||s.Complex.realIsNaN(e))throw new Error("logical: complex and NaN values cannot be converted to logical.");return s.Complex.realIsZero(e)?s.Complex.false():s.Complex.true()}if(n.CharString.isInstanceOf(e)&&1===e.length)return 0===e.str.charCodeAt(0)?s.Complex.false():s.Complex.true();throw new Error("logical: invalid conversion input.")},x.numericClassification=(e,t,r,a)=>{if(d.AST.throwInvalidCallError(e,!(void 0!==t&&0===r.length)),n.CharString.isInstanceOf(t))return x.numericClassification(e,i.MultiArray.fromCharString(t),[],a);if(s.Complex.isInstanceOf(t))return a(t)?s.Complex.true():s.Complex.false();if(i.MultiArray.isInstanceOf(t)&&!t.isCell){const r=new i.MultiArray(t.dimension);return r.array=t.array.map(t=>t.map(t=>a(x.numericClassificationElement(e,t))?s.Complex.true():s.Complex.false())),r.type=s.Complex.LOGICAL,i.MultiArray.MultiArrayToScalar(r)}throw new Error(`${e}: invalid conversion input.`)},x.numericClassificationElement=(e,t)=>{if(s.Complex.isInstanceOf(t))return t;if(n.CharString.isInstanceOf(t)&&1===t.length)return s.Complex.create(t.str.charCodeAt(0));throw new Error(`${e}: invalid conversion input.`)},x.isnanSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isnan=(e,...t)=>x.numericClassification("isnan",e,t,e=>s.Complex.realIsNaN(e)||s.Complex.imagIsNaN(e)),x.isinfSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isinf=(e,...t)=>x.numericClassification("isinf",e,t,e=>!s.Complex.realIsFinite(e)&&!s.Complex.realIsNaN(e)||!s.Complex.imagIsFinite(e)&&!s.Complex.imagIsNaN(e)),x.isfiniteSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isfinite=(e,...t)=>x.numericClassification("isfinite",e,t,e=>s.Complex.realIsFinite(e)&&s.Complex.imagIsFinite(e)),x.isfloatSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isfloat=(e,...t)=>{d.AST.throwInvalidCallError("isfloat",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e);return r&&m.FunctionValidation.numericElements(r)?s.Complex.true():s.Complex.false()},x.isintegerSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isinteger=(e,...t)=>(d.AST.throwInvalidCallError("isinteger",!(void 0!==e&&0===t.length)),s.Complex.false()),x.isnumericSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isnumeric=(e,...t)=>{d.AST.throwInvalidCallError("isnumeric",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e);return r&&m.FunctionValidation.numericElements(r)?s.Complex.true():s.Complex.false()},x.islogicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.islogical=(e,...t)=>{d.AST.throwInvalidCallError("islogical",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e);return r&&m.FunctionValidation.isLogicalValue(r)?s.Complex.true():s.Complex.false()},x.isrealSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isreal=(e,...t)=>{d.AST.throwInvalidCallError("isreal",!(void 0!==e&&0===t.length));const r=(0,p.optionalRuntimeExpressionValue)(e),n=r?m.FunctionValidation.numericElements(r,{includeLogical:!0}):void 0;return n&&n.every(e=>s.Complex.imagIsZero(e))?s.Complex.true():s.Complex.false()},x.isvalidSignature={inputs:{arity:1,parameters:[{name:"handle"}]},outputs:{arity:1}},x.isvalid=(e,...t)=>{d.AST.throwInvalidCallError("isvalid",!(void 0!==e&&0===t.length));const r=e=>{if(u.ClassEventListener.isInstanceOf(e))return u.ClassEventListener.isValid(e)?s.Complex.true():s.Complex.false();if(!l.ClassInstance.isInstanceOf(e)||!e.classDefinition.isHandleClass())throw new EvalError("isvalid: H must be a handle object.");return l.ClassInstance.isValid(e)?s.Complex.true():s.Complex.false()};return i.MultiArray.isInstanceOf(e)?i.MultiArray.MultiArrayToScalar(i.MultiArray.rawMap(e,r)):r(e)},x.isobjectSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.isobject=(e,...t)=>{d.AST.throwInvalidCallError("isobject",!(void 0!==e&&0===t.length));const r=e=>l.ClassInstance.isInstanceOf(e)||c.ClassEnumerationValue.isInstanceOf(e)||h.ClassMetaObject.isInstanceOf(e);if(i.MultiArray.isInstanceOf(e)){const t=i.MultiArray.linearize(e);return!e.isCell&&t.length>0&&t.every(r)?s.Complex.true():s.Complex.false()}return r(e)?s.Complex.true():s.Complex.false()},x.classDefinitionFromValue=(e,t)=>{if(o.ClassDefinition.isInstanceOf(e))return e;if(h.ClassMetaClass.isInstanceOf(e))return e.definition;if(l.ClassInstance.isInstanceOf(e)||c.ClassEnumerationValue.isInstanceOf(e))return e.classDefinition;if(i.MultiArray.isInstanceOf(e)&&!e.isCell){const t=e=>h.ClassMetaClass.isInstanceOf(e)?e.definition:l.ClassInstance.isInstanceOf(e)||c.ClassEnumerationValue.isInstanceOf(e)?e.classDefinition:void 0,r=i.MultiArray.linearize(e).map(t);if(r.length>0&&r.every(e=>void 0!==e)){const e=r[0];if(r.every(t=>t===e))return e}}throw new EvalError(`${t}: input must be a class object.`)},x.stringCellColumn=e=>{const t=i.MultiArray.toColumnVector(e.map(e=>n.CharString.create(e)));return t.isCell=!0,t},x.listedNames=(e,t)=>{const r=new Set;for(const n of e)t(n)&&r.add(n.name);return[...r].sort()},x.propertiesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}},x.properties=(e,...t)=>{d.AST.throwInvalidCallError("properties",!(void 0!==e&&0===t.length));const r=x.classDefinitionFromValue(e,"properties");return x.stringCellColumn(x.listedNames(r.allProperties(),e=>!e.isHidden&&"public"===e.getAccess))},x.fieldnamesSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.fieldnames=(e,...t)=>{if(d.AST.throwInvalidCallError("fieldnames",!(void 0!==e&&0===t.length)),a.Structure.isStructure(e))return x.stringCellColumn(a.Structure.fieldNames(e));const r=x.classDefinitionFromValue(e,"fieldnames");return x.stringCellColumn(x.listedNames(r.allProperties(),e=>!e.isHidden&&"public"===e.getAccess))},x.isfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fieldName"}]},outputs:{arity:1}},x.isfield=(e,t,...r)=>{d.AST.throwInvalidCallError("isfield",!(void 0!==e&&void 0!==t&&0===r.length));const o=a.Structure.isStructure(e),l=t=>{if(!n.CharString.isInstanceOf(t)){if(!o)return s.Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}return a.Structure.hasField(e,t.str)?s.Complex.true():s.Complex.false()};if(i.MultiArray.isInstanceOf(t)){if(!t.isCell){if(!o)return s.Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}const e=i.MultiArray.rawMap(t,l);return i.MultiArray.setType(e),i.MultiArray.MultiArrayToScalar(e)}return l(t)},x.numfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}},x.numfields=(e,...t)=>(d.AST.throwInvalidCallError("numfields",!(void 0!==e&&0===t.length&&a.Structure.isStructure(e))),s.Complex.create(a.Structure.fieldNames(e).length)),x.getfieldSignature={inputs:{arity:-2,min:2,parameters:[{name:"structure"},{name:"field",variadic:!0}]},outputs:{arity:1}},x.getfield=(e,...t)=>(d.AST.throwInvalidCallError("getfield",!(void 0!==e&&t.length>0&&a.Structure.isStructure(e))),a.Structure.getField(e,t.map((e,t)=>x.stringArgument(e,"getfield",t+2)))),x.setfieldSignature={inputs:{arity:-3,min:3,parameters:[{name:"structure"},{name:"fieldOrValue",variadic:!0}]},outputs:{arity:1}},x.setfield=(e,...t)=>{d.AST.throwInvalidCallError("setfield",!(void 0!==e&&t.length>=2&&a.Structure.isStructure(e)));const r=a.Structure.isInstanceOf(e)?a.Structure.copy(e):i.MultiArray.copy(e),n=t.slice(0,-1).map((e,t)=>x.stringArgument(e,"setfield",t+2));return a.Structure.setNewField(r,n,t[t.length-1]),r},x.rmfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fields"}]},outputs:{arity:1}},x.rmfield=(e,t,...r)=>(d.AST.throwInvalidCallError("rmfield",!(void 0!==e&&void 0!==t&&0===r.length&&a.Structure.isStructure(e))),a.Structure.removeFields(x.structureArgument(e,"rmfield"),x.fieldNameArguments(t,"rmfield",2))),x.orderfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}},x.orderfields=(e,...t)=>(d.AST.throwInvalidCallError("orderfields",!(void 0!==e&&0===t.length&&a.Structure.isStructure(e))),a.Structure.orderFields(x.structureArgument(e,"orderfields"))),x.struct2cellSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}},x.struct2cell=(e,...t)=>{d.AST.throwInvalidCallError("struct2cell",!(void 0!==e&&0===t.length&&a.Structure.isStructure(e)));const r=x.structureArgument(e,"struct2cell"),n=a.Structure.fieldNames(r),s=a.Structure.structureElements(r),o=a.Structure.isInstanceOf(r)?[1,1]:r.dimension,l=new i.MultiArray([n.length,...o],void 0,!0);for(let e=0;e<s.length;e++){const t=i.MultiArray.linearIndexToSubscript(o,e);for(let r=0;r<n.length;r++){const[a,o]=i.MultiArray.subscriptToMultiArrayRowColumn(l.dimension,[r+1,...t]);l.array[a][o]=g.RuntimeValue.copy(s[e].field[n[r]])}}return i.MultiArray.setType(l),l.isCell=!0,l},x.cell2structSignature={inputs:{arity:3,parameters:[{name:"cellArray",classes:["cell"]},{name:"fields"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]},outputs:{arity:1}},x.cell2struct=(e,t,r,...n)=>{var o;d.AST.throwInvalidCallError("cell2struct",!(i.MultiArray.isInstanceOf(e)&&e.isCell&&void 0!==t&&void 0!==r&&0===n.length));const l=e,c=x.fieldNameArguments(t,"cell2struct",2),u=s.Complex.realToNumber(i.MultiArray.firstElement(r))-1,h=l.dimension.slice();if(i.MultiArray.appendSingletonTail(h,u+1),c.length!==h[u])throw new EvalError("cell2struct: number of fields does not match dimension.");const m=h.filter((e,t)=>t!==u),p=0===m.length?[1,1]:m,f=new i.MultiArray(p);for(let e=0;e<i.MultiArray.linearLength(f);e++){const t=i.MultiArray.linearIndexToSubscript(p,e),r=new a.Structure({});for(let e=0;e<c.length;e++){const n=[];let s=0;for(let r=0;r<h.length;r++)n[r]=r===u?e+1:null!==(o=t[s++])&&void 0!==o?o:1;const[a,d]=i.MultiArray.subscriptToMultiArrayRowColumn(l.dimension,n.slice(0,l.dimension.length));r.field[c[e]]=g.RuntimeValue.copy(l.array[a][d])}const[n,s]=i.MultiArray.linearIndexToMultiArrayRowColumn(f.dimension[0],f.dimension[1],e);f.array[n][s]=r}return i.MultiArray.setType(f),i.MultiArray.MultiArrayToScalar(f)},x.methodsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}},x.methods=(e,...t)=>{d.AST.throwInvalidCallError("methods",!(void 0!==e&&0===t.length));const r=x.classDefinitionFromValue(e,"methods");return x.stringCellColumn(x.listedNames(r.allMethods(),e=>!e.isHidden&&"public"===e.access))},x.eventsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}},x.events=(e,...t)=>{d.AST.throwInvalidCallError("events",!(void 0!==e&&0===t.length));const r=x.classDefinitionFromValue(e,"events");return x.stringCellColumn(x.listedNames(r.allEvents(),e=>!e.isHidden&&"public"===e.listenAccess))},x.enumerationSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}},x.enumeration=(e,...t)=>{d.AST.throwInvalidCallError("enumeration",!(void 0!==e&&0===t.length));const r=x.classDefinitionFromValue(e,"enumeration");return x.stringCellColumn(x.listedNames(r.allEnumerations(),e=>!e.isHidden))},x.superclassesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}},x.superclasses=(e,...t)=>{d.AST.throwInvalidCallError("superclasses",!(void 0!==e&&0===t.length));const r=x.classDefinitionFromValue(e,"superclasses");return x.stringCellColumn(r.superclasses.slice().sort())},x.stringArgument=(e,t,r)=>{if(!n.CharString.isInstanceOf(e))throw new EvalError(`${t}: argument ${r} must be a string.`);return e.str},x.fieldNameArguments=(e,t,r)=>{if(n.CharString.isInstanceOf(e))return[e.str];if(i.MultiArray.isInstanceOf(e)&&e.isCell)return i.MultiArray.linearize(e).map(e=>x.stringArgument(e,t,r));throw new EvalError(`${t}: argument ${r} must be a string or cell array of strings.`)},x.structureArgument=(e,t)=>{if(a.Structure.isInstanceOf(e)||i.MultiArray.isInstanceOf(e)&&a.Structure.isStructure(e))return e;throw new EvalError(`${t}: argument 1 must be a structure.`)},x.ispropSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"propertyName"}]},outputs:{arity:1}},x.isprop=(e,t,...r)=>{if(d.AST.throwInvalidCallError("isprop",!(void 0!==e&&void 0!==t&&0===r.length)),!n.CharString.isInstanceOf(t))return s.Complex.false();const a=t.str;if(i.MultiArray.isInstanceOf(e)){if(e.isCell)return s.Complex.false();const t=i.MultiArray.rawMap(e,e=>x.classDefinitionFromValue(e,"isprop").findProperty(a)?s.Complex.true():s.Complex.false());return i.MultiArray.setType(t),i.MultiArray.MultiArrayToScalar(t)}return x.classDefinitionFromValue(e,"isprop").findProperty(a)?s.Complex.true():s.Complex.false()},x.ismethodSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"methodName",classes:["char","string"]}]},outputs:{arity:1}},x.ismethod=(e,t,...r)=>{d.AST.throwInvalidCallError("ismethod",!(void 0!==e&&void 0!==t&&0===r.length));const n=x.classDefinitionFromValue(e,"ismethod"),i=x.stringArgument(t,"ismethod",2);return n.findMethod(i,e=>!e.isHidden&&"public"===e.access)?s.Complex.true():s.Complex.false()},x.isequalSignature={inputs:{arity:-1,min:2,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}},x.isequal=(e,...t)=>(d.AST.throwInvalidCallError("isequal",!(void 0!==e&&t.length>=1)),t.every(t=>x.valuesEqual(e,t))?s.Complex.true():s.Complex.false()),x.valuesEqual=(e,t)=>f.RuntimeEquality.valuesEqual(e,t),x.ndimsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.ndims=(e,...t)=>(d.AST.throwInvalidCallError("ndims",!(void 0!==e&&0===t.length)),s.Complex.create(g.RuntimeValue.dimensions(e).length)),x.rowsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.rows=(e,...t)=>(d.AST.throwInvalidCallError("rows",!(void 0!==e&&0===t.length)),s.Complex.create(g.RuntimeValue.dimensions(e)[0])),x.columnsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.columns=(e,...t)=>(d.AST.throwInvalidCallError("columns",!(void 0!==e&&0===t.length)),s.Complex.create(g.RuntimeValue.dimensions(e)[1])),x.lengthSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.Length=(e,...t)=>(d.AST.throwInvalidCallError("length",!(void 0!==e&&0===t.length)),s.Complex.create(Math.max(...g.RuntimeValue.dimensions(e)))),x.numelSignature={inputs:{arity:-2,min:1,parameters:[{name:"value"},{name:"index",variadic:!0}]},outputs:{arity:1}},x.numel=(e,...t)=>{const r=g.RuntimeValue.dimensions(e);if(0===t.length)return s.Complex.create(g.RuntimeValue.elementCount(e));{const e=t.map((e,t)=>i.MultiArray.isInstanceOf(e)?i.MultiArray.linearLength(e):n.CharString.isInstanceOf(e)&&":"===e.str&&t<r.length?r[t]:1);return s.Complex.create(e.reduce((e,t)=>e*t,1))}},x.findSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"direction",classes:["char","string"],allowedStrings:["first","last"]}]}],outputs:{arity:-3}},x.find=(e,...t)=>{d.AST.throwInvalidCallError("find",t.length>2);const r=i.MultiArray.scalarToMultiArray(e);let n=1/0,a="first";t.length>=1&&(n=s.Complex.realToNumber(i.MultiArray.firstElement(t[0]))),2===t.length&&(a=t[1].str);let o=i.MultiArray.linearize(r).map((e,t)=>({index:t,value:e})).filter(({value:e})=>Boolean(s.Complex.realToNumber(e)||s.Complex.imagToNumber(e)));o="last"===a?o.slice(Math.max(0,o.length-n)):o.slice(0,n);const l=o.map(({index:e})=>s.Complex.create(e+1)),c=o.map(({index:e})=>{var t;return s.Complex.create(null!==(t=i.MultiArray.linearIndexToSubscript(r.dimension,e)[0])&&void 0!==t?t:1)}),u=o.map(({index:e})=>{var t;return s.Complex.create(null!==(t=i.MultiArray.linearIndexToSubscript(r.dimension,e)[1])&&void 0!==t?t:1)}),h=o.map(({value:e})=>e),m=e=>i.MultiArray.MultiArrayToScalar(i.MultiArray.toColumnVector(e));return d.AST.nodeBoundedReturnList(3,(e,t)=>{if(1===e.length)return m(l);switch(t){case 0:return m(c);case 1:return m(u);case 2:return m(h);default:throw new EvalError("unreachable find return-list selector branch.")}})},x.sortSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"dimensionOrDirection",alternatives:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}],outputs:{arity:-2}},x.sort=(e,...t)=>{var r;d.AST.throwInvalidCallError("sort",t.length>2);const a=i.MultiArray.scalarToMultiArray(e);let o,l="ascend";t.length>=1&&(n.CharString.isInstanceOf(t[0])?l=t[0].str:o=s.Complex.realToNumber(i.MultiArray.firstElement(t[0]))-1),2===t.length&&(l=t[1].str),o=void 0===o?i.MultiArray.firstNonSingleDimension(a):o;const c=new i.MultiArray(a.dimension),u=new i.MultiArray(a.dimension),h=a.dimension.slice();h[o]=1;const m=h.reduce((e,t)=>e*t,1);for(let e=0;e<m;e++){const t=i.MultiArray.linearIndexToSubscript(h,e),n=Array.from({length:null!==(r=a.dimension[o])&&void 0!==r?r:1},(e,r)=>{const n=t.slice();n[o]=r+1;const s=i.MultiArray.subscriptToLinearIndex(a.dimension,n),[l,c]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],s);return{index:r,value:a.array[l][c]}}).sort((e,t)=>{if(s.Complex.toBoolean(s.Complex.eq(e.value,t.value)))return e.index-t.index;const r="descend"===l?s.Complex.gt(e.value,t.value):s.Complex.lt(e.value,t.value);return s.Complex.toBoolean(r)?-1:1});for(let e=0;e<n.length;e++){const r=t.slice();r[o]=e+1;const l=i.MultiArray.subscriptToLinearIndex(a.dimension,r),[h,d]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],l);c.array[h][d]=n[e].value,u.array[h][d]=s.Complex.create(n[e].index+1)}}return i.MultiArray.setType(c),u.type=s.Complex.REAL,d.AST.nodeBoundedReturnList(2,(e,t)=>0===t||1===e.length?i.MultiArray.MultiArrayToScalar(c):i.MultiArray.MultiArrayToScalar(u))},x.ind2subSignature={inputs:{arity:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"index",classes:["double"],validators:["numeric","real","finite","integer","positive"]}]},outputs:{arity:-1}},x.ind2sub=(e,t)=>(d.AST.throwInvalidCallError("ind2sub",!(void 0!==e&&void 0!==t)),d.AST.nodeReturnList((r,n)=>{if(1===r.length)return t;{let a=i.MultiArray.linearize(e).map(e=>s.Complex.realToNumber(e)),o=!1;r.length>a.length?(i.MultiArray.appendSingletonTail(a,r.length),o=!0):a=a.slice(0,r.length-1);const l=i.MultiArray.scalarToMultiArray(t),c=new i.MultiArray(l.dimension),u=l.array.map(e=>e.map(e=>i.MultiArray.ind2subNumber(a,s.Complex.realToNumber(e))));return n===r.length-1&&o?c.array=u.map(e=>e.map(e=>s.Complex.create(e[r.length]))):c.array=u.map(e=>e.map(e=>s.Complex.create(e[n]))),c.type=s.Complex.REAL,i.MultiArray.MultiArrayToScalar(c)}})),x.sub2indSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"subscript",classes:["double"],validators:["numeric","real","finite","integer","positive"],variadic:!0}]},outputs:{arity:1}},x.sub2ind=(e,...t)=>{d.AST.throwInvalidCallError("sub2ind",t.length<1);const r=i.MultiArray.linearize(e).map(e=>s.Complex.realToNumber(e)),n=t.map(e=>i.MultiArray.scalarToMultiArray(e));for(let e=1;e<n.length;e++)if(!i.MultiArray.arrayEquals(n[0].dimension,n[e].dimension))throw new Error("sub2ind: all subscripts must be of the same size.");i.MultiArray.appendSingletonTail(r,n.length);const a=new i.MultiArray(n[0].dimension);for(let e=0;e<i.MultiArray.linearLength(n[0]);e++){const t=n.map(t=>{const[r,n]=i.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);return t.array[r][n]}),o=i.MultiArray.parseSubscript(r,t,"index "),[l,c]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[l][c]=s.Complex.create(o+1)}return i.MultiArray.MultiArrayToScalar(a)},x.sizeSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:-2,min:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["numeric","positive","integer","real"],variadic:!0}]}],outputs:{arity:-1}},x.size=(e,...t)=>{d.AST.throwInvalidCallError("size",!(void 0!==e));const r=e=>{const t=s.Complex.realToNumber(e);if(t<1||!s.Complex.realIsInteger(e))throw new Error(`size: requested dimension DIM (= ${t}) out of range. DIM must be a positive integer.`);return t},n=g.RuntimeValue.dimensions(e);if(0===t.length){const e=new i.MultiArray([1,n.length]);return e.array[0]=n.map(e=>s.Complex.create(e)),e.type=s.Complex.REAL,e}{const e=1===t.length&&i.MultiArray.isInstanceOf(t[0])?i.MultiArray.linearize(t[0]).map(e=>(s.Complex.isInstanceOf(e)||d.AST.throwInvalidCallError("size"),r(e))):t.map(e=>(e=>{const t=i.MultiArray.firstElement(e);return s.Complex.isInstanceOf(t)||d.AST.throwInvalidCallError("size"),r(t)})(e));i.MultiArray.appendSingletonTail(n,Math.max(...e));const a=new i.MultiArray([1,e.length]);return a.array[0]=e.map(e=>s.Complex.create(n[e-1])),a.type=s.Complex.REAL,i.MultiArray.MultiArrayToScalar(a)}},x.colonSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalar"]},{name:"incrementOrEnd",classes:["double"],validators:["scalar"]},{name:"end",classes:["double"],validators:["scalar"],optional:!0}]},outputs:{arity:1}},x.colon=(...e)=>2===e.length?i.MultiArray.expandRange(i.MultiArray.firstElement(e[0]),i.MultiArray.firstElement(e[1])):3===e.length?i.MultiArray.expandRange(i.MultiArray.firstElement(e[0]),i.MultiArray.firstElement(e[2]),i.MultiArray.firstElement(e[1])):void d.AST.throwInvalidCallError("colon"),x.linspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}},x.linspace=(...e)=>{let t=[],r=[],n=s.Complex.one();const a=()=>{const n="linspace: START, END must be scalars or vectors.";if(i.MultiArray.isInstanceOf(e[0])){if(!i.MultiArray.isVector(e[0]))throw new Error(n);t=i.MultiArray.linearize(e[0])}else t=[e[0]];if(i.MultiArray.isInstanceOf(e[1])){if(!i.MultiArray.isVector(e[1]))throw new Error(n);r=i.MultiArray.linearize(e[1])}else r=[e[1]]};if(2===e.length)a(),n=s.Complex.create(100);else if(3===e.length){if(a(),n=i.MultiArray.MultiArrayToScalar(e[2]),i.MultiArray.isInstanceOf(n))throw new Error("linspace: N must be a scalar.")}else d.AST.throwInvalidCallError("linspace");if(t.length!==r.length)throw new Error("linspace: vectors must be of equal length");s.Complex.realApply(n,s.Complex.applyFunction.floor),s.Complex.realIsNegative(n)&&s.Complex.realSet(n,0),s.Complex.imagSet(n,0);const o=new i.MultiArray([t.length,s.Complex.realToNumber(n)]);for(let e=0;e<t.length;e++){const i=s.Complex.rdiv(s.Complex.sub(r[e],t[e]),s.Complex.sub(n,s.Complex.one()));o.array[e][0]=t[e];for(let r=1;r<s.Complex.realToNumber(n)-1;r++)o.array[e][r]=s.Complex.add(t[e],s.Complex.mul(s.Complex.create(r),i));o.array[e][s.Complex.realToNumber(n)-1]=r[e]}return i.MultiArray.MultiArrayToScalar(o)},x.logspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}},x.logspace=(...e)=>{let t=[],r=[],n=s.Complex.one();const a=()=>{const n="logspace: START, END must be scalars or vectors.";if(i.MultiArray.isInstanceOf(e[0])){if(!i.MultiArray.isVector(e[0]))throw new Error(n);t=i.MultiArray.linearize(e[0])}else t=[e[0]];if(i.MultiArray.isInstanceOf(e[1])){if(!i.MultiArray.isVector(e[1]))throw new Error(n);r=i.MultiArray.linearize(e[1])}else r=[e[1]]};if(2===e.length)a(),n=s.Complex.create(50);else if(3===e.length){if(a(),n=i.MultiArray.MultiArrayToScalar(e[2]),i.MultiArray.isInstanceOf(n))throw new Error("logspace: N must be a scalar.")}else d.AST.throwInvalidCallError("logspace");if(t.length!==r.length)throw new Error("logspace: vectors must be of equal length");s.Complex.realApply(n,s.Complex.applyFunction.floor),s.Complex.realIsNegative(n)&&s.Complex.realSet(n,0),s.Complex.imagSet(n,0);const o=new i.MultiArray([t.length,s.Complex.realToNumber(n)]);for(let e=0;e<t.length;e++){s.Complex.realToNumber(s.Complex.eq(r[e],s.Complex.pi()))&&(r[e]=s.Complex.log10(s.Complex.pi()));const i=s.Complex.rdiv(s.Complex.sub(r[e],t[e]),s.Complex.sub(n,s.Complex.one()));o.array[e][0]=s.Complex.power(s.Complex.create(10),t[e]);for(let r=1;r<s.Complex.realToNumber(n)-1;r++)o.array[e][r]=s.Complex.power(s.Complex.create(10),s.Complex.add(t[e],s.Complex.mul(s.Complex.create(r),i)));o.array[e][s.Complex.realToNumber(n)-1]=s.Complex.power(s.Complex.create(10),r[e])}return i.MultiArray.MultiArrayToScalar(o)},x.meshgridSignature={inputs:{arity:-3,min:1,max:3,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-3}},x.meshgrid=(...e)=>{d.AST.throwInvalidCallError("meshgrid",e.length>3||e.length<1);const t=[];for(let r=0;r<3&&e.length>r;r++)if(i.MultiArray.isInstanceOf(e[r])){if(!i.MultiArray.isVector(e[r]))throw new Error("meshgrid: arguments must be vectors.");t[r]=i.MultiArray.firstVector(e[r])}else t[r]=[e[r]];return d.AST.nodeBoundedReturnList(3,(e,r)=>{const n=t;for(;n.length<e.length;)n[n.length]=n[n.length-1];const s=e.length>2?new i.MultiArray([n[1].length,n[0].length,n[2].length]):new i.MultiArray([n[1].length,n[0].length]);switch(r){case 0:for(let e=0;e<s.array.length;e++)s.array[e]=n[0];break;case 1:for(let e=0;e<s.array.length;e+=s.dimension[0])for(let t=0;t<s.dimension[0];t++)s.array[e+t]=new Array(s.dimension[1]).fill(n[1][t]);break;case 2:for(let e=0,t=0;e<s.array.length;e+=s.dimension[0],t++)for(let r=0;r<s.dimension[0];r++)s.array[e+r]=new Array(s.dimension[1]).fill(n[2][t])}return i.MultiArray.MultiArrayToScalar(s)})},x.ndgridSignature={inputs:{arity:-1,min:1,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-1}},x.ndgrid=(...e)=>{const t=[];for(let r=0;r<e.length;r++)if(i.MultiArray.isInstanceOf(e[r])){if(!i.MultiArray.isVector(e[r]))throw new Error("ndgrid: arguments must be vectors.");t[r]=e[r]}else t[r]=i.MultiArray.scalarToMultiArray(e[r]);return d.AST.nodeReturnList((e,r)=>{const n=t;if(1===n.length)for(;n.length<e.length;)n[n.length]=n[n.length-1];e.length>n.length&&d.AST.throwErrorIfGreaterThanReturnList(n.length,e.length);const s=n.map(e=>e.dimension[0]*e.dimension[1]),a=new Array(n.length).fill(1);return a[r]=s[r],s[r]=1,i.MultiArray.evaluate(new i.MultiArray(s,i.MultiArray.reshape(n[r],a)))})},x.repmatSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension"],variadic:!0}]}],outputs:{arity:1}},x.repmat=(e,...t)=>{let r;if(1===t.length)r=i.MultiArray.firstVector(t[0]);else{const e=new Array(t.length);if(r=t.map((t,r)=>{const n=i.MultiArray.MultiArrayToScalar(t);return e[r]=i.MultiArray.isInstanceOf(n)?1:0,n}),e.reduce((e,t)=>e+t,0))throw new Error("repmat: all input arguments must be scalar.")}const n=r.map(e=>s.Complex.realToNumber(e));return i.MultiArray.isInstanceOf(e)&&e.isCell?x.repmatCellArray(e,n):i.MultiArray.evaluate(new i.MultiArray(n,e))},x.repmatCellArray=(e,t)=>{const r=Math.max(e.dimension.length,t.length,2),n=e.dimension.slice(),s=t.slice();i.MultiArray.appendSingletonTail(n,r),i.MultiArray.appendSingletonTail(s,r);const a=n.map((e,t)=>e*s[t]),o=new i.MultiArray(a,void 0,!0);for(let t=0;t<i.MultiArray.linearLength(o);t++){const r=i.MultiArray.linearIndexToSubscript(o.dimension,t).map((e,t)=>(e-1)%n[t]+1),s=i.MultiArray.subscriptToLinearIndex(n,r),[a,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],s),[c,u]=i.MultiArray.linearIndexToMultiArrayRowColumn(o.dimension[0],o.dimension[1],t);o.array[c][u]=g.RuntimeValue.copy(e.array[a][l])}return o.isCell=!0,o},x.reshapeSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["reshapeDimension"],alternatives:[{name:"dimensions",validators:["reshapeDimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["reshapeDimension"],variadic:!0}]}],outputs:{arity:1}},x.reshape=(e,...t)=>{if(t.length<1)throw new Error("invalid call to reshape");const r=i.MultiArray.scalarOrCellToMultiArray(e);let n=-1;1===t.length&&i.MultiArray.isInstanceOf(t[0])&&(t=i.MultiArray.linearize(t[0]));const a=t.map((e,t)=>{if(i.MultiArray.isEmpty(e)){if(n<0)return n=t,1;throw new Error("reshape: only a single dimension can be unknown.")}return s.Complex.realToNumber(i.MultiArray.firstElement(e))});return i.MultiArray.reshape(r,a,n)},x.squeezeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},x.squeeze=(...e)=>{if(d.AST.throwInvalidCallError("squeeze",1!==e.length),!i.MultiArray.isInstanceOf(e[0]))return e[0];const t=e[0];if(t.dimension.length<=2)return t;const r=t.dimension.filter(e=>1!==e);for(;r.length<2;)r.push(1);return i.MultiArray.reshape(t,r)},x.flipSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}},x.flip=(e,t,...r)=>{d.AST.throwInvalidCallError("flip",!(void 0!==e&&0===r.length));const s=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e),a=void 0===t?i.MultiArray.firstNonSingleDimension(s)+1:x.positiveIntegerScalar(t,"flip","DIM");return x.flipArray(s,a)},x.fliplrSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}},x.fliplr=(e,...t)=>{d.AST.throwInvalidCallError("fliplr",!(void 0!==e&&0===t.length));const r=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e);return x.flipArray(r,2)},x.flipudSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}},x.flipud=(e,...t)=>{d.AST.throwInvalidCallError("flipud",!(void 0!==e&&0===t.length));const r=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e);return x.flipArray(r,1)},x.flipArray=(e,t)=>{const r=Math.max(e.dimension.length,t,2),n=e.dimension.slice();i.MultiArray.appendSingletonTail(n,r);const s=new i.MultiArray(n,void 0,e.isCell);for(let r=0;r<i.MultiArray.linearLength(e);r++){const a=i.MultiArray.linearIndexToSubscript(n,r),o=a.slice();o[t-1]=n[t-1]-a[t-1]+1;const[l,c]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r),[u,h]=i.MultiArray.subscriptToMultiArrayRowColumn(s.dimension,o);s.array[u][h]=g.RuntimeValue.copy(e.array[l][c])}return s.isCell=e.isCell,s.type=e.type,i.MultiArray.removeSingletonTail(s.dimension),i.MultiArray.MultiArrayToScalar(s)},x.rot90Signature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"k",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:1}},x.rot90=(e,t,...r)=>{d.AST.throwInvalidCallError("rot90",!(void 0!==e&&0===r.length));const s=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e),a=((void 0===t?1:x.integerScalar(t,"rot90","K"))%4+4)%4;if(0===a)return s;const o=s.dimension.slice();i.MultiArray.appendSingletonTail(o,2);const l=o.slice();a%2==1&&([l[0],l[1]]=[l[1],l[0]]);const c=new i.MultiArray(l,void 0,s.isCell);for(let e=0;e<i.MultiArray.linearLength(s);e++){const t=i.MultiArray.linearIndexToSubscript(o,e),r=t.slice();1===a?(r[0]=o[1]-t[1]+1,r[1]=t[0]):2===a?(r[0]=o[0]-t[0]+1,r[1]=o[1]-t[1]+1):(r[0]=t[1],r[1]=o[0]-t[0]+1);const[n,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],e),[u,h]=i.MultiArray.subscriptToMultiArrayRowColumn(c.dimension,r);c.array[u][h]=g.RuntimeValue.copy(s.array[n][l])}return c.isCell=s.isCell,c.type=s.type,i.MultiArray.removeSingletonTail(c.dimension),i.MultiArray.MultiArrayToScalar(c)},x.permuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}},x.permute=(e,t,...r)=>(d.AST.throwInvalidCallError("permute",!(void 0!==e&&void 0!==t&&0===r.length)),x.permuteArray(e,t,!1,"permute")),x.ipermuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}},x.ipermute=(e,t,...r)=>(d.AST.throwInvalidCallError("ipermute",!(void 0!==e&&void 0!==t&&0===r.length)),x.permuteArray(e,t,!0,"ipermute")),x.permuteArray=(e,t,r,s)=>{const a=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e),o=x.permutationOrder(t,a.dimension.length,s),l=r?x.inversePermutation(o):o,c=Math.max(a.dimension.length,l.length,2),u=a.dimension.slice();i.MultiArray.appendSingletonTail(u,c);const h=l.map(e=>u[e-1]);i.MultiArray.appendSingletonTail(h,c);const d=new i.MultiArray(h,void 0,a.isCell);for(let e=0;e<i.MultiArray.linearLength(d);e++){const t=i.MultiArray.linearIndexToSubscript(d.dimension,e),r=new Array(c).fill(1);l.forEach((e,n)=>{r[e-1]=t[n]});const n=i.MultiArray.subscriptToLinearIndex(u,r),[s,o]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],n),[h,m]=i.MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],e);d.array[h][m]=g.RuntimeValue.copy(a.array[s][o])}return d.isCell=a.isCell,d.type=a.type,i.MultiArray.removeSingletonTail(d.dimension),i.MultiArray.MultiArrayToScalar(d)},x.permutationOrder=(e,t,r)=>{const n=i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).map(e=>{if(!s.Complex.isInstanceOf(e))throw new EvalError(`${r}: ORDER must be a permutation vector.`);const t=s.Complex.realToNumber(e);if(!Number.isInteger(t)||t<1||0!==s.Complex.imagToNumber(e))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return t}),a=Math.max(t,n.length,2),o=n.slice().sort((e,t)=>e-t);if(n.length!==a||o.some((e,t)=>e!==t+1))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return n},x.inversePermutation=e=>{const t=new Array(e.length);return e.forEach((e,r)=>{t[e-1]=r+1}),t},x.circshiftSignature={inputs:[{arity:2,parameters:[{name:"array"},{name:"shifts",classes:["double"]}]},{arity:3,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}},x.circshift=(e,t,r,...s)=>{d.AST.throwInvalidCallError("circshift",!(void 0!==e&&void 0!==t&&0===s.length));const a=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarOrCellToMultiArray(e),o=x.integerVector(t,"circshift","SHIFTS");if(void 0!==r){const e=x.positiveIntegerScalar(r,"circshift","DIM");if(1!==o.length)throw new EvalError("circshift: SHIFT must be a scalar when DIM is specified.");return x.circularShiftArray(a,[o[0]],e)}if(1===o.length)return x.circularShiftArray(a,o,i.MultiArray.firstNonSingleDimension(a)+1);if(o.length>a.dimension.length)throw new EvalError("circshift: SHIFTS vector must not be longer than ndims(A).");return x.circularShiftArray(a,o)},x.circularShiftArray=(e,t,r)=>{const n=Math.max(e.dimension.length,null!=r?r:0,t.length,2),s=e.dimension.slice();i.MultiArray.appendSingletonTail(s,n);const a=new Array(n).fill(0);"number"==typeof r?a[r-1]=t[0]:t.forEach((e,t)=>{a[t]=e});const o=new i.MultiArray(s,void 0,e.isCell);for(let t=0;t<i.MultiArray.linearLength(e);t++){const r=i.MultiArray.linearIndexToSubscript(s,t).map((e,t)=>{const r=s[t];return((e-1+a[t])%r+r)%r+1}),[n,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t),[c,u]=i.MultiArray.subscriptToMultiArrayRowColumn(o.dimension,r);o.array[c][u]=g.RuntimeValue.copy(e.array[n][l])}return o.isCell=e.isCell,o.type=e.type,i.MultiArray.removeSingletonTail(o.dimension),i.MultiArray.MultiArrayToScalar(o)},x.shiftdimSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:-2}},x.shiftdim=(e,t,...r)=>{d.AST.throwInvalidCallError("shiftdim",!(void 0!==e&&0===r.length));const n=i.MultiArray.scalarOrCellToMultiArray(e);if(void 0===t){const e=x.leadingSingletonDimensions(n.dimension),t=x.shiftDimensions(n,e);return d.AST.nodeBoundedReturnList(2,(r,n)=>0===n?t:s.Complex.create(e))}const a=x.integerScalar(t,"shiftdim","N");return x.shiftDimensions(n,a)},x.leadingSingletonDimensions=e=>{let t=0;for(;t<e.length-2&&1===e[t];)t++;return t},x.shiftDimensions=(e,t)=>{if(0===t)return e;const r=e.dimension.slice(),n=0===r.length?0:t%r.length,s=t>0?r.slice(n).concat(r.slice(0,n)):new Array(-t).fill(1).concat(r);for(;s.length<2;)s.push(1);return i.MultiArray.reshape(e,s)},x.integerVector=(e,t,r)=>i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).map(e=>{if(!s.Complex.isInstanceOf(e))throw new EvalError(`${t}: ${r} must contain integer values.`);const n=s.Complex.realToNumber(e);if(!Number.isInteger(n)||0!==s.Complex.imagToNumber(e)||!Number.isFinite(n))throw new EvalError(`${t}: ${r} must contain integer values.`);return n}),x.integerScalar=(e,t,r)=>{const n=i.MultiArray.MultiArrayToScalar(e);if(!s.Complex.isInstanceOf(n))throw new EvalError(`${t}: ${r} must be an integer scalar.`);const a=s.Complex.realToNumber(n);if(!Number.isInteger(a)||0!==s.Complex.imagToNumber(n)||!Number.isFinite(a))throw new EvalError(`${t}: ${r} must be an integer scalar.`);return a},x.positiveIntegerScalar=(e,t,r)=>{const n=x.integerScalar(e,t,r);if(n<1)throw new EvalError(`${t}: ${r} must be a positive integer scalar.`);return n},x.newFilled=(e,t,...r)=>{let n;if(0===r.length)return e;if(1===r.length){const e=i.MultiArray.scalarToMultiArray(r[0]);if(!i.MultiArray.isVector(e))throw new Error(`${t} (A): use ${t} (size (A)) instead.`);n=i.MultiArray.linearize(e).map(e=>s.Complex.realToNumber(e)),1===n.length&&(n[n.length]=n[0])}else n=r.map(e=>{if(i.MultiArray.isInstanceOf(e))throw new Error(`${t}: dimensions must be scalars.`);return s.Complex.realToNumber(e)});return i.MultiArray.MultiArrayToScalar(new i.MultiArray(n,e))},x.newFilledEach=(e,...t)=>{let r;if(1===t.length)r=i.MultiArray.linearize(t[0]).map(e=>s.Complex.realToNumber(e));else{if(0===t.length)return e(0);r=t.map(e=>s.Complex.realToNumber(i.MultiArray.firstElement(e)))}1===r.length&&(r[r.length]=r[0]);const n=new i.MultiArray(r);for(let t=0;t<i.MultiArray.linearLength(n);t++){const[r,s]=i.MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[r][s]=e(t)}return i.MultiArray.setType(n),i.MultiArray.MultiArrayToScalar(n)},x.zerosSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}},x.zeros=(...e)=>x.newFilled(s.Complex.zero(),"zeros",...e),x.onesSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}},x.ones=(...e)=>x.newFilled(s.Complex.one(),"ones",...e),x.cellSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}},x.cell=(...e)=>{let t;if(0===e.length)return i.MultiArray.emptyArray(!0);if(1===e.length){const r=i.MultiArray.scalarToMultiArray(e[0]);if(!i.MultiArray.isVector(r))throw new Error("cell (A): use cell (size (A)) instead.");t=i.MultiArray.linearize(r).map(e=>s.Complex.realToNumber(e)),1===t.length&&(t[t.length]=t[0])}else t=e.map(e=>{if(i.MultiArray.isInstanceOf(e))throw new Error("cell: dimensions must be scalars.");return s.Complex.realToNumber(e)});return new i.MultiArray(t,()=>i.MultiArray.emptyArray(),!0)},x.num2cellSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["numeric","vector","real","finite","integer","positive"],alternatives:[{name:"dimension",validators:["numeric","scalar","real","finite","integer","positive"]}]}]}],outputs:{arity:1}},x.num2cell=(e,t,...r)=>{d.AST.throwInvalidCallError("num2cell",!(void 0!==e&&0===r.length));const a=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.isInstanceOf(e)?e:i.MultiArray.scalarToMultiArray(e);if(void 0===t){const e=new i.MultiArray(a.dimension,void 0,!0);for(let t=0;t<i.MultiArray.linearLength(a);t++){const[r,n]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);e.array[r][n]=g.RuntimeValue.copy(a.array[r][n])}return e.isCell=!0,e}const o=[...new Set(i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(t)).map(e=>s.Complex.realToNumber(e)-1))].sort((e,t)=>e-t);if(o.some(e=>e>=a.dimension.length))throw new EvalError("num2cell: DIM must be between 1 and ndims(A).");const l=a.dimension.slice();i.MultiArray.appendSingletonTail(l,Math.max(...o)+1);const c=l.map((e,t)=>o.includes(t)?1:e),u=l.map((e,t)=>o.includes(t)?e:1),h=new i.MultiArray(c,void 0,!0);for(let e=0;e<i.MultiArray.linearLength(h);e++){const t=i.MultiArray.linearIndexToSubscript(c,e),r=new i.MultiArray(u,void 0,a.isCell);for(let e=0;e<i.MultiArray.linearLength(r);e++){const n=i.MultiArray.linearIndexToSubscript(u,e),s=l.map((e,r)=>o.includes(r)?n[r]:t[r]),c=i.MultiArray.subscriptToLinearIndex(l,s),[h,d]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],c),[m,p]=i.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],e);r.array[m][p]=g.RuntimeValue.copy(a.array[h][d])}i.MultiArray.setType(r);const[n,s]=i.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],e);h.array[n][s]=a.isCell?r:i.MultiArray.MultiArrayToScalar(r)}return h.isCell=!0,h},x.cell2matSignature={inputs:{arity:1,parameters:[{name:"cellArray",classes:["cell"]}]},outputs:{arity:1}},x.cell2mat=(e,...t)=>{d.AST.throwInvalidCallError("cell2mat",!(i.MultiArray.isInstanceOf(e)&&e.isCell&&0===t.length));const r=e;return i.MultiArray.isEmpty(r)?i.MultiArray.emptyArray():i.MultiArray.MultiArrayToScalar(x.cell2matCompose(r))},x.cell2matBlock=e=>{if(i.MultiArray.isInstanceOf(e)&&e.isCell)throw new EvalError("cell2mat: nested cell contents are not supported.");return n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarToMultiArray(e)},x.cell2matCompose=e=>{const t=[],r=Math.max(e.dimension.length,2),n=e.dimension.slice();i.MultiArray.appendSingletonTail(n,r);const s=n.map(e=>new Array(e));for(let a=0;a<i.MultiArray.linearLength(e);a++){const[o,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],a),c=x.cell2matBlock(e.array[o][l]);t[a]=c;const u=c.dimension.slice();i.MultiArray.appendSingletonTail(u,r);const h=i.MultiArray.linearIndexToSubscript(n,a);for(let e=0;e<r;e++){const t=h[e]-1,r=s[e][t];if(void 0===r)s[e][t]=u[e];else if(r!==u[e])throw new EvalError("cell2mat: dimension mismatch")}}const a=s.map(e=>{let t=0;return e.forEach(e=>{t+=null!=e?e:0}),t}),o=s.map(e=>{let t=0;return e.map(e=>{const r=t;return t+=null!=e?e:0,r})}),l=new i.MultiArray(a);for(let e=0;e<t.length;e++){const s=t[e],a=s.dimension.slice();i.MultiArray.appendSingletonTail(a,r);const c=i.MultiArray.linearIndexToSubscript(n,e);for(let e=0;e<i.MultiArray.linearLength(s);e++){const t=i.MultiArray.linearIndexToSubscript(a,e).map((e,t)=>o[t][c[t]-1]+e),[r,n]=i.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],e),[u,h]=i.MultiArray.subscriptToMultiArrayRowColumn(l.dimension,t);l.array[u][h]=g.RuntimeValue.copy(s.array[r][n])}}return i.MultiArray.setType(l),l},x.mat2cellSignature={inputs:{arity:-2,min:2,parameters:[{name:"array"},{name:"dimensionSizes",classes:["double"],variadic:!0}]},outputs:{arity:1}},x.mat2cell=(e,...t)=>{d.AST.throwInvalidCallError("mat2cell",!(void 0!==e&&t.length>0));const r=n.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):i.MultiArray.scalarToMultiArray(e);if(r.isCell)throw new EvalError("mat2cell: input must not be a cell array.");if(t.length!==r.dimension.length)throw new EvalError("mat2cell: number of dimension vectors must match ndims(A).");const s=t.map((e,t)=>x.mat2cellPartition(e,r.dimension[t],t+2)),a=new i.MultiArray(s.map(e=>e.length),void 0,!0),o=s.map(e=>{let t=0;return e.map(e=>{const r=t;return t+=e,r})});for(let e=0;e<i.MultiArray.linearLength(a);e++){const t=i.MultiArray.linearIndexToSubscript(a.dimension,e),n=t.map((e,t)=>s[t][e-1]),l=new i.MultiArray(n);for(let e=0;e<i.MultiArray.linearLength(l);e++){const n=i.MultiArray.linearIndexToSubscript(l.dimension,e).map((e,r)=>o[r][t[r]-1]+e),s=i.MultiArray.subscriptToLinearIndex(r.dimension,n),[a,c]=i.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],s),[u,h]=i.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],e);l.array[u][h]=g.RuntimeValue.copy(r.array[a][c])}i.MultiArray.setType(l);const[c,u]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[c][u]=i.MultiArray.MultiArrayToScalar(l)}return a.isCell=!0,a},x.mat2cellPartition=(e,t,r)=>{const n=i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(e)).map(e=>{if(!s.Complex.isInstanceOf(e))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);const t=s.Complex.realToNumber(e);if(!Number.isInteger(t)||t<0||0!==s.Complex.imagToNumber(e))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);return t});if(n.reduce((e,t)=>e+t,0)!==t)throw new EvalError(`mat2cell: argument ${r} dimensions do not sum to input size.`);return n},x.randSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}},x.rand=(...e)=>x.newFilledEach(()=>s.Complex.random(),...e),x.randiSignature={inputs:[{arity:1,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]}]},{arity:2,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-3,min:3,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}},x.randi=(e,...t)=>{let r,n;if(i.MultiArray.isInstanceOf(e)){const t=i.MultiArray.linearize(e);if(2===t.length)r=t[0],n=t[1];else{if(!(t.length>0))throw new Error("bounds(1): out of bound 0 (dimensions are 0x0)");r=s.Complex.zero(),n=t[0]}}else r=s.Complex.zero(),n=e;if(!s.Complex.realIsInteger(r)||!s.Complex.realIsInteger(n))throw new Error("randi: must be integer bounds.");if(s.Complex.gt(n,r))return x.newFilledEach(s.Complex.realEquals(r,0)?()=>s.Complex.round(s.Complex.mul(n,s.Complex.random())):()=>s.Complex.round(s.Complex.add(s.Complex.mul(s.Complex.sub(n,r),s.Complex.random()),r)),...t);throw s.Complex.realEquals(r,0)?new Error("randi: require imax >= 1."):new Error("randi: require imax > imin.")},x.catSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"array",variadic:!0}]},outputs:{arity:1}},x.cat=(e,...t)=>(x.validateObjectArrayConcatenation("cat",t),i.MultiArray.concatenate(s.Complex.realToNumber(i.MultiArray.firstElement(e))-1,"cat",...t.map(e=>i.MultiArray.scalarToMultiArray(e)))),x.horzcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}},x.horzcat=(...e)=>0===e.length?i.MultiArray.emptyArray():(x.validateObjectArrayConcatenation("horzcat",e),i.MultiArray.concatenate(1,"horzcat",...e.map(e=>i.MultiArray.scalarToMultiArray(e)))),x.vertcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}},x.vertcat=(...e)=>0===e.length?i.MultiArray.emptyArray():(x.validateObjectArrayConcatenation("vertcat",e),i.MultiArray.concatenate(0,"vertcat",...e.map(e=>i.MultiArray.scalarToMultiArray(e)))),x.allSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.all=i.MultiArray.reduceFactory((e,t)=>s.Complex.and(e,t),"reduce",s.Complex.one()),x.anySignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.any=i.MultiArray.reduceFactory((e,t)=>s.Complex.or(e,t),"reduce",s.Complex.zero()),x.sumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.sum=i.MultiArray.reduceFactory((e,t)=>s.Complex.add(e,t),"reduce",s.Complex.zero()),x.prodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.prod=i.MultiArray.reduceFactory((e,t)=>s.Complex.mul(e,t),"reduce",s.Complex.one()),x.sumsqSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.sumsq=i.MultiArray.reduceFactory((e,t)=>s.Complex.add(e,s.Complex.mul(t,t)),"reduce",s.Complex.zero()),x.cumsumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.cumsum=i.MultiArray.reduceFactory((e,t)=>s.Complex.add(e,t),"cumulative"),x.cumprodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.cumprod=i.MultiArray.reduceFactory((e,t)=>s.Complex.mul(e,t),"cumulative"),x.minSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}},x.min=i.MultiArray.reduceFactory("lt","comparison"),x.maxSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}},x.max=i.MultiArray.reduceFactory("gt","comparison"),x.cumminSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}},x.cummin=i.MultiArray.reduceFactory("lt","cumcomparison"),x.cummaxSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}},x.cummax=i.MultiArray.reduceFactory("gt","cumcomparison"),x.meanSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},x.mean=(e,t)=>{const r=i.MultiArray.scalarToMultiArray(e),n=void 0!==t?s.Complex.realToNumber(i.MultiArray.firstElement(t))-1:i.MultiArray.firstNonSingleDimension(r),a=x.sum(r,s.Complex.create(n+1)),o=s.Complex.create(r.dimension[n]);return i.MultiArray.divideElementByScalar(a,o)},x.varianceSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}},x.variance=(e,t,r)=>{var n;const a=i.MultiArray.scalarToMultiArray(e);let o,l=0;if(void 0!==t){const e=i.MultiArray.firstElement(t);if(void 0===r&&s.Complex.realIsInteger(e)&&s.Complex.realToNumber(e)>1)o=s.Complex.realToNumber(e)-1;else if(void 0!==r){l=1===s.Complex.realToNumber(e)?1:0;const t=i.MultiArray.firstElement(r);o=i.MultiArray.testInteger(t,"var","DIM",[1,1/0])-1}else l=1===s.Complex.realToNumber(e)?1:0,o=i.MultiArray.firstNonSingleDimension(a)}else if(void 0!==r){const e=i.MultiArray.firstElement(r);o=i.MultiArray.testInteger(e,"var","DIM",[1,1/0])-1}else o=i.MultiArray.firstNonSingleDimension(a);const c=a.dimension[o];if(c<=1)return s.Complex.zero();const u=i.MultiArray.reduce(o,a,(e,t)=>s.Complex.add(e,t),s.Complex.zero()),h=i.MultiArray.divideElementByScalar(u,s.Complex.create(c));let d;i.MultiArray.isInstanceOf(u)?d=u.dimension.slice():(d=a.dimension.slice(),d[o]=1);const m=new i.MultiArray(d),p=d.length>2?d.slice(2).reduce((e,t)=>e*t,1):1,f=d[0]*Math.max(1,p),g=null!==(n=d[1])&&void 0!==n?n:1;m.array=new Array(f);for(let e=0;e<f;e++)m.array[e]=new Array(g);const y=a.dimension.reduce((e,t)=>e*t,1);for(let e=0;e<y;e++){const t=i.MultiArray.linearIndexToSubscript(a.dimension,e).slice();let r;if(t[o]=1,i.MultiArray.isInstanceOf(h)){const e=h,n=i.MultiArray.subscriptToLinearIndex(e.dimension,t),[s,a]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n);r=e.array[s][a]}else r=h;const[n,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e),c=a.array[n][l],u=s.Complex.sub(c,r),p=s.Complex.mul(u,u),f=i.MultiArray.subscriptToLinearIndex(d,t),[g,y]=i.MultiArray.linearIndexToMultiArrayRowColumn(d[0],d[1],f),x=m.array[g][y];m.array[g][y]=null==x?s.Complex.copy(p):s.Complex.add(x,p)}const x=s.Complex.create(c-(0===l?1:0)),C=i.MultiArray.divideElementByScalar(m,x);return i.MultiArray.isInstanceOf(C)&&i.MultiArray.setType(C),C},x.stdSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}},x.std=(e,t,r)=>{const n=x.variance(e,t,r);if(i.MultiArray.isInstanceOf(n)){const e=i.MultiArray.rawMap(n,e=>s.Complex.sqrt(e));return i.MultiArray.setType(e),e}return s.Complex.sqrt(n)},x.structSignature={inputs:[{arity:1,parameters:[{name:"structOrEmptyArray",alternatives:[{name:"field",classes:["char","string"]},{name:"struct",classes:["struct"]},{name:"emptyArray",classes:["double","cell","array"]}]}]},{arity:-1,min:0,parameters:[{name:"field",variadic:!0,variadicGroup:[{name:"field",classes:["char","string"]},{name:"value"}]}]}],outputs:{arity:1}},x.struct=(...e)=>{const t='struct: additional arguments must occur as "field", VALUE pairs';if(0===e.length)return new a.Structure({});if(1===e.length){if(i.MultiArray.isInstanceOf(e[0])&&i.MultiArray.isEmpty(e[0]))return i.MultiArray.emptyArray();if(a.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 s=0;s<e.length;s+=2){if(!n.CharString.isInstanceOf(e[s]))throw new Error(t);{const n=(0,p.runtimeExpressionValue)(e[s+1],e[s].str,"struct field",()=>{throw new Error(t)});r[e[s].str]=n}}return new a.Structure(r)}},x.substructSignature={inputs:{arity:-1,min:2,parameters:[{name:"typeAndSubscript",variadic:!0,variadicGroup:[{name:"type",classes:["char","string"]},{name:"subscript"}]}]},outputs:{arity:1}},x.substruct=(...e)=>{const t="substruct: arguments must occur as TYPE, SUBS pairs";if(e.length<2||e.length%2!=0)throw new Error(t);const r=[];for(let s=0;s<e.length;s+=2){const i=e[s],a=e[s+1];if(!n.CharString.isInstanceOf(i))throw new Error(t);r.push(x.createSubstructDescriptor(i.str,a))}return 1===r.length?r[0]:i.MultiArray.firstRow(r)},x.createSubstructDescriptor=(e,t)=>{switch(e){case".":if(!n.CharString.isInstanceOf(t))throw new Error("substruct: dot subscripts must be character strings.");return new a.Structure({type:n.CharString.create(e),subs:t.copy()});case"()":case"{}":if(!i.MultiArray.isInstanceOf(t)||!t.isCell)throw new Error(`substruct: ${e} subscripts must be supplied as a cell array.`);return new a.Structure({type:n.CharString.create(e),subs:t.copy()});default:throw new Error("substruct: TYPE must be '.', '()', or '{}'.")}},x.normSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"order",alternatives:[{name:"numericOrder",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusOrder",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}},x.isNonVectorMatrix2d=e=>i.MultiArray.isInstanceOf(e)&&2===e.dimension.length&&e.dimension[0]>1&&e.dimension[1]>1,x.matrixNorm1=e=>{let t=0;for(let r=0;r<e.dimension[1];r++){let n=0;for(let t=0;t<e.dimension[0];t++)n+=s.Complex.realToNumber(s.Complex.abs(e.array[t][r]));t=Math.max(t,n)}return s.Complex.create(t)},x.matrixNormInf=e=>{let t=0;for(let r=0;r<e.dimension[0];r++){let n=0;for(let t=0;t<e.dimension[1];t++)n+=s.Complex.realToNumber(s.Complex.abs(e.array[r][t]));t=Math.max(t,n)}return s.Complex.create(t)},x.matrixNorm2=e=>{const t=e.dimension[1],r=Array.from({length:t},()=>Array.from({length:t},()=>s.Complex.zero()));for(let n=0;n<t;n++)for(let i=n;i<t;i++){let t=s.Complex.zero();for(let r=0;r<e.dimension[0];r++)t=s.Complex.add(t,s.Complex.mul(s.Complex.conj(e.array[r][n]),e.array[r][i]));r[n][i]=t,r[i][n]=n===i?t:s.Complex.conj(t)}const{D:n}=y.LAPACK.jacobi_symmetric_hermitian(r,1e3,1e-14),i=n.reduce((e,t)=>Math.max(e,s.Complex.realToNumber(t)),0);return s.Complex.sqrt(s.Complex.create(Math.max(0,i)))},x.norm=(...e)=>{d.AST.throwInvalidCallError("norm",e.length<1||e.length>2);const t=e[0],r=i.MultiArray.linearize(i.MultiArray.scalarToMultiArray(t)).map(e=>s.Complex.abs(e)),a=2===e.length?e[1]:s.Complex.create(2);if(n.CharString.isInstanceOf(a))return"fro"!==a.str&&d.AST.throwInvalidCallError("norm"),s.Complex.sqrt(r.reduce((e,t)=>s.Complex.add(e,s.Complex.mul(t,t)),s.Complex.zero()));const o=s.Complex.realToNumber(i.MultiArray.firstElement(a));if(o===1/0)return x.isNonVectorMatrix2d(t)?x.matrixNormInf(t):r.reduce((e,t)=>s.Complex.realToNumber(t)>s.Complex.realToNumber(e)?t:e,s.Complex.zero());if(o===-1/0)return x.isNonVectorMatrix2d(t)&&d.AST.throwInvalidCallError("norm"),0===r.length?s.Complex.zero():r.reduce((e,t)=>s.Complex.realToNumber(t)<s.Complex.realToNumber(e)?t:e,s.Complex.inf_0());if(1===o)return x.isNonVectorMatrix2d(t)?x.matrixNorm1(t):r.reduce((e,t)=>s.Complex.add(e,t),s.Complex.zero());if(2===o)return x.isNonVectorMatrix2d(t)?x.matrixNorm2(t):s.Complex.sqrt(r.reduce((e,t)=>s.Complex.add(e,s.Complex.mul(t,t)),s.Complex.zero()));if(o>0&&Number.isFinite(o)){x.isNonVectorMatrix2d(t)&&d.AST.throwInvalidCallError("norm");const e=r.reduce((e,t)=>s.Complex.add(e,s.Complex.power(t,s.Complex.create(o))),s.Complex.zero());return s.Complex.power(e,s.Complex.create(1/o))}d.AST.throwInvalidCallError("norm")},x.functions={isempty:{func:x.isempty,signature:x.isemptySignature},isscalar:{func:x.isscalar,signature:x.isscalarSignature},ismatrix:{func:x.ismatrix,signature:x.ismatrixSignature},isvector:{func:x.isvector,signature:x.isvectorSignature},iscell:{func:x.iscell,signature:x.iscellSignature},isrow:{func:x.isrow,signature:x.isrowSignature},iscolumn:{func:x.iscolumn,signature:x.iscolumnSignature},isstruct:{func:x.isstruct,signature:x.isstructSignature},issparse:{func:x.issparse,signature:x.issparseSignature},full:{func:x.full,signature:x.fullSignature},sparse:{func:x.sparse,signature:x.sparseSignature},spalloc:{func:x.spalloc,signature:x.spallocSignature},nnz:{func:x.nnz,signature:x.nnzSignature},nzmax:{func:x.nzmax,signature:x.nzmaxSignature},nonzeros:{func:x.nonzeros,signature:x.nonzerosSignature},ischar:{func:x.ischar,signature:x.ischarSignature},isstring:{func:x.isstring,signature:x.isstringSignature},iscellstr:{func:x.iscellstr,signature:x.iscellstrSignature},cellstr:{func:x.cellstr,signature:x.cellstrSignature},char:{func:x.char,signature:x.charSignature},double:{func:x.double,signature:x.doubleSignature},logical:{func:x.logical,signature:x.logicalSignature},isnan:{func:x.isnan,signature:x.isnanSignature},isinf:{func:x.isinf,signature:x.isinfSignature},isfinite:{func:x.isfinite,signature:x.isfiniteSignature},isfloat:{func:x.isfloat,signature:x.isfloatSignature},isinteger:{func:x.isinteger,signature:x.isintegerSignature},isnumeric:{func:x.isnumeric,signature:x.isnumericSignature},islogical:{func:x.islogical,signature:x.islogicalSignature},isreal:{func:x.isreal,signature:x.isrealSignature},isvalid:{func:x.isvalid,signature:x.isvalidSignature},isobject:{func:x.isobject,signature:x.isobjectSignature},properties:{func:x.properties,signature:x.propertiesSignature},fieldnames:{func:x.fieldnames,signature:x.fieldnamesSignature},isfield:{func:x.isfield,signature:x.isfieldSignature},methods:{func:x.methods,signature:x.methodsSignature},events:{func:x.events,signature:x.eventsSignature},enumeration:{func:x.enumeration,signature:x.enumerationSignature},superclasses:{func:x.superclasses,signature:x.superclassesSignature},isprop:{func:x.isprop,signature:x.ispropSignature},ismethod:{func:x.ismethod,signature:x.ismethodSignature},isequal:{func:x.isequal,signature:x.isequalSignature},ndims:{func:x.ndims,signature:x.ndimsSignature},rows:{func:x.rows,signature:x.rowsSignature},columns:{func:x.columns,signature:x.columnsSignature},length:{func:x.Length,signature:x.lengthSignature},numel:{func:x.numel,signature:x.numelSignature},find:{func:x.find,signature:x.findSignature},sort:{func:x.sort,signature:x.sortSignature},ind2sub:{func:x.ind2sub,signature:x.ind2subSignature},sub2ind:{func:x.sub2ind,signature:x.sub2indSignature},size:{func:x.size,signature:x.sizeSignature},colon:{func:x.colon,signature:x.colonSignature},linspace:{func:x.linspace,signature:x.linspaceSignature},logspace:{func:x.logspace,signature:x.logspaceSignature},meshgrid:{func:x.meshgrid,signature:x.meshgridSignature},ndgrid:{func:x.ndgrid,signature:x.ndgridSignature},repmat:{func:x.repmat,signature:x.repmatSignature},reshape:{func:x.reshape,signature:x.reshapeSignature},squeeze:{func:x.squeeze,signature:x.squeezeSignature},flip:{func:x.flip,signature:x.flipSignature},fliplr:{func:x.fliplr,signature:x.fliplrSignature},flipud:{func:x.flipud,signature:x.flipudSignature},rot90:{func:x.rot90,signature:x.rot90Signature},permute:{func:x.permute,signature:x.permuteSignature},ipermute:{func:x.ipermute,signature:x.ipermuteSignature},circshift:{func:x.circshift,signature:x.circshiftSignature},shiftdim:{func:x.shiftdim,signature:x.shiftdimSignature},zeros:{func:x.zeros,signature:x.zerosSignature},ones:{func:x.ones,signature:x.onesSignature},cell:{func:x.cell,signature:x.cellSignature},num2cell:{func:x.num2cell,signature:x.num2cellSignature},cell2mat:{func:x.cell2mat,signature:x.cell2matSignature},mat2cell:{func:x.mat2cell,signature:x.mat2cellSignature},rand:{func:x.rand,signature:x.randSignature},randi:{func:x.randi,signature:x.randiSignature},cat:{func:x.cat,signature:x.catSignature},horzcat:{func:x.horzcat,signature:x.horzcatSignature},vertcat:{func:x.vertcat,signature:x.vertcatSignature},all:{func:x.all,signature:x.allSignature},any:{func:x.any,signature:x.anySignature},sum:{func:x.sum,signature:x.sumSignature},prod:{func:x.prod,signature:x.prodSignature},sumsq:{func:x.sumsq,signature:x.sumsqSignature},max:{func:x.max,signature:x.maxSignature},min:{func:x.min,signature:x.minSignature},mean:{func:x.mean,signature:x.meanSignature},cumsum:{func:x.cumsum,signature:x.cumsumSignature},cumprod:{func:x.cumprod,signature:x.cumprodSignature},cummin:{func:x.cummin,signature:x.cumminSignature},cummax:{func:x.cummax,signature:x.cummaxSignature},var:{func:x.variance,signature:x.varianceSignature},std:{func:x.std,signature:x.stdSignature},struct:{func:x.struct,signature:x.structSignature},getfield:{func:x.getfield,signature:x.getfieldSignature},setfield:{func:x.setfield,signature:x.setfieldSignature},rmfield:{func:x.rmfield,signature:x.rmfieldSignature},orderfields:{func:x.orderfields,signature:x.orderfieldsSignature},numfields:{func:x.numfields,signature:x.numfieldsSignature},struct2cell:{func:x.struct2cell,signature:x.struct2cellSignature},cell2struct:{func:x.cell2struct,signature:x.cell2structSignature},substruct:{func:x.substruct,signature:x.substructSignature},norm:{func:x.norm,signature:x.normSignature}},t.default={CoreFunctions:x}},4087(e,t,r){"use strict";t.DiagnosticMessage=void 0;const n=r(5956),s=r(845),i=r(7679);t.DiagnosticMessage=class{static formatArgument(e,t,r){const a=r.expressionValue(e,"diagnostic format argument");if("s"===t)return n.CharString.isInstanceOf(a)?a.str:r.unparse(a).trimEnd();const o=i.MultiArray.isInstanceOf(a)?i.MultiArray.MultiArrayToScalar(a):a;s.Complex.isInstanceOf(o)&&s.Complex.imagIsZero(o)||r.throwEvalError("diagnostic format argument must be a real numeric scalar.");const l=s.Complex.realToNumber(o);switch(t){case"d":case"i":return Math.trunc(l).toString();case"f":return l.toFixed(6);case"g":return l.toString();default:return r.unparse(a).trimEnd()}}static format(e,t,r){let n=0;return e.replace(/%([-+0 #]*)(\d*)(?:\.(\d+))?([sdifg%])/g,(e,a,o,l,c)=>{if("%"===c)return"%";if(n>=t.length&&r.throwEvalError("not enough arguments for diagnostic format string."),"f"===c&&void 0!==l){const e=r.expressionValue(t[n++],"diagnostic format argument"),a=i.MultiArray.isInstanceOf(e)?i.MultiArray.MultiArrayToScalar(e):e;return s.Complex.isInstanceOf(a)&&s.Complex.imagIsZero(a)||r.throwEvalError("diagnostic format argument must be a real numeric scalar."),s.Complex.realToNumber(a).toFixed(Number(l))}return this.formatArgument(t[n++],c,r)})}static parts(e,t,r,s){const i=r(e[0],`${t} identifier or message`);if(e.length>=2){const r=s.expressionValue(e[1],`${t} message`);if(i.str.includes(":")&&n.CharString.isInstanceOf(r))return{identifier:i.str,message:this.format(r.str,e.slice(2),s)}}return{identifier:"",message:this.format(i.str,e.slice(1),s)}}}},8146(e,t,r){"use strict";t.optionalRuntimeExpressionValue=t.runtimeExpressionValue=t.expressionValues=t.expressionValue=void 0;const n=r(6109),s=(e,t,r,s)=>(n.AST.isExpressionBoundaryValue(e)||s(`${r} '${t}' is not an expression.`),e);t.expressionValue=s,t.expressionValues=(e,t,r,n)=>e.map((e,i)=>s(e,`${t}${i+1}`,r,n));t.runtimeExpressionValue=(e,t,r,i)=>(s(e,t,r,i),n.AST.isRuntimeExpressionValue(e)||i(`${r} '${t}' is not a runtime value.`),e),t.optionalRuntimeExpressionValue=e=>n.AST.isRuntimeExpressionValue(e)?e:void 0},8989(e,t,r){"use strict";t.FunctionArguments=void 0;const n=r(6109),s=r(5956),i=r(845),a=r(7679),o=r(9170),l=r(1604),c=r(8146),u=r(7673);class h{static isIdentifier(e){return n.AST.isNodeIdentifier(e)}static isDefaultedIdentifier(e){return n.AST.isNodeDefaultedParameter(e)}static parameterName(e){return this.isIdentifier(e)?e.id:this.isDefaultedIdentifier(e)?e.left.id:void 0}static checkedList(e,t,r){return e.map((e,n)=>{if(!t(e))throw new TypeError(`internal AST error: ${r} ${n+1} has invalid node type.`);return e})}static runtimeArgumentValue(e,t,r){return(0,c.runtimeExpressionValue)(e,t,"Argument value",r)}static functionParameters(e){return this.checkedList(e.parameter.list,n.AST.isNodeFunctionParameter,"function parameter")}static functionReturns(e){return this.checkedList(e.return.list,n.AST.isNodeFunctionReturn,"function return")}static argumentBlocks(e){return this.checkedList(e.arguments.list,n.AST.isNodeArguments,"function arguments block")}static argumentValidations(e){return this.checkedList(e.validation,n.AST.isNodeArgumentValidation,"arguments validation")}static blockAttributeNames(e){var t;return(null===(t=e.attributes)||void 0===t?void 0:t.length)?e.attributes.map(e=>e.id):e.attribute?[e.attribute.id]:[]}static blockKind(e,t){const r=this.blockAttributeNames(e);if(0===r.length)return"Input";const n=new Set;for(const e of r)this.supportedBlockAttributes.has(e)||t(`unsupported arguments block attribute '${e}'.`),n.has(e)&&t(`duplicate arguments block attribute '${e}'.`),n.add(e);const s=n.has("Input"),i=n.has("Output"),a=n.has("Repeating");return s&&i&&t("arguments block attributes 'Input' and 'Output' cannot be combined."),(n.size>2||!s&&!i&&!a)&&t(`unsupported arguments block attribute list '${r.join(",")}'.`),a&&i?"OutputRepeating":a?"Repeating":i?"Output":"Input"}static argumentSizeDimensionDisplay(e){return"number"==typeof e?String(e):"any"===e.type?":":e.name}static argumentSizeDisplay(e){const t=e.map(e=>this.argumentSizeDimensionDisplay(e));return e.some(e=>"number"!=typeof e&&"any"===e.type)?`(${t.join(",")})`:t.join("x")}static literalNumericSize(e,t,r){i.Complex.isInstanceOf(e)&&i.Complex.realIsInteger(e)&&i.Complex.imagIsZero(e)||r(`arguments block size validation for '${t}' must use positive integer, symbolic, or ':' dimensions.`);const n=i.Complex.realToNumber(e);return n<1&&r(`arguments block size validation for '${t}' must use positive integer dimensions.`),n}static validationName(e,t){const r=e.name;return n.AST.isNodeIdentifier(r)||t("arguments block declaration must be an identifier."),r.id}static nameValueTarget(e,t){const r=e.name;if(n.AST.isNodeIndirectRef(r))return n.AST.isNodeIdentifier(r.obj)&&1===r.field.length&&"string"==typeof r.field[0]||t("arguments block name-value declaration must be a single dotted identifier."),{parameter:r.obj.id,field:r.field[0]}}static validationDisplayName(e,t){const r=this.nameValueTarget(e,t);return r?`${r.parameter}.${r.field}`:this.validationName(e,t)}static nameValueReferenceDisplay(e,t,r,s=new WeakSet){var i,o,l,c,u;if(null!==e&&"object"==typeof e&&!s.has(e)){if(s.add(e),n.AST.isNodeIdentifier(e)&&t.has(e.id))return e.id;if(n.AST.isNodeIndirectRef(e)&&n.AST.isNodeIdentifier(e.obj)&&t.has(e.obj.id)){const t=e.field[0],n="string"==typeof t?`${e.obj.id}.${t}`:e.obj.id;return n===r?void 0:n}if(n.AST.isNodeIndexExpr(e))return null!==(i=this.nameValueReferenceDisplay(e.expr,t,r,s))&&void 0!==i?i:this.firstNameValueReferenceDisplay(e.args,t,r,s);if(n.AST.isNodeRange(e))return null!==(l=null!==(o=this.nameValueReferenceDisplay(e.start_,t,r,s))&&void 0!==o?o:this.nameValueReferenceDisplay(e.stop_,t,r,s))&&void 0!==l?l:this.nameValueReferenceDisplay(e.stride_,t,r,s);if(n.AST.isNodeBinaryOperation(e))return null!==(c=this.nameValueReferenceDisplay(e.left,t,r,s))&&void 0!==c?c:this.nameValueReferenceDisplay(e.right,t,r,s);if(n.AST.isNodePrefixOperation(e))return this.nameValueReferenceDisplay(e.right,t,r,s);if(n.AST.isNodePostfixOperation(e))return this.nameValueReferenceDisplay(e.left,t,r,s);if(n.AST.isNodeSuperclassConstructor(e))return null!==(u=this.nameValueReferenceDisplay(e.instance,t,r,s))&&void 0!==u?u:this.firstNameValueReferenceDisplay(e.args,t,r,s);if(!n.AST.isNodeMetaClass(e))return n.AST.isNodeList(e)?this.firstNameValueReferenceDisplay(e.list,t,r,s):a.MultiArray.isInstanceOf(e)?this.firstNameValueReferenceDisplay(a.MultiArray.linearize(e),t,r,s):void 0}}static firstNameValueReferenceDisplay(e,t,r,n=new WeakSet){for(const s of e){const e=this.nameValueReferenceDisplay(s,t,r,n);if(e)return e}}static literalArgumentSize(e,t){if(!e.size.some(e=>void 0!==e))return;const r=this.validationDisplayName(e,t);return e.size.map(e=>n.AST.isNodeIdentifier(e)?{type:"symbol",name:e.id}:":"===(null==e?void 0:e.type)?{type:"any"}:h.literalNumericSize(e,r,t))}static argumentClassNames(e,t){const r=e.class;if(!r||n.AST.isNodeList(r)&&0===r.list.length)return;const s=this.validationDisplayName(e,t),i=n.AST.isNodeList(r)?r.list:[r];i.every(n.AST.isNodeIdentifier)||t(`arguments block class validation for '${s}' must use class identifiers.`);const a=i.map(e=>e.id);return[...new Set(a)]}static argumentClassName(e,t){const r=this.argumentClassNames(e,t);return r&&1===r.length?r[0]:void 0}static argumentClassDisplay(e){return 1===e.length?e[0]:e.slice(0,-1).join(", ")+" or "+e[e.length-1]}static argumentValidators(e,t){const r=this.validationDisplayName(e,t);return e.functions.map(e=>n.AST.isNodeIdentifier(e)&&this.supportedArgumentValidators.has(e.id)?{name:e.id}:n.AST.isNodeIdentifier(e)?{name:e.id,custom:"implicit"}:n.AST.isNodeIndexExpr(e)&&"()"===e.delim&&n.AST.isNodeIdentifier(e.expr)&&this.supportedComparatorValidators.has(e.expr.id)&&2===e.args.length?{name:e.expr.id,value:e.args[0],bounds:[e.args[1]]}:n.AST.isNodeIndexExpr(e)&&"()"===e.delim&&n.AST.isNodeIdentifier(e.expr)&&this.supportedRangeValidators.has(e.expr.id)&&(3===e.args.length||4===e.args.length)?{name:e.expr.id,value:e.args[0],bounds:e.args.slice(1)}:n.AST.isNodeIndexExpr(e)&&"()"===e.delim&&n.AST.isNodeIdentifier(e.expr)&&this.supportedMembershipValidators.has(e.expr.id)&&2===e.args.length||n.AST.isNodeIndexExpr(e)&&"()"===e.delim&&n.AST.isNodeIdentifier(e.expr)&&this.supportedClassRelationshipValidators.has(e.expr.id)&&2===e.args.length?{name:e.expr.id,value:e.args[0],bounds:[e.args[1]]}:(n.AST.isNodeIndexExpr(e)&&n.AST.isNodeIdentifier(e.expr)&&(this.supportedComparatorValidators.has(e.expr.id)||this.supportedRangeValidators.has(e.expr.id)||this.supportedMembershipValidators.has(e.expr.id)||this.supportedClassRelationshipValidators.has(e.expr.id))&&t(`arguments block function validation for '${r}' has invalid ${e.expr.id} arguments.`),n.AST.isNodeIndexExpr(e)&&"()"===e.delim&&n.AST.isNodeIdentifier(e.expr)?{name:e.expr.id,custom:"explicit",expression:e}:void t(`arguments block function validation for '${r}' must be a validator identifier or function call.`)))}static valueSize(e){return l.RuntimeValue.dimensions(e)}static textElements(e){if(s.CharString.isInstanceOf(e))return[e.str];if(a.MultiArray.isInstanceOf(e)){const t=a.MultiArray.linearize(e);return t.every(s.CharString.isInstanceOf)?t.map(e=>e.str):void 0}}static classNameElements(e){const t=this.textElements(e);if(t&&0!==t.length&&!t.some(e=>0===e.length))return[...new Set(t)]}static membershipElements(e){return a.MultiArray.isInstanceOf(e)?a.MultiArray.linearize(e).map(e=>this.runtimeArgumentValue(e,"mustBeMember element",e=>{throw new EvalError(e)})):[e]}static validateArgumentFunction(e,t,r,n,a,l,c={},h="arguments block"){const d=o.FunctionValidation.numericElements(t),m=()=>a(`${h} validation failed for '${e}': ${r}.`),p=(e=0)=>{const t=n[e],r=void 0!==t?o.FunctionValidation.numericElements(t):void 0;return r&&1===r.length&&i.Complex.imagIsZero(r[0])||m(),i.Complex.realToNumber(r[0])},f=(e,t=0)=>{const r=p(t);return Boolean(d&&d.every(t=>i.Complex.imagIsZero(t)&&e(t,r)))},g=o.FunctionValidation.builtInValidatorForArgumentValidator(r);if(g)o.FunctionValidation.matchesBuiltInValidator(t,g)||m();else switch(r){case"mustBeFile":{const e=o.FunctionValidation.matchesBuiltInValidator(t,"textScalar")?this.textElements(t):void 0;return void(e&&1===e.length&&c.fileExists&&c.fileExists(e[0])||m())}case"mustBeFolder":{const e=o.FunctionValidation.matchesBuiltInValidator(t,"text")?this.textElements(t):void 0;return void(e&&0!==e.length&&c.folderExists&&e.every(c.folderExists)||m())}case"mustBeOdd":return void(d&&d.every(e=>i.Complex.realIsInteger(e)&&i.Complex.imagIsZero(e)&&1===Math.abs(i.Complex.realToNumber(e)%2))||m());case"mustBeGreaterThan":return void(f((e,t)=>i.Complex.realGreaterThan(e,t))||m());case"mustBeGreaterThanOrEqual":return void(f((e,t)=>i.Complex.realGreaterThanOrEqualTo(e,t))||m());case"mustBeLessThan":return void(f((e,t)=>i.Complex.realLessThan(e,t))||m());case"mustBeLessThanOrEqual":return void(f((e,t)=>i.Complex.realLessThanOrEqualTo(e,t))||m());case"mustBeInRange":{const e=p(0),t=p(1),r=n[2],a=void 0===r?"inclusive":s.CharString.isInstanceOf(r)?r.str:void 0;void 0!==a&&this.supportedRangeOptions.has(a)||m();const o="exclude-lower"===a||"exclude-both"===a?t=>i.Complex.realGreaterThan(t,e):t=>i.Complex.realGreaterThanOrEqualTo(t,e),l="exclude-upper"===a||"exclude-both"===a?e=>i.Complex.realLessThan(e,t):e=>i.Complex.realLessThanOrEqualTo(e,t);return void(d&&d.every(e=>i.Complex.imagIsZero(e)&&o(e)&&l(e))||m())}case"mustBeBetween":{const e=p(0),t=p(1),r=n[2],a=void 0===r?"closed":s.CharString.isInstanceOf(r)?r.str:void 0;void 0!==a&&this.supportedBetweenOptions.has(a)||m();const o="open"===a||"openleft"===a||"closedright"===a?t=>i.Complex.realGreaterThan(t,e):t=>i.Complex.realGreaterThanOrEqualTo(t,e),l="open"===a||"openright"===a||"closedleft"===a?e=>i.Complex.realLessThan(e,t):e=>i.Complex.realLessThanOrEqualTo(e,t);return void(d&&d.every(e=>i.Complex.imagIsZero(e)&&o(e)&&l(e))||m())}case"mustBeMember":{const e=o.FunctionValidation.numericElements(n[0]);if(d&&e)return void(d.every(t=>e.some(e=>i.Complex.imagEquals(t,i.Complex.imagToNumber(e))&&i.Complex.realEquals(t,i.Complex.realToNumber(e))))||m());const r=this.textElements(t),s=this.textElements(n[0]);if(r&&s)return void(r.every(e=>s.includes(e))||m());const a=this.membershipElements(t),l=this.membershipElements(n[0]);if(a.every(e=>l.some(t=>u.RuntimeEquality.valuesEqual(e,t))))return;return void m()}default:l(`${h} function validation for '${e}' uses unsupported validator '${r}'.`)}}static validateArgumentValidation(e,t,r,s=!1,i=this.validationDisplayName(e,r.throwSyntaxError),l="arguments block"){var c,u,h,d,m;const p=this.literalArgumentSize(e,r.throwSyntaxError),f=this.argumentClassNames(e,r.throwSyntaxError),g=this.argumentValidators(e,r.throwSyntaxError);if(!p&&!f&&0===g.length)return;const y=r.resolveEntry(e,s);let x;y&&void 0!==y.node||r.throwEvalError(`'${i}' undefined.`);const C=()=>null!=x?x:x=this.runtimeArgumentValue(y.node,i,r.throwEvalError);if(p){const e=this.valueSize(C()),n=Math.max(p.length,e.length);n>p.length&&p.push(...new Array(n-p.length).fill(1)),a.MultiArray.appendSingletonTail(e,n),p.every((r,n)=>{if("number"==typeof r)return r===e[n];if("any"===r.type)return!0;const s=t.get(r.name);return void 0===s?(t.set(r.name,e[n]),!0):s===e[n]})||r.throwEvalError(`${l} validation failed for '${i}': expected size ${this.argumentSizeDisplay(p)}, got ${e.join("x")}.`)}const E=null!==(c=r.matchesClass)&&void 0!==c?c:(e,t)=>o.FunctionValidation.matchesClass(e,t);f&&!f.some(e=>E(C(),e))&&r.throwEvalError(`${l} validation failed for '${i}': expected class ${this.argumentClassDisplay(f)}, got ${o.FunctionValidation.className(C())}.`);for(const e of g){if("explicit"===e.custom){r.evaluate(e.expression);continue}if("implicit"===e.custom){n.AST.isStrictNodeExpr(y.node)||r.throwEvalError(`${l} validation failed for '${i}': validator input is not an expression.`),r.evaluate(n.AST.nodeIndexExpr(n.AST.nodeIdentifier(e.name),n.AST.nodeList([y.node])));continue}const t=e.value?this.runtimeArgumentValue(r.evaluate(e.value),i,r.throwEvalError):C(),s=null!==(h=null===(u=e.bounds)||void 0===u?void 0:u.map((e,t)=>this.runtimeArgumentValue(r.evaluate(e),`${i} bound ${t+1}`,r.throwEvalError)))&&void 0!==h?h:[];if("mustBeA"===e.name){const a=[this.classNameElements(s[0]),(null===(d=e.bounds)||void 0===d?void 0:d[0])&&n.AST.isExpressionBoundaryValue(e.bounds[0])?this.classNameElements(this.runtimeArgumentValue(e.bounds[0],`${i} class names`,r.throwEvalError)):void 0].filter(e=>Boolean(e));0!==a.length&&a.some(e=>e.some(e=>E(t,e)))||r.throwEvalError(`${l} validation failed for '${i}': mustBeA.`);continue}if("mustBeUnderlyingType"===e.name){const a=[this.classNameElements(s[0]),(null===(m=e.bounds)||void 0===m?void 0:m[0])&&n.AST.isExpressionBoundaryValue(e.bounds[0])?this.classNameElements(this.runtimeArgumentValue(e.bounds[0],`${i} underlying types`,r.throwEvalError)):void 0].filter(e=>Boolean(e));0!==a.length&&a.some(e=>e.includes(o.FunctionValidation.underlyingType(t)))||r.throwEvalError(`${l} validation failed for '${i}': mustBeUnderlyingType.`);continue}this.validateArgumentFunction(i,t,e.name,s,r.throwEvalError,r.throwSyntaxError,r,l)}}static validateFunctionArguments(e,t,r,n,s=!1){var i;const a=new Map;for(const o of this.argumentBlocks(e))if(this.blockKind(o,r.throwSyntaxError)===t)for(const e of this.argumentValidations(o))n&&!n.has(this.validationName(e,r.throwSyntaxError))||this.nameValueTarget(e,r.throwSyntaxError)&&void 0===(null===(i=r.resolveEntry(e,s))||void 0===i?void 0:i.node)||this.validateArgumentValidation(e,a,r,s)}static validateRepeatingArguments(e,t,r){for(const n of this.argumentBlocks(e)){if("Repeating"!==this.blockKind(n,r.throwSyntaxError))continue;const s=this.argumentValidations(n);t.length%s.length!==0&&r.throwEvalError(`invalid number of repeating arguments in function ${e.id}`);for(let e=0;e<t.length/s.length;e++){const n=new Map;s.forEach((i,a)=>{const o=t[e*s.length+a],l=this.validationName(i,r.throwSyntaxError);r.validateRepeatingValue(i,l,o,`${l}{${e+1}}`,n)})}}}static outputRepeatingInfo(e,t){const r=this.functionReturns(e).map(e=>n.AST.isNodeIgnoredTarget(e)?null:e.id);let s;for(const n of this.argumentBlocks(e)){if("OutputRepeating"!==this.blockKind(n,t))continue;s&&t(`function ${e.id} can contain only one arguments (Output,Repeating) block.`);const i=this.argumentValidations(n);1!==i.length&&t(`arguments (Output,Repeating) requires exactly one declaration in function ${e.id}.`);const a=i[0];this.nameValueTarget(a,t)&&t(`arguments (Output,Repeating) declaration in function ${e.id} must be a return identifier.`);const o=this.validationName(a,t),l=r.indexOf(o);l<0&&t(`arguments block declaration '${o}' does not match a return value in function ${e.id}.`),l!==r.length-1&&t(`arguments (Output,Repeating) declaration '${o}' must be the last return in function ${e.id}.`),"varargout"===o&&1!==r.length&&t(`arguments (Output,Repeating) declaration 'varargout' must be the only return in function ${e.id}.`),s={name:o,fixedReturnCount:l}}return s}static outputRepeatingName(e,t){var r;return null===(r=this.outputRepeatingInfo(e,t))||void 0===r?void 0:r.name}static validateRepeatingOutputArguments(e,t,r){for(const n of this.argumentBlocks(e)){if("OutputRepeating"!==this.blockKind(n,r.throwSyntaxError))continue;const e=this.argumentValidations(n)[0],s=this.validationName(e,r.throwSyntaxError);t.forEach(t=>{r.validateRepeatingValue(e,s,t.value,`${s}{${t.index}}`,new Map)})}}static validateBlocks(e,t){var r;(null===(r=e.attributes)||void 0===r?void 0:r.nested)&&e.arguments.list.length>0&&t(`arguments blocks are not allowed in nested function ${e.id}.`);const s=new Set(this.functionParameters(e).map(e=>this.parameterName(e)).filter(e=>void 0!==e)),i=new Set(this.functionReturns(e).filter(n.AST.isNodeIdentifier).map(e=>e.id)),a=new Set;for(const r of this.argumentBlocks(e))if("Input"===this.blockKind(r,t))for(const e of this.argumentValidations(r)){const r=this.nameValueTarget(e,t);r&&a.add(r.parameter)}const o=s.has("varargin"),l=new Set,c=new Map,u=new Set,h=new Set,d=new Set,m=new Set;let p=!1,f=!1,g=!1,y=!1,x=!1;for(const r of this.argumentBlocks(e)){const C=this.blockKind(r,t);if("Input"!==C&&"Repeating"!==C||!x||t(`input arguments blocks must appear before output arguments blocks in function ${e.id}.`),"Input"===C){const n=this.argumentValidations(r).some(e=>!this.nameValueTarget(e,t));f&&n&&t(`ordinary input arguments blocks cannot follow repeating arguments block in function ${e.id}.`)}"Repeating"===C&&(f&&t(`function ${e.id} can contain only one arguments (Repeating) block.`),y&&t(`arguments (Repeating) block must appear before name-value arguments in function ${e.id}.`),f=!0),"Output"!==C&&"OutputRepeating"!==C||(x=!0),"OutputRepeating"===C&&(p&&t(`function ${e.id} can contain only one arguments (Output,Repeating) block.`),p=!0,this.outputRepeatingInfo(e,t)),"Repeating"!==C||o||t(`arguments (Repeating) requires a varargin parameter in function ${e.id}.`),"Repeating"!==C&&"OutputRepeating"!==C||0!==r.validation.length||t(`arguments (${"OutputRepeating"===C?"Output,Repeating":"Repeating"}) requires at least one declaration in function ${e.id}.`);const E="Output"===C?i:"Input"===C?s:void 0;for(const i of this.argumentValidations(r)){const r=this.nameValueTarget(i,t),o=r?`${r.parameter}.${r.field}`:this.validationName(i,t);if(r){"Input"!==C&&t(`arguments block name-value declaration '${o}' is only supported for input arguments.`),s.has(r.parameter)||t(`arguments block declaration '${o}' does not match a function parameter in function ${e.id}.`);const n=`${r.parameter}.${r.field}`;l.has(n)&&t(`duplicate arguments block name-value declaration '${o}' in function ${e.id}.`);const i=r.field.toLowerCase(),a=c.get(i);a&&t(`duplicate arguments block name-value field '${a}' in function ${e.id}.`),h.has(r.parameter)&&t(`arguments block parameter '${r.parameter}' cannot have both ordinary and name-value declarations in function ${e.id}.`),l.add(n),c.set(i,r.field),u.add(r.parameter),y=!0}else E&&!E.has(o)&&t(`arguments block declaration '${o}' does not match a ${"Output"===C?"return value":"function parameter"} in function ${e.id}.`);r||"Input"!==C||(h.has(o)&&t(`duplicate arguments block declaration '${o}' in function ${e.id}.`),u.has(o)&&t(`arguments block parameter '${o}' cannot have both ordinary and name-value declarations in function ${e.id}.`),y&&"varargin"!==o&&t(`ordinary input arguments must appear before name-value arguments in function ${e.id}.`),g&&!i.default&&"varargin"!==o&&t(`required input arguments cannot follow optional input arguments in function ${e.id}.`),h.add(o),i.default&&(g=!0)),r||"Repeating"!==C||(d.has(o)&&t(`duplicate arguments (Repeating) declaration '${o}' in function ${e.id}.`),d.add(o)),r||"Output"!==C||(m.has(o)&&t(`duplicate arguments block output declaration '${o}' in function ${e.id}.`),m.add(o));const p=i.size.some(e=>void 0!==e),f=Boolean(i.class&&(!n.AST.isNodeList(i.class)||i.class.list.length>0)),x=i.functions.some(e=>void 0!==e);if(p&&this.literalArgumentSize(i,t),f&&this.argumentClassNames(i,t),x&&this.argumentValidators(i,t),i.default&&"Input"!==C&&t(`arguments block default for '${o}' is only supported for input parameters.`),r&&i.default){const r=this.nameValueReferenceDisplay(i.default,a);r&&t(`arguments block name-value default for '${o}' cannot reference name-value argument '${r}' in function ${e.id}.`)}if(r&&x){const r=this.firstNameValueReferenceDisplay(i.functions,a,o);r&&t(`arguments block name-value validation for '${o}' cannot reference name-value argument '${r}' in function ${e.id}.`)}i.default&&!r&&"varargin"===o&&t("arguments block default for 'varargin' is not supported.")}}}static nameValueParameters(e,t){const r=new Set;for(const n of this.argumentBlocks(e))if("Input"===this.blockKind(n,t))for(const e of this.argumentValidations(n)){const n=this.nameValueTarget(e,t);n&&r.add(n.parameter)}return r}static nameValueDeclarations(e,t){const r=new Map;for(const n of this.argumentBlocks(e))if("Input"===this.blockKind(n,t))for(const e of this.argumentValidations(n)){const n=this.nameValueTarget(e,t);if(!n)continue;let s=r.get(n.parameter);s||(s=new Map,r.set(n.parameter,s)),s.set(n.field,e)}return r}static inputArgumentDefaults(e,t){const r=new Map;for(const t of this.functionParameters(e))this.isDefaultedIdentifier(t)&&r.set(t.left.id,t.right);for(const n of this.argumentBlocks(e))if("Input"===this.blockKind(n,t))for(const e of this.argumentValidations(n))!this.nameValueTarget(e,t)&&e.default&&r.set(this.validationName(e,t),e.default);return r}static splitCallNameValueArguments(e,t,r,i){const a=this.nameValueDeclarations(e,i),o=new Set([...a.values()].flatMap(e=>[...e.keys()])),l=this.functionParameters(e),c=l[l.length-1],u=l.length>0&&"varargin"===this.parameterName(c),h=u?l.length-1:l.length,d=this.nameValueParameters(e,i),m=l.slice(0,h).filter(e=>{const t=this.parameterName(e);return"<~>"===e.type||!t||!d.has(t)}),p=this.inputArgumentDefaults(e,i);let f=m.length;for(;f>0;){const e=m[f-1],t=this.parameterName(e);if(!t||!p.has(t))break;f--}const g=[],y=new Map;let x=!1;const C=[...o],E=e=>C.some(t=>t.toLowerCase().startsWith(e.toLowerCase())),v=(t,n)=>{x=!0;const s=(t=>{if(o.has(t))return t;const n=t.toLowerCase(),s=C.filter(e=>e.toLowerCase()===n);if(1===s.length)return s[0];s.length>1&&r(`ambiguous name-value argument '${t}' in function ${e.id}`);const i=C.filter(e=>e.toLowerCase().startsWith(n));if(1===i.length)return i[0];i.length>1&&r(`ambiguous name-value argument '${t}' in function ${e.id}`),r(`unknown name-value argument '${t}' in function ${e.id}`)})(t);y.set(s,n)};for(let i=0;i<t.length;i++){const o=t[i];n.AST.isNodeDefaultedParameter(o)&&a.size>0?v(o.left.id,o.right):s.CharString.isInstanceOf(o)&&a.size>0&&(g.length>=f&&E(o.str)||!u&&g.length>=m.length)?(i+1>=t.length&&r(`missing value for name-value argument '${o.str}' in function ${e.id}`),v(o.str,t[++i])):(x&&r(`positional arguments cannot follow name-value arguments in function ${e.id}`),g.push(o))}return{positional:g,named:y}}static outputNamesToValidate(e,t,r=[]){const s=this.functionReturns(e).map(e=>n.AST.isNodeIgnoredTarget(e)?null:e.id),i=s.length>0&&"varargout"===s[s.length-1];if(1===s.length&&i)return;const a=i?s.slice(0,-1):s;return new Set(a.slice(0,Math.min(Math.max(t,1),a.length)).filter((e,t)=>{var n;return null!==e&&(null===(n=r[t])||void 0===n||n)}))}}t.FunctionArguments=h,h.supportedArgumentValidators=new Set(["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal"]),h.supportedComparatorValidators=new Set(["mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual"]),h.supportedRangeValidators=new Set(["mustBeInRange","mustBeBetween"]),h.supportedMembershipValidators=new Set(["mustBeMember"]),h.supportedClassRelationshipValidators=new Set(["mustBeA","mustBeUnderlyingType"]),h.supportedRangeOptions=new Set(["inclusive","exclude-lower","exclude-upper","exclude-both"]),h.supportedBetweenOptions=new Set(["closed","open","openleft","openright","closedleft","closedright"]),h.supportedBlockAttributes=new Set(["Input","Output","Repeating"])},164(e,t,r){"use strict";t.FunctionArity=void 0;const n=r(6109),s=r(845),i=r(7679),a=r(491);t.FunctionArity=class{static checkedList(e,t,r){return e.map((e,n)=>{if(!t(e))throw new TypeError(`internal AST error: ${r} ${n+1} has invalid node type.`);return e})}static inputArity(e){var t;switch(e.type){case"LAMBDA":{const t=this.checkedList(e.node.parameter,n.AST.isNodeFunctionParameter,"function handle parameter");return this.identifierListArity(t,"varargin")}case"FCNDEF":{const t=this.checkedList(e.node.parameter.list,n.AST.isNodeFunctionParameter,"function parameter");return this.identifierListArity(t,"varargin")}case"STATIC_METHOD":{const t=this.checkedList(e.node.method.node.parameter.list,n.AST.isNodeFunctionParameter,"static method parameter");return this.identifierListArity(t,"varargin")}case"BUILTIN":return null!==(t=a.FunctionSignature.declaredArity(a.FunctionSignature.inputSignatures(e.node)))&&void 0!==t?t:e.node.func.length}}static outputArity(e){var t;switch(e.type){case"LAMBDA":return 1;case"FCNDEF":{const t=this.checkedList(e.node.return.list,n.AST.isNodeFunctionReturn,"function return");return this.identifierListArity(t,"varargout")}case"STATIC_METHOD":{const t=this.checkedList(e.node.method.node.return.list,n.AST.isNodeFunctionReturn,"static method return");return this.identifierListArity(t,"varargout")}case"BUILTIN":return null!==(t=a.FunctionSignature.declaredArity(a.FunctionSignature.outputSignatures(e.node)))&&void 0!==t?t:1}}static countBound(e,t,r,n){const a=i.MultiArray.isInstanceOf(t)&&i.MultiArray.isScalar(t)?i.MultiArray.firstElement(t):t;s.Complex.isInstanceOf(a)&&s.Complex.imagIsZero(a)&&(r||Number.isFinite(s.Complex.realToNumber(a)))||n(`${e}: bounds must be real scalar numbers.`);const o=s.Complex.realToNumber(a);return(o<0||!Number.isInteger(o)&&(!r||o!==1/0))&&n(`${e}: bounds must be nonnegative integers.`),o}static checkFunctionCount(e,t,r,n,s,i){const a=this.countBound(e,t,!1,s),o=this.countBound(e,r,!0,s);o<a&&s(`${e}: maximum count must be greater than or equal to minimum count.`),(n<a||n>o)&&i(`${e}: invalid number of ${"nargoutchk"===e?"output":"input"} arguments.`)}static identifierListArity(e,t){const r=e[e.length-1];return e.length>0&&n.AST.isNodeIdentifier(r)&&r.id===t?-e.length:e.length}}},5273(e,t,r){"use strict";t.FunctionCall=void 0;const n=r(6109),s=r(8146),i=r(7679);class a{static isIdentifier(e){return n.AST.isNodeIdentifier(e)}static isDefaultedIdentifier(e){return n.AST.isNodeDefaultedParameter(e)}static parameterName(e){return this.isIdentifier(e)?e.id:this.isDefaultedIdentifier(e)?e.left.id:void 0}static isNamed(e,t){return this.parameterName(e)===t}static checkedList(e,t,r){return e.map((e,n)=>{if(!t(e))throw new TypeError(`internal AST error: ${r} ${n+1} has invalid node type.`);return e})}static returnExpression(e,t,r){return(0,s.expressionValue)(e,t,"Return variable",r)}static evaluatedArgument(e,t,r){return(0,s.expressionValue)(e,t,"Argument value",r)}static isDefaultArgumentMarker(e){return!0===e.useDefaultArgument}static callArgumentRequestsDefault(e){return n.AST.isNodeBase(e)&&":"===e.type}static requireEvaluatedArgument(e,t,r){return this.isDefaultArgumentMarker(e)&&r(`invalid use of default argument marker ':' for ${t}.`),e}static expressionArgumentValues(e,t,r){return e.map((e,n)=>this.requireEvaluatedArgument(e,`${t} ${n+1}`,r))}static inputLayout(e,t){const r=this.checkedList(e.parameter.list,n.AST.isNodeFunctionParameter,"function parameter"),s=r.length>0&&this.isNamed(r[r.length-1],"varargin"),i=s?r.length-1:r.length,a=r.slice(0,i).filter(e=>{const r=this.parameterName(e);return"<~>"===e.type||!r||!t.has(r)});return{params:r,hasVarargin:s,fixedParamCount:i,positionalParams:a,positionalParamCount:a.length}}static lambdaInputLayout(e){const t=e.length>0&&this.isNamed(e[e.length-1],"varargin");return{hasVarargin:t,fixedParamCount:t?e.length-1:e.length}}static returnLayout(e,t){const r=this.checkedList(e.return.list,n.AST.isNodeFunctionReturn,"function return"),s=r.map(e=>n.AST.isNodeIgnoredTarget(e)?"~":e.id),i=s.length>0&&"varargout"===s[s.length-1],a=null!=t?t:i?"varargout":void 0,o=void 0===a?-1:s.indexOf(a);return{returnNames:r,hasVarargout:i,variableOutputName:a,fixedReturnCount:o>=0?o:r.length,names:s}}static minimumPositionalCount(e,t){let r=e.length;for(;r>0;){const n=e[r-1],s=this.parameterName(n);if(!s||!t.has(s))break;r--}return r}static validateLambdaInputArity(e,t,r,n){(t&&e<r||!t&&e!==r)&&n("invalid number of arguments.")}static validateFunctionInputArity(e,t,r,n,s,i){(r&&t<s||!r&&(t<s||t>n))&&i(`invalid number of arguments in function ${e.id}`)}static validateFunctionOutputArity(e,t,r,s){!t&&e.length>0&&r>e.length&&n.AST.throwErrorIfGreaterThanReturnList(e.length,r,s)}static prepareFunctionCall(e,t,r,n){var s;const i=this.inputLayout(e,n.nameValueParameters(e)),a=this.returnLayout(e,null===(s=n.outputRepeatingName)||void 0===s?void 0:s.call(n,e));let o=n.splitCallArguments(e,t);if(o.rawPositionalCount=o.positional.length,n.expandPositionalArguments){const t=o.positional.flatMap(e=>this.callArgumentRequestsDefault(e)?[e]:n.expandPositionalArguments([e])),r=n.splitCallArguments(e,t),s=new Map(r.named);for(const[e,t]of o.named)s.set(e,t);o={positional:r.positional,rawPositionalCount:o.rawPositionalCount,named:s}}const l=n.inputDefaults(e),c=this.minimumPositionalCount(i.positionalParams,l);return this.validateFunctionInputArity(e,o.positional.length,i.hasVarargin,i.positionalParamCount,c,n.throwEvalError),this.validateFunctionOutputArity(a.returnNames,void 0!==a.variableOutputName,r,n.throwEvalError),{inputLayout:i,returnLayout:a,callArguments:o,inputDefaults:l,minFixedParamCount:c}}static vararginCell(e){return i.MultiArray.firstRow(this.expressionArgumentValues(e,"varargin argument",e=>{throw new EvalError(e)}),!0)}static emptyVarargoutCell(e,t){return new i.MultiArray([1,Math.max(e-t,1)],()=>{},!0)}static initializeFixedReturnSlots(e,t){for(const r of e)n.AST.isNodeIgnoredTarget(r)||"varargout"===r.id||Object.prototype.hasOwnProperty.call(t,r.id)||(t[r.id]={})}static evaluateCallArguments(e,t,r,s,i=0,a=!1){return e.map((e,o)=>(n.AST.isNodeBase(e)&&(e.parent=t,e.index=i+o),a&&this.callArgumentRequestsDefault(e)?this.defaultArgumentMarker:this.evaluatedArgument(r(e),`argument ${i+o+1}`,s)))}static evaluateNameValueArguments(e,t,r,s){const i=new Map;for(const[a,o]of e)n.AST.isNodeBase(o)&&(o.parent=t),i.set(a,this.evaluatedArgument(r(o),a,s));return i}static bindLambdaInputs(e,t,r,n,s,i,a,o){for(let n=0;n<s;n++){const s=e[n],l=this.requireEvaluatedArgument(this.evaluateCallArguments([t[n]],r,a,o,n)[0],`argument ${n+1}`,o);this.isIdentifier(s)&&i(s.id,l)}n&&i("varargin",this.vararginCell(this.evaluateCallArguments(t.slice(s),r,a,o,s)))}static bindPositionalInputs(e,t,r,n,s,i,a){for(let o=0;o<t.positionalParamCount;o++){const l=t.positionalParams[o],c=this.parameterName(l);if(o<r.length){const t=r[o];if(!c)continue;if(this.isDefaultArgumentMarker(t)){const t=n.get(c);t||a(`invalid use of default argument marker ':' in function ${e.id}`),s(c,this.evaluatedArgument(i(c,t),c,a))}else s(c,t)}else{c||a(`invalid number of arguments in function ${e.id}`);const t=n.get(c);t||a(`invalid number of arguments in function ${e.id}`),s(c,this.evaluatedArgument(i(c,t),c,a))}}r.slice(t.positionalParamCount).some(e=>this.isDefaultArgumentMarker(e))&&a(`invalid use of default argument marker ':' in function ${e.id}`)}static bindVarargin(e,t,r){e.hasVarargin&&r("varargin",this.vararginCell(t.slice(e.positionalParamCount)))}static bindVarargout(e,t,r){e.variableOutputName&&r(e.variableOutputName,this.emptyVarargoutCell(t,e.fixedReturnCount))}static variableReturnKey(e,t){var r;return`${null!==(r=e.variableOutputName)&&void 0!==r?r:"varargout"}${t}`}static ignoredReturnValue(){return i.MultiArray.emptyArray()}static createReturnList(e,t,r,s=[]){const{fixedReturnCount:a,names:o,variableOutputName:l}=e,c=void 0!==l,u=e=>{var t;return null===(t=s[e])||void 0===t||t};return 0===o.length?n.AST.nodeVoid():n.AST.nodeReturnList((t,s)=>{if(c){if(s<a){if("~"===o[s])return this.ignoredReturnValue();const e=t[o[s]];return void 0===e&&r(`Undefined return value '${o[s]}'`),e}const i=s-a,l=t[this.variableReturnKey(e,i)];return void 0===l&&n.AST.throwErrorIfGreaterThanReturnList(s,s+1,r),l}const i=o[s];if("~"===i)return this.ignoredReturnValue();const l=t[i];return void 0===l&&r(`Undefined return value '${i}'`),l},s=>{!c&&s>o.length&&n.AST.throwErrorIfGreaterThanReturnList(o.length,s,r);const h={length:s};if(c){for(let e=0;e<Math.min(s,a);e++){if(!u(e))continue;const n=o[e];if("~"===n)continue;const s=t[n];s&&s.node||r(`Undefined return variable '${n}'`),h[n]=this.returnExpression(s.node,n,r)}const c=t[l];c&&c.node instanceof i.MultiArray&&c.node.isCell||r(`Undefined return variable '${l}'`);const d=i.MultiArray.linearize(c.node);for(let t=a;t<s;t++){if(!u(t))continue;const s=d[t-a];void 0===s&&n.AST.throwErrorIfGreaterThanReturnList(t,t+1,r),h[this.variableReturnKey(e,t-a)]=this.returnExpression(s,`${l}{${t-a+1}}`,r)}return h}for(let e=0;e<s;e++){if(!u(e))continue;const n=o[e];if("~"===n)continue;const s=t[n];s&&s.node||r(`Undefined return variable '${n}'`),h[n]=this.returnExpression(s.node,n,r)}return h})}}t.FunctionCall=a,a.defaultArgumentMarker={useDefaultArgument:!0}},1271(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionHandle=void 0;const n=r(845);class s{constructor(e,t=[],r=null,n){this.type=s.FUNCTION_HANDLE,this.parameter=[],this.disallowNestedResolution=!1,this.id=e,this.parameter=null!=t?t:[],this.expression=r,n&&(this.closure=n)}toString(){return s.toString(this)}copy(){const e=s.copy(this);return e.parent=this.parent,e}static hasCopyMethod(e){return"function"==typeof e.copy}static isFunctionHandleNode(e){return!!e&&"object"==typeof e}static hasNodeType(e){return s.isFunctionHandleNode(e)&&"type"in e}static copyNodeValue(e){return Array.isArray(e)?e.map(e=>s.copyNodeValue(e)):s.isFunctionHandleNode(e)?s.copyNode(e):e}static copyNode(e){if(!e||"object"!=typeof e)return e;if(s.hasCopyMethod(e)){const t=e.copy();if(s.isFunctionHandleNode(t)||null==t)return t}const t={};for(const[r,n]of Object.entries(e))"parent"!==r&&Reflect.set(t,r,s.copyNodeValue(n));for(const e of Object.values(t))s.attachParent(e,t);return t}static attachParent(e,t){Array.isArray(e)?e.forEach(e=>s.attachParent(e,t)):s.hasNodeType(e)&&(e.parent=t)}toLogical(){return n.Complex.false()}}t.FunctionHandle=s,s.FUNCTION_HANDLE=5,s.isInstanceOf=e=>e instanceof s,s.isAnonymous=e=>s.isInstanceOf(e)&&void 0===e.id,s.create=(e,t=[],r=null,n)=>new s(e,t,r,n),s.unparse=(e,t,r=0)=>e.id?"@"+e.id:"@("+e.parameter.map(e=>t.Unparse(e)).join(",")+") "+t.Unparse(e.expression),s.toString=e=>e.id?"@"+e.id:"@anonymous function handle",s.unparseMathML=(e,t,r=0)=>e.id?`<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),s.copy=e=>{const t=new s(e.id,e.parameter.map(e=>s.copyNode(e)),s.copyNode(e.expression),e.closure);return t.parameter.forEach(e=>{e.parent=t}),t.expression&&(t.expression.parent=t),t.parent=e.parent,t.sourceName=e.sourceName,t.className=e.className,t.disallowNestedResolution=e.disallowNestedResolution,t},s.toLogical=e=>n.Complex.false(),t.default={FunctionHandle:s}},8342(e,t,r){"use strict";t.FunctionIntrospection=void 0;const n=r(5956),s=r(845),i=r(7679),a=r(5212),o=r(1271);t.FunctionIntrospection=class{static metadataString(e,t){if(e&&"object"==typeof e&&t in e){const r=e[t];return"string"==typeof r?r:void 0}}static functionNames(e){return Object.keys(e.functionTable).filter(t=>{var r;return"FCNDEF"===(null===(r=e.functionTable[t])||void 0===r?void 0:r.type)})}static nearestFunctionScope(e,t){var r;if(!e)return{scope:t,hasFunctionFrame:!1};if(this.functionNames(e.scope).length>0)return{scope:e.scope,hasFunctionFrame:!0};let n=e.scope.parent;for(;n;){if(this.functionNames(n).length>0)return{scope:n,excludeName:this.metadataString(null===(r=e.func)||void 0===r?void 0:r.node,"id"),hasFunctionFrame:!0};n=n.parent}return{scope:e.scope,hasFunctionFrame:!0}}static localFunctionHandles(e,t){const r=this.nearestFunctionFrame(e),{scope:n,excludeName:s,hasFunctionFrame:a}=this.nearestFunctionScope(r,t),l=this.functionNames(n).filter(e=>e!==s).sort(),c=new i.MultiArray([l.length,1],null,!0);return c.array=l.map(e=>{const t=a?n:void 0;return[o.FunctionHandle.create(e,[],null,t)]}),c}static frameName(e){var t,r;if(e.name)return e.name;const n=e.func;if(!n)return"";switch(n.type){case"BUILTIN":return null!==(t=this.metadataString(n.node,"id"))&&void 0!==t?t:"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return null!==(r=this.metadataString(n.node,"id"))&&void 0!==r?r:"<function>";default:return""}}static frameFile(e){var t,r;return null!==(r=this.metadataString(null===(t=e.func)||void 0===t?void 0:t.node,"sourceName"))&&void 0!==r?r:""}static dbstackResult(e,t,r){const o=this.dbstackSkip(e,r),l=t.filter(e=>{var t,r;return"FCNDEF"===(null===(t=e.func)||void 0===t?void 0:t.type)||"LAMBDA"===(null===(r=e.func)||void 0===r?void 0:r.type)}).slice().reverse().slice(o),c=new i.MultiArray([l.length,1]);return c.array=l.map(e=>{var t,r,i;return[new a.Structure({file:new n.CharString(this.frameFile(e)),name:new n.CharString(this.frameName(e)),line:s.Complex.create(null!==(i=null===(r=null===(t=e.callSite)||void 0===t?void 0:t.start)||void 0===r?void 0:r.line)&&void 0!==i?i:0)})]}),c.type=a.Structure.STRUCTURE,c}static nearestFunctionFrame(e){var t;let r=e;for(;r&&"FCNDEF"!==(null===(t=r.func)||void 0===t?void 0:t.type);)r=r.parentFrame;return r}static dbstackSkip(e,t){let r=0;for(const a of e){const e=i.MultiArray.isInstanceOf(a)&&i.MultiArray.isScalar(a)?i.MultiArray.firstElement(a):a;if(s.Complex.isInstanceOf(e)){const n=s.Complex.realToNumber(e);(!s.Complex.imagIsZero(e)||!Number.isInteger(n)||n<0)&&t("dbstack: omitted frame count must be a nonnegative integer."),r=n}else n.CharString.isInstanceOf(e)?"-completenames"!==e.str&&t(`dbstack: unsupported option '${e.str}'.`):t("dbstack: arguments must be a frame count or option string.")}return r}}},2951(e,t,r){"use strict";t.FunctionLookup=void 0;const n=r(5956),s=r(6816),i=r(7679),a=r(5212),o=r(1271);class l{static existCode(e,t,r,n,i=!1,a=!1){const o=null==t?void 0:t.trim().toLowerCase(),l=r&&void 0!==r.node&&!s.ClassDefinition.isInstanceOf(r.node)?1:0,c="FCNDEF"===(null==n?void 0:n.type)?2:"BUILTIN"===(null==n?void 0:n.type)?5:0,u=i||r&&s.ClassDefinition.isInstanceOf(r.node)||this.isRuntimeClassName(e)?8:0,h=a?2:0;switch(o){case void 0:return l||c||u||h;case"var":case"variable":return l;case"builtin":return 5===c?5:0;case"file":return 2===c?2:5===c?5:h;case"function":return 2===c?2:5===c?5:0;case"class":return u;default:return 0}}static existCodeFromResolution(e,t,r){const n="variable"===(null==r?void 0:r.kind)?r.entry:void 0,s="function"===(null==r?void 0:r.kind)||"builtin"===(null==r?void 0:r.kind)?r.functionDefinition:void 0,i="class"===(null==r?void 0:r.kind),a="script"===(null==r?void 0:r.kind),o="function"===(null==r?void 0:r.kind)&&!r.functionDefinition,l="class"===(null==r?void 0:r.kind)&&!r.classDefinition;if("directory"===(null==r?void 0:r.kind))switch(null==t?void 0:t.trim().toLowerCase()){case void 0:case"dir":case"file":return 7;default:return 0}if(o)switch(null==t?void 0:t.trim().toLowerCase()){case void 0:case"file":case"function":return 2;default:return 0}if(l)switch(null==t?void 0:t.trim().toLowerCase()){case void 0:case"class":return 8;case"file":return 2;default:return 0}return this.existCode(e,t,n,s,i,a)}static whichResult(e,t,r,i,a,o=!1,l=!1,c){var u;return i&&!i.id?new n.CharString(`${a(i).trim()} is an anonymous function`):i||!t||void 0===t.node||s.ClassDefinition.isInstanceOf(t.node)?"FCNDEF"===(null==r?void 0:r.type)?new n.CharString(`${e} is a ${(null===(u=r.attributes)||void 0===u?void 0:u.nested)?"nested":"user-defined"} function`):"BUILTIN"===(null==r?void 0:r.type)?new n.CharString(`${r.id} is a built-in function`):c?new n.CharString(`${c.className}.${c.methodName} is a static method`):o||t&&s.ClassDefinition.isInstanceOf(t.node)||this.isRuntimeClassName(e)?new n.CharString(`${e} is a class`):l?new n.CharString(`${e} is a script`):new n.CharString(`${e} not found`):new n.CharString(`${e} is a variable`)}static whichResultFromResolution(e,t,r,s,i){if("function"===(null==t?void 0:t.kind)&&!t.functionDefinition)return new n.CharString(`${e} is a user-defined function`);if("directory"===(null==t?void 0:t.kind))return new n.CharString(`${e} is a folder`);const a="variable"===(null==t?void 0:t.kind)?t.entry:void 0,o="function"===(null==t?void 0:t.kind)||"builtin"===(null==t?void 0:t.kind)?t.functionDefinition:void 0;return this.whichResult(e,a,o,r,s,"class"===(null==t?void 0:t.kind),"script"===(null==t?void 0:t.kind),i)}static func2str(e,t){var r;return new n.CharString(null!==(r=e.id)&&void 0!==r?r:t(e).trim())}static str2func(e,t,r){const n=e.trim();if(0===n.length&&r("str2func: function name cannot be empty."),!n.startsWith("@"))return o.FunctionHandle.create(n);const s=t(n);return o.FunctionHandle.isInstanceOf(s)||r("str2func: invalid function handle string."),s}static functionsInfo(e,t,r,s,o=()=>i.MultiArray.emptyArray(!0),l=()=>{}){var c,u,h,d,m,p;let f="anonymous",g=null!==(c=e.sourceName)&&void 0!==c?c:"";if(e.id){const n=t(e.id),s=null!==(h=null===(u=e.closure)||void 0===u?void 0:u.resolveFunction(n))&&void 0!==h?h:r(e.id);if("FCNDEF"===(null==s?void 0:s.type))f=(null===(d=s.attributes)||void 0===d?void 0:d.nested)?"nested":"simple",g=null!==(m=s.sourceName)&&void 0!==m?m:"";else{const t=l(e.id,e);f="simple",g=null!==(p=null==t?void 0:t.sourceName)&&void 0!==p?p:g}}const y="simple"===f?i.MultiArray.emptyArray(!0):o(e);return new a.Structure({function:this.func2str(e,s),type:new n.CharString(f),file:new n.CharString(g),workspace:y})}static resolveHandleFunction(e,t,r,n){var s,i;const a=r(t);return null!==(i=null===(s=e.closure)||void 0===s?void 0:s.resolveFunction(a))&&void 0!==i?i:n(t)}static isRuntimeClassName(e){return this.runtimeClassNames.has(e)}}t.FunctionLookup=l,l.runtimeClassNames=new Set(["double","single","logical","char","cell","struct","function_handle","event.listener","event.proplistener","event.EventData","event.PropertyEvent","handle","meta.class","meta.property","meta.method","meta.event","meta.EnumerationMember","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"])},491(e,t,r){"use strict";t.FunctionSignature=void 0;const n=r(9170);t.FunctionSignature=class{static inputSignatures(e){var t;const r=null===(t=e.signature)||void 0===t?void 0:t.inputs;return r?Array.isArray(r)?r:[r]:[]}static outputSignatures(e){var t;const r=null===(t=e.signature)||void 0===t?void 0:t.outputs;return r?Array.isArray(r)?r:[r]:[]}static arityMinimum(e){var t;return null!==(t=e.min)&&void 0!==t?t:e.arity<0?Math.max(Math.abs(e.arity)-1,0):e.arity}static arityMaximum(e){var t;return null!==(t=e.max)&&void 0!==t?t:e.arity<0?1/0:e.arity}static variadicPosition(e,t=!1){var r,n;const s=null!==(n=null===(r=e.parameters)||void 0===r?void 0:r.findIndex(e=>e.variadic))&&void 0!==n?n:-1;return t&&s>=0?s+1:e.arity<0?Math.abs(e.arity):s>=0?s+1:void 0}static declaredArity(e){if(0===e.length)return;const t=e.map(e=>this.arityMinimum(e)),r=e.map(e=>this.arityMaximum(e));if(!r.some(e=>e===1/0)&&t.every((e,t)=>e===r[t])&&t.every(e=>e===t[0]))return t[0];if(r.some(e=>e===1/0)){const t=e.filter((e,t)=>r[t]===1/0).map(t=>this.variadicPosition(t,e.length>1)).filter(e=>"number"==typeof e);if(t.length>0)return-Math.min(...t)}const n=r.filter(e=>e!==1/0);return n.length>0?-Math.max(...n):-Math.max(...e.map(e=>{var t;return null!==(t=this.variadicPosition(e))&&void 0!==t?t:Math.abs(e.arity)}))}static arityMatches(e,t){const r=this.arityMinimum(e),n=this.arityMaximum(e);return t>=r&&t<=n}static matchingInputSignatures(e,t){return this.inputSignatures(e).filter(e=>this.arityMatches(e,t))}static inputArityIsValid(e,t){const r=this.inputSignatures(e);return 0===r.length||r.some(e=>this.arityMatches(e,t))}static inputParametersAreValid(e,t){const r=this.matchingInputSignatures(e,t.length);return 0===r.length||r.some(e=>n.FunctionValidation.argumentsMatchBuiltInParameters(t,e.parameters))}}},9217(e,t,r){"use strict";t.FunctionStack=void 0;const n=r(6028);t.FunctionStack=class{static currentFunctionDefinition(e){var t,r;return null===(r=null===(t=this.currentFunctionFrame(e))||void 0===t?void 0:t.func)||void 0===r?void 0:r.node}static currentFunctionFrame(e){var t;for(let r=e.length-1;r>=0;r--)if("FCNDEF"===(null===(t=e[r].func)||void 0===t?void 0:t.type))return e[r]}static currentFunctionCountFrame(e){var t;for(let r=e.length-1;r>=0;r--){const n=null===(t=e[r].func)||void 0===t?void 0:t.type;if("FCNDEF"===n||"LAMBDA"===n)return e[r]}}static currentFunctionName(e){var t,r;return null!==(r=null===(t=this.currentFunctionFrame(e))||void 0===t?void 0:t.name)&&void 0!==r?r:""}static currentArgumentCount(e){var t;return null===(t=this.currentFunctionCountFrame(e))||void 0===t?void 0:t.nargin}static currentOutputCount(e){var t;return null===(t=this.currentFunctionCountFrame(e))||void 0===t?void 0:t.nargout}static callerWorkspace(e,t,r,n=!1,s=!1){var i,a;const o=this.currentFunctionCountFrame(e);if("LAMBDA"===(null===(i=null==o?void 0:o.func)||void 0===i?void 0:i.type)&&!n&&s)return this.anonymousCallerWorkspace(o,t,r);const l=this.skipBuiltInFrames(null==o?void 0:o.parentFrame),c=null!==(a=null==l?void 0:l.scope)&&void 0!==a?a:t;return!n&&s?this.variableOnlyCallerWorkspace(c,r):c}static anonymousCallerWorkspace(e,t,r){var n;const s=this.skipBuiltInFrames(e.parentFrame),i=r(),a=new Map;return this.copyVisibleVariablesWithSources(i,null!==(n=null==s?void 0:s.scope)&&void 0!==n?n:t,a),this.copyVisibleVariablesWithSources(i,e.scope,a),i.rejectDynamicNameCreation=e.scope.rejectDynamicNameCreation,i.staticWorkspaceNameSet=e.scope.staticWorkspaceNameSet?new Set(e.scope.staticWorkspaceNameSet):void 0,i.globalDeclarationTarget=e.scope,this.attachVariableOnlyWriteThrough(i,t=>{var r;return null!==(r=a.get(t))&&void 0!==r?r:e.scope}),i}static variableOnlyCallerWorkspace(e,t){const r=t();return n.FunctionWorkspace.copyVisibleScopeEntries(r,e,!1),r.rejectDynamicNameCreation=e.rejectDynamicNameCreation,r.staticWorkspaceNameSet=e.staticWorkspaceNameSet?new Set(e.staticWorkspaceNameSet):void 0,r.globalDeclarationTarget=e,this.attachVariableOnlyWriteThrough(r,()=>e),r}static copyVisibleVariablesWithSources(e,t,r){const n=[];let s=t;for(;s&&(n.push(s),s.resolveParentNames);)s=s.parent;for(let t=n.length-1;t>=0;t--){const s=n[t];Object.assign(e.nameTable,s.nameTable);for(const e of Object.keys(s.nameTable))r.set(e,s)}}static attachVariableOnlyWriteThrough(e,t){const r=(t,r)=>{const n=t.rejectDynamicNameCreation;e.rejectDynamicNameCreation&&(t.rejectDynamicNameCreation=!0);try{return r()}finally{t.rejectDynamicNameCreation=n}};e.defineName=(n,s,i)=>{const a=t(n),o=r(a,()=>a.defineName(n,s,i));return e.nameTable[n]=o,o},e.assignName=(n,s,i)=>{var a;const o=t(n),l=null===(a=o.assignName)||void 0===a?void 0:a.bind(o),c=r(o,()=>l?l(n,s,i):o.defineName(n,s,i));return e.nameTable[n]=c,c},e.removeName=r=>{const n=t(r);n.removeName?n.removeName(r):delete n.nameTable[r],delete e.nameTable[r]},e.clearName=r=>{const n=t(r);n.clearName?n.clearName(r):n.removeName?n.removeName(r):delete n.nameTable[r],delete e.nameTable[r]}}static skipBuiltInFrames(e){for(var t;"BUILTIN"===(null===(t=null==e?void 0:e.func)||void 0===t?void 0:t.type);)e=e.parentFrame;return e}}},9170(e,t,r){"use strict";t.FunctionValidation=void 0;const n=r(5956),s=r(845),i=r(1271),a=r(7679),o=r(5212),l=r(9770),c=r(7325),u=r(5577),h=r(169),d=r(482),m=r(7268),p=r(8146),f=r(1604);class g{static className(e){if(s.Complex.isInstanceOf(e))return e.type===s.Complex.LOGICAL?"logical":"double";if(n.CharString.isInstanceOf(e))return n.CharString.isChar(e)?"char":"string";if(i.FunctionHandle.isInstanceOf(e))return"function_handle";if(u.ClassEventListener.isInstanceOf(e))return e.kind;if(d.ClassPropertyEvent.isInstanceOf(e))return"event.PropertyEvent";if(h.ClassEventData.isInstanceOf(e))return"event.EventData";if(m.ClassMetaObject.isInstanceOf(e))return e.kind;if(l.ClassInstance.isInstanceOf(e))return e.classDefinition.name;if(c.ClassEnumerationValue.isInstanceOf(e))return e.classDefinition.name;if(o.Structure.isStructure(e))return"struct";if(a.MultiArray.isInstanceOf(e)){if(e.isCell)return"cell";const t=a.MultiArray.linearize(e);return t.every(e=>s.Complex.isInstanceOf(e))?t.length>0&&t.every(e=>e.type===s.Complex.LOGICAL)?"logical":"double":t.length>0&&t.every(n.CharString.isChar)?"char":t.length>0&&t.every(n.CharString.isString)?"string":"array"}return"unknown"}static underlyingType(e){return this.className(e)}static numericElements(e,t={}){const r=e=>s.Complex.isInstanceOf(e)&&(t.includeLogical||e.type!==s.Complex.LOGICAL);if(s.Complex.isInstanceOf(e))return r(e)?[e]:void 0;if(a.MultiArray.isInstanceOf(e)&&!e.isCell){const t=a.MultiArray.linearize(e);return t.every(r)?t:void 0}}static isLogicalValue(e){const t=this.numericElements(e,{includeLogical:!0});return Boolean(t&&t.length>0&&t.every(e=>e.type===s.Complex.LOGICAL))}static isCharArray(e){if(n.CharString.isChar(e))return!0;if(!a.MultiArray.isInstanceOf(e)||e.isCell)return!1;const t=a.MultiArray.linearize(e);return t.length>0&&t.every(n.CharString.isChar)}static isStringArray(e){if(n.CharString.isString(e))return!0;if(!a.MultiArray.isInstanceOf(e)||e.isCell)return!1;const t=a.MultiArray.linearize(e);return t.length>0&&t.every(n.CharString.isString)}static isCellStringArray(e){if(!a.MultiArray.isInstanceOf(e)||!e.isCell)return!1;const t=a.MultiArray.linearize(e);return t.length>0&&t.every(n.CharString.isChar)}static isTextValue(e){return this.isCharArray(e)||this.isStringArray(e)||this.isCellStringArray(e)}static isTextScalarValue(e){if(n.CharString.isInstanceOf(e))return!0;if(!a.MultiArray.isInstanceOf(e)||e.isCell||1!==f.RuntimeValue.elementCount(e))return!1;const t=a.MultiArray.firstElement(e);return n.CharString.isString(t)}static textElements(e){if(n.CharString.isInstanceOf(e))return[e.str];if(a.MultiArray.isInstanceOf(e)){const t=a.MultiArray.linearize(e);return t.length>0&&t.every(n.CharString.isInstanceOf)?t.map(e=>e.str):void 0}}static variableNameElements(e){if(n.CharString.isInstanceOf(e))return[e.str];if(!a.MultiArray.isInstanceOf(e)||!e.isCell)return;const t=a.MultiArray.linearize(e);return t.length>0&&t.every(n.CharString.isChar)?t.map(e=>e.str):void 0}static isValidVariableNameText(e){return/^[A-Za-z]\w*$/.test(e)&&e.length<=this.matlabNameLengthMax&&!this.reservedKeywords.has(e)}static matchesClass(e,t){switch(t){case"double":case"single":return Boolean(this.numericElements(e));case"logical":return this.isLogicalValue(e);case"char":return this.isCharArray(e);case"string":return this.isStringArray(e);case"cell":return a.MultiArray.isInstanceOf(e)&&e.isCell;case"array":return a.MultiArray.isInstanceOf(e);case"struct":return o.Structure.isStructure(e);case"function_handle":return i.FunctionHandle.isInstanceOf(e);default:return!1}}static normalizeValidators(e=[]){const t=new Set(e),r=(...e)=>{for(const r of e)t.delete(r)};return t.has("dimensionGreaterThanOne")&&r("numeric","scalar","real","finite","integer","positive","nonnegative","dimension"),t.has("dimension")&&r("numeric","scalar","real","finite","integer","nonnegative"),t.has("dimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),t.has("reshapeDimension")&&r("numeric","scalar","scalarOrEmpty","real","finite","integer","nonnegative"),t.has("reshapeDimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),t.has("positive")&&r("nonnegative"),t.has("negative")&&r("nonpositive"),t.has("zeroOrOne")&&r("nonnegative"),t.has("textScalar")&&r("text","scalar","scalarOrEmpty","scalarOrVector"),t.has("squareMatrix")&&r("matrix2d"),t.has("scalar")&&r("scalarOrEmpty","scalarOrVector"),[...t]}static isDimensionValue(e,t){if(f.RuntimeValue.isEmpty(e))return t;const r=this.numericElements(e);return Boolean(r&&r.every(e=>s.Complex.imagIsZero(e)&&s.Complex.realIsFinite(e)&&s.Complex.realIsInteger(e)&&s.Complex.realGreaterThanOrEqualTo(e,0)))}static isDimensionVector(e,t){if(!f.RuntimeValue.isVector(e))return!1;const r=a.MultiArray.linearize(e),n=r.map(p.optionalRuntimeExpressionValue);return r.length>0&&n.every(e=>void 0!==e)&&n.every(e=>this.isDimensionValue(e,t))}static matchesParameter(e,t){return!(t.classes&&t.classes.length>0&&!t.classes.some(t=>this.matchesClass(e,t)))&&!(t.allowedStrings&&t.allowedStrings.length>0&&(!n.CharString.isInstanceOf(e)||!t.allowedStrings.includes(e.str)))&&!!(!t.identifier||n.CharString.isInstanceOf(e)&&this.isValidVariableNameText(e.str))&&this.normalizeValidators(t.validators).every(r=>this.matchesBuiltInValidator(e,r,t.allowInfinity))}static matchesBuiltInParameterBase(e,t){const r=this.normalizeValidators(t.validators),n=new Set(["dimension","dimensionGreaterThanOne","dimensionVector","reshapeDimension","reshapeDimensionVector"]),i=Object.assign(Object.assign({},t),{validators:r.filter(e=>!n.has(e))});return!!this.matchesParameter(e,i)&&r.every(t=>{switch(t){case"dimension":return f.RuntimeValue.isScalar(e)&&this.isDimensionValue(e,!1);case"dimensionGreaterThanOne":return f.RuntimeValue.isScalar(e)&&this.isDimensionValue(e,!1)&&s.Complex.realGreaterThan(a.MultiArray.firstElement(e),1);case"dimensionVector":return this.isDimensionVector(e,!1);case"reshapeDimension":return(f.RuntimeValue.isScalar(e)||f.RuntimeValue.isEmpty(e))&&this.isDimensionValue(e,!0);case"reshapeDimensionVector":return this.isDimensionVector(e,!0);default:return!0}})}static matchesBuiltInParameter(e,t){var r,n,s,i;const a=null!==(r=t.alternatives)&&void 0!==r?r:[];return(Boolean((null===(n=t.classes)||void 0===n?void 0:n.length)||(null===(s=t.validators)||void 0===s?void 0:s.length)||(null===(i=t.allowedStrings)||void 0===i?void 0:i.length)||t.identifier)||0===a.length)&&this.matchesBuiltInParameterBase(e,t)||a.some(t=>this.matchesBuiltInParameter(e,t))}static argumentsMatchBuiltInParameters(e,t){if(!t)return!0;for(let r=0;r<e.length;r++){const n=t[Math.min(r,t.length-1)];if(!n||r>=t.length&&!n.variadic)continue;const s=n.variadic&&n.variadicGroup&&n.variadicGroup.length>0?n.variadicGroup[(r-Math.min(r,t.length-1))%n.variadicGroup.length]:n;if(!this.matchesBuiltInParameter(e[r],s))return!1}return!0}static matchesBuiltInValidator(e,t,r=!1){var i,o,l,c,u,h,d,m,p,g;const y=this.numericElements(e),x=()=>this.numericElements(e,{includeLogical:!0}),C=e=>Boolean(r&&s.Complex.imagIsZero(e)&&s.Complex.realToNumber(e)===1/0);switch(t){case"numeric":case"float":return Boolean(y);case"numericOrLogical":return Boolean(this.numericElements(e,{includeLogical:!0}));case"text":return this.isTextValue(e);case"textScalar":return this.isTextScalarValue(e);case"nonzeroLengthText":{const t=this.textElements(e);return Boolean(t&&t.length>0&&t.every(e=>e.length>0))}case"validVariableName":{const t=this.variableNameElements(e);return Boolean(t&&t.length>0&&t.every(e=>this.isValidVariableNameText(e)))}case"scalar":return f.RuntimeValue.isScalar(e);case"scalarOrEmpty":return f.RuntimeValue.isScalar(e)||f.RuntimeValue.isEmpty(e);case"scalarOrVector":return f.RuntimeValue.isScalar(e)||f.RuntimeValue.isVector(e);case"empty":return f.RuntimeValue.isEmpty(e);case"matrix2d":return f.RuntimeValue.isMatrix(e);case"squareMatrix":return f.RuntimeValue.isSquareMatrix(e);case"vector":return f.RuntimeValue.isVector(e);case"rowVector":return f.RuntimeValue.isRowVector(e);case"columnVector":return f.RuntimeValue.isColumnVector(e);case"twoElement":return 2===f.RuntimeValue.elementCount(e);case"oneOrTwoElement":{const t=f.RuntimeValue.elementCount(e);return 1===t||2===t}case"nonempty":return!f.RuntimeValue.isEmpty(e);case"positive":return Boolean(null===(i=x())||void 0===i?void 0:i.every(e=>C(e)||s.Complex.imagIsZero(e)&&s.Complex.realGreaterThan(e,0)));case"nonnegative":return Boolean(null===(o=x())||void 0===o?void 0:o.every(e=>C(e)||s.Complex.imagIsZero(e)&&s.Complex.realGreaterThanOrEqualTo(e,0)));case"negative":return Boolean(null===(l=x())||void 0===l?void 0:l.every(e=>s.Complex.imagIsZero(e)&&s.Complex.realLessThan(e,0)));case"nonpositive":return Boolean(null===(c=x())||void 0===c?void 0:c.every(e=>s.Complex.imagIsZero(e)&&s.Complex.realLessThanOrEqualTo(e,0)));case"nonzero":return Boolean(null===(u=x())||void 0===u?void 0:u.every(e=>0!==s.Complex.realToNumber(e)||0!==s.Complex.imagToNumber(e)));case"nonnan":return!!n.CharString.isInstanceOf(e)||Boolean(null===(h=x())||void 0===h?void 0:h.every(e=>!s.Complex.realIsNaN(e)&&!s.Complex.imagIsNaN(e)));case"nonmissing":{const t=x();if(t)return t.every(e=>!s.Complex.realIsNaN(e)&&!s.Complex.imagIsNaN(e));if(n.CharString.isInstanceOf(e))return!0;if(a.MultiArray.isInstanceOf(e)){const t=a.MultiArray.linearize(e);return e.isCell?t.every(e=>!n.CharString.isChar(e)||e.str.length>0):t.length>0&&t.every(n.CharString.isInstanceOf)}return!0}case"nonsparse":return!0;case"sparse":default:return!1;case"zeroOrOne":return Boolean(null===(d=x())||void 0===d?void 0:d.every(e=>s.Complex.imagIsZero(e)&&(0===s.Complex.realToNumber(e)||1===s.Complex.realToNumber(e))));case"integer":return Boolean(null===(m=x())||void 0===m?void 0:m.every(e=>C(e)||s.Complex.imagIsZero(e)&&s.Complex.realIsInteger(e)));case"finite":return Boolean(null===(p=x())||void 0===p?void 0:p.every(e=>s.Complex.realIsFinite(e)&&s.Complex.imagIsFinite(e)));case"real":return Boolean(null===(g=x())||void 0===g?void 0:g.every(e=>s.Complex.imagIsZero(e)))}}static builtInValidatorForArgumentValidator(e){switch(e){case"mustBeNumeric":return"numeric";case"mustBeFloat":return"float";case"mustBeNumericOrLogical":return"numericOrLogical";case"mustBeText":return"text";case"mustBeTextScalar":return"textScalar";case"mustBeNonzeroLengthText":return"nonzeroLengthText";case"mustBeValidVariableName":return"validVariableName";case"mustBeScalarOrEmpty":return"scalarOrEmpty";case"mustBeScalar":return"scalar";case"mustBeMatrix":return"matrix2d";case"mustBeSquare":return"squareMatrix";case"mustBeVector":return"vector";case"mustBeRow":return"rowVector";case"mustBeColumn":return"columnVector";case"mustBeNonempty":return"nonempty";case"mustBePositive":return"positive";case"mustBeNonnegative":return"nonnegative";case"mustBeNegative":return"negative";case"mustBeNonpositive":return"nonpositive";case"mustBeNonzero":return"nonzero";case"mustBeNonNan":return"nonnan";case"mustBeNonmissing":return"nonmissing";case"mustBeNonsparse":return"nonsparse";case"mustBeSparse":return"sparse";case"mustBeInteger":return"integer";case"mustBeFinite":return"finite";case"mustBeReal":return"real";default:return}}}t.FunctionValidation=g,g.matlabNameLengthMax=2048,g.reservedKeywords=new Set(["global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","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","endarguments"])},6028(e,t,r){"use strict";t.FunctionWorkspace=void 0;const n=r(6109),s=r(5956),i=r(845),a=r(8146),o=r(7679),l=r(1604);t.FunctionWorkspace=class{static ensurePersistentTable(e){return e.attributes||(e.attributes={}),e.attributes.persistent||(e.attributes.persistent=Object.create(null)),e.attributes.persistent}static copyVisibleScopeEntries(e,t,r=!0){if(!t)return;const n=[];let s=t;for(;s&&(n.unshift(s),s.resolveParentNames);)s=s.parent;for(const t of n)Object.assign(e.nameTable,t.nameTable),r&&Object.assign(e.functionTable,t.functionTable)}static inputName(e,t,r,a=!0,l){const c=o.MultiArray.isInstanceOf(t)&&o.MultiArray.isScalar(t)?o.MultiArray.firstElement(t):t;i.Complex.isInstanceOf(c)&&i.Complex.imagIsZero(c)||r("inputname: argument number must be a positive integer.");const u=i.Complex.realToNumber(c);(!Number.isInteger(u)||u<1)&&r("inputname: argument number must be a positive integer.");const h=e[u-1];return h?n.AST.isNodeIdentifier(h)?new s.CharString(h.id):new s.CharString(!a&&l?l(h).trim():""):new s.CharString("")}static resolveWorkspace(e,t,r,n){switch(e){case"base":return t;case"caller":return r;default:n(`unsupported workspace '${e}'.`)}}static evaluateWithCatch(e,t,r,n,s=()=>!0,i){try{return n(t,e)}catch(t){if(void 0===r||!s(t))throw t;return null==i||i(t),n(r,e)}}static assignIn(e,t,r){const s=l.RuntimeValue.copy(r);return e.assignName?e.assignName(t,s):e.defineName(t,s),n.AST.nodeVoid()}static declarePersistent(e,t,r,s){var i,a;const o=this.ensurePersistentTable(r);(null===(a=null===(i=s.nameTable)||void 0===i?void 0:i[e])||void 0===a?void 0:a.persistent)||(void 0!==t&&void 0===o[e]?o[e]=l.RuntimeValue.copy(t):void 0===o[e]&&(o[e]=n.AST.emptyArray()),s.defineName(e,l.RuntimeValue.copy(o[e])).persistent=!0)}static loadPersistentVariables(e,t){const r=this.ensurePersistentTable(e);for(const e of Object.keys(r))void 0===r[e]&&(r[e]=n.AST.emptyArray()),t.defineName(e,l.RuntimeValue.copy(r[e])).persistent=!0}static storePersistentVariables(e,t){const r=this.ensurePersistentTable(e);for(const e of Object.keys(r)){const n=t.hasLocalName(e)?t.nameTable[e]:void 0;n&&void 0!==n.node&&(r[e]=l.RuntimeValue.copy((0,a.runtimeExpressionValue)(n.node,e,"persistent variable",e=>{throw new EvalError(e)})))}}static declareGlobal(e,t,r,s,i,a){r.add(e);let o=s[e];o||(o=s[e]={}),o.global=!0;const c=Boolean(o.globalInitialized||(null==a?void 0:a.has(e)));void 0===t||c?void 0===o.node&&(o.node=n.AST.emptyArray()):(o.node=l.RuntimeValue.copy(t),delete o.undefinedReference,o.globalInitialized=!0,null==a||a.add(e)),i[e]=o}static clearGlobalVariables(e,t,r,n){const s=n?n.filter(t=>e.has(t)):[...e],i=new Set,a=e=>{for(var t;e&&!i.has(e);){i.add(e);for(const r of s)(null===(t=e.nameTable[r])||void 0===t?void 0:t.global)&&delete e.nameTable[r];for(const t of Object.values(e.functionTable))a(t.definingScope);e=e.parent}};a(t);for(const e of r)a(e);if(n)for(const t of s)e.delete(t);else e.clear()}}},7727(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Interpreter=t.Context=t.SyntaxError=t.CircularReferenceError=t.UndefinedReferenceError=t.ReferenceError=t.EvalError=t.InterpreterError=t.CallFrame=t.Scope=t.TableSourceResolver=t.ManifestSourceResolver=void 0;const s=r(3222),i=n(r(2207)),a=n(r(6770)),o=r(7645),l=r(6430),c=r(6109),u=r(5956),h=r(845),d=r(7679),m=r(5212),p=r(1271),f=r(6816),g=r(9770),y=r(9656),x=r(8986),C=r(3226),E=r(7325),v=r(5577),A=r(169),S=r(482),_=r(7268),b=r(6554),T=r(2424),M=r(3717),N=r(4087),I=r(4610),L=r(9947),w=r(7686),O=r(9170),R=r(8989),D=r(164),F=r(6028),P=r(8342),k=r(2951),V=r(7673),U=r(1604),$=r(2981);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return $.Scope}});const B=r(3812);Object.defineProperty(t,"CallFrame",{enumerable:!0,get:function(){return B.CallFrame}});const H=r(3225),j=r(9274),q=r(7162);Object.defineProperty(t,"Context",{enumerable:!0,get:function(){return q.Context}});const z=r(1201);Object.defineProperty(t,"CircularReferenceError",{enumerable:!0,get:function(){return z.CircularReferenceError}}),Object.defineProperty(t,"EvalError",{enumerable:!0,get:function(){return z.EvalError}}),Object.defineProperty(t,"InterpreterError",{enumerable:!0,get:function(){return z.InterpreterError}}),Object.defineProperty(t,"ReferenceError",{enumerable:!0,get:function(){return z.ReferenceError}}),Object.defineProperty(t,"SyntaxError",{enumerable:!0,get:function(){return z.SyntaxError}}),Object.defineProperty(t,"UndefinedReferenceError",{enumerable:!0,get:function(){return z.UndefinedReferenceError}});const G=r(8146);class W{get debug(){return this._debug}set debug(e){this._debug=e}refreshCommandWordListNames(){this.commandWordListNameSet=new Set(Object.keys(this.commandWordListTable)),this.assignmentSensitiveCommandNameSet=new Set(Object.entries(this.commandWordListTable).filter(([,e])=>e.preserveAssignment).map(([e])=>e))}get exitStatus(){return this._exitStatus}incDecOpFactory(e,t){return(r,n)=>{const s=e?void 0:U.RuntimeValue.copy(this.evaluatedExpressionValue(r,n,("plus"===t?"increment":"decrement")+" target")),i=c.AST.nodeOperation("plus"===t?"+=":"-=",this.cloneAssignmentTarget(r),h.Complex.one());return i.parent=r.parent,this.Evaluator(i,n),e?this.evaluatedExpressionValue(r,n,("plus"===t?"increment":"decrement")+" target"):s}}nodePrecedence(e){if("number"==typeof e.type)return h.Complex.isInstanceOf(e)?h.Complex.precedence(e,this):this.precedenceTable.max;if(c.AST.isNodeIndexExpr(e)){const t=c.AST.isNodeIdentifier(e.expr)?this.context.aliasNameFunction(e.expr.id):"";return c.AST.isNodeIdentifier(e.expr)&&t in this.context.builtInFunctionTable&&(this.context.builtInFunctionTable[t].UnparserMathML||t in w.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}functionArityCallable(e,t){let r;if(p.FunctionHandle.isInstanceOf(t))r=t;else if(u.CharString.isInstanceOf(t)){const n=t.str.trim();0===n.length&&this.context.throwEvalError(`${e}: function name cannot be empty.`),r=n.startsWith("@")?this.functionHandleFromString(t):this.createResolvedFunctionHandle(n,this.context.currentScope,void 0,!1,!0)}else this.context.throwSyntaxError(`${e}: argument must be a function handle or function name.`);const n=this.context.resolveCallable(r);return n||this.context.throwEvalError(`${e}: invalid function.`),n}functionArgumentArity(e){return D.FunctionArity.inputArity(e)}functionOutputArity(e){return D.FunctionArity.outputArity(e)}functionHandleFromString(e,t=!1){var r;const n=null!==(r=this.context.globalScope)&&void 0!==r?r:this.context.currentScope,s=t?n:this.context.currentScope,i=k.FunctionLookup.str2func(e.str,e=>{const t=this.evaluatedExecutionResult(this.Parse(e),n);return"LIST"===t.type&&1===t.list.length?t.list[0]:t},e=>this.context.throwEvalError(e));if(!i.id||i.closure)return i;if(!t){const e=this.createResolvedFunctionHandle(i.id,s,i,"importsOnly");if(e.closure)return e}return this.createResolvedFunctionHandle(i.id,n,i,"global")}resolveRuntimeSymbol(e,t=this.context.currentScope,r={}){return this.context.resolveSymbol(e,t,r)}resolveRuntimeFunction(e,t=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(e,t,Object.assign(Object.assign({},r),{variables:!1,classes:!1}))}resolveRuntimeClass(e,t=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(e,t,Object.assign(Object.assign({},r),{variables:!1,functions:!1}))}createResolvedFunctionHandle(e,t=this.context.currentScope,r,n=!1,s=!1){var i;const a=this.resolveRuntimeFunction(e,t,{loadFunctions:!1}),o=(null==a?void 0:a.functionDefinition)?void 0:this.lookupFunctionSourceResolution(e,t),l=null!=a?a:o,c=this.context.aliasNameFunction(e),u=e.includes(".")&&l?l.resolvedName:c,h=p.FunctionHandle.create(u);h.parent=r,h.sourceName=null==o?void 0:o.sourceName,h.disallowNestedResolution=s;const d=!e.includes(".")&&this.resolveImportedStaticMethod(e,t);return(!0===n?"FCNDEF"===(null===(i=null==a?void 0:a.functionDefinition)||void 0===i?void 0:i.type)||"import"===(null==o?void 0:o.source)||d:"importsOnly"===n&&("import"===(null==o?void 0:o.source)||d))&&(h.closure=t.capture(e=>b.MathOperation.copy(e),this.context.allowForwardReference)),"global"===n&&(h.closure=t),h}localFunctionHandles(){return P.FunctionIntrospection.localFunctionHandles(this.context.currentFrame,this.context.currentScope)}functionHandleWorkspaceValue(e,t){return this.runtimeExpressionValue(U.RuntimeValue.copy(e),`workspace ${t}`)}functionHandleWorkspaceInfo(e){if(!e.closure)return d.MultiArray.emptyArray(!0);const t={};for(const[r,n]of Object.entries(e.closure.nameTable))!n||n.global||void 0===n.node||f.ClassDefinition.isInstanceOf(n.node)||(t[r]=this.functionHandleWorkspaceValue(n.node,r));const r=d.MultiArray.scalarToMultiArray(new m.Structure(t));return r.isCell=!0,r}staticMethodInfo(e,t){const r=this.resolveStaticMethod(e,t);return r?{className:r.classDefinition.name,methodName:r.method.name,sourceName:r.method.node.sourceName}:void 0}dbstackResult(e){const t=P.FunctionIntrospection.dbstackResult(e,this.context.callStack,e=>this.context.throwSyntaxError(e));if(this.context.requestedOutputCount>1){const e=d.MultiArray.linearLength(t)>0?1:0;return this.valueReturnList([t,h.Complex.create(e)])}return t}currentMFilename(){var e;const t=this.currentHandleSourceName();return t&&(null===(e=t.replace(/\\/g,"/").split(/[?#]/,1)[0].split("/").pop())||void 0===e?void 0:e.replace(/\.m$/i,""))||this.context.currentFunctionName()}currentMFilenameFullPath(){return this.currentHandleSourceName()||this.context.currentFunctionName()}currentHandleSourceName(){return this.context.currentFunctionSourceName()||this.scriptSourceNameStack[this.scriptSourceNameStack.length-1]}currentHandleClassName(){return this.context.currentClassAccessName()||void 0}exceptionToStruct(e){var t,r;if(m.Structure.isInstanceOf(e))return m.Structure.copy(e);const n=e,s=void 0!==(null==n?void 0:n.publicStack)?this.runtimeExpressionValue(U.RuntimeValue.copy(n.publicStack),"error stack"):P.FunctionIntrospection.dbstackResult([],e instanceof z.InterpreterError&&e.stackFrames?e.stackFrames.slice().reverse():this.context.callStack,e=>this.context.throwSyntaxError(e));return new m.Structure({message:new u.CharString(null!==(t=null==n?void 0:n.message)&&void 0!==t?t:String(e)),identifier:new u.CharString(null!==(r=null==n?void 0:n.identifier)&&void 0!==r?r:""),stack:s})}lastErrorStruct(){return this.lastError?this.exceptionToStruct(this.lastError):this.emptyLastErrorStruct()}emptyLastErrorStruct(){return new m.Structure({message:new u.CharString(""),identifier:new u.CharString(""),stack:d.MultiArray.emptyArray()})}resetLastError(){this.lastError=void 0}rememberLastError(e){return this.lastError=e,this.exceptionToStruct(e)}normalizeLastErrorStruct(e){const t=e.field,r=void 0===t.message?new u.CharString(""):t.message,n=void 0===t.identifier?new u.CharString(""):t.identifier,s=void 0===t.stack?d.MultiArray.emptyArray():t.stack;return u.CharString.isInstanceOf(r)&&u.CharString.isInstanceOf(n)||this.context.throwEvalError("lasterror: error structure message and identifier fields must be strings."),new m.Structure({message:r,identifier:n,stack:this.runtimeExpressionValue(s,"error stack")})}lastErrorResult(e=[]){const t=this.lastErrorStruct();if(0===e.length)return t;if(u.CharString.isInstanceOf(e[0])&&"reset"===e[0].str)return this.resetLastError(),t;if(m.Structure.isInstanceOf(e[0]))return this.lastError=this.normalizeLastErrorStruct(e[0]),t;throw c.AST.throwInvalidCallError("lasterror"),new Error("unreachable")}lastErrorMessageResult(e=[]){e.length>0&&(this.lastError=this.normalizeLastErrorStruct(new m.Structure({message:this.charControlArgument(e[0],"error message"),identifier:2===e.length?this.charControlArgument(e[1],"error identifier"):new u.CharString("")})));const t=this.lastErrorStruct();return this.valueReturnList([this.charControlArgument(t.field.message,"error message"),this.charControlArgument(t.field.identifier,"error identifier")])}setLastWarning(e,t=""){this.lastWarning={message:e,identifier:t}}resetWarningState(){this.setLastWarning(""),this.globalWarningState="on",this.warningIdentifierStates.clear()}warningState(e="all"){var t;return"last"===e?this.warningState(this.lastWarning.identifier||"all"):"all"===e||0===e.length?this.globalWarningState:null!==(t=this.warningIdentifierStates.get(e))&&void 0!==t?t:this.globalWarningState}isWarningState(e){return"on"===e||"off"===e||"error"===e}warningStateStruct(e="all"){const t="last"===e?this.lastWarning.identifier||"all":e;return new m.Structure({identifier:new u.CharString(t),state:new u.CharString(this.warningState(t))})}warningStateSnapshot(){const e=[...this.warningIdentifierStates.keys()].sort(),t=[this.warningStateStruct("all"),...e.map(e=>this.warningStateStruct(e))];if(1===t.length)return t[0];const r=new d.MultiArray([t.length,1]);return t.forEach((e,t)=>{r.array[t][0]=e}),d.MultiArray.setType(r),r}warningStateStructParts(e){const t=e.field.identifier,r=e.field.state;return u.CharString.isInstanceOf(t)&&u.CharString.isInstanceOf(r)&&this.isWarningState(r.str)||this.context.throwEvalError("warning: state structure must contain string identifier and state fields."),{identifier:t.str,state:r.str}}restoreWarningState(e,t){const r="last"===e?this.lastWarning.identifier||"all":e;"all"===r||0===r.length?this.globalWarningState=t:this.warningIdentifierStates.set(r,t)}restoreWarningStateStruct(e){let t;if(m.Structure.isInstanceOf(e))t=[e];else{if(!d.MultiArray.isInstanceOf(e)||!m.Structure.isStructure(e))throw c.AST.throwInvalidCallError("warning"),new Error("unreachable");t=d.MultiArray.linearize(e).map(e=>{if(!m.Structure.isInstanceOf(e))throw c.AST.throwInvalidCallError("warning"),new Error("unreachable");return e})}for(const e of t){const t=this.warningStateStructParts(e);this.restoreWarningState(t.identifier,t.state)}return c.AST.nodeVoid()}warningControlResult(e){if(0===e.length)return this.warningStateSnapshot();if(1===e.length&&(m.Structure.isInstanceOf(e[0])||d.MultiArray.isInstanceOf(e[0])&&m.Structure.isStructure(e[0])))return this.restoreWarningStateStruct(e[0]);if(!u.CharString.isInstanceOf(e[0]))return;const t=e[0].str.toLowerCase();if(!this.isWarningState(t)&&"query"!==t)return;if(e.length>2||2===e.length&&!u.CharString.isInstanceOf(e[1]))return;const r=2===e.length?e[1].str:"all";if("query"===t)return 1===e.length?this.warningStateSnapshot():this.warningStateStruct(r);const n=this.warningStateStruct(r),s="last"===r?this.lastWarning.identifier||"all":r;return this.restoreWarningState(s,t),n}diagnosticMessageParts(e,t){return N.DiagnosticMessage.parts(e,t,(e,t)=>this.charControlArgument(e,t),{expressionValue:(e,t)=>this.expressionValue(e,t),unparse:e=>this.Unparse(e),throwEvalError:e=>this.context.throwEvalError(e)})}diagnosticCommandArguments(e){return e.length>1&&e[0].includes(":")?[new u.CharString(e[0]),new u.CharString(e.slice(1).join(" "))]:[new u.CharString(e.join(" "))]}warningResult(e){const t=this.warningControlResult(e);if(t)return t;const{identifier:r,message:n}=this.diagnosticMessageParts(e,"warning");if(this.setLastWarning(n,r),"error"===this.warningState(r))try{this.context.throwEvalError(n)}catch(e){throw r&&(e.identifier=r),e}return this._exitStatus=W.response.WARNING,c.AST.nodeVoid()}errorResult(e){var t,r;if(1===e.length&&m.Structure.isInstanceOf(e[0])){const n=this.charControlArgument(null!==(t=e[0].field.message)&&void 0!==t?t:new u.CharString(""),"error structure message").str,s=this.charControlArgument(null!==(r=e[0].field.identifier)&&void 0!==r?r:new u.CharString(""),"error structure identifier").str;if(!n)return c.AST.nodeVoid();try{this.context.throwEvalError(n)}catch(e){throw s&&(e.identifier=s),e}}const{identifier:n,message:s}=this.diagnosticMessageParts(e,"error");if(!n&&!s)return c.AST.nodeVoid();try{this.context.throwEvalError(s)}catch(e){throw n&&(e.identifier=n),e}}assertUsesDiagnosticForm(e){return 1===e.length||e.length>=2&&u.CharString.isInstanceOf(e[1])&&!u.CharString.isInstanceOf(e[0])}assertNumericElements(e,t){const r=d.MultiArray.scalarToMultiArray(e),n=d.MultiArray.linearize(r);return!r.isCell&&n.every(h.Complex.isInstanceOf)||this.context.throwEvalError(`assert: ${t} must be numeric when tolerance is specified.`),{dimensions:r.dimension.slice(),elements:n}}assertValuesEqualWithinTolerance(e,t,r){const n=this.assertNumericElements(e,"actual value"),s=this.assertNumericElements(t,"expected value");if(n.dimensions.length!==s.dimensions.length||n.dimensions.some((e,t)=>e!==s.dimensions[t]))return!1;const i=this.validateattributesNumericScalar(r,"assert tolerance"),a=Math.abs(i),o=i<0;return n.elements.every((e,t)=>{const r=s.elements[t],n=h.Complex.abs(h.Complex.sub(e,r));return h.Complex.realToNumber(n)<=(o?a*h.Complex.realToNumber(h.Complex.abs(r)):a)})}assertComparisonParts(e){return e.length<=2?{diagnostic:[]}:u.CharString.isInstanceOf(e[2])?{diagnostic:e.slice(2)}:{tolerance:e[2],diagnostic:e.slice(3)}}assertComparisonResult(e){c.AST.throwInvalidCallError("assert",e.length<2,e=>this.context.throwEvalError(e));const t=this.expressionValue(e[0],"assert actual value"),r=this.expressionValue(e[1],"assert expected value"),n=this.assertComparisonParts(e);return(n.tolerance?this.assertValuesEqualWithinTolerance(t,r,n.tolerance):V.RuntimeEquality.valuesEqual(t,r))?c.AST.nodeVoid():n.diagnostic.length>0?this.errorResult(n.diagnostic):void this.context.throwEvalError("assertion failed: observed value does not match expected value.")}assertResult(e){return c.AST.throwInvalidCallError("assert",0===e.length,e=>this.context.throwEvalError(e)),this.assertUsesDiagnosticForm(e)?this.toBoolean(this.expressionValue(e[0],"assert condition"))?c.AST.nodeVoid():(1===e.length&&this.context.throwEvalError("assertion failed."),this.errorResult(e.slice(1))):this.assertComparisonResult(e)}validationTextList(e,t,r){if(u.CharString.isInstanceOf(e))return[e.str];if(d.MultiArray.isInstanceOf(e)){const t=d.MultiArray.linearize(e);if(t.every(u.CharString.isInstanceOf))return t.map(e=>e.str)}this.context.throwEvalError(`${t}: ${r} must be a string or cell array of strings.`)}validationTextItem(e,t,r){if(u.CharString.isInstanceOf(e))return e.str;this.context.throwEvalError(`${t}: ${r} must be a string.`)}validationListItems(e,t,r){return u.CharString.isInstanceOf(e)?[e]:d.MultiArray.isInstanceOf(e)?d.MultiArray.linearize(e):void this.context.throwEvalError(`${t}: ${r} must be a string or cell array.`)}validatestringResult(e){const t=this.charControlArgument(e[0],"validatestring string").str,r=this.validationTextList(e[1],"validatestring","valid strings"),n=t.toLowerCase(),s=this.validatestringDiagnosticPrefix(e),i=r.filter(e=>e.toLowerCase()===n);if(i.length>0)return new u.CharString(i[0]);const a=r.filter(e=>e.toLowerCase().startsWith(n));if(1===a.length)return new u.CharString(a[0]);a.length>1&&this.context.throwEvalError(`${s} ambiguous string '${t}'.`),this.context.throwEvalError(`${s} expected one of: ${r.join(", ")}.`)}validatestringDiagnosticPrefix(e){if(e.length<3)return"validatestring:";const t=this.charControlArgument(e[2],"validatestring function name").str;if(e.length<4)return`validatestring: input for function '${t}'`;const r=this.charControlArgument(e[3],"validatestring variable name").str;return e.length<5?`validatestring: variable '${r}' for function '${t}'`:`validatestring: argument ${this.validateattributesNumericScalar(e[4],"validatestring argument position")} '${r}' for function '${t}'`}validateattributesValidator(e){switch(e.toLowerCase()){case"scalar":return"scalar";case"vector":return"vector";case"row":return"rowVector";case"column":return"columnVector";case"2d":return"matrix2d";case"square":return"squareMatrix";case"nonempty":return"nonempty";case"empty":return"empty";case"real":return"real";case"finite":return"finite";case"nonnan":return"nonnan";case"positive":return"positive";case"nonnegative":return"nonnegative";case"negative":return"negative";case"nonpositive":return"nonpositive";case"nonzero":return"nonzero";case"integer":return"integer";case"nonsparse":return"nonsparse";case"sparse":return"sparse";default:return}}validateattributesDimensions(e){return u.CharString.isString(e)?[1,1]:U.RuntimeValue.dimensions(e)}validateattributesRealNumericElements(e,t){const r=d.MultiArray.linearize(d.MultiArray.scalarToMultiArray(e));return r.every(e=>h.Complex.isInstanceOf(e)&&h.Complex.imagIsZero(e))||this.context.throwEvalError(`validateattributes: ${t} requires real numeric input.`),r}validateattributesNumericScalar(e,t){const r=d.MultiArray.isInstanceOf(e)&&U.RuntimeValue.isScalar(e)?d.MultiArray.firstElement(e):e;return h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: attribute '${t}' parameter must be a real numeric scalar.`),h.Complex.realToNumber(r)}validateattributesNumericVector(e,t){const r=d.MultiArray.scalarToMultiArray(e),n=d.MultiArray.linearize(r);return!r.isCell&&U.RuntimeValue.isVector(r)&&n.every(e=>h.Complex.isInstanceOf(e)&&h.Complex.imagIsZero(e))||this.context.throwEvalError(`validateattributes: attribute '${t}' parameter must be a real numeric vector.`),n.map(e=>h.Complex.realToNumber(e))}validateattributesNumericComparison(e,t,r){const n=this.validateattributesRealNumericElements(e,t);switch(t){case">":return n.every(e=>h.Complex.realGreaterThan(e,r));case">=":return n.every(e=>h.Complex.realGreaterThanOrEqualTo(e,r));case"<":return n.every(e=>h.Complex.realLessThan(e,r));case"<=":return n.every(e=>h.Complex.realLessThanOrEqualTo(e,r));default:return!1}}validateattributesMonotonicColumns(e,t){const r=d.MultiArray.scalarToMultiArray(e);r.isCell&&this.context.throwEvalError(`validateattributes: ${t} requires real numeric input.`);for(let e=0;e<r.array.length;e+=r.dimension[0])for(let n=0;n<r.dimension[1];n++)for(let s=1;s<r.dimension[0];s++){const i=r.array[e+s-1][n],a=r.array[e+s][n];if(h.Complex.isInstanceOf(i)&&h.Complex.imagIsZero(i)&&h.Complex.isInstanceOf(a)&&h.Complex.imagIsZero(a)||this.context.throwEvalError(`validateattributes: ${t} requires real numeric input.`),!("increasing"===t?h.Complex.realGreaterThan(a,h.Complex.realToNumber(i)):"decreasing"===t?h.Complex.realLessThan(a,h.Complex.realToNumber(i)):"nondecreasing"===t?h.Complex.realGreaterThanOrEqualTo(a,h.Complex.realToNumber(i)):h.Complex.realLessThanOrEqualTo(a,h.Complex.realToNumber(i))))return!1}return!0}validateattributesSpecialAttribute(e,t){const r=t.toLowerCase();switch(r){case"3d":return this.validateattributesDimensions(e).length<=3;case"scalartext":return u.CharString.isInstanceOf(e)||d.MultiArray.isInstanceOf(e)&&!e.isCell&&U.RuntimeValue.isScalar(e)&&u.CharString.isInstanceOf(d.MultiArray.firstElement(e));case"even":case"odd":return this.validateattributesRealNumericElements(e,t).every(e=>h.Complex.realIsInteger(e)&&Math.abs(h.Complex.realToNumber(e)%2)===("odd"===r?1:0));case"binary":return this.validateattributesRealNumericElements(e,t).every(e=>h.Complex.realEquals(e,0)||h.Complex.realEquals(e,1));case"diag":case"diagonal":{const r=this.validateattributesDimensions(e);if(2!==r.length||r[0]!==r[1])return!1;const n=d.MultiArray.scalarToMultiArray(e);n.isCell&&this.context.throwEvalError(`validateattributes: ${t} requires real numeric input.`);for(let e=0;e<r[0];e++)for(let s=0;s<r[1];s++){const r=n.array[e][s];if(h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: ${t} requires real numeric input.`),e!==s&&!h.Complex.realEquals(r,0))return!1}return!0}case"increasing":case"decreasing":case"nondecreasing":case"nonincreasing":return this.validateattributesMonotonicColumns(e,r);default:return}}validateattributesMatchesValidator(e,t){return!("scalar"!==t||!u.CharString.isString(e))||O.FunctionValidation.matchesBuiltInValidator(e,t)}validateattributesParameterizedAttribute(e,t,r,n){const s=this.validateattributesDimensions(e);switch(t.toLowerCase()){case"size":{const e=this.validateattributesNumericVector(r,t);return void(e.length<=s.length&&e.every((e,t)=>Number.isNaN(e)||s[t]===e)&&s.slice(e.length).every(e=>1===e)||this.context.throwEvalError(`validateattributes: ${n} must have size ${e.join("x")}.`))}case"numel":{const s=this.validateattributesNumericVector(r,t);return void(s.includes(U.RuntimeValue.elementCount(e))||this.context.throwEvalError(`validateattributes: ${n} must have ${s.join(" or ")} elements.`))}case"numrows":case"nrows":{const e=this.validateattributesNumericScalar(r,t);return void(s[0]!==e&&this.context.throwEvalError(`validateattributes: ${n} must have ${e} rows.`))}case"numcols":case"ncols":{const e=this.validateattributesNumericScalar(r,t);return void(s[1]!==e&&this.context.throwEvalError(`validateattributes: ${n} must have ${e} columns.`))}case"ndims":{const e=this.validateattributesNumericScalar(r,t);return void(s.length!==e&&this.context.throwEvalError(`validateattributes: ${n} must have ${e} dimensions.`))}case">":case">=":case"<":case"<=":{const s=this.validateattributesNumericScalar(r,t);return void(this.validateattributesNumericComparison(e,t,s)||this.context.throwEvalError(`validateattributes: ${n} must be ${t} ${s}.`))}default:this.context.throwEvalError(`validateattributes: unsupported attribute '${t}'.`)}}validateattributesSubject(e){if(e.length>=6){const t=this.charControlArgument(e[3],"validateattributes function name").str,r=this.charControlArgument(e[4],"validateattributes variable name").str;return`argument ${this.validateattributesNumericScalar(e[5],"validateattributes argument position")} '${r}' for function '${t}'`}return e.length>=5?this.charControlArgument(e[4],"validateattributes variable name").str:e.length>=4?u.CharString.isInstanceOf(e[3])?`input for function '${this.charControlArgument(e[3],"validateattributes function name").str}'`:`argument ${this.validateattributesNumericScalar(e[3],"validateattributes argument position")}`:"input"}validateattributesMatchesClass(e,t){switch(t.toLowerCase()){case"numeric":return O.FunctionValidation.matchesBuiltInValidator(e,"numeric");case"float":return O.FunctionValidation.matchesBuiltInValidator(e,"float");case"integer":return O.FunctionValidation.matchesBuiltInValidator(e,"integer");case"object":return g.ClassInstance.isInstanceOf(e)||d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearize(e).some(g.ClassInstance.isInstanceOf);default:return O.FunctionValidation.matchesClass(e,t)||this.valueIsRuntimeClass(e,t)}}validateattributesResult(e){const t=this.expressionValue(e[0],"validateattributes value"),r=this.validationTextList(e[1],"validateattributes","class list"),n=this.validationListItems(e[2],"validateattributes","attribute list"),s=this.validateattributesSubject(e);r.length>0&&!r.some(e=>this.validateattributesMatchesClass(t,e))&&this.context.throwEvalError(`validateattributes: ${s} must be one of: ${r.join(", ")}.`);for(let e=0;e<n.length;e++){const r=this.validationTextItem(n[e],"validateattributes","attribute"),i=this.validateattributesValidator(r);if(!i){const i=this.validateattributesSpecialAttribute(t,r);if(void 0!==i){i||this.context.throwEvalError(`validateattributes: ${s} must be ${r}.`);continue}e+1>=n.length&&this.context.throwEvalError(`validateattributes: attribute '${r}' requires a parameter.`),this.validateattributesParameterizedAttribute(t,r,n[++e],s);continue}this.validateattributesMatchesValidator(t,i)||this.context.throwEvalError(`validateattributes: ${s} must be ${r}.`)}return c.AST.nodeVoid()}mustBeArity(e){switch(e){case"mustBeGreaterThan":case"mustBeGreaterThanOrEqual":case"mustBeLessThan":case"mustBeLessThanOrEqual":case"mustBeMember":case"mustBeA":case"mustBeUnderlyingType":return{min:2,max:2};case"mustBeInRange":case"mustBeBetween":return{min:3,max:4};default:return{min:1,max:1}}}mustBeResult(e,t){const r=this.mustBeArity(e);c.AST.throwInvalidCallError(e,t.length<r.min||t.length>r.max,e=>this.context.throwEvalError(e));const n=this.runtimeExpressionValue(t[0],`${e} value`),s=t.slice(1).map((t,r)=>this.runtimeExpressionValue(t,`${e} bound ${r+1}`));return"mustBeA"===e?(this.validationTextList(s[0],e,"class list").some(e=>this.valueMatchesValidationClass(n,e,this.context.currentScope))||this.context.throwEvalError(`${e} validation failed for 'input': ${e}.`),c.AST.nodeVoid()):"mustBeUnderlyingType"===e?(this.validationTextList(s[0],e,"type list").includes(O.FunctionValidation.underlyingType(n))||this.context.throwEvalError(`${e} validation failed for 'input': ${e}.`),c.AST.nodeVoid()):(R.FunctionArguments.validateArgumentFunction("input",n,e,s,e=>this.context.throwEvalError(e),e=>this.context.throwSyntaxError(e),this.pathValidationCallbacks,e),c.AST.nodeVoid())}mustBeFunctionEntries(){return Object.fromEntries(W.publicArgumentValidators.map(e=>[e,{func:(...t)=>this.mustBeResult(e,t),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}}]))}commandWordListResult(e){if(void 0!==e)return"string"==typeof e?new u.CharString(e):"number"==typeof e?h.Complex.create(e):"boolean"==typeof e?e?h.Complex.true():h.Complex.false():e}rethrowResult(e){m.Structure.isInstanceOf(e)||this.context.throwEvalError("rethrow: input must be an error structure.");const t=e.field.message,r=e.field.identifier,n=e.field.stack;u.CharString.isInstanceOf(t)&&u.CharString.isInstanceOf(r)&&void 0!==n||this.context.throwEvalError("rethrow: input must be an error structure.");const s=this.runtimeExpressionValue(n,"error stack");try{this.context.throwEvalError(t.str)}catch(e){throw e.publicStack=s,r.str&&(e.identifier=r.str),e}}lastWarningResult(e=[]){return 1===e.length?this.setLastWarning(this.charControlArgument(e[0],"warning message").str):2===e.length&&this.setLastWarning(this.charControlArgument(e[0],"warning message").str,this.charControlArgument(e[1],"warning identifier").str),this.valueReturnList([new u.CharString(this.lastWarning.message),new u.CharString(this.lastWarning.identifier)])}dealResult(e){const t=this.context.requestedOutputMask(Math.max(this.context.requestedOutputCount,e.length)),r=e=>{var r;return null===(r=t[e])||void 0===r||r};return c.AST.nodeCommaSeparatedReturnList(e.length,(e,t)=>{const r=e[`out${t}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(t,t+1,e=>this.context.throwEvalError(e)),r},t=>{1!==e.length&&1!==t&&t!==e.length&&this.context.throwEvalError("deal: nargin and nargout must match unless there is exactly one input.");const n={length:t};for(let s=0;s<t;s++){if(!r(s))continue;const t=1===e.length?e[0]:e[s];n[`out${s}`]=this.returnListValue(t,`out${s+1}`)}return n})}positiveIntegerIndex(e,t){const r=d.MultiArray.isInstanceOf(e)&&d.MultiArray.isScalar(e)?d.MultiArray.firstElement(e):e;h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`${t} must be a positive integer.`);const n=h.Complex.realToNumber(r);return(!Number.isInteger(n)||n<1)&&this.context.throwEvalError(`${t} must be a positive integer.`),n}nthargoutIndexes(e){if(!d.MultiArray.isInstanceOf(e))return{indexes:[this.positiveIntegerIndex(e,"nthargout index")],vector:!1};const t=d.MultiArray.linearize(e);return 0===t.length&&this.context.throwEvalError("nthargout index must be a positive integer."),{indexes:t.map(e=>this.positiveIntegerIndex(e,"nthargout index")),vector:t.length>1}}nthargoutCallable(e){let t=this.expressionValue(e,"nthargout function");if(u.CharString.isInstanceOf(t)){const e=t.str.trim();0===e.length&&this.context.throwEvalError("nthargout: function name cannot be empty."),t=e.startsWith("@")?this.functionHandleFromString(t):this.createResolvedFunctionHandle(e,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(t);return r||this.context.throwEvalError("nthargout: function must be a function handle or function name."),r}nthargoutResult(e){const{indexes:t,vector:r}=this.nthargoutIndexes(e[0]),n=e.length>=3&&h.Complex.isInstanceOf(d.MultiArray.isInstanceOf(e[1])&&d.MultiArray.isScalar(e[1])?d.MultiArray.firstElement(e[1]):e[1]),s=n?this.positiveIntegerIndex(e[1],"nthargout total output count"):Math.max(...t);s<Math.max(...t)&&this.context.throwEvalError("nthargout total output count must be at least the largest requested output index.");const i=n?2:1,a=this.nthargoutCallable(e[i]);let o;this.context.pushRequestedOutputCount(s),this.context.pushRequestedOutputMask(Array.from({length:s},()=>!0));try{o=this.context.callCallable(a,this.callArgumentValues(e.slice(i+1),"nthargout"),c.AST.nodeIdentifier("nthargout"))}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}const l=c.AST.ensureReturnList(this.expressionValue(o,"nthargout result")),u=l.handler(s),m=t.map(e=>this.returnListValue(l.selector(u,e-1),`nthargout output ${e}`));if(!r)return m[0];const p=d.MultiArray.toRowVector(m);return p.isCell=!0,p}expressionValue(e,t){return(0,G.expressionValue)(e,t,"Expression value",e=>this.context.throwEvalError(e))}runtimeExpressionValue(e,t){return(0,G.runtimeExpressionValue)(e,t,"Expression value",e=>this.context.throwEvalError(e))}evaluatedExpressionValue(e,t,r){return this.expressionValue(c.AST.reduceToFirstIfReturnList(this.Evaluator(e,t)),r)}evaluatedExecutionResult(e,t){return c.AST.reduceToFirstIfReturnList(this.Evaluator(e,t))}scopedExpressionValue(e,t,r){const n=e.resolveName(t);return n&&void 0!==n.node||this.context.throwEvalError(`internal error: missing scoped expression '${t}'.`),this.expressionValue(n.node,r)}scopedMultiArrayValue(e,t,r){const n=this.scopedExpressionValue(e,t,r);return d.MultiArray.isInstanceOf(n)||this.context.throwEvalError(`internal error: scoped expression '${t}' is not an array.`),n}callArgumentValues(e,t){return e.map((e,r)=>this.expressionValue(e,`${t}${r+1}`))}charControlArgument(e,t){const r=this.expressionValue(e,t);return u.CharString.isInstanceOf(r)||this.context.throwEvalError(`${t} must be a character string.`),r}charStringList(e,t){return e.every(u.CharString.isInstanceOf)||this.context.throwEvalError(`${t} must contain character strings.`),e}functionHandleControlArgument(e,t){const r=this.expressionValue(e,t);return p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError(`${t} must be a function handle.`),r}booleanControlArgument(e,t){return this.toBoolean(this.expressionValue(e,t))}workerCountControlArgument(e,t){const r=this.expressionValue(e,t),n=d.MultiArray.isScalar(r)?d.MultiArray.firstElement(r):r;h.Complex.isInstanceOf(n)&&0===h.Complex.imagToNumber(n)||this.context.throwEvalError(`${t} must be a nonnegative integer.`);const s=h.Complex.realToNumber(n);return(!Number.isFinite(s)||!Number.isInteger(s)||s<0)&&this.context.throwEvalError(`${t} must be a nonnegative integer.`),s}classMethodArgumentValues(e,t){return e.map((e,r)=>this.expressionValue(e,`${t}${r+1}`))}reducedClassMethodResult(e,t,r,n){return c.AST.reduceToFirstIfReturnList(this.context.callClassInstanceMethod(e,t,r,n))}reducedClassMethodResultWithOutputCount(e,t,r,n,s){return c.AST.reduceToFirstIfReturnList(this.callClassInstanceMethodWithOutputCount(e,t,r,n,s))}classSubsasgnResult(e,t,r,n){const s=this.reducedClassMethodResult(e,t,r,n);return g.ClassInstance.isInstanceOf(s)||this.context.throwEvalError(`subsasgn for class ${e.classDefinition.name} must return an object of class ${e.classDefinition.name}.`),s.classDefinition===e.classDefinition||s.classDefinition.isSubclassOf(e.classDefinition)||this.context.throwEvalError(`subsasgn for class ${e.classDefinition.name} must return an object of class ${e.classDefinition.name}.`),s}reducedAssignmentValue(e){return c.AST.reduceToFirstIfReturnList(e)}structureAssignmentValue(e,t){return this.runtimeExpressionValue(this.reducedAssignmentValue(e),t)}assignStructureFieldValue(e,t,r,n){if(n&&d.MultiArray.isInstanceOf(e)&&m.Structure.isStructure(e)){const n=m.Structure.structureElements(e),s=d.MultiArray.isInstanceOf(r)?d.MultiArray.linearize(r):[r];if(s.length===n.length)return void n.forEach((e,r)=>{m.Structure.setNewField(e,t,this.runtimeExpressionValue(s[r],`field ${t.join(".")} element ${r+1}`))})}m.Structure.setNewField(e,t,r)}reducedIndexingResult(e){return c.AST.reduceToFirstIfReturnList(e)}assignmentValues(e,t){return d.MultiArray.linearize(this.expressionValue(e,t)).map((e,r)=>this.expressionValue(e,`${t}${r+1}`))}classPropertyPathAssignmentValues(e,t,r){return 1===t||r.tailDescriptors&&r.tailDescriptors.length>0&&d.MultiArray.isInstanceOf(e)&&d.MultiArray.isEmpty(e)?[this.expressionValue(e,"assignment")]:this.assignmentValues(e,"assignment")}expressionList(e,t){return e.map((e,r)=>this.expressionValue(e,`${t}${r+1}`))}linearExpressionValues(e,t){const r=this.expressionValue(e,t);return d.MultiArray.isInstanceOf(r)?d.MultiArray.linearize(r).map((e,r)=>this.expressionValue(e,`${t}${r+1}`)):[r]}copyExpressionValue(e,t){const r=this.expressionValue(e,t);return this.expressionValue(U.RuntimeValue.copy(r),t)}forLoopValues(e,t){if(m.Structure.isInstanceOf(e)){const r=d.MultiArray.isRowVector(t)?d.MultiArray.linearize(this.expressionValue(t,"for target")).length:1;return Object.entries(e.field).map(([e,t])=>{const n=this.expressionValue(t,e);return r>1?this.expressionValue(new d.MultiArray([1,2],[[n,u.CharString.create(e)]]),e):n})}if(u.CharString.isInstanceOf(e))return e.toCharacterScalars();if(!d.MultiArray.isInstanceOf(e))return[this.expressionValue(e,"for")];if(0===e.dimension[0]||0===e.dimension[1])return[];if(1===e.dimension[0]&&!e.isCell)return e.array[0].map((e,t)=>this.expressionValue(e,`for${t+1}`));const r=[];for(let t=0;t<e.dimension[1];t++){const n=new d.MultiArray([e.dimension[0],1],void 0,e.isCell);for(let r=0;r<e.dimension[0];r++)n.array[r][0]=e.array[r][t];r.push(this.expressionValue(n,`for${t+1}`))}return r}forLoopAssignmentValue(e,t){if(!d.MultiArray.isRowVector(e))return this.copyExpressionValue(t,"for");const r=this.linearExpressionValues(t,"for");return c.AST.nodeReturnList((e,t)=>{if(t<r.length)return this.copyExpressionValue(r[t],`for${t+1}`);c.AST.throwErrorIfGreaterThanReturnList(r.length,t+1,e=>this.context.throwEvalError(e))},e=>(e>r.length&&c.AST.throwErrorIfGreaterThanReturnList(r.length,e,e=>this.context.throwEvalError(e)),{length:e}))}validateParforHeader(e,t){c.AST.isNodeIdentifier(e)||this.context.throwEvalError("parfor loop variable must be a simple identifier.");const r=(()=>d.MultiArray.isInstanceOf(t)?((t.isCell||1!==t.dimension[0])&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),d.MultiArray.linearize(t)):[t])().map((e,t)=>{const r=this.expressionValue(e,`parfor range ${t+1}`);h.Complex.isInstanceOf(r)&&0===h.Complex.imagToNumber(r)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");const n=h.Complex.realToNumber(r);return Number.isFinite(n)&&Number.isInteger(n)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),n});if(r.length<=1)return;const n=r[1]-r[0];1!==Math.abs(n)&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");for(let e=2;e<r.length;e++)r[e]-r[e-1]!==n&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.")}validateParforBody(e,t){const r=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]),n=e=>c.AST.isNodeIdentifier(e)?e.id===t:c.AST.isNodeIndexExpr(e)?n(e.expr):c.AST.isNodeIndirectRef(e)?n(e.obj):c.AST.isNodeList(e)?e.list.some(n):!!d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearize(e).some(n),s=e=>{if(c.AST.isNodeBase(e)){if("BREAK"!==e.type&&"RETURN"!==e.type||this.context.throwEvalError(("BREAK"===e.type?"break":"return")+" is not allowed inside a parfor loop."),c.AST.isNodeDeclaration(e)&&this.context.throwEvalError(("GLOBAL"===e.type?"global":"persistent")+" declarations are not allowed inside a parfor loop."),c.AST.isNodeCmdWList(e)&&"clear"===e.id&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),(e=>c.AST.isNodeIndexExpr(e)&&c.AST.isNodeIdentifier(e.expr)&&"clear"===e.expr.id&&"()"===e.delim)(e)&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),"SPMD"===e.type&&this.context.throwEvalError("spmd is not allowed inside a parfor loop."),"FOR"===e.type&&!0===Reflect.get(e,"parallel")&&this.context.throwEvalError("nested parfor loops are not allowed."),c.AST.isNodeBinaryOperation(e))return r.has(e.type)&&n(e.left)&&this.context.throwEvalError(`assignment to parfor loop variable '${t}' is not allowed.`),s(e.left),void s(e.right);if(c.AST.isNodePrefixOperation(e))return"++_"!==e.type&&"--_"!==e.type||!n(e.right)||this.context.throwEvalError(`assignment to parfor loop variable '${t}' is not allowed.`),void s(e.right);if(c.AST.isNodePostfixOperation(e))return"_++"!==e.type&&"_--"!==e.type||!n(e.left)||this.context.throwEvalError(`assignment to parfor loop variable '${t}' is not allowed.`),void s(e.left);if(c.AST.isNodeIndexExpr(e))return s(e.expr),void e.args.forEach(s);if(c.AST.isNodeIndirectRef(e))return s(e.obj),void e.field.forEach(e=>{"string"!=typeof e&&s(e)});if(c.AST.isNodeList(e))e.list.forEach(s);else switch(e.type){case"IF":Reflect.get(e,"expression").forEach(s),Reflect.get(e,"then").forEach(s),Reflect.get(e,"else")&&s(Reflect.get(e,"else"));break;case"SWITCH":s(Reflect.get(e,"expression")),Reflect.get(e,"cases").forEach(s),Reflect.get(e,"otherwise")&&s(Reflect.get(e,"otherwise"));break;case"CASE":s(Reflect.get(e,"expression")),s(Reflect.get(e,"then"));break;case"WHILE":case"DO_UNTIL":s(Reflect.get(e,"expression")),s(Reflect.get(e,"body"));break;case"FOR":s(Reflect.get(e,"target")),s(Reflect.get(e,"expression")),s(Reflect.get(e,"body"));break;case"TRY":s(Reflect.get(e,"body")),Reflect.get(e,"catchBody")&&s(Reflect.get(e,"catchBody"));break;case"UNWIND_PROTECT":s(Reflect.get(e,"body")),s(Reflect.get(e,"cleanup"))}}};s(e)}validateSpmdBody(e){const t=e=>{if(p.FunctionHandle.isInstanceOf(e))void 0===e.id&&this.context.throwEvalError("anonymous function definitions are not allowed inside an spmd block.");else if(c.AST.isNodeBase(e)){if("BREAK"!==e.type&&"CONTINUE"!==e.type&&"RETURN"!==e.type||this.context.throwEvalError(("BREAK"===e.type?"break":"CONTINUE"===e.type?"continue":"return")+" is not allowed inside an spmd block."),c.AST.isNodeDeclaration(e)&&this.context.throwEvalError(("GLOBAL"===e.type?"global":"persistent")+" declarations are not allowed inside an spmd block."),c.AST.isNodeCmdWList(e)&&"clear"===e.id&&this.context.throwEvalError("clear is not allowed inside an spmd block."),(e=>c.AST.isNodeIndexExpr(e)&&c.AST.isNodeIdentifier(e.expr)&&"clear"===e.expr.id&&"()"===e.delim)(e)&&this.context.throwEvalError("clear is not allowed inside an spmd block."),"SPMD"===e.type&&this.context.throwEvalError("nested spmd blocks are not allowed."),"FOR"===e.type&&!0===Reflect.get(e,"parallel")&&this.context.throwEvalError("parfor is not allowed inside an spmd block."),c.AST.isNodeBinaryOperation(e))return t(e.left),void t(e.right);if(c.AST.isNodePrefixOperation(e))t(e.right);else if(c.AST.isNodePostfixOperation(e))t(e.left);else{if(c.AST.isNodeIndexExpr(e))return t(e.expr),void e.args.forEach(t);if(c.AST.isNodeIndirectRef(e))return t(e.obj),void e.field.forEach(e=>{"string"!=typeof e&&t(e)});if(c.AST.isNodeList(e))e.list.forEach(t);else switch(e.type){case"IF":Reflect.get(e,"expression").forEach(t),Reflect.get(e,"then").forEach(t),Reflect.get(e,"else")&&t(Reflect.get(e,"else"));break;case"SWITCH":t(Reflect.get(e,"expression")),Reflect.get(e,"cases").forEach(t),Reflect.get(e,"otherwise")&&t(Reflect.get(e,"otherwise"));break;case"CASE":t(Reflect.get(e,"expression")),t(Reflect.get(e,"then"));break;case"WHILE":case"DO_UNTIL":t(Reflect.get(e,"expression")),t(Reflect.get(e,"body"));break;case"FOR":t(Reflect.get(e,"target")),t(Reflect.get(e,"expression")),Reflect.get(e,"workers")&&t(Reflect.get(e,"workers")),t(Reflect.get(e,"body"));break;case"TRY":t(Reflect.get(e,"body")),Reflect.get(e,"catchBody")&&t(Reflect.get(e,"catchBody"));break;case"UNWIND_PROTECT":t(Reflect.get(e,"body")),t(Reflect.get(e,"cleanup"))}}}};t(e)}cloneAssignmentTarget(e){if(h.Complex.isInstanceOf(e)||u.CharString.isInstanceOf(e)||m.Structure.isInstanceOf(e)||p.FunctionHandle.isInstanceOf(e)||f.ClassDefinition.isInstanceOf(e)||g.ClassInstance.isInstanceOf(e)||y.ClassBoundMethod.isInstanceOf(e)||x.ClassStaticMethod.isInstanceOf(e)||C.ClassEmptyMethod.isInstanceOf(e)||E.ClassEnumerationValue.isInstanceOf(e)||_.ClassMetaObject.isInstanceOf(e))return this.copyExpressionValue(e,"assignment target");if(c.AST.isNodeIdentifier(e))return c.AST.nodeIdentifier(e.id);if(c.AST.isNodeIgnoredTarget(e))return c.AST.nodeIgnoredTarget();if(c.AST.isNodeIndexExpr(e))return c.AST.nodeIndexExpr(this.cloneAssignmentTarget(e.expr),c.AST.nodeList(e.args.map(e=>this.cloneAssignmentTarget(e))),e.delim);if(c.AST.isNodeIndirectRef(e)){const t=e.field[0];let r=c.AST.nodeIndirectRef(this.cloneAssignmentTarget(e.obj),"string"==typeof t?t:this.cloneAssignmentTarget(t));for(let t=1;t<e.field.length;t++){const n=e.field[t];r=c.AST.nodeIndirectRef(r,"string"==typeof n?n:this.cloneAssignmentTarget(n))}return r}if(d.MultiArray.isInstanceOf(e)){const t=e,r=new d.MultiArray(t.dimension,void 0,t.isCell);for(let e=0;e<t.dimension[0];e++)for(let n=0;n<t.dimension[1];n++)r.array[e][n]=this.cloneAssignmentTarget(t.array[e][n]);return d.MultiArray.setType(r),this.expressionValue(r,"assignment target")}return this.expressionValue(c.AST.nodeCopy(this.expressionValue(e,"assignment target")),"assignment target")}returnListValue(e,t){return(0,G.expressionValue)(e,t,"Return value",e=>this.context.throwEvalError(e))}valueReturnList(e,t){const r=null!=t?t:this.context.requestedOutputMask(e.length),n=e=>{var t;return null===(t=r[e])||void 0===t||t};return c.AST.nodeCommaSeparatedReturnList(e.length,(e,t)=>{const r=e[`out${t}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(t,t+1,e=>this.context.throwEvalError(e)),r},t=>{c.AST.throwErrorIfGreaterThanReturnList(e.length,t,e=>this.context.throwEvalError(e));const r={length:t};for(let s=0;s<t;s++)n(s)&&(r[`out${s}`]=this.returnListValue(e[s],`out${s+1}`));return r})}compoundAssignmentOperand(e,t){var r;if(!c.AST.isNodeReturnList(e)||!e.commaSeparated)return this.expressionValue(e,t);const n=null!==(r=e.returnListLength)&&void 0!==r?r:e.handler(0).length,s=e.handler(n),i=[];for(let r=0;r<n;r++)i.push(this.expressionValue(e.selector(s,r),`${t}${r+1}`));return d.MultiArray.toRowVector(i)}nestedAssignmentValue(e){const t=e.list[0];return c.AST.isNodeBinaryOperation(t)&&"="===t.type||this.context.throwEvalError("invalid nested assignment result."),this.expressionValue(t.right,"assignment result")}evalStringInScope(e,t,r={}){var n,s;const i=this.Parse(e);i.parent=null,this.validateDeclarationPlacement(i);const a=this.pushDynamicNameCreationGuard(t);this.context.pushCallStackFrame(new B.CallFrame(t));try{const e=null!==(n=r.requestedOutputCount)&&void 0!==n?n:this.context.requestedOutputCount,a=null!==(s=r.requestedOutputMask)&&void 0!==s?s:this.context.requestedOutputMask(e);this.context.pushRequestedOutputCount(e),this.context.pushRequestedOutputMask(a);try{if(c.AST.isNodeList(i)&&1===i.list.length&&!i.list[0].omitOutput){let e=i.list[0];return c.AST.isNodeIdentifier(e)&&!t.resolveName(e.id)&&this.commandWordListNameSet.has(e.id)&&(e=c.AST.nodeEmptyCmdWList(e),i.list[0]=e),e.index=0,this.Evaluator(e,t)}const e=this.Evaluator(i,t);return c.AST.isNodeList(e)&&1===e.list.length&&c.AST.isNodeReturnList(e.list[0])?e.list[0]:e}catch(e){if(r.topLevelReturn&&e instanceof q.ReturnSignal)return c.AST.nodeVoid();throw e}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}finally{this.context.popCallStackFrame(),a()}}pushDynamicNameCreationGuard(e){const t=e.rejectDynamicNameCreation;return e.staticWorkspaceNameSet&&(e.rejectDynamicNameCreation=!0),()=>{e.rejectDynamicNameCreation=t}}isEvalCatchableError(e){return!(e instanceof q.ReturnSignal||e instanceof q.BreakSignal||e instanceof q.ContinueSignal)}evalcResult(e,t){const r=this.context.requestedOutputCount,n=Math.max(r-1,1),s=this.context.requestedOutputMask(r),i=Array.from({length:n},(e,t)=>{var r;return null===(r=s[t+1])||void 0===r||r});let a;a=F.FunctionWorkspace.evaluateWithCatch(this.context.currentScope,e,t,(e,t)=>this.evalStringInScope(e,t,{requestedOutputCount:n,requestedOutputMask:i}),e=>this.isEvalCatchableError(e),e=>this.rememberLastError(e));const o=new Array(n);let l=a;if(c.AST.isNodeReturnList(a)){const e=a.handler(n);for(let t=0;t<n;t++)i[t]&&(o[t]=this.returnListValue(a.selector(e,t),`evalc output ${t+1}`));const t=o.filter(e=>void 0!==e);l=0===t.length?c.AST.nodeVoid():1===t.length?t[0]:c.AST.nodeList(t.map(e=>this.returnListValue(e,"evalc display value")))}else"VOID"!==a.type&&(o[0]=this.returnListValue(a,"evalc output 1"));const h=new u.CharString(this.Unparse(l));return r>1?this.valueReturnList([h,...o],s):h}topLevelClassDefinitions(e){return c.AST.isNodeClassDef(e)?[e]:c.AST.isNodeList(e)?e.list.filter(c.AST.isNodeClassDef):[]}topLevelFunctionDefinitions(e){return c.AST.isNodeFunctionDefinition(e)?[e]:c.AST.isNodeList(e)?e.list.filter(c.AST.isNodeFunctionDefinition):[]}parseFunctionSource(e,t){var r;const n=null!==(r=e.split(".").pop())&&void 0!==r?r:e,s=this.Parse(t);this.validateDeclarationPlacement(s);const i=this.topLevelFunctionDefinitions(s),a=i.find(t=>t.id===n||t.id===e);return a||this.context.throwEvalError(`function '${e}' could not be loaded: source does not contain primary function ${n}.`),a.id=e,{primary:a,subfunctions:i.filter(e=>e!==a)}}resolveFunctionSource(e){return this.sourceResolver.resolve("function",e)}hasFunctionSource(e){return Boolean(this.validFunctionSource(e))}validFunctionSource(e){var t,r;const n=this.resolveFunctionSource(e);if(void 0!==n)try{const s=this.parseFunctionSource(null!==(t=n.name)&&void 0!==t?t:e,n.source);return this.validateFunctionFileDefinitions(s.primary,s.subfunctions,`function file ${null!==(r=n.name)&&void 0!==r?r:e}`),n}catch(e){return}}validateFunctionFileDefinitions(e,t,r=`function file ${e.id}`){this.validateFunctionSignature(e),this.validateFunctionArgumentsBlocks(e);const n=new Set([e.id]);for(const e of t)n.has(e.id)&&this.context.throwSyntaxError(`duplicate function '${e.id}' in ${r}.`),n.add(e.id),this.validateFunctionSignature(e),this.validateFunctionArgumentsBlocks(e)}registerFunctionFileDefinition(e,t,r,n=e.id){var s,i,a;this.validateFunctionFileDefinitions(e,t,`function file ${e.id}`);const o=$.Scope.create(r,!1);o.defineFunction(e.id,e),e.definingScope=o,e.sourceName=n,((null===(s=e.attributes)||void 0===s?void 0:s.nested)||(null===(i=e.attributes)||void 0===i?void 0:i.subfunction))&&(e.attributes=Object.assign({},e.attributes),delete e.attributes.nested,delete e.attributes.subfunction);for(const e of t)e.definingScope=o,e.sourceName=n,e.attributes=Object.assign(Object.assign({},null!==(a=e.attributes)&&void 0!==a?a:{}),{subfunction:!0}),delete e.attributes.nested,o.defineFunction(e.id,e);return r.defineFunction(e.id,e),e}LoadFunctionFile(e,t,r,n){var s;void 0===r&&(r=null!==(s=this.context.globalScope)&&void 0!==s?s:this.context.currentScope),void 0===n&&(n=e);const i=this.parseFunctionSource(e,t);return this.registerFunctionFileDefinition(i.primary,i.subfunctions,r,n)}loadFunctionDefinition(e,t){var r,n,s,i;const a=this.resolveFunctionSource(e);if(a&&!this.loadingFunctionNames.has(e)){this.loadingFunctionNames.add(e);try{return this.LoadFunctionFile(null!==(r=a.name)&&void 0!==r?r:e,a.source,null!==(n=this.context.globalScope)&&void 0!==n?n:t,null!==(i=null!==(s=a.sourceName)&&void 0!==s?s:a.name)&&void 0!==i?i:e)}finally{this.loadingFunctionNames.delete(e)}}}resolveScriptSource(e){return this.sourceResolver.resolve("script",e)}hasScriptSource(e){return Boolean(this.validScriptSource(e))}validScriptSource(e){const t=this.resolveScriptSource(e);if(void 0!==t)try{const e=this.Parse(t.source);return this.validateDeclarationPlacement(e),t}catch(e){return}}executeScriptTree(e,t,r){const n=this.topLevelFunctionDefinitions(e),s=new Map,i=t.importSnapshot(),a=this.pushDynamicNameCreationGuard(t);for(const e of n)s.has(e.id)||s.set(e.id,t.functionTable[e.id]);this.scriptExecutionDepth++,this.scriptSourceNameStack.push(r);try{return this.applyScopedImports(e,t),this.Evaluator(e,t)}catch(e){if(e instanceof q.ReturnSignal)return c.AST.nodeVoid();throw e}finally{this.scriptSourceNameStack.pop(),this.scriptExecutionDepth--,a();for(const[e,r]of s)r?t.defineFunction(e,r):t.removeFunction(e);t.restoreImports(i)}}LoadScriptFile(e,t,r=this.context.currentScope,n=e){const s=this.Parse(t);return s.parent=null,this.validateDeclarationPlacement(s),this.executeScriptTree(s,r,n)}RunScriptFile(e,t=this.context.currentScope){var r,n,s;const i=this.resolveScriptSource(e);return i||this.context.throwEvalError(`script '${e}' could not be loaded.`),this.LoadScriptFile(null!==(r=i.name)&&void 0!==r?r:e,i.source,t,null!==(s=null!==(n=i.sourceName)&&void 0!==n?n:i.name)&&void 0!==s?s:e)}parseClassSource(e,t){var r;const n=this.tryParseClassSource(e,t);if(!n){const t=null!==(r=e.split(".").pop())&&void 0!==r?r:e;this.context.throwEvalError(`class '${e}' could not be loaded: source does not contain classdef ${t}.`)}return n}tryParseClassSource(e,t){var r;const n=null!==(r=e.split(".").pop())&&void 0!==r?r:e,s=this.Parse(t);this.validateDeclarationPlacement(s);const i=this.topLevelClassDefinitions(s).find(e=>e.id===n);if(i)return i.id=e,i}isFunctionOnlySource(e){const t=this.Parse(e);return this.validateDeclarationPlacement(t),0===this.topLevelClassDefinitions(t).length&&this.topLevelFunctionDefinitions(t).length>0}parseClassMethodSource(e,t,r,n){var s,i;const a=new Set([t,r]);t.includes(".")||a.add(null!==(s=r.split(".").pop())&&void 0!==s?s:r);const o=this.Parse(n);this.validateDeclarationPlacement(o);const l=this.topLevelFunctionDefinitions(o),c=l.find(e=>a.has(e.id));return c||this.context.throwEvalError(`method '${t}' for class ${e} could not be loaded: source does not contain primary function ${t}.`),c.id=t,(null===(i=c.attributes)||void 0===i?void 0:i.prototype)&&(c.attributes=Object.assign({},c.attributes),delete c.attributes.prototype),{primary:c,subfunctions:l.filter(e=>e!==c)}}resolveClassSource(e){return this.sourceResolver.resolve("class",e)}hasClassSource(e){return Boolean(this.validClassSource(e))}validClassSource(e){var t;const r=this.resolveClassSource(e);if(void 0!==r)try{const n=this.tryParseClassSource(null!==(t=r.name)&&void 0!==t?t:e,r.source);if(!n)return;return f.ClassDefinition.create(n).validateLocalDefinition(e=>this.context.throwEvalError(e)),r}catch(e){return}}attachClassDefinitionSourceName(e,t){for(const r of e.methods)r.node.sourceName=t}loadClassDefinition(e,t){var r,n,s,i;const a=this.resolveClassSource(e);if(a&&!this.loadingClassNames.has(e)){this.loadingClassNames.add(e);try{const o=this.tryParseClassSource(null!==(r=a.name)&&void 0!==r?r:e,a.source);if(!o){if(this.isFunctionOnlySource(a.source))return;return void this.parseClassSource(null!==(n=a.name)&&void 0!==n?n:e,a.source)}const l=f.ClassDefinition.create(o);return this.attachClassDefinitionSourceName(l,null!==(i=null!==(s=a.sourceName)&&void 0!==s?s:a.name)&&void 0!==i?i:e),l.resolveSuperclasses(e=>this.context.resolveClassDefinition(e,t),e=>this.context.throwEvalError(e)),l}finally{this.loadingClassNames.delete(e)}}}loadClassMethodDefinition(e,t,r){var n,s,i,a,o,l,c;const u=`${e}.${t}`,h=this.resolveClassSource(u);if(h&&!this.loadingClassMethodNames.has(u)){this.loadingClassMethodNames.add(u);try{const d=this.parseClassMethodSource(e,t,null!==(n=h.name)&&void 0!==n?n:u,h.source),m=$.Scope.create(null!==(s=this.context.globalScope)&&void 0!==s?s:r,!1);this.validateFunctionFileDefinitions(d.primary,d.subfunctions,`method file ${u}`),d.primary.definingScope=m,d.primary.sourceName=null!==(a=null!==(i=h.sourceName)&&void 0!==i?i:h.name)&&void 0!==a?a:u,m.defineFunction(d.primary.id,d.primary);for(const e of d.subfunctions)e.definingScope=m,e.sourceName=null!==(l=null!==(o=h.sourceName)&&void 0!==o?o:h.name)&&void 0!==l?l:u,e.attributes=Object.assign(Object.assign({},null!==(c=e.attributes)&&void 0!==c?c:{}),{subfunction:!0}),delete e.attributes.nested,m.defineFunction(e.id,e);return d.primary}finally{this.loadingClassMethodNames.delete(u)}}}qualifiedReferenceParts(e){if("IDENT"===e.obj.type&&!e.field.some(e=>"string"!=typeof e))return[e.obj.id,...e.field]}resolveClassDefinitionMemberChain(e,t,r){let n=e;for(const e of t)if(f.ClassDefinition.isInstanceOf(n)){const t=n.findProperty(e);if(null==t?void 0:t.isConstant){this.assertCanReadClassProperty(t,e,n.name),n=t.defaultValue?this.evaluatedExpressionValue(t.defaultValue,r,`constant property ${e}`):d.MultiArray.emptyArray();continue}const s=n.findEnumeration(e);if(s){const e=s.args.map((e,t)=>this.runtimeExpressionValue(this.evaluatedExpressionValue(e,r,`enumeration argument ${t+1}`),`enumeration argument ${t+1}`));n=E.ClassEnumerationValue.create(s.classDefinition,s,e);continue}if("empty"===e){n=C.ClassEmptyMethod.bind(n);continue}const i=n.findMethod(e,e=>e.isStatic);if(i){this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${e}' has ${i.access} access for class ${n.name}.`),n=x.ClassStaticMethod.bind(n,i);continue}this.context.throwEvalError(`unknown static method '${e}' for class ${n.name}.`)}else n=m.Structure.getField(n,[e]);return n}resolveQualifiedAccess(e,t){const r=this.qualifiedReferenceParts(e);if(!r||r.length<2||this.hasConcreteName(t,r[0]))return;for(let e=r.length;e>=2;e--){const n=r.slice(0,e).join("."),s=this.resolveRuntimeClass(n,t,{imports:!1});if("class"===(null==s?void 0:s.kind))return{kind:"class-member-chain",parts:r,prefixLength:e,resolvedName:s.resolvedName,classDefinition:s.classDefinition}}const n=r.join("."),s=this.resolveRuntimeFunction(n,t,{imports:!1});if(null==s?void 0:s.functionDefinition){const t=p.FunctionHandle.create(s.resolvedName);return t.parent=e,{kind:"function",parts:r,prefixLength:r.length,resolvedName:s.resolvedName,functionHandle:t}}}resolveQualifiedNameAccess(e,t){const r=this.resolveQualifiedAccess(e,t);if(r)switch(r.kind){case"class-member-chain":return r.classDefinition.parent=e,this.resolveClassDefinitionMemberChain(r.classDefinition,r.parts.slice(r.prefixLength),t);case"function":return r.functionHandle}}hasConcreteName(e,t){const r=e.resolveName(t);return void 0!==(null==r?void 0:r.node)&&!r.undefinedReference}resolveImportedStaticMethod(e,t){var r;const n=[...new Map(t.importedNameCandidates(e).map(e=>this.importedStaticMethodCandidate(e,t)).filter(e=>void 0!==e).map(e=>[e.name,e.method])).entries()];return n.length>1&&this.context.throwEvalError(`imported name '${e}' is ambiguous: ${n.map(([e])=>e).join(", ")}.`),null===(r=n[0])||void 0===r?void 0:r[1]}resolveStaticMethod(e,t){const r=this.context.aliasNameFunction(e);if(!r.includes("."))return this.resolveImportedStaticMethod(r,t);const n=r.split("."),s=n[n.length-1],i=n.slice(0,-1).join("."),a=this.resolveRuntimeClass(i,t,{imports:!1});if("class"!==(null==a?void 0:a.kind)||!a.classDefinition)return;const o=a.classDefinition.findMethod(s,e=>e.isStatic);return o?(this.context.canAccessClassMember(o.classDefinition,o.access)||this.context.throwEvalError(`method '${s}' has ${o.access} access for class ${a.classDefinition.name}.`),x.ClassStaticMethod.bind(a.classDefinition,o)):void 0}importedStaticMethodCandidate(e,t){const r=e.split(".");if(r.length<2)return;const n=r[r.length-1],s=r.slice(0,-1).join("."),i=this.resolveRuntimeClass(s,t,{imports:!1});if("class"!==(null==i?void 0:i.kind)||!i.classDefinition)return;const a=i.classDefinition.findMethod(n,e=>e.isStatic);return a?(this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method '${n}' has ${a.access} access for class ${i.classDefinition.name}.`),{name:e,method:x.ClassStaticMethod.bind(i.classDefinition,a)}):void 0}hasQualifiedNameAccessOperand(e,t){return c.AST.isNodeIndirectRef(e)?void 0!==this.resolveQualifiedAccess(e,t)||this.hasQualifiedNameAccessOperand(e.obj,t):!!c.AST.isNodeIndexExpr(e)&&this.hasQualifiedNameAccessOperand(e.expr,t)}resolveMetaclassLiteral(e,t){const r=e.split(".");for(let e=r.length;e>=1;e--){const n=r.slice(0,e).join("."),s=this.context.resolveClassDefinition(n,t);if(!s)continue;let i=this.createClassMetaClass(s,t);for(const t of r.slice(e))if(_.ClassMetaObject.isInstanceOf(i)){const e=i.getProperty(t);void 0===e&&this.context.throwEvalError(`unknown property '${t}' for ${i.kind}.`),i=e}else i=m.Structure.getField(i,[t]);return i}this.context.throwEvalError(`metaclass: class '${e}' is not defined.`)}createClassMetaClass(e,t=this.context.currentScope){return _.ClassMetaClass.create(e,e=>e.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(e.defaultValue,t,`property ${e.name} default`),`property ${e.name} default`):void 0)}createClassMetaProperty(e,t=this.context.currentScope){return _.ClassMetaProperty.create(e,e=>e.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(e.defaultValue,t,`property ${e.name} default`),`property ${e.name} default`):void 0)}functionCountMessage(e,t){return"nargchk"===e?"low"===t?{message:"Not enough input arguments.",identifier:"MATLAB:nargchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:nargchk:tooManyInputs"}:"narginchk"===e?"low"===t?{message:"Not enough input arguments.",identifier:"MATLAB:narginchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:narginchk:tooManyInputs"}:"low"===t?{message:"Not enough output arguments.",identifier:"MATLAB:nargoutchk:notEnoughOutputs"}:{message:"Too many output arguments.",identifier:"MATLAB:nargoutchk:tooManyOutputs"}}functionCountStatus(e,t,r,n){const s=D.FunctionArity.countBound(e,t,!1,e=>this.context.throwSyntaxError(e)),i=D.FunctionArity.countBound(e,r,!0,e=>this.context.throwSyntaxError(e));return i<s&&this.context.throwSyntaxError(`${e}: maximum count must be greater than or equal to minimum count.`),n<s?"low":n>i?"high":"ok"}checkFunctionCount(e,t,r){const n="narginchk"===e?h.Complex.realToNumber(this.context.currentFunctionArgumentCountOrZero()):h.Complex.realToNumber(this.context.currentFunctionOutputCountOrZero());return"ok"!==this.functionCountStatus(e,t,r,n)&&this.context.throwEvalError(`${e}: invalid number of ${"narginchk"===e?"input":"output"} arguments.`),c.AST.nodeVoid()}functionCountMessageResult(e,t){const r=D.FunctionArity.countBound(e,t[2],!1,e=>this.context.throwSyntaxError(e)),n=this.functionCountStatus(e,t[0],t[1],r);if(4===t.length){const r=this.charControlArgument(t[3],`${e} output kind`).str;if(c.AST.throwInvalidCallError(e,"struct"!==r&&"string"!==r,e=>this.context.throwSyntaxError(e)),"string"===r)return"ok"===n?new u.CharString(""):u.CharString.create(this.functionCountMessage(e,n).message,"'");if("ok"===n)return new m.Structure({});const s=this.functionCountMessage(e,n);return new m.Structure({message:u.CharString.create(s.message,"'"),identifier:u.CharString.create(s.identifier,"'")})}return"ok"===n?new u.CharString(""):u.CharString.create(this.functionCountMessage(e,n).message,"'")}nargoutchkResult(e){return 2===e.length?this.checkFunctionCount("nargoutchk",e[0],e[1]):this.functionCountMessageResult("nargoutchk",e)}nargchkResult(e){return this.functionCountMessageResult("nargchk",e)}lookupImportedSourceResolution(e,t,r,n){var s,i;const a=this.context.aliasNameFunction(e),o=n(a);if(o)return{kind:r,name:e,resolvedName:a,source:"local",sourceName:null!==(i=null!==(s=o.sourceName)&&void 0!==s?s:o.name)&&void 0!==i?i:a};if(!a.includes(".")){const s=[...new Map(t.importedNameCandidates(a).map(e=>this.context.aliasNameFunction(e)).map(e=>({importedCanonical:e,source:n(e)})).filter(e=>void 0!==e.source).map(({importedCanonical:t,source:n})=>{var s,i;return[t,{kind:r,name:e,resolvedName:t,source:"import",sourceName:null!==(i=null!==(s=n.sourceName)&&void 0!==s?s:n.name)&&void 0!==i?i:t}]})).values()];if(s.length>1&&this.context.throwEvalError(`imported name '${a}' is ambiguous: ${s.map(e=>e.resolvedName).join(", ")}.`),1===s.length)return s[0]}}lookupClassSourceResolution(e,t){return this.lookupImportedSourceResolution(e,t,"class",e=>this.validClassSource(e))}lookupFunctionSourceResolution(e,t){return this.lookupImportedSourceResolution(e,t,"function",e=>this.validFunctionSource(e))}lookupScriptSourceResolution(e){var t,r;const n=this.context.aliasNameFunction(e),s=this.validScriptSource(n);if(s)return{kind:"script",name:e,resolvedName:n,source:"local",sourceName:null!==(r=null!==(t=s.sourceName)&&void 0!==t?t:s.name)&&void 0!==r?r:n}}lookupDirectorySourceResolution(e){const t=this.context.aliasNameFunction(e);return this.sourceResolver.hasDirectory(t)?{kind:"directory",name:e,resolvedName:t,source:"local"}:void 0}resolveLookupSymbol(e,t,r=this.context.currentScope){var n,s,i;const a=null==t?void 0:t.trim().toLowerCase();if("dir"===a)return this.lookupDirectorySourceResolution(e);if("builtin"===a){const t=this.context.aliasNameFunction(e),r=this.context.builtInFunctionTable[t];return r?{kind:"builtin",name:e,resolvedName:t,source:"builtin",functionDefinition:r}:void 0}const o="class"===a||void 0===a,l=o||"file"===a,c="file"===a||void 0===a,u="class"!==a&&"var"!==a&&"variable"!==a,h=this.resolveRuntimeSymbol(e,r,{variables:"class"!==a&&"file"!==a&&"function"!==a,classes:o,loadClasses:!1,functions:u,loadFunctions:!1});if(h){if(u&&"builtin"===h.kind){const t=this.lookupFunctionSourceResolution(e,r);if(t)return t}return h}return null!==(i=null!==(s=null!==(n=u?this.lookupFunctionSourceResolution(e,r):void 0)&&void 0!==n?n:l?this.lookupClassSourceResolution(e,r):void 0)&&void 0!==s?s:c?this.lookupScriptSourceResolution(e):void 0)&&void 0!==i?i:"file"===a||void 0===a?this.lookupDirectorySourceResolution(e):void 0}existCode(e,t){const r=this.resolveLookupSymbol(e,t);return k.FunctionLookup.existCodeFromResolution(e,t,r)}whichResult(e,t){var r;const n=null!==(r=null==t?void 0:t.closure)&&void 0!==r?r:this.context.currentScope,s=t?t.id?this.resolveLookupSymbol(t.id,"function",n):void 0:this.resolveLookupSymbol(e),i=!s&&e?this.staticMethodInfo(e,n):void 0;return k.FunctionLookup.whichResultFromResolution(e,s,t,e=>p.FunctionHandle.unparse(e,this),i)}isClassName(e,t=this.context.currentScope){return k.FunctionLookup.isRuntimeClassName(e)||Boolean(this.resolveRuntimeClass(e,t,{loadClasses:!1}))||Boolean(this.lookupClassSourceResolution(e,t))}valueIsRuntimeClass(e,t){switch(t){case"double":case"logical":case"char":case"cell":case"struct":case"function_handle":return this.getValueClassName(e)===t;case"event.listener":return v.ClassEventListener.isInstanceOf(e);case"event.proplistener":return v.ClassEventListener.isInstanceOf(e)&&"event.proplistener"===e.kind;case"event.EventData":return A.ClassEventData.isInstanceOf(e)||g.ClassInstance.isInstanceOf(e)&&e.classDefinition.isSubclassOfName("event.EventData");case"event.PropertyEvent":return S.ClassPropertyEvent.isInstanceOf(e);default:if(d.MultiArray.isInstanceOf(e)){const r=d.MultiArray.linearize(e);return r.length>0&&r.every(e=>this.valueIsRuntimeClass(e,t))}return _.ClassMetaObject.isInstanceOf(e)?e.kind===t:(g.ClassInstance.isInstanceOf(e)||!!E.ClassEnumerationValue.isInstanceOf(e))&&(e.classDefinition.name===t||e.classDefinition.isSubclassOfName(t))}}valueMatchesValidationClass(e,t,r,n=!1){if(O.FunctionValidation.matchesClass(e,t)||this.valueIsRuntimeClass(e,t))return!0;const s=this.context.resolveClassDefinition(t,r);if(!s)return!1;const i=e=>!(!g.ClassInstance.isInstanceOf(e)&&!E.ClassEnumerationValue.isInstanceOf(e))&&(e.classDefinition===s||e.classDefinition.isSubclassOf(s));if(d.MultiArray.isInstanceOf(e)){const t=d.MultiArray.linearize(e);return!(0!==t.length||!n||!d.MultiArray.isEmpty(e))||t.length>0&&t.every(i)}return i(e)}classIntrospectionArgument(e,t){if(!u.CharString.isInstanceOf(t))return t;const r=t.str,n=this.context.resolveClassDefinition(r);if(n)return n;this.context.throwEvalError(`${e}: class '${r}' is not defined.`)}metaclassArgument(e){if(_.ClassMetaClass.isInstanceOf(e))return e;if(f.ClassDefinition.isInstanceOf(e))return this.createClassMetaClass(e);if(g.ClassInstance.isInstanceOf(e)||E.ClassEnumerationValue.isInstanceOf(e))return this.createClassMetaClass(e.classDefinition);if(u.CharString.isInstanceOf(e)){const t=this.context.resolveClassDefinition(e.str);if(t)return this.createClassMetaClass(t);this.context.throwEvalError(`metaclass: class '${e.str}' is not defined.`)}this.context.throwEvalError("metaclass: input must be a class object or class name.")}eventData(e,t){return A.ClassEventData.create(e,t)}propertyEventData(e,t,r=t,n=e){return S.ClassPropertyEvent.create(e,t,r,n)}isEventDataObject(e){return A.ClassEventData.isInstanceOf(e)||g.ClassInstance.isInstanceOf(e)&&e.classDefinition.isSubclassOfName("event.EventData")}prepareEventDataObject(e,t,r){return A.ClassEventData.isInstanceOf(r)?(r.source=e,r.eventName=t):g.ClassInstance.isInstanceOf(r)&&(r.eventDataSource=e,r.eventDataEventName=t),r}propertyEventKey(e,t){return`${e}:${t}`}validateClassEventAccess(e,t,r){const n=e.classDefinition.findEvent(t);if(n){const s="listen"===r?n.listenAccess:n.notifyAccess;return this.context.canAccessClassMember(n.classDefinition,s)||this.context.throwEvalError(`event '${t}' has ${s} ${r} access for class ${e.classDefinition.name}.`),n}const s=e.classDefinition.findProperty(t);s&&(s.isGetObservable||s.isSetObservable)||this.context.throwEvalError(`unknown event '${t}' for class ${e.classDefinition.name}.`)}validatePropertyEventAccess(e,t,r){const n=e.classDefinition.findProperty(t);switch(n||this.context.throwEvalError(`unknown property '${t}' for class ${e.classDefinition.name}.`),r){case"PreGet":case"PostGet":return void(n.isGetObservable||this.context.throwEvalError(`property '${t}' is not GetObservable for class ${e.classDefinition.name}.`));case"PreSet":case"PostSet":return void(n.isSetObservable||this.context.throwEvalError(`property '${t}' is not SetObservable for class ${e.classDefinition.name}.`));default:this.context.throwEvalError(`unknown property event '${r}' for class ${e.classDefinition.name}.`)}}propertyListenerName(e,t,r){if(u.CharString.isInstanceOf(t))return t.str;if(_.ClassMetaProperty.isInstanceOf(t)){const r=e.classDefinition.findProperty(t.property.name);return r&&r===t.property||this.context.throwEvalError(`property '${t.property.name}' is not a property of class ${e.classDefinition.name}.`),t.property.name}this.context.throwEvalError(`${r}: property name must be a string or meta.property.`)}propertyListenerNameList(e,t,r){return d.MultiArray.linearize(t).map((t,n)=>this.propertyListenerName(e,this.expressionValue(t,`property${n+1}`),r))}addClassPropertyListenerArray(e,t,r,n,s){t.classDefinition.isHandleClass()||this.context.throwEvalError(`${e}: source must be a handle object.`),u.CharString.isInstanceOf(n)||this.context.throwEvalError(`${e}: property event name must be a string.`),p.FunctionHandle.isInstanceOf(s)||this.context.throwEvalError(`${e}: callback must be a function handle.`);const i=this.propertyListenerNameList(t,r,e),a=new d.MultiArray(r.dimension);for(let e=0;e<i.length;e++){const r=i[e];this.validatePropertyEventAccess(t,r,n.str);const[o,l]=d.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[o][l]=g.ClassInstance.addListener(t,n.str,s,this.propertyEventKey(r,n.str),"event.proplistener")}return d.MultiArray.setType(a),a}addClassListenerForSource(e,t,r,n,s,i){const a=4===i?s:n;if(t.classDefinition.isHandleClass()||this.context.throwEvalError(`${e}: source must be a handle object.`),p.FunctionHandle.isInstanceOf(a)||this.context.throwEvalError(`${e}: callback must be a function handle.`),4===i){u.CharString.isInstanceOf(n)||this.context.throwEvalError(`${e}: property event name must be a string.`);const s=this.propertyListenerName(t,r,e);return this.validatePropertyEventAccess(t,s,n.str),g.ClassInstance.addListener(t,n.str,a,this.propertyEventKey(s,n.str),"event.proplistener")}u.CharString.isInstanceOf(r)||this.context.throwEvalError(`${e}: event name must be a string.`),this.validateClassEventAccess(t,r.str,"listen");const o=t.classDefinition.findProperty(r.str);return g.ClassInstance.addListener(t,r.str,a,r.str,o?"event.proplistener":"event.listener")}addClassListener(e,...t){const[r,n,s,i]=t;if(d.MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const a=new d.MultiArray(r.dimension),o=d.MultiArray.linearize(r);for(let r=0;r<o.length;r++){const l=this.expressionValue(o[r],`source${r+1}`);g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError(`${e}: source array must contain class instances.`);const[c,u]=d.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],r);a.array[c][u]=this.addClassListenerForSource(e,l,n,s,i,t.length)}return d.MultiArray.setType(a),a}return g.ClassInstance.isInstanceOf(r)||this.context.throwEvalError(`${e}: source must be a class instance.`),4===t.length&&d.MultiArray.isInstanceOf(n)?this.addClassPropertyListenerArray(e,r,n,s,i):this.addClassListenerForSource(e,r,n,s,i,t.length)}createClassEventListenerForSource(e,t,r){return g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("event.listener: source must be a class instance."),e.classDefinition.isHandleClass()||this.context.throwEvalError("event.listener: source must be a handle object."),u.CharString.isInstanceOf(t)||this.context.throwEvalError("event.listener: event name must be a string."),p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event.listener: callback must be a function handle."),this.validateClassEventAccess(e,t.str,"listen")||this.context.throwEvalError("event.listener: event name must name a class event."),g.ClassInstance.addListener(e,t.str,r,t.str,"event.listener")}createClassEventListener(...e){const[t,r,n]=e;if(d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){const e=new d.MultiArray(t.dimension),s=d.MultiArray.linearize(t);for(let t=0;t<s.length;t++){const i=this.expressionValue(s[t],`source${t+1}`);g.ClassInstance.isInstanceOf(i)||this.context.throwEvalError("event.listener: source array must contain class instances.");const[a,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);e.array[a][o]=this.createClassEventListenerForSource(i,r,n)}return d.MultiArray.setType(e),e}return g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("event.listener: source must be a class instance."),this.createClassEventListenerForSource(t,r,n)}createClassPropertyListener(...e){return 4!==e.length&&c.AST.throwInvalidCallError("event.proplistener",!0,e=>this.context.throwEvalError(e)),this.addClassListener("listener",...e)}notifyClassEventForSource(e,t,r){e.classDefinition.isHandleClass()||this.context.throwEvalError("notify: source must be a handle object."),this.validateClassEventAccess(e,t,"notify"),this.dispatchClassEvent(e,t,r?this.prepareEventDataObject(e,t,r):this.eventData(e,t))}notifyClassEvent(e,t,r){if(u.CharString.isInstanceOf(t)||this.context.throwEvalError("notify: event name must be a string."),void 0===r||this.isEventDataObject(r)||this.context.throwEvalError("notify: event data must be an event.EventData object."),d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)){for(const n of d.MultiArray.linearize(e)){const e=this.expressionValue(n,"source");g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("notify: source array must contain class instances."),this.notifyClassEventForSource(e,t.str,r)}return c.AST.nodeVoid()}return g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("notify: source must be a class instance."),this.notifyClassEventForSource(e,t.str,r),c.AST.nodeVoid()}dispatchClassEvent(e,t,r=this.eventData(e,t)){for(const n of g.ClassInstance.listenersFor(e,t))if(!n.notifying||n.recursive){n.notifying=!0;try{this.context.apply(this.expressionValue(n.callback,"event callback"),this.classMethodArgumentValues([e,r],"event"),c.AST.nodeIdentifier("notify"))}finally{n.notifying=!1}}}dispatchClassPropertyEvent(e,t,r){const n=e.classDefinition.findProperty(t);n||this.context.throwEvalError(`unknown property '${t}' for class ${e.classDefinition.name}.`);const s=this.createClassMetaProperty(n),i=this.propertyEventData(e,t,r,s);for(const n of g.ClassInstance.listenersFor(e,this.propertyEventKey(t,r)))if(!n.notifying||n.recursive){n.notifying=!0;try{this.context.apply(this.expressionValue(n.callback,"property event callback"),this.classMethodArgumentValues([s,i],"property event"),c.AST.nodeIdentifier("addlistener"))}finally{n.notifying=!1}}if("PostGet"===r||"PostSet"===r){const r=this.propertyEventData(e,t,t,s);for(const n of g.ClassInstance.listenersFor(e,t))if(!n.notifying||n.recursive){n.notifying=!0;try{this.context.apply(this.expressionValue(n.callback,"property event callback"),this.classMethodArgumentValues([s,r],"property event"),c.AST.nodeIdentifier("addlistener"))}finally{n.notifying=!1}}}}resolveClassEventDataField(e,t){const r=S.ClassPropertyEvent.isInstanceOf(e)?S.ClassPropertyEvent.getProperty(e,t):A.ClassEventData.getProperty(e,t);return void 0===r&&("Source"!==t&&"EventName"!==t||this.context.throwEvalError(`event data ${t} is not assigned until notify dispatch.`),this.context.throwEvalError(`unknown property '${t}' for ${S.ClassPropertyEvent.isInstanceOf(e)?"event.PropertyEvent":"event.EventData"}.`)),r}setClassEventDataField(e,t){this.context.throwEvalError(`cannot assign to read-only property '${t}' for ${S.ClassPropertyEvent.isInstanceOf(e)?"event.PropertyEvent":"event.EventData"}.`)}resolveClassEventListenerField(e,t){switch(v.ClassEventListener.isValid(e)||this.context.throwEvalError("invalid or deleted event listener."),t){case"Callback":return e.callback;case"Enabled":return e.enabled?h.Complex.true():h.Complex.false();case"EventName":return u.CharString.create(e.eventName);case"Recursive":return e.recursive?h.Complex.true():h.Complex.false();case"Source":case"Object":return e.source;default:this.context.throwEvalError(`unknown property '${t}' for ${e.kind}.`)}}removeClassEventListenerRegistration(e){if(!g.ClassInstance.isInstanceOf(e.source))return;const t=e.source.listeners[e.listenerKey];if(!t)return;const r=t.indexOf(e);r>=0&&t.splice(r,1),0===t.length&&delete e.source.listeners[e.listenerKey]}addClassEventListenerRegistration(e,t){var r,n;g.ClassInstance.isInstanceOf(e.source)&&(null!==(r=(n=e.source.listeners)[t])&&void 0!==r||(n[t]=[]),e.source.listeners[t].includes(e)||e.source.listeners[t].push(e))}setClassEventListenerEventName(e,t){u.CharString.isInstanceOf(t)||this.context.throwEvalError("event listener EventName must be a string."),g.ClassInstance.isInstanceOf(e.source)||this.context.throwEvalError(`cannot assign EventName for ${e.kind}.`);let r=t.str;if("event.proplistener"===e.kind){const[n,s]=e.listenerKey.split(":");void 0===s&&this.context.throwEvalError(`cannot assign EventName for ${e.kind}.`),this.validatePropertyEventAccess(e.source,n,t.str),r=this.propertyEventKey(n,t.str)}else this.validateClassEventAccess(e.source,t.str,"listen")||this.context.throwEvalError("event listener EventName must name a class event.");this.removeClassEventListenerRegistration(e),e.eventName=t.str,e.listenerKey=r,this.addClassEventListenerRegistration(e,r)}setClassEventListenerSource(e,t){if(g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("event listener Source must be a class instance."),t.classDefinition.isHandleClass()||this.context.throwEvalError("event listener Source must be a handle object."),"event.proplistener"===e.kind){const[r,n]=e.listenerKey.split(":");void 0===n?this.validateClassEventAccess(t,e.eventName,"listen"):this.validatePropertyEventAccess(t,r,e.eventName)}else this.validateClassEventAccess(t,e.eventName,"listen")||this.context.throwEvalError("event listener Source must define the listener EventName as a class event.");this.removeClassEventListenerRegistration(e),e.source=t,this.addClassEventListenerRegistration(e,e.listenerKey)}setClassEventListenerField(e,t,r){switch(v.ClassEventListener.isValid(e)||this.context.throwEvalError("invalid or deleted event listener."),t){case"Callback":return p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event listener Callback must be a function handle."),void(e.callback=r);case"Enabled":return void(e.enabled=this.toBoolean(r));case"EventName":return void this.setClassEventListenerEventName(e,r);case"Recursive":return void(e.recursive=this.toBoolean(r));case"Source":case"Object":return void this.setClassEventListenerSource(e,r);default:this.context.throwEvalError(`cannot assign to read-only property '${t}' for ${e.kind}.`)}}resolveSetGetProperty(e,t,r){e.classDefinition.isSetGetClass()||this.context.throwEvalError(`${r}: first argument must be a matlab.mixin.SetGet object.`);const n=e.classDefinition.allProperties(),s=n.filter(e=>e.name===t);if(1===s.length)return s[0];s.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${t}' for class ${e.classDefinition.name}.`),e.classDefinition.isSetGetExactNamesClass()&&this.context.throwEvalError(`${r}: unknown property '${t}' for class ${e.classDefinition.name}.`);const i=t.toLowerCase(),a=n.filter(e=>e.name.toLowerCase()===i);if(1===a.length)return a[0];a.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${t}' for class ${e.classDefinition.name}.`);const o=n.filter(e=>e.name.toLowerCase().startsWith(i));0===o.length&&this.context.throwEvalError(`${r}: unknown property '${t}' for class ${e.classDefinition.name}.`);const l=Math.min(...o.map(e=>e.partialMatchPriority)),c=o.filter(e=>e.partialMatchPriority===l);return 1!==c.length&&this.context.throwEvalError(`${r}: ambiguous partial property name '${t}' for class ${e.classDefinition.name}.`),c[0]}isSetGetSettableProperty(e){return!(e.isConstant||"public"!==e.setAccess||e.isDependent&&!e.setMethodName&&!e.classDefinition.findMethod(`set.${e.name}`,e=>!e.isStatic))}assertSetGetSettableProperty(e,t){this.isSetGetSettableProperty(e)||this.context.throwEvalError(`${t}: property '${e.name}' is not publicly settable for class ${e.classDefinition.name}.`)}setGetObject(e,t){if(d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e))return this.setGetArrayRepresentative(e,t),e;g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError(`${t}: first argument must be a matlab.mixin.SetGet object.`);try{g.ClassInstance.throwIfDeleted(e)}catch(e){this.context.throwEvalError(e.message)}return e.classDefinition.isSetGetClass()||this.context.throwEvalError(`${t}: first argument must be a matlab.mixin.SetGet object.`),e}setGetArrayRepresentative(e,t){const r=d.MultiArray.linearize(e);0===r.length&&this.context.throwEvalError(`${t}: first argument must be a nonempty matlab.mixin.SetGet object array.`);const n=r[0];g.ClassInstance.isInstanceOf(n)||this.context.throwEvalError(`${t}: first argument must be a matlab.mixin.SetGet object.`);for(const e of r){g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError(`${t}: first argument must be a matlab.mixin.SetGet object.`);try{g.ClassInstance.throwIfDeleted(e)}catch(e){this.context.throwEvalError(e.message)}e.classDefinition.isSetGetClass()||this.context.throwEvalError(`${t}: first argument must be a matlab.mixin.SetGet object.`)}return n}setGetStructure(e){const t={};for(const r of e.classDefinition.allProperties().filter(e=>!e.isHidden&&"public"===e.getAccess))t[r.name]=this.runtimeExpressionValue(this.resolveClassInstanceField(e,r.name,c.AST.nodeIdentifier("get")),`property ${r.name}`);return new m.Structure(t)}setGetStructureArray(e){const t=new d.MultiArray([d.MultiArray.linearLength(e),1]);for(let r=0;r<d.MultiArray.linearLength(e);r++){const[n,s]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r),i=e.array[n][s];g.ClassInstance.isInstanceOf(i)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),t.array[r][0]=this.setGetStructure(i)}return d.MultiArray.setType(t),t}setGetPropertyNames(e,t){if(u.CharString.isInstanceOf(e))return[e.str];if(d.MultiArray.isInstanceOf(e)&&e.isCell){const r=d.MultiArray.linearize(e);if(r.every(u.CharString.isInstanceOf))return this.charStringList(r,`${t} property name cell array`).map(e=>e.str)}return c.AST.throwInvalidCallError(t),[]}getSetGetPropertyCell(e,t){const r=g.ClassInstance.isInstanceOf(e)?[e]:d.MultiArray.linearize(e),n=new d.MultiArray([r.length,t.length],void 0,!0);return r.forEach((e,r)=>{g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),t.forEach((t,s)=>{n.array[r][s]=this.resolveClassInstanceField(e,t.name,c.AST.nodeIdentifier("get"))})}),d.MultiArray.setType(n),n}setSetGetPropertyCell(e,t,r){t.isCell&&1===t.dimension[0]||this.context.throwEvalError("set: property name cell array must be 1-by-N."),r.isCell||c.AST.throwInvalidCallError("set");const n=d.MultiArray.linearize(t);n.every(u.CharString.isInstanceOf)||c.AST.throwInvalidCallError("set");const s=g.ClassInstance.isInstanceOf(e)?[e]:d.MultiArray.linearize(e),i=n.length;r.dimension[0]===s.length&&r.dimension[1]===i||this.context.throwEvalError(`set: property value cell array must be ${s.length}-by-${i}.`);const a=g.ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"set"),o=this.charStringList(n,"set property name cell array").map(e=>{const t=this.resolveSetGetProperty(a,e.str,"set");return this.assertSetGetSettableProperty(t,"set"),t});s.forEach((t,n)=>{g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("set: first argument must be a matlab.mixin.SetGet object."),o.forEach((s,i)=>{const a=this.assignClassInstanceField(t,s.name,r.array[n][i],c.AST.nodeIdentifier("set"),this.context.currentScope);if(d.MultiArray.isInstanceOf(e)){const[t,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n);e.array[t][r]=a}})}),d.MultiArray.isInstanceOf(e)&&d.MultiArray.setType(e)}assignSetGetProperty(e,t,r){const n=g.ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"set"),s=this.resolveSetGetProperty(n,t,"set");this.assertSetGetSettableProperty(s,"set"),g.ClassInstance.isInstanceOf(e)?this.assignClassInstanceField(e,s.name,r,c.AST.nodeIdentifier("set"),this.context.currentScope):this.assignClassArrayField(e,s.name,r,c.AST.nodeIdentifier("set"),this.context.currentScope)}setGetSettableStructure(e){const t={};for(const r of e.classDefinition.allProperties().filter(e=>!e.isHidden&&this.isSetGetSettableProperty(e)))t[r.name]=d.MultiArray.emptyArray(!0);return new m.Structure(t)}getSetGetProperty(e){const t=this.setGetObject(e[0],"get");if(1===e.length)return g.ClassInstance.isInstanceOf(t)?this.setGetStructure(t):this.setGetStructureArray(t);2===e.length&&u.CharString.isInstanceOf(e[1])||2===e.length&&d.MultiArray.isInstanceOf(e[1])&&e[1].isCell||c.AST.throwInvalidCallError("get");const r=g.ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"get"),n=this.setGetPropertyNames(e[1],"get").map(e=>this.resolveSetGetProperty(r,e,"get"));if(g.ClassInstance.isInstanceOf(t)&&u.CharString.isInstanceOf(e[1]))return this.resolveClassInstanceField(t,n[0].name,c.AST.nodeIdentifier("get"));if(d.MultiArray.isInstanceOf(t)&&u.CharString.isInstanceOf(e[1])){const e=new d.MultiArray(t.dimension,void 0,!0);for(let r=0;r<d.MultiArray.linearLength(t);r++){const[s,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r),a=t.array[s][i];g.ClassInstance.isInstanceOf(a)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),e.array[s][i]=this.resolveClassInstanceField(a,n[0].name,c.AST.nodeIdentifier("get"))}return d.MultiArray.setType(e),e}return this.getSetGetPropertyCell(t,n)}setSetGetProperties(e){const t=this.setGetObject(e[0],"set");if(1===e.length){if(g.ClassInstance.isInstanceOf(t))return this.setGetSettableStructure(t);c.AST.throwInvalidCallError("set")}if(2===e.length){if(u.CharString.isInstanceOf(e[1])){const r=g.ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"set"),n=this.resolveSetGetProperty(r,e[1].str,"set");return this.assertSetGetSettableProperty(n,"set"),d.MultiArray.emptyArray(!0)}if(m.Structure.isInstanceOf(e[1])){for(const[r,n]of Object.entries(e[1].field))this.assignSetGetProperty(t,r,n);return c.AST.nodeVoid()}c.AST.throwInvalidCallError("set")}if(m.Structure.isInstanceOf(e[1])){(e.length-2)%2!=0&&c.AST.throwInvalidCallError("set");for(const[r,n]of Object.entries(e[1].field))this.assignSetGetProperty(t,r,n);for(let r=2;r<e.length;r+=2){const n=e[r];u.CharString.isInstanceOf(n)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(t,n.str,e[r+1])}return c.AST.nodeVoid()}if(d.MultiArray.isInstanceOf(e[1])&&e[1].isCell){d.MultiArray.isInstanceOf(e[2])&&e[2].isCell||c.AST.throwInvalidCallError("set"),this.setSetGetPropertyCell(t,e[1],e[2]),(e.length-3)%2!=0&&c.AST.throwInvalidCallError("set");for(let r=3;r<e.length;r+=2){const n=e[r];u.CharString.isInstanceOf(n)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(t,n.str,e[r+1])}return c.AST.nodeVoid()}e.length%2==0&&c.AST.throwInvalidCallError("set");for(let r=1;r<e.length;r+=2){const n=e[r];u.CharString.isInstanceOf(n)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(t,n.str,e[r+1])}return c.AST.nodeVoid()}loadInterpreter(e){var t,r,n,s,i,a,o,l;this._exitStatus=W.response.OK,this.resetLastError(),this.resetWarningState(),c.AST.reload(),this.context.loadContext(),this.context.nativeNameTable=W.nativeNameTableFactory(),this.context.nativeNameSet=new Set(Object.keys(this.context.nativeNameTable)),this.context.globalScope.defineNameTable(this.context.nativeNameTable);for(const e in this.functions)this.context.defineBuiltInFunction(e,this.functions[e].func,!1,[],this.functions[e].signature);const u={inputs:{arity:1,parameters:[{name:"value",classes:["double"]}]},outputs:{arity:1}};for(const e in h.Complex.mapFunction)this.context.defineBuiltInFunction(e,h.Complex.mapFunction[e],!0,[],u);const d={inputs:{arity:2,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]}]},outputs:{arity:1}},m={logb:{inputs:{arity:2,parameters:[{name:"value",classes:["double"]},{name:"base",classes:["double"]}]},outputs:{arity:1}}};for(const e in h.Complex.twoArgFunction)this.context.defineBuiltInFunction(e,h.Complex.twoArgFunction[e],!1,[],null!==(t=m[e])&&void 0!==t?t:d);for(const e in L.Configuration.functions)this.context.defineBuiltInFunction(e,L.Configuration.functions[e].func,!1,[],L.Configuration.functions[e].signature);for(const e in M.CoreFunctions.functions)this.context.defineBuiltInFunction(e,M.CoreFunctions.functions[e].func,!1,[],M.CoreFunctions.functions[e].signature);for(const e of["properties","fieldnames","methods","events","enumeration","superclasses","isprop","ismethod"])this.context.defineBuiltInFunction(e,this.functions[e].func,!1,[],this.functions[e].signature);for(const e in I.LinearAlgebra.functions)this.context.defineBuiltInFunction(e,I.LinearAlgebra.functions[e].func,!1,[],I.LinearAlgebra.functions[e].signature);for(const e in b.MathOperation.leftAssociativeMultipleOperations)this.context.defineLeftAssociativeMultipleOperationFunction(e,b.MathOperation.leftAssociativeMultipleOperations[e]);for(const e in b.MathOperation.binaryOperations)this.context.defineBinaryOperatorFunction(e,b.MathOperation.binaryOperations[e]);for(const e in b.MathOperation.unaryOperations)this.context.defineUnaryOperatorFunction(e,b.MathOperation.unaryOperations[e]);for(const e in this.unparseMathMLFunctions)this.context.builtInFunctionTable[e].UnparserMathML=this.unparseMathMLFunctions[e];e?(this.context.setAliasNameTable(e.aliasNameTable),this.context.assignBuiltInFunctionTable(e.externalFunctionTable),this.sourceResolver=null!==(r=e.sourceResolver)&&void 0!==r?r:j.TableSourceResolver.create({functionSourceTable:null!==(s=null!==(n=e.functionSourceTable)&&void 0!==n?n:e.externalFunctionSourceTable)&&void 0!==s?s:Object.create(null),functionSourceProvider:e.functionSourceProvider,scriptSourceTable:null!==(a=null!==(i=e.scriptSourceTable)&&void 0!==i?i:e.externalScriptSourceTable)&&void 0!==a?a:Object.create(null),scriptSourceProvider:e.scriptSourceProvider,classSourceTable:null!==(l=null!==(o=e.classSourceTable)&&void 0!==o?o:e.externalClassSourceTable)&&void 0!==l?l:Object.create(null),classSourceProvider:e.classSourceProvider}),this.pathValidationCallbacks={fileExists:e.fileExists,folderExists:e.folderExists},e.externalCmdWListTable&&Object.assign(this.commandWordListTable,e.externalCmdWListTable)):(this.context.aliasNameFunction=e=>e,this.sourceResolver=j.TableSourceResolver.create(),this.pathValidationCallbacks={}),this.refreshCommandWordListNames()}constructor(e,t){this._debug=!1,this.commandWordListTable={clear:{preserveAssignment:!0,func:(...e)=>(this.Clear(...e),c.AST.nodeVoid())},run:{preserveAssignment:!0,func:(...e)=>(1!==e.length&&this.context.throwEvalError("Invalid call to run."),this.RunScriptFile(e[0],this.context.currentScope))},source:{preserveAssignment:!0,func:(...e)=>{(e.length<1||e.length>2)&&this.context.throwEvalError("Invalid call to source.");const t=2===e.length?this.context.resolveWorkspace(e[1]):this.context.currentScope;return this.RunScriptFile(e[0],t)}},exist:{preserveAssignment:!0,func:(...e)=>((e.length<1||e.length>2)&&c.AST.throwInvalidCallError("exist",!0,e=>this.context.throwSyntaxError(e)),h.Complex.create(this.existCode(e[0],e[1])))},which:{preserveAssignment:!0,func:(...e)=>{const t=e.join(" ").match(/^\(([\s\S]*)\)$/);if(t){const e=this.evaluatedExecutionResult(this.Parse(t[1]),this.context.currentScope),r="LIST"===e.type&&1===e.list.length?e.list[0]:e;return this.functions.which.func(r)}return c.AST.throwInvalidCallError("which",e.length<1,e=>this.context.throwSyntaxError(e)),new u.CharString(e.map(e=>this.whichResult(e).str).join("\n"))}},who:{func:(...e)=>this.whoResultFromPatterns(e)},whos:{func:(...e)=>this.whosResultFromPatterns(e)},isglobal:{func:(...e)=>(c.AST.throwInvalidCallError("isglobal",1!==e.length,e=>this.context.throwSyntaxError(e)),this.isGlobalName(e[0])?h.Complex.true():h.Complex.false())},dbstack:{func:(...e)=>{const t=e.map(e=>/^\d+$/.test(e)?h.Complex.create(Number(e)):new u.CharString(e));return this.dbstackResult(t)}},warning:{func:(...e)=>{var t;const r=this.warningControlResult(e.map(e=>new u.CharString(e)));return r?"query"===(null===(t=e[0])||void 0===t?void 0:t.toLowerCase())?r:c.AST.nodeVoid():this.warningResult(this.diagnosticCommandArguments(e))}},error:{func:(...e)=>this.errorResult(this.diagnosticCommandArguments(e))},__operators__:{func:(...e)=>{const t=Object.keys(this.opTable).sort(),r=new d.MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new u.CharString(e)]),r}},__keywords__:{func:(...e)=>{const t=i.default.keywordNames.slice(1).sort(),r=new d.MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new u.CharString(e)]),r}},__builtins__:{func:(...e)=>{const t=new d.MultiArray([this.context.builtInFunctionList.length,1],null,!0);return t.array=this.context.builtInFunctionList.sort().map(e=>[new u.CharString(e)]),t}},__list_functions__:{func:(...e)=>d.MultiArray.emptyArray(!0)},__dump_symtab_info__:{func:(...e)=>d.MultiArray.emptyArray(!0)}},this.commandWordListNameSet=new Set,this.assignmentSensitiveCommandNameSet=new Set,this.sourceResolver=j.TableSourceResolver.create(),this.pathValidationCallbacks={},this.loadingFunctionNames=new Set,this.loadingClassNames=new Set,this.loadingClassMethodNames=new Set,this.scriptExecutionDepth=0,this.scriptSourceNameStack=[],this.lastWarning={message:"",identifier:""},this.globalWarningState="on",this.warningIdentifierStates=new Map,this.opTable={"+":b.MathOperation.plus,"-":b.MathOperation.minus,".*":b.MathOperation.times,"*":b.MathOperation.mtimes,"./":b.MathOperation.rdivide,"/":b.MathOperation.mrdivide,".\\":b.MathOperation.ldivide,"\\":b.MathOperation.mldivide,".^":b.MathOperation.power,"^":b.MathOperation.mpower,"+_":b.MathOperation.uplus,"-_":b.MathOperation.uminus,".'":b.MathOperation.transpose,"'":b.MathOperation.ctranspose,"<":b.MathOperation.lt,"<=":b.MathOperation.le,"==":b.MathOperation.eq,">=":b.MathOperation.ge,">":b.MathOperation.gt,"!=":b.MathOperation.ne,"&":b.MathOperation.and,"|":b.MathOperation.or,"!":b.MathOperation.not,"&&":b.MathOperation.mand,"||":b.MathOperation.mor,"++_":this.incDecOpFactory(!0,"plus"),"--_":this.incDecOpFactory(!0,"minus"),"_++":this.incDecOpFactory(!1,"plus"),"_--":this.incDecOpFactory(!1,"minus")},this.functions=Object.assign(Object.assign({unparse:{func:e=>new u.CharString(this.Unparse(e)),signature:{inputs:{arity:1},outputs:{arity:1}}},clear:{func:(...e)=>(this.Clear(...e.map(e=>this.charControlArgument(e,"clear name").str)),c.AST.nodeVoid()),signature:{inputs:{arity:-1,min:0,parameters:[{name:"name",classes:["char","string"],variadic:!0}]},outputs:{arity:0}}},who:{func:(...e)=>this.whoResult(e),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},whos:{func:(...e)=>this.whosResult(e),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},iskeyword:{func:(...e)=>this.isKeywordResult(e),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"name",classes:["char","string","cell"],optional:!0}]},outputs:{arity:1}}},isvarname:{func:(...e)=>this.isVarNameResult(e),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},isglobal:{func:(...e)=>this.isGlobalResult(e),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},namelengthmax:{func:(...e)=>(c.AST.throwInvalidCallError("namelengthmax",0!==e.length,e=>this.context.throwEvalError(e)),h.Complex.create(W.nameLengthMax)),signature:{inputs:{arity:0},outputs:{arity:1}}},class:{func:(...e)=>new u.CharString(this.getValueClassName(e[0])),signature:{inputs:{arity:1},outputs:{arity:1}}},isa:{func:(...e)=>this.valueIsRuntimeClass(e[0],this.charControlArgument(e[1],"class name").str)?h.Complex.true():h.Complex.false(),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},isclass:{func:(...e)=>this.isClassName(this.charControlArgument(e[0],"class name").str)?h.Complex.true():h.Complex.false(),signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},metaclass:{func:(...e)=>this.metaclassArgument(e[0]),signature:{inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}}},__meta_class_fromName:{func:(...e)=>{const t=this.context.resolveClassDefinition(this.charControlArgument(e[0],"class name").str);return t?this.createClassMetaClass(t):d.MultiArray.emptyArray()},signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},properties:{func:(...e)=>M.CoreFunctions.properties(this.classIntrospectionArgument("properties",e[0])),signature:M.CoreFunctions.propertiesSignature},fieldnames:{func:(...e)=>M.CoreFunctions.fieldnames(this.classIntrospectionArgument("fieldnames",e[0])),signature:M.CoreFunctions.fieldnamesSignature},methods:{func:(...e)=>M.CoreFunctions.methods(this.classIntrospectionArgument("methods",e[0])),signature:M.CoreFunctions.methodsSignature},events:{func:(...e)=>M.CoreFunctions.events(this.classIntrospectionArgument("events",e[0])),signature:M.CoreFunctions.eventsSignature},enumeration:{func:(...e)=>M.CoreFunctions.enumeration(this.classIntrospectionArgument("enumeration",e[0])),signature:M.CoreFunctions.enumerationSignature},superclasses:{func:(...e)=>M.CoreFunctions.superclasses(this.classIntrospectionArgument("superclasses",e[0])),signature:M.CoreFunctions.superclassesSignature},isprop:{func:(...e)=>M.CoreFunctions.isprop(this.classIntrospectionArgument("isprop",e[0]),e[1]),signature:M.CoreFunctions.ispropSignature},ismethod:{func:(...e)=>M.CoreFunctions.ismethod(this.classIntrospectionArgument("ismethod",e[0]),e[1]),signature:M.CoreFunctions.ismethodSignature},addlistener:{func:(...e)=>this.addClassListener("addlistener",...e),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},listener:{func:(...e)=>this.addClassListener("listener",...e),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},"event.listener":{func:(...e)=>this.createClassEventListener(...e),signature:{inputs:{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},"event.EventData":{func:()=>A.ClassEventData.create(),signature:{inputs:{arity:0},outputs:{arity:1}}},"event.proplistener":{func:(...e)=>this.createClassPropertyListener(...e),signature:{inputs:{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},notify:{func:(...e)=>this.notifyClassEvent(e[0],e[1],e[2]),signature:{inputs:[{arity:2,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]}]},{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"eventData"}]}],outputs:{arity:0}}},get:{func:(...e)=>this.getSetGetProperty(e),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell"]}]}],outputs:{arity:-1}}},set:{func:(...e)=>this.setSetGetProperties(e),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyNameOrStruct"}]},{arity:-1,min:3,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell","struct"]},{name:"propertyValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},mfilename:{func:(...e)=>{const t=1===e.length?this.charControlArgument(e[0],"mfilename option").str:"";return"class"===t?new u.CharString(this.context.currentClassAccessName()):"fullpath"===t?new u.CharString(this.currentMFilenameFullPath()):new u.CharString(this.currentMFilename())},signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"option",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},dbstack:{func:(...e)=>this.dbstackResult(e),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"optionOrCount",optional:!0,variadic:!0,alternatives:[{name:"option",classes:["char","string"],allowedStrings:["-completenames"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]}]},outputs:{arity:-1}}},lasterror:{func:(...e)=>this.lastErrorResult(e),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"error",optional:!0,alternatives:[{name:"reset",classes:["char","string"],allowedStrings:["reset"]},{name:"errorStruct",classes:["struct"]}]}]},outputs:{arity:-1}}},lasterr:{func:(...e)=>this.lastErrorMessageResult(e),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},lastwarn:{func:(...e)=>this.lastWarningResult(e),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},deal:{func:(...e)=>this.dealResult(e),signature:{inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:-1}}},subsref:{func:(...e)=>this.subsrefResult(e[0],e[1]),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"subscript",classes:["struct"]}]},outputs:{arity:-1,min:0}}},subsasgn:{func:(...e)=>this.subsasgnResult(e[0],e[1],e[2]),signature:{inputs:{arity:3,parameters:[{name:"value"},{name:"subscript",classes:["struct"]},{name:"newValue"}]},outputs:{arity:1}}},warning:{func:(...e)=>this.warningResult(e),signature:{inputs:[{arity:0},{arity:1,parameters:[{name:"stateStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},error:{func:(...e)=>this.errorResult(e),signature:{inputs:[{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:0}}},assert:{func:(...e)=>this.assertResult(e),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}},rethrow:{func:(...e)=>this.rethrowResult(e[0]),signature:{inputs:{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},outputs:{arity:0}}},exist:{func:(...e)=>h.Complex.create(this.existCode(this.charControlArgument(e[0],"name").str,2===e.length?this.charControlArgument(e[1],"kind").str:void 0)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"name",classes:["char","string"]},{name:"kind",classes:["char","string"],optional:!0}]},outputs:{arity:1}}},which:{func:(...e)=>{var t;if(p.FunctionHandle.isInstanceOf(e[0])){const r=this.functionHandleControlArgument(e[0],"function handle");return this.whichResult(null!==(t=r.id)&&void 0!==t?t:p.FunctionHandle.unparse(r,this).trim(),r)}return this.whichResult(this.charControlArgument(e[0],"name").str)},signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","function_handle"]}]},outputs:{arity:1}}},validatestring:{func:(...e)=>this.validatestringResult(e),signature:{inputs:{arity:-1,min:2,max:5,parameters:[{name:"string",classes:["char","string"]},{name:"validStrings",classes:["char","string","cell"]},{name:"functionName",classes:["char","string"],optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:1}}},validateattributes:{func:(...e)=>this.validateattributesResult(e),signature:{inputs:{arity:-1,min:3,max:6,parameters:[{name:"value"},{name:"classes",classes:["char","string","cell"]},{name:"attributes",classes:["char","string","cell"]},{name:"functionNameOrArgumentPosition",optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:0}}}},this.mustBeFunctionEntries()),{func2str:{func:(...e)=>k.FunctionLookup.func2str(this.functionHandleControlArgument(e[0],"function handle"),e=>p.FunctionHandle.unparse(e,this)),signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},str2func:{func:(...e)=>{const t=e.length>1?this.charControlArgument(e[1],"scope").str.trim().toLowerCase():"";return this.functionHandleFromString(this.charControlArgument(e[0],"source"),"global"===t)},signature:{inputs:{arity:-1,min:1,max:2,parameters:[{name:"source",classes:["char","string"]},{name:"scope",classes:["char","string"],allowedStrings:["global"],optional:!0}]},outputs:{arity:1}}},builtin:{func:(...e)=>{const t=this.charControlArgument(e[0],"builtin function").str.trim();0===t.length&&this.context.throwEvalError("builtin: function name cannot be empty.");const r=this.context.aliasNameFunction(t),n=this.context.builtInFunctionTable[r];return n||this.context.throwEvalError(`builtin: '${t}' is not a built-in function.`),this.context.callCallable(H.Callables.builtin(n),this.callArgumentValues(e.slice(1),"builtin"),c.AST.nodeIdentifier("builtin"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},feval:{func:(...e)=>{let t=this.expressionValue(e[0],"feval target");if(u.CharString.isInstanceOf(t)){const r=t.str.trim();0===r.length&&this.context.throwEvalError("feval: function name cannot be empty.");const n=r.startsWith("@")?void 0:this.resolveStaticMethod(r,this.context.currentScope);if(n)return this.context.callClassStaticMethod(n.method,this.callArgumentValues(e.slice(1),"feval"),c.AST.nodeIdentifier("feval"));t=r.startsWith("@")?this.functionHandleFromString(t):this.createResolvedFunctionHandle(r,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(t);return r||this.context.throwEvalError("feval: first argument must be a function handle or function name."),this.context.callCallable(r,this.callArgumentValues(e.slice(1),"feval"),c.AST.nodeIdentifier("feval"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string","function_handle"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},spfun:{func:(...e)=>{const t=this.context.resolveCallable(this.expressionValue(e[0],"spfun function"));t||this.context.throwEvalError("spfun: first argument must be a function handle.");const r=d.MultiArray.scalarToMultiArray(this.expressionValue(e[1],"spfun input")),n=new d.MultiArray(r.dimension,h.Complex.zero()),s=d.MultiArray.linearize(r);for(let e=0;e<s.length;e++){if(!M.CoreFunctions.isNonzeroElement(s[e]))continue;const i=this.expressionValue(U.RuntimeValue.copy(s[e]),"spfun value"),a=this.expressionValue(this.context.callCallable(t,[i],c.AST.nodeIdentifier("spfun")),"spfun result"),o=d.MultiArray.MultiArrayToScalar(a);d.MultiArray.isInstanceOf(o)&&this.context.throwEvalError("spfun: function must return a scalar value for each nonzero element.");const[l,u]=d.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],e);n.array[l][u]=U.RuntimeValue.copy(o)}return d.MultiArray.setType(n),d.MultiArray.MultiArrayToScalar(n)},signature:{inputs:{arity:2,parameters:[{name:"function",classes:["function_handle"]},{name:"value",alternatives:[{name:"numericValue",classes:["double"]},{name:"logicalValue",classes:["logical"]}]}]},outputs:{arity:1}}},functions:{func:(...e)=>{var t;const r=this.functionHandleControlArgument(e[0],"function handle"),n=null!==(t=r.closure)&&void 0!==t?t:this.context.currentScope;return k.FunctionLookup.functionsInfo(r,e=>this.context.aliasNameFunction(e),e=>{var t;return null===(t=this.context.resolveSymbol(e,n,{variables:!1,classes:!1,loadFunctions:!1}))||void 0===t?void 0:t.functionDefinition},e=>p.FunctionHandle.unparse(e,this),e=>this.functionHandleWorkspaceInfo(e),(e,t)=>{var r;return this.staticMethodInfo(e,null!==(r=null==t?void 0:t.closure)&&void 0!==r?r:this.context.currentScope)})},signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},localfunctions:{func:(...e)=>this.localFunctionHandles(),signature:{inputs:{arity:0},outputs:{arity:1}}},nargin:{func:(...e)=>0===e.length?this.context.currentFunctionArgumentCount("nargin"):h.Complex.create(this.functionArgumentArity(this.functionArityCallable("nargin",e[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},narginchk:{func:(...e)=>this.checkFunctionCount("narginchk",e[0],e[1]),signature:{inputs:{arity:2,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0}]},outputs:{arity:0}}},nargchk:{func:(...e)=>this.nargchkResult(e),signature:{inputs:{arity:-1,min:3,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"inputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nargout:{func:(...e)=>0===e.length?this.context.currentFunctionOutputCount("nargout"):h.Complex.create(this.functionOutputArity(this.functionArityCallable("nargout",e[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},isargout:{func:(...e)=>this.context.currentFunctionOutputIsRequested(e[0]),signature:{inputs:{arity:1,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]}]},outputs:{arity:1}}},nargoutchk:{func:(...e)=>this.nargoutchkResult(e),signature:{inputs:{arity:-1,min:2,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"outputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],optional:!0},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nthargout:{func:(...e)=>this.nthargoutResult(e),signature:{inputs:{arity:-2,min:2,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]},{name:"functionOrTotalOutputCount"},{name:"argument",variadic:!0}]},outputs:{arity:1}}},inputname:{func:(...e)=>{const t=2!==e.length||this.booleanControlArgument(e[1],"inputname onlyVariableNames");return this.context.currentFunctionInputName(e[0],t,e=>this.Unparse(e))},signature:{inputs:[{arity:1,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]}]},{arity:2,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"onlyVariableNames",classes:["logical"],validators:["scalar"]}]}],outputs:{arity:1}}},eval:{func:(...e)=>F.FunctionWorkspace.evaluateWithCatch(this.context.currentScope,this.charControlArgument(e[0],"eval code").str,2===e.length?this.charControlArgument(e[1],"eval catch code").str:void 0,(e,t)=>this.evalStringInScope(e,t),e=>this.isEvalCatchableError(e),e=>this.rememberLastError(e)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalc:{func:(...e)=>this.evalcResult(this.charControlArgument(e[0],"evalc code").str,2===e.length?this.charControlArgument(e[1],"evalc catch code").str:void 0),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalin:{func:(...e)=>{const t=this.charControlArgument(e[0],"workspace").str,r=this.context.resolveWorkspace(t,!1,"caller"===t);return F.FunctionWorkspace.evaluateWithCatch(r,this.charControlArgument(e[1],"evalin code").str,3===e.length?this.charControlArgument(e[2],"evalin catch code").str:void 0,(e,r)=>this.evalStringInScope(e,r,{topLevelReturn:"base"===t}),e=>this.isEvalCatchableError(e),e=>this.rememberLastError(e))},signature:{inputs:{arity:-3,min:2,max:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},run:{func:(...e)=>this.RunScriptFile(this.charControlArgument(e[0],"script").str,this.context.currentScope),signature:{inputs:{arity:1,parameters:[{name:"script",classes:["char","string"]}]},outputs:{arity:1}}},source:{func:(...e)=>{const t=2===e.length?this.context.resolveWorkspace(this.charControlArgument(e[1],"workspace").str):this.context.currentScope;return this.RunScriptFile(this.charControlArgument(e[0],"script").str,t)},signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"script",classes:["char","string"]},{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"],optional:!0}]},outputs:{arity:1}}},assignin:{func:(...e)=>{const t=this.context.resolveWorkspace(this.charControlArgument(e[0],"workspace").str,!0),r=this.pushDynamicNameCreationGuard(t);try{return F.FunctionWorkspace.assignIn(t,this.charControlArgument(e[1],"name").str,this.runtimeExpressionValue(e[2],"assignin value"))}finally{r()}},signature:{inputs:{arity:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"name",classes:["char","string"],identifier:!0},{name:"value"}]},outputs:{arity:0}}}}),this.unparseMathMLFunctions={logb:e=>{let t=this.UnparserMathML(e.args[1]);return this.nodePrecedence(e.args[1])<this.precedenceTable.max&&(t=w.MathML.format["()"]("(",t,")")),w.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=w.MathML.format["()"]("(",t,")")),w.MathML.format.log2(t)},log10:e=>{let t=this.UnparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this.precedenceTable.max&&(t=w.MathML.format["()"]("(",t,")")),w.MathML.format.log10(t)},factorial:e=>{let t=this.UnparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this.precedenceTable.max&&(t=w.MathML.format["()"]("(",t,")")),w.MathML.format.factorial(t)}},this.opTable["**"]=this.opTable["^"],this.opTable[".**"]=this.opTable[".^"],this.opTable["~="]=this.opTable["!="],this.opTable["~"]=this.opTable["!"],this.precedenceTable={},W.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["!"],t?(this.context=t,this.context.interpreter=this):this.context=q.Context.create(this),this.loadInterpreter(e)}Parse(e){var t;const r=s.CharStreams.fromString(e),n=new i.default(r);n.commandNames=this.commandWordListNameSet,n.assignmentSensitiveCommandNames=this.assignmentSensitiveCommandNameSet;const u=new s.CommonTokenStream(n),h=new a.default(u);return h.buildParseTrees=!0,n.removeErrorListeners(),n.addErrorListener(new o.LexerErrorListener(e)),h.removeErrorListeners(),h.addErrorListener(new l.ParserErrorListener(e)),this._debug,null!==(t=h.input().node)&&void 0!==t?t:c.AST.nodeVoid()}Restart(){this.loadInterpreter()}Clear(...e){if(0===e.length)this.context.clearCurrentVariables();else{const t=this.clearCommandOptions(e);if(!t)return;this.clearCommandCategory(t)}}clearAllWorkspaceCategories(){this.context.clearCurrentVariables(),this.context.clearGlobalVariables(),this.context.clearClassDefinitions(),this.context.currentScope.clearImports(),this.clearUserFunctions()}clearCommandOptions(e){const t={category:"visible",regexp:!1,exclusive:!1,patterns:[]};for(let r=0;r<e.length;r++)switch(e[r]){case"all":case"-all":case"-a":return void this.clearAllWorkspaceCategories();case"import":return(this.context.isInsideUserFunction()||this.scriptExecutionDepth>0)&&this.context.throwEvalError("clear import is not allowed inside a function or script."),void this.context.currentScope.clearImports();case"variables":case"-variables":case"-v":t.category="variables";break;case"functions":case"-functions":case"-f":t.category="functions";break;case"classes":case"-classes":case"-c":t.category="classes";break;case"global":case"-global":case"-g":t.category="global";break;case"regexp":case"-regexp":case"-r":t.regexp=!0;break;case"-exclusive":case"-x":t.exclusive=!0;break;default:return t.patterns=e.slice(r),t}return t}clearCommandCategory(e){switch(e.category){case"variables":return void this.context.clearCurrentVariables(this.selectClearPatternMatches(e.patterns,this.clearVariableCandidates(),e));case"functions":return void this.clearUserFunctions(this.selectClearPatternMatches(e.patterns,this.clearFunctionCandidates(),e));case"classes":return void this.clearClassDefinitions(this.selectClearPatternMatches(e.patterns,this.clearClassCandidates(),e));case"global":return void this.context.clearGlobalVariables(this.selectClearPatternMatches(e.patterns,[...this.context.globalNameSet],e));case"visible":return void this.clearVisibleSymbols(e)}}clearVisibleSymbols(e){var t;if(0===e.patterns.length){if(e.regexp||e.exclusive)return;return void this.context.clearCurrentVariables()}const r={regexp:e.regexp,exclusive:e.exclusive};if(e.exclusive)this.context.clearCurrentVariables(this.selectClearPatternMatches(e.patterns,this.clearVariableCandidates(),r));else if(e.regexp||e.patterns.some(e=>this.clearPatternHasWildcards(e)))for(const n of null!==(t=this.selectClearPatternMatches(e.patterns,this.clearVisibleCandidates(),r))&&void 0!==t?t:[])this.clearNamedSymbol(n);else for(const t of e.patterns)this.clearNamedSymbol(t)}clearPatternHasWildcards(e){return/[*?\[]/.test(e)}clearPatternRegExp(e){let t="^";for(let r=0;r<e.length;r++){const n=e[r];if("*"===n)t+=".*";else if("?"===n)t+=".";else if("["===n){const n=e.indexOf("]",r+1);n>r+1?(t+=`[${e.slice(r+1,n).replace(/\\/g,"\\\\")}]`,r=n):t+="\\["}else t+=n.replace(/[\\^$+?.()|{}]/g,"\\$&")}return new RegExp(t+"$")}clearPatternOptions(e,t={}){var r,n;let s=null!==(r=t.regexp)&&void 0!==r&&r,i=null!==(n=t.exclusive)&&void 0!==n&&n,a=0;for(;a<e.length;){const t=e[a];if("-regexp"===t||"-r"===t||"regexp"===t)s=!0,a++;else{if("-exclusive"!==t&&"-x"!==t)break;i=!0,a++}}return{patterns:e.slice(a),regexp:s,exclusive:i}}clearPatternMatches(e,t,r){return r?new RegExp(t).test(e):this.clearPatternRegExp(t).test(e)}selectClearPatternMatches(e,t,r={}){if(!e)return;if(0===e.length)return r.regexp||r.exclusive?[]:void 0;const n=this.clearPatternOptions(e,r);if(0===n.patterns.length)return r.regexp||r.exclusive?[]:void 0;if(n.exclusive)return t.filter(e=>!n.patterns.some(t=>this.clearPatternMatches(e,t,n.regexp)));const s=[],i=e=>{s.includes(e)||s.push(e)};for(const e of n.patterns)n.regexp||this.clearPatternHasWildcards(e)?t.filter(t=>this.clearPatternMatches(t,e,n.regexp)).forEach(i):i(e);return s}clearVariableCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(e=>{const t=this.context.currentScope.nameTable[e];return!this.context.nativeNameSet.has(e)&&!f.ClassDefinition.isInstanceOf(null==t?void 0:t.node)})}visibleWorkspaceVariableEntries(){return Object.entries(this.context.currentScope.nameTable).filter(([e,t])=>!this.context.nativeNameSet.has(e)&&!f.ClassDefinition.isInstanceOf(null==t?void 0:t.node)).sort(([e],[t])=>e.localeCompare(t))}workspaceListingOptions(e,t){const r={globalOnly:!1,regexp:!1,patterns:[]};for(let n=0;n<e.length;n++){const s=e[n],i=s.toLowerCase();"global"===i||"-global"===i?r.globalOnly=!0:"-regexp"===i||"-r"===i||"regexp"===i?r.regexp=!0:"-file"===i||"file"===i?this.context.throwEvalError(`${t}: MAT-file workspace listing is not supported in the browser runtime.`):r.patterns.push(s)}return r}workspaceVariableNamesByPatterns(e,t){const r=this.workspaceListingOptions(e,t),n=this.visibleWorkspaceVariableEntries().filter(([e])=>!r.globalOnly||this.context.globalNameSet.has(e)).map(([e])=>e);if(0===r.patterns.length)return r.regexp?[]:n;const s=[],i=e=>{s.includes(e)||s.push(e)};for(const e of r.patterns){const t=this.clearPatternHasWildcards(e);n.filter(n=>r.regexp||t?this.clearPatternMatches(n,e,r.regexp):n===e).forEach(i)}return s}whoResult(e){const t=e.map(e=>this.charControlArgument(e,"who pattern").str);return this.whoResultFromPatterns(t)}whoResultFromPatterns(e){const t=d.MultiArray.toColumnVector(this.workspaceVariableNamesByPatterns(e,"who").map(e=>u.CharString.create(e,"'")));return t.isCell=!0,t}whosValueSize(e){return d.MultiArray.isInstanceOf(e)?e.dimension:u.CharString.isChar(e)?[1,e.str.length]:[1,1]}whosValueBytes(e){return h.Complex.isInstanceOf(e)?16:u.CharString.isInstanceOf(e)?2*e.str.length:d.MultiArray.isInstanceOf(e)?d.MultiArray.linearize(e).reduce((e,t)=>e+this.whosValueBytes(this.expressionValue(t,"whos element")),0):m.Structure.isInstanceOf(e)?Object.values(e.field).reduce((e,t)=>e+this.whosValueBytes(this.expressionValue(t,"whos field")),0):0}whosValueIsComplex(e){return h.Complex.isInstanceOf(e)?!h.Complex.isRealValue(e):d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearize(e).some(e=>h.Complex.isInstanceOf(e)&&!h.Complex.isRealValue(e))}whosResult(e){const t=e.map(e=>this.charControlArgument(e,"whos pattern").str);return this.whosResultFromPatterns(t)}whosResultFromPatterns(e){const t=new Set(this.workspaceVariableNamesByPatterns(e,"whos")),r=this.visibleWorkspaceVariableEntries().filter(([e])=>t.has(e)),n=d.MultiArray.toColumnVector(r.map(([e,t])=>{const r=this.expressionValue(t.node,`workspace variable ${e}`);return new m.Structure({name:u.CharString.create(e,"'"),size:d.MultiArray.toRowVector(this.whosValueSize(r).map(e=>h.Complex.create(e))),bytes:h.Complex.create(this.whosValueBytes(r)),class:u.CharString.create(this.getValueClassName(r),"'"),global:this.context.globalNameSet.has(e)?h.Complex.true():h.Complex.false(),sparse:h.Complex.false(),complex:this.whosValueIsComplex(r)?h.Complex.true():h.Complex.false(),nesting:new m.Structure({function:u.CharString.create("","'"),level:h.Complex.create(0)}),persistent:h.Complex.false()})}));return d.MultiArray.setType(n),n}keywordListResult(){const e=d.MultiArray.toColumnVector(W.keywordNames.map(e=>u.CharString.create(e,"'")));return e.isCell=!0,e}textNamePredicateResult(e,t,r){if(u.CharString.isInstanceOf(e))return r(e.str)?h.Complex.true():h.Complex.false();d.MultiArray.isInstanceOf(e)||c.AST.throwInvalidCallError(t,!0,e=>this.context.throwEvalError(e));const n=new d.MultiArray(e.dimension);for(let t=0;t<d.MultiArray.linearLength(e);t++){const[s,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t),a=e.array[s][i];n.array[s][i]=u.CharString.isInstanceOf(a)&&r(a.str)?h.Complex.true():h.Complex.false()}return d.MultiArray.setType(n),d.MultiArray.MultiArrayToScalar(n)}isKeywordResult(e){return c.AST.throwInvalidCallError("iskeyword",e.length>1,e=>this.context.throwEvalError(e)),0===e.length?this.keywordListResult():this.textNamePredicateResult(e[0],"iskeyword",e=>W.keywordNameSet.has(e))}isVarNameResult(e){return c.AST.throwInvalidCallError("isvarname",1!==e.length,e=>this.context.throwEvalError(e)),this.textNamePredicateResult(e[0],"isvarname",e=>/^[A-Za-z][A-Za-z0-9_]*$/.test(e)&&e.length<=W.nameLengthMax&&!W.keywordNameSet.has(e))}isGlobalName(e){return this.context.globalNameSet.has(e)}isGlobalResult(e){return c.AST.throwInvalidCallError("isglobal",1!==e.length,e=>this.context.throwEvalError(e)),this.textNamePredicateResult(e[0],"isglobal",e=>this.isGlobalName(e))}clearFunctionCandidates(){return this.visibleUserFunctionNames()}visibleUserFunctionNames(){const e=[],t=new Set;let r=this.context.currentScope;for(;r;){for(const[n,s]of Object.entries(r.functionTable))t.has(n)||"FCNDEF"!==(null==s?void 0:s.type)||(e.push(n),t.add(n));r=r.parent}return e}hasVisibleUserFunction(e){var t;let r=this.context.currentScope;for(;r;){if("FCNDEF"===(null===(t=r.functionTable[e])||void 0===t?void 0:t.type))return!0;r=r.parent}return!1}clearVisibleUserFunction(e){return!!this.hasVisibleUserFunction(e)&&(this.context.currentScope.clearFunction(e),!0)}clearClassCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(e=>{var t;return f.ClassDefinition.isInstanceOf(null===(t=this.context.currentScope.nameTable[e])||void 0===t?void 0:t.node)})}clearVisibleCandidates(){return[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()]}clearClassDefinitions(e){if(e)for(const t of e)this.clearNamedSymbol(t);else this.context.clearClassDefinitions()}clearNamedPattern(e){var t;if(!this.clearPatternHasWildcards(e))return void this.clearNamedSymbol(e);const r=[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()];for(const n of null!==(t=this.selectClearPatternMatches([e],r))&&void 0!==t?t:[])this.clearNamedSymbol(n)}clearNamedSymbol(e){var t;const r=this.resolveRuntimeSymbol(e,this.context.currentScope,{loadClasses:!1,loadFunctions:!1}),n=null!==(t=null==r?void 0:r.resolvedName)&&void 0!==t?t:this.context.aliasNameFunction(e),s=new Set([e,n]);let i=!1;for(const e of s)this.context.currentScope.hasLocalName(e)&&(this.context.currentScope.removeName(e),i=!0,this.context.nativeNameSet.has(e)&&this.context.globalScope.defineName(e,this.context.nativeNameTable[e]));if(!i)for(const e of s)if(this.clearVisibleUserFunction(e))break}clearUserFunctions(e){var t;const r=e||this.clearFunctionCandidates();for(const e of r){const r=this.resolveRuntimeSymbol(e,this.context.currentScope,{variables:!1,classes:!1,loadClasses:!1,loadFunctions:!1}),n=null!==(t=null==r?void 0:r.resolvedName)&&void 0!==t?t:this.context.aliasNameFunction(e);for(const t of new Set([e,n]))this.clearVisibleUserFunction(t)}}validateAssignment(e,t,r=this.context.currentScope){const n="invalid left hand side of assignment",s=(e,t,r,n)=>{const s={done:!1},i=()=>c.AST.nodeList([this.expressionValue(h.Complex.create(r+1),"index")]),a=e=>{if(c.AST.isNodeIdentifier(e)){const r=c.AST.nodeIdentifier(e.id);return"insert-at-identifier"!==n||s.done?r:(s.done=!0,c.AST.nodeIndexExpr(r,i(),t))}if(c.AST.isNodeIgnoredTarget(e))return c.AST.nodeIgnoredTarget();if(c.AST.isNodeIndexExpr(e)){const r=a(e.expr);return"replace-first-index"!==n||s.done?c.AST.nodeIndexExpr(r,c.AST.nodeList(e.args.map(e=>this.cloneAssignmentTarget(e))),e.delim):(s.done=!0,c.AST.nodeIndexExpr(r,i(),t))}if(c.AST.isNodeIndirectRef(e)){const t=e.field[0];let r=c.AST.nodeIndirectRef(a(e.obj),"string"==typeof t?t:this.cloneAssignmentTarget(t));for(let t=1;t<e.field.length;t++){const n=e.field[t];r=c.AST.nodeIndirectRef(r,"string"==typeof n?n:this.cloneAssignmentTarget(n))}return r}return this.cloneAssignmentTarget(e)};return a(e)},i=n=>{if(t||!n.descriptors||0===n.descriptors.length)return[n];const i=r.resolveName(n.id);if(!i||!d.MultiArray.isInstanceOf(i.node))return[n];const a=this.readNativeSubscriptDescriptor(n.descriptors[0],"subsasgn"),o=n.descriptors[1]?this.readNativeSubscriptDescriptor(n.descriptors[1],"subsasgn"):void 0,l=i.node.isCell&&"()"===a.type&&"{}"===(null==o?void 0:o.type);if(i.node.isCell&&"{}"!==a.type&&!l)return[n];if(!i.node.isCell&&!m.Structure.isStructure(i.node)&&!this.hasClassInstanceElement(i.node))return[n];const c="()"===a.type,u="{}"===a.type,p=c||u?d.MultiArray.resolveLinearIndices(i.node,n.id,this.nativeDescriptorIndexList(a,i.node),this):d.MultiArray.resolveLinearIndices(i.node,n.id,[d.MultiArray.expandColon(d.MultiArray.linearLength(i.node))],this),f=u?"{}":"()";return p.map(t=>{const i=s(e,f,t,c||u?"replace-first-index":"insert-at-identifier");return this.collectSubsasgnAssignmentTarget(i,r)||{id:n.id,index:[this.expressionValue(h.Complex.create(t+1),"index")],delimiter:f,field:[],descriptors:[this.createSubscriptDescriptor(f,[this.expressionValue(h.Complex.create(t+1),"index")],e,r)]}})};if(c.AST.isNodeIdentifier(e))return[{id:e.id,field:[]}];if(c.AST.isNodeIndexExpr(e)&&c.AST.isNodeIdentifier(e.expr)){if(!t&&"{}"===e.delim){const t=r.resolveName(e.expr.id);if(t&&d.MultiArray.isInstanceOf(t.node)&&t.node.isCell){const n=this.evaluatedIndexArguments(e.args,r);return d.MultiArray.resolveLinearIndices(t.node,e.expr.id,n).map(t=>({id:e.expr.id,index:[this.expressionValue(h.Complex.create(t+1),"index")],delimiter:e.delim,field:[]}))}}return[{id:e.expr.id,index:e.args,delimiter:e.delim,field:[]}]}if(c.AST.isNodeIndirectRef(e)){const s=e.field.map(e=>"string"==typeof e?e:this.evaluatedDynamicFieldName(e,r,`${n}: dynamic structure field names must be strings.`));if(c.AST.isNodeIdentifier(e.obj)){if(!t){const t=r.resolveName(e.obj.id);if(t&&d.MultiArray.isInstanceOf(t.node)&&(m.Structure.isStructure(t.node)||this.hasClassInstanceElement(t.node)))return d.MultiArray.resolveLinearIndices(t.node,e.obj.id,[d.MultiArray.expandColon(d.MultiArray.linearLength(t.node))],this).map(t=>({id:e.obj.id,index:[this.expressionValue(h.Complex.create(t+1),"index")],delimiter:"()",field:s}))}return[{id:e.obj.id,field:s}]}if(c.AST.isNodeIndexExpr(e.obj)&&c.AST.isNodeIdentifier(e.obj.expr)){if(!t&&"{}"===e.obj.delim){const t=r.resolveName(e.obj.expr.id);if(t&&d.MultiArray.isInstanceOf(t.node)&&t.node.isCell){const n=this.evaluatedIndexArguments(e.obj.args,r);return d.MultiArray.resolveLinearIndices(t.node,e.obj.expr.id,n,this).map(t=>({id:e.obj.expr.id,index:[this.expressionValue(h.Complex.create(t+1),"index")],delimiter:e.obj.delim,field:[],descriptors:[this.createSubscriptDescriptor(e.obj.delim,[this.expressionValue(h.Complex.create(t+1),"index")],e.obj,r),...s.map(t=>this.createDotSubscriptDescriptor(t,e,r))]}))}}if(!t&&"()"===e.obj.delim){const t=r.resolveName(e.obj.expr.id);if(t&&d.MultiArray.isInstanceOf(t.node)&&(m.Structure.isStructure(t.node)||this.hasClassInstanceElement(t.node))){const n=this.evaluatedIndexArguments(e.obj.args,r);return d.MultiArray.resolveLinearIndices(t.node,e.obj.expr.id,n,this).map(t=>({id:e.obj.expr.id,index:[this.expressionValue(h.Complex.create(t+1),"index")],delimiter:e.obj.delim,field:s,descriptors:[this.createSubscriptDescriptor(e.obj.delim,[this.expressionValue(h.Complex.create(t+1),"index")],e.obj,r),...s.map(t=>this.createDotSubscriptDescriptor(t,e,r))]}))}}return[{id:e.obj.expr.id,index:e.obj.args,delimiter:e.obj.delim,field:s,descriptors:[this.createSubscriptDescriptor(e.obj.delim,e.obj.args,e.obj,r),...s.map(t=>this.createDotSubscriptDescriptor(t,e,r))]}]}{const t=this.collectSubsasgnAssignmentTarget(e,r);if(t)return i(t);this.context.throwEvalError(`${n}.`)}}else{if(c.AST.isNodeIgnoredTarget(e))return[{id:"~",field:[]}];if(t&&d.MultiArray.isRowVector(e))return e.array[0].flatMap(e=>this.validateAssignment(e,!1,r));{const t=this.collectSubsasgnAssignmentTarget(e,r);if(t)return i(t);this.context.throwEvalError(`${n}.`)}}}toBoolean(e){if(d.MultiArray.isInstanceOf(e)){if(e.isCell&&this.context.throwEvalError("invalid conversion from cell to logical."),this.hasClassInstanceElement(e)){const t=this.classUnaryOperatorArray(e,"logical",c.AST.nodeIdentifier("logical"));if(t)return this.toBoolean(this.expressionValue(t,"logical conversion"));this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(e)} to logical.`)}return this.complexConditionValue(d.MultiArray.toLogical(e))}if(h.Complex.isInstanceOf(e))return this.complexConditionValue(e);if(u.CharString.isInstanceOf(e))return!!e.str;if(g.ClassInstance.isInstanceOf(e)){const t=this.classUnaryOperatorMethod(e,"logical");if(t)return this.toBoolean(this.expressionValue(this.reducedClassMethodResult(t.receiver,t.method,[],c.AST.nodeIdentifier("logical")),"logical conversion"))}this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(e)} to logical.`)}complexConditionValue(e){return Boolean(h.Complex.realToNumber(e)||h.Complex.imagToNumber(e))}evaluatedCondition(e,t,r){return this.toBoolean(this.evaluatedConditionExpression(e,t,r))}evaluatedConditionExpression(e,t,r){return!c.AST.isNodeBinaryOperation(e)||"&"!==e.type&&"|"!==e.type&&"&&"!==e.type&&"||"!==e.type?this.evaluatedExpressionValue(e,t,r):this.evaluateConditionalLogicalOperation(e,t)}evaluateConditionalLogicalOperation(e,t){const r=this.evaluatedCondition(e.left,t,"left condition operand");return"&"===e.type||"&&"===e.type?r&&this.evaluatedCondition(e.right,t,"right condition operand")?h.Complex.true():h.Complex.false():r||this.evaluatedCondition(e.right,t,"right condition operand")?h.Complex.true():h.Complex.false()}switchComparableValue(e){return d.MultiArray.isInstanceOf(e)&&!e.isCell&&2===e.dimension.length&&1===e.dimension[0]&&1===e.dimension[1]?this.expressionValue(e.array[0][0],"switch value"):e}switchCaseMatches(e,t){const r=d.MultiArray.isInstanceOf(t)&&t.isCell?this.expressionList(d.MultiArray.linearize(t),"switch case"):[t];for(const t of r)if(this.switchCandidateMatches(e,t))return!0;return!1}switchCandidateMatches(e,t){const r=this.switchComparableValue(t),n=this.switchComparableValue(e),s=this.classBinaryOperatorMethod(r,n,"eq");return s?this.toBoolean(this.expressionValue(this.reducedClassMethodResult(s.receiver,s.method,s.args,c.AST.nodeIdentifier("switch")),"switch case")):V.RuntimeEquality.valuesEqual(n,r)}classDefinitionForOperatorValue(e){return g.ClassInstance.isInstanceOf(e)?e.classDefinition:void 0}classNameForOperatorValue(e){return g.ClassInstance.isInstanceOf(e)?e.classDefinition.name:this.getValueClassName(e)}classDeclaresInferior(e,t){if(!e)return!1;const r=this.classDefinitionForOperatorValue(t),n=this.classNameForOperatorValue(t);return e.inferiorClasses.some(e=>e===n||!!r&&(r.name===e||r.isSubclassOfName(e)))}classBinaryOperatorMethod(e,t,r){var n,s;const i=n=>{if(!g.ClassInstance.isInstanceOf(n))return;const s=n.classDefinition.findMethod(r,e=>!e.isStatic);return s?(this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method '${r}' has ${s.access} access for class ${n.classDefinition.name}.`),{receiver:n,method:s,args:this.classMethodArgumentValues([n===e?t:e],"operator")}):void 0},a=this.classDefinitionForOperatorValue(e),o=this.classDefinitionForOperatorValue(t);return this.classDeclaresInferior(o,e)&&!this.classDeclaresInferior(a,t)?null!==(n=i(t))&&void 0!==n?n:i(e):null!==(s=i(e))&&void 0!==s?s:i(t)}hasClassInstanceElement(e){return g.ClassInstance.isInstanceOf(e)||d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearize(e).some(e=>g.ClassInstance.isInstanceOf(e))}classBinaryOperatorArray(e,t,r,n){var s,i;if(!this.hasClassInstanceElement(e)&&!this.hasClassInstanceElement(t))return;const a=d.MultiArray.scalarToMultiArray(e),o=d.MultiArray.scalarToMultiArray(t),l=a.dimension.slice(),c=o.dimension.slice(),u=Math.max(l.length,c.length);for(;l.length<u;)l.push(1);for(;c.length<u;)c.push(1);const h=new Array(u),m=new Array(u),p=new Array(u);for(let e=0;e<u;e++)l[e]===c[e]?(h[e]=l[e],m[e]=p[e]=!1):1===l[e]?(h[e]=c[e],m[e]=!0,p[e]=!1):1===c[e]?(h[e]=l[e],m[e]=!1,p[e]=!0):this.context.throwEvalError(`operator ${r}: nonconformant arguments (op1 is ${l.join("x")}, op2 is ${c.join("x")}).`);const f=null===(s=a.array[0])||void 0===s?void 0:s[0],g=null===(i=o.array[0])||void 0===i?void 0:i[0];if(!this.classBinaryOperatorMethod(f,g,r))return;const y=d.MultiArray.computeStrides(l),x=d.MultiArray.computeStrides(c),C=d.MultiArray.computeStrides(h),E=new d.MultiArray(h),v=h.reduce((e,t)=>e*t,1);for(let e=0;e<v;e++){let t=0,s=0;for(let r=0;r<u;r++){const n=Math.floor(e/C[r])%h[r];t+=(m[r]?0:n)*y[r],s+=(p[r]?0:n)*x[r]}const[i,f]=d.MultiArray.linearIndexToMultiArrayRowColumn(l[0],l[1],t),[g,v]=d.MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],s),[A,S]=d.MultiArray.linearIndexToMultiArrayRowColumn(h[0],h[1],e),_=this.classBinaryOperatorMethod(a.array[i][f],o.array[g][v],r);_||this.context.throwEvalError(`operator ${r} is not defined for class array element.`),E.array[A][S]=this.reducedClassMethodResult(_.receiver,_.method,_.args,n)}return d.MultiArray.setType(E),d.MultiArray.MultiArrayToScalar(E)}evaluateBinaryOperatorWithClassDispatch(e,t,r,n,s){const i=this.classBinaryOperatorArray(e,t,r,s);if(i)return i;const a=this.classBinaryOperatorMethod(e,t,r);return a?this.context.callClassInstanceMethod(a.receiver,a.method,a.args,s):b.MathOperation[n](e,t)}classVariadicOperatorMethod(e,t){for(let r=0;r<e.length;r++){const n=e[r];if(!g.ClassInstance.isInstanceOf(n))continue;const s=n.classDefinition.findMethod(t,e=>!e.isStatic);if(s)return this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method '${t}' has ${s.access} access for class ${n.classDefinition.name}.`),{receiver:n,method:s,args:this.classMethodArgumentValues(e.filter((e,t)=>t!==r),"operator")}}}evaluateColonWithClassDispatch(e,t){if(!e.some(e=>this.hasClassInstanceElement(e)))return;const r=this.classVariadicOperatorMethod(e,"colon");if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,r.args,t);this.context.throwEvalError("operator colon is not defined for class operands.")}concatenateOverload(e,t,r){const n=t.map((t,r)=>this.expressionValue(t,`${e} argument ${r+1}`));if(!n.some(e=>this.hasClassInstanceElement(e)))return;const s=this.classVariadicOperatorMethod(n,e);return s?this.reducedClassMethodResult(s.receiver,s.method,s.args,r):void 0}callFunctionalOperatorOverload(e,t,r){var n;const s=e.id,i=b.MathOperation.unaryOperations[s],a=b.MathOperation.binaryOperations[s],o=b.MathOperation.leftAssociativeMultipleOperations[s],l="colon"===s,u="cat"===s,h="horzcat"===s||"vertcat"===s;if(!(i||a||o||l||u||h))return;const d=this.context.evaluateBuiltInArgs(e,t,r).map((e,t)=>this.expressionValue(e,`operator argument ${t+1}`));if(this.context.validateBuiltInInputArity(e,d.length),(!d.some(e=>this.hasClassInstanceElement(e))||u||h)&&this.context.validateBuiltInInputParameters(e,d),l)return 2!==d.length&&3!==d.length&&c.AST.throwInvalidCallError(s,!1,e=>this.context.throwEvalError(e)),null!==(n=this.evaluateColonWithClassDispatch(d,r))&&void 0!==n?n:M.CoreFunctions.colon(...d);if(u){const e=this.concatenateOverload(s,d,r);if(e)return e;const[t,...n]=d;return M.CoreFunctions.cat(t,...n)}if(h){return this.concatenateOverload(s,d,r)||("horzcat"===s?M.CoreFunctions.horzcat:M.CoreFunctions.vertcat)(...d)}if(i){1!==d.length&&c.AST.throwInvalidCallError(s,!1,e=>this.context.throwEvalError(e));const e=d[0],t=this.classUnaryOperatorArray(e,s,r);if(t)return t;const n=this.classUnaryOperatorMethod(e,s);return n?this.context.callClassInstanceMethod(n.receiver,n.method,[],r):i(e)}if(a)return 2!==d.length&&c.AST.throwInvalidCallError(s,!1,e=>this.context.throwEvalError(e)),this.evaluateBinaryOperatorWithClassDispatch(d[0],d[1],s,s,r);if(o){d.length<2&&c.AST.throwInvalidCallError(s,!1,e=>this.context.throwEvalError(e));let e=this.evaluateBinaryOperatorWithClassDispatch(d[0],d[1],s,s,r);for(let t=2;t<d.length;t++)e=this.evaluateBinaryOperatorWithClassDispatch(e,d[t],s,s,r);return e}}requireBinaryOperation(e){if(c.AST.isNodeBinaryOperation(e))return e;this.context.throwEvalError(`invalid binary operation AST node '${e.type}'.`)}requirePrefixOperation(e){if(c.AST.isNodePrefixOperation(e))return e;this.context.throwEvalError(`invalid prefix operation AST node '${e.type}'.`)}requirePostfixOperation(e){if(c.AST.isNodePostfixOperation(e))return e;this.context.throwEvalError(`invalid postfix operation AST node '${e.type}'.`)}evaluateBinaryOperation(e,t){const r=this.evaluatedExpressionValue(e.left,t,"left operand"),n=this.evaluatedExpressionValue(e.right,t,"right operand"),s=W.binaryOperatorMethodTable[e.type];return s?this.evaluateBinaryOperatorWithClassDispatch(r,n,s,s,e):this.opTable[e.type](r,n)}evaluateShortCircuitOperation(e,t){const r=this.evaluatedExpressionValue(e.left,t,"left operand"),n=this.toBoolean(r);return"&&"===e.type?n&&this.toBoolean(this.evaluatedExpressionValue(e.right,t,"right operand"))?h.Complex.true():h.Complex.false():n||this.toBoolean(this.evaluatedExpressionValue(e.right,t,"right operand"))?h.Complex.true():h.Complex.false()}classUnaryOperatorMethod(e,t){if(!g.ClassInstance.isInstanceOf(e))return;const r=e.classDefinition.findMethod(t,e=>!e.isStatic);return r?(this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method '${t}' has ${r.access} access for class ${e.classDefinition.name}.`),{receiver:e,method:r}):void 0}classUnaryOperatorArray(e,t,r){var n;if(!d.MultiArray.isInstanceOf(e)||!this.hasClassInstanceElement(e))return;const s=null===(n=e.array[0])||void 0===n?void 0:n[0];if(!this.classUnaryOperatorMethod(s,t))return;const i=new d.MultiArray(e.dimension);for(let n=0;n<d.MultiArray.linearLength(e);n++){const[s,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n),o=this.classUnaryOperatorMethod(e.array[s][a],t);o||this.context.throwEvalError(`operator ${t} is not defined for class array element.`),i.array[s][a]=this.reducedClassMethodResult(o.receiver,o.method,[],r)}return d.MultiArray.setType(i),d.MultiArray.MultiArrayToScalar(i)}evaluateUnaryOperation(e,t){const r=c.AST.isNodePrefixOperation(e)?e.right:e.left,n=this.evaluatedExpressionValue(r,t,"unary operand"),s=W.unaryOperatorMethodTable[e.type];if(s){const t=this.classUnaryOperatorArray(n,s,e);if(t)return t;const r=this.classUnaryOperatorMethod(n,s);if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,[],e)}return this.opTable[e.type](n)}resolveClassInstanceField(e,t,r){try{g.ClassInstance.throwIfDeleted(e)}catch(e){this.context.throwEvalError(e.message)}if(e.classDefinition.isSubclassOfName("event.EventData")){if("Source"===t)return e.eventDataSource||this.context.throwEvalError("event data Source is not assigned until notify dispatch."),e.eventDataSource;if("EventName"===t)return e.eventDataEventName||this.context.throwEvalError("event data EventName is not assigned until notify dispatch."),u.CharString.create(e.eventDataEventName)}if(!this.context.canAccessClassMember(e.classDefinition,"private")){const n=this.callClassDotSubsref(e,t,r,this.context.currentScope);if(void 0!==n)return n}const n=e.classDefinition.findProperty(t);if(null==n?void 0:n.getMethodName){this.assertCanReadClassProperty(n,t,e.classDefinition.name),n.isGetObservable&&this.dispatchClassPropertyEvent(e,t,"PreGet");const s=e.classDefinition.findMethod(n.getMethodName,e=>!e.isStatic);s||this.context.throwEvalError(`GetMethod '${n.getMethodName}' for property '${t}' in class ${e.classDefinition.name} is not defined.`);const i=this.reducedClassMethodResult(e,s,[],r);return n.isGetObservable&&this.dispatchClassPropertyEvent(e,t,"PostGet"),i}if(null==n?void 0:n.isDependent){this.assertCanReadClassProperty(n,t,e.classDefinition.name),n.isGetObservable&&this.dispatchClassPropertyEvent(e,t,"PreGet");const s=e.classDefinition.findMethod(`get.${t}`,e=>!e.isStatic);s||this.context.throwEvalError(`dependent property '${t}' for class ${e.classDefinition.name} has no get accessor.`);const i=this.reducedClassMethodResult(e,s,[],r);return n.isGetObservable&&this.dispatchClassPropertyEvent(e,t,"PostGet"),i}const s=g.ClassInstance.getProperty(e,t);if(void 0!==s)return n&&(this.assertCanReadClassProperty(n,t,e.classDefinition.name),n.isGetObservable&&(this.dispatchClassPropertyEvent(e,t,"PreGet"),this.dispatchClassPropertyEvent(e,t,"PostGet"))),s;const i=e.classDefinition.findMethod(t,e=>!e.isStatic);if(i)return this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${t}' has ${i.access} access for class ${e.classDefinition.name}.`),y.ClassBoundMethod.bind(e,i);this.context.throwEvalError(`unknown property or method '${t}' for class ${e.classDefinition.name}.`)}assertCanReadClassProperty(e,t,r){this.context.canAccessClassMember(e.classDefinition,e.getAccess)||this.context.throwEvalError(`property '${t}' has ${e.getAccess} get access for class ${r}.`)}assertCanWriteClassProperty(e,t,r){this.context.canAccessClassMember(e.classDefinition,e.setAccess)||this.context.throwEvalError(`property '${t}' has ${e.setAccess} set access for class ${r}.`)}shouldAbortClassPropertySet(e,t,r){return t.isAbortSet&&!t.isDependent&&g.ClassInstance.hasProperty(e,t.name)&&V.RuntimeEquality.valuesEqual(g.ClassInstance.getProperty(e,t.name),r)}assignClassInstanceField(e,t,r,n,s){var i;if(!this.context.canAccessClassMember(e.classDefinition,"private")){const i=this.callClassDotSubsasgn(e,t,r,n,s);if(i)return i}!e.classDefinition.isSubclassOfName("event.EventData")||"Source"!==t&&"EventName"!==t||this.context.throwEvalError(`cannot assign to read-only property '${t}' for class ${e.classDefinition.name}.`);const a=e.classDefinition.findProperty(t);if(a&&this.assertCanWriteClassProperty(a,t,e.classDefinition.name),(null==a?void 0:a.isConstant)&&this.context.throwEvalError(`cannot assign to constant property '${t}' for class ${e.classDefinition.name}.`),a&&this.shouldAbortClassPropertySet(e,a,r))return e;if((null==a?void 0:a.isSetObservable)&&this.dispatchClassPropertyEvent(e,t,"PreSet"),(null==a?void 0:a.setMethodName)||(null==a?void 0:a.isDependent)){this.validateClassPropertyValue(a,r,s);const o=null!==(i=a.setMethodName)&&void 0!==i?i:`set.${t}`,l=e.classDefinition.findMethod(o,e=>!e.isStatic);l||(a.setMethodName&&this.context.throwEvalError(`SetMethod '${a.setMethodName}' for property '${t}' in class ${e.classDefinition.name} is not defined.`),this.context.throwEvalError(`cannot assign to dependent property '${t}' for class ${e.classDefinition.name} without a set accessor.`));const c=this.reducedClassMethodResult(e,l,this.classMethodArgumentValues([r],`set.${t}`),n);return g.ClassInstance.isInstanceOf(c)||this.context.throwEvalError(`set accessor for property '${t}' must return an object of class ${e.classDefinition.name}.`),a.isSetObservable&&this.dispatchClassPropertyEvent(c,t,"PostSet"),c}a&&this.validateClassPropertyValue(a,r,s);try{g.ClassInstance.setProperty(e,t,r)}catch(e){this.context.throwEvalError(e.message)}return(null==a?void 0:a.isSetObservable)&&this.dispatchClassPropertyEvent(e,t,"PostSet"),e}assignNestedClassInstanceField(e,t,r,n,s){if(1===t.length)return this.assignClassInstanceField(e,t[0],r,n,s);const i=t[0],a=t.slice(1);let o,l=this.resolveClassInstanceField(e,i,n);if(d.MultiArray.isEmpty(l)&&(l=new m.Structure({})),m.Structure.isInstanceOf(l)){const e=m.Structure.copy(l);m.Structure.setNewField(e,a,this.runtimeExpressionValue(r,`field ${t.join(".")}`)),o=e}else g.ClassInstance.isInstanceOf(l)?o=this.assignNestedClassInstanceField(l,a,r,n,s):this.context.throwEvalError("value cannot be indexed with .");return this.assignClassInstanceField(e,i,o,n,s)}assignClassArrayField(e,t,r,n,s){const i=d.MultiArray.copy(e),a=this.assignmentValues(r,"assignment"),o=d.MultiArray.linearLength(i);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let e=0;e<o;e++){const[r,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e),l=i.array[r][o];g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),i.array[r][o]=this.assignClassInstanceField(l,t,1===a.length?a[0]:a[e],n,s)}return d.MultiArray.setType(i),i}assignNestedClassArrayField(e,t,r,n,s){if(1===t.length)return this.assignClassArrayField(e,t[0],r,n,s);const i=d.MultiArray.copy(e),a=this.assignmentValues(r,"assignment"),o=d.MultiArray.linearLength(i);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let e=0;e<o;e++){const[r,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e),l=i.array[r][o];g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),i.array[r][o]=this.assignNestedClassInstanceField(l,t,1===a.length?a[0]:a[e],n,s)}return d.MultiArray.setType(i),i}assignClassArrayIndexedField(e,t,r,n,s,i,a){const o=this.evaluatedIndexArguments(r,a),l=d.MultiArray.getElements(t,e,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[s]:this.assignmentValues(s,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let e=0;e<c.length;e++){const t=c[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,s]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],e);m.array[r][s]=this.assignClassInstanceField(t,n,1===u.length?u[0]:u[e],i,a)}return d.MultiArray.setType(m),d.MultiArray.setElements(a,e,[],o,m),this.scopedMultiArrayValue(a,e,"object array assignment result")}assignClassArrayIndexedNestedField(e,t,r,n,s,i,a){if(1===n.length)return this.assignClassArrayIndexedField(e,t,r,n[0],s,i,a);const o=this.evaluatedIndexArguments(r,a),l=d.MultiArray.getElements(t,e,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[s]:this.assignmentValues(s,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let e=0;e<c.length;e++){const t=c[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,s]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],e);m.array[r][s]=this.assignNestedClassInstanceField(t,n,1===u.length?u[0]:u[e],i,a)}return d.MultiArray.setType(m),d.MultiArray.setElements(a,e,[],o,m),this.scopedMultiArrayValue(a,e,"object array assignment result")}assignClassArrayDescriptorField(e,t,r,n,s,i){const a=d.MultiArray.copy(e),o=d.MultiArray.getElements(a,"",[],t),l=this.assignmentValues(o,"selection"),c=1===l.length?[n]:this.assignmentValues(n,"assignment");1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=d.MultiArray.isInstanceOf(o)?o:d.MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new d.MultiArray(u.dimension);for(let e=0;e<l.length;e++){const t=l[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],e);h.array[n][a]=this.assignNestedClassInstanceField(t,r,1===c.length?c[0]:c[e],s,i)}d.MultiArray.setType(h);const m=$.Scope.create();return m.defineName("__object_array_subsasgn__",a),d.MultiArray.setElements(m,"__object_array_subsasgn__",[],t,h,void 0,this),this.scopedMultiArrayValue(m,"__object_array_subsasgn__","object array assignment result")}evaluatedIndexArguments(e,t){return d.MultiArray.indexArguments(e.map((e,r)=>this.convertIndexArgument(this.evaluatedExpressionValue(e,t,`index${r+1}`),e)),"index")}evaluatedDynamicFieldName(e,t,r){const n=this.evaluatedExpressionValue(e,t,"dynamic field name");return u.CharString.isInstanceOf(n)||this.context.throwEvalError(r),n.str}evaluatedCommaSeparatedReceiver(e,t){this.context.pushRequestedOutputCount(1),this.context.pushCommaListExpansion();try{const r=this.Evaluator(e,t);return c.AST.isNodeReturnList(r)&&r.commaSeparated?this.context.expandCommaSeparatedList(r):void 0}finally{this.context.popCommaListExpansion(),this.context.popRequestedOutputCount()}}chainedCommaListResult(e){return 1===e.length?this.returnListValue(e[0],"out1"):this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(e):c.AST.nodeList(this.expressionList(e,"out"))}chainedCommaItemApply(e,t,r){this.context.pushRequestedOutputCount(1);try{const n=this.context.apply(this.expressionValue(e,"indexed expression"),t,r);return this.reducedIndexingResult(n)}finally{this.context.popRequestedOutputCount()}}dottedCommaReceiver(e,t){const r=e=>{try{return this.evaluatedCommaSeparatedReceiver(e,t)}catch(e){return}};let n=e.obj;for(let t=0;t<e.field.length;t++){const s=r(n);if(s)return{values:s,fields:e.field.slice(t)};n=c.AST.nodeIndirectRef(c.AST.isNodeIndirectRef(n)?Object.assign(Object.assign({},n),{field:[...n.field]}):n,e.field[t])}const s=r(n);return s?{values:s,fields:[]}:void 0}resolveDotFieldChain(e,t,r,n){if(g.ClassInstance.isInstanceOf(e))return this.resolveClassFieldChain(e,t,r);if(d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e))return this.resolveClassFieldChain(e,t,r);if(v.ClassEventListener.isInstanceOf(e)){let n=e;for(const e of t)n=v.ClassEventListener.isInstanceOf(n)?this.resolveClassEventListenerField(n,e):g.ClassInstance.isInstanceOf(n)?this.resolveClassInstanceField(n,e,r):m.Structure.getField(n,[e]);return n}if(A.ClassEventData.isInstanceOf(e)||S.ClassPropertyEvent.isInstanceOf(e)){let n=e;for(const e of t)if(A.ClassEventData.isInstanceOf(n)||S.ClassPropertyEvent.isInstanceOf(n))n=this.resolveClassEventDataField(n,e);else if(g.ClassInstance.isInstanceOf(n))n=this.resolveClassInstanceField(n,e,r);else if(_.ClassMetaObject.isInstanceOf(n)){const t=n.getProperty(e);void 0===t&&this.context.throwEvalError(`unknown property '${e}' for ${n.kind}.`),n=t}else n=m.Structure.getField(n,[e]);return n}if(_.ClassMetaObject.isInstanceOf(e)){let r=e;for(const e of t)if(_.ClassMetaObject.isInstanceOf(r)){const t=r.getProperty(e);void 0===t&&this.context.throwEvalError(`unknown property '${e}' for ${r.kind}.`),r=t}else r=m.Structure.getField(r,[e]);return r}if(f.ClassDefinition.isInstanceOf(e))return this.resolveClassDefinitionMemberChain(e,t,n);const s=m.Structure.getFields(e,t);return 1===s.length?s[0]:this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(s):c.AST.nodeList(s)}resolveClassArrayField(e,t,r,n=!0){const s=new d.MultiArray(e.dimension);for(let n=0;n<d.MultiArray.linearLength(e);n++){const[i,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n),o=e.array[i][a];g.ClassInstance.isInstanceOf(o)||this.context.throwEvalError("object array field access requires class instance elements."),s.array[i][a]=this.resolveClassInstanceField(o,t,r)}d.MultiArray.setType(s);const i=d.MultiArray.linearize(s);return n&&(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!i.every(e=>y.ClassBoundMethod.isInstanceOf(e))?this.valueReturnList(i):s}resolveClassFieldChain(e,t,r){let n=e;for(let e=0;e<t.length;e++){const s=t[e],i=e===t.length-1;n=g.ClassInstance.isInstanceOf(n)?this.resolveClassInstanceField(n,s,r):d.MultiArray.isInstanceOf(n)&&this.hasClassInstanceElement(n)?this.resolveClassArrayField(n,s,r,i):this.resolveStructureLikeField(n,s,i)}return n}evaluatedCallArguments(e,t,r){return e.map((e,n)=>this.evaluatedExpressionValue(e,t,`${r}${n+1}`))}isClassInstanceArray(e){return d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearLength(e)>0&&d.MultiArray.linearize(e).every(g.ClassInstance.isInstanceOf)}isClassEventListenerArray(e){return d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearLength(e)>0&&d.MultiArray.linearize(e).every(v.ClassEventListener.isInstanceOf)}inheritedHandleMethodCall(e,t){if("()"!==e.delim||!c.AST.isNodeIndirectRef(e.expr)||this.hasQualifiedNameAccessOperand(e.expr,t))return;const r=e.expr,n=r.field[r.field.length-1];if("string"!=typeof n||!["addlistener","delete","isvalid","notify"].includes(n))return;const s=r.field.slice(0,-1).map(e=>"string"==typeof e?e:this.evaluatedDynamicFieldName(e,t,"Dynamic structure field names must be strings."));let i=this.evaluatedExpressionValue(r.obj,t,`${n} receiver`);if(s.length>0&&(i=this.resolveDotFieldChain(i,s,r,t)),v.ClassEventListener.isInstanceOf(i))switch(n){case"delete":return c.AST.throwInvalidCallError("delete",0!==e.args.length,e=>this.context.throwEvalError(e)),v.ClassEventListener.delete(i),c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==e.args.length,e=>this.context.throwEvalError(e)),M.CoreFunctions.isvalid(i);default:return}if(this.isClassEventListenerArray(i))switch(n){case"delete":c.AST.throwInvalidCallError("delete",0!==e.args.length,e=>this.context.throwEvalError(e));for(const e of d.MultiArray.linearize(i))v.ClassEventListener.isInstanceOf(e)||this.context.throwEvalError("internal error: event listener array contains a non-listener value."),v.ClassEventListener.delete(e);return c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==e.args.length,e=>this.context.throwEvalError(e)),M.CoreFunctions.isvalid(i);default:return}const a=g.ClassInstance.isInstanceOf(i)?i.classDefinition:this.isClassInstanceArray(i)?d.MultiArray.linearize(i).find(g.ClassInstance.isInstanceOf).classDefinition:void 0;if(!(null==a?void 0:a.isHandleClass()))return;if("delete"!==n&&a.findMethod(n,e=>!e.isStatic))return;const o=()=>this.evaluatedCallArguments(e.args,t,`${n} argument `);if(g.ClassInstance.isInstanceOf(i))switch(n){case"addlistener":return this.addClassListener("addlistener",i,...o());case"delete":return c.AST.throwInvalidCallError("delete",0!==e.args.length,e=>this.context.throwEvalError(e)),this.context.deleteClassInstance(i,e);case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==e.args.length,e=>this.context.throwEvalError(e)),M.CoreFunctions.isvalid(i);case"notify":{const e=o();return c.AST.throwInvalidCallError("notify",e.length<1||e.length>2,e=>this.context.throwEvalError(e)),this.notifyClassEvent(i,e[0],e[1])}default:return}if(this.isClassInstanceArray(i))switch(n){case"addlistener":return this.addClassListener("addlistener",i,...o());case"delete":c.AST.throwInvalidCallError("delete",0!==e.args.length,e=>this.context.throwEvalError(e));for(const t of d.MultiArray.linearize(i))g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("internal error: object array contains a non-object value."),this.context.deleteClassInstance(t,e);return c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==e.args.length,e=>this.context.throwEvalError(e)),M.CoreFunctions.isvalid(i);case"notify":{const e=o();return c.AST.throwInvalidCallError("notify",e.length<1||e.length>2,e=>this.context.throwEvalError(e)),this.notifyClassEvent(i,e[0],e[1])}default:return}}resolveNestedClassInstanceIndexedField(e,t,r,n){const s=this.resolveClassFieldChain(e,t,n);return this.nativeSubscriptScalar(s,r)}resolveClassArrayDescriptorIndexedField(e,t,r,n,s,i){const a=d.MultiArray.getElements(e,"",[],t,this),o=d.MultiArray.isInstanceOf(a)?a:d.MultiArray.scalarToMultiArray(this.expressionValue(a,"selection")),l=new d.MultiArray(null!=i?i:o.dimension),c=d.MultiArray.linearize(o);for(let e=0;e<c.length;e++){const t=c[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field access requires class instance elements.");const[i,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],e);l.array[i][a]=this.resolveNestedClassInstanceIndexedField(t,r,n,s)}d.MultiArray.setType(l);const u=d.MultiArray.linearize(l);return 1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(l),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(e=>y.ClassBoundMethod.isInstanceOf(e))?this.valueReturnList(u):l}resolveStructureLikeField(e,t,r){if(d.MultiArray.isInstanceOf(e)&&m.Structure.isStructure(e)){const n=m.Structure.getFields(e,[t]);return r&&n.length>1?c.AST.nodeList(this.expressionList(n,t)):d.MultiArray.MultiArrayToScalar(d.MultiArray.toRowVector(n))}return m.Structure.getField(e,[t])}createSubscriptDescriptor(e,t,r,n){const s=new d.MultiArray([1,t.length]);s.isCell=!0;for(let e=0;e<t.length;e++){const r=t[e];s.array[0][e]=":"===r.type?u.CharString.create(":"):this.evaluatedExpressionValue(r,n,`subscript${e+1}`)}return d.MultiArray.setType(s),new m.Structure({type:u.CharString.create(e),subs:s})}createSubsrefDescriptor(e,t){return this.createSubscriptDescriptor(e.delim,e.args,e,t)}createDotSubscriptDescriptor(e,t,r){return this.expressionValue(u.CharString.create(e),"dot subscript"),new m.Structure({type:u.CharString.create("."),subs:u.CharString.create(e)})}createSubscriptDescriptorArray(e){if(1===e.length)return e[0];const t=new d.MultiArray([1,e.length]);for(let r=0;r<e.length;r++)t.array[0][r]=e[r];return d.MultiArray.setType(t),t}numericScalarToNumber(e,t){const r=d.MultiArray.firstElement(e);return h.Complex.isInstanceOf(r)||this.context.throwEvalError(t),h.Complex.realToNumber(r)}callClassInstanceMethodWithOutputCount(e,t,r,n,s,i){this.context.pushRequestedOutputCount(s),i&&this.context.pushRequestedOutputMask(i);try{return this.context.callClassInstanceMethod(e,t,r,n)}finally{i&&this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}callClassNumArgumentsFromSubscript(e,t,r){const n=e.classDefinition.findMethod("numArgumentsFromSubscript",e=>!e.isStatic);if(!n)return;this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method 'numArgumentsFromSubscript' has ${n.access} access for class ${e.classDefinition.name}.`);const s=this.reducedClassMethodResultWithOutputCount(e,n,this.classMethodArgumentValues([t,u.CharString.create("subsref")],"numArgumentsFromSubscript"),r,1),i=this.numericScalarToNumber(s,`numArgumentsFromSubscript for class ${e.classDefinition.name} must return a numeric scalar.`);return(!Number.isFinite(i)||!Number.isInteger(i)||i<0)&&this.context.throwEvalError(`numArgumentsFromSubscript for class ${e.classDefinition.name} must return a nonnegative integer scalar.`),i}callClassSubsrefMethod(e,t,r,n){var s;const i=this.context.requestedOutputCount;if(i<=1)return this.reducedClassMethodResult(e,t,this.classMethodArgumentValues([r],"subsref"),n);const a=null!==(s=this.callClassNumArgumentsFromSubscript(e,r,n))&&void 0!==s?s:i;c.AST.throwErrorIfGreaterThanReturnList(a,i,e=>this.context.throwEvalError(e));const o=this.context.requestedOutputMask(i),l=e=>{var t;return null===(t=o[e])||void 0===t||t};return c.AST.nodeReturnList((e,t)=>{const r=e[`out${t}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(t,t+1,e=>this.context.throwEvalError(e)),r},s=>{c.AST.throwErrorIfGreaterThanReturnList(a,s,e=>this.context.throwEvalError(e));const i=this.callClassInstanceMethodWithOutputCount(e,t,this.classMethodArgumentValues([r],"subsref"),n,s,o.slice(0,s)),u={length:s};if(c.AST.isNodeReturnList(i)){const e=i.handler(s);for(let t=0;t<s;t++)l(t)&&(u[`out${t}`]=i.selector(e,t));return u}return s>1&&c.AST.throwErrorIfGreaterThanReturnList(1,s,e=>this.context.throwEvalError(e)),u.out0=i,u})}callClassSubsref(e,t,r){const n=e.classDefinition.findMethod("subsref",e=>!e.isStatic);if(!n)return;this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method 'subsref' has ${n.access} access for class ${e.classDefinition.name}.`);const s=this.createSubsrefDescriptor(t,r);return this.callClassSubsrefMethod(e,n,s,t)}callClassSubsrefDescriptors(e,t,r){const n=e.classDefinition.findMethod("subsref",e=>!e.isStatic);if(!n)return;this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method 'subsref' has ${n.access} access for class ${e.classDefinition.name}.`);const s=this.createSubscriptDescriptorArray(t);return this.callClassSubsrefMethod(e,n,s,r)}callClassDotSubsref(e,t,r,n){const s=e.classDefinition.findMethod("subsref",e=>!e.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsref' has ${s.access} access for class ${e.classDefinition.name}.`);const i=this.createDotSubscriptDescriptor(t,r,n);return this.callClassSubsrefMethod(e,s,i,r)}collectClassSubsrefChain(e,t){if("IDX"===e.type){const r=this.collectClassSubsrefChain(e.expr,t);if(!r){const r=this.evaluatedExpressionValue(e.expr,t,"subsref chain receiver");if(d.MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const n=this.reducedIndexingResult(this.context.apply(r,e.args,e));if(g.ClassInstance.isInstanceOf(n))return{instance:n,descriptors:[this.createSubsrefDescriptor(e,t)]}}return}return r.descriptors.push(this.createSubsrefDescriptor(e,t)),r}if("."===e.type){const r=this.collectClassSubsrefChain(e.obj,t);if(!r)return;for(const n of e.field){const s="string"==typeof n?n:this.evaluatedDynamicFieldName(n,t,"Dynamic structure field names must be strings.");r.descriptors.push(this.createDotSubscriptDescriptor(s,e,t))}return r}const r=this.evaluatedExpressionValue(e,t,"subsref chain receiver");return g.ClassInstance.isInstanceOf(r)?{instance:r,descriptors:[]}:void 0}collectSubsasgnAssignmentTarget(e,t){const r=e=>{if(c.AST.isNodeIdentifier(e))return{id:e.id,descriptors:[]};if(c.AST.isNodeIndexExpr(e)){const n=r(e.expr);if(!n)return;return n.descriptors.push(this.createSubscriptDescriptor(e.delim,e.args,e,t)),n}if(c.AST.isNodeIndirectRef(e)){const n=r(e.obj);if(!n)return;for(const r of e.field){const s="string"==typeof r?r:this.evaluatedDynamicFieldName(r,t,"invalid left hand side of assignment: dynamic structure field names must be strings.");n.descriptors.push(this.createDotSubscriptDescriptor(s,e,t))}return n}},n=r(e);return n&&n.descriptors.length>0?{id:n.id,field:[],descriptors:n.descriptors}:void 0}indexedAssignmentRhs(e,t,r,n=!1){return"{}"===e?(void 0!==r&&d.MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("matrix cannot be indexed with {"),d.MultiArray.firstRow([this.runtimeExpressionValue(t,"cell assignment value")],!0)):n?new d.MultiArray([1,1],[[this.runtimeExpressionValue(t,"cell assignment value")]]):!n&&"()"===e&&d.MultiArray.isInstanceOf(t)&&t.isCell?(void 0!==r&&d.MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("cell array assignment requires a cell array target."),t):"()"===e&&d.MultiArray.isInstanceOf(r)&&r.isCell?(d.MultiArray.isInstanceOf(t)&&!t.isCell&&d.MultiArray.isEmpty(t)||d.MultiArray.isInstanceOf(t)&&t.isCell||this.context.throwEvalError("cell array assignment requires a cell array value."),t):d.MultiArray.scalarToMultiArray(this.runtimeExpressionValue(t,"indexed assignment value"))}readNativeSubscriptDescriptor(e,t="subsasgn"){const r=e.field.type,n=e.field.subs;if((!u.CharString.isInstanceOf(r)||"()"!==r.str&&"{}"!==r.str&&"."!==r.str)&&this.context.throwEvalError(`invalid ${t} descriptor.`),"."===r.str){if(u.CharString.isInstanceOf(n))return{type:".",subs:[n]};if(d.MultiArray.isInstanceOf(n)&&n.isCell){const e=this.descriptorSubscripts(n);if(1===e.length&&u.CharString.isInstanceOf(e[0]))return{type:".",subs:e}}this.context.throwEvalError(`invalid ${t} descriptor.`)}return d.MultiArray.isInstanceOf(n)&&n.isCell||this.context.throwEvalError(`invalid ${t} descriptor.`),{type:r.str,subs:this.descriptorSubscripts(n)}}descriptorSubscripts(e){return d.MultiArray.linearize(e).map((e,t)=>this.expressionValue(e,`subscript${t+1}`))}subscriptDescriptorStructures(e,t){const r=m.Structure.structureElements(e);return 0===r.length&&this.context.throwEvalError(`${t}: subscript argument must be a structure array.`),r.forEach(e=>this.readNativeSubscriptDescriptor(e,t)),r}nativeSubsrefNativeDescriptors(e,t){let r=e;for(let e=0;e<t.length;e++){const n=t[e],s=e===t.length-1,i=e=>{if("()"===n.type&&(y.ClassBoundMethod.isInstanceOf(e)||d.MultiArray.isInstanceOf(e)&&d.MultiArray.linearLength(e)>0&&d.MultiArray.linearize(e).every(y.ClassBoundMethod.isInstanceOf))){const t=n.subs.map((e,t)=>this.expressionValue(e,`subsref method argument ${t+1}`));return this.context.callClassBoundMethodValue(e,t,c.AST.nodeIdentifier("subsref"))}return"."===n.type?this.nativeDotSubsrefResult(e,n):"{}"===n.type?this.nativeBraceSubsrefResult(e,n):s&&"()"===n.type?this.nativeParenSubsrefResult(e,n):this.nativeSubscriptScalar(e,n)};r=c.AST.isNodeReturnList(r)&&r.commaSeparated?this.chainedCommaListResult(this.context.expandCommaSeparatedList(r).map(e=>i(e))):i(r)}return r}nativeSubsrefDescriptors(e,t){return this.nativeSubsrefNativeDescriptors(e,t.map(e=>this.readNativeSubscriptDescriptor(e,"subsref")))}nativeDotSubsrefResult(e,t){const r=t.subs[0];u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsref descriptor.");const n=m.Structure.getFields(e,[r.str]);return n.length>1?this.valueReturnList(n):this.expressionValue(n[0],`field ${r.str}`)}nativeBraceSubsrefResult(e,t){d.MultiArray.isInstanceOf(e)&&e.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=d.MultiArray.getElements(e,"",[],this.nativeDescriptorIndexList(t,e),this),n=d.MultiArray.linearize(r);return n.length>1?this.valueReturnList(n):this.expressionValue(d.MultiArray.MultiArrayToScalar(r),"indexed value")}nativeParenSubsrefResult(e,t){if(u.CharString.isInstanceOf(e)){const r=d.MultiArray.characterVectorFromCharString(e),n=d.MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(t,r),this);return d.MultiArray.charStringFromCharacterVectorResult(n,e.quote)}d.MultiArray.isInstanceOf(e)||this.context.throwEvalError("matrix cannot be indexed with (");const r=d.MultiArray.getElements(e,"",[],this.nativeDescriptorIndexList(t,e),this);return e.isCell?(d.MultiArray.isInstanceOf(r)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),r.isCell=!0,r):this.expressionValue(d.MultiArray.MultiArrayToScalar(r),"indexed value")}numericCodeToCharString(e,t='"'){return 0!==h.Complex.imagToNumber(e)&&this.context.throwEvalError("character string assignment requires real character codes."),u.CharString.fromNumericCode(h.Complex.realToNumber(e),t)}charStringAssignmentElement(e,t='"'){return u.CharString.isInstanceOf(e)?e:h.Complex.isInstanceOf(e)?this.numericCodeToCharString(e,t):void this.context.throwEvalError("character string assignment requires character or numeric values.")}charStringAssignmentRhs(e,t='"'){if(u.CharString.isInstanceOf(e))return d.MultiArray.characterVectorFromCharString(e);if(d.MultiArray.isInstanceOf(e)&&!e.isCell){const r=new d.MultiArray(e.dimension);for(let n=0;n<d.MultiArray.linearLength(e);n++){const[s,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n);r.array[s][i]=this.charStringAssignmentElement(e.array[s][i],t)}return d.MultiArray.setType(r),r}return d.MultiArray.scalarToMultiArray(this.charStringAssignmentElement(e,t))}publicObjectArraySubscriptTarget(e,t){if(!d.MultiArray.isInstanceOf(e)||!this.hasClassInstanceElement(e)||0===t.length)return;const r=this.readNativeSubscriptDescriptor(t[0]);if("."===r.type)return;const n=this.singleOutputNativeSubscriptScalar(e,r);return g.ClassInstance.isInstanceOf(n)?n:void 0}singleOutputNativeSubscriptScalar(e,t){this.context.pushRequestedOutputCount(1);try{return this.reducedIndexingResult(this.nativeSubscriptScalar(e,t))}finally{this.context.popRequestedOutputCount()}}publicCellContentSubscriptSelection(e,t){if(!d.MultiArray.isInstanceOf(e)||!e.isCell||0===t.length)return;const r=this.readNativeSubscriptDescriptor(t[0]);if("{}"===r.type){const n=this.singleOutputNativeSubscriptScalar(e,r);return g.ClassInstance.isInstanceOf(n)?{instance:n,objectDescriptors:t.slice(1),contentDescriptor:r}:void 0}if("()"!==r.type||t.length<2)return;const n=this.readNativeSubscriptDescriptor(t[1]);if("{}"!==n.type)return;const s=this.nativeParenSubsrefResult(e,r);if(!d.MultiArray.isInstanceOf(s)||!s.isCell)return;const i=this.singleOutputNativeSubscriptScalar(s,n);return g.ClassInstance.isInstanceOf(i)?{instance:i,objectDescriptors:t.slice(2),contentDescriptor:n,outerDescriptor:r,selectedCell:s}:void 0}dotDescriptorFieldChain(e,t="subsasgn"){const r=[];for(const n of e){if("."!==n.type)return;const e=n.subs[0];u.CharString.isInstanceOf(e)||this.context.throwEvalError(`invalid ${t} descriptor.`),r.push(e.str)}return r}classPropertyDescriptorChain(e,t){var r,n;const s={fields:[]};let i=0;if("()"===(null===(r=e[0])||void 0===r?void 0:r.type))s.leadingIndex=e[0],i=1;else if("{}"===(null===(n=e[0])||void 0===n?void 0:n.type))return;for(;i<e.length;i++){const r=e[i];if("."!==r.type)break;const n=r.subs[0];u.CharString.isInstanceOf(n)||this.context.throwEvalError(`invalid ${t} descriptor.`),s.fields.push(n.str)}if(0!==s.fields.length){if(i<e.length){if(i!==e.length-1||"."===e[i].type)return;s.finalIndex=e[i]}return s}}classPropertyDescriptorPath(e,t){var r,n;const s={fields:[]};let i=0;if("()"===(null===(r=e[0])||void 0===r?void 0:r.type))s.leadingIndex=e[0],i=1;else if("{}"===(null===(n=e[0])||void 0===n?void 0:n.type))return;for(;i<e.length&&"."===e[i].type;i++){const r=e[i].subs[0];u.CharString.isInstanceOf(r)||this.context.throwEvalError(`invalid ${t} descriptor.`),s.fields.push(r.str)}if(0!==s.fields.length)return s.tailDescriptors=e.slice(i),1===s.tailDescriptors.length&&(s.finalIndex=s.tailDescriptors[0]),s}indexedClassPropertyValue(e,t,r){return d.MultiArray.isInstanceOf(e)||this.context.throwEvalError(`matrix cannot be indexed with ${t.type[0]}`),this.setNativeIndexedValue(e,t,r)}assignNestedClassInstanceIndexedField(e,t,r,n,s,i){const a=this.resolveClassFieldChain(e,t,s),o=this.indexedClassPropertyValue(a,r,n);return this.assignNestedClassInstanceField(e,t,o,s,i)}resolveClassSubsrefDescriptors(e,t,r){const n=this.classPropertyDescriptorPath(t,"subsref");if(g.ClassInstance.isInstanceOf(e)){if(!n||n.leadingIndex)return;const t=this.resolveClassFieldChain(e,n.fields,r);return n.tailDescriptors&&n.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(t,n.tailDescriptors):t}if(n&&d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)&&0!==t.length){if(n.leadingIndex){const t=this.nativeDescriptorIndexList(n.leadingIndex,e);return this.resolveClassArrayPropertyPath(e,t,n,r)}return this.resolveClassArrayPropertyPath(e,[d.MultiArray.expandColon(d.MultiArray.linearLength(e))],n,r,e.dimension)}}assignClassArrayDescriptorIndexedField(e,t,r,n,s,i,a){const o=d.MultiArray.copy(e),l=d.MultiArray.getElements(o,"",[],t),c=this.assignmentValues(l,"selection"),u=1===c.length?[s]:this.assignmentValues(s,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let e=0;e<c.length;e++){const t=c[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[s,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],e);m.array[s][o]=this.assignNestedClassInstanceIndexedField(t,r,n,1===u.length?u[0]:u[e],i,a)}d.MultiArray.setType(m);const p=$.Scope.create();return p.defineName("__object_array_subsasgn__",o),d.MultiArray.setElements(p,"__object_array_subsasgn__",[],t,m,void 0,this),this.scopedMultiArrayValue(p,"__object_array_subsasgn__","object array assignment result")}resolveClassArrayPropertyPath(e,t,r,n,s){const i=d.MultiArray.getElements(e,"",[],t,this),a=d.MultiArray.isInstanceOf(i)?i:d.MultiArray.scalarToMultiArray(this.expressionValue(i,"selection")),o=d.MultiArray.linearize(a),l=(e,t)=>{g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed property access requires class instance elements."),t&&this.context.pushRequestedOutputCount(1);try{const t=this.resolveClassFieldChain(e,r.fields,n);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(t,r.tailDescriptors):t}finally{t&&this.context.popRequestedOutputCount()}};if(1===o.length&&!s)return l(o[0],!1);const c=new d.MultiArray(null!=s?s:a.dimension);for(let e=0;e<o.length;e++){const[t,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(c.dimension[0],c.dimension[1],e);c.array[t][r]=l(o[e],!0)}d.MultiArray.setType(c);const u=d.MultiArray.linearize(c);return 1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(c),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(e=>y.ClassBoundMethod.isInstanceOf(e))?this.valueReturnList(u):c}resolveClassCellContentPropertyPath(e,t,r,n){const s=d.MultiArray.getElements(e,"",[],this.nativeDescriptorIndexList(t,e),this),i=d.MultiArray.isInstanceOf(s)?s:d.MultiArray.scalarToMultiArray(this.expressionValue(s,"selection")),a=d.MultiArray.linearize(i),o=(e,t)=>{g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("cell content property access requires class instance elements."),t&&this.context.pushRequestedOutputCount(1);try{const t=this.resolveClassFieldChain(e,r.fields,n);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(t,r.tailDescriptors):t}finally{t&&this.context.popRequestedOutputCount()}};if(1===a.length)return o(a[0],!1);const l=new d.MultiArray(i.dimension);for(let e=0;e<a.length;e++){const[t,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],e);l.array[t][r]=o(a[e],!0)}d.MultiArray.setType(l);const c=d.MultiArray.linearize(l);return this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(c):l}selectedCellContentsAreClassInstances(e,t){this.context.pushRequestedOutputCount(1);try{const r=d.MultiArray.getElements(e,"",[],this.nativeDescriptorIndexList(t,e),this),n=d.MultiArray.isInstanceOf(r)?r:d.MultiArray.scalarToMultiArray(this.expressionValue(r,"selection"));return d.MultiArray.linearize(n).every(e=>g.ClassInstance.isInstanceOf(e))}finally{this.context.popRequestedOutputCount()}}assignClassInstancePropertyPath(e,t,r,n,s){if(!t.tailDescriptors||0===t.tailDescriptors.length)return this.assignNestedClassInstanceField(e,t.fields,r,n,s);const i=this.resolveClassFieldChain(e,t.fields,n),a=this.assignNativeSubsasgnNativeDescriptors(i,t.tailDescriptors,r);return this.assignNestedClassInstanceField(e,t.fields,a,n,s)}assignClassArrayPropertyPath(e,t,r,n,s,i){const a=d.MultiArray.copy(e),o=d.MultiArray.getElements(a,"",[],t),l=this.assignmentValues(o,"selection"),c=this.classPropertyPathAssignmentValues(n,l.length,r);1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=d.MultiArray.isInstanceOf(o)?o:d.MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new d.MultiArray(u.dimension);for(let e=0;e<l.length;e++){const t=l[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],e);h.array[n][a]=this.assignClassInstancePropertyPath(t,r,1===c.length?c[0]:c[e],s,i)}d.MultiArray.setType(h);const m=$.Scope.create();return m.defineName("__object_array_subsasgn__",a),d.MultiArray.setElements(m,"__object_array_subsasgn__",[],t,h,void 0,this),this.scopedMultiArrayValue(m,"__object_array_subsasgn__","object array assignment result")}assignClassCellContentPropertyPath(e,t,r,n,s,i){const a=d.MultiArray.copy(e),o=this.nativeDescriptorIndexList(t,a),l=d.MultiArray.getElements(a,"",[],o),c=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),u=d.MultiArray.linearize(c).map((e,t)=>this.expressionValue(e,`selection${t+1}`)),h=this.classPropertyPathAssignmentValues(n,u.length,r);1!==h.length&&h.length!==u.length&&this.context.throwEvalError(`assignment value count ${h.length} does not match selected object count ${u.length}.`);const m=new d.MultiArray(c.dimension);for(let e=0;e<u.length;e++){const t=u[e];g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("cell content property assignment requires class instance elements.");const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],e);m.array[n][a]=this.assignClassInstancePropertyPath(t,r,1===h.length?h[0]:h[e],s,i)}d.MultiArray.setType(m);const p=1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(m),"cell object assignment value"):m,f=this.setNativeIndexedValue(a,t,p);return d.MultiArray.isInstanceOf(f)||this.context.throwEvalError("internal error: cell object assignment result is not an array."),f}assignClassSubsasgnDescriptors(e,t,r,n){var s,i,a;const o=this.context.currentScope;if(d.MultiArray.isInstanceOf(e)&&e.isCell&&"{}"===(null===(s=t[0])||void 0===s?void 0:s.type)){const s=this.classPropertyDescriptorPath(t.slice(1),"subsasgn");if(s&&!s.leadingIndex&&this.selectedCellContentsAreClassInstances(e,t[0]))return this.assignClassCellContentPropertyPath(e,t[0],s,r,n,o)}if(d.MultiArray.isInstanceOf(e)&&e.isCell&&"()"===(null===(i=t[0])||void 0===i?void 0:i.type)&&"{}"===(null===(a=t[1])||void 0===a?void 0:a.type)){const s=this.nativeParenSubsrefResult(e,t[0]);if(d.MultiArray.isInstanceOf(s)&&s.isCell){const i=this.classPropertyDescriptorPath(t.slice(2),"subsasgn");if(i&&!i.leadingIndex&&this.selectedCellContentsAreClassInstances(s,t[1])){const a=this.assignClassCellContentPropertyPath(s,t[1],i,r,n,o);return this.setNativeIndexedValue(e,t[0],a)}}}const l=this.classPropertyDescriptorPath(t,"subsasgn");if(g.ClassInstance.isInstanceOf(e)){if(!l||l.leadingIndex)return;return this.assignClassInstancePropertyPath(g.ClassInstance.copy(e),l,r,n,o)}if(l&&d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)){if(l.leadingIndex){const t=this.nativeDescriptorIndexList(l.leadingIndex,e);return this.assignClassArrayPropertyPath(e,t,l,r,n,o)}return this.assignClassArrayPropertyPath(e,[d.MultiArray.expandColon(d.MultiArray.linearLength(e))],l,r,n,o)}}resolveClassCellSubsrefDescriptors(e,t,r){var n,s,i;if(!d.MultiArray.isInstanceOf(e)||!e.isCell||"{}"!==(null===(n=t[0])||void 0===n?void 0:n.type)){if(d.MultiArray.isInstanceOf(e)&&e.isCell&&"()"===(null===(s=t[0])||void 0===s?void 0:s.type)&&"{}"===(null===(i=t[1])||void 0===i?void 0:i.type)){const n=this.nativeParenSubsrefResult(e,t[0]);if(d.MultiArray.isInstanceOf(n)&&n.isCell){const e=this.classPropertyDescriptorPath(t.slice(2),"subsref");if(e&&!e.leadingIndex&&this.selectedCellContentsAreClassInstances(n,t[1]))return this.resolveClassCellContentPropertyPath(n,t[1],e,r)}}return}const a=this.classPropertyDescriptorPath(t.slice(1),"subsref");if(a&&!a.leadingIndex&&this.selectedCellContentsAreClassInstances(e,t[0]))return this.resolveClassCellContentPropertyPath(e,t[0],a,r)}subsrefResult(e,t){const r=this.subscriptDescriptorStructures(t,"subsref"),n=r.map(e=>this.readNativeSubscriptDescriptor(e,"subsref"));if(g.ClassInstance.isInstanceOf(e)){const t=this.callClassSubsrefDescriptors(e,r,c.AST.nodeIdentifier("subsref"));if(void 0!==t)return t;const s=this.resolveClassSubsrefDescriptors(e,n,c.AST.nodeIdentifier("subsref"));if(void 0!==s)return s}const s=this.publicObjectArraySubscriptTarget(e,r);if(s){const e=this.callClassSubsrefDescriptors(s,r,c.AST.nodeIdentifier("subsref"));if(void 0!==e)return e}const i=this.publicCellContentSubscriptSelection(e,r);if(i&&i.objectDescriptors.length>0){const e=this.callClassSubsrefDescriptors(i.instance,i.objectDescriptors,c.AST.nodeIdentifier("subsref"));if(void 0!==e)return e}const a=this.resolveClassSubsrefDescriptors(e,n,c.AST.nodeIdentifier("subsref"));if(void 0!==a)return a;const o=this.resolveClassCellSubsrefDescriptors(e,n,c.AST.nodeIdentifier("subsref"));return void 0!==o?o:this.nativeSubsrefDescriptors(e,r)}subsasgnResult(e,t,r){const n=this.subscriptDescriptorStructures(t,"subsasgn"),s=n.map(e=>this.readNativeSubscriptDescriptor(e,"subsasgn"));if(g.ClassInstance.isInstanceOf(e)){const t=this.callClassSubsasgnDescriptors(e,n,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==t)return t;const i=this.assignClassSubsasgnDescriptors(e,s,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==i)return i}const i=this.publicObjectArraySubscriptTarget(e,n);if(i){const t=this.callClassSubsasgnDescriptors(i,n,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==t)return d.MultiArray.isInstanceOf(e)||this.context.throwEvalError("internal error: object-array subsasgn target is not an array."),this.setNativeIndexedValue(e,this.readNativeSubscriptDescriptor(n[0]),t)}const a=this.publicCellContentSubscriptSelection(e,n);if(a&&a.objectDescriptors.length>0){const t=this.callClassSubsasgnDescriptors(a.instance,a.objectDescriptors,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==t){if(d.MultiArray.isInstanceOf(e)||this.context.throwEvalError("internal error: cell-object subsasgn target is not an array."),a.outerDescriptor&&a.selectedCell){const r=this.setNativeIndexedValue(a.selectedCell,a.contentDescriptor,t);return d.MultiArray.isInstanceOf(r)&&r.isCell||this.context.throwEvalError("internal error: selected cell-object subsasgn result is not a cell array."),this.setNativeIndexedValue(e,a.outerDescriptor,r)}return this.setNativeIndexedValue(e,a.contentDescriptor,t)}}const o=this.assignClassSubsasgnDescriptors(e,s,r,c.AST.nodeIdentifier("subsasgn"));return void 0!==o?o:this.assignNativeSubsasgnDescriptors(e,n,r)}nativeDescriptorIndexList(e,t){return e.subs.map((r,n)=>{if(u.CharString.isInstanceOf(r)&&":"===r.str)return 1===e.subs.length?d.MultiArray.expandColon(d.MultiArray.linearLength(t)):d.MultiArray.expandColon(d.MultiArray.getDimension(t,n));const s=this.convertIndexArgument(r,c.AST.nodeIdentifier("subsindex"));return d.MultiArray.isIndexArgument(s)||this.context.throwEvalError(`subscript${n+1}: invalid subscript type.`),s})}nativeSubscriptScalar(e,t){if("."===t.type){const r=t.subs[0];return u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),this.expressionValue(m.Structure.getField(e,[r.str]),`field ${r.str}`)}if(u.CharString.isInstanceOf(e)){"{}"===t.type&&this.context.throwEvalError("matrix cannot be indexed with {");const r=d.MultiArray.characterVectorFromCharString(e),n=d.MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(t,r),this);return d.MultiArray.charStringFromCharacterVectorResult(n,e.quote)}d.MultiArray.isInstanceOf(e)||this.context.throwEvalError(`matrix cannot be indexed with ${t.type[0]}`),"{}"!==t.type||e.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=this.nativeDescriptorIndexList(t,e),n=d.MultiArray.getElements(e,"",[],r,this);return"()"===t.type&&e.isCell?(d.MultiArray.isInstanceOf(n)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),n.isCell=!0,n):this.expressionValue(d.MultiArray.MultiArrayToScalar(n),"indexed value")}setNativeIndexedValue(e,t,r){if(u.CharString.isInstanceOf(e)){"{}"===t.type&&this.context.throwEvalError("matrix cannot be indexed with {");const n=d.MultiArray.characterVectorFromCharString(e),s=$.Scope.create();return s.defineName("__subsasgn__",n),d.MultiArray.setElements(s,"__subsasgn__",[],this.nativeDescriptorIndexList(t,n),this.charStringAssignmentRhs(r,e.quote),void 0,this),d.MultiArray.charStringFromCharacterVectorResult(this.scopedExpressionValue(s,"__subsasgn__","character assignment result"),e.quote)}"{}"!==t.type||e.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const n=d.MultiArray.copy(e);let s=this.indexedAssignmentRhs(t.type,r,n);if("{}"===t.type&&d.MultiArray.isInstanceOf(r)&&!r.isCell)try{const e=d.MultiArray.linearize(d.MultiArray.getElements(n,"",[],this.nativeDescriptorIndexList(t,n),this)).length;e>1&&e===d.MultiArray.linearLength(r)&&(s=d.MultiArray.firstRow(d.MultiArray.linearize(r),!0))}catch(e){s=this.indexedAssignmentRhs(t.type,r,n)}const i=$.Scope.create();return i.defineName("__subsasgn__",n),d.MultiArray.setElements(i,"__subsasgn__",[],this.nativeDescriptorIndexList(t,n),s,void 0,this),this.scopedMultiArrayValue(i,"__subsasgn__","indexed assignment result")}blankNativeSubsasgnValue(e){return e&&"."!==e.type?"()"===e.type&&1===e.subs.length?new d.MultiArray([1,0],void 0,!1):"{}"===e.type&&1===e.subs.length?new d.MultiArray([1,0],void 0,!0):d.MultiArray.emptyArray("{}"===e.type):new m.Structure({})}nativeSubscriptScalarForAssignment(e,t,r){try{return this.nativeSubscriptScalar(e,t)}catch(t){if(d.MultiArray.isInstanceOf(e))return this.blankNativeSubsasgnValue(r);throw t}}assignNativeSubsasgnNativeDescriptors(e,t,r){if(0===t.length)return r;const n=(e,t,r)=>1===t||r&&d.MultiArray.isInstanceOf(e)&&d.MultiArray.isEmpty(e)?[this.expressionValue(e,"assignment")]:this.assignmentValues(e,"assignment"),s=(e,i,a=r)=>{const o=t[i];if(!o)return a;if("."===o.type){const r=o.subs[0];u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),d.MultiArray.isEmpty(e)&&(e=new m.Structure({})),m.Structure.isInstanceOf(e)||m.Structure.isStructure(e)||this.context.throwEvalError("value cannot be indexed with .");const l=m.Structure.isInstanceOf(e)?m.Structure.copy(e):d.MultiArray.isInstanceOf(e)?d.MultiArray.copy(e):void 0;l||this.context.throwEvalError("value cannot be indexed with .");const c=m.Structure.structureElements(l);if(c.length>1&&i<t.length-1){const e=n(a,c.length,!0);return 1!==e.length&&e.length!==c.length&&this.context.throwEvalError(`assignment value count ${e.length} does not match selected structure count ${c.length}.`),c.forEach((n,a)=>{let o;try{o=this.expressionValue(m.Structure.getField(n,[r.str]),`field ${r.str}`)}catch(e){o=this.blankNativeSubsasgnValue(t[i+1])}const l=s(o,i+1,1===e.length?e[0]:e[a]);m.Structure.setNewField(n,[r.str],this.runtimeExpressionValue(l,`field ${r.str}`))}),l}let h;try{h=this.expressionValue(m.Structure.getField(l,[r.str]),`field ${r.str}`)}catch(e){h=this.blankNativeSubsasgnValue(t[i+1])}const p=i===t.length-1?a:s(h,i+1,a);return m.Structure.setNewField(l,[r.str],this.runtimeExpressionValue(p,`field ${r.str}`)),l}d.MultiArray.isInstanceOf(e)||u.CharString.isInstanceOf(e)||this.context.throwEvalError(`matrix cannot be indexed with ${o.type[0]}`);const l=i===t.length-1?a:s(this.nativeSubscriptScalarForAssignment(e,o,t[i+1]),i+1,a);return this.setNativeIndexedValue(e,o,l)};return s(e,0)}assignNativeSubsasgnDescriptors(e,t,r){return this.assignNativeSubsasgnNativeDescriptors(e,t.map(e=>this.readNativeSubscriptDescriptor(e,"subsasgn")),r)}shouldUseNativeChainedSubsasgn(e){if(e.length>2)return!0;if(e.length<2)return!1;const[t,r]=e.map(e=>this.readNativeSubscriptDescriptor(e).type);return!("()"===t&&"."===r)}callClassSubsasgn(e,t,r,n,s,i){const a=e.classDefinition.findMethod("subsasgn",e=>!e.isStatic);if(!a)return;this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method 'subsasgn' has ${a.access} access for class ${e.classDefinition.name}.`);const o=this.createSubsasgnDescriptor(t,r,s,i);return this.classSubsasgnResult(e,a,this.classMethodArgumentValues([o,n],"subsasgn"),s)}callClassSubsasgnDescriptors(e,t,r,n){const s=e.classDefinition.findMethod("subsasgn",e=>!e.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsasgn' has ${s.access} access for class ${e.classDefinition.name}.`);const i=this.createSubscriptDescriptorArray(t);return this.classSubsasgnResult(e,s,this.classMethodArgumentValues([i,r],"subsasgn"),n)}createSubsasgnDescriptor(e,t,r,n){return this.createSubscriptDescriptor(t,e,r,n)}callClassDotSubsasgn(e,t,r,n,s){const i=e.classDefinition.findMethod("subsasgn",e=>!e.isStatic);if(!i)return;this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'subsasgn' has ${i.access} access for class ${e.classDefinition.name}.`);const a=this.createDotSubscriptDescriptor(t,n,s);return this.classSubsasgnResult(e,i,this.classMethodArgumentValues([a,r],"subsasgn"),n)}callClassEnd(e,t,r,n){const s=e.classDefinition.findMethod("end",e=>!e.isStatic);if(s)return this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'end' has ${s.access} access for class ${e.classDefinition.name}.`),this.reducedClassMethodResult(e,s,this.classMethodArgumentValues([h.Complex.create(t),h.Complex.create(r)],"end"),n)}callClassSubsindex(e,t){const r=e.classDefinition.findMethod("subsindex",e=>!e.isStatic);return r||this.context.throwEvalError(`object of class ${e.classDefinition.name} cannot be used as an index without a subsindex method.`),this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method 'subsindex' has ${r.access} access for class ${e.classDefinition.name}.`),this.reducedClassMethodResultWithOutputCount(e,r,[],t,1)}zeroBasedSubsindexValue(e,t,r){const n=(e,t)=>{const r=this.expressionValue(e,t);h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError("subsindex must return zero-based real integer indices.");const n=h.Complex.realToNumber(r);return(!Number.isInteger(n)||n<0)&&this.context.throwEvalError("subsindex must return zero-based real integer indices."),h.Complex.create(n+1)},s=this.expressionValue(e,r);if(d.MultiArray.isInstanceOf(s)){const e=new d.MultiArray(s.dimension,void 0,!1);for(let t=0;t<d.MultiArray.linearLength(s);t++){const[i,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t);e.array[i][a]=n(this.expressionValue(s.array[i][a],`${r}${t+1}`),`${r}${t+1}`)}return d.MultiArray.setType(e),e.parent=t,e}return n(s,r)}convertIndexArgument(e,t){if(g.ClassInstance.isInstanceOf(e))return this.zeroBasedSubsindexValue(this.callClassSubsindex(e,t),t,"subsindex");if(d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)){const r=new d.MultiArray(e.dimension,void 0,!1);for(let n=0;n<d.MultiArray.linearLength(e);n++){const[s,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],n),a=e.array[s][i];g.ClassInstance.isInstanceOf(a)||this.context.throwEvalError("object index arrays must contain class instance elements.");const o=this.zeroBasedSubsindexValue(this.callClassSubsindex(a,t),t,`subsindex${n+1}`);h.Complex.isInstanceOf(o)||this.context.throwEvalError("subsindex for object index arrays must return scalar indices."),r.array[s][i]=o}return d.MultiArray.setType(r),r.parent=t,r}return e}solveUndefined(e,t=this.context.currentScope,r=[]){if(this.context.allowForwardReference){const n=r.indexOf(e);n>=0&&this.context.throwCircularReferenceError([...r.slice(n),e]);const s=t.undefinedReferenceTable[e];if(void 0!==s){const n=[...s].filter(e=>e),i=new Set,a=[];n.forEach(e=>{if(void 0!==t.nameTable[e])try{t.nameTable[e].node=this.evaluatedExecutionResult(t.nameTable[e].node,t),delete t.nameTable[e].undefinedReference,a.push(e)}catch(r){r instanceof z.UndefinedReferenceError?(i.add(r.identifier),t.nameTable[e].undefinedReference=r.identifier):i.add(e)}}),t.undefinedReferenceTable[e]=i,a.forEach(n=>this.solveUndefined(n,t,[...r,e]))}}}isLocalUndefinedReference(e){var t;if(!(e instanceof z.UndefinedReferenceError))return!1;const r=this.context.callStack.filter(e=>void 0!==e.func),n=r[r.length-1];return(null===(t=e.stackFrames)||void 0===t?void 0:t[0])===n}registerFunctionDefinition(e,t,r){var n,s;this.validateFunctionSignature(e),this.validateDeclarationPlacement(e),r?e.attributes=Object.assign(Object.assign({},null!==(n=e.attributes)&&void 0!==n?n:{}),{nested:!0}):(null===(s=e.attributes)||void 0===s?void 0:s.nested)&&(e.attributes=Object.assign({},e.attributes),delete e.attributes.nested),this.validateFunctionArgumentsBlocks(e),t.defineFunction(e.id,e),e.definingScope=r?t:t.capture(e=>b.MathOperation.copy(e),this.context.allowForwardReference)}isNodeInsideExecutableBlock(e){const t=e.parent,r=null==t?void 0:t.parent;return c.AST.isNodeBase(r)&&("IF"===r.type||"SWITCH"===r.type||"CASE"===r.type||"WHILE"===r.type||"DO_UNTIL"===r.type||"FOR"===r.type||"SPMD"===r.type||"TRY"===r.type||"UNWIND_PROTECT"===r.type)}validateDeclarationPlacement(e){const t=(e,r)=>{if(e)if(c.AST.isNodeList(e))e.list.forEach(e=>t(e,r));else{if(c.AST.isNodeFunctionDefinition(e))return this.isNodeInsideExecutableBlock(e)&&this.context.throwSyntaxError(`function definition '${e.id}' is not allowed inside a control block.`),t(e.arguments,!0),void t(e.statements,!0);if(c.AST.isNodeClassDef(e))return this.isNodeInsideExecutableBlock(e)&&this.context.throwSyntaxError(`class definition '${e.id}' is not allowed inside a control block.`),r&&this.context.throwSyntaxError(`class definition '${e.id}' is not allowed inside a function.`),void e.sections.forEach(e=>t(e,r));switch(c.AST.isNodeImport(e)&&e.imports.length>0&&this.isNodeInsideExecutableBlock(e)&&this.context.throwSyntaxError("import declaration is not allowed inside a control block."),"PERSIST"!==e.type||r||this.context.throwSyntaxError("persistent declaration is only valid inside a function."),e.type){case"IF":e.then.forEach(e=>t(e,r)),t(e.else,r);break;case"SWITCH":e.cases.forEach(e=>t(e,r)),t(e.otherwise,r);break;case"CASE":t(e.then,r);break;case"WHILE":case"DO_UNTIL":case"FOR":case"SPMD":t(e.body,r);break;case"TRY":t(e.body,r),t(e.catchBody,r);break;case"UNWIND_PROTECT":t(e.body,r),t(e.cleanup,r);break;case"CLASS_SECTION":t(e.members,r)}}};t(e,!1)}preregisterScriptLocalFunctions(e,t){var r,n;if(null!==e.parent)return;if("FCNDEF"===(null===(n=null===(r=this.context.currentFrame)||void 0===r?void 0:r.func)||void 0===n?void 0:n.type))return;const s=this.scriptSourceNameStack[this.scriptSourceNameStack.length-1];for(const r of e.list)c.AST.isNodeFunctionDefinition(r)&&t.functionTable[r.id]!==r&&(r.sourceName=s,this.registerFunctionDefinition(r,t,!1))}getArgumentValidationName(e){return R.FunctionArguments.validationName(e,e=>this.context.throwSyntaxError(e))}getNameValueArgumentTarget(e){return R.FunctionArguments.nameValueTarget(e,e=>this.context.throwSyntaxError(e))}getArgumentValidationDisplayName(e){return R.FunctionArguments.validationDisplayName(e,e=>this.context.throwSyntaxError(e))}validateFunctionArgumentsBlocks(e){R.FunctionArguments.validateBlocks(e,e=>this.context.throwSyntaxError(e))}validateFunctionSignatureList(e,t,r,n,s){const i=new Set;e.forEach((a,o)=>{if(t(a)||this.context.throwSyntaxError(`invalid ${n} list in ${s}.`),c.AST.isNodeIgnoredTarget(a))return;let l;c.AST.isNodeDefaultedParameter(a)?("parameter"===n&&"anonymous function"!==s||this.context.throwSyntaxError(`invalid ${n} list in ${s}.`),l=a.left.id):c.AST.isNodeIdentifier(a)?l=a.id:this.context.throwSyntaxError(`invalid ${n} list in ${s}.`),i.has(l)&&this.context.throwSyntaxError(`duplicate ${n} name '${l}' in ${s}.`),i.add(l),l===r&&o!==e.length-1&&this.context.throwSyntaxError(`${r} must be the last ${n} in ${s}.`),"="===a.type&&l===r&&this.context.throwSyntaxError(`${r} default value is not supported in ${s}.`)})}validateFunctionSignature(e){const t=`function ${e.id}`;this.validateFunctionSignatureList(e.parameter.list,c.AST.isNodeFunctionParameter,"varargin","parameter",t),this.validateFunctionSignatureList(e.return.list,c.AST.isNodeFunctionReturn,"varargout","return",t),this.validateFunctionDeclarations(e,t)}validateAnonymousFunctionSignature(e){this.validateFunctionSignatureList(e.parameter,c.AST.isNodeFunctionParameter,"varargin","parameter","anonymous function")}declarationName(e,t){const r=c.AST.getDeclarationNode(e);return c.AST.isNodeIdentifier(r)?r.id:c.AST.isNodeDefaultedParameter(r)?r.left.id:void this.context.throwSyntaxError(`invalid ${t} declaration.`)}signatureNameSet(e){const t=new Set;return e.forEach(e=>{c.AST.isNodeDefaultedParameter(e)?t.add(e.left.id):c.AST.isNodeIdentifier(e)&&t.add(e.id)}),t}collectIdentifierReferences(e,t){e&&"object"==typeof e&&(c.AST.isNodeIdentifier(e)?t.add(e.id):c.AST.isNodeFunctionDefinition(e)||c.AST.isNodeClassDef(e)||e instanceof u.CharString||e instanceof h.Complex||e instanceof p.FunctionHandle||(d.MultiArray.isInstanceOf(e)?d.MultiArray.linearize(e).forEach(e=>this.collectIdentifierReferences(e,t)):m.Structure.isInstanceOf(e)?Object.values(e.field).forEach(e=>this.collectIdentifierReferences(e,t)):Object.entries(e).forEach(([e,r])=>{"parent"!==e&&this.collectIdentifierReferences(r,t)})))}validateFunctionDeclarations(e,t){const r=this.signatureNameSet(e.parameter.list),n=this.signatureNameSet(e.return.list),s=new Set,i=new Set,a=new Set,o=e=>{e.list.forEach(o=>{const l=this.declarationName(o,"PERSIST"===e.type?"persistent":"global"),c="PERSIST"===e.type?"persistent":"global",u="PERSIST"===e.type?i:a;(r.has(l)||n.has(l))&&this.context.throwSyntaxError(`can't make function parameter ${l} ${c}.`),!u.has(l)&&s.has(l)&&this.context.throwSyntaxError(`${c} declaration '${l}' must appear before any use in ${t}.`),u.add(l)})},l=e=>{if(c.AST.isNodeDeclaration(e))return o(e),void this.collectIdentifierReferences(e,s);switch(e.type){case"IF":return e.expression.forEach(e=>this.collectIdentifierReferences(e,s)),e.then.forEach(u),void(e.else&&u(e.else));case"SWITCH":return this.collectIdentifierReferences(e.expression,s),e.cases.forEach(e=>{this.collectIdentifierReferences(e.expression,s),u(e.then)}),void(e.otherwise&&u(e.otherwise));case"WHILE":return this.collectIdentifierReferences(e.expression,s),void u(e.body);case"DO_UNTIL":return u(e.body),void this.collectIdentifierReferences(e.expression,s);case"FOR":return this.collectIdentifierReferences(e.target,s),this.collectIdentifierReferences(e.expression,s),this.collectIdentifierReferences(e.workers,s),void u(e.body);case"SPMD":return this.collectIdentifierReferences(e.workers,s),void u(e.body);case"TRY":return u(e.body),this.collectIdentifierReferences(e.catchIdentifier,s),void(e.catchBody&&u(e.catchBody));case"UNWIND_PROTECT":return u(e.body),void u(e.cleanup);case"FCNDEF":case"CLASSDEF":return;default:this.collectIdentifierReferences(e,s)}},u=e=>{e.list.forEach(e=>{l(e)})};u(e.statements)}getValueClassName(e){if(d.MultiArray.isInstanceOf(e)&&!e.isCell){const t=d.MultiArray.linearize(e);if(t.length>0){const e=this.objectArrayClassName(t);if(e)return e}}return O.FunctionValidation.className(e)}objectArrayClassName(e){const t=e.map(e=>g.ClassInstance.isInstanceOf(e)||E.ClassEnumerationValue.isInstanceOf(e)?e.classDefinition.name:_.ClassMetaObject.isInstanceOf(e)?e.kind:void 0);if(!t.every(e=>void 0!==e))return;const r=t[0];return t.every(e=>e===r)?r:void 0}getArgumentValidationEntry(e,t,r){const n=this.getNameValueArgumentTarget(e);if(!n){const n=this.getArgumentValidationName(e);return r?t.nameTable[n]:t.resolveName(n)}const s=r?t.nameTable[n.parameter]:t.resolveName(n.parameter);if(s&&void 0!==s.node)try{return{node:m.Structure.getField(s.node,[n.field])}}catch(e){return}}validateArgumentValidation(e,t,r,n=!1,s=this.getArgumentValidationDisplayName(e)){R.FunctionArguments.validateArgumentValidation(e,r,Object.assign(Object.assign({resolveEntry:(e,r)=>this.getArgumentValidationEntry(e,t,r),evaluate:e=>this.evaluatedExpressionValue(e,t,"argument validation expression"),matchesClass:(e,r)=>this.valueMatchesValidationClass(e,r,t)},this.pathValidationCallbacks),{throwEvalError:e=>this.context.throwEvalError(e),throwSyntaxError:e=>this.context.throwSyntaxError(e)}),n,s)}classPropertyValidationNode(e){return{type:"ARGVALID",name:e.node.name,size:e.size,class:e.class,functions:e.functions,default:e.defaultValue,omitAnswer:!0,omitOutput:!0}}validateClassPropertyValue(e,t,r,n=!1){const s=this.classPropertyValidationNode(e),i=$.Scope.create(r);i.defineName(e.name,t),R.FunctionArguments.validateArgumentValidation(s,new Map,Object.assign(Object.assign({resolveEntry:()=>({node:t}),evaluate:e=>this.evaluatedExpressionValue(e,i,"property validation expression"),matchesClass:(e,t)=>this.valueMatchesValidationClass(e,t,i,n)},this.pathValidationCallbacks),{throwEvalError:e=>this.context.throwEvalError(e),throwSyntaxError:e=>this.context.throwSyntaxError(e)}),!1,e.name,"property")}validateClassInstancePropertyDefaults(e,t){for(const r of e.classDefinition.allProperties())!r.isDependent&&g.ClassInstance.hasProperty(e,r.name)&&this.validateClassPropertyValue(r,g.ClassInstance.getProperty(e,r.name),t,!0)}validateFunctionArguments(e,t,r,n,s=!1){R.FunctionArguments.validateFunctionArguments(e,r,Object.assign(Object.assign({resolveEntry:(e,r)=>this.getArgumentValidationEntry(e,t,r),evaluate:e=>this.evaluatedExpressionValue(e,t,"argument validation expression"),matchesClass:(e,r)=>this.valueMatchesValidationClass(e,r,t)},this.pathValidationCallbacks),{throwEvalError:e=>this.context.throwEvalError(e),throwSyntaxError:e=>this.context.throwSyntaxError(e)}),n,s)}validateFunctionInputArguments(e,t){this.validateFunctionArguments(e,t,"Input")}validateFunctionRepeatingArguments(e,t,r){R.FunctionArguments.validateRepeatingArguments(e,r,Object.assign(Object.assign({evaluate:e=>this.evaluatedExpressionValue(e,t,"repeating argument validation expression")},this.pathValidationCallbacks),{throwEvalError:e=>this.context.throwEvalError(e),throwSyntaxError:e=>this.context.throwSyntaxError(e),validateRepeatingValue:(e,r,n,s,i)=>{const a=$.Scope.create(t);a.defineName(r,n),this.validateArgumentValidation(e,a,i,!0,s)}}))}getFunctionNameValueParameters(e){return R.FunctionArguments.nameValueParameters(e,e=>this.context.throwSyntaxError(e))}getFunctionNameValueDeclarations(e){return R.FunctionArguments.nameValueDeclarations(e,e=>this.context.throwSyntaxError(e))}splitFunctionCallNameValueArguments(e,t){return R.FunctionArguments.splitCallNameValueArguments(e,t,e=>this.context.throwEvalError(e),e=>this.context.throwSyntaxError(e))}bindFunctionNameValueArguments(e,t,r){const n=this.getFunctionNameValueDeclarations(e);for(const[e,s]of n){const n=new m.Structure({});for(const[r,i]of s)if(i.default){this.context.pushRequestedOutputCount(1);try{m.Structure.setNewField(n,[r],this.runtimeExpressionValue(this.evaluatedExpressionValue(i.default,t,`name-value default ${e}.${r}`),`name-value default ${e}.${r}`))}finally{this.context.popRequestedOutputCount()}}for(const[e,t]of r)s.has(e)&&m.Structure.setNewField(n,[e],this.runtimeExpressionValue(t,`name-value argument ${e}`));t.defineName(e,n)}}registerNestedFunctions(e,t){var r;for(const n of e.statements.list){if(!c.AST.isNodeFunctionDefinition(n))continue;const s=Object.assign(Object.assign({},n),{attributes:Object.assign(Object.assign({},null!==(r=n.attributes)&&void 0!==r?r:{}),{nested:!0})});this.validateFunctionSignature(s),this.validateFunctionArgumentsBlocks(s),s.definingScope=t,s.sourceName=e.sourceName,t.defineFunction(s.id,s)}}configureFunctionWorkspace(e,t){var r;((null===(r=e.attributes)||void 0===r?void 0:r.nested)||this.functionContainsNestedDefinitions(e))&&t.allowStaticWorkspaceNames(this.staticWorkspaceTextNames(e))}functionContainsNestedDefinitions(e){return e.statements.list.some(c.AST.isNodeFunctionDefinition)}staticWorkspaceTextNames(e){const t=new Set,r=e=>{for(const r of e)c.AST.isNodeIdentifier(r)?t.add(r.id):c.AST.isNodeDefaultedParameter(r)&&t.add(r.left.id)};return r(e.parameter.list),r(e.return.list),this.collectStaticWorkspaceTextNames(e.statements,t),t}collectStaticWorkspaceTextNames(e,t){if(!c.AST.isNodeFunctionDefinition(e)){if(c.AST.isNodeIdentifier(e))t.add(e.id);else if(c.AST.isNodeDeclaration(e))for(const r of e.list)c.AST.isNodeIdentifier(r)?t.add(r.id):c.AST.isNodeDefaultedParameter(r)&&t.add(r.left.id);else c.AST.isNodeBinaryOperation(e)&&W.assignmentOperatorNames.has(e.type)&&this.collectStaticAssignmentTargetNames(e.left,t);if(e&&"object"==typeof e)for(const[r,n]of Object.entries(e))if("parent"!==r&&"start"!==r&&"stop"!==r)if(Array.isArray(n))for(const e of n)e&&"object"==typeof e&&this.collectStaticWorkspaceTextNames(e,t);else n&&"object"==typeof n&&this.collectStaticWorkspaceTextNames(n,t)}}collectStaticAssignmentTargetNames(e,t){if(c.AST.isNodeIdentifier(e))t.add(e.id);else if(!c.AST.isNodeIgnoredTarget(e))if(c.AST.isNodeIndexExpr(e))this.collectStaticAssignmentTargetNames(e.expr,t);else if(c.AST.isNodeIndirectRef(e))this.collectStaticAssignmentTargetNames(e.obj,t);else if(d.MultiArray.isInstanceOf(e))for(const r of d.MultiArray.linearize(e))this.collectStaticAssignmentTargetNames(r,t)}applyScopedImports(e,t){const r=c.AST.isNodeList(e)?e.list:[e];for(const e of r)if(c.AST.isNodeImport(e))for(const r of e.imports)this.context.defineImport(r.id,t)}validateFunctionOutputArguments(e,t,r,n=[]){const s=R.FunctionArguments.outputNamesToValidate(e,r,n);s&&this.validateFunctionArguments(e,t,"Output",s,!0);const i=R.FunctionArguments.outputRepeatingInfo(e,e=>this.context.throwSyntaxError(e));if(!i)return;const a=Math.max(r-i.fixedReturnCount,0);if(0===a)return;const o=t.nameTable[i.name];o&&o.node instanceof d.MultiArray&&o.node.isCell||this.context.throwEvalError(`Undefined return variable '${i.name}'`);const l=d.MultiArray.linearize(o.node).slice(0,a).map((e,t)=>{var r;return null!==(r=n[i.fixedReturnCount+t])&&void 0!==r&&!r||void 0===e?void 0:{value:this.expressionValue(e,`${i.name}{${t+1}}`),index:t+1}}).filter(e=>void 0!==e);R.FunctionArguments.validateRepeatingOutputArguments(e,l,Object.assign(Object.assign({evaluate:e=>this.evaluatedExpressionValue(e,t,"repeating output validation expression")},this.pathValidationCallbacks),{throwEvalError:e=>this.context.throwEvalError(e),throwSyntaxError:e=>this.context.throwSyntaxError(e),validateRepeatingValue:(e,r,n,s,i)=>{const a=$.Scope.create(t);a.defineName(r,n),this.validateArgumentValidation(e,a,i,!0,s)}}))}getFunctionInputArgumentDefaults(e){return R.FunctionArguments.inputArgumentDefaults(e,e=>this.context.throwSyntaxError(e))}getFunctionOutputRepeatingName(e){return R.FunctionArguments.outputRepeatingName(e,e=>this.context.throwSyntaxError(e))}Evaluator(e,t=this.context.currentScope){var r,n,s,i,a;if(this._debug&&console.log(`Interpreter(\ntree:${JSON.stringify(e,(e,t)=>"parent"!==e?t:null!==t||"root",2)},\n);`),!e)return null;if(p.FunctionHandle.isInstanceOf(e)){const r=e.id&&!e.closure?this.resolveRuntimeFunction(e.id,t,{loadFunctions:!1}):void 0,n=!e.id||e.closure||(null==r?void 0:r.functionDefinition)?void 0:this.lookupFunctionSourceResolution(e.id,t);if(null==r?void 0:r.functionDefinition){const n=p.FunctionHandle.copy(e);return n.id=e.id.includes(".")?r.resolvedName:this.context.aliasNameFunction(e.id),"FCNDEF"===r.functionDefinition.type&&(n.closure=t.capture(e=>b.MathOperation.copy(e),this.context.allowForwardReference)),n}if(n){const r=p.FunctionHandle.copy(e);return r.id=e.id.includes(".")?n.resolvedName:this.context.aliasNameFunction(e.id),r.sourceName=n.sourceName,"import"===n.source&&(r.closure=t.capture(e=>b.MathOperation.copy(e),this.context.allowForwardReference)),r}if(e.id&&!e.closure&&this.resolveImportedStaticMethod(e.id,t)){const r=p.FunctionHandle.copy(e);return r.closure=t.capture(e=>b.MathOperation.copy(e),this.context.allowForwardReference),r}if(!e.id&&!e.closure){this.validateAnonymousFunctionSignature(e);const r=p.FunctionHandle.copy(e);return r.closure=t.snapshot(e=>b.MathOperation.copy(e)),r.sourceName=this.currentHandleSourceName(),r.className=this.currentHandleClassName(),r}return e}if(h.Complex.isInstanceOf(e)||u.CharString.isInstanceOf(e)||m.Structure.isInstanceOf(e)||f.ClassDefinition.isInstanceOf(e)||g.ClassInstance.isInstanceOf(e)||y.ClassBoundMethod.isInstanceOf(e)||x.ClassStaticMethod.isInstanceOf(e)||C.ClassEmptyMethod.isInstanceOf(e)||E.ClassEnumerationValue.isInstanceOf(e)||v.ClassEventListener.isInstanceOf(e)||A.ClassEventData.isInstanceOf(e)||S.ClassPropertyEvent.isInstanceOf(e)||_.ClassMetaObject.isInstanceOf(e))return e;if(d.MultiArray.isInstanceOf(e))return d.MultiArray.evaluate(e,this,t);switch(e.type){case"VOID":return e;case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":return this.evaluateBinaryOperation(this.requireBinaryOperation(e),t);case"&&":case"||":return this.evaluateShortCircuitOperation(this.requireBinaryOperation(e),t);case"()":return this.evaluatedExpressionValue(this.requirePrefixOperation(e).right,t,"parenthesized expression");case"!":case"~":case"+_":case"-_":return this.evaluateUnaryOperation(this.requirePrefixOperation(e),t);case"++_":case"--_":return this.opTable[e.type](this.requirePrefixOperation(e).right,t);case".'":case"'":return this.evaluateUnaryOperation(this.requirePostfixOperation(e),t);case"_++":case"_--":return this.opTable[e.type](this.requirePostfixOperation(e).left,t);case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const r=this.requireBinaryOperation(e),n=this.validateAssignment(r.left,!0,t),s=r.type,i=s.substring(0,s.length-1);let a,o,l;n.length>1&&i.length>0&&this.context.throwEvalError("computed multiple assignment not allowed."),this.context.pushForwardReferenceTargets(n.map(({id:e})=>e).filter(e=>"~"!==e)),this.context.pushRequestedOutputCount(n.length),this.context.pushRequestedOutputMask(n.map(({id:e})=>"~"!==e));try{a=c.AST.isNodeReturnList(r.right)?r.right:b.MathOperation.copy(this.Evaluator(r.right,t))}catch(e){if(!this.context.allowForwardReference)throw e;if(!this.isLocalUndefinedReference(e))throw e;l=e,a=b.MathOperation.copy(r.right),o=e.identifier}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount(),this.context.popForwardReferenceTargets()}const h=c.AST.ensureReturnList(a),f=c.AST.nodeListFirst(),y=h.handler(n.length),x=e=>{const t=h.selector(y,e);return void 0===t&&c.AST.throwErrorIfGreaterThanReturnList(e,e+1,e=>this.context.throwEvalError(e)),t};for(let s=0;s<n.length;s++){const{id:a,index:h,delimiter:y,field:C,descriptors:E}=n[s];if("~"!==a){if(E&&E.length>0&&!i){const r=t.resolveName(a),n=this.evaluatedExpressionValue(x(s),t,"assignment value");if(r&&g.ClassInstance.isInstanceOf(r.node)&&!this.context.canAccessClassMember(r.node.classDefinition,"private")){const t=this.callClassSubsasgnDescriptors(r.node,E,n,e);if(t){r.node=t,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(r&&(g.ClassInstance.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node))){const t=this.assignClassSubsasgnDescriptors(r.node,E.map(e=>this.readNativeSubscriptDescriptor(e,"subsasgn")),n,e);if(void 0!==t){r.node=t,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(!r&&this.shouldUseNativeChainedSubsasgn(E)){const e=this.readNativeSubscriptDescriptor(E[0]),r=this.blankNativeSubsasgnValue(e),s=this.assignNativeSubsasgnDescriptors(r,E,n),i=t.defineName(a,s);c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),i.node));continue}if(r&&this.shouldUseNativeChainedSubsasgn(E)&&(d.MultiArray.isInstanceOf(r.node)||m.Structure.isInstanceOf(r.node)||m.Structure.isStructure(r.node))&&(!d.MultiArray.isInstanceOf(r.node)||!this.hasClassInstanceElement(r.node))){r.node=this.assignNativeSubsasgnDescriptors(r.node,E,n),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(E&&E.length>0&&i){const e=t.resolveName(a);if(e||this.context.throwEvalError(`in computed assignment ${a} OP= X, ${a} must be defined first.`),this.shouldUseNativeChainedSubsasgn(E)&&(d.MultiArray.isInstanceOf(e.node)||m.Structure.isInstanceOf(e.node)||m.Structure.isStructure(e.node))&&(!d.MultiArray.isInstanceOf(e.node)||!this.hasClassInstanceElement(e.node))){const r=this.nativeSubsrefDescriptors(e.node,E),n=this.evaluatedExpressionValue(c.AST.nodeOperation(i,this.compoundAssignmentOperand(r,"compound assignment target value"),this.evaluatedExpressionValue(x(s),t,"assignment value")),t,"compound assignment value");e.node=this.assignNativeSubsasgnDescriptors(e.node,E,n),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(e.node)));continue}}if(h)if(i){const e=t.resolveName(a);if(void 0!==e){if(!p.FunctionHandle.isInstanceOf(e.node)){const n=this.evaluatedIndexArguments(h,t);if(C.length>0&&c.AST.isNodeIndexExpr(r.left)&&c.AST.isNodeIndirectRef(r.left.expr)&&(m.Structure.isInstanceOf(e.node)||d.MultiArray.isInstanceOf(e.node)&&m.Structure.isStructure(e.node))){const r=m.Structure.getField(e.node,C);if(d.MultiArray.isInstanceOf(r)&&!d.MultiArray.isEmpty(r)){const o=this.evaluatedExpressionValue(c.AST.nodeOperation(i,d.MultiArray.getElements(r,"__field_assignment__",[],n,this),d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(x(s),t,"assignment value"))),t,"compound field assignment value"),l=$.Scope.create();l.defineName("__field_assignment__",r),d.MultiArray.setElements(l,"__field_assignment__",[],n,this.indexedAssignmentRhs(y,o,r),void 0,this),m.Structure.setNewField(e.node,C,this.runtimeExpressionValue(this.scopedExpressionValue(l,"__field_assignment__","field assignment result"),"field assignment result")),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(e.node)));continue}}d.MultiArray.setElements(t,a,C,n,d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(c.AST.nodeOperation(i,d.MultiArray.getElements(e.node,a,C,n),d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(x(s),t,"assignment value"))),t,"compound assignment value"))),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(e.node)));continue}this.context.throwEvalError("can't perform indexed assignment for function handle type.")}else this.context.throwEvalError(`in computed assignment ${a}(index) OP= X, ${a} must be defined first.`)}else{const n=this.evaluatedExpressionValue(x(s),t,"assignment value"),i=t.resolveName(a);if(i&&g.ClassInstance.isInstanceOf(i.node)&&0===C.length){const r=this.callClassSubsasgn(i.node,h,null!=y?y:"()",n,e,t);if(r){i.node=r,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(i.node)));continue}}if(i&&d.MultiArray.isInstanceOf(i.node)&&0===C.length&&this.hasClassInstanceElement(i.node)){const r=this.evaluatedIndexArguments(h,t);try{const s=d.MultiArray.MultiArrayToScalar(this.reducedIndexingResult(d.MultiArray.getElements(i.node,a,[],r)));if(g.ClassInstance.isInstanceOf(s)){const i=this.callClassSubsasgn(s,h,null!=y?y:"()",n,e,t);if(i){d.MultiArray.setElements(t,a,[],r,d.MultiArray.scalarToMultiArray(i)),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),t.resolveName(a).node));continue}}}catch(e){if(!(e instanceof RangeError))throw e}}if(i&&d.MultiArray.isInstanceOf(i.node)&&C.length>0&&this.hasClassInstanceElement(i.node)){i.node=this.assignClassArrayIndexedNestedField(a,i.node,h,C,n,r.left,t),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(i.node)));continue}if(i&&u.CharString.isInstanceOf(i.node)&&0===C.length){"{}"===y&&this.context.throwEvalError("matrix cannot be indexed with {");const e=d.MultiArray.characterVectorFromCharString(i.node),r=$.Scope.create();r.defineName("__char_assignment__",e),d.MultiArray.setElements(r,"__char_assignment__",[],this.evaluatedIndexArguments(h,t),this.charStringAssignmentRhs(n,i.node.quote),void 0,this),i.node=d.MultiArray.charStringFromCharacterVectorResult(this.scopedMultiArrayValue(r,"__char_assignment__","character assignment result"),i.node.quote),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(i.node)));continue}if(i&&C.length>0&&c.AST.isNodeIndexExpr(r.left)&&c.AST.isNodeIndirectRef(r.left.expr)&&(m.Structure.isInstanceOf(i.node)||d.MultiArray.isInstanceOf(i.node)&&m.Structure.isStructure(i.node))){const e=m.Structure.getField(i.node,C);if(d.MultiArray.isInstanceOf(e)&&!d.MultiArray.isEmpty(e)){const r=$.Scope.create();r.defineName("__field_assignment__",e),d.MultiArray.setElements(r,"__field_assignment__",[],this.evaluatedIndexArguments(h,t),this.indexedAssignmentRhs(y,n,e)),m.Structure.setNewField(i.node,C,this.runtimeExpressionValue(this.scopedExpressionValue(r,"__field_assignment__","field assignment result"),"field assignment result")),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(i.node)));continue}}d.MultiArray.setElements(t,a,C,this.evaluatedIndexArguments(h,t),this.indexedAssignmentRhs(y,n,0===C.length?null==i?void 0:i.node:void 0,C.length>0)),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(t.resolveName(a).node)))}else{const n=x(s);n.parent=r.right;let u=n;try{if(C.length>0){let r=t.resolveName(a);i.length&&void 0===r&&this.context.throwEvalError(`in computed assignment ${a}.${C.join(".")} OP= X, ${a}.${C.join(".")} must be defined first.`),void 0===r?r=t.defineName(a,new m.Structure({})):d.MultiArray.isInstanceOf(r.node)&&!r.node.isCell&&d.MultiArray.isEmpty(r.node)&&(r.node=new m.Structure({}));const s=()=>m.Structure.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&m.Structure.isStructure(r.node)?this.expressionValue(m.Structure.getField(r.node,C),`field ${C.join(".")}`):g.ClassInstance.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?this.expressionValue(this.resolveClassFieldChain(r.node,C,e),`field ${C.join(".")}`):void this.context.throwEvalError("in indexed assignment."),o=i.length?void 0!==l?c.AST.nodeOperation(i,s(),n):this.Evaluator(c.AST.nodeOperation(i,s(),n)):n;if(u=o,m.Structure.isInstanceOf(r.node))this.assignStructureFieldValue(r.node,C,this.structureAssignmentValue(o,`field ${C.join(".")}`),!1);else if(d.MultiArray.isInstanceOf(r.node)&&m.Structure.isStructure(r.node))this.assignStructureFieldValue(r.node,C,this.structureAssignmentValue(o,`field ${C.join(".")}`),i.length>0);else if(g.ClassInstance.isInstanceOf(r.node)){const n=this.reducedAssignmentValue(o);r.node=this.assignNestedClassInstanceField(r.node,C,n,e,t)}else d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?r.node=this.assignNestedClassArrayField(r.node,C,this.reducedAssignmentValue(o),e,t):v.ClassEventListener.isInstanceOf(r.node)?(1!==C.length&&this.context.throwEvalError(`cannot assign nested property '${C.join(".")}' for ${r.node.kind}.`),this.setClassEventListenerField(r.node,C[0],this.reducedAssignmentValue(o))):A.ClassEventData.isInstanceOf(r.node)||S.ClassPropertyEvent.isInstanceOf(r.node)?(1!==C.length&&this.context.throwEvalError(`cannot assign nested property '${C.join(".")}' for ${S.ClassPropertyEvent.isInstanceOf(r.node)?"event.PropertyEvent":"event.EventData"}.`),this.setClassEventDataField(r.node,C[0])):this.context.throwEvalError("in indexed assignment.");c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)))}else{const e=i.length?void 0!==l?c.AST.nodeOperation(i,c.AST.nodeIdentifier(a),n):this.Evaluator(c.AST.nodeOperation(i,c.AST.nodeIdentifier(a),n)):n;let r;if(u=e,o)if(this.context.allowForwardReference)t.defineUndefinedReference(o,a),r=t.assignName(a,this.reducedAssignmentValue(e),o);else{if(l)throw l;this.context.throwUndefinedReferenceError(o)}else r=t.assignName(a,this.reducedAssignmentValue(e));if(this.solveUndefined(a,t),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node))),l)throw l}}catch(e){throw this.context.allowForwardReference&&this.isLocalUndefinedReference(e)&&t.assignName(a,u,o),e}}}}return e.parent&&e.parent.parent?this.nestedAssignmentValue(f):1===f.list.length?f.list[0]:f}case"IDENT":return this.context.resolveIdentifier(e,t);case"RETURN":throw new q.ReturnSignal;case"BREAK":throw new q.BreakSignal;case"CONTINUE":throw new q.ContinueSignal;case"FCNDEF":{const a=c.AST.isNodeFunctionDefinition(e)?e:this.context.throwEvalError(`invalid function definition AST node '${e.type}'.`);return this.isNodeInsideExecutableBlock(a)&&this.context.throwSyntaxError(`function definition '${a.id}' is not allowed inside a control block.`),"FCNDEF"===(null===(n=null===(r=this.context.currentFrame)||void 0===r?void 0:r.func)||void 0===n?void 0:n.type)&&t.hasLocalFunction(a.id)||t.functionTable[a.id]===a||this.registerFunctionDefinition(a,t,"FCNDEF"===(null===(i=null===(s=this.context.currentFrame)||void 0===s?void 0:s.func)||void 0===i?void 0:i.type)),c.AST.nodeVoid()}case"CLASSDEF":{const r=c.AST.isNodeClassDef(e)?e:this.context.throwEvalError(`invalid class definition AST node '${e.type}'.`);this.isNodeInsideExecutableBlock(r)&&this.context.throwSyntaxError(`class definition '${r.id}' is not allowed inside a control block.`);const n=f.ClassDefinition.create(r);n.resolveSuperclasses(e=>this.context.resolveClassDefinition(e,t),e=>this.context.throwEvalError(e)),this.context.defineClassDefinition(n,t)}return c.AST.nodeVoid();case"GLOBAL":for(const r of e.list){const e=c.AST.getDeclarationNode(r);if(c.AST.isNodeIdentifier(e))this.context.declareGlobal(e.id,void 0,t);else if(c.AST.isNodeDefaultedParameter(e)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(e.right,t,`global ${e.left.id} default`),`global ${e.left.id} default`);this.context.declareGlobal(e.left.id,r,t)}else this.context.throwSyntaxError("invalid global declaration.")}return c.AST.nodeVoid();case"PERSIST":for(const r of e.list){const e=c.AST.getDeclarationNode(r);if(c.AST.isNodeIdentifier(e))this.context.declarePersistent(e.id,void 0,t);else if(c.AST.isNodeDefaultedParameter(e)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(e.right,t,`persistent ${e.left.id} default`),`persistent ${e.left.id} default`);this.context.declarePersistent(e.left.id,r,t)}else this.context.throwSyntaxError("invalid persistent declaration.")}return c.AST.nodeVoid();case"IMPORT":if(0===e.imports.length){const e=d.MultiArray.toColumnVector(t.importList().map(e=>u.CharString.create(e)));return e.isCell=!0,e}for(const r of e.imports)this.context.defineImport(r.id,t);return c.AST.nodeVoid();case".":{const r=this.resolveQualifiedNameAccess(e,t);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(e,t)){const r=this.collectClassSubsrefChain(e,t);if(r&&r.descriptors.length>0&&!this.context.canAccessClassMember(r.instance.classDefinition,"private")){const t=this.callClassSubsrefDescriptors(r.instance,r.descriptors,e);if(void 0!==t)return t}}const n=e.field.map(e=>"string"==typeof e?e:this.evaluatedDynamicFieldName(e,t,"Dynamic structure field names must be strings.")),s=this.evaluatedCommaSeparatedReceiver(e.obj,t);if(s)return this.chainedCommaListResult(s.map(r=>this.resolveDotFieldChain(r,n,e,t)));const i=this.evaluatedExpressionValue(e.obj,t,"dot receiver");return this.resolveDotFieldChain(i,n,e,t)}case"SUPERCLASS_CTOR":{const r=e,n="IDENT"===r.instance.type?null===(a=t.resolveName(r.instance.id))||void 0===a?void 0:a.node:void 0;if("IDENT"===r.instance.type&&!g.ClassInstance.isInstanceOf(n)){0===r.args.length&&this.context.throwEvalError(`superclass method '${r.instance.id}' requires an object argument.`);const e=this.evaluatedExpressionValue(r.args[0],t,"superclass method receiver");g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError(`superclass method '${r.instance.id}' requires a class instance.`);const n=e.classDefinition.findSuperclass(r.superclass.id);n||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${e.classDefinition.name}.`),this.context.canAccessClassMember(n,"protected")||this.context.throwEvalError(`superclass method '${r.instance.id}' is only accessible from class methods.`);const s=n.findMethod(r.instance.id,e=>!e.isStatic);return s||this.context.throwEvalError(`unknown superclass method '${r.instance.id}' for class ${n.name}.`),this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method '${r.instance.id}' has ${s.access} access for class ${e.classDefinition.name}.`),this.context.callClassInstanceMethod(e,s,r.args.slice(1),r)}const s=g.ClassInstance.isInstanceOf(n)?n:this.evaluatedExpressionValue(r.instance,t,"superclass constructor receiver");g.ClassInstance.isInstanceOf(s)||this.context.throwEvalError("superclass constructor target must be a class instance.");const i=s.classDefinition.findSuperclass(r.superclass.id);return i||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${s.classDefinition.name}.`),this.context.canAccessClassMember(i,"protected")||this.context.throwEvalError(`superclass constructor '${r.superclass.id}' is only accessible from class methods.`),this.context.constructSuperclassInstance(s,i,r.args,r)}case"METACLASS":return this.resolveMetaclassLiteral(e.className.id,t);case"LIST":{this.preregisterScriptLocalFunctions(e,t);const r={type:"LIST",list:new Array(e.list.length),parent:null===e.parent?null:e};let n=0,s=!1;for(let i=0;i<e.list.length;i++){let a;c.AST.isNodeIdentifier(e.list[i])&&!t.resolveName(e.list[i].id)&&this.commandWordListNameSet.has(e.list[i].id)&&(e.list[i]=c.AST.nodeEmptyCmdWList(e.list[i])),e.list[i].index=i;try{a=this.evaluatedExecutionResult(e.list[i],t)}catch(t){if(t instanceof q.ReturnSignal&&null===e.parent&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth){s=!0;break}throw t}if("LIST"===a.type)for(let s=0;s<a.list.length;s++){const i=a.list[s];"VOID"!==i.type&&(a.list[s].parent=r,a.list[s].index=n,r.list[n]=i,null!==e.parent||i.omitAnswer||t.defineName("ans",i),n++)}else if("VOID"===a.type){const t=e.list[i];t.omitAnswer=!0,t.omitOutput=!0,t.parent=r,t.index=n,r.list[n]=t,n++}else a.parent=r,a.index=n,r.list[n]=a,null!==e.parent||a.omitAnswer||t.defineName("ans",a),n++}if(r.list.length=n,s&&0===n)return c.AST.nodeVoid();const i=r.list.filter(e=>!e.omitOutput);return i.length>0&&i.length<r.list.length&&(r.list=i,r.list.forEach((e,t)=>{e.parent=r,e.index=t})),r}case"RANGE":{const r=this.evaluatedExpressionValue(e.start_,t,"range start"),n=this.evaluatedExpressionValue(e.stop_,t,"range stop"),s=e.stride_?this.evaluatedExpressionValue(e.stride_,t,"range stride"):null;return this.evaluateColonWithClassDispatch(s?[r,s,n]:[r,n],e)||d.MultiArray.expandRange(r,n,s)}case"ENDRANGE":{let r=e.parent,n=e.index;for(;c.AST.isNodeBase(r)&&"IDX"!==r.type;)n=r.index,r=r.parent;if(c.AST.isNodeIndexExpr(r)){const e=this.evaluatedExpressionValue(r.expr,t,"indexed expression");if(g.ClassInstance.isInstanceOf(e)){const t=this.callClassEnd(e,n+1,r.args.length,r);return void 0!==t?t:h.Complex.one()}return d.MultiArray.isInstanceOf(e)?1===r.args.length?h.Complex.create(d.MultiArray.linearLength(e)):h.Complex.create(d.MultiArray.getDimension(e,n)):u.CharString.isInstanceOf(e)?h.Complex.create(e.length):h.Complex.one()}this.context.throwSyntaxError("indeterminate end of range. The word 'end' to refer a value is valid only in indexing.")}case":":if(c.AST.isNodeIndexExpr(e.parent)){const r=this.evaluatedExpressionValue(e.parent.expr,t,"indexed expression");return d.MultiArray.isInstanceOf(r)?1===e.parent.args.length?d.MultiArray.expandColon(d.MultiArray.linearLength(r)):d.MultiArray.expandColon(d.MultiArray.getDimension(r,e.index)):u.CharString.isInstanceOf(r)?d.MultiArray.expandColon(r.length):h.Complex.one()}this.context.throwSyntaxError("indeterminate colon. The colon to refer a range is valid only in indexing.");case"IDX":{e.expr||this.context.throwReferenceError(`'${e.id}' undefined.`);const r=this.inheritedHandleMethodCall(e,t);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(e,t)&&c.AST.isNodeIndirectRef(e.expr)){const r=this.dottedCommaReceiver(e.expr,t);if(r){const n=r.fields.map(e=>"string"==typeof e?e:this.evaluatedDynamicFieldName(e,t,"Dynamic structure field names must be strings."));return this.chainedCommaListResult(r.values.map(r=>{const s=this.resolveDotFieldChain(r,n,e.expr,t);return this.chainedCommaItemApply(s,e.args,e)}))}}if(!this.hasQualifiedNameAccessOperand(e,t)){const r=this.collectClassSubsrefChain(e,t);if(r&&r.descriptors.length>0){const t=this.callClassSubsrefDescriptors(r.instance,r.descriptors,e);if(void 0!==t)return t}}const n=this.evaluatedCommaSeparatedReceiver(e.expr,t);if(n)return this.chainedCommaListResult(n.map(t=>this.chainedCommaItemApply(t,e.args,e)));const s=this.evaluatedExpressionValue(e.expr,t,"indexed expression");if(g.ClassInstance.isInstanceOf(s)){const r=this.callClassSubsref(s,e,t);if(void 0!==r)return r}return this.context.apply(s,e.args,e)}case"CMDWLIST":{const t=this.commandWordListTable[e.id];t||this.context.throwUndefinedReferenceError(e.id);const r=this.commandWordListResult(t.func(...e.args.map(e=>e.str)));return void 0!==r?r:e}case"IF":for(let r=0;r<e.expression.length;r++)if(this.evaluatedCondition(e.expression[r],t,"if condition"))return this.evaluatedExecutionResult(e.then[r],t);return e.else?this.evaluatedExecutionResult(e.else,t):{type:"LIST",list:[],parent:e};case"SWITCH":{const r=this.evaluatedExpressionValue(e.expression,t,"switch expression");for(const n of e.cases){const e=this.evaluatedExpressionValue(n.expression,t,"switch case");if(this.switchCaseMatches(r,e))return this.evaluatedExecutionResult(n.then,t)}return e.otherwise?this.evaluatedExecutionResult(e.otherwise,t):{type:"LIST",list:[],parent:e}}case"WHILE":{let r={type:"LIST",list:[],parent:e};for(;;){if(!this.evaluatedCondition(e.expression,t,"while condition"))return r;try{r=this.evaluatedExecutionResult(e.body,t)}catch(e){if(e instanceof q.ContinueSignal)continue;if(e instanceof q.BreakSignal)return r;throw e}}}case"DO_UNTIL":{let r={type:"LIST",list:[],parent:e};for(;;){try{r=this.evaluatedExecutionResult(e.body,t)}catch(e){if(e instanceof q.BreakSignal)return r;if(!(e instanceof q.ContinueSignal))throw e}if(this.evaluatedCondition(e.expression,t,"until condition"))return r}}case"FOR":{let r={type:"LIST",list:[],parent:e};e.workers&&this.workerCountControlArgument(this.evaluatedExpressionValue(e.workers,t,"parfor workers"),"parfor workers");const n=this.evaluatedExpressionValue(e.expression,t,"for expression");e.parallel&&(this.validateParforHeader(e.target,n),this.validateParforBody(e.body,e.target.id));const s=this.forLoopValues(n,e.target);for(const n of s){const s=c.AST.nodeOperation("=",this.cloneAssignmentTarget(e.target),this.forLoopAssignmentValue(e.target,n));this.Evaluator(s,t);try{r=this.evaluatedExecutionResult(e.body,t)}catch(e){if(e instanceof q.ContinueSignal)continue;if(e instanceof q.BreakSignal)return r;throw e}}return r}case"SPMD":if(this.validateSpmdBody(e.body),e.workers){const r=e.workers.list.map((e,r)=>this.workerCountControlArgument(this.evaluatedExpressionValue(this.expressionValue(e,`spmd worker ${r+1}`),t,`spmd worker ${r+1}`),`spmd worker ${r+1}`));2===r.length&&r[0]>r[1]&&this.context.throwEvalError("spmd minimum worker count cannot exceed maximum worker count.")}const o=["spmdIndex","spmdSize"],l=new Map;o.forEach(e=>{l.set(e,t.hasLocalName(e)?Object.assign({},t.nameTable[e]):void 0)}),t.defineName("spmdIndex",h.Complex.one()),t.defineName("spmdSize",h.Complex.one());try{return this.evaluatedExecutionResult(e.body,t)}finally{o.forEach(e=>{const r=l.get(e);r?t.nameTable[e]=r:t.removeName(e)})}case"TRY":try{return this.evaluatedExecutionResult(e.body,t)}catch(r){if(r instanceof q.ReturnSignal||r instanceof q.BreakSignal||r instanceof q.ContinueSignal)throw r;const n=this.rememberLastError(r);return e.catchBody?(e.catchIdentifier&&t.defineName(e.catchIdentifier.id,n),this.evaluatedExecutionResult(e.catchBody,t)):{type:"LIST",list:[],parent:e}}case"UNWIND_PROTECT":{let r,n={type:"LIST",list:[],parent:e},s=!1;try{n=this.evaluatedExecutionResult(e.body,t)}catch(e){r=e,s=!0}if(this.evaluatedExecutionResult(e.cleanup,t),s)throw r;return n}default:this.context.throwEvalError(`evaluating undefined type '${e.type}'.`)}}Evaluate(e){try{return this._exitStatus=W.response.OK,e.parent=null,this.validateDeclarationPlacement(e),this.Evaluator(e)}catch(e){if(e instanceof q.ReturnSignal&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth)return c.AST.nodeVoid();if(this._exitStatus=W.response.EVAL_ERROR,e instanceof q.BreakSignal)try{this.context.throwEvalError("break is only valid inside a loop.")}catch(e){throw this.lastError=e,e}if(e instanceof q.ContinueSignal)try{this.context.throwEvalError("continue is only valid inside a loop.")}catch(e){throw this.lastError=e,e}throw this.lastError=e,e}}Execute(e){try{return this.Evaluate(this.Parse(e))}catch(e){throw this.lastError=e,e}}Unparse(e,t=0){const r=(e,t)=>e+" "+t.list.map(e=>this.Unparse(c.AST.getDeclarationNode(e))).join(" "),n=e=>e.map(e=>this.Unparse(e)).join(","),s=e=>!!e&&"LIST"===e.type&&0===e.list.length,i=e=>e.length>0?"("+e.map(e=>this.Unparse(e)).join(",")+")":"",a=e=>{var t;const r=0===e.return.list.length?"":1===e.return.list.length?this.Unparse(e.return.list[0]):"["+n(e.return.list)+"]",s="("+n(e.parameter.list)+")";if(null===(t=e.attributes)||void 0===t?void 0:t.prototype)return(r?r+"=":"")+e.id+s;const i=e.arguments.list.length>0?"\n"+e.arguments.list.map(e=>this.Unparse(e)).join("\n"):"";return"FUNCTION "+(r?r+"=":"")+e.id+s+i+(e.statements.list.length>0?"\n"+this.Unparse(e.statements).trimEnd():"")+"\nENDFUNCTION"},o=(e,t)=>{const r=this.nodePrecedence(t),n=this.Unparse(t.left,r);return(this.nodePrecedence(t.left)<r?"("+n+")":n)+e},l=(e,t)=>{const r=this.nodePrecedence(t),n=this.Unparse(t.right,r);return e+(this.nodePrecedence(t.right)<r?"("+n+")":n)},b=e=>c.AST.isNodeOperation(e)&&"string"==typeof e.type&&["!","~","+_","-_","++_","--_"].includes(e.type),T=e=>c.AST.isNodeOperation(e)&&"()"===e.type&&b(this.requirePrefixOperation(e).right),M=e=>{const t=this.nodePrecedence(e);return this.nodePrecedence(e.left)<t||("^"===e.type||".^"===e.type||"**"===e.type||".**"===e.type)&&(b(e.left)||T(e.left))};try{if(!e)return"";if(void 0===e)return"<UNDEFINED>";if(h.Complex.isInstanceOf(e))return h.Complex.unparse(e,this,t);if(u.CharString.isInstanceOf(e))return u.CharString.unparse(e,t);if(d.MultiArray.isInstanceOf(e))return d.MultiArray.unparse(e,this,t);if(m.Structure.isInstanceOf(e))return m.Structure.unparse(e,this,t);if(p.FunctionHandle.isInstanceOf(e))return p.FunctionHandle.unparse(e,this,t);if(f.ClassDefinition.isInstanceOf(e))return f.ClassDefinition.unparse(e,this);if(g.ClassInstance.isInstanceOf(e))return g.ClassInstance.unparse(e,this);if(y.ClassBoundMethod.isInstanceOf(e))return y.ClassBoundMethod.unparse(e,this);if(x.ClassStaticMethod.isInstanceOf(e))return x.ClassStaticMethod.unparse(e,this);if(C.ClassEmptyMethod.isInstanceOf(e))return C.ClassEmptyMethod.unparse(e,this);if(E.ClassEnumerationValue.isInstanceOf(e))return E.ClassEnumerationValue.unparse(e,this);if(v.ClassEventListener.isInstanceOf(e))return v.ClassEventListener.unparse(e,this);if(S.ClassPropertyEvent.isInstanceOf(e))return S.ClassPropertyEvent.unparse(e,this);if(A.ClassEventData.isInstanceOf(e))return A.ClassEventData.unparse(e,this);if(_.ClassMetaObject.isInstanceOf(e))return _.ClassMetaObject.unparse(e,this);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.requireBinaryOperation(e),r=this.nodePrecedence(e),n=this.Unparse(t.left,r),s=this.Unparse(t.right,r);return(M(t)?"("+n+")":n)+e.type+(this.nodePrecedence(t.right)<r?"("+s+")":s)}case"()":{const r=this.requirePrefixOperation(e),n=this.nodePrecedence(r.right),s=this.Unparse(r.right,n);return n<t?"("+s+")":s}case"!":case"~":return l(e.type,this.requirePrefixOperation(e));case"+_":return l("+",this.requirePrefixOperation(e));case"-_":return l("-",this.requirePrefixOperation(e));case"++_":return l("++",this.requirePrefixOperation(e));case"--_":return l("--",this.requirePrefixOperation(e));case".'":case"'":return o(e.type,this.requirePostfixOperation(e));case"_++":return o("++",this.requirePostfixOperation(e));case"_--":return o("--",this.requirePostfixOperation(e));case"IDENT":case"CLASS_EVENT":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"SUPERCLASS_CTOR":return this.Unparse(e.instance)+"@"+this.Unparse(e.superclass)+"("+e.args.map(e=>this.Unparse(e).trimEnd()).join(",")+")";case"METACLASS":return"?"+this.Unparse(e.className);case"RETLIST":return"<RETLIST>";case"CMDWLIST":return(e.id+" "+e.args.map(e=>this.Unparse(e)).join(" ")).trimEnd();case"ARGVALID":{const t=e.size.length>0?"("+n(e.size)+")":"",r=e.class&&!s(e.class)?" "+this.Unparse(e.class).trimEnd():"",i=e.functions.length>0?" {"+n(e.functions)+"}":"",a=e.default?"="+this.Unparse(e.default):"";return this.Unparse(e.name)+t+r+i+a}case"ARGS":return"ARGUMENTS"+(e.attributes.length>0?" ("+e.attributes.map(e=>this.Unparse(e)).join(",")+")":"")+(e.validation.length>0?"\n"+e.validation.map(e=>this.Unparse(e)).join("\n"):"")+"\nENDARGUMENTS";case"GLOBAL":return r("global",e);case"PERSIST":return r("persistent",e);case"IMPORT":return"import"+(e.imports.length>0?" "+e.imports.map(e=>this.Unparse(e)).join(" "):"");case"RETURN":return"return";case"BREAK":return"break";case"CONTINUE":return"continue";case"IF":let c="IF "+this.Unparse(e.expression[0])+"\n";c+=this.Unparse(e.then[0])+"\n";for(let t=1;t<e.expression.length;t++)c+="ELSEIF "+this.Unparse(e.expression[t])+"\n",c+=this.Unparse(e.then[t])+"\n";return e.else&&(c+="ELSE\n"+this.Unparse(e.else)+"\n"),c+="ENDIF",c;case"SWITCH":let u="SWITCH "+this.Unparse(e.expression)+"\n";for(const t of e.cases)u+="CASE "+this.Unparse(t.expression)+"\n",u+=this.Unparse(t.then)+"\n";return e.otherwise&&(u+="OTHERWISE\n"+this.Unparse(e.otherwise)+"\n"),u+="ENDSWITCH",u;case"WHILE":return"WHILE "+this.Unparse(e.expression)+"\n"+this.Unparse(e.body)+"\nENDWHILE";case"DO_UNTIL":return"DO\n"+this.Unparse(e.body)+"\nUNTIL "+this.Unparse(e.expression);case"FOR":return(e.parallel?"PARFOR ":"FOR ")+(e.workers?"(":"")+this.Unparse(e.target)+"="+this.Unparse(e.expression)+(e.workers?","+this.Unparse(e.workers)+")":"")+"\n"+this.Unparse(e.body)+(e.parallel?"\nENDPARFOR":"\nENDFOR");case"SPMD":return"SPMD"+(e.workers?" ("+e.workers.list.map(e=>this.Unparse(e)).join(",")+")":"")+"\n"+this.Unparse(e.body)+"\nENDSPMD";case"TRY":return"TRY\n"+this.Unparse(e.body)+(e.catchBody?"\nCATCH"+(e.catchIdentifier?" "+this.Unparse(e.catchIdentifier):"")+"\n"+this.Unparse(e.catchBody):"")+"\nEND_TRY_CATCH";case"UNWIND_PROTECT":return"UNWIND_PROTECT\n"+this.Unparse(e.body)+"\nUNWIND_PROTECT_CLEANUP\n"+this.Unparse(e.cleanup)+"\nEND_UNWIND_PROTECT";case"CLASSDEF":return"CLASSDEF "+i(e.attributes)+(e.attributes.length>0?" ":"")+e.id+(e.superclasses.length>0?" < "+e.superclasses.map(e=>this.Unparse(e)).join("&"):"")+(e.sections.length>0?"\n"+e.sections.map(e=>this.Unparse(e)).join("\n"):"")+"\nENDCLASSDEF";case"CLASS_SECTION":return e.kind+(e.attributes.length>0?" "+i(e.attributes):"")+(e.members.list.length>0?"\n"+this.Unparse(e.members).trimEnd():"")+"\n"+(e=>{switch(e){case"PROPERTIES":return"ENDPROPERTIES";case"METHODS":return"ENDMETHODS";case"EVENTS":return"ENDEVENTS";case"ENUMERATION":return"ENDENUMERATION";default:return"END"}})(e.kind);case"CLASS_PROPERTY":return e.id+(e.size.length>0?"("+n(e.size)+")":"")+(e.class&&!s(e.class)?" "+this.Unparse(e.class).trimEnd():"")+(e.functions.length>0?" {"+n(e.functions)+"}":"")+(e.defaultValue?"="+this.Unparse(e.defaultValue).trimEnd():"");case"CLASS_ENUMERATION":return e.id+(e.args.length>0?"("+e.args.map(e=>this.Unparse(e).trimEnd()).join(",")+")":"");case"CLASS_ATTRIBUTE":return!e.value||"~"!==e.value.type&&"!"!==e.value.type?e.id+(e.value?"="+this.Unparse(e.value).trimEnd():""):e.value.type+e.id;case"FCNDEF":return a(e);case"VOID":return"";default:return"<INVALID>"}}catch(e){return"<ERROR>"}}UnparserMathML(e,t=0){const r=(e,t)=>`<mrow><mi>${e}</mi><mspace width="0.4em"/>${t.list.map(e=>this.UnparserMathML(c.AST.getDeclarationNode(e))).join('<mspace width="0.4em"/>')}</mrow>`,n=e=>e.map(e=>this.UnparserMathML(e)).join("<mo>,</mo>"),s=(e,t)=>`<mtr><mtd><mo><b>${e}</b></mo></mtd>${void 0===t?"":`<mtd>${t}</mtd>`}</mtr>`,i=e=>`<mtr><mtd></mtd><mtd>${this.UnparserMathML(e)}</mtd></mtr>`,a=(e,t,r,n)=>`<mtable>${s(e,n)}${i(t)}${s(r)}</mtable>`,o=(e,t,r)=>w.MathML.format["()"](e,t,r),l=e=>e.length>0?o("(",n(e),")"):"",f=e=>{const t=e.size.length>0?o("(",n(e.size),")"):"",r=!e.class||(s=e.class)&&"LIST"===s.type&&0===s.list.length?"":'<mspace width="0.33em"/>'+this.UnparserMathML(e.class);var s;const i=e.functions.length>0?'<mspace width="0.33em"/>'+o("{",n(e.functions),"}"):"",a=e.default?"<mo>=</mo>"+this.UnparserMathML(e.default):"";return`<mrow>${this.UnparserMathML(e.name)}${t}${r}${i}${a}</mrow>`},g=e=>{const t=0===e.return.list.length?"":1===e.return.list.length?this.UnparserMathML(e.return.list[0]):o("[",n(e.return.list),"]"),r=o("(",n(e.parameter.list),")");return`${t?t+"<mo>=</mo>":""}${w.MathML.format.IDENT(e.id)}${r}`};try{if(!e)return w.MathML.format.UNDEFINED();if(void 0===e)return w.MathML.format.UNDEFINED();if(h.Complex.isInstanceOf(e))return h.Complex.unparseMathML(e,this,t);if(u.CharString.isInstanceOf(e))return u.CharString.unparseMathML(e,t);if(d.MultiArray.isInstanceOf(e))return d.MultiArray.unparseMathML(e,this,t);if(m.Structure.isInstanceOf(e))return m.Structure.unparseMathML(e,this,t);if(p.FunctionHandle.isInstanceOf(e))return p.FunctionHandle.unparseMathML(e,this,t);switch(e.type){case"()":{const r=this.requirePrefixOperation(e),n=this.nodePrecedence(r.right),s=this.UnparserMathML(r.right,n);return n<t?w.MathML.format["()"]("(",s,")"):s}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.requireBinaryOperation(e),r=this.nodePrecedence(e),n=this.UnparserMathML(t.left,r),s=this.UnparserMathML(t.right,r);return w.MathML.formatDynamic(e.type,this.nodePrecedence(t.left)<r?w.MathML.format["()"]("(",n,")"):n,this.nodePrecedence(t.right)<r?w.MathML.format["()"]("(",s,")"):s)}case"/":{const t=this.requireBinaryOperation(e);return w.MathML.formatDynamic(e.type,this.UnparserMathML(t.left),this.UnparserMathML(t.right))}case"**":case"^":{const t=this.requireBinaryOperation(e);return w.MathML.formatDynamic(e.type,this.UnparserMathML(t.left,this.precedenceTable["_"+e.type]),this.UnparserMathML(t.right))}case"!":case"~":case"+_":case"-_":case"++_":case"--_":{const t=this.requirePrefixOperation(e);return w.MathML.formatDynamic(e.type,this.UnparserMathML(t.right))}case"_++":case"_--":case".'":case"'":{const t=this.requirePostfixOperation(e);return w.MathML.formatDynamic(e.type,this.UnparserMathML(t.left,this.precedenceTable["_"+e.type]))}case"IDENT":return w.MathML.format.IDENT((0,T.substSymbol)(e.id));case".":return w.MathML.format["."](this.UnparserMathML(e.obj),e.field.map(e=>"string"==typeof e?w.MathML.format.IDENT(e):w.MathML.format["()"]("(",this.UnparserMathML(e),")")));case"LIST":return w.MathML.format.LIST(e.list.map(e=>this.UnparserMathML(e)));case"RANGE":return e.start_&&e.stop_?e.stride_?w.MathML.format.RANGE(this.UnparserMathML(e.start_),this.UnparserMathML(e.stride_),this.UnparserMathML(e.stop_)):w.MathML.format.RANGE(this.UnparserMathML(e.start_),this.UnparserMathML(e.stop_)):w.MathML.format.RANGE();case"ENDRANGE":case":":case"<~>":return w.MathML.formatDynamic(e.type);case"IDX":if(0===e.args.length)return w.MathML.format.IDX(this.UnparserMathML(e.expr),e.delim[0],[],e.delim[1]);{let r;if("IDENT"===e.expr.type){const t=this.context.aliasNameFunction(e.expr.id);r=t in this.context.builtInFunctionTable&&this.context.builtInFunctionTable[t].UnparserMathML?this.context.builtInFunctionTable[t].UnparserMathML(e):t in this.context.builtInFunctionTable&&w.MathML.formatFunction(t)?w.MathML.formatDynamic(t,...e.args.map(e=>this.UnparserMathML(e))):w.MathML.format.IDX(w.MathML.format.IDENT((0,T.substSymbol)(e.expr.id)),e.delim[0],e.args.map(e=>this.UnparserMathML(e)),e.delim[1])}else r=w.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:w.MathML.format["()"]("(",r,")")}case"RETLIST":return w.MathML.format.RETLIST();case"CMDWLIST":return w.MathML.format.CMDWLIST(e.id,e.args.map(e=>this.UnparserMathML(e)));case"ARGVALID":return f(e);case"ARGS":return`<mtable>${s("arguments",e.attributes.length>0?e.attributes.map(e=>this.UnparserMathML(e)).join("<mo>,</mo>"):void 0)}${e.validation.map(e=>i(e)).join("")}${s("endarguments")}</mtable>`;case"GLOBAL":return r("global",e);case"PERSIST":return r("persistent",e);case"IMPORT":return"<mrow><mi>import</mi>"+(e.imports.length>0?'<mspace width="0.33em"/>'+e.imports.map(e=>this.UnparserMathML(e)).join("<mo>,</mo>"):"")+"</mrow>";case"RETURN":return"<mi>return</mi>";case"BREAK":return"<mi>break</mi>";case"CONTINUE":return"<mi>continue</mi>";case"IF":const c=e.expression.map((t,r)=>`${s(0===r?"if":"elseif",this.UnparserMathML(t))}${i(e.then[r])}`),u=e.else?`${s("else")}${i(e.else)}`:"";return`<mtable>${c.join("")}${u}${s("endif")}</mtable>`;case"SWITCH":return`<mtable>${s("switch",this.UnparserMathML(e.expression))}${e.cases.map(e=>`${s("case",this.UnparserMathML(e.expression))}${i(e.then)}`).join("")}${e.otherwise?`${s("otherwise")}${i(e.otherwise)}`:""}${s("endswitch")}</mtable>`;case"WHILE":return a("while",e.body,"endwhile",this.UnparserMathML(e.expression));case"DO_UNTIL":return`<mtable>${s("do")}${i(e.body)}${s("until",this.UnparserMathML(e.expression))}</mtable>`;case"FOR":return a(e.parallel?"parfor":"for",e.body,e.parallel?"endparfor":"endfor",this.UnparserMathML(e.target)+'<mo form="infix" stretchy="true">=</mo>'+this.UnparserMathML(e.expression)+(e.workers?"<mo>,</mo>"+this.UnparserMathML(e.workers):""));case"SPMD":return a("spmd",e.body,"endspmd",e.workers?this.UnparserMathML(e.workers):void 0);case"TRY":return`<mtable>${s("try")}${i(e.body)}${e.catchBody?s("catch",e.catchIdentifier?this.UnparserMathML(e.catchIdentifier):void 0)+i(e.catchBody):""}${s("end_try_catch")}</mtable>`;case"UNWIND_PROTECT":return`<mtable>${s("unwind_protect")}${i(e.body)}${s("unwind_protect_cleanup")}${i(e.cleanup)}${s("end_unwind_protect")}</mtable>`;case"CLASSDEF":return`<mtable>${s("classdef",`${l(e.attributes)}${e.attributes.length>0?'<mspace width="0.33em"/>':""}${w.MathML.format.IDENT(e.id)}${e.superclasses.length>0?'<mspace width="0.33em"/><mo><</mo><mspace width="0.33em"/>'+e.superclasses.map(e=>this.UnparserMathML(e)).join("<mo>&</mo>"):""}`)}${e.sections.map(e=>i(e)).join("")}${s("endclassdef")}</mtable>`;case"CLASS_SECTION":return`<mtable>${s(e.kind.toLowerCase(),e.attributes.length>0?l(e.attributes):void 0)}${i(e.members)}${s((e=>{switch(e){case"PROPERTIES":return"endproperties";case"METHODS":return"endmethods";case"EVENTS":return"endevents";case"ENUMERATION":return"endenumeration";default:return"end"}})(e.kind))}</mtable>`;case"CLASS_PROPERTY":return f(e.validation);case"CLASS_EVENT":return w.MathML.format.IDENT(e.id);case"CLASS_ENUMERATION":return`<mrow>${w.MathML.format.IDENT(e.id)}${e.args.length>0?o("(",n(e.args),")"):""}</mrow>`;case"CLASS_ATTRIBUTE":return!e.value||"~"!==e.value.type&&"!"!==e.value.type?`<mrow>${w.MathML.format.IDENT(e.id)}${e.value?"<mo>=</mo>"+this.UnparserMathML(e.value):""}</mrow>`:`<mrow><mo>${e.value.type}</mo>${w.MathML.format.IDENT(e.id)}</mrow>`;case"FCNDEF":return(e=>{var t;if(null===(t=e.attributes)||void 0===t?void 0:t.prototype)return g(e);const r=e.arguments.list.map(e=>i(e)).join("");return`<mtable>${s("function",g(e))}${r}${i(e.statements)}${s("endfunction")}</mtable>`})(e);case"VOID":return w.MathML.format.VOID();default:return w.MathML.format.INVALID()}}catch(e){if(this._debug)throw e;return w.MathML.format.ERROR()}}UnparseMathML(e,t="block"){let r=this.UnparserMathML(e);return r?w.MathML.format.math(w.MathML.format.errorReplace(r),t):"<b>Unparse error.</b>"}ToMathML(e,t="block"){return this.UnparseMathML(this.Parse(e),t)}Interprets(e,t="none"){const r=this.Parse(e),n=this.Evaluate(r);return{input:e,inputParsed:r,inputUnparsed:this.Unparse(n),inputUnparsedMathML:this.UnparseMathML(n),evaluated:n,evaluatedUnparsed:this.Unparse(n),evaluatedUnparsedMathML:this.UnparseMathML(n,t)}}}t.Interpreter=W,W.nameLengthMax=63,W.keywordNames=i.default.keywordNames.filter(e=>"string"==typeof e&&e.length>0).sort(),W.keywordNameSet=new Set(W.keywordNames),W.publicArgumentValidators=["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal","mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual","mustBeInRange","mustBeBetween","mustBeMember","mustBeA","mustBeUnderlyingType"],W.response={EXTERNAL:-2,WARNING:-1,OK:0,LEX_ERROR:1,PARSER_ERROR:2,EVAL_ERROR:3},W.assignmentOperatorNames=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]),W.binaryOperatorMethodTable={"+":"plus","-":"minus",".*":"times","*":"mtimes","./":"rdivide","/":"mrdivide",".\\":"ldivide","\\":"mldivide",".^":"power","^":"mpower","<":"lt","<=":"le","==":"eq",">=":"ge",">":"gt","!=":"ne","~=":"ne","&":"and","|":"or","&&":"and","||":"or"},W.unaryOperatorMethodTable={"+_":"uplus","-_":"uminus","!":"not","~":"not",".'":"transpose","'":"ctranspose"},W.precedence=[["min","=","+=","-=","*=","/=","\\="],["||"],["&&"],["|"],["&"],["!=","<",">","<=",">="],["+","-"],[".*","*","./","/",".\\","\\"],["^",".**","**",".'","'"],["!","~","-_","+_"],["preMax","_.^","_.**","_^","_**","__.'","__'","__++"],["max","()","IDENT","ENDRANGE",":","<~>","."]],W.Create=(e,t)=>new W(e,t),W.nativeNameTableFactory=()=>({false:h.Complex.false(),true:h.Complex.true(),i:h.Complex.onei(),I:h.Complex.onei(),j:h.Complex.onei(),J:h.Complex.onei(),e:h.Complex.e(),pi:h.Complex.pi(),inf:h.Complex.inf_0(),Inf:h.Complex.inf_0(),nan:h.Complex.NaN_0(),NaN:h.Complex.NaN_0()});var Q=r(9274);Object.defineProperty(t,"ManifestSourceResolver",{enumerable:!0,get:function(){return Q.ManifestSourceResolver}}),Object.defineProperty(t,"TableSourceResolver",{enumerable:!0,get:function(){return Q.TableSourceResolver}}),t.default={Scope:$.Scope,CallFrame:B.CallFrame,InterpreterError:z.InterpreterError,EvalError:z.EvalError,ReferenceError:z.ReferenceError,UndefinedReferenceError:z.UndefinedReferenceError,CircularReferenceError:z.CircularReferenceError,SyntaxError:z.SyntaxError,Context:q.Context,Interpreter:W}},1201(e,t){"use strict";t.SyntaxError=t.CircularReferenceError=t.UndefinedReferenceError=t.ReferenceError=t.EvalError=t.InterpreterError=void 0;class r extends Error{constructor(e,t){super(e),this.name="InterpreterError",this.stackFrames=t}format(){let e=`Error: ${this.message}`;if(!this.stackFrames||0===this.stackFrames.length)return e;const t=[];for(const e of this.stackFrames){const r=this.getFrameName(e);if(!r||"<anonymous>"===r)continue;let n="";const s=e.callSite;if(null==s?void 0:s.start){const{line:e,column:t}=s.start;void 0!==e&&void 0!==t?n=` (line ${e}, column ${t})`:void 0!==e&&(n=` (line ${e})`)}t.push(`Error in ${r}${n}`)}return t.length>0&&(e+="\n"+t.join("\n")),e}getFrameName(e){var t,r;if(e.name)return e.name;const n=e.func;if(!n)return"";switch(n.type){case"BUILTIN":return null!==(t=n.node.id)&&void 0!==t?t:"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return null!==(r=n.node.id)&&void 0!==r?r:"<function>";default:return"<unknown>"}}toString(){return this.format()}}t.InterpreterError=r,t.EvalError=class extends r{constructor(e,t){super(e,t),this.name="EvalError"}};class n extends r{constructor(e,t){super(e,t),this.name="ReferenceError"}}t.ReferenceError=n,t.UndefinedReferenceError=class extends n{constructor(e,t){super(`'${e}' undefined.`,t),this.identifier=e,this.name="UndefinedReferenceError"}},t.CircularReferenceError=class extends r{constructor(e,t){super(`Circular reference detected: ${e.join(" → ")}`,t),this.chain=e,this.name="CircularReferenceError"}},t.SyntaxError=class extends r{constructor(e,t){super(e,t),this.name="SyntaxError"}}},227(e,t,r){"use strict";t.LAPACK=t.ec=void 0;const n=r(845),s=r(7679),i=r(6115);t.ec=["maxIterationFactor"];const a=new Set(t.ec);class o{}t.LAPACK=o,o.defaultSettings=Object.assign({},{maxIterationFactor:1e3}),o.settings=o.defaultSettings,o.mtimes=(e,t)=>{const r=e.dimension[0],a=e.dimension[1],o=t.dimension[1];if(a!==t.dimension[0])throw new Error(`LAPACK.mtimes: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is ${t.dimension.join("x")}).`);const l=new s.MultiArray([r,o]);return i.BLAS.gemm(n.Complex.one(),e.array,r,a,t.array,o,n.Complex.zero(),l.array),s.MultiArray.setType(l),l},o.set=e=>{Object.entries(e).forEach(e=>{if(!a.has(e[0]))throw new Error(`LAPACK.set: invalid configuration parameter: ${e[0]}`);o.settings[e[0]]=e[1]})},o.is_hermitian=e=>{const t=e.length;if(0===t)return!0;if(e[0].length!==t)return!1;for(let r=0;r<t;r++){const s=e[r][r];if(Math.abs((0,n.toNumber)(s.im))>1e-14)return!1;for(let s=r+1;s<t;s++){const t=e[r][s],i=e[s][r],a=(0,n.toNumber)(t.re)-(0,n.toNumber)(i.re),o=(0,n.toNumber)(t.im)+(0,n.toNumber)(i.im);if(Math.hypot(a,o)>1e-14)return!1}}return!0},o.is_positive_definite=e=>{const t=e.length;if(0===t)return!0;if(e[0].length!==t)return!1;if(!o.is_hermitian(e))return!1;const r=Array.from({length:t},(r,s)=>Array.from({length:t},(t,r)=>n.Complex.copy(e[s][r])));for(let e=0;e<t;e++){let s=r[e][e];for(let t=0;t<e;t++){const i=r[e][t];s=n.Complex.sub(s,n.Complex.mul(i,n.Complex.conj(i)))}if(Math.abs((0,n.toNumber)(s.im))>1e-14)return!1;if((0,n.toNumber)(s.re)<=1e-14)return!1;const i=n.Complex.create(Math.sqrt((0,n.toNumber)(s.re)),0);r[e][e]=i;for(let s=e+1;s<t;s++){let t=r[s][e];for(let i=0;i<e;i++)t=n.Complex.sub(t,n.Complex.mul(r[s][i],n.Complex.conj(r[e][i])));r[s][e]=n.Complex.rdiv(t,i)}}return!0},o.laswp=(e,t,r,n,s,i,a,o)=>{const l=t[0],c=t[1],u=2===t.length?1:t.slice(2).reduce((e,t)=>e*t,1),h=void 0===a?0:a,d=void 0===o?c-1:o;if(!s||0===s.length)return;const m=0===Math.min(...s);if(i>0)for(let t=r;t<=n;t+=i){const r=t-1,n=s[t-1],i=m?n:n-1;if(i!==r)for(let t=0;t<u;t++){const n=t*l+r,s=t*l+i;for(let t=h;t<=d;t++){const r=e[n][t];e[n][t]=e[s][t],e[s][t]=r}}}else for(let t=r;t>=n;t+=i){const r=t-1,n=s[t-1],i=m?n:n-1;if(i!==r)for(let t=0;t<u;t++){const n=t*l+r,s=t*l+i;for(let t=h;t<=d;t++){const r=e[n][t];e[n][t]=e[s][t],e[s][t]=r}}}},o.laswp_rows=(e,t,r,n)=>{const s=r+1,i=s,a=[];a[s-1]=n+1,o.laswp(e,t,s,i,a,1)},o.laswp_cols=(e,t,r,n)=>{const s=t[0]*(2===t.length?1:t.slice(2).reduce((e,t)=>e*t,1));for(let t=0;t<s;t++){const s=e[t][r];e[t][r]=e[t][n],e[t][n]=s}},o.eye=(...e)=>{const t=e.flat(),r=t[0],s=t[1];if(2===t.length)return Array.from({length:r},(e,t)=>Array.from({length:s},(e,r)=>t===r?n.Complex.one():n.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:s},(e,t)=>i===t?n.Complex.one():n.Complex.zero())})}},o.fillFactory=e=>(...t)=>{const r=t.flat();return Array.from({length:r[0]*r.slice(2).reduce((e,t)=>e*t,1)},()=>Array.from({length:r[1]},e))},o.zeros=o.fillFactory(()=>n.Complex.zero()),o.ones=o.fillFactory(()=>n.Complex.one()),o.diag=(e,t=0,...r)=>{const s=r.length>0?r.flat():[e.length,e.length],i=s[0],a=s[1];if(2===s.length)return Array.from({length:i},(r,s)=>Array.from({length:a},(r,i)=>s+t===i?e[s]:n.Complex.zero()));{const r=s.slice(2).reduce((e,t)=>e*t,1);return Array.from({length:i*r},(r,s)=>{const o=s%i;return Array.from({length:a},(r,s)=>o+t===s?e[o]:n.Complex.zero())})}},o.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},o.lassq=e=>{const t=e.dimension[0],r=e.dimension[1];let s=n.Complex.zero(),i=n.Complex.one();for(let a=0;a<t;a++)for(let t=0;t<r;t++){const r=e.array[a][t];if(!n.Complex.realIsZero(r)){const e=n.Complex.abs(r);if(n.Complex.lt(s,e)){if(!n.Complex.realIsZero(s)){const t=n.Complex.rdiv(s,e);n.Complex.mulAndSumTo(i,i,n.Complex.mul(t,t))}s=e}else{const t=n.Complex.rdiv(e,s);n.Complex.mulAndSumTo(i,t,t)}}}return{scale:s,sumsq:i}},o.lange=(e,t)=>{const r=t.dimension[0],s=t.dimension[1];switch(e){case"F":{const{scale:e,sumsq:r}=o.lassq(t);return n.Complex.realIsZero(e)?n.Complex.zero():n.Complex.mul(e,n.Complex.sqrt(r))}case"M":{let e=n.Complex.zero();for(let i=0;i<r;i++)for(let r=0;r<s;r++){const s=n.Complex.abs(t.array[i][r]);n.Complex.lt(e,s)&&(e=s)}return e}default:throw new Error(`lange: norm '${e}' not implemented`)}},o.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 s=0;s<t;s++){const t=s*r;for(let r=0;r<e.dimension[0];r++){const s=e.array[t+r];for(let t=0;t<Math.min(r,e.dimension[1]);t++)s[t]=n.Complex.zero()}}s.MultiArray.setType(e)},o.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 s=0;s<t;s++){const t=s*r;for(let r=0;r<e.dimension[0];r++){const s=e.array[t+r];for(let t=r+1;t<e.dimension[1];t++)s[t]=n.Complex.zero()}}s.MultiArray.setType(e)},o.trsm_left_upper_block=(e,t,r)=>{const s=e[0].length;for(let i=t+r;i<s;i++)for(let s=r-1;s>=0;s--){const a=t+s;let o=e[a][i];for(let l=s+1;l<r;l++){const r=e[a][t+l],s=e[t+l][i];o=n.Complex.sub(o,n.Complex.mul(r,s))}const l=e[a][t+s];e[a][i]=n.Complex.rdiv(o,l)}},o.lapmt_matrix=e=>{const t=e.length,r=new s.MultiArray([t,t]);for(let s=0;s<t;s++){const t=e[s];r.array[t][s]=n.Complex.one()}return s.MultiArray.setType(r),r},o.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 s=0;s<n;s++){const n=t[s];for(let t=0;t<r;t++)e.array[t][s]=i[t][n]}s.MultiArray.setType(e)},o.dotc_col=(e,t,r)=>{const s=e.dimension[0];if(r+1>=s)return n.Complex.zero();{const n=e.array.slice(r+1,s).map(e=>e[t]);return i.BLAS.dotc(n,n)}},o.dotc_row=(e,t,r)=>{const s=e.dimension[1];if(r+1>=s)return n.Complex.zero();{const n=e.array[t].slice(r+1,s);return i.BLAS.dotc(n,n)}},o.larfg=(e,t,r,s)=>{const i=r-s,a=new Array(i);if(a[0]=t.array[s][s],"L"===e)for(let e=1;e<i;e++)a[e]=t.array[s+e][s];else for(let e=1;e<i;e++)a[e]=t.array[s][s+e];const o=a[0],l=n.Complex.abs(o),c=n.Complex.realIsZero(l)?n.Complex.one():n.Complex.rdiv(o,l);let u=n.Complex.zero();for(let e=1;e<i;e++)u=n.Complex.add(u,n.Complex.mul(a[e],n.Complex.conj(a[e])));if(1===i||n.Complex.realIsZero(n.Complex.abs(u))){const e=n.Complex.zero(),t=new Array(i).fill(n.Complex.zero());return t[0]=n.Complex.one(),{tau:e,v:t,phi:c,alpha:o}}const h=n.Complex.sqrt(n.Complex.add(n.Complex.mul(o,n.Complex.conj(o)),u)),d=n.Complex.mul(n.Complex.neg(c),h),m=n.Complex.rdiv(n.Complex.sub(d,o),d),p=n.Complex.sub(o,d),f=new Array(i);f[0]=n.Complex.one();for(let e=1;e<i;e++)f[e]=n.Complex.rdiv(a[e],p);return{tau:m,v:f,phi:c,alpha:d}},o.larfg_novo=(e,t,r,s)=>{const i=r-s,a=new Array(i);if(a[0]=t.array[s][s],"L"===e)for(let e=1;e<i;e++)a[e]=t.array[s+e][s];else for(let e=1;e<i;e++)a[e]=t.array[s][s+e];const o=a[0],l=n.Complex.abs(o),c=n.Complex.realIsZero(l)?n.Complex.one():n.Complex.rdiv(o,l);let u=n.Complex.zero();for(let e=1;e<i;e++)u=n.Complex.add(u,n.Complex.mul(a[e],n.Complex.conj(a[e])));if(1===i||n.Complex.realIsZero(n.Complex.abs(u))){const e=n.Complex.zero(),t=new Array(i).fill(n.Complex.zero());return t[0]=n.Complex.one(),{tau:e,v:t,phi:c,alpha:o}}const h=n.Complex.sqrt(n.Complex.add(n.Complex.mul(o,n.Complex.conj(o)),u)),d=n.Complex.mul(n.Complex.neg(c),h),m=n.Complex.rdiv(n.Complex.sub(d,o),d),p=n.Complex.sub(o,d),f=new Array(i);f[0]=n.Complex.one();for(let e=1;e<i;e++)f[e]=n.Complex.rdiv(a[e],p);return{tau:m,v:f,phi:c,alpha:d}},o.larf_left=(e,t,r,s,i)=>{if(n.Complex.realIsZero(n.Complex.abs(r)))return;const a=t.length;for(let o=i;o<e.dimension[1];o++){let i=n.Complex.zero();for(let r=0;r<a;r++)n.Complex.mulAndSumTo(i,n.Complex.conj(t[r]),e.array[s+r][o]);if(i=n.Complex.mul(r,i),!n.Complex.realIsZero(n.Complex.abs(i)))for(let r=0;r<a;r++)e.array[s+r][o]=n.Complex.sub(e.array[s+r][o],n.Complex.mul(t[r],i))}},o.larf=(e,t,r,s,i,a)=>{if(n.Complex.realIsZero(n.Complex.abs(s)))return;const o=t.dimension[0],l=t.dimension[1],c=r.length;if("L"===e){const e=new Array(l-a).fill(n.Complex.zero());for(let s=0;s<l-a;s++){let o=n.Complex.zero();for(let e=0;e<c;e++){const l=t.array[i+e][a+s];n.Complex.mulAndSumTo(o,n.Complex.conj(r[e]),l)}e[s]=o}for(let o=0;o<c;o++){const c=r[o],u=t.array[i+o];for(let t=0;t<l-a;t++)u[a+t]=n.Complex.sub(u[a+t],n.Complex.mul(s,n.Complex.mul(c,e[t])))}}else{const e=o-i,l=r.length,c=new Array(e);for(let s=0;s<e;s++){let e=n.Complex.zero();const o=t.array[i+s];for(let t=0;t<l;t++)n.Complex.mulAndSumTo(e,o[a+t],n.Complex.conj(r[t]));c[s]=e}for(let o=0;o<e;o++){const e=c[o];if(n.Complex.realIsZero(n.Complex.abs(e)))continue;const u=t.array[i+o];for(let t=0;t<l;t++)u[a+t]=n.Complex.sub(u[a+t],n.Complex.mul(s,n.Complex.mul(e,r[t])))}}},o.larf_right_adjoint=(e,t,r,s,i)=>{if(n.Complex.realIsZero(n.Complex.abs(r)))return;const a=e.dimension[0],o=t.length,l=new Array(a-s).fill(n.Complex.zero());for(let r=s;r<a;r++){let a=n.Complex.zero();for(let s=0;s<o;s++)a=n.Complex.add(a,n.Complex.mul(e.array[r][i+s],t[s]));l[r-s]=a}const c=n.Complex.conj(r);for(let r=s;r<a;r++)for(let a=0;a<o;a++){const o=n.Complex.mul(c,n.Complex.mul(l[r-s],n.Complex.conj(t[a])));e.array[r][i+a]=n.Complex.sub(e.array[r][i+a],o)}},o.larf_left_block=(e,t,r,a,o,l)=>{if(n.Complex.realIsZero(n.Complex.abs(r)))return;const c=e.dimension[0],u=e.dimension[1],h=t.length;if(a<0||a>=c)throw new Error("larf_left_block: invalid rowStart");if(o<0||o>=u)throw new Error("larf_left_block: invalid colStart");if(h!==c-a)throw new Error("larf_left_block: v length must equal m - rowStart");const d=Math.max(1,Math.floor(null!=l?l:i.BLAS.settings.blockSize)),m=new s.MultiArray([h,1]);for(let e=0;e<h;e++)m.array[e][0]=t[e];const p=new s.MultiArray([1,h]);for(let e=0;e<h;e++)p.array[0][e]=n.Complex.conj(t[e]);for(let t=o;t<u;t+=d){const o=Math.min(t+d,u)-t,l=new s.MultiArray([h,o]);for(let r=0;r<h;r++)for(let n=0;n<o;n++)l.array[r][n]=e.array[a+r][t+n];const c=new s.MultiArray([1,o]);i.BLAS.gemm_block(p.array,l.array,c.array,n.Complex.one(),n.Complex.zero(),d);for(let e=0;e<o;e++)c.array[0][e]=n.Complex.mul(r,c.array[0][e]);for(let e=0;e<h;e++){const t=m.array[e][0];if(!n.Complex.realIsZero(n.Complex.abs(t)))for(let r=0;r<o;r++){const s=n.Complex.mul(t,c.array[0][r]);l.array[e][r]=n.Complex.sub(l.array[e][r],s)}}for(let r=0;r<h;r++)for(let n=0;n<o;n++)e.array[a+r][t+n]=l.array[r][n]}},o.geqr2=e=>{const t=s.MultiArray.copy(e),r=t.dimension[0],i=t.dimension[1],a=Math.min(r,i),l=new Array(a),c=new Array(a);for(let e=0;e<a;e++){const{tau:s,v:a,phi:u,alpha:h}=o.larfg("L",t,r,e);t.array[e][e]=h;for(let r=1;r<a.length;r++)t.array[e+r][e]=n.Complex.mul(s,a[r]);e+1<i&&o.larf("L",t,a,s,e,e+1),l[e]=s,c[e]=u}return s.MultiArray.setType(t),{R:t,taus:l,phis:c}},o.geqp2=e=>{const t=e.dimension[0],r=e.dimension[1],a=new Array(Math.min(t,r)),l=new Array(Math.min(t,r)),c=new Array(r);for(let e=0;e<r;e++)c[e]=e;const u=new Array(r),h=new Array(r);for(let t=0;t<r;t++){const r=i.BLAS.nrm2(e.array.map(e=>e[t]));u[t]=r,h[t]=r}const d=Math.min(t,r);for(let s=0;s<d;s++){let d=s,m=u[s];for(let e=s+1;e<r;e++)n.Complex.toBoolean(n.Complex.gt(u[e],m))&&(m=u[e],d=e);if(d!==s){for(let r=0;r<t;r++){const t=e.array[r][s];e.array[r][s]=e.array[r][d],e.array[r][d]=t}const r=u[s];u[s]=u[d],u[d]=r;const n=h[s];h[s]=h[d],h[d]=n;const i=c[s];c[s]=c[d],c[d]=i}const{tau:p,v:f,alpha:g,phi:y}=o.larfg("L",e,t,s);a[s]=p,l[s]=y,e.array[s][s]=g;for(let t=1;t<f.length;t++)e.array[s+t][s]=n.Complex.mul(p,f[t]);s+1<r&&o.larf("L",e,f,p,s,s+1);for(let a=s+1;a<r;a++){if(n.Complex.toBoolean(n.Complex.eq(u[a],n.Complex.zero())))continue;const r=n.Complex.abs(e.array[s][a]),o=n.Complex.rdiv(r,u[a]),l=n.Complex.sub(n.Complex.one(),n.Complex.mul(o,o)),c=n.Complex.toBoolean(n.Complex.gt(l,n.Complex.zero()))?l:n.Complex.zero();if(u[a]=n.Complex.mul(u[a],n.Complex.sqrt(c)),n.Complex.toBoolean(n.Complex.le(u[a],n.Complex.mul(n.Complex.onediv2(),h[a])))){const r=i.BLAS.nrm2(e.array.slice(s+1,t).map(e=>e[a]));u[a]=r,h[a]=r}}}return s.MultiArray.setType(e),{R:e,taus:a,phis:l,jpvt:c}},o.geqp3=e=>{const t=s.MultiArray.copy(e),r=t.dimension[0],i=t.dimension[1],a=Math.min(r,i),l=new Array(a),c=new Array(a),u=new Array(i);for(let e=0;e<i;e++)u[e]=e;const h=new Array(i),d=new Array(i);for(let e=0;e<i;e++){let s=n.Complex.zero();for(let i=0;i<r;i++){const r=t.array[i][e],a=n.Complex.abs(r);n.Complex.mulAndSumTo(s,a,a)}const i=n.Complex.sqrt(s);h[e]=i,d[e]=i}for(let e=0;e<a;e++){let s=e,a=h[e];for(let t=e+1;t<i;t++)n.Complex.toBoolean(n.Complex.gt(h[t],a))&&(a=h[t],s=t);if(s!==e){for(let n=0;n<r;n++){const r=t.array[n][e];t.array[n][e]=t.array[n][s],t.array[n][s]=r}const n=u[e];u[e]=u[s],u[s]=n;const i=h[e];h[e]=h[s],h[s]=i;const a=d[e];d[e]=d[s],d[s]=a}const{tau:m,v:p,phi:f,alpha:g}=o.larfg("L",t,r,e);if(t.array[e][e]=g,n.Complex.realIsZero(n.Complex.abs(m)))for(let r=1;r<p.length;r++)t.array[e+r][e]=n.Complex.zero();else for(let r=1;r<p.length;r++)t.array[e+r][e]=n.Complex.mul(m,p[r]);e+1<i&&!n.Complex.realIsZero(n.Complex.abs(m))&&o.larf("L",t,p,m,e,e+1),l[e]=m,c[e]=f;for(let s=e;s>=0;s--){const e=r-s,i=new Array(e);i[0]=n.Complex.one();const a=l[s];if(n.Complex.realIsZero(n.Complex.abs(a)))for(let t=1;t<e;t++)i[t]=n.Complex.zero();else for(let r=1;r<e;r++)i[r]=n.Complex.rdiv(t.array[s+r][s],a)}for(let s=e+1;s<i;s++)if(n.Complex.toBoolean(n.Complex.ne(h[s],n.Complex.zero()))){const i=t.array[e][s],a=n.Complex.abs(i),o=n.Complex.sub(n.Complex.one(),n.Complex.rdiv(n.Complex.mul(a,a),n.Complex.mul(h[s],h[s]))),l=n.Complex.toBoolean(n.Complex.gt(o,n.Complex.zero()))?n.Complex.sqrt(o):n.Complex.zero(),c=n.Complex.mul(h[s],l),u=n.Complex.onediv2();if(n.Complex.toBoolean(n.Complex.le(c,n.Complex.mul(u,d[s])))){let i=n.Complex.zero();for(let a=e+1;a<r;a++){const e=t.array[a][s],r=n.Complex.abs(e);n.Complex.mulAndSumTo(i,r,r)}const a=n.Complex.sqrt(i);h[s]=a,d[s]=a}else h[s]=c}}return s.MultiArray.setType(t),{R:t,taus:l,phis:c,jpvt:u}},o.gelq2=e=>{const t=e.dimension[0],r=e.dimension[1],i=Math.min(t,r),a=new Array(i),l=new Array(i);for(let s=0;s<i;s++){const{tau:i,v:c,alpha:u,phi:h}=o.larfg("R",e,r,s);a[s]=i,l[s]=h,e.array[s][s]=u;for(let t=1;t<c.length;t++)e.array[s][s+t]=c[t];s+1<t&&!n.Complex.realIsZero(n.Complex.abs(i))&&o.larf("R",e,c,i,s+1,s)}return s.MultiArray.setType(e),{L:e,taus:a,phis:l}},o.orgqr=(e,t)=>{const r=e.dimension[0],i=e.dimension[1],a=Math.min(r,i),l=new s.MultiArray([r,r]);l.array=o.eye(r,r);for(let s=a-1;s>=0;s--){const i=r-s,a=[n.Complex.one()],c=t[s];if(n.Complex.realIsZero(n.Complex.abs(c)))for(let e=1;e<i;e++)a[e]=n.Complex.zero();else for(let t=1;t<i;t++)a[t]=n.Complex.rdiv(e.array[s+t][s],c);o.larf("L",l,a,c,s,0)}return s.MultiArray.setType(l),l},o.orglq=(e,t)=>{const r=e.dimension[1],i=t.length,a=new s.MultiArray([r,r]);a.array=o.eye(r,r);for(let s=i-1;s>=0;s--){const i=t[s];if(n.Complex.realIsZero(n.Complex.abs(i)))continue;const l=r-s,c=new Array(l);c[0]=n.Complex.one();for(let t=1;t<l;t++)c[t]=e.array[s][s+t];o.larf("R",a,c,i,0,s)}return s.MultiArray.setType(a),a},o.getf2=(e,t,r,s,i,a)=>{const l=[e.length,e[0].length],[c,u]=l,h=Math.min(t+r,Math.min(c,u));for(let r=t;r<h;r++){let t=r,h=n.Complex.abs(e[r][r]);for(let s=r+1;s<c;s++){const i=n.Complex.abs(e[s][r]);n.Complex.toBoolean(n.Complex.gt(i,h))&&(h=i,t=s)}s[r]=t,t!==r&&(o.laswp_rows(e,l,r,t),void 0!==i&&i.swaps++);const d=e[r][r];if(n.Complex.toBoolean(n.Complex.eq(n.Complex.abs(d),n.Complex.zero())))void 0!==a&&0===a.info&&(a.info=r+1);else{for(let t=r+1;t<c;t++)e[t][r]=n.Complex.rdiv(e[t][r],d);for(let t=r+1;t<c;t++){const s=e[t][r];if(n.Complex.toBoolean(n.Complex.eq(n.Complex.abs(s),n.Complex.zero())))continue;const i=e[t],a=e[r];for(let e=r+1;e<u;e++)i[e]=n.Complex.sub(i[e],n.Complex.mul(s,a[e]))}}}},o.getrf=(e,t)=>{const r=e.length,s=e[0].length,a=Math.min(r,s),l=new Array(a);for(let e=0;e<a;e++)l[e]=e;const c={swaps:0},u={info:0};for(let h=0;h<a;h+=null!=t?t:i.BLAS.settings.blockSize){const d=Math.min(null!=t?t:i.BLAS.settings.blockSize,a-h);o.getf2(e,h,d,l,c,u);for(let t=h;t<h+d&&t<a;t++){const r=l[t];if(r!==t&&c.swaps++,r!==t&&h>0)for(let n=0;n<h;n++){const s=e[t][n];e[t][n]=e[r][n],e[r][n]=s}}const m=d,p=r-(h+m),f=s-(h+m);if(h+m<s){const t=e,r=[];for(let e=0;e<p;e++){const n=h+m+e,s=new Array(m);for(let e=0;e<m;e++)s[e]=t[n][h+e];r.push(s)}const s=[];for(let e=0;e<m;e++){const r=h+e,n=new Array(f);for(let e=0;e<f;e++)n[e]=t[r][h+m+e];s.push(n)}const a=[];for(let e=0;e<p;e++){const r=h+m+e,n=new Array(f);for(let e=0;e<f;e++)n[e]=t[r][h+m+e];a.push(n)}i.BLAS.gemm(n.Complex.neg(n.Complex.one()),r,p,m,s,f,n.Complex.one(),a);for(let e=0;e<p;e++){const r=h+m+e;for(let n=0;n<f;n++)t[r][h+m+n]=a[e][n]}for(let e=0;e<m;e++){const r=h+e;for(let n=0;n<f;n++)t[r][h+m+n]=s[e][n]}for(let e=0;e<p;e++){const n=h+m+e;for(let s=0;s<m;s++)t[n][h+s]=r[e][s]}}}return{LU:e,piv:l,swaps:c.swaps,info:u.info}},o.getrf_blocked=(e,t)=>{const r=e.length,n=e[0].length,s=Math.min(r,n),a=new Array(s);for(let e=0;e<s;e++)a[e]=e;const l={swaps:0},c={info:0};for(let u=0;u<s;u+=null!=t?t:i.BLAS.settings.blockSize){const h=Math.min(null!=t?t:i.BLAS.settings.blockSize,s-u);o.getf2(e,u,h,a,l,c),u+h<n&&o.trsm_left_upper_block(e,u,h),u+h<r&&u+h<n&&o.gemm_blocked(e,u,h)}return{LU:e,piv:a,info:c.info,swaps:l.swaps}},o.gemm_blocked=(e,t,r,s=64)=>{const i=t+r,a=t+r,o=e.length-(t+r),l=e[0].length-(t+r);if(o<=0||l<=0)return;const c=r,u=s;for(let r=0;r<o;r+=u){const s=Math.min(r+u,o);for(let o=0;o<l;o+=u){const h=Math.min(o+u,l);for(let l=r;l<s;l++){const r=e[i+l];for(let s=o;s<h;s++){let o=n.Complex.zero();for(let r=0;r<c;r++){const c=e[i+l][t+r],u=e[t+r][a+s];o=n.Complex.add(o,n.Complex.mul(c,u))}r[a+s]=n.Complex.sub(r[a+s],o)}}}}},o.getrs=(e,t,r)=>{var s;const a=e.length,o=e[0].length,l=null!==(s=r[0].length)&&void 0!==s?s:1,c=i.BLAS.copy(r);for(let e=0;e<t.length;e++){const r=t[e];if(r!==e){const t=c[e];c[e]=c[r],c[r]=t}}for(let t=0;t<l;t++)for(let r=0;r<a;r++){let s=c[r][t];for(let i=0;i<r&&i<o;i++)s=n.Complex.sub(s,n.Complex.mul(e[r][i],c[i][t]));c[r][t]=s}for(let t=0;t<l;t++)for(let r=Math.min(o,a)-1;r>=0;r--){let s=c[r][t];for(let i=r+1;i<o;i++)s=n.Complex.sub(s,n.Complex.mul(e[r][i],c[i][t]));const i=e[r][r];c[r][t]=n.Complex.rdiv(s,i)}return c},o.gesv=(e,t)=>{const r=i.BLAS.copy(e),n=i.BLAS.copy(t),{LU:s,piv:a,info:l}=o.getrf(r);return 0!==l?{X:n,info:l}:{X:o.getrs(s,a,n),info:0}},o.posv=(e,t)=>{const r=i.BLAS.copy(e),n=i.BLAS.copy(t),{LU:s,piv:a,info:l}=o.getrf(r);if(0!==l)throw new Error(`posv: matrix is singular or not positive definite (info = ${l})`);return o.getrs(s,a,n)},o.potrf=(e,t)=>{var r;const i=null!==(r=null==t?void 0:t.uplo)&&void 0!==r?r:"lower",a=e.dimension[0];if(e.dimension[0]!==e.dimension[1])throw new Error("LAPACK.potrf: A must be square");const o=s.MultiArray.copy(e);if("lower"===i){for(let e=0;e<a;e++){let t=n.Complex.realToNumber(o.array[e][e]);for(let r=0;r<e;r++){const s=o.array[e][r];t-=n.Complex.realToNumber(n.Complex.mul(s,n.Complex.conj(s)))}if(t<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");o.array[e][e]=n.Complex.create(Math.sqrt(t));for(let t=e+1;t<a;t++){let r=o.array[t][e];for(let s=0;s<e;s++)r=n.Complex.sub(r,n.Complex.mul(o.array[t][s],n.Complex.conj(o.array[e][s])));o.array[t][e]=n.Complex.rdiv(r,o.array[e][e])}}for(let e=0;e<a;e++)for(let t=e+1;t<a;t++)o.array[e][t]=n.Complex.zero()}else{for(let e=0;e<a;e++){let t=n.Complex.realToNumber(o.array[e][e]);for(let r=0;r<e;r++){const s=o.array[r][e];t-=n.Complex.realToNumber(n.Complex.mul(s,n.Complex.conj(s)))}if(t<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");o.array[e][e]=n.Complex.create(Math.sqrt(t));for(let t=e+1;t<a;t++){let r=o.array[e][t];for(let s=0;s<e;s++)r=n.Complex.sub(r,n.Complex.mul(n.Complex.conj(o.array[s][e]),o.array[s][t]));o.array[e][t]=n.Complex.rdiv(r,o.array[e][e])}}for(let e=1;e<a;e++)for(let t=0;t<e;t++)o.array[e][t]=n.Complex.zero()}return s.MultiArray.setType(o),o},o.sysv=(e,t)=>{const r=i.BLAS.copy(e),n=i.BLAS.copy(t),{LU:s,piv:a,info:l}=o.getrf(r);if(0!==l)throw new Error(`sysv: matrix is singular (info = ${l})`);return o.getrs(s,a,n)},o.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 l,c,u;if(o.is_hermitian(e.array))if(o.is_positive_definite(e.array)){const r=o.posv(e.array,t.array);l=new s.MultiArray([r.length,r[0].length]),l.array=r,c=0,u="posv"}else{const r=o.sysv(e.array,t.array);l=new s.MultiArray([r.length,r[0].length]),l.array=r,c=0,u="sysv"}else{const r=o.gesv(e.array,t.array);l=new s.MultiArray([r.X.length,r.X[0].length]),l.array=r.X,c=r.info,u="gesv"}return{X:l,info:c,solver:u}},o.larfg_original=e=>{const t=e.length;if(0===t)return{tau:n.Complex.zero(),v:[],phi:n.Complex.one(),alpha:n.Complex.zero()};const r=e[0];let s=n.Complex.zero();for(let r=1;r<t;r++){const t=n.Complex.abs(e[r]);n.Complex.mulAndSumTo(s,t,t)}const i=n.Complex.abs(r),a=n.Complex.realIsZero(i)?n.Complex.one():n.Complex.rdiv(r,i);if(1===t||n.Complex.realIsZero(n.Complex.abs(s))){const e=n.Complex.zero(),s=new Array(t);s[0]=n.Complex.one();for(let e=1;e<t;e++)s[e]=n.Complex.zero();return{tau:e,v:s,phi:a,alpha:r}}{const i=n.Complex.sqrt(n.Complex.add(n.Complex.mul(r,n.Complex.conj(r)),s)),o=n.Complex.mul(n.Complex.neg(a),i),l=n.Complex.rdiv(n.Complex.sub(o,r),o),c=n.Complex.sub(r,o),u=new Array(t);u[0]=n.Complex.one();for(let r=1;r<t;r++)u[r]=n.Complex.rdiv(e[r],c);return{tau:l,v:u,phi:a,alpha:o}}},o.sytrd=(e,t)=>{const r=e.dimension[0],s=new Array(r),i=new Array(r-1),a=new Array(r-1);for(let l=0;l<r-1;l++){const c=r-l-1,u=new Array(c);for(let t=0;t<c;t++)u[t]=n.Complex.copy(e.array[l+1+t][l]);const{alpha:h,v:d,tau:m}=o.larfg_original(u);a[l]=m,i[l]=h,e.array[l+1][l]=h;for(let t=1;t<c;t++)e.array[l+1+t][l]=d[t];n.Complex.realIsZero(n.Complex.abs(m))||t(e,d,n.Complex.conj(m),l+1,l+1),s[l]=n.Complex.copy(e.array[l][l])}return s[r-1]=n.Complex.copy(e.array[r-1][r-1]),{diag:s,offdiag:i,taus:a}},o.her2_zhtrd_update=(e,t,r,s,i)=>{if(n.Complex.realIsZero(n.Complex.abs(r)))return;const a=t.length,o=new Array(a);for(let l=0;l<a;l++){let c=n.Complex.zero();for(let r=0;r<a;r++)n.Complex.mulAndSumTo(c,e.array[s+l][i+r],t[r]);o[l]=n.Complex.mul(r,c)}let l=n.Complex.zero();for(let e=0;e<a;e++)n.Complex.mulAndSumTo(l,n.Complex.conj(t[e]),o[e]);const c=n.Complex.mul(n.Complex.minusonediv2(),n.Complex.mul(r,l));for(let e=0;e<a;e++)n.Complex.mulAndSumTo(o[e],c,t[e]);for(let r=0;r<a;r++)for(let l=r;l<a;l++){const a=n.Complex.add(n.Complex.mul(t[r],n.Complex.conj(o[l])),n.Complex.mul(o[r],n.Complex.conj(t[l]))),c=s+r,u=i+l;e.array[c][u]=n.Complex.sub(e.array[c][u],a),r!==l&&(e.array[u][c]=n.Complex.conj(e.array[c][u]))}},o.hetrd=e=>o.sytrd(e,o.her2_zhtrd_update),o.ungtr=(e,t)=>{const r=e.dimension[0],i=new s.MultiArray([r,r]);i.array=o.eye([r,r]);for(let s=r-2;s>=0;s--){const a=t[s];if(!a||n.Complex.realIsZero(n.Complex.abs(a)))continue;const o=r-s-1,l=new Array(o);l[0]=n.Complex.one();for(let t=1;t<o;t++)l[t]=n.Complex.copy(e.array[s+1+t][s]);const c=new Array(r);for(let e=0;e<r;e++){let t=n.Complex.zero();for(let r=0;r<o;r++)n.Complex.mulAndSumTo(t,n.Complex.conj(l[r]),i.array[s+1+r][e]);c[e]=t}for(let e=0;e<o;e++){const t=n.Complex.mul(a,l[e]);for(let a=0;a<r;a++)i.array[s+1+e][a]=n.Complex.sub(i.array[s+1+e][a],n.Complex.mul(t,c[a]))}}return i},o.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 s=new Array(r),a=new Array(r),l=new Array(r);if(0===r)return{diag:s,offdiag:a,taus:l};if(1===r)return s[0]=e.array[0][0],a[0]=n.Complex.zero(),l[0]=n.Complex.zero(),{diag:s,offdiag:a,taus:l};const c=Math.max(1,Math.floor(null!=t?t:i.BLAS.settings.blockSize));for(let t=0;t<r-1;t+=c){const i=Math.min(c,r-1-t),u=new Array(r-t-1),h=new Array(r-t-1);for(let e=0;e<r-t-1;e++)u[e]=new Array(i).fill(n.Complex.zero()),h[e]=new Array(i).fill(n.Complex.zero());for(let c=0;c<i;c++){const i=t+c,d=r-i-1,m=new Array(d);for(let t=0;t<d;t++)m[t]=e.array[i+1+t][i];const p=o.larfg_original(m),f=p.v,g=p.tau,y=p.alpha;l[i]=g,s[i]=e.array[i][i],a[i]=y;for(let t=0;t<d;t++)e.array[i+1+t][i]=f[t],u[t][c]=f[t];if(!n.Complex.realIsZero(n.Complex.abs(g)))for(let t=0;t<d;t++){let r=n.Complex.zero();for(let s=0;s<=t;s++)r=n.Complex.add(r,n.Complex.mul(u[s][c],n.Complex.conj(e.array[i+1+s][i+1+t])));h[t][c]=n.Complex.mul(g,r)}}for(let s=0;s<r-t-1;s++)for(let a=s;a<r-t-1;a++){let r=n.Complex.zero(),o=n.Complex.zero();for(let e=0;e<i;e++)r=n.Complex.add(r,n.Complex.mul(u[s][e],n.Complex.conj(h[a][e]))),o=n.Complex.add(o,n.Complex.mul(h[s][e],n.Complex.conj(u[a][e])));e.array[t+1+s][t+1+a]=n.Complex.sub(e.array[t+1+s][t+1+a],n.Complex.add(r,o)),s!==a&&(e.array[t+1+a][t+1+s]=n.Complex.conj(e.array[t+1+s][t+1+a]))}}return s[r-1]=e.array[r-1][r-1],a[r-1]=n.Complex.zero(),l[r-1]=n.Complex.zero(),{diag:s,offdiag:a,taus:l}},o.tridiagonal_hermitian_to_dense=(e,t)=>{const r=e.length,s=Array.from({length:r},()=>Array.from({length:r},()=>n.Complex.zero()));for(let i=0;i<r;i++)s[i][i]=n.Complex.copy(e[i]),i<r-1&&(s[i][i+1]=n.Complex.copy(t[i]),s[i+1][i]=n.Complex.conj(t[i]));return s},o.hermitian_to_real2n=e=>{const t=e.length,r=Array.from({length:2*t},e=>Array.from({length:2*t}));for(let s=0;s<t;s++)for(let i=0;i<t;i++){const a=e[s][i];r[s][i]=n.Complex.real(a),r[s][i+t]=n.Complex.neg(n.Complex.imag(a)),r[s+t][i]=n.Complex.imag(a),r[s+t][i+t]=n.Complex.real(a)}return r},o.real2n_to_complex_eigenvectors=e=>{const t=e.length/2,r=Array.from({length:t},e=>Array.from({length:t}));for(let s=0;s<t;s++)for(let i=0;i<t;i++){const a=e[i][s],o=e[i+t][s];r[i][s]=n.Complex.create(a.re,o.re)}return r},o.real2n_to_complex_eigenvalues=e=>{const t=e.length/2,r=new Array(t);for(let s=0;s<t;s++){const i=e[s].re,a=e[s+t].re;r[s]=n.Complex.create(i,a)}return r},o.jacobi_real_symmetric_dense=(e,t=1e3,r=1e-14)=>{const s=e.length;if(0===s)return{D:[],V:[]};if(1===s)return{D:[e[0][0]],V:[[n.Complex.one()]]};const i=o.eye([s,s]);for(let a=0;a<(0,n.toNumber)(t);a++){let t=n.Complex.zero();for(let a=0;a<s-1;a++)for(let o=a+1;o<s;o++){const l=e[a][o];if(t=n.Complex.max(t,n.Complex.abs(l)),n.Complex.realLessThan(n.Complex.abs(l),r))continue;const c=e[a][a],u=e[o][o],h=n.Complex.mul(n.Complex.two(),l);if(n.Complex.toBoolean(n.Complex.eq(h,n.Complex.zero())))continue;const d=n.Complex.rdiv(n.Complex.sub(u,c),h),m=n.Complex.toBoolean(n.Complex.ge(d,n.Complex.zero()))?n.Complex.one():n.Complex.minusone(),p=n.Complex.rdiv(m,n.Complex.add(n.Complex.abs(d),n.Complex.sqrt(n.Complex.add(n.Complex.one(),n.Complex.mul(d,d))))),f=n.Complex.rdiv(n.Complex.one(),n.Complex.sqrt(n.Complex.add(n.Complex.one(),n.Complex.mul(p,p)))),g=n.Complex.mul(p,f);for(let t=0;t<s;t++)if(t!==a&&t!==o){const r=e[t][a],s=e[t][o];e[t][a]=n.Complex.sub(n.Complex.mul(f,r),n.Complex.mul(g,s)),e[a][t]=e[t][a],e[t][o]=n.Complex.add(n.Complex.mul(g,r),n.Complex.mul(f,s)),e[o][t]=e[t][o]}e[a][a]=n.Complex.add(n.Complex.sub(n.Complex.mul(n.Complex.mul(f,f),c),n.Complex.mul(n.Complex.mul(n.Complex.mul(n.Complex.two(),g),f),l)),n.Complex.mul(n.Complex.mul(g,g),u)),e[o][o]=n.Complex.add(n.Complex.add(n.Complex.mul(n.Complex.mul(g,g),c),n.Complex.mul(n.Complex.mul(n.Complex.mul(n.Complex.two(),g),f),l)),n.Complex.mul(n.Complex.mul(f,f),u)),e[a][o]=n.Complex.zero(),e[o][a]=n.Complex.zero();for(let e=0;e<s;e++){const t=i[e][a],r=i[e][o];i[e][a]=n.Complex.sub(n.Complex.mul(f,t),n.Complex.mul(g,r)),i[e][o]=n.Complex.add(n.Complex.mul(g,t),n.Complex.mul(f,r))}}if(n.Complex.realLessThan(t,r))break}return{D:o.from_diag(e),V:i}},o.jacobi_symmetric_hermitian=(e,t,r)=>{const s=e.length,i=Array.from({length:s},(e,t)=>Array.from({length:s},(e,r)=>t===r?n.Complex.create(1):n.Complex.zero())),a=null!=r?r:1e-12,o=null!=t?t:Math.max(50,Math.floor(1e3/Math.max(1,s))),l=e=>{let t=0;for(let r=0;r<s;r++)for(let i=r+1;i<s;i++){const s=n.Complex.abs(e[r][i]),a=n.Complex.realToNumber(s);t+=a*a}return Math.sqrt(t)};for(let t=0;t<o;t++){let t=!1;for(let r=0;r<s-1;r++)for(let o=r+1;o<s;o++){const l=e[r][o];if(n.Complex.realToNumber(n.Complex.le(n.Complex.abs(l),n.Complex.create(a))))continue;const c=e[r][r],u=e[o][o],h=n.Complex.realToNumber(n.Complex.real(l)),d=n.Complex.realToNumber(n.Complex.real(c)),m=n.Complex.realToNumber(n.Complex.real(u)),p=.5*Math.atan2(2*h,m-d),f=Math.cos(p),g=Math.sin(p);for(let t=0;t<s;t++){if(t===r||t===o)continue;const s=e[t][r],i=e[t][o];e[t][r]=n.Complex.sub(n.Complex.mul(n.Complex.create(f),s),n.Complex.mul(n.Complex.create(g),i)),e[r][t]=n.Complex.conj(e[t][r]),e[t][o]=n.Complex.add(n.Complex.mul(n.Complex.create(g),s),n.Complex.mul(n.Complex.create(f),i)),e[o][t]=n.Complex.conj(e[t][o])}const y=n.Complex.add(n.Complex.sub(n.Complex.mul(n.Complex.create(f*f),c),n.Complex.mul(n.Complex.create(2*g*f),l)),n.Complex.mul(n.Complex.create(g*g),u)),x=n.Complex.add(n.Complex.add(n.Complex.mul(n.Complex.create(g*g),c),n.Complex.mul(n.Complex.create(2*g*f),l)),n.Complex.mul(n.Complex.create(f*f),u));e[r][r]=y,e[o][o]=x,e[r][o]=n.Complex.zero(),e[o][r]=n.Complex.zero();for(let e=0;e<s;e++){const t=i[e][r],s=i[e][o];i[e][r]=n.Complex.sub(n.Complex.mul(n.Complex.create(f),t),n.Complex.mul(n.Complex.create(g),s)),i[e][o]=n.Complex.add(n.Complex.mul(n.Complex.create(g),t),n.Complex.mul(n.Complex.create(f),s))}t=!0}if(!t)break;if(l(e)<=a)break}const c=new Array(s);for(let t=0;t<s;t++)c[t]=e[t][t];return{D:c,V:i}},o.column_pivot=(e,t,r=0,s=e.length)=>{const i=e.slice(r,s).map(e=>n.Complex.abs(e[t])),a=i.reduce((e,t,r,s)=>n.Complex.toBoolean(n.Complex.gt(t,s[e]))?r:e,0);return{pivotRow:a,pivotAbs:i[a],pivotIsZero:n.Complex.realIsZero(i[a])}},o.normalize_eigenvector_phases=(e,t=!0)=>{const r=e.length,s=e[0].length;for(let i=0;i<s;i++){const{pivotRow:s,pivotAbs:a,pivotIsZero:l}=o.column_pivot(e,i);if(l)continue;const c=e[s][i];let u=n.Complex.rdiv(n.Complex.conj(c),a);t&&n.Complex.realLessThan(n.Complex.mul(c,u),0)&&(u=n.Complex.neg(u));for(let t=0;t<r;t++)e[t][i]=n.Complex.mul(e[t][i],u)}},o.steqr_vectors=(e,t,r=1e3*e.length)=>{const s=e.length,i=e.map(e=>n.Complex.copy(e)),a=t.map(e=>n.Complex.copy(e));a[s-1]=n.Complex.zero();let l=!1;for(let e=0;e<s;e++)if(n.Complex.isComplexValue(i[e])||e<s-1&&n.Complex.isComplexValue(a[e])){l=!0;break}const c=new Array(s);let u=i.slice(),h=new Array(s);if(l){c[0]=n.Complex.one();for(let e=0;e<s-1;e++){const t=a[e],r=n.Complex.abs(t);if(n.Complex.realIsZero(r))c[e+1]=n.Complex.copy(c[e]);else{const s=n.Complex.rdiv(n.Complex.conj(t),r);c[e+1]=n.Complex.mul(c[e],s)}}for(let e=0;e<s-1;e++){const t=n.Complex.mul(n.Complex.conj(c[e]),n.Complex.mul(a[e],c[e+1]));h[e]=n.Complex.abs(t)}}else for(let e=0;e<s-1;e++)h[e]=n.Complex.copy(a[e]);h[s-1]=n.Complex.zero();const d=o.tridiagonal_hermitian_to_dense(u,h),m=o.jacobi_real_symmetric_dense(d,r);let p=m.D.map(e=>n.Complex.copy(e)),f=m.V.map(e=>e.map(e=>n.Complex.copy(e)));if(l)for(let e=0;e<s;e++)for(let t=0;t<s;t++)f[e][t]=n.Complex.mul(c[e],f[e][t]);const g=p.map((e,t)=>({v:e,i:t})).sort((e,t)=>n.Complex.realToNumber(e.v)-n.Complex.realToNumber(t.v)),y=Array.from({length:s},()=>Array(s)),x=g.map(e=>e.v);for(let e=0;e<s;e++){const t=g[e].i;for(let r=0;r<s;r++)y[r][e]=n.Complex.copy(f[r][t])}return o.normalize_eigenvector_phases(y),{D:x,V:y,complex:l}},o.steqr_vectors_tridiagonal=(e,t,r=1e3)=>{const s=e.length;if(0===s)return{D:[],V:[]};if(1===s)return{D:[n.Complex.copy(e[0])],V:[[n.Complex.one()]]};const i=e.map(e=>n.Complex.copy(e)),a=t.map(e=>n.Complex.copy(e)),o=Array.from({length:s},(e,t)=>Array.from({length:s},(e,r)=>t===r?n.Complex.one():n.Complex.zero())),l=Number.EPSILON||2220446049250313e-31;let c=0;for(;c<r;){let e=0;for(;e<s-1&&n.Complex.realLessThanOrEqualTo(n.Complex.abs(a[e]),l);)e++;if(e>=s-1)break;let t=e;for(;t<s-2&&n.Complex.realGreaterThan(n.Complex.abs(a[t]),l);)t++;const r=i[t],u=i[t+1],h=a[t],d=n.Complex.mul(n.Complex.sub(r,u),n.Complex.create(.5)),m=n.Complex.abs(d),p=n.Complex.power(n.Complex.abs(h),n.Complex.two()),f=n.Complex.add(m,n.Complex.sqrt(n.Complex.add(n.Complex.mul(m,m),p))),g=n.Complex.realGreaterThanOrEqualTo(d,0)?n.Complex.one():n.Complex.minusone(),y=n.Complex.sub(u,n.Complex.rdiv(n.Complex.mul(g,p),f));let x=n.Complex.sub(i[e],y),C=a[e];for(let r=e;r<=t;r++){const e=n.Complex.sqrt(n.Complex.add(n.Complex.power(n.Complex.abs(x),n.Complex.two()),n.Complex.power(n.Complex.abs(C),n.Complex.two())));if(n.Complex.realEquals(e,0))continue;const l=n.Complex.rdiv(x,e),c=n.Complex.rdiv(C,e),u=i[r],h=i[r+1];i[r]=n.Complex.add(n.Complex.mul(n.Complex.conj(l),n.Complex.mul(l,u)),n.Complex.mul(n.Complex.conj(c),n.Complex.mul(c,h))),i[r+1]=n.Complex.add(n.Complex.mul(n.Complex.conj(c),n.Complex.mul(c,u)),n.Complex.mul(n.Complex.conj(l),n.Complex.mul(l,h))),a[r]=n.Complex.zero(),r<t&&(x=a[r],C=a[r+1]);for(let e=0;e<s;e++){const t=o[e][r],s=o[e][r+1];o[e][r]=n.Complex.sub(n.Complex.mul(l,t),n.Complex.mul(c,s)),o[e][r+1]=n.Complex.add(n.Complex.mul(n.Complex.conj(c),t),n.Complex.mul(l,s))}}c++}return{D:i,V:o}},o.steqr_values=(e,t,r)=>o.steqr_vectors(e,t,r).D,o.orgtr=(e,t)=>{const r=e.dimension[0];if(r!==e.dimension[1])throw new Error("orgtr: A must be square");const i=new s.MultiArray([r,r]);i.array=o.eye(r,r);for(let s=r-2;s>=0;s--){const a=r-s-1,l=new Array(a);for(let t=0;t<a;t++)l[t]=e.array[s+1+t][s];const c=t[s];n.Complex.realIsZero(n.Complex.abs(c))||o.larf_left(i,l,c,s+1,0)}return s.MultiArray.setType(i),i},o.orgtr_blocked=(e,t,r)=>{const a=e.dimension[0];if(a!==e.dimension[1])throw new Error("orgtr_blocked: A must be square");const l=new s.MultiArray([a,a]);l.array=o.eye(a,a);const c=Math.max(1,Math.floor(null!=r?r:i.BLAS.settings.blockSize));for(let r=a-2-(a-2)%c;r>=0;r-=c){for(let s=Math.min(c,a-1-r)-1;s>=0;s--){const i=r+s,u=a-i-1;if(u<=0)continue;const h=new Array(u);for(let t=0;t<u;t++)h[t]=e.array[i+1+t][i];const d=t[i];n.Complex.realIsZero(n.Complex.abs(d))||o.larf_left_block(l,h,d,i+1,0,c)}if(0===r)break}return s.MultiArray.setType(l),l},o.orgtr_blocked_w=(e,t,r)=>{var a,l,c,u;const h=e.dimension[0];if(h!==e.dimension[1])throw new Error("orgtr_blocked_w: A must be square");const d=new s.MultiArray([h,h]);d.array=o.eye(h,h);const m=Math.max(1,Math.floor(null!=r?r:i.BLAS.settings.blockSize));for(let r=h-2;r>=0;r-=m){const s=Math.min(m,r+1),i=new Array(h-r-1),o=new Array(h-r-1);for(let e=0;e<h-r-1;e++)i[e]=new Array(s).fill(n.Complex.zero()),o[e]=new Array(s).fill(n.Complex.zero());for(let t=0;t<s;t++){const n=r-s+1+t,a=h-n-1;for(let r=0;r<a;r++)i[r][t]=e.array[n+1+r][n]}for(let e=0;e<s;e++){const a=r-s+1+e,l=t[a],c=h-a-1;if(!n.Complex.realIsZero(n.Complex.abs(l)))for(let t=0;t<c;t++){let r=n.Complex.zero();for(let s=0;s<=t;s++)r=n.Complex.add(r,n.Complex.mul(i[s][e],n.Complex.conj(d.array[a+1+s][a+1+t])));o[t][e]=n.Complex.mul(l,r)}}for(let e=0;e<h-r-1;e++)for(let t=0;t<h;t++){let h=n.Complex.zero(),m=n.Complex.zero();for(let d=0;d<s;d++)h=n.Complex.add(h,n.Complex.mul(i[e][d],n.Complex.conj(null!==(l=null===(a=o[t-r-1+e])||void 0===a?void 0:a[d])&&void 0!==l?l:n.Complex.zero()))),m=n.Complex.add(m,n.Complex.mul(o[e][d],n.Complex.conj(null!==(u=null===(c=i[t-r-1+e])||void 0===c?void 0:c[d])&&void 0!==u?u:n.Complex.zero())));d.array[r+1+e][t]=n.Complex.sub(d.array[r+1+e][t],n.Complex.add(h,m))}}return d},o.eig_symmetric=(e,t=!1)=>{e.dimension[0];const r=s.MultiArray.copy(e),{diag:n,offdiag:i,taus:a}=o.hetrd(r);if(t){let e=o.ungtr(r,a);const{D:t,V:l}=o.steqr_vectors(n,i),c=new s.MultiArray([l.length,l[0].length]);return c.array=l,e=o.mtimes(e,c),{D:s.MultiArray.toDiagonalMatrix(t),V:e}}return{D:s.MultiArray.toColumnVector(o.steqr_vectors(n,i).D)}},o.eig_hermitian=(e,t=!1)=>{const r=e.dimension[0],i=s.MultiArray.copy(e);let a=!1;for(let e=0;e<r&&!a;e++)for(let t=0;t<r;t++){const r=i.array[e][t];if(!n.Complex.imagIsZero(r)){a=!0;break}}if(a){const{diag:e,offdiag:n,taus:a}=o.hetrd(i);if(!t){const{D:t}=o.steqr_vectors(e,n);return{D:s.MultiArray.toColumnVector(t)}}let l=o.ungtr(i,a);console.log("Q =",l);const{D:c,V:u}=o.steqr_vectors(e,n),h=new s.MultiArray([r,r]);return h.array=u,l=o.mtimes(l,h),{D:s.MultiArray.toDiagonalMatrix(c),V:l}}{const{diag:e,offdiag:n,taus:a}=o.hetrd(i);if(!t){const{D:t}=o.steqr_vectors(e,n);return{D:s.MultiArray.toColumnVector(t)}}let l=o.ungtr(i,a);const{D:c,V:u}=o.steqr_vectors(e,n),h=new s.MultiArray([r,r]);return h.array=u,l=o.mtimes(l,h),{D:s.MultiArray.toDiagonalMatrix(c),V:l}}},o.functions={is_hermitian:o.is_hermitian,is_positive_definite:o.is_positive_definite,laswp:o.laswp,laswp_rows:o.laswp_rows,laswp_cols:o.laswp_cols,eye:o.eye,fillFactory:o.fillFactory,zeros:o.zeros,ones:o.ones,diag:o.diag,from_diag:o.from_diag,lassq:o.lassq,lange:o.lange,triu_inplace:o.triu_inplace,tril_inplace:o.tril_inplace,trsm_left_upper_block:o.trsm_left_upper_block,lapmt_matrix:o.lapmt_matrix,lapmt_apply:o.lapmt_apply,dotc_col:o.dotc_col,dotc_row:o.dotc_row,larfg:o.larfg,larf:o.larf,geqr2:o.geqr2,geqp2:o.geqp2,geqp3:o.geqp3,gelq2:o.gelq2,orgqr:o.orgqr,orglq:o.orglq,getf2:o.getf2,getrf:o.getrf,getrf_blocked:o.getrf_blocked,gemm_blocked:o.gemm_blocked,getrs:o.getrs,gesv:o.gesv,posv:o.posv,potrf:o.potrf,sysv:o.sysv,mldivide:o.mldivide,sytrd:o.sytrd,her2_zhtrd_update:o.her2_zhtrd_update,hetrd:o.hetrd,ungtr:o.ungtr,sytrd_blocked_w:o.sytrd_blocked_w,tridiagonal_hermitian_to_dense:o.tridiagonal_hermitian_to_dense,hermitian_to_real2n:o.hermitian_to_real2n,real2n_to_complex_eigenvectors:o.real2n_to_complex_eigenvectors,real2n_to_complex_eigenvalues:o.real2n_to_complex_eigenvalues,jacobi_real_symmetric_dense:o.jacobi_real_symmetric_dense,jacobi_symmetric_hermitian:o.jacobi_symmetric_hermitian,column_pivot:o.column_pivot,normalize_eigenvector_phases:o.normalize_eigenvector_phases,steqr_vectors:o.steqr_vectors,steqr_vectors_tridiagonal:o.steqr_vectors_tridiagonal,steqr_values:o.steqr_values,orgtr:o.orgtr,orgtr_blocked:o.orgtr_blocked,orgtr_blocked_w:o.orgtr_blocked_w,eig_symmetric:o.eig_symmetric,eig_hermitian:o.eig_hermitian}},7645(e,t,r){"use strict";t.LexerErrorListener=void 0;const n=r(3222),s=r(2697);class i extends n.ErrorListener{constructor(e=""){super(),this.source=e}syntaxError(e,t,r,n,i,a){if(!s.SyntaxDiagnostic.isBenignEndOfInput(i))throw s.SyntaxDiagnostic.error(i,r,n,this.source)}}t.LexerErrorListener=i},4610(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LinearAlgebra=t.LinearAlgebraConfigKeyTable=void 0;const n=r(845),s=r(5956),i=r(7679),a=r(6115),o=r(227),l=r(6109);t.LinearAlgebraConfigKeyTable=["wasteLU","qrPhaseEpsilon"];const c=new Set(t.LinearAlgebraConfigKeyTable);class u{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 i.MultiArray([e.dimension[0],t.dimension[1]]);return a.BLAS.gemm(n.Complex.one(),e.array,e.dimension[0],e.dimension[1],t.array,t.dimension[1],n.Complex.zero(),r.array),i.MultiArray.setType(r),r}}static test(e){return l.AST.nodeBoundedReturnList(3,(e,t)=>{if(1===e.length){if(0===t)return n.Complex.zero()}else if(2===e.length){if(0===t)return n.Complex.zero();if(1===t)return n.Complex.one()}else if(3===e.length){if(0===t)return n.Complex.zero();if(1===t)return n.Complex.one();if(2===t)return n.Complex.two()}},e=>({length:e}))}}t.LinearAlgebra=u,u.defaultSettings=Object.assign({},{wasteLU:1e-15,qrPhaseEpsilon:1e-300}),u.settings=u.defaultSettings,u.set=e=>{Object.entries(e).forEach(e=>{if(!c.has(e[0]))throw new Error(`LinearAlgebra.set: invalid configuration parameter: ${e[0]}`);u.settings[e[0]]=e[1]})},u.eyeSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector","oneOrTwoElement"]}]}]},{arity:2,parameters:[{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}},u.eye=(...e)=>{let t=0,r=0;if(0===e.length)return n.Complex.one();if(1===e.length)if(i.MultiArray.isInstanceOf(e[0])){const n=i.MultiArray.linearize(e[0]);if(0===n.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");if(1===n.length)t=i.MultiArray.testIndex(n[0]),r=t;else{if(2!==n.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");t=i.MultiArray.testIndex(n[0]),r=i.MultiArray.testIndex(n[1])}}else t=i.MultiArray.testIndex(e[0]),r=t;else 2===e.length&&n.Complex.isInstanceOf(e[0])&&n.Complex.isInstanceOf(e[1])?(t=i.MultiArray.testIndex(e[0]),r=i.MultiArray.testIndex(e[1])):l.AST.throwInvalidCallError("eye");const s=new i.MultiArray([t,r],n.Complex.zero());for(let e=0;e<Math.min(s.dimension[0],s.dimension[1]);e++)s.array[e][e]=n.Complex.one();return s},u.diagSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"offset",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},{arity:3,parameters:[{name:"value",classes:["double"],validators:["vector"]},{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}},u.diag=(...e)=>{let t;if(e.length>0&&e.length<=3)if(i.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 i.MultiArray([r,r]),t.array=o.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 i.MultiArray([r,r]),t.array=o.LAPACK.diag(e[0].array.map(e=>e[0]))}else t=i.MultiArray.toColumnVector(o.LAPACK.from_diag(e[0].array));else if(2===e.length){const r=Math.floor(n.Complex.realToNumber(i.MultiArray.firstElement(e[1])));if(1===e[0].dimension[0]&&e[0].dimension[1]>1){const n=e[0].dimension[1];t=new i.MultiArray([n,n]),t.array=o.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 i.MultiArray([n,n]),t.array=o.LAPACK.diag(e[0].array.map(e=>e[0]),r)}else t=i.MultiArray.toColumnVector(o.LAPACK.from_diag(e[0].array,r))}else{const r=Math.floor(n.Complex.realToNumber(i.MultiArray.firstElement(e[1]))),s=Math.floor(n.Complex.realToNumber(i.MultiArray.firstElement(e[2])));if(t=new i.MultiArray([r,s]),t.array=o.LAPACK.diag(e[0].array[0],0,[r,s]),1===e[0].dimension[0]&&e[0].dimension[1]>1)t.array=o.LAPACK.diag(e[0].array[0],0,r,s);else{if(!(1===e[0].dimension[1]&&e[0].dimension[0]>1))throw new Error("diag: V must be a vector");t.array=o.LAPACK.diag(e[0].array.map(e=>e[0]),0,r,s)}}}else t=new i.MultiArray([1,1],e[0].copy());else l.AST.throwInvalidCallError("diag");return t},u.traceSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}},u.trace=e=>{if(2===e.dimension.length)return e.array.map((e,t)=>e[t]?e[t]:n.Complex.zero()).reduce((e,t)=>n.Complex.add(e,t),n.Complex.zero());throw new Error("trace: only valid on 2-D objects")},u.applyTranspose=(e,t=e=>e)=>{if(2===e.dimension.length){const r=new i.MultiArray([e.dimension[1],e.dimension[0]],void 0,e.isCell);for(let n=0;n<e.dimension[1];n++){r.array[n]=new Array(e.dimension[0]);for(let s=0;s<e.dimension[0];s++)r.array[n][s]=t(e.array[s][n]).copy()}return r.type=e.type,r.isCell=e.isCell,r}throw new Error("transpose not defined for N-D objects")},u.transposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},u.transpose=e=>{const t=s.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):e;return n.Complex.isInstanceOf(t)?n.Complex.copy(t):u.applyTranspose(t)},u.ctransposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}},u.ctranspose=e=>{const t=s.CharString.isInstanceOf(e)?i.MultiArray.characterVectorFromCharString(e):e;return n.Complex.isInstanceOf(t)?n.Complex.conj(t):u.applyTranspose(t,e=>t.isCell||!n.Complex.isInstanceOf(e)?e:n.Complex.conj(e))},u.mulSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}},u.powerSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"exponent",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},outputs:{arity:1}},u.multiplyMatrices=(e,t)=>{const r=new i.MultiArray([e.dimension[0],t.dimension[1]]);return a.BLAS.gemm(n.Complex.one(),e.array,e.dimension[0],e.dimension[1],t.array,t.dimension[1],n.Complex.zero(),r.array),i.MultiArray.setType(r),r},u.formatDimensions=e=>e.dimension.join("x"),u.hermitianEigenExpansion=(e,t)=>{if(!o.LAPACK.is_hermitian(e.array))throw new Error("invalid exponent in '^'.");const r=o.LAPACK.jacobi_symmetric_hermitian(a.BLAS.copy(e.array),1e3,1e-14),n=new i.MultiArray([e.dimension[0],e.dimension[1]]);n.array=r.V;const s=i.MultiArray.toDiagonalMatrix(r.D.map(t)),l=u.multiplyMatrices(n,s);return u.multiplyMatrices(l,u.ctranspose(n))},u.power=(e,t)=>{if(2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new EvalError("operator ^: only square matrices can be raised to scalar powers.");if(n.Complex.realIsInteger(t)&&n.Complex.imagEquals(t,0)){let r=Math.abs(n.Complex.realToNumber(t)),s=u.eye(n.Complex.create(e.dimension[0],0)),a=n.Complex.realGreaterThan(t,0)||n.Complex.realEquals(t,0)?i.MultiArray.copy(e):u.inv(e);for(;r>0;)r%2==1&&(s=u.multiplyMatrices(s,a)),r=Math.floor(r/2),r>0&&(a=u.multiplyMatrices(a,a));return s}return u.hermitianEigenExpansion(e,e=>n.Complex.power(e,t))},u.scalarPower=(e,t)=>{if(2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new EvalError("operator ^: matrix exponent must be square when base is scalar.");return u.hermitianEigenExpansion(t,t=>n.Complex.power(e,t))},u.detSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}},u.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 n.Complex.create(1,0);if(1===t)return e.array[0][0];if(2===t)return n.Complex.sub(n.Complex.mul(e.array[0][0],e.array[1][1]),n.Complex.mul(e.array[0][1],e.array[1][0]));const{U:r,swaps:s}=u.luDecomposition(e);let i=n.Complex.one();for(let e=0;e<t;e++){const t=r.array[e][e];if(n.Complex.realIsZero(n.Complex.abs(t)))return n.Complex.zero();i=n.Complex.mul(i,t)}return s%2==1&&(i=n.Complex.neg(i)),i},u.luDecomposition=e=>{const t=i.MultiArray.copy(e),{LU:r,piv:s,swaps:a}=o.LAPACK.getrf_blocked(t.array),l=t.dimension[0],c=t.dimension[1],h=Math.min(l,c),d=u.eye(n.Complex.create(l));for(let e=0;e<h;e++)s[e]!==e&&o.LAPACK.laswp_rows(d.array,d.dimension,e,s[e]);const m=new i.MultiArray([l,l]),p=new i.MultiArray([l,c]);for(let e=0;e<l;e++)for(let r=0;r<c;r++)e>r?(m.array[e][r]=t.array[e][r],p.array[e][r]=n.Complex.zero()):e===r?(m.array[e][r]=n.Complex.one(),p.array[e][r]=t.array[e][r]):(m.array[e][r]=n.Complex.zero(),p.array[e][r]=t.array[e][r]);return{L:m,U:p,P:d,swaps:a}},u.luSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}},u.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 l.AST.nodeBoundedReturnList(3,(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:s}=u.luDecomposition(e);return{length:t,L:r,U:n,P:s}})},u.invSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}},u.inv=e=>{if(!e||2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new Error("inv: matrix must be square.");const t=i.MultiArray.copy(e),{LU:r,piv:s,info:a,swaps:l}=o.LAPACK.getrf_blocked(t.array);if(0!==a){const t=e.dimension[0],r=new i.MultiArray([t,t]);for(let e=0;e<t;e++)for(let s=0;s<t;s++)r.array[e][s]=n.Complex.inf_0();return i.MultiArray.setType(r),r}{const t=e.dimension[0],n=o.LAPACK.eye([t,t]),a=o.LAPACK.getrs(r,s,n),l=new i.MultiArray([a.length,a[0].length]);return l.array=a,i.MultiArray.setType(l),l}},u.condSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"normType",alternatives:[{name:"numericNormType",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusNormType",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}},u.cond=(e,t=n.Complex.create(2))=>{if(e&&2===e.dimension.length||l.AST.throwInvalidCallError("cond"),0===e.dimension[0]||0===e.dimension[1])return n.Complex.zero();if(s.CharString.isInstanceOf(t))return"fro"!==t.str&&l.AST.throwInvalidCallError("cond"),u.squareMatrixNormCondition(e,"fro");const r=n.Complex.realToNumber(i.MultiArray.firstElement(t));if(2===r){const t=u.singularValuesSquared(e);if(0===t.length)return n.Complex.zero();const r=t[t.length-1],s=t[0];return s<=Math.max(1e-14*r,0)?n.Complex.inf_0():n.Complex.create(Math.sqrt(r/s))}if(1===r||r===1/0)return u.squareMatrixNormCondition(e,r);throw l.AST.throwInvalidCallError("cond"),new EvalError("Invalid call to cond.")},u.rankSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"tolerance",classes:["double"],validators:["numeric","scalar","real","finite","nonnegative"]}]}],outputs:{arity:1}},u.rank=(e,t)=>{e&&2===e.dimension.length||l.AST.throwInvalidCallError("rank");const r=u.singularValues(e);if(0===r.length)return n.Complex.zero();const s=void 0===t?Math.max(e.dimension[0],e.dimension[1])*Number.EPSILON*r[r.length-1]:n.Complex.realToNumber(t);return(!Number.isFinite(s)||s<0||void 0!==t&&!n.Complex.imagIsZero(t))&&l.AST.throwInvalidCallError("rank"),n.Complex.create(u.rankByElimination(e,s))},u.squareMatrixNormCondition=(e,t)=>(e.dimension[0]!==e.dimension[1]&&l.AST.throwInvalidCallError("cond"),n.Complex.mul(u.matrixNorm(e,t),u.matrixNorm(u.inv(e),t))),u.matrixNorm=(e,t)=>{if(1===t){let t=0;for(let r=0;r<e.dimension[1];r++){let s=0;for(let t=0;t<e.dimension[0];t++)s+=n.Complex.realToNumber(n.Complex.abs(e.array[t][r]));t=Math.max(t,s)}return n.Complex.create(t)}if(t===1/0){let t=0;for(let r=0;r<e.dimension[0];r++){let s=0;for(let t=0;t<e.dimension[1];t++)s+=n.Complex.realToNumber(n.Complex.abs(e.array[r][t]));t=Math.max(t,s)}return n.Complex.create(t)}let r=n.Complex.zero();for(const t of i.MultiArray.linearize(e)){const e=n.Complex.abs(t);r=n.Complex.add(r,n.Complex.mul(e,e))}return n.Complex.sqrt(r)},u.singularValuesSquared=e=>{const t=e.dimension[0],r=e.dimension[1],s=Math.min(t,r);if(0===s)return[];const i=Array.from({length:s},()=>Array.from({length:s},()=>n.Complex.zero()));if(t>=r)for(let s=0;s<r;s++)for(let a=s;a<r;a++){let r=n.Complex.zero();for(let i=0;i<t;i++)r=n.Complex.add(r,n.Complex.mul(n.Complex.conj(e.array[i][s]),e.array[i][a]));i[s][a]=r,i[a][s]=s===a?r:n.Complex.conj(r)}else for(let s=0;s<t;s++)for(let a=s;a<t;a++){let t=n.Complex.zero();for(let i=0;i<r;i++)t=n.Complex.add(t,n.Complex.mul(e.array[s][i],n.Complex.conj(e.array[a][i])));i[s][a]=t,i[a][s]=s===a?t:n.Complex.conj(t)}const{D:a}=o.LAPACK.jacobi_symmetric_hermitian(i,1e3,1e-14);return a.map(e=>Math.max(0,n.Complex.realToNumber(e))).sort((e,t)=>e-t)},u.singularValues=e=>u.singularValuesSquared(e).map(e=>Math.sqrt(e)),u.rankByElimination=(e,t)=>{const r=e.array.map(e=>e.map(e=>n.Complex.create(n.Complex.realToNumber(e),n.Complex.imagToNumber(e)))),s=e.dimension[0],i=e.dimension[1];let a=0;for(let e=0;e<i&&a<s;e++){let o=a,l=n.Complex.realToNumber(n.Complex.abs(r[o][e]));for(let t=a+1;t<s;t++){const s=n.Complex.realToNumber(n.Complex.abs(r[t][e]));s>l&&(l=s,o=t)}if(l<=t)continue;if(o!==a){const e=r[a];r[a]=r[o],r[o]=e}const c=r[a][e];for(let t=a+1;t<s;t++){const s=n.Complex.rdiv(r[t][e],c);if(!n.Complex.realIsZero(n.Complex.abs(s)))for(let o=e;o<i;o++)r[t][o]=n.Complex.sub(r[t][o],n.Complex.mul(s,r[a][o]))}a++}return a},u.mldivide=(e,t)=>{if(2!==e.dimension.length||2!==t.dimension.length||e.dimension[0]!==e.dimension[1]||e.dimension[0]!==t.dimension[0])throw new EvalError(`operator \\: nonconformant arguments (op1 is ${u.formatDimensions(e)}, op2 is ${u.formatDimensions(t)}).`);return o.LAPACK.mldivide(e,t).X},u.mrdivide=(e,t)=>{if(2!==e.dimension.length||2!==t.dimension.length||t.dimension[0]!==t.dimension[1]||e.dimension[1]!==t.dimension[1])throw new EvalError(`operator /: nonconformant arguments (op1 is ${u.formatDimensions(e)}, op2 is ${u.formatDimensions(t)}).`);return u.ctranspose(u.mldivide(u.ctranspose(t),u.ctranspose(e)))},u.gaussSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"rightHandSide",classes:["double"]}]},outputs:{arity:1}},u.gauss=(e,t)=>{if(e.dimension.length>2||e.dimension[0]!==e.dimension[1])throw new Error("invalid dimensions in function gauss.");const r=i.MultiArray.copy(e);let s,a,o;for(Math.min(t.dimension[0],t.dimension[1])===t.dimension[1]&&(t=u.transpose(t)),s=0;s<r.dimension[0];s++)r.array[s].push(t.array[0][s]);const l=r.dimension[0];for(s=0;s<l;s++){let e=n.Complex.abs(r.array[s][s]),t=s;for(a=s+1;a<l;a++)n.Complex.realGreaterThan(n.Complex.abs(r.array[a][s]),e.re)&&(e=n.Complex.abs(r.array[a][s]),t=a);for(a=s;a<l+1;a++){const e=r.array[t][a];r.array[t][a]=r.array[s][a],r.array[s][a]=e}for(a=s+1;a<l;a++){const e=n.Complex.rdiv(n.Complex.neg(r.array[a][s]),r.array[s][s]);for(o=s;o<l+1;o++)r.array[a][o]=s===o?n.Complex.zero():n.Complex.add(r.array[a][o],n.Complex.mul(e,r.array[s][o]))}}const c=new i.MultiArray([1,l],n.Complex.zero());for(s=l-1;s>-1;s--)for(c.array[0][s]=n.Complex.rdiv(r.array[s][l],r.array[s][s]),a=s-1;a>-1;a--)r.array[a][l]=n.Complex.sub(r.array[a][l],n.Complex.mul(r.array[a][s],c.array[0][s]));return i.MultiArray.setType(c),c},u.dotSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},u.dot=(e,t,r)=>{var s;if(!i.MultiArray.arrayEquals(e.dimension,t.dimension))throw new Error("dot: A and B must have the same size.");let a;if(a=void 0!==r?i.MultiArray.testIndex(r,"dot")-1:i.MultiArray.firstNonSingleDimension(e),a<0||a>=e.dimension.length)throw new Error("dot: dimension argument out of range.");const o=e.dimension,l=o.length,c=o.reduce((e,t)=>e*t,1),u=new Array(l);u[0]=1;for(let e=1;e<l;e++)u[e]=u[e-1]*o[e-1];const h=[...o];h[a]=1;const d=h.reduce((e,t)=>e*t,1),m=new Array(l);m[0]=1;for(let e=1;e<l;e++)m[e]=m[e-1]*h[e-1];const p=new i.MultiArray(h),f=h.slice(2).reduce((e,t)=>e*t,1),g=h[0]*Math.max(1,f),y=null!==(s=h[1])&&void 0!==s?s:1;p.array=new Array(g);for(let e=0;e<g;e++)p.array[e]=new Array(y);const x=o[0]*o[1],C=h[0]*h[1];for(let r=0;r<c;r++){let s=0;for(let e=0;e<l;e++){const t=Math.floor(r/u[e])%o[e];e!==a&&(s+=t*m[e])}const i=Math.floor(r/x),c=r-i*x,d=i*o[0]+c%o[0],f=Math.floor(c/o[0]);if(!e.array[d]||void 0===e.array[d][f])throw new Error(`dot_fast: invalid access to A at physical [${d},${f}] (linIdx=${r}).`);if(!t.array[d]||void 0===t.array[d][f])throw new Error(`dot_fast: invalid access to B at physical [${d},${f}] (linIdx=${r}).`);const g=e.array[d][f],y=t.array[d][f],E=n.Complex.mul(n.Complex.conj(g),y),v=Math.floor(s/C),A=s-v*C,S=v*h[0]+A%h[0],_=Math.floor(A/h[0]);void 0===p.array[S][_]||null===p.array[S][_]?p.array[S][_]=n.Complex.copy(E):p.array[S][_]=n.Complex.add(p.array[S][_],E)}return i.MultiArray.setType(p),1===d?p.array[0][0]:p},u.crossSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}},u.dimensionArgumentToNumber=e=>{if("number"==typeof e)return e;if(i.MultiArray.isInstanceOf(e)){const t=i.MultiArray.linearize(e);return t.length>0?u.dimensionArgumentToNumber(t[0]):void 0}return n.Complex.isInstanceOf(e)?n.Complex.realToNumber(e):void 0},u.cross=(e,t,r)=>{var s,a,o;const l=e.dimension.slice(),c=t.dimension.slice();let h;if(void 0!==r){const e=u.dimensionArgumentToNumber(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)}.`);h=t-1}const d=Math.max(l.length,c.length,void 0!==h?h+1:0),m=l.slice(),p=c.slice();for(;m.length<d;)m.push(1);for(;p.length<d;)p.push(1);if(void 0===h&&(h=m.findIndex(e=>3===e),-1===h))throw new EvalError("cross: no dimension of length 3 found and dim not specified.");for(let e=0;e<d;e++)if(e!==h&&m[e]!==p[e])throw new EvalError("cross: A and B must have the same size, except along the operation dimension.");const f=null!==(s=m[h])&&void 0!==s?s:1,g=null!==(a=p[h])&&void 0!==a?a:1;if(3!==f||3!==g)throw new EvalError(`cross: inputs must have length 3 along the operation dimension (got ${f} and ${g}).`);const y=i.MultiArray.linearize(e),x=i.MultiArray.linearize(t),C=y.length,E=new Array(C),v=m.slice(0,h).reduce((e,t)=>e*t,1),A=m[h],S=v*A,_=Math.floor(C/S);if(3!==A)throw new EvalError(`cross: internal error, block length along dim ${h+1} must be 3.`);for(let e=0;e<_;e++){const t=e*S;for(let e=0;e<v;e++){const r=t+0*v+e,s=t+1*v+e,i=t+2*v+e;E[r]=n.Complex.sub(n.Complex.mul(y[s],x[i]),n.Complex.mul(y[i],x[s])),E[s]=n.Complex.sub(n.Complex.mul(y[i],x[r]),n.Complex.mul(y[r],x[i])),E[i]=n.Complex.sub(n.Complex.mul(y[r],x[s]),n.Complex.mul(y[s],x[r]))}}const b=new i.MultiArray(l);1===b.dimension.length&&b.dimension.push(1);for(let e=0;e<y.length;e++){const[t,r]=i.MultiArray.linearIndexToMultiArrayRowColumn(b.dimension[0],b.dimension[1],e);b.array[t][r]=null!==(o=E[e])&&void 0!==o?o:n.Complex.zero()}return i.MultiArray.setType(b),b},u.kronSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}},u.kron=(e,t)=>{const r=i.MultiArray.scalarToMultiArray(e),s=i.MultiArray.scalarToMultiArray(t);if(!r||r.dimension.length<2||!s||s.dimension.length<2)throw new Error("kron: inputs must be at least 2-D arrays");const a=r.dimension[0],o=r.dimension[1],l=s.dimension[0],c=s.dimension[1],u=[a*l,o*c],h=new i.MultiArray(u);for(let e=0;e<a;e++)for(let t=0;t<o;t++){const i=r.array[e][t];for(let r=0;r<l;r++)for(let a=0;a<c;a++){const o=s.array[r][a],u=n.Complex.mul(i,o);h.array[e*l+r][t*c+a]=u}}return i.MultiArray.setType(h),h},u.qrPhaseNormalize=(e,t,r)=>{const s=Math.min(t.dimension[0],t.dimension[1]);for(let i=0;i<s;i++){if(n.Complex.realIsZero(n.Complex.abs(t.array[i][i])))continue;const s=n.Complex.neg(e[i]);for(let e=i;e<t.dimension[1];e++)t.array[i][e]=n.Complex.rdiv(t.array[i][e],s);if(void 0!==r)for(let e=0;e<r.dimension[0];e++)r.array[e][i]=n.Complex.mul(r.array[e][i],s)}if(n.Complex.imagGreaterThan(n.Complex.abs(t.array[0][0]),u.settings.qrPhaseEpsilon))throw new Error("Phase normalization error: R(1,1) should be real.");if(n.Complex.realGreaterThan(t.array[0][0],0)){for(let e=0;e<t.dimension[1];e++)t.array[0][e]=n.Complex.neg(t.array[0][e]);if(void 0!==r)for(let e=0;e<r.dimension[0];e++)r.array[e][0]=n.Complex.neg(r.array[e][0])}},u.lqPhaseNormalize=(e,t,r)=>{const s=Math.min(t.dimension[0],t.dimension[1]);for(let i=0;i<s;i++){const s=e[i];if(!n.Complex.realIsZero(n.Complex.abs(s))){for(let e=i;e<t.dimension[1];e++)t.array[i][e]=n.Complex.mul(t.array[i][e],s);if(r){const e=n.Complex.conj(s);for(let t=0;t<r.dimension[0];t++)r.array[t][i]=n.Complex.mul(r.array[t][i],e)}}}},u.qrDecomposition=(e,t)=>{switch(t){case 1:{const{R:t,phis:r}=o.LAPACK.geqr2(e);return i.MultiArray.haveAnyComplex(t)&&u.qrPhaseNormalize(r,t),{R:t}}case 2:{const{R:t,taus:r,phis:n}=o.LAPACK.geqr2(e),s=o.LAPACK.orgqr(t,r);return o.LAPACK.triu_inplace(t),i.MultiArray.haveAnyComplex(t)&&u.qrPhaseNormalize(n,t,s),{Q:s,R:t}}case 3:{const{R:t,taus:r,phis:n,jpvt:s}=o.LAPACK.geqp3(e),a=o.LAPACK.orgqr(t,r);o.LAPACK.triu_inplace(t);const l=o.LAPACK.lapmt_matrix(s);return i.MultiArray.haveAnyComplex(t)&&u.qrPhaseNormalize(n,t,a),{Q:a,R:t,P:l}}}},u.qrSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:-3}},u.qr=e=>{if(!e||2!==e.dimension.length)throw new Error("QR decomposition can only be applied to 2D matrices.");return l.AST.nodeBoundedReturnList(3,(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(1===t){const{R:r}=u.qrDecomposition(e,1);return{length:t,R:r}}if(2===t){const{Q:r,R:n}=u.qrDecomposition(e,2);return{length:t,R:n,Q:r}}{const{Q:r,R:n,P:s}=u.qrDecomposition(e,3);return{length:t,R:n,Q:r,P:s}}})},u.eigDecomposition_original=(e,t,r=32,s="asc")=>{if(!e||!e.dimension||2!==e.dimension.length)throw new Error("eigDecomposition: A must be a 2D MultiArray");const l=e.dimension[0];if(l!==e.dimension[1])throw new Error("eigDecomposition: A must be square");const c=i.MultiArray.copy(e),{diag:u,offdiag:h,taus:d}=o.LAPACK.sytrd_blocked_w(c,r);if(!Array.isArray(u)||!Array.isArray(h))throw new Error("eigDecomposition: sytrd_blocked_w did not return diag/offdiag arrays");if(1===t){const e=i.MultiArray.toColumnVector(o.LAPACK.steqr_values(u,h));if(!e||!e.array||e.dimension[0]!==l)throw new Error("eigDecomposition: steqr_values returned invalid MultiArray");if("none"===s)return i.MultiArray.setType(e),{values:e};const t=new Array(l);for(let r=0;r<l;r++)t[r]=e.array[r][0];const r=Array.from({length:l},(e,t)=>t).sort((e,r)=>{const i=n.Complex.realToNumber(t[e]),a=n.Complex.realToNumber(t[r]);return"asc"===s?i-a:a-i}).map(e=>t[e]),a=i.MultiArray.toColumnVector(r);return i.MultiArray.setType(a),{values:a}}{const e=o.LAPACK.steqr_vectors(u,h);if(!e||!e.D||!e.V)throw new Error("eigDecomposition: steqr_vectors returned invalid result");const m=i.MultiArray.toDiagonalMatrix(e.D),p=new i.MultiArray([e.V.length,e.V[0].length]);if(p.array=e.V,m.dimension[0]!==l)throw new Error("eigDecomposition: steqr_vectors returned D of unexpected size");if(p.dimension[0]!==l||p.dimension[1]!==l)throw new Error("eigDecomposition: steqr_vectors returned V of unexpected shape");const f=o.LAPACK.orgtr_blocked_w(c,d,r),g=new i.MultiArray([l,l]);for(let e=0;e<l;e++)for(let t=0;t<l;t++)g.array[e][t]=n.Complex.zero();a.BLAS.gemm_block(f.array,p.array,g.array,n.Complex.one(),n.Complex.zero(),r),i.MultiArray.setType(g);const y=new Array(l);for(let e=0;e<l;e++)y[e]=m.array[e][0];const x="none"===s?Array.from({length:l},(e,t)=>t):Array.from({length:l},(e,t)=>t).sort((e,t)=>{const r=n.Complex.realToNumber(y[e]),i=n.Complex.realToNumber(y[t]);return"asc"===s?r-i:i-r}),C=x.map(e=>y[e]),E=i.MultiArray.toColumnVector(C),v=new i.MultiArray([l,l]);for(let e=0;e<l;e++){const t=x[e];for(let r=0;r<l;r++)v.array[r][e]=g.array[r][t]}if(i.MultiArray.setType(E),i.MultiArray.setType(v),2===t)return{values:E,vectors:v};{const e=new i.MultiArray([l,l]);for(let t=0;t<l;t++)for(let r=0;r<l;r++)e.array[t][r]=n.Complex.zero();for(let t=0;t<l;t++)e.array[t][t]=u[t],t<l-1&&(e.array[t][t+1]=h[t],e.array[t+1][t]=n.Complex.conj(h[t]));return i.MultiArray.setType(e),{values:E,vectors:v,T:e}}}},u.eigDecomposition=(e,t,r="asc",s)=>{const a=e.dimension[0],l=i.MultiArray.copy(e),{diag:c,offdiag:u,taus:h}=o.LAPACK.sytrd(l,o.LAPACK.larf_left);if(1===t){const{D:e}=o.LAPACK.steqr_vectors(c,u,1e4),t=Array.from({length:a},(e,t)=>t).sort((t,s)=>{const i=n.Complex.realToNumber(e[t]),a=n.Complex.realToNumber(e[s]);return"asc"===r?i-a:a-i}).map(t=>e[t]),s=i.MultiArray.toColumnVector(t);return i.MultiArray.setType(s),{values:s}}{const{D:e,V:t}=o.LAPACK.steqr_vectors_tridiagonal(c,u,1e4),r=new i.MultiArray([t.length,t[0].length]);return r.array=t,{values:i.MultiArray.toDiagonalMatrix(e),vectors:r}}},u.eigSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}},u.eig=e=>l.AST.nodeBoundedReturnList(3,(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(1===t){const{D:r}=o.LAPACK.eig_hermitian(e);return{length:t,values:r}}if(2===t){const{D:r,V:n}=o.LAPACK.eig_hermitian(e,!0);return{length:t,values:r,vectors:n}}{const{values:r,vectors:n,T:s}=u.eigDecomposition(e,3);return{length:t,values:r,vectors:n,T:s}}}),u.testSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}},u.functions={eye:{func:u.eye,signature:u.eyeSignature},transpose:{func:u.transpose,signature:u.transposeSignature},ctranspose:{func:u.ctranspose,signature:u.ctransposeSignature},diag:{func:u.diag,signature:u.diagSignature},trace:{func:u.trace,signature:u.traceSignature},det:{func:u.det,signature:u.detSignature},inv:{func:u.inv,signature:u.invSignature},cond:{func:u.cond,signature:u.condSignature},rank:{func:u.rank,signature:u.rankSignature},gauss:{func:u.gauss,signature:u.gaussSignature},lu:{func:u.lu,signature:u.luSignature},dot:{func:u.dot,signature:u.dotSignature},cross:{func:u.cross,signature:u.crossSignature},kron:{func:u.kron,signature:u.kronSignature},qr:{func:u.qr,signature:u.qrSignature},eig:{func:u.eig,signature:u.eigSignature},test:{func:u.test,signature:u.testSignature}},t.default={LinearAlgebra:u}},2207(__unused_webpack_module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const antlr4_1=__webpack_require__(3222);class MathJSLabLexer extends antlr4_1.Lexer{commandQuoteIsClosed(e){let t=1,r=this._input.LA(t);for(;r!==antlr4_1.Token.EOF&&10!==r&&13!==r;){if(r===e){if(this._input.LA(t+1)===e){t+=2,r=this._input.LA(t);continue}return!0}t++,r=this._input.LA(t)}return!1}commandIsFollowedByAssignment(e){const t=this._input.LA(e);if(61===t)return!0;const r=this._input.LA(e+1);return!(![43,45,42,47,92,94,38,124].includes(t)||61!==r)||46===t&&[42,47,92,94].includes(r)&&61===this._input.LA(e+2)}matrixWhitespaceIsSeparator(e=!1){let t=1;if(e)for(;9===this._input.LA(t)||32===this._input.LA(t);)t++;const r=this._input.LA(t);if(43!==r&&45!==r)return!this.matrixWhitespaceBeforeBinaryOperator(t);const n=this._input.LA(t+1);return 9!==n&&32!==n}matrixWhitespaceBeforeBinaryOperator(e){const t=this._input.LA(e),r=this._input.LA(e+1);return!![38,42,47,58,60,62,92,94,124].includes(t)||(46===t?[42,47,92,94].includes(r):61===t&&61===r||126===t&&61===r)}emit(){const e=super.emit();return null!==this.continuedTokenType&&e.type!==antlr4_1.Token.EOF&&e.type!==MathJSLabLexer.NEWLINE&&e.type!==MathJSLabLexer.WSPACE&&(this.continuedTokenType=null),e}constructor(e){super(e),this.commandNames=new Set,this.assignmentSensitiveCommandNames=new Set,this.previousTokenType=antlr4_1.Token.EOF,this.parenthesisCount=0,this.continuedTokenType=null,this.commandContinued=!1,this.matrixContext=[],this.curlyBraceIsMatrixContext=[],this.indexingBraceCount=0,this.quotedString="",this._interp=new antlr4_1.LexerATNSimulator(this,MathJSLabLexer._ATN,MathJSLabLexer.DecisionsToDFA,new antlr4_1.PredictionContextCache)}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.QUESTION_action(e,r);break;case 13:this.LPAREN_action(e,r);break;case 14:this.RPAREN_action(e,r);break;case 15:this.LBRACKET_action(e,r);break;case 16:this.RBRACKET_action(e,r);break;case 17:this.LCURLYBR_action(e,r);break;case 18:this.RCURLYBR_action(e,r);break;case 19:this.LEFTDIV_action(e,r);break;case 20:this.ADD_EQ_action(e,r);break;case 21:this.SUB_EQ_action(e,r);break;case 22:this.MUL_EQ_action(e,r);break;case 23:this.DIV_EQ_action(e,r);break;case 24:this.LEFTDIV_EQ_action(e,r);break;case 25:this.POW_EQ_action(e,r);break;case 26:this.EMUL_EQ_action(e,r);break;case 27:this.EDIV_EQ_action(e,r);break;case 28:this.ELEFTDIV_EQ_action(e,r);break;case 29:this.EPOW_EQ_action(e,r);break;case 30:this.AND_EQ_action(e,r);break;case 31:this.OR_EQ_action(e,r);break;case 32:this.EXPR_AND_AND_action(e,r);break;case 33:this.EXPR_OR_OR_action(e,r);break;case 34:this.EXPR_AND_action(e,r);break;case 35:this.EXPR_OR_action(e,r);break;case 36:this.EXPR_LT_action(e,r);break;case 37:this.EXPR_LE_action(e,r);break;case 38:this.EXPR_EQ_action(e,r);break;case 39:this.EXPR_NE_action(e,r);break;case 40:this.EXPR_GE_action(e,r);break;case 41:this.EXPR_GT_action(e,r);break;case 42:this.EMUL_action(e,r);break;case 43:this.EDIV_action(e,r);break;case 44:this.ELEFTDIV_action(e,r);break;case 45:this.PLUS_PLUS_action(e,r);break;case 46:this.MINUS_MINUS_action(e,r);break;case 47:this.POW_action(e,r);break;case 48:this.EPOW_action(e,r);break;case 49:this.TRANSPOSE_action(e,r);break;case 50:this.HERMITIAN_action(e,r);break;case 51:this.DQSTRING_action(e,r);break;case 52:this.IDENTIFIER_action(e,r);break;case 53:this.FLOAT_NUMBER_action(e,r);break;case 54:this.NUMBER_DOT_OP_action(e,r);break;case 55:this.LINE_CONTINUATION_action(e,r);break;case 56:this.SPACE_OR_CONTINUATION_action(e,r);break;case 57:this.NEWLINE_action(e,r);break;case 58:this.BLOCK_COMMENT_START_action(e,r);break;case 59:this.COMMENT_LINE_action(e,r);break;case 61:this.SINGLEQ_STRING_action(e,r);break;case 62:this.SINGLEQ_NL_action(e,r);break;case 63:this.SINGLEQ_SINGLEQ_action(e,r);break;case 64:this.SINGLEQ_END_action(e,r);break;case 65:this.DOUBLEQ_STRING_action(e,r);break;case 66:this.DOUBLEQ_NL_action(e,r);break;case 67:this.DOUBLEQ_DOUBLEQ_action(e,r);break;case 68:this.DOUBLEQ_ESCAPE_action(e,r);break;case 69:this.DOUBLEQ_ESCAPE_OTHER_action(e,r);break;case 70:this.DOUBLEQ_ESCAPE_OCT_action(e,r);break;case 71:this.DOUBLEQ_ESCAPE_HEX_action(e,r);break;case 72:this.DOUBLEQ_ESCAPE_UNICODE_action(e,r);break;case 73:this.DOUBLEQ_END_action(e,r);break;case 74:this.BLOCK_COMMENT_START_AGAIN_action(e,r);break;case 75:this.BLOCK_COMMENT_END_action(e,r);break;case 77:this.BLOCK_COMMENT_EOF_action(e,r);break;case 78:this.COMMAND_LINE_CONTINUATION_action(e,r);break;case 79:this.COMMAND_CONTINUED_BLOCK_COMMENT_START_action(e,r);break;case 83:this.COMMAND_LONE_DQUOTE_action(e,r);break;case 84:this.COMMAND_LONE_SQUOTE_action(e,r);break;case 85:this.COMMAND_UNCLOSED_DQUOTE_action(e,r);break;case 86:this.COMMAND_UNCLOSED_SQUOTE_action(e,r);break;case 87:this.COMMAND_DQSTRING_action(e,r);break;case 88:this.COMMAND_SQSTRING_action(e,r);break;case 90:this.COMMAND_SEPARATOR_action(e,r);break;case 91:this.EXIT_AT_NEWLINE_action(e,r);break;case 92:this.EXIT_AT_EOF_action(e,r);break;case 93: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)}QUESTION_action(e,t){12===t&&(this.previousTokenType=MathJSLabLexer.QUESTION)}LPAREN_action(e,t){13===t&&(this.matrixContext.length>0&&this.matrixContext.push(MathJSLabLexer.LPAREN),this.parenthesisCount++,this.previousTokenType=MathJSLabLexer.LPAREN)}RPAREN_action(e,t){14===t&&(this.matrixContext.length>0&&this.matrixContext.pop(),this.parenthesisCount=Math.max(0,this.parenthesisCount-1),this.previousTokenType=MathJSLabLexer.RPAREN)}LBRACKET_action(e,t){15===t&&(this.matrixContext.push(MathJSLabLexer.LBRACKET),this.previousTokenType=MathJSLabLexer.LBRACKET)}RBRACKET_action(e,t){16===t&&(this.matrixContext.pop(),this.previousTokenType=MathJSLabLexer.RBRACKET)}LCURLYBR_action(e,t){if(17===t){const e=this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER||this.previousTokenType===MathJSLabLexer.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE;this.curlyBraceIsMatrixContext.push(!e),e?this.indexingBraceCount++:this.matrixContext.push(MathJSLabLexer.LCURLYBR),this.previousTokenType=MathJSLabLexer.LCURLYBR}}RCURLYBR_action(e,t){var r;18===t&&(null===(r=this.curlyBraceIsMatrixContext.pop())||void 0===r||r?this.matrixContext.pop():this.indexingBraceCount=Math.max(0,this.indexingBraceCount-1),this.previousTokenType=MathJSLabLexer.RCURLYBR)}LEFTDIV_action(e,t){19===t&&(this.previousTokenType=MathJSLabLexer.LEFTDIV)}ADD_EQ_action(e,t){20===t&&(this.previousTokenType=MathJSLabLexer.ADD_EQ)}SUB_EQ_action(e,t){21===t&&(this.previousTokenType=MathJSLabLexer.SUB_EQ)}MUL_EQ_action(e,t){22===t&&(this.previousTokenType=MathJSLabLexer.MUL_EQ)}DIV_EQ_action(e,t){23===t&&(this.previousTokenType=MathJSLabLexer.DIV_EQ)}LEFTDIV_EQ_action(e,t){24===t&&(this.previousTokenType=MathJSLabLexer.LEFTDIV_EQ)}POW_EQ_action(e,t){25===t&&(this.previousTokenType=MathJSLabLexer.POW_EQ)}EMUL_EQ_action(e,t){26===t&&(this.previousTokenType=MathJSLabLexer.EMUL_EQ)}EDIV_EQ_action(e,t){27===t&&(this.previousTokenType=MathJSLabLexer.EDIV_EQ)}ELEFTDIV_EQ_action(e,t){28===t&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV_EQ)}EPOW_EQ_action(e,t){29===t&&(this.previousTokenType=MathJSLabLexer.EPOW_EQ)}AND_EQ_action(e,t){30===t&&(this.previousTokenType=MathJSLabLexer.AND_EQ)}OR_EQ_action(e,t){31===t&&(this.previousTokenType=MathJSLabLexer.OR_EQ)}EXPR_AND_AND_action(e,t){32===t&&(this.previousTokenType=MathJSLabLexer.EXPR_AND_AND)}EXPR_OR_OR_action(e,t){33===t&&(this.previousTokenType=MathJSLabLexer.EXPR_OR_OR)}EXPR_AND_action(e,t){34===t&&(this.previousTokenType=MathJSLabLexer.EXPR_AND)}EXPR_OR_action(e,t){35===t&&(this.previousTokenType=MathJSLabLexer.EXPR_OR)}EXPR_LT_action(e,t){36===t&&(this.previousTokenType=MathJSLabLexer.EXPR_LT)}EXPR_LE_action(e,t){37===t&&(this.previousTokenType=MathJSLabLexer.EXPR_LE)}EXPR_EQ_action(e,t){38===t&&(this.previousTokenType=MathJSLabLexer.EXPR_EQ)}EXPR_NE_action(e,t){39===t&&(this.previousTokenType=MathJSLabLexer.EXPR_NE)}EXPR_GE_action(e,t){40===t&&(this.previousTokenType=MathJSLabLexer.EXPR_GE)}EXPR_GT_action(e,t){41===t&&(this.previousTokenType=MathJSLabLexer.EXPR_GT)}EMUL_action(e,t){42===t&&(this.previousTokenType=MathJSLabLexer.EMUL)}EDIV_action(e,t){43===t&&(this.previousTokenType=MathJSLabLexer.EDIV)}ELEFTDIV_action(e,t){44===t&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV)}PLUS_PLUS_action(e,t){45===t&&(this.previousTokenType=MathJSLabLexer.PLUS_PLUS)}MINUS_MINUS_action(e,t){46===t&&(this.previousTokenType=MathJSLabLexer.MINUS_MINUS)}POW_action(e,t){47===t&&(this.previousTokenType=MathJSLabLexer.POW)}EPOW_action(e,t){48===t&&(this.previousTokenType=MathJSLabLexer.EPOW)}TRANSPOSE_action(e,t){49===t&&(this.previousTokenType=MathJSLabLexer.TRANSPOSE)}HERMITIAN_action(e,t){50===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.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE?this.previousTokenType=MathJSLabLexer.HERMITIAN:(this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip()))}DQSTRING_action(e,t){51===t&&(this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}IDENTIFIER_action(e,t){if(52===t)if(this.previousTokenType===MathJSLabLexer.DOT)this.previousTokenType=MathJSLabLexer.IDENTIFIER;else{const e=MathJSLabLexer.keywordTypeByName.get(this.text);if(void 0!==e)e===MathJSLabLexer.END?this._type=this.previousTokenType=this.parenthesisCount>0||this.matrixContext.length>0||this.indexingBraceCount>0?MathJSLabLexer.ENDRANGE:MathJSLabLexer.END:this._type=this.previousTokenType=e;else{const e=this.commandNames.has(this.text),t=this.previousTokenType===antlr4_1.Token.EOF||this.previousTokenType===MathJSLabLexer.NEWLINE||this.previousTokenType===MathJSLabLexer.SEMICOLON||this.previousTokenType===MathJSLabLexer.COMMA&&0===this.parenthesisCount&&0===this.matrixContext.length;let r=1,n=this._input.LA(r);for(;9===n||32===n;)n=this._input.LA(++r);const s=this.assignmentSensitiveCommandNames.has(this.text)&&this.commandIsFollowedByAssignment(r);e&&t&&(40!==n||r>1)&&!s&&this.pushMode(MathJSLabLexer.ANY_AS_STRING_UNTIL_END_OF_LINE),this.previousTokenType=MathJSLabLexer.IDENTIFIER}}}FLOAT_NUMBER_action(e,t){53===t&&(this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}NUMBER_DOT_OP_action(e,t){54===t&&(this._input.seek(this._input.index-2),this._type=this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}LINE_CONTINUATION_action(e,t){55===t&&(this.continuedTokenType=this.previousTokenType,this.skip())}SPACE_OR_CONTINUATION_action(e,t){56===t&&(this.text.includes("...")&&(this.continuedTokenType=this.previousTokenType),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.has(this.previousTokenType)&&this.matrixWhitespaceIsSeparator(this.text.includes("..."))?this._type=this.previousTokenType=MathJSLabLexer.WSPACE:this.skip())}NEWLINE_action(e,t){57===t&&(this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.indexingBraceCount>0||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){58===t&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}COMMENT_LINE_action(e,t){switch(t){case 59:this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE;break;case 60:this._type=this.previousTokenType=MathJSLabLexer.EOF}}SINGLEQ_STRING_action(e,t){61===t&&(this.quotedString+=this.text,this.skip())}SINGLEQ_NL_action(e,t){62===t&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}SINGLEQ_SINGLEQ_action(e,t){63===t&&(this.quotedString+="'",this.skip())}SINGLEQ_END_action(e,t){64===t&&(this.text=`'${this.quotedString}'`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}DOUBLEQ_STRING_action(e,t){65===t&&(this.quotedString+=this.text,this.skip())}DOUBLEQ_NL_action(e,t){66===t&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}DOUBLEQ_DOUBLEQ_action(e,t){67===t&&(this.quotedString+='"',this.skip())}DOUBLEQ_ESCAPE_action(e,t){68===t&&(this.quotedString+=JSON.parse(`"${this.text}"`),this.skip())}DOUBLEQ_ESCAPE_OTHER_action(e,t){69===t&&(this.quotedString+=this.text.substring(1),this.skip())}DOUBLEQ_ESCAPE_OCT_action(e,t){70===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){71===actionIndex&&(this.quotedString+=eval(`"\\x${this.text.substring(2)}"`),this.skip())}DOUBLEQ_ESCAPE_UNICODE_action(e,t){72===t&&(this.quotedString+=JSON.parse(`"\\u${this.text.substring(2).padStart(4,"0")}"`),this.skip())}DOUBLEQ_END_action(e,t){73===t&&(this.text=`"${this.quotedString}"`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}BLOCK_COMMENT_START_AGAIN_action(e,t){74===t&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}BLOCK_COMMENT_END_action(e,t){75===t&&(this.popMode(),this.skip())}BLOCK_COMMENT_EOF_action(e,t){if(76===t)throw new SyntaxError("Block comment open at end of input.")}COMMAND_LINE_CONTINUATION_action(e,t){77===t&&(this.commandContinued=!0,this.skip())}COMMAND_CONTINUED_BLOCK_COMMENT_START_action(e,t){78===t&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}COMMAND_LONE_DQUOTE_action(e,t){79===t&&(this.commandContinued=!1,this.text='"',this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_LONE_SQUOTE_action(e,t){80===t&&(this.commandContinued=!1,this.text="'",this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_DQUOTE_action(e,t){81===t&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_SQUOTE_action(e,t){82===t&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_DQSTRING_action(e,t){83===t&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}COMMAND_SQSTRING_action(e,t){84===t&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip())}COMMAND_SEPARATOR_action(e,t){85===t&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=","===this.text?MathJSLabLexer.COMMA:MathJSLabLexer.SEMICOLON)}EXIT_AT_NEWLINE_action(e,t){86===t&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}EXIT_AT_EOF_action(e,t){87===t&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.EOF)}UNQUOTED_STRING_action(e,t){88===t&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING)}sempred(e,t,r){switch(t){case 58:return this.BLOCK_COMMENT_START_sempred(e,r);case 74:return this.BLOCK_COMMENT_START_AGAIN_sempred(e,r);case 75:return this.BLOCK_COMMENT_END_sempred(e,r);case 79:return this.COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(e,r);case 80:return this.COMMAND_CONTINUED_COMMENT_LINE_sempred(e,r);case 81:return this.COMMAND_CONTINUED_NEWLINE_sempred(e,r);case 83:return this.COMMAND_LONE_DQUOTE_sempred(e,r);case 84:return this.COMMAND_LONE_SQUOTE_sempred(e,r);case 85:return this.COMMAND_UNCLOSED_DQUOTE_sempred(e,r);case 86:return this.COMMAND_UNCLOSED_SQUOTE_sempred(e,r);case 87:return this.COMMAND_DQSTRING_sempred(e,r);case 88:return this.COMMAND_SQSTRING_sempred(e,r)}return!0}BLOCK_COMMENT_START_sempred(e,t){return 0!==t||0===this.column}BLOCK_COMMENT_START_AGAIN_sempred(e,t){return 1!==t||0===this.column}BLOCK_COMMENT_END_sempred(e,t){return 2!==t||0===this.column}COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(e,t){return 3!==t||this.commandContinued}COMMAND_CONTINUED_COMMENT_LINE_sempred(e,t){return 4!==t||this.commandContinued}COMMAND_CONTINUED_NEWLINE_sempred(e,t){return 5!==t||this.commandContinued}COMMAND_LONE_DQUOTE_sempred(e,t){return 6!==t||[antlr4_1.Token.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_LONE_SQUOTE_sempred(e,t){return 7!==t||[antlr4_1.Token.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_UNCLOSED_DQUOTE_sempred(e,t){return 8!==t||!this.commandQuoteIsClosed(34)}COMMAND_UNCLOSED_SQUOTE_sempred(e,t){return 9!==t||!this.commandQuoteIsClosed(39)}COMMAND_DQSTRING_sempred(e,t){return 10!==t||this.commandQuoteIsClosed(34)}COMMAND_SQSTRING_sempred(e,t){return 11!==t||this.commandQuoteIsClosed(39)}static get _ATN(){return MathJSLabLexer.__ATN||(MathJSLabLexer.__ATN=(new antlr4_1.ATNDeserializer).deserialize(MathJSLabLexer._serializedATN)),MathJSLabLexer.__ATN}}MathJSLabLexer.GLOBAL=1,MathJSLabLexer.PERSISTENT=2,MathJSLabLexer.IMPORT=3,MathJSLabLexer.IF=4,MathJSLabLexer.ENDIF=5,MathJSLabLexer.END=6,MathJSLabLexer.ENDRANGE=7,MathJSLabLexer.ELSEIF=8,MathJSLabLexer.ELSE=9,MathJSLabLexer.SWITCH=10,MathJSLabLexer.ENDSWITCH=11,MathJSLabLexer.CASE=12,MathJSLabLexer.OTHERWISE=13,MathJSLabLexer.WHILE=14,MathJSLabLexer.ENDWHILE=15,MathJSLabLexer.DO=16,MathJSLabLexer.UNTIL=17,MathJSLabLexer.FOR=18,MathJSLabLexer.ENDFOR=19,MathJSLabLexer.PARFOR=20,MathJSLabLexer.ENDPARFOR=21,MathJSLabLexer.SPMD=22,MathJSLabLexer.ENDSPMD=23,MathJSLabLexer.BREAK=24,MathJSLabLexer.CONTINUE=25,MathJSLabLexer.RETURN=26,MathJSLabLexer.FUNCTION=27,MathJSLabLexer.ENDFUNCTION=28,MathJSLabLexer.TRY=29,MathJSLabLexer.CATCH=30,MathJSLabLexer.END_TRY_CATCH=31,MathJSLabLexer.UNWIND_PROTECT=32,MathJSLabLexer.UNWIND_PROTECT_CLEANUP=33,MathJSLabLexer.END_UNWIND_PROTECT=34,MathJSLabLexer.CLASSDEF=35,MathJSLabLexer.ENDCLASSDEF=36,MathJSLabLexer.ENUMERATION=37,MathJSLabLexer.ENDENUMERATION=38,MathJSLabLexer.PROPERTIES=39,MathJSLabLexer.ENDPROPERTIES=40,MathJSLabLexer.EVENTS=41,MathJSLabLexer.ENDEVENTS=42,MathJSLabLexer.METHODS=43,MathJSLabLexer.ENDMETHODS=44,MathJSLabLexer.WSPACE=45,MathJSLabLexer.STRING=46,MathJSLabLexer.ARGUMENTS=47,MathJSLabLexer.ENDARGUMENTS=48,MathJSLabLexer.PLUS=49,MathJSLabLexer.MINUS=50,MathJSLabLexer.MUL=51,MathJSLabLexer.DIV=52,MathJSLabLexer.EQ=53,MathJSLabLexer.COLON=54,MathJSLabLexer.SEMICOLON=55,MathJSLabLexer.COMMA=56,MathJSLabLexer.DOT=57,MathJSLabLexer.TILDE=58,MathJSLabLexer.EXCLAMATION=59,MathJSLabLexer.COMMAT=60,MathJSLabLexer.QUESTION=61,MathJSLabLexer.LPAREN=62,MathJSLabLexer.RPAREN=63,MathJSLabLexer.LBRACKET=64,MathJSLabLexer.RBRACKET=65,MathJSLabLexer.LCURLYBR=66,MathJSLabLexer.RCURLYBR=67,MathJSLabLexer.LEFTDIV=68,MathJSLabLexer.ADD_EQ=69,MathJSLabLexer.SUB_EQ=70,MathJSLabLexer.MUL_EQ=71,MathJSLabLexer.DIV_EQ=72,MathJSLabLexer.LEFTDIV_EQ=73,MathJSLabLexer.POW_EQ=74,MathJSLabLexer.EMUL_EQ=75,MathJSLabLexer.EDIV_EQ=76,MathJSLabLexer.ELEFTDIV_EQ=77,MathJSLabLexer.EPOW_EQ=78,MathJSLabLexer.AND_EQ=79,MathJSLabLexer.OR_EQ=80,MathJSLabLexer.EXPR_AND_AND=81,MathJSLabLexer.EXPR_OR_OR=82,MathJSLabLexer.EXPR_AND=83,MathJSLabLexer.EXPR_OR=84,MathJSLabLexer.EXPR_LT=85,MathJSLabLexer.EXPR_LE=86,MathJSLabLexer.EXPR_EQ=87,MathJSLabLexer.EXPR_NE=88,MathJSLabLexer.EXPR_GE=89,MathJSLabLexer.EXPR_GT=90,MathJSLabLexer.EMUL=91,MathJSLabLexer.EDIV=92,MathJSLabLexer.ELEFTDIV=93,MathJSLabLexer.PLUS_PLUS=94,MathJSLabLexer.MINUS_MINUS=95,MathJSLabLexer.POW=96,MathJSLabLexer.EPOW=97,MathJSLabLexer.TRANSPOSE=98,MathJSLabLexer.HERMITIAN=99,MathJSLabLexer.DQSTRING=100,MathJSLabLexer.IDENTIFIER=101,MathJSLabLexer.FLOAT_NUMBER=102,MathJSLabLexer.NUMBER_DOT_OP=103,MathJSLabLexer.LINE_CONTINUATION=104,MathJSLabLexer.SPACE_OR_CONTINUATION=105,MathJSLabLexer.NEWLINE=106,MathJSLabLexer.BLOCK_COMMENT_START=107,MathJSLabLexer.COMMENT_LINE=108,MathJSLabLexer.INVALID=109,MathJSLabLexer.SINGLEQ_STRING=110,MathJSLabLexer.SINGLEQ_NL=111,MathJSLabLexer.SINGLEQ_SINGLEQ=112,MathJSLabLexer.SINGLEQ_END=113,MathJSLabLexer.DOUBLEQ_STRING=114,MathJSLabLexer.DOUBLEQ_NL=115,MathJSLabLexer.DOUBLEQ_DOUBLEQ=116,MathJSLabLexer.DOUBLEQ_ESCAPE=117,MathJSLabLexer.DOUBLEQ_ESCAPE_OTHER=118,MathJSLabLexer.DOUBLEQ_ESCAPE_OCT=119,MathJSLabLexer.DOUBLEQ_ESCAPE_HEX=120,MathJSLabLexer.DOUBLEQ_ESCAPE_UNICODE=121,MathJSLabLexer.DOUBLEQ_END=122,MathJSLabLexer.BLOCK_COMMENT_START_AGAIN=123,MathJSLabLexer.BLOCK_COMMENT_END=124,MathJSLabLexer.BLOCK_COMMENT_LINE=125,MathJSLabLexer.BLOCK_COMMENT_EOF=126,MathJSLabLexer.COMMAND_LINE_CONTINUATION=127,MathJSLabLexer.COMMAND_CONTINUED_BLOCK_COMMENT_START=128,MathJSLabLexer.COMMAND_CONTINUED_COMMENT_LINE=129,MathJSLabLexer.COMMAND_CONTINUED_NEWLINE=130,MathJSLabLexer.SKIP_SPACE=131,MathJSLabLexer.COMMAND_LONE_DQUOTE=132,MathJSLabLexer.COMMAND_LONE_SQUOTE=133,MathJSLabLexer.COMMAND_UNCLOSED_DQUOTE=134,MathJSLabLexer.COMMAND_UNCLOSED_SQUOTE=135,MathJSLabLexer.COMMAND_DQSTRING=136,MathJSLabLexer.COMMAND_SQSTRING=137,MathJSLabLexer.SKIP_COMMENT_LINE=138,MathJSLabLexer.COMMAND_SEPARATOR=139,MathJSLabLexer.EXIT_AT_NEWLINE=140,MathJSLabLexer.EXIT_AT_EOF=141,MathJSLabLexer.UNQUOTED_STRING=142,MathJSLabLexer.EOF=antlr4_1.Token.EOF,MathJSLabLexer.SQ_STRING=1,MathJSLabLexer.DQ_STRING=2,MathJSLabLexer.BLOCK_COMMENT=3,MathJSLabLexer.ANY_AS_STRING_UNTIL_END_OF_LINE=4,MathJSLabLexer.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"],MathJSLabLexer.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,null,null,"''''",null,null,null,"'\"\"'"],MathJSLabLexer.symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","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","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","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","LINE_CONTINUATION","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","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"],MathJSLabLexer.modeNames=["DEFAULT_MODE","SQ_STRING","DQ_STRING","BLOCK_COMMENT","ANY_AS_STRING_UNTIL_END_OF_LINE"],MathJSLabLexer.ruleNames=["PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","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","LINE_CONTINUATION","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","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","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"],MathJSLabLexer.keywordNames=[null,"global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","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","endarguments"],MathJSLabLexer.keywordTypes=[NaN,MathJSLabLexer.GLOBAL,MathJSLabLexer.PERSISTENT,MathJSLabLexer.IMPORT,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.SPMD,MathJSLabLexer.ENDSPMD,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,MathJSLabLexer.ENDARGUMENTS],MathJSLabLexer.keywordTypeByName=new Map(MathJSLabLexer.keywordNames.map((e,t)=>e?[e,MathJSLabLexer.keywordTypes[t]]:void 0).filter(e=>void 0!==e)),MathJSLabLexer.nonTerminalSign=new Set([MathJSLabLexer.PLUS,MathJSLabLexer.MINUS,MathJSLabLexer.MUL,MathJSLabLexer.DIV,MathJSLabLexer.EQ,MathJSLabLexer.COLON,MathJSLabLexer.DOT,MathJSLabLexer.TILDE,MathJSLabLexer.EXCLAMATION,MathJSLabLexer.COMMAT,MathJSLabLexer.QUESTION,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]),MathJSLabLexer._serializedATN=[4,0,142,927,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,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,98,7,98,2,99,7,99,2,100,7,100,2,101,7,101,2,102,7,102,2,103,7,103,2,104,7,104,2,105,7,105,2,106,7,106,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,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,1,25,1,25,1,25,1,25,1,25,3,25,310,8,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,29,1,29,1,29,1,29,1,29,1,29,1,29,3,29,339,8,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,33,1,33,1,34,1,34,1,34,1,35,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,3,39,386,8,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,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,1,46,1,46,1,47,1,47,1,47,3,47,426,8,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,3,48,435,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,52,1,52,1,52,1,53,1,53,3,53,455,8,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,5,55,469,8,55,10,55,12,55,472,9,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,5,56,483,8,56,10,56,12,56,486,9,56,1,56,1,56,3,56,490,8,56,3,56,492,8,56,1,56,1,56,1,57,1,57,1,57,1,58,1,58,3,58,501,8,58,1,58,1,58,1,58,3,58,506,8,58,1,58,1,58,1,58,1,59,1,59,5,59,513,8,59,10,59,12,59,516,9,59,1,59,1,59,1,59,1,59,1,59,3,59,523,8,59,1,60,1,60,1,61,4,61,528,8,61,11,61,12,61,529,1,61,1,61,1,62,1,62,1,62,1,63,1,63,1,63,1,63,1,63,1,64,1,64,1,64,1,65,4,65,546,8,65,11,65,12,65,547,1,65,1,65,1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,67,1,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,70,1,70,1,70,3,70,571,8,70,1,70,3,70,574,8,70,1,70,1,70,1,71,1,71,1,71,1,71,3,71,582,8,71,1,71,1,71,1,72,1,72,1,72,1,72,3,72,590,8,72,1,72,3,72,593,8,72,1,72,3,72,596,8,72,1,72,1,72,1,73,1,73,1,73,1,74,1,74,3,74,605,8,74,1,74,1,74,1,74,3,74,610,8,74,1,74,1,74,1,74,1,75,1,75,3,75,617,8,75,1,75,1,75,1,75,3,75,622,8,75,1,75,3,75,625,8,75,1,75,1,75,1,76,5,76,630,8,76,10,76,12,76,633,9,76,1,76,1,76,1,76,1,76,1,77,5,77,640,8,77,10,77,12,77,643,9,77,1,77,1,77,1,77,1,78,1,78,1,78,1,78,1,78,5,78,653,8,78,10,78,12,78,656,9,78,1,78,1,78,1,78,1,79,1,79,3,79,663,8,79,1,79,1,79,1,79,3,79,668,8,79,1,79,1,79,1,79,1,80,1,80,1,80,5,80,676,8,80,10,80,12,80,679,9,80,1,80,1,80,1,80,1,80,1,81,1,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,83,1,83,1,83,1,83,1,84,1,84,1,84,1,84,1,85,1,85,1,85,5,85,705,8,85,10,85,12,85,708,9,85,1,85,1,85,1,86,1,86,1,86,5,86,715,8,86,10,86,12,86,718,9,86,1,86,1,86,1,87,1,87,1,87,1,87,1,88,1,88,1,88,1,88,1,89,1,89,5,89,732,8,89,10,89,12,89,735,9,89,1,89,1,89,1,90,1,90,1,90,1,91,1,91,1,91,1,92,1,92,1,92,1,93,1,93,5,93,750,8,93,10,93,12,93,753,9,93,1,93,1,93,1,94,1,94,1,95,1,95,3,95,761,8,95,1,95,3,95,764,8,95,1,96,4,96,767,8,96,11,96,12,96,768,1,97,1,97,5,97,773,8,97,10,97,12,97,776,9,97,1,98,1,98,3,98,780,8,98,1,98,1,98,3,98,784,8,98,1,98,5,98,787,8,98,10,98,12,98,790,9,98,1,99,1,99,3,99,794,8,99,1,99,3,99,797,8,99,1,99,1,99,3,99,801,8,99,1,99,1,99,3,99,805,8,99,1,99,1,99,1,99,1,99,3,99,811,8,99,1,99,3,99,814,8,99,1,99,1,99,3,99,818,8,99,1,99,1,99,3,99,822,8,99,1,99,1,99,1,99,1,99,3,99,828,8,99,1,99,3,99,831,8,99,1,99,1,99,3,99,835,8,99,1,99,1,99,3,99,839,8,99,1,99,1,99,1,99,1,99,3,99,845,8,99,1,99,3,99,848,8,99,1,99,1,99,3,99,852,8,99,1,99,1,99,3,99,856,8,99,3,99,858,8,99,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,3,100,869,8,100,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101,3,101,879,8,101,3,101,881,8,101,1,102,1,102,3,102,885,8,102,1,102,5,102,888,8,102,10,102,12,102,891,9,102,1,103,1,103,3,103,895,8,103,1,103,5,103,898,8,103,10,103,12,103,901,9,103,1,104,1,104,3,104,905,8,104,1,104,5,104,908,8,104,10,104,12,104,911,9,104,1,105,1,105,3,105,915,8,105,1,105,5,105,918,8,105,10,105,12,105,921,9,105,1,106,3,106,924,8,106,1,106,1,106,1,631,0,107,5,49,7,50,9,51,11,52,13,53,15,54,17,55,19,56,21,57,23,58,25,59,27,60,29,61,31,62,33,63,35,64,37,65,39,66,41,67,43,68,45,69,47,70,49,71,51,72,53,73,55,74,57,75,59,76,61,77,63,78,65,79,67,80,69,81,71,82,73,83,75,84,77,85,79,86,81,87,83,88,85,89,87,90,89,91,91,92,93,93,95,94,97,95,99,96,101,97,103,98,105,99,107,100,109,101,111,102,113,103,115,104,117,105,119,106,121,107,123,108,125,109,127,110,129,111,131,112,133,113,135,114,137,115,139,116,141,117,143,118,145,119,147,120,149,121,151,122,153,123,155,124,157,125,159,126,161,127,163,128,165,129,167,130,169,131,171,132,173,133,175,134,177,135,179,136,181,137,183,138,185,139,187,140,189,141,191,142,193,0,195,0,197,0,199,0,201,0,203,0,205,0,207,0,209,0,211,0,213,0,215,0,217,0,5,0,1,2,3,4,25,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,44,44,59,59,7,0,9,10,13,13,32,32,34,34,39,39,44,44,59,59,5,0,9,10,13,13,32,32,44,44,59,59,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,1,0,48,49,2,0,43,43,45,45,987,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,0,123,1,0,0,0,0,125,1,0,0,0,1,127,1,0,0,0,1,129,1,0,0,0,1,131,1,0,0,0,1,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,2,149,1,0,0,0,2,151,1,0,0,0,3,153,1,0,0,0,3,155,1,0,0,0,3,157,1,0,0,0,3,159,1,0,0,0,4,161,1,0,0,0,4,163,1,0,0,0,4,165,1,0,0,0,4,167,1,0,0,0,4,169,1,0,0,0,4,171,1,0,0,0,4,173,1,0,0,0,4,175,1,0,0,0,4,177,1,0,0,0,4,179,1,0,0,0,4,181,1,0,0,0,4,183,1,0,0,0,4,185,1,0,0,0,4,187,1,0,0,0,4,189,1,0,0,0,4,191,1,0,0,0,5,219,1,0,0,0,7,222,1,0,0,0,9,225,1,0,0,0,11,228,1,0,0,0,13,231,1,0,0,0,15,234,1,0,0,0,17,237,1,0,0,0,19,240,1,0,0,0,21,243,1,0,0,0,23,246,1,0,0,0,25,249,1,0,0,0,27,252,1,0,0,0,29,255,1,0,0,0,31,258,1,0,0,0,33,261,1,0,0,0,35,264,1,0,0,0,37,267,1,0,0,0,39,270,1,0,0,0,41,273,1,0,0,0,43,276,1,0,0,0,45,279,1,0,0,0,47,284,1,0,0,0,49,289,1,0,0,0,51,294,1,0,0,0,53,299,1,0,0,0,55,309,1,0,0,0,57,313,1,0,0,0,59,319,1,0,0,0,61,325,1,0,0,0,63,338,1,0,0,0,65,342,1,0,0,0,67,347,1,0,0,0,69,352,1,0,0,0,71,357,1,0,0,0,73,362,1,0,0,0,75,365,1,0,0,0,77,368,1,0,0,0,79,371,1,0,0,0,81,376,1,0,0,0,83,385,1,0,0,0,85,389,1,0,0,0,87,394,1,0,0,0,89,397,1,0,0,0,91,402,1,0,0,0,93,407,1,0,0,0,95,412,1,0,0,0,97,417,1,0,0,0,99,425,1,0,0,0,101,434,1,0,0,0,103,438,1,0,0,0,105,443,1,0,0,0,107,446,1,0,0,0,109,449,1,0,0,0,111,452,1,0,0,0,113,458,1,0,0,0,115,463,1,0,0,0,117,476,1,0,0,0,119,495,1,0,0,0,121,498,1,0,0,0,123,510,1,0,0,0,125,524,1,0,0,0,127,527,1,0,0,0,129,533,1,0,0,0,131,536,1,0,0,0,133,541,1,0,0,0,135,545,1,0,0,0,137,551,1,0,0,0,139,554,1,0,0,0,141,559,1,0,0,0,143,563,1,0,0,0,145,567,1,0,0,0,147,577,1,0,0,0,149,585,1,0,0,0,151,599,1,0,0,0,153,602,1,0,0,0,155,614,1,0,0,0,157,631,1,0,0,0,159,641,1,0,0,0,161,647,1,0,0,0,163,660,1,0,0,0,165,672,1,0,0,0,167,684,1,0,0,0,169,689,1,0,0,0,171,693,1,0,0,0,173,697,1,0,0,0,175,701,1,0,0,0,177,711,1,0,0,0,179,721,1,0,0,0,181,725,1,0,0,0,183,729,1,0,0,0,185,738,1,0,0,0,187,741,1,0,0,0,189,744,1,0,0,0,191,747,1,0,0,0,193,756,1,0,0,0,195,763,1,0,0,0,197,766,1,0,0,0,199,770,1,0,0,0,201,777,1,0,0,0,203,857,1,0,0,0,205,859,1,0,0,0,207,880,1,0,0,0,209,882,1,0,0,0,211,892,1,0,0,0,213,902,1,0,0,0,215,912,1,0,0,0,217,923,1,0,0,0,219,220,5,43,0,0,220,221,6,0,0,0,221,6,1,0,0,0,222,223,5,45,0,0,223,224,6,1,1,0,224,8,1,0,0,0,225,226,5,42,0,0,226,227,6,2,2,0,227,10,1,0,0,0,228,229,5,47,0,0,229,230,6,3,3,0,230,12,1,0,0,0,231,232,5,61,0,0,232,233,6,4,4,0,233,14,1,0,0,0,234,235,5,58,0,0,235,236,6,5,5,0,236,16,1,0,0,0,237,238,5,59,0,0,238,239,6,6,6,0,239,18,1,0,0,0,240,241,5,44,0,0,241,242,6,7,7,0,242,20,1,0,0,0,243,244,5,46,0,0,244,245,6,8,8,0,245,22,1,0,0,0,246,247,5,126,0,0,247,248,6,9,9,0,248,24,1,0,0,0,249,250,5,33,0,0,250,251,6,10,10,0,251,26,1,0,0,0,252,253,5,64,0,0,253,254,6,11,11,0,254,28,1,0,0,0,255,256,5,63,0,0,256,257,6,12,12,0,257,30,1,0,0,0,258,259,5,40,0,0,259,260,6,13,13,0,260,32,1,0,0,0,261,262,5,41,0,0,262,263,6,14,14,0,263,34,1,0,0,0,264,265,5,91,0,0,265,266,6,15,15,0,266,36,1,0,0,0,267,268,5,93,0,0,268,269,6,16,16,0,269,38,1,0,0,0,270,271,5,123,0,0,271,272,6,17,17,0,272,40,1,0,0,0,273,274,5,125,0,0,274,275,6,18,18,0,275,42,1,0,0,0,276,277,5,92,0,0,277,278,6,19,19,0,278,44,1,0,0,0,279,280,5,43,0,0,280,281,5,61,0,0,281,282,1,0,0,0,282,283,6,20,20,0,283,46,1,0,0,0,284,285,5,45,0,0,285,286,5,61,0,0,286,287,1,0,0,0,287,288,6,21,21,0,288,48,1,0,0,0,289,290,5,42,0,0,290,291,5,61,0,0,291,292,1,0,0,0,292,293,6,22,22,0,293,50,1,0,0,0,294,295,5,47,0,0,295,296,5,61,0,0,296,297,1,0,0,0,297,298,6,23,23,0,298,52,1,0,0,0,299,300,5,92,0,0,300,301,5,61,0,0,301,302,1,0,0,0,302,303,6,24,24,0,303,54,1,0,0,0,304,305,5,94,0,0,305,310,5,61,0,0,306,307,5,42,0,0,307,308,5,42,0,0,308,310,5,61,0,0,309,304,1,0,0,0,309,306,1,0,0,0,310,311,1,0,0,0,311,312,6,25,25,0,312,56,1,0,0,0,313,314,5,46,0,0,314,315,5,42,0,0,315,316,5,61,0,0,316,317,1,0,0,0,317,318,6,26,26,0,318,58,1,0,0,0,319,320,5,46,0,0,320,321,5,47,0,0,321,322,5,61,0,0,322,323,1,0,0,0,323,324,6,27,27,0,324,60,1,0,0,0,325,326,5,46,0,0,326,327,5,92,0,0,327,328,5,61,0,0,328,329,1,0,0,0,329,330,6,28,28,0,330,62,1,0,0,0,331,332,5,46,0,0,332,333,5,94,0,0,333,339,5,61,0,0,334,335,5,46,0,0,335,336,5,42,0,0,336,337,5,42,0,0,337,339,5,61,0,0,338,331,1,0,0,0,338,334,1,0,0,0,339,340,1,0,0,0,340,341,6,29,29,0,341,64,1,0,0,0,342,343,5,38,0,0,343,344,5,61,0,0,344,345,1,0,0,0,345,346,6,30,30,0,346,66,1,0,0,0,347,348,5,124,0,0,348,349,5,61,0,0,349,350,1,0,0,0,350,351,6,31,31,0,351,68,1,0,0,0,352,353,5,38,0,0,353,354,5,38,0,0,354,355,1,0,0,0,355,356,6,32,32,0,356,70,1,0,0,0,357,358,5,124,0,0,358,359,5,124,0,0,359,360,1,0,0,0,360,361,6,33,33,0,361,72,1,0,0,0,362,363,5,38,0,0,363,364,6,34,34,0,364,74,1,0,0,0,365,366,5,124,0,0,366,367,6,35,35,0,367,76,1,0,0,0,368,369,5,60,0,0,369,370,6,36,36,0,370,78,1,0,0,0,371,372,5,60,0,0,372,373,5,61,0,0,373,374,1,0,0,0,374,375,6,37,37,0,375,80,1,0,0,0,376,377,5,61,0,0,377,378,5,61,0,0,378,379,1,0,0,0,379,380,6,38,38,0,380,82,1,0,0,0,381,382,5,33,0,0,382,386,5,61,0,0,383,384,5,126,0,0,384,386,5,61,0,0,385,381,1,0,0,0,385,383,1,0,0,0,386,387,1,0,0,0,387,388,6,39,39,0,388,84,1,0,0,0,389,390,5,62,0,0,390,391,5,61,0,0,391,392,1,0,0,0,392,393,6,40,40,0,393,86,1,0,0,0,394,395,5,62,0,0,395,396,6,41,41,0,396,88,1,0,0,0,397,398,5,46,0,0,398,399,5,42,0,0,399,400,1,0,0,0,400,401,6,42,42,0,401,90,1,0,0,0,402,403,5,46,0,0,403,404,5,47,0,0,404,405,1,0,0,0,405,406,6,43,43,0,406,92,1,0,0,0,407,408,5,46,0,0,408,409,5,92,0,0,409,410,1,0,0,0,410,411,6,44,44,0,411,94,1,0,0,0,412,413,5,43,0,0,413,414,5,43,0,0,414,415,1,0,0,0,415,416,6,45,45,0,416,96,1,0,0,0,417,418,5,45,0,0,418,419,5,45,0,0,419,420,1,0,0,0,420,421,6,46,46,0,421,98,1,0,0,0,422,426,5,94,0,0,423,424,5,42,0,0,424,426,5,42,0,0,425,422,1,0,0,0,425,423,1,0,0,0,426,427,1,0,0,0,427,428,6,47,47,0,428,100,1,0,0,0,429,430,5,46,0,0,430,435,5,94,0,0,431,432,5,46,0,0,432,433,5,42,0,0,433,435,5,42,0,0,434,429,1,0,0,0,434,431,1,0,0,0,435,436,1,0,0,0,436,437,6,48,48,0,437,102,1,0,0,0,438,439,5,46,0,0,439,440,5,39,0,0,440,441,1,0,0,0,441,442,6,49,49,0,442,104,1,0,0,0,443,444,5,39,0,0,444,445,6,50,50,0,445,106,1,0,0,0,446,447,5,34,0,0,447,448,6,51,51,0,448,108,1,0,0,0,449,450,3,199,97,0,450,451,6,52,52,0,451,110,1,0,0,0,452,454,3,203,99,0,453,455,7,0,0,0,454,453,1,0,0,0,454,455,1,0,0,0,455,456,1,0,0,0,456,457,6,53,53,0,457,112,1,0,0,0,458,459,3,207,101,0,459,460,5,46,0,0,460,461,7,1,0,0,461,462,6,54,54,0,462,114,1,0,0,0,463,464,5,46,0,0,464,465,5,46,0,0,465,466,5,46,0,0,466,470,1,0,0,0,467,469,8,2,0,0,468,467,1,0,0,0,469,472,1,0,0,0,470,468,1,0,0,0,470,471,1,0,0,0,471,473,1,0,0,0,472,470,1,0,0,0,473,474,3,195,95,0,474,475,6,55,55,0,475,116,1,0,0,0,476,491,3,197,96,0,477,478,5,46,0,0,478,479,5,46,0,0,479,480,5,46,0,0,480,484,1,0,0,0,481,483,8,2,0,0,482,481,1,0,0,0,483,486,1,0,0,0,484,482,1,0,0,0,484,485,1,0,0,0,485,487,1,0,0,0,486,484,1,0,0,0,487,489,3,195,95,0,488,490,3,197,96,0,489,488,1,0,0,0,489,490,1,0,0,0,490,492,1,0,0,0,491,477,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,6,56,56,0,494,118,1,0,0,0,495,496,3,195,95,0,496,497,6,57,57,0,497,120,1,0,0,0,498,500,4,58,0,0,499,501,3,197,96,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,3,193,94,0,503,505,5,123,0,0,504,506,3,197,96,0,505,504,1,0,0,0,505,506,1,0,0,0,506,507,1,0,0,0,507,508,3,195,95,0,508,509,6,58,58,0,509,122,1,0,0,0,510,514,3,193,94,0,511,513,8,2,0,0,512,511,1,0,0,0,513,516,1,0,0,0,514,512,1,0,0,0,514,515,1,0,0,0,515,522,1,0,0,0,516,514,1,0,0,0,517,518,3,195,95,0,518,519,6,59,59,0,519,523,1,0,0,0,520,521,5,0,0,1,521,523,6,59,60,0,522,517,1,0,0,0,522,520,1,0,0,0,523,124,1,0,0,0,524,525,9,0,0,0,525,126,1,0,0,0,526,528,8,3,0,0,527,526,1,0,0,0,528,529,1,0,0,0,529,527,1,0,0,0,529,530,1,0,0,0,530,531,1,0,0,0,531,532,6,61,61,0,532,128,1,0,0,0,533,534,3,195,95,0,534,535,6,62,62,0,535,130,1,0,0,0,536,537,5,39,0,0,537,538,5,39,0,0,538,539,1,0,0,0,539,540,6,63,63,0,540,132,1,0,0,0,541,542,5,39,0,0,542,543,6,64,64,0,543,134,1,0,0,0,544,546,8,4,0,0,545,544,1,0,0,0,546,547,1,0,0,0,547,545,1,0,0,0,547,548,1,0,0,0,548,549,1,0,0,0,549,550,6,65,65,0,550,136,1,0,0,0,551,552,3,195,95,0,552,553,6,66,66,0,553,138,1,0,0,0,554,555,5,34,0,0,555,556,5,34,0,0,556,557,1,0,0,0,557,558,6,67,67,0,558,140,1,0,0,0,559,560,5,92,0,0,560,561,7,5,0,0,561,562,6,68,68,0,562,142,1,0,0,0,563,564,5,92,0,0,564,565,9,0,0,0,565,566,6,69,69,0,566,144,1,0,0,0,567,568,5,92,0,0,568,570,7,6,0,0,569,571,7,6,0,0,570,569,1,0,0,0,570,571,1,0,0,0,571,573,1,0,0,0,572,574,7,6,0,0,573,572,1,0,0,0,573,574,1,0,0,0,574,575,1,0,0,0,575,576,6,70,70,0,576,146,1,0,0,0,577,578,5,92,0,0,578,579,5,120,0,0,579,581,7,7,0,0,580,582,7,7,0,0,581,580,1,0,0,0,581,582,1,0,0,0,582,583,1,0,0,0,583,584,6,71,71,0,584,148,1,0,0,0,585,586,5,92,0,0,586,587,5,117,0,0,587,589,7,7,0,0,588,590,7,7,0,0,589,588,1,0,0,0,589,590,1,0,0,0,590,592,1,0,0,0,591,593,7,7,0,0,592,591,1,0,0,0,592,593,1,0,0,0,593,595,1,0,0,0,594,596,7,7,0,0,595,594,1,0,0,0,595,596,1,0,0,0,596,597,1,0,0,0,597,598,6,72,72,0,598,150,1,0,0,0,599,600,5,34,0,0,600,601,6,73,73,0,601,152,1,0,0,0,602,604,4,74,1,0,603,605,3,197,96,0,604,603,1,0,0,0,604,605,1,0,0,0,605,606,1,0,0,0,606,607,3,193,94,0,607,609,5,123,0,0,608,610,3,197,96,0,609,608,1,0,0,0,609,610,1,0,0,0,610,611,1,0,0,0,611,612,3,195,95,0,612,613,6,74,74,0,613,154,1,0,0,0,614,616,4,75,2,0,615,617,3,197,96,0,616,615,1,0,0,0,616,617,1,0,0,0,617,618,1,0,0,0,618,619,3,193,94,0,619,621,5,125,0,0,620,622,3,197,96,0,621,620,1,0,0,0,621,622,1,0,0,0,622,624,1,0,0,0,623,625,3,195,95,0,624,623,1,0,0,0,624,625,1,0,0,0,625,626,1,0,0,0,626,627,6,75,75,0,627,156,1,0,0,0,628,630,9,0,0,0,629,628,1,0,0,0,630,633,1,0,0,0,631,632,1,0,0,0,631,629,1,0,0,0,632,634,1,0,0,0,633,631,1,0,0,0,634,635,3,195,95,0,635,636,1,0,0,0,636,637,6,76,76,0,637,158,1,0,0,0,638,640,8,2,0,0,639,638,1,0,0,0,640,643,1,0,0,0,641,639,1,0,0,0,641,642,1,0,0,0,642,644,1,0,0,0,643,641,1,0,0,0,644,645,5,0,0,1,645,646,6,77,77,0,646,160,1,0,0,0,647,648,5,46,0,0,648,649,5,46,0,0,649,650,5,46,0,0,650,654,1,0,0,0,651,653,8,2,0,0,652,651,1,0,0,0,653,656,1,0,0,0,654,652,1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656,654,1,0,0,0,657,658,3,195,95,0,658,659,6,78,78,0,659,162,1,0,0,0,660,662,4,79,3,0,661,663,3,197,96,0,662,661,1,0,0,0,662,663,1,0,0,0,663,664,1,0,0,0,664,665,3,193,94,0,665,667,5,123,0,0,666,668,3,197,96,0,667,666,1,0,0,0,667,668,1,0,0,0,668,669,1,0,0,0,669,670,3,195,95,0,670,671,6,79,79,0,671,164,1,0,0,0,672,673,4,80,4,0,673,677,3,193,94,0,674,676,8,2,0,0,675,674,1,0,0,0,676,679,1,0,0,0,677,675,1,0,0,0,677,678,1,0,0,0,678,680,1,0,0,0,679,677,1,0,0,0,680,681,3,195,95,0,681,682,1,0,0,0,682,683,6,80,76,0,683,166,1,0,0,0,684,685,4,81,5,0,685,686,3,195,95,0,686,687,1,0,0,0,687,688,6,81,76,0,688,168,1,0,0,0,689,690,3,197,96,0,690,691,1,0,0,0,691,692,6,82,76,0,692,170,1,0,0,0,693,694,5,34,0,0,694,695,4,83,6,0,695,696,6,83,80,0,696,172,1,0,0,0,697,698,5,39,0,0,698,699,4,84,7,0,699,700,6,84,81,0,700,174,1,0,0,0,701,702,5,34,0,0,702,706,4,85,8,0,703,705,8,8,0,0,704,703,1,0,0,0,705,708,1,0,0,0,706,704,1,0,0,0,706,707,1,0,0,0,707,709,1,0,0,0,708,706,1,0,0,0,709,710,6,85,82,0,710,176,1,0,0,0,711,712,5,39,0,0,712,716,4,86,9,0,713,715,8,8,0,0,714,713,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,719,1,0,0,0,718,716,1,0,0,0,719,720,6,86,83,0,720,178,1,0,0,0,721,722,5,34,0,0,722,723,4,87,10,0,723,724,6,87,84,0,724,180,1,0,0,0,725,726,5,39,0,0,726,727,4,88,11,0,727,728,6,88,85,0,728,182,1,0,0,0,729,733,3,193,94,0,730,732,8,2,0,0,731,730,1,0,0,0,732,735,1,0,0,0,733,731,1,0,0,0,733,734,1,0,0,0,734,736,1,0,0,0,735,733,1,0,0,0,736,737,6,89,76,0,737,184,1,0,0,0,738,739,7,9,0,0,739,740,6,90,86,0,740,186,1,0,0,0,741,742,3,195,95,0,742,743,6,91,87,0,743,188,1,0,0,0,744,745,5,0,0,1,745,746,6,92,88,0,746,190,1,0,0,0,747,751,8,10,0,0,748,750,8,11,0,0,749,748,1,0,0,0,750,753,1,0,0,0,751,749,1,0,0,0,751,752,1,0,0,0,752,754,1,0,0,0,753,751,1,0,0,0,754,755,6,93,89,0,755,192,1,0,0,0,756,757,7,12,0,0,757,194,1,0,0,0,758,764,5,13,0,0,759,761,5,13,0,0,760,759,1,0,0,0,760,761,1,0,0,0,761,762,1,0,0,0,762,764,5,10,0,0,763,758,1,0,0,0,763,760,1,0,0,0,764,196,1,0,0,0,765,767,7,13,0,0,766,765,1,0,0,0,767,768,1,0,0,0,768,766,1,0,0,0,768,769,1,0,0,0,769,198,1,0,0,0,770,774,7,14,0,0,771,773,7,15,0,0,772,771,1,0,0,0,773,776,1,0,0,0,774,772,1,0,0,0,774,775,1,0,0,0,775,200,1,0,0,0,776,774,1,0,0,0,777,788,3,199,97,0,778,780,3,197,96,0,779,778,1,0,0,0,779,780,1,0,0,0,780,781,1,0,0,0,781,783,5,46,0,0,782,784,3,197,96,0,783,782,1,0,0,0,783,784,1,0,0,0,784,785,1,0,0,0,785,787,3,199,97,0,786,779,1,0,0,0,787,790,1,0,0,0,788,786,1,0,0,0,788,789,1,0,0,0,789,202,1,0,0,0,790,788,1,0,0,0,791,793,3,209,102,0,792,794,5,46,0,0,793,792,1,0,0,0,793,794,1,0,0,0,794,801,1,0,0,0,795,797,3,209,102,0,796,795,1,0,0,0,796,797,1,0,0,0,797,798,1,0,0,0,798,799,5,46,0,0,799,801,3,209,102,0,800,791,1,0,0,0,800,796,1,0,0,0,801,804,1,0,0,0,802,803,7,16,0,0,803,805,3,217,106,0,804,802,1,0,0,0,804,805,1,0,0,0,805,858,1,0,0,0,806,807,5,48,0,0,807,817,7,17,0,0,808,810,3,211,103,0,809,811,5,46,0,0,810,809,1,0,0,0,810,811,1,0,0,0,811,818,1,0,0,0,812,814,3,211,103,0,813,812,1,0,0,0,813,814,1,0,0,0,814,815,1,0,0,0,815,816,5,46,0,0,816,818,3,211,103,0,817,808,1,0,0,0,817,813,1,0,0,0,818,821,1,0,0,0,819,820,7,18,0,0,820,822,3,217,106,0,821,819,1,0,0,0,821,822,1,0,0,0,822,858,1,0,0,0,823,824,5,48,0,0,824,834,7,19,0,0,825,827,3,213,104,0,826,828,5,46,0,0,827,826,1,0,0,0,827,828,1,0,0,0,828,835,1,0,0,0,829,831,3,213,104,0,830,829,1,0,0,0,830,831,1,0,0,0,831,832,1,0,0,0,832,833,5,46,0,0,833,835,3,213,104,0,834,825,1,0,0,0,834,830,1,0,0,0,835,838,1,0,0,0,836,837,7,18,0,0,837,839,3,217,106,0,838,836,1,0,0,0,838,839,1,0,0,0,839,858,1,0,0,0,840,841,5,48,0,0,841,851,7,20,0,0,842,844,3,215,105,0,843,845,5,46,0,0,844,843,1,0,0,0,844,845,1,0,0,0,845,852,1,0,0,0,846,848,3,215,105,0,847,846,1,0,0,0,847,848,1,0,0,0,848,849,1,0,0,0,849,850,5,46,0,0,850,852,3,215,105,0,851,842,1,0,0,0,851,847,1,0,0,0,852,855,1,0,0,0,853,854,7,18,0,0,854,856,3,217,106,0,855,853,1,0,0,0,855,856,1,0,0,0,856,858,1,0,0,0,857,800,1,0,0,0,857,806,1,0,0,0,857,823,1,0,0,0,857,840,1,0,0,0,858,204,1,0,0,0,859,860,3,207,101,0,860,868,7,21,0,0,861,869,5,56,0,0,862,863,5,49,0,0,863,869,5,54,0,0,864,865,5,51,0,0,865,869,5,50,0,0,866,867,5,54,0,0,867,869,5,52,0,0,868,861,1,0,0,0,868,862,1,0,0,0,868,864,1,0,0,0,868,866,1,0,0,0,869,206,1,0,0,0,870,881,3,209,102,0,871,878,5,48,0,0,872,873,7,17,0,0,873,879,3,211,103,0,874,875,7,19,0,0,875,879,3,213,104,0,876,877,7,20,0,0,877,879,3,215,105,0,878,872,1,0,0,0,878,874,1,0,0,0,878,876,1,0,0,0,879,881,1,0,0,0,880,870,1,0,0,0,880,871,1,0,0,0,881,208,1,0,0,0,882,889,7,22,0,0,883,885,5,95,0,0,884,883,1,0,0,0,884,885,1,0,0,0,885,886,1,0,0,0,886,888,7,22,0,0,887,884,1,0,0,0,888,891,1,0,0,0,889,887,1,0,0,0,889,890,1,0,0,0,890,210,1,0,0,0,891,889,1,0,0,0,892,899,7,23,0,0,893,895,5,95,0,0,894,893,1,0,0,0,894,895,1,0,0,0,895,896,1,0,0,0,896,898,7,23,0,0,897,894,1,0,0,0,898,901,1,0,0,0,899,897,1,0,0,0,899,900,1,0,0,0,900,212,1,0,0,0,901,899,1,0,0,0,902,909,7,6,0,0,903,905,5,95,0,0,904,903,1,0,0,0,904,905,1,0,0,0,905,906,1,0,0,0,906,908,7,6,0,0,907,904,1,0,0,0,908,911,1,0,0,0,909,907,1,0,0,0,909,910,1,0,0,0,910,214,1,0,0,0,911,909,1,0,0,0,912,919,7,7,0,0,913,915,5,95,0,0,914,913,1,0,0,0,914,915,1,0,0,0,915,916,1,0,0,0,916,918,7,7,0,0,917,914,1,0,0,0,918,921,1,0,0,0,919,917,1,0,0,0,919,920,1,0,0,0,920,216,1,0,0,0,921,919,1,0,0,0,922,924,7,24,0,0,923,922,1,0,0,0,923,924,1,0,0,0,924,925,1,0,0,0,925,926,3,209,102,0,926,218,1,0,0,0,78,0,1,2,3,4,309,338,385,425,434,454,470,484,489,491,500,505,514,522,529,547,570,573,581,589,592,595,604,609,616,621,624,631,641,654,662,667,677,706,716,733,751,760,763,768,774,779,783,788,793,796,800,804,810,813,817,821,827,830,834,838,844,847,851,855,857,868,878,880,884,889,894,899,904,909,914,919,923,90,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,58,58,1,59,59,1,59,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,1,74,74,1,75,75,6,0,0,1,77,76,1,78,77,1,79,78,1,83,79,1,84,80,1,85,81,1,86,82,1,87,83,1,88,84,1,90,85,1,91,86,1,92,87,1,93,88],MathJSLabLexer.DecisionsToDFA=MathJSLabLexer._ATN.decisionToState.map((e,t)=>new antlr4_1.DFA(e,t)),exports.default=MathJSLabLexer},6770(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Jump_commandContext=t.Spmd_worker_specContext=t.Spmd_commandContext=t.For_commandContext=t.Do_until_commandContext=t.While_commandContext=t.Loop_commandContext=t.Otherwise_caseContext=t.Switch_caseContext=t.Switch_case_listContext=t.Switch_commandContext=t.Else_clauseContext=t.Elseif_clauseContext=t.If_commandContext=t.Select_commandContext=t.Import_nameContext=t.Import_commandContext=t.Declaration_elementContext=t.DeclarationContext=t.CommandContext=t.Assign_listContext=t.Assign_lhsContext=t.ExpressionContext=t.Simple_exprContext=t.Colon_exprContext=t.Power_exprContext=t.Oper_exprContext=t.Arg_listContext=t.List_elementContext=t.Magic_tildeContext=t.Magic_colonContext=t.Primary_exprContext=t.Anon_fcn_handleContext=t.Meta_classContext=t.Fcn_handleContext=t.Matrix_rowContext=t.MatrixContext=t.ConstantContext=t.End_rangeContext=t.NumberContext=t.StringContext=t.Qualified_identifierContext=t.Qualified_identifier_partContext=t.IdentifierContext=t.Command_wordContext=t.Word_list_cmdContext=t.StatementContext=t.ListContext=t.Global_listContext=t.InputContext=void 0,t.SepContext=t.NlContext=t.Sep_no_nlContext=t.Arg_validation_nameContext=t.Arg_validationContext=t.Args_validation_listContext=t.Arguments_attribute_listContext=t.Arguments_blockContext=t.Arguments_block_listContext=t.Class_enumerationContext=t.Class_enumeration_listContext=t.Enumeration_sectionContext=t.Class_eventContext=t.Class_event_listContext=t.Events_sectionContext=t.Class_method_listContext=t.Class_methodContext=t.Methods_sectionContext=t.Class_propertyContext=t.Class_property_listContext=t.Properties_sectionContext=t.Class_sectionContext=t.Class_section_listContext=t.Class_superclass_listContext=t.Class_method_nameContext=t.Class_attributeContext=t.Class_attribute_listContext=t.Classdef_commandContext=t.Function_nameContext=t.FunctionContext=t.Return_listContext=t.Return_list_eltContext=t.Param_list_eltContext=t.Param_listContext=t.Unwind_cleanup_clauseContext=t.Unwind_commandContext=t.Catch_clauseContext=t.Try_commandContext=t.Except_commandContext=void 0;const n=r(3222),s=r(6109);class i extends n.Parser{get grammarFileName(){return"MathJSLabParser.g4"}get literalNames(){return i.literalNames}get symbolicNames(){return i.symbolicNames}get ruleNames(){return i.ruleNames}get serializedATN(){return i._serializedATN}createFailedPredicateException(e,t){return new n.FailedPredicateException(this,e,t)}markStatementRange(e,t){e.start={line:t.line,column:t.column},e.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}}markPreviousStatementOmitOutput(e,t){";"===(null==t?void 0:t[0])&&(e.list[e.list.length-1].omitOutput=!0)}constructor(e){super(e),this._interp=new n.ParserATNSimulator(this,i._ATN,i.DecisionsToDFA,new n.PredictionContextCache)}input(){let e,t=new a(this,this._ctx,this.state);this.enterRule(t,0,i.RULE_input);try{switch(this.state=190,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,2,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=179,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=178,this.sep()),this.state=181,this.match(i.EOF),t.node=null;break;case 2:this.enterOuterAlt(t,2),this.state=184,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=183,this.sep()),this.state=186,this.global_list(),this.state=187,this.match(i.EOF),t.node=t.global_list().node}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}global_list(){var e;let t,r=new o(this,this._ctx,this.state);this.enterRule(r,2,i.RULE_global_list);try{let i;for(this.enterOuterAlt(r,1),this.state=192,this.statement(),this.markStatementRange(r.statement(r.i).node,r.statement(r.i).start),r.node=s.AST.nodeListFirst(r.statement(r.i++).node),this.state=200,this._errHandler.sync(this),i=this._interp.adaptivePredict(this._input,3,this._ctx);2!==i&&i!==n.ATN.INVALID_ALT_NUMBER;)1===i&&(this.state=194,this.sep(),this.state=195,this.statement(),this.markStatementRange(r.statement(r.i).node,r.statement(r.i).start),this.markPreviousStatementOmitOutput(r.node,r.sep(r.i-1).getText()),r.node=s.AST.appendNodeList(r.node,r.statement(r.i++).node)),this.state=202,this._errHandler.sync(this),i=this._interp.adaptivePredict(this._input,3,this._ctx);this.state=204,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=203,this.sep()),this.markPreviousStatementOmitOutput(r.node,null===(e=r.sep(r.i-1))||void 0===e?void 0:e.getText())}catch(e){if(!(e instanceof n.RecognitionException))throw e;r.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return r}list(){var e;let t=new l(this,this._ctx,this.state);this.enterRule(t,4,i.RULE_list);try{let r;for(this.enterOuterAlt(t,1),this.state=208,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),t.node=s.AST.nodeListFirst(t.statement(t.i++).node),this.state=216,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,5,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=210,this.sep(),this.state=211,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),this.markPreviousStatementOmitOutput(t.node,t.sep(t.i-1).getText()),t.node=s.AST.appendNodeList(t.node,t.statement(t.i++).node)),this.state=218,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,5,this._ctx);this.state=220,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,6,this._ctx)&&(this.state=219,this.sep()),this.markPreviousStatementOmitOutput(t.node,null===(e=t.sep(t.i-1))||void 0===e?void 0:e.getText())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}statement(){let e=new c(this,this._ctx,this.state);this.enterRule(e,6,i.RULE_statement);try{switch(this.state=233,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,7,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=224,this.command(),e.node=e.command().node;break;case 2:this.enterOuterAlt(e,2),this.state=227,this.word_list_cmd(),e.node=e.word_list_cmd().node;break;case 3:this.enterOuterAlt(e,3),this.state=230,this.expression(),e.node=e.expression().node}}catch(t){if(!(t instanceof n.RecognitionException))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 u(this,this._ctx,this.state);this.enterRule(t,8,i.RULE_word_list_cmd);try{for(this.enterOuterAlt(t,1),this.state=235,this.identifier(),this.state=236,this.command_word(),t.node=s.AST.nodeListFirst(t.command_word(t.i++).node),this.state=243,this._errHandler.sync(this),e=this._input.LA(1);46===e||142===e;)this.state=238,this.command_word(),s.AST.appendNodeList(t.node,t.command_word(t.i++).node),this.state=245,this._errHandler.sync(this),e=this._input.LA(1);t.node=s.AST.nodeCmdWList(t.identifier().node,t.node)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}command_word(){let e=new h(this,this._ctx,this.state);this.enterRule(e,10,i.RULE_command_word);try{this.enterOuterAlt(e,1),this.state=248,this.string_(),e.node=e.string_().node}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}identifier(){let e=new d(this,this._ctx,this.state);this.enterRule(e,12,i.RULE_identifier);try{switch(this.state=261,this._errHandler.sync(this),this._input.LA(1)){case 101:this.enterOuterAlt(e,1),this.state=251,this.match(i.IDENTIFIER),e.node=s.AST.nodeIdentifier(e.IDENTIFIER().getText());break;case 39:this.enterOuterAlt(e,2),this.state=253,this.match(i.PROPERTIES),e.node=s.AST.nodeIdentifier("properties");break;case 43:this.enterOuterAlt(e,3),this.state=255,this.match(i.METHODS),e.node=s.AST.nodeIdentifier("methods");break;case 41:this.enterOuterAlt(e,4),this.state=257,this.match(i.EVENTS),e.node=s.AST.nodeIdentifier("events");break;case 37:this.enterOuterAlt(e,5),this.state=259,this.match(i.ENUMERATION),e.node=s.AST.nodeIdentifier("enumeration");break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}qualified_identifier_part(){let e=new m(this,this._ctx,this.state);this.enterRule(e,14,i.RULE_qualified_identifier_part);try{switch(this.state=268,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=263,this.identifier(),e.text=e.identifier().node.id;break;case 6:this.enterOuterAlt(e,2),this.state=266,this.match(i.END),e.text="end";break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}qualified_identifier(){let e=new p(this,this._ctx,this.state);this.enterRule(e,16,i.RULE_qualified_identifier);try{let t;for(this.enterOuterAlt(e,1),this.state=270,this.qualified_identifier_part(),e.node=s.AST.nodeIdentifier(e.qualified_identifier_part(0).text),this.state=278,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,11,this._ctx);2!==t&&t!==n.ATN.INVALID_ALT_NUMBER;)1===t&&(this.state=272,this.match(i.DOT),this.state=273,this.qualified_identifier_part(),e.node=s.AST.nodeIdentifier(e.node.id+"."+e.qualified_identifier_part(e.i++).text)),this.state=280,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,11,this._ctx)}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}string_(){let e=new f(this,this._ctx,this.state);this.enterRule(e,18,i.RULE_string);try{switch(this.state=285,this._errHandler.sync(this),this._input.LA(1)){case 46:this.enterOuterAlt(e,1);{this.state=281,this.match(i.STRING);const t=e.STRING().getText();e.node=s.AST.nodeString(t.substring(1,t.length-1),t[0])}break;case 142:this.enterOuterAlt(e,2),this.state=283,this.match(i.UNQUOTED_STRING),e.node=s.AST.nodeString(e.UNQUOTED_STRING().getText());break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}number_(){let e=new g(this,this._ctx,this.state);this.enterRule(e,20,i.RULE_number);try{this.enterOuterAlt(e,1),this.state=287,this.match(i.FLOAT_NUMBER),e.node=s.AST.nodeNumber(e.FLOAT_NUMBER().getText())}catch(t){if(!(t instanceof n.RecognitionException))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 y(this,this._ctx,this.state);this.enterRule(e,22,i.RULE_end_range);try{this.enterOuterAlt(e,1),this.state=290,this.match(i.ENDRANGE),e.node=s.AST.nodeEndRange()}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}constant(){let e=new x(this,this._ctx,this.state);this.enterRule(e,24,i.RULE_constant);try{switch(this.state=302,this._errHandler.sync(this),this._input.LA(1)){case 102:this.enterOuterAlt(e,1),this.state=293,this.number_(),e.node=e.number_().node;break;case 46:case 142:this.enterOuterAlt(e,2),this.state=296,this.string_(),e.node=e.string_().node;break;case 7:this.enterOuterAlt(e,3),this.state=299,this.end_range(),e.node=e.end_range().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))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 C(this,this._ctx,this.state);this.enterRule(t,26,i.RULE_matrix);try{let r;switch(this.state=366,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,28,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=304,this.match(i.LBRACKET),this.state=305,this.match(i.RBRACKET),t.node=s.AST.emptyArray();break;case 2:for(this.enterOuterAlt(t,2),this.state=307,this.match(i.LBRACKET),this.state=312,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=310,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=308,this.match(i.SEMICOLON);break;case 106:this.state=309,this.nl();break;default:throw new n.NoViableAltException(this)}this.state=314,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx)}for(this.state=316,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736768853||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=315,this.matrix_row()),t.node=s.AST.nodeFirstRow(t.matrix_row(t.i)?t.matrix_row(t.i++).node:null),this.state=331,this._errHandler.sync(this),e=this._input.LA(1);55===e||106===e;){this.state=321,this._errHandler.sync(this),r=1;do{if(1!==r)throw new n.NoViableAltException(this);switch(this.state=321,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=319,this.match(i.SEMICOLON);break;case 106:this.state=320,this.nl();break;default:throw new n.NoViableAltException(this)}this.state=323,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,18,this._ctx)}while(2!==r&&r!==n.ATN.INVALID_ALT_NUMBER);this.state=326,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736768853||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=325,this.matrix_row()),t.node=s.AST.nodeAppendRow(t.node,t.matrix_row(t.i)?t.matrix_row(t.i++).node:null),this.state=333,this._errHandler.sync(this),e=this._input.LA(1)}this.state=334,this.match(i.RBRACKET);break;case 3:this.enterOuterAlt(t,3),this.state=335,this.match(i.LCURLYBR),this.state=336,this.match(i.RCURLYBR),t.node=s.AST.emptyArray(!0);break;case 4:for(this.enterOuterAlt(t,4),this.state=338,this.match(i.LCURLYBR),this.state=343,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=341,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=339,this.match(i.SEMICOLON);break;case 106:this.state=340,this.nl();break;default:throw new n.NoViableAltException(this)}this.state=345,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx)}for(this.state=347,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736768853||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=346,this.matrix_row()),t.node=s.AST.nodeFirstRow(t.matrix_row(t.i)?t.matrix_row(t.i++).node:null,!0),this.state=362,this._errHandler.sync(this),e=this._input.LA(1);55===e||106===e;){this.state=352,this._errHandler.sync(this),r=1;do{if(1!==r)throw new n.NoViableAltException(this);switch(this.state=352,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=350,this.match(i.SEMICOLON);break;case 106:this.state=351,this.nl();break;default:throw new n.NoViableAltException(this)}this.state=354,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,25,this._ctx)}while(2!==r&&r!==n.ATN.INVALID_ALT_NUMBER);this.state=357,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736768853||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=356,this.matrix_row()),t.node=s.AST.nodeAppendRow(t.node,t.matrix_row(t.i)?t.matrix_row(t.i++).node:null),this.state=364,this._errHandler.sync(this),e=this._input.LA(1)}this.state=365,this.match(i.RCURLYBR)}}catch(e){if(!(e instanceof n.RecognitionException))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 E(this,this._ctx,this.state);this.enterRule(t,28,i.RULE_matrix_row);try{let r;switch(this.state=387,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,32,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=368,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=null;break;case 2:for(this.enterOuterAlt(t,2),this.state=371,this._errHandler.sync(this),e=this._input.LA(1),45!==e&&56!==e||(this.state=370,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())),this.state=373,this.list_element(),t.node=s.AST.nodeListFirst(t.list_element(t.i++).node),this.state=381,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=375,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=376,this.list_element(),t.node=s.AST.appendNodeList(t.node,t.list_element(t.i++).node)),this.state=383,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);this.state=385,this._errHandler.sync(this),e=this._input.LA(1),45!==e&&56!==e||(this.state=384,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}}catch(e){if(!(e instanceof n.RecognitionException))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 v(this,this._ctx,this.state);this.enterRule(e,30,i.RULE_fcn_handle);try{this.enterOuterAlt(e,1),this.state=389,this.match(i.COMMAT),this.state=390,this.qualified_identifier(),e.node=s.AST.nodeFunctionHandle(e.qualified_identifier().node)}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}meta_class(){let e=new A(this,this._ctx,this.state);this.enterRule(e,32,i.RULE_meta_class);try{this.enterOuterAlt(e,1),this.state=393,this.match(i.QUESTION),this.state=394,this.qualified_identifier(),e.node=s.AST.nodeMetaClass(e.qualified_identifier().node)}catch(t){if(!(t instanceof n.RecognitionException))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 S(this,this._ctx,this.state);this.enterRule(e,34,i.RULE_anon_fcn_handle);try{this.enterOuterAlt(e,1),this.state=397,this.match(i.COMMAT),this.state=398,this.param_list(),this.state=399,this.expression(),e.node=s.AST.nodeFunctionHandle(null,e.param_list().node,e.expression().node)}catch(t){if(!(t instanceof n.RecognitionException))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 _(this,this._ctx,this.state);this.enterRule(e,36,i.RULE_primary_expr);try{switch(this.state=424,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=402,this.identifier(),e.node=e.identifier().node;break;case 3:this.enterOuterAlt(e,2),this.state=405,this.match(i.IMPORT),e.node=s.AST.nodeImport();break;case 7:case 46:case 102:case 142:this.enterOuterAlt(e,3),this.state=407,this.constant(),e.node=e.constant().node;break;case 60:this.enterOuterAlt(e,4),this.state=410,this.fcn_handle(),e.node=e.fcn_handle().node;break;case 61:this.enterOuterAlt(e,5),this.state=413,this.meta_class(),e.node=e.meta_class().node;break;case 64:case 66:this.enterOuterAlt(e,6),this.state=416,this.matrix(),e.node=e.matrix().node;break;case 62:this.enterOuterAlt(e,7),this.state=419,this.match(i.LPAREN),this.state=420,this.expression(),this.state=421,this.match(i.RPAREN),e.node=s.AST.nodeOperation("()",e.expression().node);break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))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 b(this,this._ctx,this.state);this.enterRule(e,38,i.RULE_magic_colon);try{this.enterOuterAlt(e,1),this.state=426,this.match(i.COLON),e.node=s.AST.nodeColon()}catch(t){if(!(t instanceof n.RecognitionException))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 T(this,this._ctx,this.state);this.enterRule(e,40,i.RULE_magic_tilde);try{this.enterOuterAlt(e,1),this.state=429,this.match(i.TILDE),e.node=s.AST.nodeIgnoredTarget()}catch(t){if(!(t instanceof n.RecognitionException))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 M(this,this._ctx,this.state);this.enterRule(e,42,i.RULE_list_element);try{switch(this.state=441,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,34,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=432,this.expression(),e.node=e.expression().node;break;case 2:this.enterOuterAlt(e,2),this.state=435,this.magic_colon(),e.node=e.magic_colon().node;break;case 3:this.enterOuterAlt(e,3),this.state=438,this.magic_tilde(),e.node=e.magic_tilde().node}}catch(t){if(!(t instanceof n.RecognitionException))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 N(this,this._ctx,this.state);this.enterRule(t,44,i.RULE_arg_list);try{for(this.enterOuterAlt(t,1),this.state=443,this.list_element(),t.node=s.AST.nodeListFirst(t.list_element(t.i++).node),this.state=451,this._errHandler.sync(this),e=this._input.LA(1);56===e;)this.state=445,this.match(i.COMMA),this.state=446,this.list_element(),t.node=s.AST.appendNodeList(t.node,t.list_element(t.i++).node),this.state=453,this._errHandler.sync(this),e=this._input.LA(1)}catch(e){if(!(e instanceof n.RecognitionException))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,a=this.state,o=new I(this,this._ctx,a),l=o,c=46;this.enterRecursionRule(o,46,i.RULE_oper_expr,e);try{let e;switch(this.enterOuterAlt(o,1),this.state=466,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=455,this.primary_expr(),o.node=o.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=458,o._op=this._input.LT(1),t=this._input.LA(1),49!==t&&50!==t&&94!==t&&95!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=459,this.oper_expr(4),o.node=s.AST.nodeOperation(o._op.text+"_",o.oper_expr(0).node);break;case 58:case 59:this.state=462,o._op=this._input.LT(1),t=this._input.LA(1),58!==t&&59!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=463,this.oper_expr(3),o.node=s.AST.nodeOperation(o._op.text,o.oper_expr(0).node);break;default:throw new n.NoViableAltException(this)}for(this._ctx.stop=this._input.LT(-1),this.state=527,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,41,this._ctx);2!==e&&e!==n.ATN.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=525,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,40,this._ctx)){case 1:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=468,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=469,o._op=this._input.LT(1),t=this._input.LA(1),!(t-51&-32)&&1<<t-51&131075||!(t-91&-32)&&1<<t-91&7?(this._errHandler.reportMatch(this),this.consume()):o._op=this._errHandler.recoverInline(this),this.state=470,this.oper_expr(3),o.node=s.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.oper_expr(1).node);break;case 2:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=473,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=474,o._op=this._input.LT(1),t=this._input.LA(1),49!==t&&50!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=475,this.oper_expr(2),o.node=s.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.oper_expr(1).node);break;case 3:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=478,!this.precpred(this._ctx,12))throw this.createFailedPredicateException("this.precpred(this._ctx, 12)");this.state=479,o._op=this._input.LT(1),t=this._input.LA(1),94!==t&&95!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=s.AST.nodeOperation("_"+o._op.text,o.oper_expr(0).node);break;case 4:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=481,!this.precpred(this._ctx,11))throw this.createFailedPredicateException("this.precpred(this._ctx, 11)");this.state=482,this.match(i.LPAREN),this.state=484,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=483,this.arg_list()),this.state=486,this.match(i.RPAREN),o.node=s.AST.nodeIndexExpr(o.oper_expr(0).node,o.arg_list()?o.arg_list().node:null,"()");break;case 5:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=488,!this.precpred(this._ctx,10))throw this.createFailedPredicateException("this.precpred(this._ctx, 10)");this.state=489,this.match(i.LCURLYBR),this.state=491,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=490,this.arg_list()),this.state=493,this.match(i.RCURLYBR),o.node=s.AST.nodeIndexExpr(o.oper_expr(0).node,o.arg_list()?o.arg_list().node:null,"{}");break;case 6:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=495,!this.precpred(this._ctx,9))throw this.createFailedPredicateException("this.precpred(this._ctx, 9)");this.state=496,this.match(i.COMMAT),this.state=497,this.qualified_identifier(),this.state=498,this.match(i.LPAREN),this.state=500,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=499,this.arg_list()),this.state=502,this.match(i.RPAREN),o.node=s.AST.nodeSuperclassConstructor(o.oper_expr(0).node,o.qualified_identifier().node,o.arg_list()?o.arg_list().node:null);break;case 7:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=505,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=506,o._op=this._input.LT(1),t=this._input.LA(1),98!==t&&99!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=s.AST.nodeOperation(o._op.text,o.oper_expr(0).node);break;case 8:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=508,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=509,this.match(i.DOT),this.state=510,this.qualified_identifier_part(),o.node=s.AST.nodeIndirectRef(o.oper_expr(0).node,o.qualified_identifier_part().text);break;case 9:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=513,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=514,this.match(i.DOT),this.state=515,this.match(i.LPAREN),this.state=516,this.expression(),this.state=517,this.match(i.RPAREN),o.node=s.AST.nodeIndirectRef(o.oper_expr(0).node,o.expression().node);break;case 10:if(o=new I(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_oper_expr),this.state=520,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=521,o._op=this._input.LT(1),t=this._input.LA(1),96!==t&&97!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=522,this.power_expr(0),o.node=s.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.power_expr().node)}this.state=529,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,41,this._ctx)}}catch(e){if(!(e instanceof n.RecognitionException))throw e;o.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return o}power_expr(e){void 0===e&&(e=0);let t,r=this._ctx,a=this.state,o=new L(this,this._ctx,a),l=o,c=48;this.enterRecursionRule(o,48,i.RULE_power_expr,e);try{let e;switch(this.enterOuterAlt(o,1),this.state=542,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=531,this.primary_expr(),o.node=o.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=534,o._op=this._input.LT(1),t=this._input.LA(1),49!==t&&50!==t&&94!==t&&95!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=535,this.power_expr(2),o.node=s.AST.nodeOperation(o._op.text+"_",o.power_expr().node);break;case 58:case 59:this.state=538,o._op=this._input.LT(1),t=this._input.LA(1),58!==t&&59!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=539,this.power_expr(1),o.node=s.AST.nodeOperation(o._op.text,o.power_expr().node);break;default:throw new n.NoViableAltException(this)}for(this._ctx.stop=this._input.LT(-1),this.state=585,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,47,this._ctx);2!==e&&e!==n.ATN.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=583,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,46,this._ctx)){case 1:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=544,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=545,o._op=this._input.LT(1),t=this._input.LA(1),94!==t&&95!==t?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=s.AST.nodeOperation("_"+o._op.text,o.power_expr().node);break;case 2:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=547,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=548,this.match(i.LPAREN),this.state=550,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=549,this.arg_list()),this.state=552,this.match(i.RPAREN),o.node=s.AST.nodeIndexExpr(o.power_expr().node,o.arg_list()?o.arg_list().node:null,"()");break;case 3:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=554,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=555,this.match(i.LCURLYBR),this.state=557,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=556,this.arg_list()),this.state=559,this.match(i.RCURLYBR),o.node=s.AST.nodeIndexExpr(o.power_expr().node,o.arg_list()?o.arg_list().node:null,"{}");break;case 4:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=561,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=562,this.match(i.COMMAT),this.state=563,this.qualified_identifier(),this.state=564,this.match(i.LPAREN),this.state=566,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=565,this.arg_list()),this.state=568,this.match(i.RPAREN),o.node=s.AST.nodeSuperclassConstructor(o.power_expr().node,o.qualified_identifier().node,o.arg_list()?o.arg_list().node:null);break;case 5:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=571,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=572,this.match(i.DOT),this.state=573,this.qualified_identifier_part(),o.node=s.AST.nodeIndirectRef(o.power_expr().node,o.qualified_identifier_part().text);break;case 6:if(o=new L(this,r,a),this.pushNewRecursionContext(o,c,i.RULE_power_expr),this.state=576,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=577,this.match(i.DOT),this.state=578,this.match(i.LPAREN),this.state=579,this.expression(),this.state=580,this.match(i.RPAREN),o.node=s.AST.nodeIndirectRef(o.power_expr().node,o.expression().node)}this.state=587,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,47,this._ctx)}}catch(e){if(!(e instanceof n.RecognitionException))throw e;o.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return o}colon_expr(){let e=new w(this,this._ctx,this.state);this.enterRule(e,50,i.RULE_colon_expr);try{this.enterOuterAlt(e,1),this.state=588,this.oper_expr(0),this.state=589,this.match(i.COLON),this.state=590,this.oper_expr(0),this.state=593,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,48,this._ctx)&&(this.state=591,this.match(i.COLON),this.state=592,this.oper_expr(0)),e.oper_expr(2)?e.node=s.AST.nodeRange(e.oper_expr(0).node,e.oper_expr(2).node,e.oper_expr(1).node):e.node=s.AST.nodeRange(e.oper_expr(0).node,e.oper_expr(1).node)}catch(t){if(!(t instanceof n.RecognitionException))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,a=this.state,o=new O(this,this._ctx,a),l=o;this.enterRecursionRule(o,52,i.RULE_simple_expr,e);try{let e;switch(this.enterOuterAlt(o,1),this.state=604,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,49,this._ctx)){case 1:this.state=598,this.oper_expr(0),o.node=o.oper_expr().node;break;case 2:this.state=601,this.colon_expr(),o.node=o.colon_expr().node}for(this._ctx.stop=this._input.LT(-1),this.state=633,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,51,this._ctx);2!==e&&e!==n.ATN.INVALID_ALT_NUMBER;){if(1===e)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=631,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,50,this._ctx)){case 1:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,i.RULE_simple_expr),this.state=606,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=607,o._op=this._input.LT(1),t=this._input.LA(1),t-85&-32||!(1<<t-85&63)?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=608,this.simple_expr(6),o.node=s.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 2:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,i.RULE_simple_expr),this.state=611,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=612,o._op=this.match(i.EXPR_AND),this.state=613,this.simple_expr(5),o.node=s.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 3:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,i.RULE_simple_expr),this.state=616,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=617,o._op=this.match(i.EXPR_OR),this.state=618,this.simple_expr(4),o.node=s.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 4:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,i.RULE_simple_expr),this.state=621,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=622,o._op=this.match(i.EXPR_AND_AND),this.state=623,this.simple_expr(3),o.node=s.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 5:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,i.RULE_simple_expr),this.state=626,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=627,o._op=this.match(i.EXPR_OR_OR),this.state=628,this.simple_expr(2),o.node=s.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node)}this.state=635,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,51,this._ctx)}}catch(e){if(!(e instanceof n.RecognitionException))throw e;o.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.unrollRecursionContexts(r)}return o}expression(){let e,t=new R(this,this._ctx,this.state);this.enterRule(t,54,i.RULE_expression);try{switch(this.state=647,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,52,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=636,this.simple_expr(0),t.node=t.simple_expr().node;break;case 2:this.enterOuterAlt(t,2),this.state=639,this.simple_expr(0),this.state=640,t._op=this._input.LT(1),e=this._input.LA(1),e-53&-32||!(1<<e-53&268369921)?t._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=641,this.expression(),t.node=s.AST.nodeOperation(t._op.text,t.simple_expr().node,t.expression().node);break;case 3:this.enterOuterAlt(t,3),this.state=644,this.anon_fcn_handle(),t.node=t.anon_fcn_handle().node}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}assign_lhs(){let e,t=new D(this,this._ctx,this.state);this.enterRule(t,56,i.RULE_assign_lhs);try{switch(this.state=658,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,54,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=649,this.simple_expr(0),t.node=t.simple_expr().node;break;case 2:this.enterOuterAlt(t,2),this.state=652,this.match(i.LBRACKET),this.state=654,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=653,this.assign_list()),this.state=656,this.match(i.RBRACKET),t.node=s.AST.nodeFirstRow(t.assign_list()?t.assign_list().node:s.AST.nodeListFirst())}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}assign_list(){let e,t=new F(this,this._ctx,this.state);this.enterRule(t,58,i.RULE_assign_list);try{let r;for(this.enterOuterAlt(t,1),this.state=660,this.list_element(),t.node=s.AST.nodeListFirst(t.list_element(t.i++).node),this.state=668,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=662,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=663,this.list_element(),t.node=s.AST.appendNodeList(t.node,t.list_element(t.i++).node)),this.state=670,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);this.state=672,this._errHandler.sync(this),e=this._input.LA(1),45!==e&&56!==e||(this.state=671,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}command(){let e=new P(this,this._ctx,this.state);this.enterRule(e,60,i.RULE_command);try{switch(this.state=698,this._errHandler.sync(this),this._input.LA(1)){case 1:case 2:this.enterOuterAlt(e,1),this.state=674,this.declaration(),e.node=e.declaration().node;break;case 3:this.enterOuterAlt(e,2),this.state=677,this.import_command(),e.node=e.import_command().node;break;case 4:case 10:this.enterOuterAlt(e,3),this.state=680,this.select_command(),e.node=e.select_command().node;break;case 14:case 16:case 18:case 20:case 22:this.enterOuterAlt(e,4),this.state=683,this.loop_command(),e.node=e.loop_command().node;break;case 24:case 25:case 26:this.enterOuterAlt(e,5),this.state=686,this.jump_command(),e.node=e.jump_command().node;break;case 29:case 32:this.enterOuterAlt(e,6),this.state=689,this.except_command(),e.node=e.except_command().node;break;case 27:this.enterOuterAlt(e,7),this.state=692,this.function_(),e.node=e.function_().node;break;case 35:this.enterOuterAlt(e,8),this.state=695,this.classdef_command(),e.node=e.classdef_command().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))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 k(this,this._ctx,this.state);this.enterRule(t,62,i.RULE_declaration);try{let r;switch(this.enterOuterAlt(t,1),this.state=704,this._errHandler.sync(this),this._input.LA(1)){case 1:this.state=700,this.match(i.GLOBAL),t.node=s.AST.nodeDeclarationFirst("GLOBAL");break;case 2:this.state=702,this.match(i.PERSISTENT),t.node=s.AST.nodeDeclarationFirst("PERSIST");break;default:throw new n.NoViableAltException(this)}for(this.state=706,this.declaration_element(),t.node=s.AST.nodeAppendDeclaration(t.node,t.declaration_element(t.i++).node),this.state=716,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=709,this._errHandler.sync(this),e=this._input.LA(1),56===e&&(this.state=708,this.match(i.COMMA)),this.state=711,this.declaration_element(),t.node=s.AST.nodeAppendDeclaration(t.node,t.declaration_element(t.i++).node)),this.state=718,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx)}catch(e){if(!(e instanceof n.RecognitionException))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 V(this,this._ctx,this.state);this.enterRule(e,64,i.RULE_declaration_element);try{switch(this.state=727,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,61,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=719,this.identifier(),e.node=e.identifier().node;break;case 2:this.enterOuterAlt(e,2),this.state=722,this.identifier(),this.state=723,this.match(i.EQ),this.state=724,this.expression(),e.node=s.AST.nodeDefaultedParameter(e.identifier().node,e.expression().node)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}import_command(){let e,t=new U(this,this._ctx,this.state);this.enterRule(t,66,i.RULE_import_command);try{let r;if(this.enterOuterAlt(t,1),this.state=729,this.match(i.IMPORT),t.node=s.AST.nodeImport(),this.state=744,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,64,this._ctx))for(this.state=731,this.import_name(),t.node=s.AST.nodeImportFirst(t.import_name(t.i++).node),this.state=741,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=734,this._errHandler.sync(this),e=this._input.LA(1),56===e&&(this.state=733,this.match(i.COMMA)),this.state=736,this.import_name(),t.node=s.AST.nodeAppendImport(t.node,t.import_name(t.i++).node)),this.state=743,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}import_name(){let e=new $(this,this._ctx,this.state);this.enterRule(e,68,i.RULE_import_name);try{switch(this.state=757,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,66,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=746,this.qualified_identifier(),e.node=e.qualified_identifier().node;break;case 2:switch(this.enterOuterAlt(e,2),this.state=749,this.qualified_identifier(),this.state=753,this._errHandler.sync(this),this._input.LA(1)){case 57:this.state=750,this.match(i.DOT),this.state=751,this.match(i.MUL);break;case 91:this.state=752,this.match(i.EMUL);break;default:throw new n.NoViableAltException(this)}e.node=s.AST.nodeIdentifier(e.qualified_identifier().node.id+".*")}}catch(t){if(!(t instanceof n.RecognitionException))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 B(this,this._ctx,this.state);this.enterRule(e,70,i.RULE_select_command);try{switch(this.state=765,this._errHandler.sync(this),this._input.LA(1)){case 4:this.enterOuterAlt(e,1),this.state=759,this.if_command(),e.node=e.if_command().node;break;case 10:this.enterOuterAlt(e,2),this.state=762,this.switch_command(),e.node=e.switch_command().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))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 H(this,this._ctx,this.state);this.enterRule(t,72,i.RULE_if_command);try{for(this.enterOuterAlt(t,1),this.state=767,this.match(i.IF),this.state=768,this.expression(),this.state=770,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=769,this.sep()),this.state=773,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=772,this.list()),t.node=s.AST.nodeIfBegin(t.expression().node,t.list()?t.list().node:s.AST.nodeListFirst()),this.state=781,this._errHandler.sync(this),e=this._input.LA(1);8===e;)this.state=776,this.elseif_clause(),t.node=s.AST.nodeIfAppendElseIf(t.node,t.elseif_clause(t.i++).node),this.state=783,this._errHandler.sync(this),e=this._input.LA(1);this.state=785,this._errHandler.sync(this),e=this._input.LA(1),9===e&&(this.state=784,this.else_clause()),t.else_clause()&&(t.node=s.AST.nodeIfAppendElse(t.node,t.else_clause().node)),this.state=788,e=this._input.LA(1),5!==e&&6!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())}catch(e){if(!(e instanceof n.RecognitionException))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 j(this,this._ctx,this.state);this.enterRule(t,74,i.RULE_elseif_clause);try{this.enterOuterAlt(t,1),this.state=790,this.match(i.ELSEIF),this.state=792,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=791,this.sep()),this.state=794,this.expression(),this.state=796,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=795,this.sep()),this.state=799,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=798,this.list()),t.node=s.AST.nodeElseIf(t.expression().node,t.list()?t.list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))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 q(this,this._ctx,this.state);this.enterRule(t,76,i.RULE_else_clause);try{this.enterOuterAlt(t,1),this.state=803,this.match(i.ELSE),this.state=805,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=804,this.sep()),this.state=808,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=807,this.list()),t.node=s.AST.nodeElse(t.list()?t.list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}switch_command(){let e,t=new z(this,this._ctx,this.state);this.enterRule(t,78,i.RULE_switch_command);try{this.enterOuterAlt(t,1),this.state=812,this.match(i.SWITCH),this.state=813,this.expression(),this.state=815,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=814,this.sep()),this.state=818,this._errHandler.sync(this),e=this._input.LA(1),12===e&&(this.state=817,this.switch_case_list()),this.state=821,this._errHandler.sync(this),e=this._input.LA(1),13===e&&(this.state=820,this.otherwise_case()),this.state=823,e=this._input.LA(1),6!==e&&11!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeSwitch(t.expression().node,t.switch_case_list()?t.switch_case_list().node:s.AST.nodeListFirst(),t.otherwise_case()?t.otherwise_case().node:null)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}switch_case_list(){let e,t=new G(this,this._ctx,this.state);this.enterRule(t,80,i.RULE_switch_case_list);try{let r;for(this.enterOuterAlt(t,1),this.state=826,this.switch_case(),t.node=s.AST.nodeListFirst(t.switch_case(t.i++).node),this.state=836,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=829,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=828,this.sep()),this.state=831,this.switch_case(),t.node=s.AST.appendNodeList(t.node,t.switch_case(t.i++).node)),this.state=838,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);this.state=840,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=839,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}switch_case(){let e,t=new W(this,this._ctx,this.state);this.enterRule(t,82,i.RULE_switch_case);try{this.enterOuterAlt(t,1),this.state=842,this.match(i.CASE),this.state=844,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=843,this.sep()),this.state=846,this.expression(),this.state=848,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,84,this._ctx)&&(this.state=847,this.sep()),this.state=851,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=850,this.list()),t.node=s.AST.nodeSwitchCase(t.expression().node,t.list()?t.list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}otherwise_case(){let e,t=new Q(this,this._ctx,this.state);this.enterRule(t,84,i.RULE_otherwise_case);try{this.enterOuterAlt(t,1),this.state=855,this.match(i.OTHERWISE),this.state=857,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,86,this._ctx)&&(this.state=856,this.sep()),this.state=860,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=859,this.list()),this.state=863,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=862,this.sep()),t.node=t.list()?t.list().node:s.AST.nodeListFirst()}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}loop_command(){let e=new J(this,this._ctx,this.state);this.enterRule(e,86,i.RULE_loop_command);try{switch(this.state=879,this._errHandler.sync(this),this._input.LA(1)){case 14:this.enterOuterAlt(e,1),this.state=867,this.while_command(),e.node=e.while_command().node;break;case 16:this.enterOuterAlt(e,2),this.state=870,this.do_until_command(),e.node=e.do_until_command().node;break;case 18:case 20:this.enterOuterAlt(e,3),this.state=873,this.for_command(),e.node=e.for_command().node;break;case 22:this.enterOuterAlt(e,4),this.state=876,this.spmd_command(),e.node=e.spmd_command().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}while_command(){let e,t=new K(this,this._ctx,this.state);this.enterRule(t,88,i.RULE_while_command);try{this.enterOuterAlt(t,1),this.state=881,this.match(i.WHILE),this.state=882,this.expression(),this.state=884,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=883,this.sep()),this.state=887,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=886,this.list()),this.state=889,e=this._input.LA(1),6!==e&&15!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeWhile(t.expression().node,t.list()?t.list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}do_until_command(){let e,t=new Z(this,this._ctx,this.state);this.enterRule(t,90,i.RULE_do_until_command);try{this.enterOuterAlt(t,1),this.state=892,this.match(i.DO),this.state=894,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=893,this.sep()),this.state=897,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=896,this.list()),this.state=899,this.match(i.UNTIL),this.state=900,this.expression(),t.node=s.AST.nodeDoUntil(t.list()?t.list().node:s.AST.nodeListFirst(),t.expression().node)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}for_command(){let e,t=new X(this,this._ctx,this.state);this.enterRule(t,92,i.RULE_for_command);try{switch(this.state=963,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,103,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=903,this.match(i.FOR),this.state=904,this.assign_lhs(),this.state=905,this.match(i.EQ),this.state=906,this.expression(),this.state=908,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=907,this.sep()),this.state=911,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=910,this.list()),this.state=913,e=this._input.LA(1),6!==e&&19!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeFor(t.assign_lhs().node,t.expression(0).node,t.list()?t.list().node:s.AST.nodeListFirst());break;case 2:this.enterOuterAlt(t,2),this.state=916,this.match(i.FOR),this.state=917,this.match(i.LPAREN),this.state=918,this.assign_lhs(),this.state=919,this.match(i.EQ),this.state=920,this.expression(),this.state=921,this.match(i.RPAREN),this.state=923,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=922,this.sep()),this.state=926,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=925,this.list()),this.state=928,e=this._input.LA(1),6!==e&&19!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeFor(t.assign_lhs().node,t.expression(0).node,t.list()?t.list().node:s.AST.nodeListFirst());break;case 3:this.enterOuterAlt(t,3),this.state=931,this.match(i.PARFOR),this.state=932,this.assign_lhs(),this.state=933,this.match(i.EQ),this.state=934,this.expression(),this.state=936,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=935,this.sep()),this.state=939,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=938,this.list()),this.state=941,e=this._input.LA(1),6!==e&&21!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeFor(t.assign_lhs().node,t.expression(0).node,t.list()?t.list().node:s.AST.nodeListFirst(),!0);break;case 4:this.enterOuterAlt(t,4),this.state=944,this.match(i.PARFOR),this.state=945,this.match(i.LPAREN),this.state=946,this.assign_lhs(),this.state=947,this.match(i.EQ),this.state=948,this.expression(),this.state=951,this._errHandler.sync(this),e=this._input.LA(1),56===e&&(this.state=949,this.match(i.COMMA),this.state=950,this.expression()),this.state=953,this.match(i.RPAREN),this.state=955,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=954,this.sep()),this.state=958,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=957,this.list()),this.state=960,e=this._input.LA(1),6!==e&&21!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeFor(t.assign_lhs().node,t.expression(0).node,t.list()?t.list().node:s.AST.nodeListFirst(),!0,t.expression(1)?t.expression(1).node:null)}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}spmd_command(){let e,t=new Y(this,this._ctx,this.state);this.enterRule(t,94,i.RULE_spmd_command);try{this.enterOuterAlt(t,1),this.state=965,this.match(i.SPMD),this.state=967,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,104,this._ctx)&&(this.state=966,this.spmd_worker_spec()),this.state=970,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=969,this.sep()),this.state=973,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=972,this.list()),this.state=975,e=this._input.LA(1),6!==e&&23!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeSpmd(t.list()?t.list().node:s.AST.nodeListFirst(),t.spmd_worker_spec()?t.spmd_worker_spec().node:null)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}spmd_worker_spec(){let e,t=new ee(this,this._ctx,this.state);this.enterRule(t,96,i.RULE_spmd_worker_spec);try{this.enterOuterAlt(t,1),this.state=978,this.match(i.LPAREN),this.state=979,this.expression(),t.node=s.AST.nodeListFirst(t.expression(t.i++).node),this.state=985,this._errHandler.sync(this),e=this._input.LA(1),56===e&&(this.state=981,this.match(i.COMMA),this.state=982,this.expression(),t.node=s.AST.appendNodeList(t.node,t.expression(t.i++).node)),this.state=987,this.match(i.RPAREN)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}jump_command(){let e=new te(this,this._ctx,this.state);this.enterRule(e,98,i.RULE_jump_command);try{switch(this.state=995,this._errHandler.sync(this),this._input.LA(1)){case 24:this.enterOuterAlt(e,1),this.state=989,this.match(i.BREAK),e.node=s.AST.nodeBreak();break;case 25:this.enterOuterAlt(e,2),this.state=991,this.match(i.CONTINUE),e.node=s.AST.nodeContinue();break;case 26:this.enterOuterAlt(e,3),this.state=993,this.match(i.RETURN),e.node=s.AST.nodeReturn();break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}except_command(){let e=new re(this,this._ctx,this.state);this.enterRule(e,100,i.RULE_except_command);try{switch(this.state=1003,this._errHandler.sync(this),this._input.LA(1)){case 29:this.enterOuterAlt(e,1),this.state=997,this.try_command(),e.node=e.try_command().node;break;case 32:this.enterOuterAlt(e,2),this.state=1e3,this.unwind_command(),e.node=e.unwind_command().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}try_command(){let e,t=new ne(this,this._ctx,this.state);this.enterRule(t,102,i.RULE_try_command);try{switch(this.state=1025,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,114,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=1005,this.match(i.TRY),this.state=1007,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1006,this.sep()),this.state=1010,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1009,this.list()),this.state=1012,this.catch_clause(),this.state=1013,e=this._input.LA(1),6!==e&&31!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeTry(t.list()?t.list().node:s.AST.nodeListFirst(),t.catch_clause().body,t.catch_clause().identifierNode);break;case 2:this.enterOuterAlt(t,2),this.state=1016,this.match(i.TRY),this.state=1018,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1017,this.sep()),this.state=1021,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1020,this.list()),this.state=1023,e=this._input.LA(1),6!==e&&31!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeTry(t.list()?t.list().node:s.AST.nodeListFirst())}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}catch_clause(){let e,t=new se(this,this._ctx,this.state);this.enterRule(t,104,i.RULE_catch_clause);try{this.enterOuterAlt(t,1),this.state=1027,this.match(i.CATCH),this.state=1029,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1028,this.sep()),this.state=1032,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1031,this.list()),t.identifierNode=null,t.body=t.list()?t.list().node:s.AST.nodeListFirst(),!t.sep()&&t.body.list.length>0&&s.AST.isNodeIdentifier(t.body.list[0])&&(t.identifierNode=t.body.list.shift(),t.body.list.forEach((e,t)=>{e.index=t}))}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}unwind_command(){let e,t=new ie(this,this._ctx,this.state);this.enterRule(t,106,i.RULE_unwind_command);try{this.enterOuterAlt(t,1),this.state=1036,this.match(i.UNWIND_PROTECT),this.state=1038,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1037,this.sep()),this.state=1041,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1040,this.list()),this.state=1043,this.unwind_cleanup_clause(),this.state=1044,e=this._input.LA(1),6!==e&&34!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeUnwindProtect(t.list()?t.list().node:s.AST.nodeListFirst(),t.unwind_cleanup_clause().node)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}unwind_cleanup_clause(){let e,t=new ae(this,this._ctx,this.state);this.enterRule(t,108,i.RULE_unwind_cleanup_clause);try{this.enterOuterAlt(t,1),this.state=1047,this.match(i.UNWIND_PROTECT_CLEANUP),this.state=1049,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1048,this.sep()),this.state=1052,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1051,this.list()),t.node=t.list()?t.list().node:s.AST.nodeListFirst()}catch(e){if(!(e instanceof n.RecognitionException))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 oe(this,this._ctx,this.state);this.enterRule(t,110,i.RULE_param_list);try{if(this.enterOuterAlt(t,1),this.state=1056,this.match(i.LPAREN),t.node=s.AST.nodeListFirst(),this.state=1069,this._errHandler.sync(this),e=this._input.LA(1),!(e-37&-32)&&1<<e-37&2097237||101===e)for(this.state=1058,this.param_list_elt(),t.node=s.AST.appendNodeList(t.node,t.param_list_elt(t.i++).node),this.state=1066,this._errHandler.sync(this),e=this._input.LA(1);56===e;)this.state=1060,this.match(i.COMMA),this.state=1061,this.param_list_elt(),t.node=s.AST.appendNodeList(t.node,t.param_list_elt(t.i++).node),this.state=1068,this._errHandler.sync(this),e=this._input.LA(1);this.state=1071,this.match(i.RPAREN)}catch(e){if(!(e instanceof n.RecognitionException))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 le(this,this._ctx,this.state);this.enterRule(e,112,i.RULE_param_list_elt);try{switch(this.state=1079,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=1073,this.declaration_element(),e.node=e.declaration_element().node;break;case 58:this.enterOuterAlt(e,2),this.state=1076,this.magic_tilde(),e.node=e.magic_tilde().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}return_list_elt(){let e=new ce(this,this._ctx,this.state);this.enterRule(e,114,i.RULE_return_list_elt);try{switch(this.state=1087,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=1081,this.identifier(),e.node=e.identifier().node;break;case 58:this.enterOuterAlt(e,2),this.state=1084,this.magic_tilde(),e.node=e.magic_tilde().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))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 ue(this,this._ctx,this.state);this.enterRule(t,116,i.RULE_return_list);try{switch(this.state=1108,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 58:case 101:this.enterOuterAlt(t,1),this.state=1089,this.return_list_elt(),t.node=s.AST.nodeListFirst(t.return_list_elt(0).node);break;case 64:if(this.enterOuterAlt(t,2),this.state=1092,this.match(i.LBRACKET),t.node=s.AST.nodeListFirst(),this.state=1105,this._errHandler.sync(this),e=this._input.LA(1),!(e-37&-32)&&1<<e-37&2097237||101===e)for(this.state=1094,this.return_list_elt(),t.node=s.AST.appendNodeList(t.node,t.return_list_elt(t.i++).node),this.state=1102,this._errHandler.sync(this),e=this._input.LA(1);45===e||56===e;)this.state=1096,e=this._input.LA(1),45!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1097,this.return_list_elt(),t.node=s.AST.appendNodeList(t.node,t.return_list_elt(t.i++).node),this.state=1104,this._errHandler.sync(this),e=this._input.LA(1);this.state=1107,this.match(i.RBRACKET);break;default:throw new n.NoViableAltException(this)}}catch(e){if(!(e instanceof n.RecognitionException))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 he(this,this._ctx,this.state);this.enterRule(t,118,i.RULE_function);try{this.enterOuterAlt(t,1),this.state=1110,this.match(i.FUNCTION),this.state=1114,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,128,this._ctx)&&(this.state=1111,this.return_list(),this.state=1112,this.match(i.EQ)),this.state=1116,this.function_name(),this.state=1118,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,129,this._ctx)&&(this.state=1117,this.param_list()),this.state=1121,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1120,this.sep()),this.state=1124,this._errHandler.sync(this),e=this._input.LA(1),47===e&&(this.state=1123,this.arguments_block_list()),this.state=1127,this._errHandler.sync(this),e=this._input.LA(1),(!(e-1&-32)&&1<<e-1&2544542287||!(e-35&-32)&&1<<e-35&2944452949||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1126,this.list()),this.state=1129,e=this._input.LA(1),e- -1&-32||!(1<<e- -1&536871041)?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeFunctionDefinition(t.function_name().node,t.return_list()?t.return_list().node:s.AST.nodeListFirst(),t.param_list()?t.param_list().node:s.AST.nodeListFirst(),t.arguments_block_list()?t.arguments_block_list().node:s.AST.nodeListFirst(),t.list()?t.list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}function_name(){let e=new de(this,this._ctx,this.state);this.enterRule(e,120,i.RULE_function_name);try{this.enterOuterAlt(e,1),this.state=1132,this.qualified_identifier(),e.node=e.qualified_identifier().node}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}classdef_command(){let e,t=new me(this,this._ctx,this.state);this.enterRule(t,122,i.RULE_classdef_command);try{this.enterOuterAlt(t,1),this.state=1135,this.match(i.CLASSDEF),this.state=1137,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1136,this.class_attribute_list()),this.state=1139,this.qualified_identifier(),this.state=1141,this._errHandler.sync(this),e=this._input.LA(1),85===e&&(this.state=1140,this.class_superclass_list()),this.state=1144,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1143,this.sep()),this.state=1147,this._errHandler.sync(this),e=this._input.LA(1),!(e-37&-32)&&1<<e-37&85&&(this.state=1146,this.class_section_list()),this.state=1149,e=this._input.LA(1),-1!==e&&6!==e&&36!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeClassDef(t.qualified_identifier().node,t.class_section_list()?t.class_section_list().node:s.AST.nodeListFirst(),t.class_attribute_list()?t.class_attribute_list().node:s.AST.nodeListFirst(),t.class_superclass_list()?t.class_superclass_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_attribute_list(){let e,t=new pe(this,this._ctx,this.state);this.enterRule(t,124,i.RULE_class_attribute_list);try{if(this.enterOuterAlt(t,1),this.state=1152,this.match(i.LPAREN),t.node=s.AST.nodeListFirst(),this.state=1165,this._errHandler.sync(this),e=this._input.LA(1),!(e-37&-32)&&1<<e-37&6291541||101===e)for(this.state=1154,this.class_attribute(),t.node=s.AST.appendNodeList(t.node,t.class_attribute(t.i++).node),this.state=1162,this._errHandler.sync(this),e=this._input.LA(1);56===e;)this.state=1156,this.match(i.COMMA),this.state=1157,this.class_attribute(),t.node=s.AST.appendNodeList(t.node,t.class_attribute(t.i++).node),this.state=1164,this._errHandler.sync(this),e=this._input.LA(1);this.state=1167,this.match(i.RPAREN),this.state=1169,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,139,this._ctx)&&(this.state=1168,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_attribute(){let e,t=new fe(this,this._ctx,this.state);this.enterRule(t,126,i.RULE_class_attribute);try{switch(this.state=1182,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=1171,this.identifier(),this.state=1174,this._errHandler.sync(this),e=this._input.LA(1),53===e&&(this.state=1172,this.match(i.EQ),this.state=1173,this.expression()),t.node=s.AST.nodeClassAttribute(t.identifier().node,t.expression()?t.expression().node:null);break;case 58:case 59:this.enterOuterAlt(t,2),this.state=1178,t._op=this._input.LT(1),e=this._input.LA(1),58!==e&&59!==e?t._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1179,this.identifier(),t.node=s.AST.nodeClassAttribute(t.identifier().node,s.AST.nodeOperation(t._op.text,t.identifier().node));break;default:throw new n.NoViableAltException(this)}}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_method_name(){let e,t=new ge(this,this._ctx,this.state);this.enterRule(t,128,i.RULE_class_method_name);try{for(this.enterOuterAlt(t,1),this.state=1184,this.identifier(),t.node=s.AST.nodeIdentifier(t.identifier(0).node.id),this.state=1192,this._errHandler.sync(this),e=this._input.LA(1);57===e;)this.state=1186,this.match(i.DOT),this.state=1187,this.identifier(),t.node=s.AST.nodeIdentifier(t.node.id+"."+t.identifier(t.i++).node.id),this.state=1194,this._errHandler.sync(this),e=this._input.LA(1)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_superclass_list(){let e,t=new ye(this,this._ctx,this.state);this.enterRule(t,130,i.RULE_class_superclass_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1195,this.match(i.EXPR_LT),this.state=1196,this.qualified_identifier(),t.node=s.AST.nodeListFirst(t.qualified_identifier(t.i++).node),this.state=1204,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1198,e=this._input.LA(1),56!==e&&83!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1199,this.qualified_identifier(),t.node=s.AST.appendNodeList(t.node,t.qualified_identifier(t.i++).node)),this.state=1206,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_section_list(){let e,t=new xe(this,this._ctx,this.state);this.enterRule(t,132,i.RULE_class_section_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1207,this.class_section(),t.node=s.AST.nodeListFirst(t.class_section(t.i++).node),this.state=1217,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1210,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1209,this.sep()),this.state=1212,this.class_section(),t.node=s.AST.appendNodeList(t.node,t.class_section(t.i++).node)),this.state=1219,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);this.state=1221,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1220,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_section(){let e=new Ce(this,this._ctx,this.state);this.enterRule(e,134,i.RULE_class_section);try{switch(this.state=1235,this._errHandler.sync(this),this._input.LA(1)){case 39:this.enterOuterAlt(e,1),this.state=1223,this.properties_section(),e.node=e.properties_section().node;break;case 43:this.enterOuterAlt(e,2),this.state=1226,this.methods_section(),e.node=e.methods_section().node;break;case 41:this.enterOuterAlt(e,3),this.state=1229,this.events_section(),e.node=e.events_section().node;break;case 37:this.enterOuterAlt(e,4),this.state=1232,this.enumeration_section(),e.node=e.enumeration_section().node;break;default:throw new n.NoViableAltException(this)}}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}properties_section(){let e,t=new Ee(this,this._ctx,this.state);this.enterRule(t,136,i.RULE_properties_section);try{this.enterOuterAlt(t,1),this.state=1237,this.match(i.PROPERTIES),this.state=1239,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1238,this.class_attribute_list()),this.state=1242,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1241,this.sep()),this.state=1245,this._errHandler.sync(this),e=this._input.LA(1),(!(e-37&-32)&&1<<e-37&85||101===e)&&(this.state=1244,this.class_property_list()),this.state=1247,e=this._input.LA(1),6!==e&&40!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeClassSection("PROPERTIES",t.class_property_list()?t.class_property_list().node:s.AST.nodeListFirst(),t.class_attribute_list()?t.class_attribute_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_property_list(){let e,t=new ve(this,this._ctx,this.state);this.enterRule(t,138,i.RULE_class_property_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1250,this.class_property(),t.node=s.AST.nodeListFirst(t.class_property(t.i++).node),this.state=1258,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1252,this.sep(),this.state=1253,this.class_property(),t.node=s.AST.appendNodeList(t.node,t.class_property(t.i++).node)),this.state=1260,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);this.state=1262,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1261,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_property(){let e,t=new Ae(this,this._ctx,this.state);this.enterRule(t,140,i.RULE_class_property);try{this.enterOuterAlt(t,1),this.state=1264,this.identifier(),this.state=1269,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1265,this.match(i.LPAREN),this.state=1266,this.arg_list(),this.state=1267,this.match(i.RPAREN)),this.state=1272,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,154,this._ctx)&&(this.state=1271,this.qualified_identifier()),this.state=1278,this._errHandler.sync(this),e=this._input.LA(1),66===e&&(this.state=1274,this.match(i.LCURLYBR),this.state=1275,this.arg_list(),this.state=1276,this.match(i.RCURLYBR)),this.state=1282,this._errHandler.sync(this),e=this._input.LA(1),53===e&&(this.state=1280,this.match(i.EQ),this.state=1281,this.expression()),t.node=s.AST.nodeClassProperty(t.identifier().node,t.LPAREN()?t.arg_list(0).node:s.AST.nodeListFirst(),t.qualified_identifier()?t.qualified_identifier().node:null,t.LCURLYBR()?t.arg_list(t.LPAREN()?1:0).node:s.AST.nodeListFirst(),t.expression()?t.expression().node:null)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}methods_section(){let e,t=new Se(this,this._ctx,this.state);this.enterRule(t,142,i.RULE_methods_section);try{this.enterOuterAlt(t,1),this.state=1286,this.match(i.METHODS),this.state=1288,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1287,this.class_attribute_list()),this.state=1291,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1290,this.sep()),this.state=1294,this._errHandler.sync(this),e=this._input.LA(1),(27===e||!(e-37&-32)&&1<<e-37&136314965||101===e)&&(this.state=1293,this.class_method_list()),this.state=1296,e=this._input.LA(1),6!==e&&44!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeClassSection("METHODS",t.class_method_list()?t.class_method_list().node:s.AST.nodeListFirst(),t.class_attribute_list()?t.class_attribute_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_method(){var e,t;let r,a=new _e(this,this._ctx,this.state);this.enterRule(a,144,i.RULE_class_method);try{switch(this.state=1316,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,162,this._ctx)){case 1:this.enterOuterAlt(a,1),this.state=1299,this.function_(),a.node=a.function_().node;break;case 2:this.enterOuterAlt(a,2),this.state=1302,this.class_method_name(),this.state=1304,this._errHandler.sync(this),r=this._input.LA(1),62===r&&(this.state=1303,this.param_list()),a.node=s.AST.nodeFunctionDefinition(a.class_method_name().node,s.AST.nodeListFirst(),a.param_list()?a.param_list().node:s.AST.nodeListFirst(),s.AST.nodeListFirst(),s.AST.nodeListFirst()),a.node.attributes=Object.assign(Object.assign({},null!==(e=a.node.attributes)&&void 0!==e?e:{}),{prototype:!0});break;case 3:this.enterOuterAlt(a,3),this.state=1308,this.return_list(),this.state=1309,this.match(i.EQ),this.state=1310,this.class_method_name(),this.state=1312,this._errHandler.sync(this),r=this._input.LA(1),62===r&&(this.state=1311,this.param_list()),a.node=s.AST.nodeFunctionDefinition(a.class_method_name().node,a.return_list().node,a.param_list()?a.param_list().node:s.AST.nodeListFirst(),s.AST.nodeListFirst(),s.AST.nodeListFirst()),a.node.attributes=Object.assign(Object.assign({},null!==(t=a.node.attributes)&&void 0!==t?t:{}),{prototype:!0})}}catch(e){if(!(e instanceof n.RecognitionException))throw e;a.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return a}class_method_list(){let e,t=new be(this,this._ctx,this.state);this.enterRule(t,146,i.RULE_class_method_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1318,this.class_method(),t.node=s.AST.nodeListFirst(t.class_method(t.i++).node),this.state=1328,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1321,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1320,this.sep()),this.state=1323,this.class_method(),t.node=s.AST.appendNodeList(t.node,t.class_method(t.i++).node)),this.state=1330,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);this.state=1332,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1331,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}events_section(){let e,t=new Te(this,this._ctx,this.state);this.enterRule(t,148,i.RULE_events_section);try{this.enterOuterAlt(t,1),this.state=1334,this.match(i.EVENTS),this.state=1336,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1335,this.class_attribute_list()),this.state=1339,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1338,this.sep()),this.state=1342,this._errHandler.sync(this),e=this._input.LA(1),(!(e-37&-32)&&1<<e-37&85||101===e)&&(this.state=1341,this.class_event_list()),this.state=1344,e=this._input.LA(1),6!==e&&42!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeClassSection("EVENTS",t.class_event_list()?t.class_event_list().node:s.AST.nodeListFirst(),t.class_attribute_list()?t.class_attribute_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_event_list(){let e,t=new Me(this,this._ctx,this.state);this.enterRule(t,150,i.RULE_class_event_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1347,this.class_event(),t.node=s.AST.nodeListFirst(t.class_event(t.i++).node),this.state=1357,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1350,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1349,this.sep()),this.state=1352,this.class_event(),t.node=s.AST.appendNodeList(t.node,t.class_event(t.i++).node)),this.state=1359,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);this.state=1361,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1360,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_event(){let e=new Ne(this,this._ctx,this.state);this.enterRule(e,152,i.RULE_class_event);try{this.enterOuterAlt(e,1),this.state=1363,this.identifier(),e.node=s.AST.nodeClassEvent(e.identifier().node)}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}enumeration_section(){let e,t=new Ie(this,this._ctx,this.state);this.enterRule(t,154,i.RULE_enumeration_section);try{this.enterOuterAlt(t,1),this.state=1366,this.match(i.ENUMERATION),this.state=1368,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1367,this.class_attribute_list()),this.state=1371,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1370,this.sep()),this.state=1374,this._errHandler.sync(this),e=this._input.LA(1),(!(e-37&-32)&&1<<e-37&85||101===e)&&(this.state=1373,this.class_enumeration_list()),this.state=1376,e=this._input.LA(1),6!==e&&38!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeClassSection("ENUMERATION",t.class_enumeration_list()?t.class_enumeration_list().node:s.AST.nodeListFirst(),t.class_attribute_list()?t.class_attribute_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_enumeration_list(){let e,t=new Le(this,this._ctx,this.state);this.enterRule(t,156,i.RULE_class_enumeration_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1379,this.class_enumeration(),t.node=s.AST.nodeListFirst(t.class_enumeration(t.i++).node),this.state=1389,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1382,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1381,this.sep()),this.state=1384,this.class_enumeration(),t.node=s.AST.appendNodeList(t.node,t.class_enumeration(t.i++).node)),this.state=1391,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);this.state=1393,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1392,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}class_enumeration(){let e,t=new we(this,this._ctx,this.state);this.enterRule(t,158,i.RULE_class_enumeration);try{this.enterOuterAlt(t,1),this.state=1395,this.identifier(),this.state=1401,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1396,this.match(i.LPAREN),this.state=1398,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=1397,this.arg_list()),this.state=1400,this.match(i.RPAREN)),t.node=s.AST.nodeClassEnumeration(t.identifier().node,t.arg_list()?t.arg_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))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 Oe(this,this._ctx,this.state);this.enterRule(t,160,i.RULE_arguments_block_list);try{let r;for(this.enterOuterAlt(t,1),this.state=1405,this.arguments_block(),t.node=s.AST.nodeListFirst(t.arguments_block(t.i++).node),this.state=1415,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);2!==r&&r!==n.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1408,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1407,this.sep()),this.state=1410,this.arguments_block(),t.node=s.AST.appendNodeList(t.node,t.arguments_block(t.i++).node)),this.state=1417,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);this.state=1419,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1418,this.sep())}catch(e){if(!(e instanceof n.RecognitionException))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 Re(this,this._ctx,this.state);this.enterRule(t,162,i.RULE_arguments_block);try{this.enterOuterAlt(t,1),this.state=1421,this.match(i.ARGUMENTS),this.state=1423,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,183,this._ctx)&&(this.state=1422,this.sep()),this.state=1431,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1425,this.match(i.LPAREN),this.state=1426,this.arguments_attribute_list(),this.state=1427,this.match(i.RPAREN),this.state=1429,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,184,this._ctx))&&(this.state=1428,this.sep()),this.state=1434,this._errHandler.sync(this),e=this._input.LA(1),(!(e-37&-32)&&1<<e-37&85||101===e)&&(this.state=1433,this.args_validation_list()),this.state=1437,this._errHandler.sync(this),e=this._input.LA(1),55!==e&&56!==e&&106!==e||(this.state=1436,this.sep()),this.state=1439,e=this._input.LA(1),6!==e&&48!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),t.node=s.AST.nodeArguments(t.arguments_attribute_list()?t.arguments_attribute_list().node:null,t.args_validation_list()?t.args_validation_list().node:s.AST.nodeListFirst())}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arguments_attribute_list(){let e,t=new De(this,this._ctx,this.state);this.enterRule(t,164,i.RULE_arguments_attribute_list);try{for(this.enterOuterAlt(t,1),this.state=1442,this.identifier(),t.node=s.AST.nodeListFirst(t.identifier(t.i++).node),this.state=1450,this._errHandler.sync(this),e=this._input.LA(1);56===e;)this.state=1444,this.match(i.COMMA),this.state=1445,this.identifier(),t.node=s.AST.appendNodeList(t.node,t.identifier(t.i++).node),this.state=1452,this._errHandler.sync(this),e=this._input.LA(1)}catch(e){if(!(e instanceof n.RecognitionException))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 Fe(this,this._ctx,this.state);this.enterRule(e,166,i.RULE_args_validation_list);try{let t;for(this.enterOuterAlt(e,1),this.state=1453,this.arg_validation(),e.node=s.AST.nodeListFirst(e.arg_validation(e.i++).node),this.state=1461,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,189,this._ctx);2!==t&&t!==n.ATN.INVALID_ALT_NUMBER;)1===t&&(this.state=1455,this.sep(),this.state=1456,this.arg_validation(),e.node=s.AST.appendNodeList(e.node,e.arg_validation(e.i++).node)),this.state=1463,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,189,this._ctx)}catch(t){if(!(t instanceof n.RecognitionException))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 Pe(this,this._ctx,this.state);this.enterRule(t,168,i.RULE_arg_validation);try{this.enterOuterAlt(t,1),this.state=1464,this.arg_validation_name(),this.state=1469,this._errHandler.sync(this),e=this._input.LA(1),62===e&&(this.state=1465,this.match(i.LPAREN),this.state=1466,this.arg_list(),this.state=1467,this.match(i.RPAREN)),this.state=1472,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,191,this._ctx)&&(this.state=1471,this.qualified_identifier()),this.state=1478,this._errHandler.sync(this),e=this._input.LA(1),66===e&&(this.state=1474,this.match(i.LCURLYBR),this.state=1475,this.arg_list(),this.state=1476,this.match(i.RCURLYBR)),this.state=1482,this._errHandler.sync(this),e=this._input.LA(1),53===e&&(this.state=1480,this.match(i.EQ),this.state=1481,this.expression()),t.node=s.AST.nodeArgumentValidation(t.arg_validation_name().node,t.LPAREN()?t.arg_list(0).node:s.AST.nodeListFirst(),t.qualified_identifier()?t.qualified_identifier().node:s.AST.nodeListFirst(),t.LCURLYBR()?t.LPAREN()?t.arg_list(1).node:t.arg_list(0).node:s.AST.nodeListFirst(),t.expression()?t.expression().node:null)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arg_validation_name(){let e,t=new ke(this,this._ctx,this.state);this.enterRule(t,170,i.RULE_arg_validation_name);try{for(this.enterOuterAlt(t,1),this.state=1486,this.identifier(),t.node=t.identifier(0).node,this.state=1494,this._errHandler.sync(this),e=this._input.LA(1);57===e;)this.state=1488,this.match(i.DOT),this.state=1489,this.identifier(),t.node=s.AST.nodeIndirectRef(t.node,t.identifier(t.i++).node.id),this.state=1496,this._errHandler.sync(this),e=this._input.LA(1)}catch(e){if(!(e instanceof n.RecognitionException))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 Ve(this,this._ctx,this.state);this.enterRule(t,172,i.RULE_sep_no_nl);try{this.enterOuterAlt(t,1),this.state=1498,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=1497,e=this._input.LA(1),55!==e&&56!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1500,this._errHandler.sync(this),e=this._input.LA(1)}while(55===e||56===e)}catch(e){if(!(e instanceof n.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}nl(){let e=new Ue(this,this._ctx,this.state);this.enterRule(e,174,i.RULE_nl);try{let t;this.enterOuterAlt(e,1),this.state=1503,this._errHandler.sync(this),t=1;do{if(1!==t)throw new n.NoViableAltException(this);this.state=1502,this.match(i.NEWLINE),this.state=1505,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,196,this._ctx)}while(2!==t&&t!==n.ATN.INVALID_ALT_NUMBER)}catch(t){if(!(t instanceof n.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}sep(){let e,t=new $e(this,this._ctx,this.state);this.enterRule(t,176,i.RULE_sep);try{let r;this.enterOuterAlt(t,1),this.state=1508,this._errHandler.sync(this),r=1;do{if(1!==r)throw new n.NoViableAltException(this);this.state=1507,e=this._input.LA(1),55!==e&&56!==e&&106!==e?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1510,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,197,this._ctx)}while(2!==r&&r!==n.ATN.INVALID_ALT_NUMBER)}catch(e){if(!(e instanceof n.RecognitionException))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 23:return this.oper_expr_sempred(e,r);case 24:return this.power_expr_sempred(e,r);case 26: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,12);case 3:return this.precpred(this._ctx,11);case 4:return this.precpred(this._ctx,10);case 5:return this.precpred(this._ctx,9);case 6:return this.precpred(this._ctx,8);case 7:return this.precpred(this._ctx,7);case 8:return this.precpred(this._ctx,6);case 9:return this.precpred(this._ctx,5)}return!0}power_expr_sempred(e,t){switch(t){case 10:return this.precpred(this._ctx,8);case 11:return this.precpred(this._ctx,7);case 12:return this.precpred(this._ctx,6);case 13:return this.precpred(this._ctx,5);case 14:return this.precpred(this._ctx,4);case 15:return this.precpred(this._ctx,3)}return!0}simple_expr_sempred(e,t){switch(t){case 16:return this.precpred(this._ctx,5);case 17:return this.precpred(this._ctx,4);case 18:return this.precpred(this._ctx,3);case 19:return this.precpred(this._ctx,2);case 20:return this.precpred(this._ctx,1)}return!0}static get _ATN(){return i.__ATN||(i.__ATN=(new n.ATNDeserializer).deserialize(i._serializedATN)),i.__ATN}}i.GLOBAL=1,i.PERSISTENT=2,i.IMPORT=3,i.IF=4,i.ENDIF=5,i.END=6,i.ENDRANGE=7,i.ELSEIF=8,i.ELSE=9,i.SWITCH=10,i.ENDSWITCH=11,i.CASE=12,i.OTHERWISE=13,i.WHILE=14,i.ENDWHILE=15,i.DO=16,i.UNTIL=17,i.FOR=18,i.ENDFOR=19,i.PARFOR=20,i.ENDPARFOR=21,i.SPMD=22,i.ENDSPMD=23,i.BREAK=24,i.CONTINUE=25,i.RETURN=26,i.FUNCTION=27,i.ENDFUNCTION=28,i.TRY=29,i.CATCH=30,i.END_TRY_CATCH=31,i.UNWIND_PROTECT=32,i.UNWIND_PROTECT_CLEANUP=33,i.END_UNWIND_PROTECT=34,i.CLASSDEF=35,i.ENDCLASSDEF=36,i.ENUMERATION=37,i.ENDENUMERATION=38,i.PROPERTIES=39,i.ENDPROPERTIES=40,i.EVENTS=41,i.ENDEVENTS=42,i.METHODS=43,i.ENDMETHODS=44,i.WSPACE=45,i.STRING=46,i.ARGUMENTS=47,i.ENDARGUMENTS=48,i.PLUS=49,i.MINUS=50,i.MUL=51,i.DIV=52,i.EQ=53,i.COLON=54,i.SEMICOLON=55,i.COMMA=56,i.DOT=57,i.TILDE=58,i.EXCLAMATION=59,i.COMMAT=60,i.QUESTION=61,i.LPAREN=62,i.RPAREN=63,i.LBRACKET=64,i.RBRACKET=65,i.LCURLYBR=66,i.RCURLYBR=67,i.LEFTDIV=68,i.ADD_EQ=69,i.SUB_EQ=70,i.MUL_EQ=71,i.DIV_EQ=72,i.LEFTDIV_EQ=73,i.POW_EQ=74,i.EMUL_EQ=75,i.EDIV_EQ=76,i.ELEFTDIV_EQ=77,i.EPOW_EQ=78,i.AND_EQ=79,i.OR_EQ=80,i.EXPR_AND_AND=81,i.EXPR_OR_OR=82,i.EXPR_AND=83,i.EXPR_OR=84,i.EXPR_LT=85,i.EXPR_LE=86,i.EXPR_EQ=87,i.EXPR_NE=88,i.EXPR_GE=89,i.EXPR_GT=90,i.EMUL=91,i.EDIV=92,i.ELEFTDIV=93,i.PLUS_PLUS=94,i.MINUS_MINUS=95,i.POW=96,i.EPOW=97,i.TRANSPOSE=98,i.HERMITIAN=99,i.DQSTRING=100,i.IDENTIFIER=101,i.FLOAT_NUMBER=102,i.NUMBER_DOT_OP=103,i.LINE_CONTINUATION=104,i.SPACE_OR_CONTINUATION=105,i.NEWLINE=106,i.BLOCK_COMMENT_START=107,i.COMMENT_LINE=108,i.INVALID=109,i.SINGLEQ_STRING=110,i.SINGLEQ_NL=111,i.SINGLEQ_SINGLEQ=112,i.SINGLEQ_END=113,i.DOUBLEQ_STRING=114,i.DOUBLEQ_NL=115,i.DOUBLEQ_DOUBLEQ=116,i.DOUBLEQ_ESCAPE=117,i.DOUBLEQ_ESCAPE_OTHER=118,i.DOUBLEQ_ESCAPE_OCT=119,i.DOUBLEQ_ESCAPE_HEX=120,i.DOUBLEQ_ESCAPE_UNICODE=121,i.DOUBLEQ_END=122,i.BLOCK_COMMENT_START_AGAIN=123,i.BLOCK_COMMENT_END=124,i.BLOCK_COMMENT_LINE=125,i.BLOCK_COMMENT_EOF=126,i.COMMAND_LINE_CONTINUATION=127,i.COMMAND_CONTINUED_BLOCK_COMMENT_START=128,i.COMMAND_CONTINUED_COMMENT_LINE=129,i.COMMAND_CONTINUED_NEWLINE=130,i.SKIP_SPACE=131,i.COMMAND_LONE_DQUOTE=132,i.COMMAND_LONE_SQUOTE=133,i.COMMAND_UNCLOSED_DQUOTE=134,i.COMMAND_UNCLOSED_SQUOTE=135,i.COMMAND_DQSTRING=136,i.COMMAND_SQSTRING=137,i.SKIP_COMMENT_LINE=138,i.COMMAND_SEPARATOR=139,i.EXIT_AT_NEWLINE=140,i.EXIT_AT_EOF=141,i.UNQUOTED_STRING=142,i.EOF=n.Token.EOF,i.RULE_input=0,i.RULE_global_list=1,i.RULE_list=2,i.RULE_statement=3,i.RULE_word_list_cmd=4,i.RULE_command_word=5,i.RULE_identifier=6,i.RULE_qualified_identifier_part=7,i.RULE_qualified_identifier=8,i.RULE_string=9,i.RULE_number=10,i.RULE_end_range=11,i.RULE_constant=12,i.RULE_matrix=13,i.RULE_matrix_row=14,i.RULE_fcn_handle=15,i.RULE_meta_class=16,i.RULE_anon_fcn_handle=17,i.RULE_primary_expr=18,i.RULE_magic_colon=19,i.RULE_magic_tilde=20,i.RULE_list_element=21,i.RULE_arg_list=22,i.RULE_oper_expr=23,i.RULE_power_expr=24,i.RULE_colon_expr=25,i.RULE_simple_expr=26,i.RULE_expression=27,i.RULE_assign_lhs=28,i.RULE_assign_list=29,i.RULE_command=30,i.RULE_declaration=31,i.RULE_declaration_element=32,i.RULE_import_command=33,i.RULE_import_name=34,i.RULE_select_command=35,i.RULE_if_command=36,i.RULE_elseif_clause=37,i.RULE_else_clause=38,i.RULE_switch_command=39,i.RULE_switch_case_list=40,i.RULE_switch_case=41,i.RULE_otherwise_case=42,i.RULE_loop_command=43,i.RULE_while_command=44,i.RULE_do_until_command=45,i.RULE_for_command=46,i.RULE_spmd_command=47,i.RULE_spmd_worker_spec=48,i.RULE_jump_command=49,i.RULE_except_command=50,i.RULE_try_command=51,i.RULE_catch_clause=52,i.RULE_unwind_command=53,i.RULE_unwind_cleanup_clause=54,i.RULE_param_list=55,i.RULE_param_list_elt=56,i.RULE_return_list_elt=57,i.RULE_return_list=58,i.RULE_function=59,i.RULE_function_name=60,i.RULE_classdef_command=61,i.RULE_class_attribute_list=62,i.RULE_class_attribute=63,i.RULE_class_method_name=64,i.RULE_class_superclass_list=65,i.RULE_class_section_list=66,i.RULE_class_section=67,i.RULE_properties_section=68,i.RULE_class_property_list=69,i.RULE_class_property=70,i.RULE_methods_section=71,i.RULE_class_method=72,i.RULE_class_method_list=73,i.RULE_events_section=74,i.RULE_class_event_list=75,i.RULE_class_event=76,i.RULE_enumeration_section=77,i.RULE_class_enumeration_list=78,i.RULE_class_enumeration=79,i.RULE_arguments_block_list=80,i.RULE_arguments_block=81,i.RULE_arguments_attribute_list=82,i.RULE_args_validation_list=83,i.RULE_arg_validation=84,i.RULE_arg_validation_name=85,i.RULE_sep_no_nl=86,i.RULE_nl=87,i.RULE_sep=88,i.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,null,null,"''''",null,null,null,"'\"\"'"],i.symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","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","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","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","LINE_CONTINUATION","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","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"],i.ruleNames=["input","global_list","list","statement","word_list_cmd","command_word","identifier","qualified_identifier_part","qualified_identifier","string","number","end_range","constant","matrix","matrix_row","fcn_handle","meta_class","anon_fcn_handle","primary_expr","magic_colon","magic_tilde","list_element","arg_list","oper_expr","power_expr","colon_expr","simple_expr","expression","assign_lhs","assign_list","command","declaration","declaration_element","import_command","import_name","select_command","if_command","elseif_clause","else_clause","switch_command","switch_case_list","switch_case","otherwise_case","loop_command","while_command","do_until_command","for_command","spmd_command","spmd_worker_spec","jump_command","except_command","try_command","catch_clause","unwind_command","unwind_cleanup_clause","param_list","param_list_elt","return_list_elt","return_list","function","function_name","classdef_command","class_attribute_list","class_attribute","class_method_name","class_superclass_list","class_section_list","class_section","properties_section","class_property_list","class_property","methods_section","class_method","class_method_list","events_section","class_event_list","class_event","enumeration_section","class_enumeration_list","class_enumeration","arguments_block_list","arguments_block","arguments_attribute_list","args_validation_list","arg_validation","arg_validation_name","sep_no_nl","nl","sep"],i._serializedATN=[4,1,142,1513,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,1,0,3,0,180,8,0,1,0,1,0,1,0,3,0,185,8,0,1,0,1,0,1,0,1,0,3,0,191,8,0,1,1,1,1,1,1,1,1,1,1,1,1,5,1,199,8,1,10,1,12,1,202,9,1,1,1,3,1,205,8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,5,2,215,8,2,10,2,12,2,218,9,2,1,2,3,2,221,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,234,8,3,1,4,1,4,1,4,1,4,1,4,1,4,5,4,242,8,4,10,4,12,4,245,9,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,262,8,6,1,7,1,7,1,7,1,7,1,7,3,7,269,8,7,1,8,1,8,1,8,1,8,1,8,1,8,5,8,277,8,8,10,8,12,8,280,9,8,1,9,1,9,1,9,1,9,3,9,286,8,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,3,12,303,8,12,1,13,1,13,1,13,1,13,1,13,1,13,5,13,311,8,13,10,13,12,13,314,9,13,1,13,3,13,317,8,13,1,13,1,13,1,13,4,13,322,8,13,11,13,12,13,323,1,13,3,13,327,8,13,1,13,5,13,330,8,13,10,13,12,13,333,9,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,5,13,342,8,13,10,13,12,13,345,9,13,1,13,3,13,348,8,13,1,13,1,13,1,13,4,13,353,8,13,11,13,12,13,354,1,13,3,13,358,8,13,1,13,5,13,361,8,13,10,13,12,13,364,9,13,1,13,3,13,367,8,13,1,14,1,14,1,14,3,14,372,8,14,1,14,1,14,1,14,1,14,1,14,1,14,5,14,380,8,14,10,14,12,14,383,9,14,1,14,3,14,386,8,14,3,14,388,8,14,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,425,8,18,1,19,1,19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,3,21,442,8,21,1,22,1,22,1,22,1,22,1,22,1,22,5,22,450,8,22,10,22,12,22,453,9,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,467,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,485,8,23,1,23,1,23,1,23,1,23,1,23,3,23,492,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,501,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,526,8,23,10,23,12,23,529,9,23,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,543,8,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,551,8,24,1,24,1,24,1,24,1,24,1,24,3,24,558,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,567,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,5,24,584,8,24,10,24,12,24,587,9,24,1,25,1,25,1,25,1,25,1,25,3,25,594,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,605,8,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,5,26,632,8,26,10,26,12,26,635,9,26,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,3,27,648,8,27,1,28,1,28,1,28,1,28,1,28,3,28,655,8,28,1,28,1,28,3,28,659,8,28,1,29,1,29,1,29,1,29,1,29,1,29,5,29,667,8,29,10,29,12,29,670,9,29,1,29,3,29,673,8,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,699,8,30,1,31,1,31,1,31,1,31,3,31,705,8,31,1,31,1,31,1,31,3,31,710,8,31,1,31,1,31,1,31,5,31,715,8,31,10,31,12,31,718,9,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,728,8,32,1,33,1,33,1,33,1,33,1,33,3,33,735,8,33,1,33,1,33,1,33,5,33,740,8,33,10,33,12,33,743,9,33,3,33,745,8,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,3,34,754,8,34,1,34,1,34,3,34,758,8,34,1,35,1,35,1,35,1,35,1,35,1,35,3,35,766,8,35,1,36,1,36,1,36,3,36,771,8,36,1,36,3,36,774,8,36,1,36,1,36,1,36,1,36,5,36,780,8,36,10,36,12,36,783,9,36,1,36,3,36,786,8,36,1,36,1,36,1,36,1,37,1,37,3,37,793,8,37,1,37,1,37,3,37,797,8,37,1,37,3,37,800,8,37,1,37,1,37,1,38,1,38,3,38,806,8,38,1,38,3,38,809,8,38,1,38,1,38,1,39,1,39,1,39,3,39,816,8,39,1,39,3,39,819,8,39,1,39,3,39,822,8,39,1,39,1,39,1,39,1,40,1,40,1,40,3,40,830,8,40,1,40,1,40,1,40,5,40,835,8,40,10,40,12,40,838,9,40,1,40,3,40,841,8,40,1,41,1,41,3,41,845,8,41,1,41,1,41,3,41,849,8,41,1,41,3,41,852,8,41,1,41,1,41,1,42,1,42,3,42,858,8,42,1,42,3,42,861,8,42,1,42,3,42,864,8,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,3,43,880,8,43,1,44,1,44,1,44,3,44,885,8,44,1,44,3,44,888,8,44,1,44,1,44,1,44,1,45,1,45,3,45,895,8,45,1,45,3,45,898,8,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,3,46,909,8,46,1,46,3,46,912,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,924,8,46,1,46,3,46,927,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,937,8,46,1,46,3,46,940,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,952,8,46,1,46,1,46,3,46,956,8,46,1,46,3,46,959,8,46,1,46,1,46,1,46,3,46,964,8,46,1,47,1,47,3,47,968,8,47,1,47,3,47,971,8,47,1,47,3,47,974,8,47,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,48,1,48,3,48,986,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,49,3,49,996,8,49,1,50,1,50,1,50,1,50,1,50,1,50,3,50,1004,8,50,1,51,1,51,3,51,1008,8,51,1,51,3,51,1011,8,51,1,51,1,51,1,51,1,51,1,51,1,51,3,51,1019,8,51,1,51,3,51,1022,8,51,1,51,1,51,3,51,1026,8,51,1,52,1,52,3,52,1030,8,52,1,52,3,52,1033,8,52,1,52,1,52,1,53,1,53,3,53,1039,8,53,1,53,3,53,1042,8,53,1,53,1,53,1,53,1,53,1,54,1,54,3,54,1050,8,54,1,54,3,54,1053,8,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,1,55,1,55,1,55,5,55,1065,8,55,10,55,12,55,1068,9,55,3,55,1070,8,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,3,56,1080,8,56,1,57,1,57,1,57,1,57,1,57,1,57,3,57,1088,8,57,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,5,58,1101,8,58,10,58,12,58,1104,9,58,3,58,1106,8,58,1,58,3,58,1109,8,58,1,59,1,59,1,59,1,59,3,59,1115,8,59,1,59,1,59,3,59,1119,8,59,1,59,3,59,1122,8,59,1,59,3,59,1125,8,59,1,59,3,59,1128,8,59,1,59,1,59,1,59,1,60,1,60,1,60,1,61,1,61,3,61,1138,8,61,1,61,1,61,3,61,1142,8,61,1,61,3,61,1145,8,61,1,61,3,61,1148,8,61,1,61,1,61,1,61,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,5,62,1161,8,62,10,62,12,62,1164,9,62,3,62,1166,8,62,1,62,1,62,3,62,1170,8,62,1,63,1,63,1,63,3,63,1175,8,63,1,63,1,63,1,63,1,63,1,63,1,63,3,63,1183,8,63,1,64,1,64,1,64,1,64,1,64,1,64,5,64,1191,8,64,10,64,12,64,1194,9,64,1,65,1,65,1,65,1,65,1,65,1,65,1,65,5,65,1203,8,65,10,65,12,65,1206,9,65,1,66,1,66,1,66,3,66,1211,8,66,1,66,1,66,1,66,5,66,1216,8,66,10,66,12,66,1219,9,66,1,66,3,66,1222,8,66,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,3,67,1236,8,67,1,68,1,68,3,68,1240,8,68,1,68,3,68,1243,8,68,1,68,3,68,1246,8,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,69,1,69,5,69,1257,8,69,10,69,12,69,1260,9,69,1,69,3,69,1263,8,69,1,70,1,70,1,70,1,70,1,70,3,70,1270,8,70,1,70,3,70,1273,8,70,1,70,1,70,1,70,1,70,3,70,1279,8,70,1,70,1,70,3,70,1283,8,70,1,70,1,70,1,71,1,71,3,71,1289,8,71,1,71,3,71,1292,8,71,1,71,3,71,1295,8,71,1,71,1,71,1,71,1,72,1,72,1,72,1,72,1,72,3,72,1305,8,72,1,72,1,72,1,72,1,72,1,72,1,72,3,72,1313,8,72,1,72,1,72,3,72,1317,8,72,1,73,1,73,1,73,3,73,1322,8,73,1,73,1,73,1,73,5,73,1327,8,73,10,73,12,73,1330,9,73,1,73,3,73,1333,8,73,1,74,1,74,3,74,1337,8,74,1,74,3,74,1340,8,74,1,74,3,74,1343,8,74,1,74,1,74,1,74,1,75,1,75,1,75,3,75,1351,8,75,1,75,1,75,1,75,5,75,1356,8,75,10,75,12,75,1359,9,75,1,75,3,75,1362,8,75,1,76,1,76,1,76,1,77,1,77,3,77,1369,8,77,1,77,3,77,1372,8,77,1,77,3,77,1375,8,77,1,77,1,77,1,77,1,78,1,78,1,78,3,78,1383,8,78,1,78,1,78,1,78,5,78,1388,8,78,10,78,12,78,1391,9,78,1,78,3,78,1394,8,78,1,79,1,79,1,79,3,79,1399,8,79,1,79,3,79,1402,8,79,1,79,1,79,1,80,1,80,1,80,3,80,1409,8,80,1,80,1,80,1,80,5,80,1414,8,80,10,80,12,80,1417,9,80,1,80,3,80,1420,8,80,1,81,1,81,3,81,1424,8,81,1,81,1,81,1,81,1,81,3,81,1430,8,81,3,81,1432,8,81,1,81,3,81,1435,8,81,1,81,3,81,1438,8,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,82,1,82,5,82,1449,8,82,10,82,12,82,1452,9,82,1,83,1,83,1,83,1,83,1,83,1,83,5,83,1460,8,83,10,83,12,83,1463,9,83,1,84,1,84,1,84,1,84,1,84,3,84,1470,8,84,1,84,3,84,1473,8,84,1,84,1,84,1,84,1,84,3,84,1479,8,84,1,84,1,84,3,84,1483,8,84,1,84,1,84,1,85,1,85,1,85,1,85,1,85,1,85,5,85,1493,8,85,10,85,12,85,1496,9,85,1,86,4,86,1499,8,86,11,86,12,86,1500,1,87,4,87,1504,8,87,11,87,12,87,1505,1,88,4,88,1509,8,88,11,88,12,88,1510,1,88,0,3,46,48,52,89,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,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,0,28,2,0,45,45,56,56,2,0,49,50,94,95,1,0,58,59,3,0,51,52,68,68,91,93,1,0,49,50,1,0,94,95,1,0,98,99,1,0,96,97,1,0,85,90,2,0,53,53,69,80,1,0,5,6,2,0,6,6,11,11,2,0,6,6,15,15,2,0,6,6,19,19,2,0,6,6,21,21,2,0,6,6,23,23,2,0,6,6,31,31,2,0,6,6,34,34,2,1,6,6,28,28,2,1,6,6,36,36,2,0,56,56,83,83,2,0,6,6,40,40,2,0,6,6,44,44,2,0,6,6,42,42,2,0,6,6,38,38,2,0,6,6,48,48,1,0,55,56,2,0,55,56,106,106,1666,0,190,1,0,0,0,2,192,1,0,0,0,4,208,1,0,0,0,6,233,1,0,0,0,8,235,1,0,0,0,10,248,1,0,0,0,12,261,1,0,0,0,14,268,1,0,0,0,16,270,1,0,0,0,18,285,1,0,0,0,20,287,1,0,0,0,22,290,1,0,0,0,24,302,1,0,0,0,26,366,1,0,0,0,28,387,1,0,0,0,30,389,1,0,0,0,32,393,1,0,0,0,34,397,1,0,0,0,36,424,1,0,0,0,38,426,1,0,0,0,40,429,1,0,0,0,42,441,1,0,0,0,44,443,1,0,0,0,46,466,1,0,0,0,48,542,1,0,0,0,50,588,1,0,0,0,52,604,1,0,0,0,54,647,1,0,0,0,56,658,1,0,0,0,58,660,1,0,0,0,60,698,1,0,0,0,62,704,1,0,0,0,64,727,1,0,0,0,66,729,1,0,0,0,68,757,1,0,0,0,70,765,1,0,0,0,72,767,1,0,0,0,74,790,1,0,0,0,76,803,1,0,0,0,78,812,1,0,0,0,80,826,1,0,0,0,82,842,1,0,0,0,84,855,1,0,0,0,86,879,1,0,0,0,88,881,1,0,0,0,90,892,1,0,0,0,92,963,1,0,0,0,94,965,1,0,0,0,96,978,1,0,0,0,98,995,1,0,0,0,100,1003,1,0,0,0,102,1025,1,0,0,0,104,1027,1,0,0,0,106,1036,1,0,0,0,108,1047,1,0,0,0,110,1056,1,0,0,0,112,1079,1,0,0,0,114,1087,1,0,0,0,116,1108,1,0,0,0,118,1110,1,0,0,0,120,1132,1,0,0,0,122,1135,1,0,0,0,124,1152,1,0,0,0,126,1182,1,0,0,0,128,1184,1,0,0,0,130,1195,1,0,0,0,132,1207,1,0,0,0,134,1235,1,0,0,0,136,1237,1,0,0,0,138,1250,1,0,0,0,140,1264,1,0,0,0,142,1286,1,0,0,0,144,1316,1,0,0,0,146,1318,1,0,0,0,148,1334,1,0,0,0,150,1347,1,0,0,0,152,1363,1,0,0,0,154,1366,1,0,0,0,156,1379,1,0,0,0,158,1395,1,0,0,0,160,1405,1,0,0,0,162,1421,1,0,0,0,164,1442,1,0,0,0,166,1453,1,0,0,0,168,1464,1,0,0,0,170,1486,1,0,0,0,172,1498,1,0,0,0,174,1503,1,0,0,0,176,1508,1,0,0,0,178,180,3,176,88,0,179,178,1,0,0,0,179,180,1,0,0,0,180,181,1,0,0,0,181,182,5,0,0,1,182,191,6,0,-1,0,183,185,3,176,88,0,184,183,1,0,0,0,184,185,1,0,0,0,185,186,1,0,0,0,186,187,3,2,1,0,187,188,5,0,0,1,188,189,6,0,-1,0,189,191,1,0,0,0,190,179,1,0,0,0,190,184,1,0,0,0,191,1,1,0,0,0,192,193,3,6,3,0,193,200,6,1,-1,0,194,195,3,176,88,0,195,196,3,6,3,0,196,197,6,1,-1,0,197,199,1,0,0,0,198,194,1,0,0,0,199,202,1,0,0,0,200,198,1,0,0,0,200,201,1,0,0,0,201,204,1,0,0,0,202,200,1,0,0,0,203,205,3,176,88,0,204,203,1,0,0,0,204,205,1,0,0,0,205,206,1,0,0,0,206,207,6,1,-1,0,207,3,1,0,0,0,208,209,3,6,3,0,209,216,6,2,-1,0,210,211,3,176,88,0,211,212,3,6,3,0,212,213,6,2,-1,0,213,215,1,0,0,0,214,210,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,176,88,0,220,219,1,0,0,0,220,221,1,0,0,0,221,222,1,0,0,0,222,223,6,2,-1,0,223,5,1,0,0,0,224,225,3,60,30,0,225,226,6,3,-1,0,226,234,1,0,0,0,227,228,3,8,4,0,228,229,6,3,-1,0,229,234,1,0,0,0,230,231,3,54,27,0,231,232,6,3,-1,0,232,234,1,0,0,0,233,224,1,0,0,0,233,227,1,0,0,0,233,230,1,0,0,0,234,7,1,0,0,0,235,236,3,12,6,0,236,237,3,10,5,0,237,243,6,4,-1,0,238,239,3,10,5,0,239,240,6,4,-1,0,240,242,1,0,0,0,241,238,1,0,0,0,242,245,1,0,0,0,243,241,1,0,0,0,243,244,1,0,0,0,244,246,1,0,0,0,245,243,1,0,0,0,246,247,6,4,-1,0,247,9,1,0,0,0,248,249,3,18,9,0,249,250,6,5,-1,0,250,11,1,0,0,0,251,252,5,101,0,0,252,262,6,6,-1,0,253,254,5,39,0,0,254,262,6,6,-1,0,255,256,5,43,0,0,256,262,6,6,-1,0,257,258,5,41,0,0,258,262,6,6,-1,0,259,260,5,37,0,0,260,262,6,6,-1,0,261,251,1,0,0,0,261,253,1,0,0,0,261,255,1,0,0,0,261,257,1,0,0,0,261,259,1,0,0,0,262,13,1,0,0,0,263,264,3,12,6,0,264,265,6,7,-1,0,265,269,1,0,0,0,266,267,5,6,0,0,267,269,6,7,-1,0,268,263,1,0,0,0,268,266,1,0,0,0,269,15,1,0,0,0,270,271,3,14,7,0,271,278,6,8,-1,0,272,273,5,57,0,0,273,274,3,14,7,0,274,275,6,8,-1,0,275,277,1,0,0,0,276,272,1,0,0,0,277,280,1,0,0,0,278,276,1,0,0,0,278,279,1,0,0,0,279,17,1,0,0,0,280,278,1,0,0,0,281,282,5,46,0,0,282,286,6,9,-1,0,283,284,5,142,0,0,284,286,6,9,-1,0,285,281,1,0,0,0,285,283,1,0,0,0,286,19,1,0,0,0,287,288,5,102,0,0,288,289,6,10,-1,0,289,21,1,0,0,0,290,291,5,7,0,0,291,292,6,11,-1,0,292,23,1,0,0,0,293,294,3,20,10,0,294,295,6,12,-1,0,295,303,1,0,0,0,296,297,3,18,9,0,297,298,6,12,-1,0,298,303,1,0,0,0,299,300,3,22,11,0,300,301,6,12,-1,0,301,303,1,0,0,0,302,293,1,0,0,0,302,296,1,0,0,0,302,299,1,0,0,0,303,25,1,0,0,0,304,305,5,64,0,0,305,306,5,65,0,0,306,367,6,13,-1,0,307,312,5,64,0,0,308,311,5,55,0,0,309,311,3,174,87,0,310,308,1,0,0,0,310,309,1,0,0,0,311,314,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,316,1,0,0,0,314,312,1,0,0,0,315,317,3,28,14,0,316,315,1,0,0,0,316,317,1,0,0,0,317,318,1,0,0,0,318,331,6,13,-1,0,319,322,5,55,0,0,320,322,3,174,87,0,321,319,1,0,0,0,321,320,1,0,0,0,322,323,1,0,0,0,323,321,1,0,0,0,323,324,1,0,0,0,324,326,1,0,0,0,325,327,3,28,14,0,326,325,1,0,0,0,326,327,1,0,0,0,327,328,1,0,0,0,328,330,6,13,-1,0,329,321,1,0,0,0,330,333,1,0,0,0,331,329,1,0,0,0,331,332,1,0,0,0,332,334,1,0,0,0,333,331,1,0,0,0,334,367,5,65,0,0,335,336,5,66,0,0,336,337,5,67,0,0,337,367,6,13,-1,0,338,343,5,66,0,0,339,342,5,55,0,0,340,342,3,174,87,0,341,339,1,0,0,0,341,340,1,0,0,0,342,345,1,0,0,0,343,341,1,0,0,0,343,344,1,0,0,0,344,347,1,0,0,0,345,343,1,0,0,0,346,348,3,28,14,0,347,346,1,0,0,0,347,348,1,0,0,0,348,349,1,0,0,0,349,362,6,13,-1,0,350,353,5,55,0,0,351,353,3,174,87,0,352,350,1,0,0,0,352,351,1,0,0,0,353,354,1,0,0,0,354,352,1,0,0,0,354,355,1,0,0,0,355,357,1,0,0,0,356,358,3,28,14,0,357,356,1,0,0,0,357,358,1,0,0,0,358,359,1,0,0,0,359,361,6,13,-1,0,360,352,1,0,0,0,361,364,1,0,0,0,362,360,1,0,0,0,362,363,1,0,0,0,363,365,1,0,0,0,364,362,1,0,0,0,365,367,5,67,0,0,366,304,1,0,0,0,366,307,1,0,0,0,366,335,1,0,0,0,366,338,1,0,0,0,367,27,1,0,0,0,368,369,7,0,0,0,369,388,6,14,-1,0,370,372,7,0,0,0,371,370,1,0,0,0,371,372,1,0,0,0,372,373,1,0,0,0,373,374,3,42,21,0,374,381,6,14,-1,0,375,376,7,0,0,0,376,377,3,42,21,0,377,378,6,14,-1,0,378,380,1,0,0,0,379,375,1,0,0,0,380,383,1,0,0,0,381,379,1,0,0,0,381,382,1,0,0,0,382,385,1,0,0,0,383,381,1,0,0,0,384,386,7,0,0,0,385,384,1,0,0,0,385,386,1,0,0,0,386,388,1,0,0,0,387,368,1,0,0,0,387,371,1,0,0,0,388,29,1,0,0,0,389,390,5,60,0,0,390,391,3,16,8,0,391,392,6,15,-1,0,392,31,1,0,0,0,393,394,5,61,0,0,394,395,3,16,8,0,395,396,6,16,-1,0,396,33,1,0,0,0,397,398,5,60,0,0,398,399,3,110,55,0,399,400,3,54,27,0,400,401,6,17,-1,0,401,35,1,0,0,0,402,403,3,12,6,0,403,404,6,18,-1,0,404,425,1,0,0,0,405,406,5,3,0,0,406,425,6,18,-1,0,407,408,3,24,12,0,408,409,6,18,-1,0,409,425,1,0,0,0,410,411,3,30,15,0,411,412,6,18,-1,0,412,425,1,0,0,0,413,414,3,32,16,0,414,415,6,18,-1,0,415,425,1,0,0,0,416,417,3,26,13,0,417,418,6,18,-1,0,418,425,1,0,0,0,419,420,5,62,0,0,420,421,3,54,27,0,421,422,5,63,0,0,422,423,6,18,-1,0,423,425,1,0,0,0,424,402,1,0,0,0,424,405,1,0,0,0,424,407,1,0,0,0,424,410,1,0,0,0,424,413,1,0,0,0,424,416,1,0,0,0,424,419,1,0,0,0,425,37,1,0,0,0,426,427,5,54,0,0,427,428,6,19,-1,0,428,39,1,0,0,0,429,430,5,58,0,0,430,431,6,20,-1,0,431,41,1,0,0,0,432,433,3,54,27,0,433,434,6,21,-1,0,434,442,1,0,0,0,435,436,3,38,19,0,436,437,6,21,-1,0,437,442,1,0,0,0,438,439,3,40,20,0,439,440,6,21,-1,0,440,442,1,0,0,0,441,432,1,0,0,0,441,435,1,0,0,0,441,438,1,0,0,0,442,43,1,0,0,0,443,444,3,42,21,0,444,451,6,22,-1,0,445,446,5,56,0,0,446,447,3,42,21,0,447,448,6,22,-1,0,448,450,1,0,0,0,449,445,1,0,0,0,450,453,1,0,0,0,451,449,1,0,0,0,451,452,1,0,0,0,452,45,1,0,0,0,453,451,1,0,0,0,454,455,6,23,-1,0,455,456,3,36,18,0,456,457,6,23,-1,0,457,467,1,0,0,0,458,459,7,1,0,0,459,460,3,46,23,4,460,461,6,23,-1,0,461,467,1,0,0,0,462,463,7,2,0,0,463,464,3,46,23,3,464,465,6,23,-1,0,465,467,1,0,0,0,466,454,1,0,0,0,466,458,1,0,0,0,466,462,1,0,0,0,467,527,1,0,0,0,468,469,10,2,0,0,469,470,7,3,0,0,470,471,3,46,23,3,471,472,6,23,-1,0,472,526,1,0,0,0,473,474,10,1,0,0,474,475,7,4,0,0,475,476,3,46,23,2,476,477,6,23,-1,0,477,526,1,0,0,0,478,479,10,12,0,0,479,480,7,5,0,0,480,526,6,23,-1,0,481,482,10,11,0,0,482,484,5,62,0,0,483,485,3,44,22,0,484,483,1,0,0,0,484,485,1,0,0,0,485,486,1,0,0,0,486,487,5,63,0,0,487,526,6,23,-1,0,488,489,10,10,0,0,489,491,5,66,0,0,490,492,3,44,22,0,491,490,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,5,67,0,0,494,526,6,23,-1,0,495,496,10,9,0,0,496,497,5,60,0,0,497,498,3,16,8,0,498,500,5,62,0,0,499,501,3,44,22,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,5,63,0,0,503,504,6,23,-1,0,504,526,1,0,0,0,505,506,10,8,0,0,506,507,7,6,0,0,507,526,6,23,-1,0,508,509,10,7,0,0,509,510,5,57,0,0,510,511,3,14,7,0,511,512,6,23,-1,0,512,526,1,0,0,0,513,514,10,6,0,0,514,515,5,57,0,0,515,516,5,62,0,0,516,517,3,54,27,0,517,518,5,63,0,0,518,519,6,23,-1,0,519,526,1,0,0,0,520,521,10,5,0,0,521,522,7,7,0,0,522,523,3,48,24,0,523,524,6,23,-1,0,524,526,1,0,0,0,525,468,1,0,0,0,525,473,1,0,0,0,525,478,1,0,0,0,525,481,1,0,0,0,525,488,1,0,0,0,525,495,1,0,0,0,525,505,1,0,0,0,525,508,1,0,0,0,525,513,1,0,0,0,525,520,1,0,0,0,526,529,1,0,0,0,527,525,1,0,0,0,527,528,1,0,0,0,528,47,1,0,0,0,529,527,1,0,0,0,530,531,6,24,-1,0,531,532,3,36,18,0,532,533,6,24,-1,0,533,543,1,0,0,0,534,535,7,1,0,0,535,536,3,48,24,2,536,537,6,24,-1,0,537,543,1,0,0,0,538,539,7,2,0,0,539,540,3,48,24,1,540,541,6,24,-1,0,541,543,1,0,0,0,542,530,1,0,0,0,542,534,1,0,0,0,542,538,1,0,0,0,543,585,1,0,0,0,544,545,10,8,0,0,545,546,7,5,0,0,546,584,6,24,-1,0,547,548,10,7,0,0,548,550,5,62,0,0,549,551,3,44,22,0,550,549,1,0,0,0,550,551,1,0,0,0,551,552,1,0,0,0,552,553,5,63,0,0,553,584,6,24,-1,0,554,555,10,6,0,0,555,557,5,66,0,0,556,558,3,44,22,0,557,556,1,0,0,0,557,558,1,0,0,0,558,559,1,0,0,0,559,560,5,67,0,0,560,584,6,24,-1,0,561,562,10,5,0,0,562,563,5,60,0,0,563,564,3,16,8,0,564,566,5,62,0,0,565,567,3,44,22,0,566,565,1,0,0,0,566,567,1,0,0,0,567,568,1,0,0,0,568,569,5,63,0,0,569,570,6,24,-1,0,570,584,1,0,0,0,571,572,10,4,0,0,572,573,5,57,0,0,573,574,3,14,7,0,574,575,6,24,-1,0,575,584,1,0,0,0,576,577,10,3,0,0,577,578,5,57,0,0,578,579,5,62,0,0,579,580,3,54,27,0,580,581,5,63,0,0,581,582,6,24,-1,0,582,584,1,0,0,0,583,544,1,0,0,0,583,547,1,0,0,0,583,554,1,0,0,0,583,561,1,0,0,0,583,571,1,0,0,0,583,576,1,0,0,0,584,587,1,0,0,0,585,583,1,0,0,0,585,586,1,0,0,0,586,49,1,0,0,0,587,585,1,0,0,0,588,589,3,46,23,0,589,590,5,54,0,0,590,593,3,46,23,0,591,592,5,54,0,0,592,594,3,46,23,0,593,591,1,0,0,0,593,594,1,0,0,0,594,595,1,0,0,0,595,596,6,25,-1,0,596,51,1,0,0,0,597,598,6,26,-1,0,598,599,3,46,23,0,599,600,6,26,-1,0,600,605,1,0,0,0,601,602,3,50,25,0,602,603,6,26,-1,0,603,605,1,0,0,0,604,597,1,0,0,0,604,601,1,0,0,0,605,633,1,0,0,0,606,607,10,5,0,0,607,608,7,8,0,0,608,609,3,52,26,6,609,610,6,26,-1,0,610,632,1,0,0,0,611,612,10,4,0,0,612,613,5,83,0,0,613,614,3,52,26,5,614,615,6,26,-1,0,615,632,1,0,0,0,616,617,10,3,0,0,617,618,5,84,0,0,618,619,3,52,26,4,619,620,6,26,-1,0,620,632,1,0,0,0,621,622,10,2,0,0,622,623,5,81,0,0,623,624,3,52,26,3,624,625,6,26,-1,0,625,632,1,0,0,0,626,627,10,1,0,0,627,628,5,82,0,0,628,629,3,52,26,2,629,630,6,26,-1,0,630,632,1,0,0,0,631,606,1,0,0,0,631,611,1,0,0,0,631,616,1,0,0,0,631,621,1,0,0,0,631,626,1,0,0,0,632,635,1,0,0,0,633,631,1,0,0,0,633,634,1,0,0,0,634,53,1,0,0,0,635,633,1,0,0,0,636,637,3,52,26,0,637,638,6,27,-1,0,638,648,1,0,0,0,639,640,3,52,26,0,640,641,7,9,0,0,641,642,3,54,27,0,642,643,6,27,-1,0,643,648,1,0,0,0,644,645,3,34,17,0,645,646,6,27,-1,0,646,648,1,0,0,0,647,636,1,0,0,0,647,639,1,0,0,0,647,644,1,0,0,0,648,55,1,0,0,0,649,650,3,52,26,0,650,651,6,28,-1,0,651,659,1,0,0,0,652,654,5,64,0,0,653,655,3,58,29,0,654,653,1,0,0,0,654,655,1,0,0,0,655,656,1,0,0,0,656,657,5,65,0,0,657,659,6,28,-1,0,658,649,1,0,0,0,658,652,1,0,0,0,659,57,1,0,0,0,660,661,3,42,21,0,661,668,6,29,-1,0,662,663,7,0,0,0,663,664,3,42,21,0,664,665,6,29,-1,0,665,667,1,0,0,0,666,662,1,0,0,0,667,670,1,0,0,0,668,666,1,0,0,0,668,669,1,0,0,0,669,672,1,0,0,0,670,668,1,0,0,0,671,673,7,0,0,0,672,671,1,0,0,0,672,673,1,0,0,0,673,59,1,0,0,0,674,675,3,62,31,0,675,676,6,30,-1,0,676,699,1,0,0,0,677,678,3,66,33,0,678,679,6,30,-1,0,679,699,1,0,0,0,680,681,3,70,35,0,681,682,6,30,-1,0,682,699,1,0,0,0,683,684,3,86,43,0,684,685,6,30,-1,0,685,699,1,0,0,0,686,687,3,98,49,0,687,688,6,30,-1,0,688,699,1,0,0,0,689,690,3,100,50,0,690,691,6,30,-1,0,691,699,1,0,0,0,692,693,3,118,59,0,693,694,6,30,-1,0,694,699,1,0,0,0,695,696,3,122,61,0,696,697,6,30,-1,0,697,699,1,0,0,0,698,674,1,0,0,0,698,677,1,0,0,0,698,680,1,0,0,0,698,683,1,0,0,0,698,686,1,0,0,0,698,689,1,0,0,0,698,692,1,0,0,0,698,695,1,0,0,0,699,61,1,0,0,0,700,701,5,1,0,0,701,705,6,31,-1,0,702,703,5,2,0,0,703,705,6,31,-1,0,704,700,1,0,0,0,704,702,1,0,0,0,705,706,1,0,0,0,706,707,3,64,32,0,707,716,6,31,-1,0,708,710,5,56,0,0,709,708,1,0,0,0,709,710,1,0,0,0,710,711,1,0,0,0,711,712,3,64,32,0,712,713,6,31,-1,0,713,715,1,0,0,0,714,709,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,63,1,0,0,0,718,716,1,0,0,0,719,720,3,12,6,0,720,721,6,32,-1,0,721,728,1,0,0,0,722,723,3,12,6,0,723,724,5,53,0,0,724,725,3,54,27,0,725,726,6,32,-1,0,726,728,1,0,0,0,727,719,1,0,0,0,727,722,1,0,0,0,728,65,1,0,0,0,729,730,5,3,0,0,730,744,6,33,-1,0,731,732,3,68,34,0,732,741,6,33,-1,0,733,735,5,56,0,0,734,733,1,0,0,0,734,735,1,0,0,0,735,736,1,0,0,0,736,737,3,68,34,0,737,738,6,33,-1,0,738,740,1,0,0,0,739,734,1,0,0,0,740,743,1,0,0,0,741,739,1,0,0,0,741,742,1,0,0,0,742,745,1,0,0,0,743,741,1,0,0,0,744,731,1,0,0,0,744,745,1,0,0,0,745,67,1,0,0,0,746,747,3,16,8,0,747,748,6,34,-1,0,748,758,1,0,0,0,749,753,3,16,8,0,750,751,5,57,0,0,751,754,5,51,0,0,752,754,5,91,0,0,753,750,1,0,0,0,753,752,1,0,0,0,754,755,1,0,0,0,755,756,6,34,-1,0,756,758,1,0,0,0,757,746,1,0,0,0,757,749,1,0,0,0,758,69,1,0,0,0,759,760,3,72,36,0,760,761,6,35,-1,0,761,766,1,0,0,0,762,763,3,78,39,0,763,764,6,35,-1,0,764,766,1,0,0,0,765,759,1,0,0,0,765,762,1,0,0,0,766,71,1,0,0,0,767,768,5,4,0,0,768,770,3,54,27,0,769,771,3,176,88,0,770,769,1,0,0,0,770,771,1,0,0,0,771,773,1,0,0,0,772,774,3,4,2,0,773,772,1,0,0,0,773,774,1,0,0,0,774,775,1,0,0,0,775,781,6,36,-1,0,776,777,3,74,37,0,777,778,6,36,-1,0,778,780,1,0,0,0,779,776,1,0,0,0,780,783,1,0,0,0,781,779,1,0,0,0,781,782,1,0,0,0,782,785,1,0,0,0,783,781,1,0,0,0,784,786,3,76,38,0,785,784,1,0,0,0,785,786,1,0,0,0,786,787,1,0,0,0,787,788,6,36,-1,0,788,789,7,10,0,0,789,73,1,0,0,0,790,792,5,8,0,0,791,793,3,176,88,0,792,791,1,0,0,0,792,793,1,0,0,0,793,794,1,0,0,0,794,796,3,54,27,0,795,797,3,176,88,0,796,795,1,0,0,0,796,797,1,0,0,0,797,799,1,0,0,0,798,800,3,4,2,0,799,798,1,0,0,0,799,800,1,0,0,0,800,801,1,0,0,0,801,802,6,37,-1,0,802,75,1,0,0,0,803,805,5,9,0,0,804,806,3,176,88,0,805,804,1,0,0,0,805,806,1,0,0,0,806,808,1,0,0,0,807,809,3,4,2,0,808,807,1,0,0,0,808,809,1,0,0,0,809,810,1,0,0,0,810,811,6,38,-1,0,811,77,1,0,0,0,812,813,5,10,0,0,813,815,3,54,27,0,814,816,3,176,88,0,815,814,1,0,0,0,815,816,1,0,0,0,816,818,1,0,0,0,817,819,3,80,40,0,818,817,1,0,0,0,818,819,1,0,0,0,819,821,1,0,0,0,820,822,3,84,42,0,821,820,1,0,0,0,821,822,1,0,0,0,822,823,1,0,0,0,823,824,7,11,0,0,824,825,6,39,-1,0,825,79,1,0,0,0,826,827,3,82,41,0,827,836,6,40,-1,0,828,830,3,176,88,0,829,828,1,0,0,0,829,830,1,0,0,0,830,831,1,0,0,0,831,832,3,82,41,0,832,833,6,40,-1,0,833,835,1,0,0,0,834,829,1,0,0,0,835,838,1,0,0,0,836,834,1,0,0,0,836,837,1,0,0,0,837,840,1,0,0,0,838,836,1,0,0,0,839,841,3,176,88,0,840,839,1,0,0,0,840,841,1,0,0,0,841,81,1,0,0,0,842,844,5,12,0,0,843,845,3,176,88,0,844,843,1,0,0,0,844,845,1,0,0,0,845,846,1,0,0,0,846,848,3,54,27,0,847,849,3,176,88,0,848,847,1,0,0,0,848,849,1,0,0,0,849,851,1,0,0,0,850,852,3,4,2,0,851,850,1,0,0,0,851,852,1,0,0,0,852,853,1,0,0,0,853,854,6,41,-1,0,854,83,1,0,0,0,855,857,5,13,0,0,856,858,3,176,88,0,857,856,1,0,0,0,857,858,1,0,0,0,858,860,1,0,0,0,859,861,3,4,2,0,860,859,1,0,0,0,860,861,1,0,0,0,861,863,1,0,0,0,862,864,3,176,88,0,863,862,1,0,0,0,863,864,1,0,0,0,864,865,1,0,0,0,865,866,6,42,-1,0,866,85,1,0,0,0,867,868,3,88,44,0,868,869,6,43,-1,0,869,880,1,0,0,0,870,871,3,90,45,0,871,872,6,43,-1,0,872,880,1,0,0,0,873,874,3,92,46,0,874,875,6,43,-1,0,875,880,1,0,0,0,876,877,3,94,47,0,877,878,6,43,-1,0,878,880,1,0,0,0,879,867,1,0,0,0,879,870,1,0,0,0,879,873,1,0,0,0,879,876,1,0,0,0,880,87,1,0,0,0,881,882,5,14,0,0,882,884,3,54,27,0,883,885,3,176,88,0,884,883,1,0,0,0,884,885,1,0,0,0,885,887,1,0,0,0,886,888,3,4,2,0,887,886,1,0,0,0,887,888,1,0,0,0,888,889,1,0,0,0,889,890,7,12,0,0,890,891,6,44,-1,0,891,89,1,0,0,0,892,894,5,16,0,0,893,895,3,176,88,0,894,893,1,0,0,0,894,895,1,0,0,0,895,897,1,0,0,0,896,898,3,4,2,0,897,896,1,0,0,0,897,898,1,0,0,0,898,899,1,0,0,0,899,900,5,17,0,0,900,901,3,54,27,0,901,902,6,45,-1,0,902,91,1,0,0,0,903,904,5,18,0,0,904,905,3,56,28,0,905,906,5,53,0,0,906,908,3,54,27,0,907,909,3,176,88,0,908,907,1,0,0,0,908,909,1,0,0,0,909,911,1,0,0,0,910,912,3,4,2,0,911,910,1,0,0,0,911,912,1,0,0,0,912,913,1,0,0,0,913,914,7,13,0,0,914,915,6,46,-1,0,915,964,1,0,0,0,916,917,5,18,0,0,917,918,5,62,0,0,918,919,3,56,28,0,919,920,5,53,0,0,920,921,3,54,27,0,921,923,5,63,0,0,922,924,3,176,88,0,923,922,1,0,0,0,923,924,1,0,0,0,924,926,1,0,0,0,925,927,3,4,2,0,926,925,1,0,0,0,926,927,1,0,0,0,927,928,1,0,0,0,928,929,7,13,0,0,929,930,6,46,-1,0,930,964,1,0,0,0,931,932,5,20,0,0,932,933,3,56,28,0,933,934,5,53,0,0,934,936,3,54,27,0,935,937,3,176,88,0,936,935,1,0,0,0,936,937,1,0,0,0,937,939,1,0,0,0,938,940,3,4,2,0,939,938,1,0,0,0,939,940,1,0,0,0,940,941,1,0,0,0,941,942,7,14,0,0,942,943,6,46,-1,0,943,964,1,0,0,0,944,945,5,20,0,0,945,946,5,62,0,0,946,947,3,56,28,0,947,948,5,53,0,0,948,951,3,54,27,0,949,950,5,56,0,0,950,952,3,54,27,0,951,949,1,0,0,0,951,952,1,0,0,0,952,953,1,0,0,0,953,955,5,63,0,0,954,956,3,176,88,0,955,954,1,0,0,0,955,956,1,0,0,0,956,958,1,0,0,0,957,959,3,4,2,0,958,957,1,0,0,0,958,959,1,0,0,0,959,960,1,0,0,0,960,961,7,14,0,0,961,962,6,46,-1,0,962,964,1,0,0,0,963,903,1,0,0,0,963,916,1,0,0,0,963,931,1,0,0,0,963,944,1,0,0,0,964,93,1,0,0,0,965,967,5,22,0,0,966,968,3,96,48,0,967,966,1,0,0,0,967,968,1,0,0,0,968,970,1,0,0,0,969,971,3,176,88,0,970,969,1,0,0,0,970,971,1,0,0,0,971,973,1,0,0,0,972,974,3,4,2,0,973,972,1,0,0,0,973,974,1,0,0,0,974,975,1,0,0,0,975,976,7,15,0,0,976,977,6,47,-1,0,977,95,1,0,0,0,978,979,5,62,0,0,979,980,3,54,27,0,980,985,6,48,-1,0,981,982,5,56,0,0,982,983,3,54,27,0,983,984,6,48,-1,0,984,986,1,0,0,0,985,981,1,0,0,0,985,986,1,0,0,0,986,987,1,0,0,0,987,988,5,63,0,0,988,97,1,0,0,0,989,990,5,24,0,0,990,996,6,49,-1,0,991,992,5,25,0,0,992,996,6,49,-1,0,993,994,5,26,0,0,994,996,6,49,-1,0,995,989,1,0,0,0,995,991,1,0,0,0,995,993,1,0,0,0,996,99,1,0,0,0,997,998,3,102,51,0,998,999,6,50,-1,0,999,1004,1,0,0,0,1e3,1001,3,106,53,0,1001,1002,6,50,-1,0,1002,1004,1,0,0,0,1003,997,1,0,0,0,1003,1e3,1,0,0,0,1004,101,1,0,0,0,1005,1007,5,29,0,0,1006,1008,3,176,88,0,1007,1006,1,0,0,0,1007,1008,1,0,0,0,1008,1010,1,0,0,0,1009,1011,3,4,2,0,1010,1009,1,0,0,0,1010,1011,1,0,0,0,1011,1012,1,0,0,0,1012,1013,3,104,52,0,1013,1014,7,16,0,0,1014,1015,6,51,-1,0,1015,1026,1,0,0,0,1016,1018,5,29,0,0,1017,1019,3,176,88,0,1018,1017,1,0,0,0,1018,1019,1,0,0,0,1019,1021,1,0,0,0,1020,1022,3,4,2,0,1021,1020,1,0,0,0,1021,1022,1,0,0,0,1022,1023,1,0,0,0,1023,1024,7,16,0,0,1024,1026,6,51,-1,0,1025,1005,1,0,0,0,1025,1016,1,0,0,0,1026,103,1,0,0,0,1027,1029,5,30,0,0,1028,1030,3,176,88,0,1029,1028,1,0,0,0,1029,1030,1,0,0,0,1030,1032,1,0,0,0,1031,1033,3,4,2,0,1032,1031,1,0,0,0,1032,1033,1,0,0,0,1033,1034,1,0,0,0,1034,1035,6,52,-1,0,1035,105,1,0,0,0,1036,1038,5,32,0,0,1037,1039,3,176,88,0,1038,1037,1,0,0,0,1038,1039,1,0,0,0,1039,1041,1,0,0,0,1040,1042,3,4,2,0,1041,1040,1,0,0,0,1041,1042,1,0,0,0,1042,1043,1,0,0,0,1043,1044,3,108,54,0,1044,1045,7,17,0,0,1045,1046,6,53,-1,0,1046,107,1,0,0,0,1047,1049,5,33,0,0,1048,1050,3,176,88,0,1049,1048,1,0,0,0,1049,1050,1,0,0,0,1050,1052,1,0,0,0,1051,1053,3,4,2,0,1052,1051,1,0,0,0,1052,1053,1,0,0,0,1053,1054,1,0,0,0,1054,1055,6,54,-1,0,1055,109,1,0,0,0,1056,1057,5,62,0,0,1057,1069,6,55,-1,0,1058,1059,3,112,56,0,1059,1066,6,55,-1,0,1060,1061,5,56,0,0,1061,1062,3,112,56,0,1062,1063,6,55,-1,0,1063,1065,1,0,0,0,1064,1060,1,0,0,0,1065,1068,1,0,0,0,1066,1064,1,0,0,0,1066,1067,1,0,0,0,1067,1070,1,0,0,0,1068,1066,1,0,0,0,1069,1058,1,0,0,0,1069,1070,1,0,0,0,1070,1071,1,0,0,0,1071,1072,5,63,0,0,1072,111,1,0,0,0,1073,1074,3,64,32,0,1074,1075,6,56,-1,0,1075,1080,1,0,0,0,1076,1077,3,40,20,0,1077,1078,6,56,-1,0,1078,1080,1,0,0,0,1079,1073,1,0,0,0,1079,1076,1,0,0,0,1080,113,1,0,0,0,1081,1082,3,12,6,0,1082,1083,6,57,-1,0,1083,1088,1,0,0,0,1084,1085,3,40,20,0,1085,1086,6,57,-1,0,1086,1088,1,0,0,0,1087,1081,1,0,0,0,1087,1084,1,0,0,0,1088,115,1,0,0,0,1089,1090,3,114,57,0,1090,1091,6,58,-1,0,1091,1109,1,0,0,0,1092,1093,5,64,0,0,1093,1105,6,58,-1,0,1094,1095,3,114,57,0,1095,1102,6,58,-1,0,1096,1097,7,0,0,0,1097,1098,3,114,57,0,1098,1099,6,58,-1,0,1099,1101,1,0,0,0,1100,1096,1,0,0,0,1101,1104,1,0,0,0,1102,1100,1,0,0,0,1102,1103,1,0,0,0,1103,1106,1,0,0,0,1104,1102,1,0,0,0,1105,1094,1,0,0,0,1105,1106,1,0,0,0,1106,1107,1,0,0,0,1107,1109,5,65,0,0,1108,1089,1,0,0,0,1108,1092,1,0,0,0,1109,117,1,0,0,0,1110,1114,5,27,0,0,1111,1112,3,116,58,0,1112,1113,5,53,0,0,1113,1115,1,0,0,0,1114,1111,1,0,0,0,1114,1115,1,0,0,0,1115,1116,1,0,0,0,1116,1118,3,120,60,0,1117,1119,3,110,55,0,1118,1117,1,0,0,0,1118,1119,1,0,0,0,1119,1121,1,0,0,0,1120,1122,3,176,88,0,1121,1120,1,0,0,0,1121,1122,1,0,0,0,1122,1124,1,0,0,0,1123,1125,3,160,80,0,1124,1123,1,0,0,0,1124,1125,1,0,0,0,1125,1127,1,0,0,0,1126,1128,3,4,2,0,1127,1126,1,0,0,0,1127,1128,1,0,0,0,1128,1129,1,0,0,0,1129,1130,7,18,0,0,1130,1131,6,59,-1,0,1131,119,1,0,0,0,1132,1133,3,16,8,0,1133,1134,6,60,-1,0,1134,121,1,0,0,0,1135,1137,5,35,0,0,1136,1138,3,124,62,0,1137,1136,1,0,0,0,1137,1138,1,0,0,0,1138,1139,1,0,0,0,1139,1141,3,16,8,0,1140,1142,3,130,65,0,1141,1140,1,0,0,0,1141,1142,1,0,0,0,1142,1144,1,0,0,0,1143,1145,3,176,88,0,1144,1143,1,0,0,0,1144,1145,1,0,0,0,1145,1147,1,0,0,0,1146,1148,3,132,66,0,1147,1146,1,0,0,0,1147,1148,1,0,0,0,1148,1149,1,0,0,0,1149,1150,7,19,0,0,1150,1151,6,61,-1,0,1151,123,1,0,0,0,1152,1153,5,62,0,0,1153,1165,6,62,-1,0,1154,1155,3,126,63,0,1155,1162,6,62,-1,0,1156,1157,5,56,0,0,1157,1158,3,126,63,0,1158,1159,6,62,-1,0,1159,1161,1,0,0,0,1160,1156,1,0,0,0,1161,1164,1,0,0,0,1162,1160,1,0,0,0,1162,1163,1,0,0,0,1163,1166,1,0,0,0,1164,1162,1,0,0,0,1165,1154,1,0,0,0,1165,1166,1,0,0,0,1166,1167,1,0,0,0,1167,1169,5,63,0,0,1168,1170,3,176,88,0,1169,1168,1,0,0,0,1169,1170,1,0,0,0,1170,125,1,0,0,0,1171,1174,3,12,6,0,1172,1173,5,53,0,0,1173,1175,3,54,27,0,1174,1172,1,0,0,0,1174,1175,1,0,0,0,1175,1176,1,0,0,0,1176,1177,6,63,-1,0,1177,1183,1,0,0,0,1178,1179,7,2,0,0,1179,1180,3,12,6,0,1180,1181,6,63,-1,0,1181,1183,1,0,0,0,1182,1171,1,0,0,0,1182,1178,1,0,0,0,1183,127,1,0,0,0,1184,1185,3,12,6,0,1185,1192,6,64,-1,0,1186,1187,5,57,0,0,1187,1188,3,12,6,0,1188,1189,6,64,-1,0,1189,1191,1,0,0,0,1190,1186,1,0,0,0,1191,1194,1,0,0,0,1192,1190,1,0,0,0,1192,1193,1,0,0,0,1193,129,1,0,0,0,1194,1192,1,0,0,0,1195,1196,5,85,0,0,1196,1197,3,16,8,0,1197,1204,6,65,-1,0,1198,1199,7,20,0,0,1199,1200,3,16,8,0,1200,1201,6,65,-1,0,1201,1203,1,0,0,0,1202,1198,1,0,0,0,1203,1206,1,0,0,0,1204,1202,1,0,0,0,1204,1205,1,0,0,0,1205,131,1,0,0,0,1206,1204,1,0,0,0,1207,1208,3,134,67,0,1208,1217,6,66,-1,0,1209,1211,3,176,88,0,1210,1209,1,0,0,0,1210,1211,1,0,0,0,1211,1212,1,0,0,0,1212,1213,3,134,67,0,1213,1214,6,66,-1,0,1214,1216,1,0,0,0,1215,1210,1,0,0,0,1216,1219,1,0,0,0,1217,1215,1,0,0,0,1217,1218,1,0,0,0,1218,1221,1,0,0,0,1219,1217,1,0,0,0,1220,1222,3,176,88,0,1221,1220,1,0,0,0,1221,1222,1,0,0,0,1222,133,1,0,0,0,1223,1224,3,136,68,0,1224,1225,6,67,-1,0,1225,1236,1,0,0,0,1226,1227,3,142,71,0,1227,1228,6,67,-1,0,1228,1236,1,0,0,0,1229,1230,3,148,74,0,1230,1231,6,67,-1,0,1231,1236,1,0,0,0,1232,1233,3,154,77,0,1233,1234,6,67,-1,0,1234,1236,1,0,0,0,1235,1223,1,0,0,0,1235,1226,1,0,0,0,1235,1229,1,0,0,0,1235,1232,1,0,0,0,1236,135,1,0,0,0,1237,1239,5,39,0,0,1238,1240,3,124,62,0,1239,1238,1,0,0,0,1239,1240,1,0,0,0,1240,1242,1,0,0,0,1241,1243,3,176,88,0,1242,1241,1,0,0,0,1242,1243,1,0,0,0,1243,1245,1,0,0,0,1244,1246,3,138,69,0,1245,1244,1,0,0,0,1245,1246,1,0,0,0,1246,1247,1,0,0,0,1247,1248,7,21,0,0,1248,1249,6,68,-1,0,1249,137,1,0,0,0,1250,1251,3,140,70,0,1251,1258,6,69,-1,0,1252,1253,3,176,88,0,1253,1254,3,140,70,0,1254,1255,6,69,-1,0,1255,1257,1,0,0,0,1256,1252,1,0,0,0,1257,1260,1,0,0,0,1258,1256,1,0,0,0,1258,1259,1,0,0,0,1259,1262,1,0,0,0,1260,1258,1,0,0,0,1261,1263,3,176,88,0,1262,1261,1,0,0,0,1262,1263,1,0,0,0,1263,139,1,0,0,0,1264,1269,3,12,6,0,1265,1266,5,62,0,0,1266,1267,3,44,22,0,1267,1268,5,63,0,0,1268,1270,1,0,0,0,1269,1265,1,0,0,0,1269,1270,1,0,0,0,1270,1272,1,0,0,0,1271,1273,3,16,8,0,1272,1271,1,0,0,0,1272,1273,1,0,0,0,1273,1278,1,0,0,0,1274,1275,5,66,0,0,1275,1276,3,44,22,0,1276,1277,5,67,0,0,1277,1279,1,0,0,0,1278,1274,1,0,0,0,1278,1279,1,0,0,0,1279,1282,1,0,0,0,1280,1281,5,53,0,0,1281,1283,3,54,27,0,1282,1280,1,0,0,0,1282,1283,1,0,0,0,1283,1284,1,0,0,0,1284,1285,6,70,-1,0,1285,141,1,0,0,0,1286,1288,5,43,0,0,1287,1289,3,124,62,0,1288,1287,1,0,0,0,1288,1289,1,0,0,0,1289,1291,1,0,0,0,1290,1292,3,176,88,0,1291,1290,1,0,0,0,1291,1292,1,0,0,0,1292,1294,1,0,0,0,1293,1295,3,146,73,0,1294,1293,1,0,0,0,1294,1295,1,0,0,0,1295,1296,1,0,0,0,1296,1297,7,22,0,0,1297,1298,6,71,-1,0,1298,143,1,0,0,0,1299,1300,3,118,59,0,1300,1301,6,72,-1,0,1301,1317,1,0,0,0,1302,1304,3,128,64,0,1303,1305,3,110,55,0,1304,1303,1,0,0,0,1304,1305,1,0,0,0,1305,1306,1,0,0,0,1306,1307,6,72,-1,0,1307,1317,1,0,0,0,1308,1309,3,116,58,0,1309,1310,5,53,0,0,1310,1312,3,128,64,0,1311,1313,3,110,55,0,1312,1311,1,0,0,0,1312,1313,1,0,0,0,1313,1314,1,0,0,0,1314,1315,6,72,-1,0,1315,1317,1,0,0,0,1316,1299,1,0,0,0,1316,1302,1,0,0,0,1316,1308,1,0,0,0,1317,145,1,0,0,0,1318,1319,3,144,72,0,1319,1328,6,73,-1,0,1320,1322,3,176,88,0,1321,1320,1,0,0,0,1321,1322,1,0,0,0,1322,1323,1,0,0,0,1323,1324,3,144,72,0,1324,1325,6,73,-1,0,1325,1327,1,0,0,0,1326,1321,1,0,0,0,1327,1330,1,0,0,0,1328,1326,1,0,0,0,1328,1329,1,0,0,0,1329,1332,1,0,0,0,1330,1328,1,0,0,0,1331,1333,3,176,88,0,1332,1331,1,0,0,0,1332,1333,1,0,0,0,1333,147,1,0,0,0,1334,1336,5,41,0,0,1335,1337,3,124,62,0,1336,1335,1,0,0,0,1336,1337,1,0,0,0,1337,1339,1,0,0,0,1338,1340,3,176,88,0,1339,1338,1,0,0,0,1339,1340,1,0,0,0,1340,1342,1,0,0,0,1341,1343,3,150,75,0,1342,1341,1,0,0,0,1342,1343,1,0,0,0,1343,1344,1,0,0,0,1344,1345,7,23,0,0,1345,1346,6,74,-1,0,1346,149,1,0,0,0,1347,1348,3,152,76,0,1348,1357,6,75,-1,0,1349,1351,3,176,88,0,1350,1349,1,0,0,0,1350,1351,1,0,0,0,1351,1352,1,0,0,0,1352,1353,3,152,76,0,1353,1354,6,75,-1,0,1354,1356,1,0,0,0,1355,1350,1,0,0,0,1356,1359,1,0,0,0,1357,1355,1,0,0,0,1357,1358,1,0,0,0,1358,1361,1,0,0,0,1359,1357,1,0,0,0,1360,1362,3,176,88,0,1361,1360,1,0,0,0,1361,1362,1,0,0,0,1362,151,1,0,0,0,1363,1364,3,12,6,0,1364,1365,6,76,-1,0,1365,153,1,0,0,0,1366,1368,5,37,0,0,1367,1369,3,124,62,0,1368,1367,1,0,0,0,1368,1369,1,0,0,0,1369,1371,1,0,0,0,1370,1372,3,176,88,0,1371,1370,1,0,0,0,1371,1372,1,0,0,0,1372,1374,1,0,0,0,1373,1375,3,156,78,0,1374,1373,1,0,0,0,1374,1375,1,0,0,0,1375,1376,1,0,0,0,1376,1377,7,24,0,0,1377,1378,6,77,-1,0,1378,155,1,0,0,0,1379,1380,3,158,79,0,1380,1389,6,78,-1,0,1381,1383,3,176,88,0,1382,1381,1,0,0,0,1382,1383,1,0,0,0,1383,1384,1,0,0,0,1384,1385,3,158,79,0,1385,1386,6,78,-1,0,1386,1388,1,0,0,0,1387,1382,1,0,0,0,1388,1391,1,0,0,0,1389,1387,1,0,0,0,1389,1390,1,0,0,0,1390,1393,1,0,0,0,1391,1389,1,0,0,0,1392,1394,3,176,88,0,1393,1392,1,0,0,0,1393,1394,1,0,0,0,1394,157,1,0,0,0,1395,1401,3,12,6,0,1396,1398,5,62,0,0,1397,1399,3,44,22,0,1398,1397,1,0,0,0,1398,1399,1,0,0,0,1399,1400,1,0,0,0,1400,1402,5,63,0,0,1401,1396,1,0,0,0,1401,1402,1,0,0,0,1402,1403,1,0,0,0,1403,1404,6,79,-1,0,1404,159,1,0,0,0,1405,1406,3,162,81,0,1406,1415,6,80,-1,0,1407,1409,3,176,88,0,1408,1407,1,0,0,0,1408,1409,1,0,0,0,1409,1410,1,0,0,0,1410,1411,3,162,81,0,1411,1412,6,80,-1,0,1412,1414,1,0,0,0,1413,1408,1,0,0,0,1414,1417,1,0,0,0,1415,1413,1,0,0,0,1415,1416,1,0,0,0,1416,1419,1,0,0,0,1417,1415,1,0,0,0,1418,1420,3,176,88,0,1419,1418,1,0,0,0,1419,1420,1,0,0,0,1420,161,1,0,0,0,1421,1423,5,47,0,0,1422,1424,3,176,88,0,1423,1422,1,0,0,0,1423,1424,1,0,0,0,1424,1431,1,0,0,0,1425,1426,5,62,0,0,1426,1427,3,164,82,0,1427,1429,5,63,0,0,1428,1430,3,176,88,0,1429,1428,1,0,0,0,1429,1430,1,0,0,0,1430,1432,1,0,0,0,1431,1425,1,0,0,0,1431,1432,1,0,0,0,1432,1434,1,0,0,0,1433,1435,3,166,83,0,1434,1433,1,0,0,0,1434,1435,1,0,0,0,1435,1437,1,0,0,0,1436,1438,3,176,88,0,1437,1436,1,0,0,0,1437,1438,1,0,0,0,1438,1439,1,0,0,0,1439,1440,7,25,0,0,1440,1441,6,81,-1,0,1441,163,1,0,0,0,1442,1443,3,12,6,0,1443,1450,6,82,-1,0,1444,1445,5,56,0,0,1445,1446,3,12,6,0,1446,1447,6,82,-1,0,1447,1449,1,0,0,0,1448,1444,1,0,0,0,1449,1452,1,0,0,0,1450,1448,1,0,0,0,1450,1451,1,0,0,0,1451,165,1,0,0,0,1452,1450,1,0,0,0,1453,1454,3,168,84,0,1454,1461,6,83,-1,0,1455,1456,3,176,88,0,1456,1457,3,168,84,0,1457,1458,6,83,-1,0,1458,1460,1,0,0,0,1459,1455,1,0,0,0,1460,1463,1,0,0,0,1461,1459,1,0,0,0,1461,1462,1,0,0,0,1462,167,1,0,0,0,1463,1461,1,0,0,0,1464,1469,3,170,85,0,1465,1466,5,62,0,0,1466,1467,3,44,22,0,1467,1468,5,63,0,0,1468,1470,1,0,0,0,1469,1465,1,0,0,0,1469,1470,1,0,0,0,1470,1472,1,0,0,0,1471,1473,3,16,8,0,1472,1471,1,0,0,0,1472,1473,1,0,0,0,1473,1478,1,0,0,0,1474,1475,5,66,0,0,1475,1476,3,44,22,0,1476,1477,5,67,0,0,1477,1479,1,0,0,0,1478,1474,1,0,0,0,1478,1479,1,0,0,0,1479,1482,1,0,0,0,1480,1481,5,53,0,0,1481,1483,3,54,27,0,1482,1480,1,0,0,0,1482,1483,1,0,0,0,1483,1484,1,0,0,0,1484,1485,6,84,-1,0,1485,169,1,0,0,0,1486,1487,3,12,6,0,1487,1494,6,85,-1,0,1488,1489,5,57,0,0,1489,1490,3,12,6,0,1490,1491,6,85,-1,0,1491,1493,1,0,0,0,1492,1488,1,0,0,0,1493,1496,1,0,0,0,1494,1492,1,0,0,0,1494,1495,1,0,0,0,1495,171,1,0,0,0,1496,1494,1,0,0,0,1497,1499,7,26,0,0,1498,1497,1,0,0,0,1499,1500,1,0,0,0,1500,1498,1,0,0,0,1500,1501,1,0,0,0,1501,173,1,0,0,0,1502,1504,5,106,0,0,1503,1502,1,0,0,0,1504,1505,1,0,0,0,1505,1503,1,0,0,0,1505,1506,1,0,0,0,1506,175,1,0,0,0,1507,1509,7,27,0,0,1508,1507,1,0,0,0,1509,1510,1,0,0,0,1510,1508,1,0,0,0,1510,1511,1,0,0,0,1511,177,1,0,0,0,198,179,184,190,200,204,216,220,233,243,261,268,278,285,302,310,312,316,321,323,326,331,341,343,347,352,354,357,362,366,371,381,385,387,424,441,451,466,484,491,500,525,527,542,550,557,566,583,585,593,604,631,633,647,654,658,668,672,698,704,709,716,727,734,741,744,753,757,765,770,773,781,785,792,796,799,805,808,815,818,821,829,836,840,844,848,851,857,860,863,879,884,887,894,897,908,911,923,926,936,939,951,955,958,963,967,970,973,985,995,1003,1007,1010,1018,1021,1025,1029,1032,1038,1041,1049,1052,1066,1069,1079,1087,1102,1105,1108,1114,1118,1121,1124,1127,1137,1141,1144,1147,1162,1165,1169,1174,1182,1192,1204,1210,1217,1221,1235,1239,1242,1245,1258,1262,1269,1272,1278,1282,1288,1291,1294,1304,1312,1316,1321,1328,1332,1336,1339,1342,1350,1357,1361,1368,1371,1374,1382,1389,1393,1398,1401,1408,1415,1419,1423,1429,1431,1434,1437,1450,1461,1469,1472,1478,1482,1494,1500,1505,1510],i.DecisionsToDFA=i._ATN.decisionToState.map((e,t)=>new n.DFA(e,t)),t.default=i;class a extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}EOF(){return this.getToken(i.EOF,0)}sep(){return this.getTypedRuleContext($e,0)}global_list(){return this.getTypedRuleContext(o,0)}get ruleIndex(){return i.RULE_input}}t.InputContext=a;class o extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}statement_list(){return this.getTypedRuleContexts(c)}statement(e){return this.getTypedRuleContext(c,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_global_list}}t.Global_listContext=o;class l extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}statement_list(){return this.getTypedRuleContexts(c)}statement(e){return this.getTypedRuleContext(c,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_list}}t.ListContext=l;class c extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}command(){return this.getTypedRuleContext(P,0)}word_list_cmd(){return this.getTypedRuleContext(u,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_statement}}t.StatementContext=c;class u extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}command_word_list(){return this.getTypedRuleContexts(h)}command_word(e){return this.getTypedRuleContext(h,e)}get ruleIndex(){return i.RULE_word_list_cmd}}t.Word_list_cmdContext=u;class h extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}string_(){return this.getTypedRuleContext(f,0)}get ruleIndex(){return i.RULE_command_word}}t.Command_wordContext=h;class d extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}IDENTIFIER(){return this.getToken(i.IDENTIFIER,0)}PROPERTIES(){return this.getToken(i.PROPERTIES,0)}METHODS(){return this.getToken(i.METHODS,0)}EVENTS(){return this.getToken(i.EVENTS,0)}ENUMERATION(){return this.getToken(i.ENUMERATION,0)}get ruleIndex(){return i.RULE_identifier}}t.IdentifierContext=d;class m extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}END(){return this.getToken(i.END,0)}get ruleIndex(){return i.RULE_qualified_identifier_part}}t.Qualified_identifier_partContext=m;class p extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=1,this.parser=e}qualified_identifier_part_list(){return this.getTypedRuleContexts(m)}qualified_identifier_part(e){return this.getTypedRuleContext(m,e)}DOT_list(){return this.getTokens(i.DOT)}DOT(e){return this.getToken(i.DOT,e)}get ruleIndex(){return i.RULE_qualified_identifier}}t.Qualified_identifierContext=p;class f extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}STRING(){return this.getToken(i.STRING,0)}UNQUOTED_STRING(){return this.getToken(i.UNQUOTED_STRING,0)}get ruleIndex(){return i.RULE_string}}t.StringContext=f;class g extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}FLOAT_NUMBER(){return this.getToken(i.FLOAT_NUMBER,0)}get ruleIndex(){return i.RULE_number}}t.NumberContext=g;class y extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}ENDRANGE(){return this.getToken(i.ENDRANGE,0)}get ruleIndex(){return i.RULE_end_range}}t.End_rangeContext=y;class x extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}number_(){return this.getTypedRuleContext(g,0)}string_(){return this.getTypedRuleContext(f,0)}end_range(){return this.getTypedRuleContext(y,0)}get ruleIndex(){return i.RULE_constant}}t.ConstantContext=x;class C extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}LBRACKET(){return this.getToken(i.LBRACKET,0)}RBRACKET(){return this.getToken(i.RBRACKET,0)}SEMICOLON_list(){return this.getTokens(i.SEMICOLON)}SEMICOLON(e){return this.getToken(i.SEMICOLON,e)}nl_list(){return this.getTypedRuleContexts(Ue)}nl(e){return this.getTypedRuleContext(Ue,e)}matrix_row_list(){return this.getTypedRuleContexts(E)}matrix_row(e){return this.getTypedRuleContext(E,e)}LCURLYBR(){return this.getToken(i.LCURLYBR,0)}RCURLYBR(){return this.getToken(i.RCURLYBR,0)}get ruleIndex(){return i.RULE_matrix}}t.MatrixContext=C;class E extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}WSPACE_list(){return this.getTokens(i.WSPACE)}WSPACE(e){return this.getToken(i.WSPACE,e)}list_element_list(){return this.getTypedRuleContexts(M)}list_element(e){return this.getTypedRuleContext(M,e)}get ruleIndex(){return i.RULE_matrix_row}}t.Matrix_rowContext=E;class v extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}COMMAT(){return this.getToken(i.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return i.RULE_fcn_handle}}t.Fcn_handleContext=v;class A extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}QUESTION(){return this.getToken(i.QUESTION,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return i.RULE_meta_class}}t.Meta_classContext=A;class S extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}COMMAT(){return this.getToken(i.COMMAT,0)}param_list(){return this.getTypedRuleContext(oe,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_anon_fcn_handle}}t.Anon_fcn_handleContext=S;class _ extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}IMPORT(){return this.getToken(i.IMPORT,0)}constant(){return this.getTypedRuleContext(x,0)}fcn_handle(){return this.getTypedRuleContext(v,0)}meta_class(){return this.getTypedRuleContext(A,0)}matrix(){return this.getTypedRuleContext(C,0)}LPAREN(){return this.getToken(i.LPAREN,0)}expression(){return this.getTypedRuleContext(R,0)}RPAREN(){return this.getToken(i.RPAREN,0)}get ruleIndex(){return i.RULE_primary_expr}}t.Primary_exprContext=_;class b extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}COLON(){return this.getToken(i.COLON,0)}get ruleIndex(){return i.RULE_magic_colon}}t.Magic_colonContext=b;class T extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}TILDE(){return this.getToken(i.TILDE,0)}get ruleIndex(){return i.RULE_magic_tilde}}t.Magic_tildeContext=T;class M extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(R,0)}magic_colon(){return this.getTypedRuleContext(b,0)}magic_tilde(){return this.getTypedRuleContext(T,0)}get ruleIndex(){return i.RULE_list_element}}t.List_elementContext=M;class N extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}list_element_list(){return this.getTypedRuleContexts(M)}list_element(e){return this.getTypedRuleContext(M,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_arg_list}}t.Arg_listContext=N;class I extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}primary_expr(){return this.getTypedRuleContext(_,0)}oper_expr_list(){return this.getTypedRuleContexts(I)}oper_expr(e){return this.getTypedRuleContext(I,e)}PLUS_PLUS(){return this.getToken(i.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(i.MINUS_MINUS,0)}PLUS(){return this.getToken(i.PLUS,0)}MINUS(){return this.getToken(i.MINUS,0)}TILDE(){return this.getToken(i.TILDE,0)}EXCLAMATION(){return this.getToken(i.EXCLAMATION,0)}MUL(){return this.getToken(i.MUL,0)}DIV(){return this.getToken(i.DIV,0)}LEFTDIV(){return this.getToken(i.LEFTDIV,0)}EMUL(){return this.getToken(i.EMUL,0)}EDIV(){return this.getToken(i.EDIV,0)}ELEFTDIV(){return this.getToken(i.ELEFTDIV,0)}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}arg_list(){return this.getTypedRuleContext(N,0)}LCURLYBR(){return this.getToken(i.LCURLYBR,0)}RCURLYBR(){return this.getToken(i.RCURLYBR,0)}COMMAT(){return this.getToken(i.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}TRANSPOSE(){return this.getToken(i.TRANSPOSE,0)}HERMITIAN(){return this.getToken(i.HERMITIAN,0)}DOT(){return this.getToken(i.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(m,0)}expression(){return this.getTypedRuleContext(R,0)}power_expr(){return this.getTypedRuleContext(L,0)}POW(){return this.getToken(i.POW,0)}EPOW(){return this.getToken(i.EPOW,0)}get ruleIndex(){return i.RULE_oper_expr}}t.Oper_exprContext=I;class L extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}primary_expr(){return this.getTypedRuleContext(_,0)}power_expr(){return this.getTypedRuleContext(L,0)}PLUS_PLUS(){return this.getToken(i.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(i.MINUS_MINUS,0)}PLUS(){return this.getToken(i.PLUS,0)}MINUS(){return this.getToken(i.MINUS,0)}TILDE(){return this.getToken(i.TILDE,0)}EXCLAMATION(){return this.getToken(i.EXCLAMATION,0)}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}arg_list(){return this.getTypedRuleContext(N,0)}LCURLYBR(){return this.getToken(i.LCURLYBR,0)}RCURLYBR(){return this.getToken(i.RCURLYBR,0)}COMMAT(){return this.getToken(i.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}DOT(){return this.getToken(i.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(m,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_power_expr}}t.Power_exprContext=L;class w extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}oper_expr_list(){return this.getTypedRuleContexts(I)}oper_expr(e){return this.getTypedRuleContext(I,e)}COLON_list(){return this.getTokens(i.COLON)}COLON(e){return this.getToken(i.COLON,e)}get ruleIndex(){return i.RULE_colon_expr}}t.Colon_exprContext=w;class O extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}oper_expr(){return this.getTypedRuleContext(I,0)}colon_expr(){return this.getTypedRuleContext(w,0)}simple_expr_list(){return this.getTypedRuleContexts(O)}simple_expr(e){return this.getTypedRuleContext(O,e)}EXPR_LT(){return this.getToken(i.EXPR_LT,0)}EXPR_LE(){return this.getToken(i.EXPR_LE,0)}EXPR_GT(){return this.getToken(i.EXPR_GT,0)}EXPR_GE(){return this.getToken(i.EXPR_GE,0)}EXPR_EQ(){return this.getToken(i.EXPR_EQ,0)}EXPR_NE(){return this.getToken(i.EXPR_NE,0)}EXPR_AND(){return this.getToken(i.EXPR_AND,0)}EXPR_OR(){return this.getToken(i.EXPR_OR,0)}EXPR_AND_AND(){return this.getToken(i.EXPR_AND_AND,0)}EXPR_OR_OR(){return this.getToken(i.EXPR_OR_OR,0)}get ruleIndex(){return i.RULE_simple_expr}}t.Simple_exprContext=O;class R extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}simple_expr(){return this.getTypedRuleContext(O,0)}expression(){return this.getTypedRuleContext(R,0)}EQ(){return this.getToken(i.EQ,0)}ADD_EQ(){return this.getToken(i.ADD_EQ,0)}SUB_EQ(){return this.getToken(i.SUB_EQ,0)}MUL_EQ(){return this.getToken(i.MUL_EQ,0)}EMUL_EQ(){return this.getToken(i.EMUL_EQ,0)}DIV_EQ(){return this.getToken(i.DIV_EQ,0)}EDIV_EQ(){return this.getToken(i.EDIV_EQ,0)}LEFTDIV_EQ(){return this.getToken(i.LEFTDIV_EQ,0)}ELEFTDIV_EQ(){return this.getToken(i.ELEFTDIV_EQ,0)}POW_EQ(){return this.getToken(i.POW_EQ,0)}EPOW_EQ(){return this.getToken(i.EPOW_EQ,0)}AND_EQ(){return this.getToken(i.AND_EQ,0)}OR_EQ(){return this.getToken(i.OR_EQ,0)}anon_fcn_handle(){return this.getTypedRuleContext(S,0)}get ruleIndex(){return i.RULE_expression}}t.ExpressionContext=R;class D extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}simple_expr(){return this.getTypedRuleContext(O,0)}LBRACKET(){return this.getToken(i.LBRACKET,0)}RBRACKET(){return this.getToken(i.RBRACKET,0)}assign_list(){return this.getTypedRuleContext(F,0)}get ruleIndex(){return i.RULE_assign_lhs}}t.Assign_lhsContext=D;class F extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}list_element_list(){return this.getTypedRuleContexts(M)}list_element(e){return this.getTypedRuleContext(M,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}WSPACE_list(){return this.getTokens(i.WSPACE)}WSPACE(e){return this.getToken(i.WSPACE,e)}get ruleIndex(){return i.RULE_assign_list}}t.Assign_listContext=F;class P extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}declaration(){return this.getTypedRuleContext(k,0)}import_command(){return this.getTypedRuleContext(U,0)}select_command(){return this.getTypedRuleContext(B,0)}loop_command(){return this.getTypedRuleContext(J,0)}jump_command(){return this.getTypedRuleContext(te,0)}except_command(){return this.getTypedRuleContext(re,0)}function_(){return this.getTypedRuleContext(he,0)}classdef_command(){return this.getTypedRuleContext(me,0)}get ruleIndex(){return i.RULE_command}}t.CommandContext=P;class k extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}declaration_element_list(){return this.getTypedRuleContexts(V)}declaration_element(e){return this.getTypedRuleContext(V,e)}GLOBAL(){return this.getToken(i.GLOBAL,0)}PERSISTENT(){return this.getToken(i.PERSISTENT,0)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_declaration}}t.DeclarationContext=k;class V extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}EQ(){return this.getToken(i.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_declaration_element}}t.Declaration_elementContext=V;class U extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}IMPORT(){return this.getToken(i.IMPORT,0)}import_name_list(){return this.getTypedRuleContexts($)}import_name(e){return this.getTypedRuleContext($,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_import_command}}t.Import_commandContext=U;class $ extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}qualified_identifier(){return this.getTypedRuleContext(p,0)}DOT(){return this.getToken(i.DOT,0)}MUL(){return this.getToken(i.MUL,0)}EMUL(){return this.getToken(i.EMUL,0)}get ruleIndex(){return i.RULE_import_name}}t.Import_nameContext=$;class B extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}if_command(){return this.getTypedRuleContext(H,0)}switch_command(){return this.getTypedRuleContext(z,0)}get ruleIndex(){return i.RULE_select_command}}t.Select_commandContext=B;class H extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}IF(){return this.getToken(i.IF,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(i.END,0)}ENDIF(){return this.getToken(i.ENDIF,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}elseif_clause_list(){return this.getTypedRuleContexts(j)}elseif_clause(e){return this.getTypedRuleContext(j,e)}else_clause(){return this.getTypedRuleContext(q,0)}get ruleIndex(){return i.RULE_if_command}}t.If_commandContext=H;class j extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}ELSEIF(){return this.getToken(i.ELSEIF,0)}expression(){return this.getTypedRuleContext(R,0)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_elseif_clause}}t.Elseif_clauseContext=j;class q extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}ELSE(){return this.getToken(i.ELSE,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_else_clause}}t.Else_clauseContext=q;class z extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}SWITCH(){return this.getToken(i.SWITCH,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(i.END,0)}ENDSWITCH(){return this.getToken(i.ENDSWITCH,0)}sep(){return this.getTypedRuleContext($e,0)}switch_case_list(){return this.getTypedRuleContext(G,0)}otherwise_case(){return this.getTypedRuleContext(Q,0)}get ruleIndex(){return i.RULE_switch_command}}t.Switch_commandContext=z;class G extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}switch_case_list(){return this.getTypedRuleContexts(W)}switch_case(e){return this.getTypedRuleContext(W,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_switch_case_list}}t.Switch_case_listContext=G;class W extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}CASE(){return this.getToken(i.CASE,0)}expression(){return this.getTypedRuleContext(R,0)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_switch_case}}t.Switch_caseContext=W;class Q extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}OTHERWISE(){return this.getToken(i.OTHERWISE,0)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_otherwise_case}}t.Otherwise_caseContext=Q;class J extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}while_command(){return this.getTypedRuleContext(K,0)}do_until_command(){return this.getTypedRuleContext(Z,0)}for_command(){return this.getTypedRuleContext(X,0)}spmd_command(){return this.getTypedRuleContext(Y,0)}get ruleIndex(){return i.RULE_loop_command}}t.Loop_commandContext=J;class K extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}WHILE(){return this.getToken(i.WHILE,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(i.END,0)}ENDWHILE(){return this.getToken(i.ENDWHILE,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_while_command}}t.While_commandContext=K;class Z extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}DO(){return this.getToken(i.DO,0)}UNTIL(){return this.getToken(i.UNTIL,0)}expression(){return this.getTypedRuleContext(R,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_do_until_command}}t.Do_until_commandContext=Z;class X extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}FOR(){return this.getToken(i.FOR,0)}assign_lhs(){return this.getTypedRuleContext(D,0)}EQ(){return this.getToken(i.EQ,0)}expression_list(){return this.getTypedRuleContexts(R)}expression(e){return this.getTypedRuleContext(R,e)}END(){return this.getToken(i.END,0)}ENDFOR(){return this.getToken(i.ENDFOR,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}PARFOR(){return this.getToken(i.PARFOR,0)}ENDPARFOR(){return this.getToken(i.ENDPARFOR,0)}COMMA(){return this.getToken(i.COMMA,0)}get ruleIndex(){return i.RULE_for_command}}t.For_commandContext=X;class Y extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}SPMD(){return this.getToken(i.SPMD,0)}END(){return this.getToken(i.END,0)}ENDSPMD(){return this.getToken(i.ENDSPMD,0)}spmd_worker_spec(){return this.getTypedRuleContext(ee,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_spmd_command}}t.Spmd_commandContext=Y;class ee extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}LPAREN(){return this.getToken(i.LPAREN,0)}expression_list(){return this.getTypedRuleContexts(R)}expression(e){return this.getTypedRuleContext(R,e)}RPAREN(){return this.getToken(i.RPAREN,0)}COMMA(){return this.getToken(i.COMMA,0)}get ruleIndex(){return i.RULE_spmd_worker_spec}}t.Spmd_worker_specContext=ee;class te extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}BREAK(){return this.getToken(i.BREAK,0)}CONTINUE(){return this.getToken(i.CONTINUE,0)}RETURN(){return this.getToken(i.RETURN,0)}get ruleIndex(){return i.RULE_jump_command}}t.Jump_commandContext=te;class re extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}try_command(){return this.getTypedRuleContext(ne,0)}unwind_command(){return this.getTypedRuleContext(ie,0)}get ruleIndex(){return i.RULE_except_command}}t.Except_commandContext=re;class ne extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}TRY(){return this.getToken(i.TRY,0)}catch_clause(){return this.getTypedRuleContext(se,0)}END(){return this.getToken(i.END,0)}END_TRY_CATCH(){return this.getToken(i.END_TRY_CATCH,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_try_command}}t.Try_commandContext=ne;class se extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}CATCH(){return this.getToken(i.CATCH,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_catch_clause}}t.Catch_clauseContext=se;class ie extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}UNWIND_PROTECT(){return this.getToken(i.UNWIND_PROTECT,0)}unwind_cleanup_clause(){return this.getTypedRuleContext(ae,0)}END(){return this.getToken(i.END,0)}END_UNWIND_PROTECT(){return this.getToken(i.END_UNWIND_PROTECT,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_unwind_command}}t.Unwind_commandContext=ie;class ae extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}UNWIND_PROTECT_CLEANUP(){return this.getToken(i.UNWIND_PROTECT_CLEANUP,0)}sep(){return this.getTypedRuleContext($e,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_unwind_cleanup_clause}}t.Unwind_cleanup_clauseContext=ae;class oe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}param_list_elt_list(){return this.getTypedRuleContexts(le)}param_list_elt(e){return this.getTypedRuleContext(le,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_param_list}}t.Param_listContext=oe;class le extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}declaration_element(){return this.getTypedRuleContext(V,0)}magic_tilde(){return this.getTypedRuleContext(T,0)}get ruleIndex(){return i.RULE_param_list_elt}}t.Param_list_eltContext=le;class ce extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}magic_tilde(){return this.getTypedRuleContext(T,0)}get ruleIndex(){return i.RULE_return_list_elt}}t.Return_list_eltContext=ce;class ue extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}return_list_elt_list(){return this.getTypedRuleContexts(ce)}return_list_elt(e){return this.getTypedRuleContext(ce,e)}LBRACKET(){return this.getToken(i.LBRACKET,0)}RBRACKET(){return this.getToken(i.RBRACKET,0)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}WSPACE_list(){return this.getTokens(i.WSPACE)}WSPACE(e){return this.getToken(i.WSPACE,e)}get ruleIndex(){return i.RULE_return_list}}t.Return_listContext=ue;class he extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}FUNCTION(){return this.getToken(i.FUNCTION,0)}function_name(){return this.getTypedRuleContext(de,0)}END(){return this.getToken(i.END,0)}ENDFUNCTION(){return this.getToken(i.ENDFUNCTION,0)}EOF(){return this.getToken(i.EOF,0)}return_list(){return this.getTypedRuleContext(ue,0)}EQ(){return this.getToken(i.EQ,0)}param_list(){return this.getTypedRuleContext(oe,0)}sep(){return this.getTypedRuleContext($e,0)}arguments_block_list(){return this.getTypedRuleContext(Oe,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return i.RULE_function}}t.FunctionContext=he;class de extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return i.RULE_function_name}}t.Function_nameContext=de;class me extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}CLASSDEF(){return this.getToken(i.CLASSDEF,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}END(){return this.getToken(i.END,0)}ENDCLASSDEF(){return this.getToken(i.ENDCLASSDEF,0)}EOF(){return this.getToken(i.EOF,0)}class_attribute_list(){return this.getTypedRuleContext(pe,0)}class_superclass_list(){return this.getTypedRuleContext(ye,0)}sep(){return this.getTypedRuleContext($e,0)}class_section_list(){return this.getTypedRuleContext(xe,0)}get ruleIndex(){return i.RULE_classdef_command}}t.Classdef_commandContext=me;class pe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}class_attribute_list(){return this.getTypedRuleContexts(fe)}class_attribute(e){return this.getTypedRuleContext(fe,e)}sep(){return this.getTypedRuleContext($e,0)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_class_attribute_list}}t.Class_attribute_listContext=pe;class fe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}EQ(){return this.getToken(i.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}TILDE(){return this.getToken(i.TILDE,0)}EXCLAMATION(){return this.getToken(i.EXCLAMATION,0)}get ruleIndex(){return i.RULE_class_attribute}}t.Class_attributeContext=fe;class ge extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=1,this.parser=e}identifier_list(){return this.getTypedRuleContexts(d)}identifier(e){return this.getTypedRuleContext(d,e)}DOT_list(){return this.getTokens(i.DOT)}DOT(e){return this.getToken(i.DOT,e)}get ruleIndex(){return i.RULE_class_method_name}}t.Class_method_nameContext=ge;class ye extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}EXPR_LT(){return this.getToken(i.EXPR_LT,0)}qualified_identifier_list(){return this.getTypedRuleContexts(p)}qualified_identifier(e){return this.getTypedRuleContext(p,e)}EXPR_AND_list(){return this.getTokens(i.EXPR_AND)}EXPR_AND(e){return this.getToken(i.EXPR_AND,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_class_superclass_list}}t.Class_superclass_listContext=ye;class xe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}class_section_list(){return this.getTypedRuleContexts(Ce)}class_section(e){return this.getTypedRuleContext(Ce,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_class_section_list}}t.Class_section_listContext=xe;class Ce extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}properties_section(){return this.getTypedRuleContext(Ee,0)}methods_section(){return this.getTypedRuleContext(Se,0)}events_section(){return this.getTypedRuleContext(Te,0)}enumeration_section(){return this.getTypedRuleContext(Ie,0)}get ruleIndex(){return i.RULE_class_section}}t.Class_sectionContext=Ce;class Ee extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}PROPERTIES(){return this.getToken(i.PROPERTIES,0)}END(){return this.getToken(i.END,0)}ENDPROPERTIES(){return this.getToken(i.ENDPROPERTIES,0)}class_attribute_list(){return this.getTypedRuleContext(pe,0)}sep(){return this.getTypedRuleContext($e,0)}class_property_list(){return this.getTypedRuleContext(ve,0)}get ruleIndex(){return i.RULE_properties_section}}t.Properties_sectionContext=Ee;class ve extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}class_property_list(){return this.getTypedRuleContexts(Ae)}class_property(e){return this.getTypedRuleContext(Ae,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_class_property_list}}t.Class_property_listContext=ve;class Ae extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}LPAREN(){return this.getToken(i.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(N)}arg_list(e){return this.getTypedRuleContext(N,e)}RPAREN(){return this.getToken(i.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}LCURLYBR(){return this.getToken(i.LCURLYBR,0)}RCURLYBR(){return this.getToken(i.RCURLYBR,0)}EQ(){return this.getToken(i.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_class_property}}t.Class_propertyContext=Ae;class Se extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}METHODS(){return this.getToken(i.METHODS,0)}END(){return this.getToken(i.END,0)}ENDMETHODS(){return this.getToken(i.ENDMETHODS,0)}class_attribute_list(){return this.getTypedRuleContext(pe,0)}sep(){return this.getTypedRuleContext($e,0)}class_method_list(){return this.getTypedRuleContext(be,0)}get ruleIndex(){return i.RULE_methods_section}}t.Methods_sectionContext=Se;class _e extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}function_(){return this.getTypedRuleContext(he,0)}class_method_name(){return this.getTypedRuleContext(ge,0)}param_list(){return this.getTypedRuleContext(oe,0)}return_list(){return this.getTypedRuleContext(ue,0)}EQ(){return this.getToken(i.EQ,0)}get ruleIndex(){return i.RULE_class_method}}t.Class_methodContext=_e;class be extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}class_method_list(){return this.getTypedRuleContexts(_e)}class_method(e){return this.getTypedRuleContext(_e,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_class_method_list}}t.Class_method_listContext=be;class Te extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}EVENTS(){return this.getToken(i.EVENTS,0)}END(){return this.getToken(i.END,0)}ENDEVENTS(){return this.getToken(i.ENDEVENTS,0)}class_attribute_list(){return this.getTypedRuleContext(pe,0)}sep(){return this.getTypedRuleContext($e,0)}class_event_list(){return this.getTypedRuleContext(Me,0)}get ruleIndex(){return i.RULE_events_section}}t.Events_sectionContext=Te;class Me extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}class_event_list(){return this.getTypedRuleContexts(Ne)}class_event(e){return this.getTypedRuleContext(Ne,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_class_event_list}}t.Class_event_listContext=Me;class Ne extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}get ruleIndex(){return i.RULE_class_event}}t.Class_eventContext=Ne;class Ie extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}ENUMERATION(){return this.getToken(i.ENUMERATION,0)}END(){return this.getToken(i.END,0)}ENDENUMERATION(){return this.getToken(i.ENDENUMERATION,0)}class_attribute_list(){return this.getTypedRuleContext(pe,0)}sep(){return this.getTypedRuleContext($e,0)}class_enumeration_list(){return this.getTypedRuleContext(Le,0)}get ruleIndex(){return i.RULE_enumeration_section}}t.Enumeration_sectionContext=Ie;class Le extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}class_enumeration_list(){return this.getTypedRuleContexts(we)}class_enumeration(e){return this.getTypedRuleContext(we,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_class_enumeration_list}}t.Class_enumeration_listContext=Le;class we extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(d,0)}LPAREN(){return this.getToken(i.LPAREN,0)}RPAREN(){return this.getToken(i.RPAREN,0)}arg_list(){return this.getTypedRuleContext(N,0)}get ruleIndex(){return i.RULE_class_enumeration}}t.Class_enumerationContext=we;class Oe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}arguments_block_list(){return this.getTypedRuleContexts(Re)}arguments_block(e){return this.getTypedRuleContext(Re,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_arguments_block_list}}t.Arguments_block_listContext=Oe;class Re extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}ARGUMENTS(){return this.getToken(i.ARGUMENTS,0)}END(){return this.getToken(i.END,0)}ENDARGUMENTS(){return this.getToken(i.ENDARGUMENTS,0)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}LPAREN(){return this.getToken(i.LPAREN,0)}arguments_attribute_list(){return this.getTypedRuleContext(De,0)}RPAREN(){return this.getToken(i.RPAREN,0)}args_validation_list(){return this.getTypedRuleContext(Fe,0)}get ruleIndex(){return i.RULE_arguments_block}}t.Arguments_blockContext=Re;class De extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}identifier_list(){return this.getTypedRuleContexts(d)}identifier(e){return this.getTypedRuleContext(d,e)}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}get ruleIndex(){return i.RULE_arguments_attribute_list}}t.Arguments_attribute_listContext=De;class Fe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=0,this.parser=e}arg_validation_list(){return this.getTypedRuleContexts(Pe)}arg_validation(e){return this.getTypedRuleContext(Pe,e)}sep_list(){return this.getTypedRuleContexts($e)}sep(e){return this.getTypedRuleContext($e,e)}get ruleIndex(){return i.RULE_args_validation_list}}t.Args_validation_listContext=Fe;class Pe extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}arg_validation_name(){return this.getTypedRuleContext(ke,0)}LPAREN(){return this.getToken(i.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(N)}arg_list(e){return this.getTypedRuleContext(N,e)}RPAREN(){return this.getToken(i.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}LCURLYBR(){return this.getToken(i.LCURLYBR,0)}RCURLYBR(){return this.getToken(i.RCURLYBR,0)}EQ(){return this.getToken(i.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return i.RULE_arg_validation}}t.Arg_validationContext=Pe;class ke extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.i=1,this.parser=e}identifier_list(){return this.getTypedRuleContexts(d)}identifier(e){return this.getTypedRuleContext(d,e)}DOT_list(){return this.getTokens(i.DOT)}DOT(e){return this.getToken(i.DOT,e)}get ruleIndex(){return i.RULE_arg_validation_name}}t.Arg_validation_nameContext=ke;class Ve extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}SEMICOLON_list(){return this.getTokens(i.SEMICOLON)}SEMICOLON(e){return this.getToken(i.SEMICOLON,e)}get ruleIndex(){return i.RULE_sep_no_nl}}t.Sep_no_nlContext=Ve;class Ue extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}NEWLINE_list(){return this.getTokens(i.NEWLINE)}NEWLINE(e){return this.getToken(i.NEWLINE,e)}get ruleIndex(){return i.RULE_nl}}t.NlContext=Ue;class $e extends n.ParserRuleContext{constructor(e,t,r){super(t,r),this.parser=e}COMMA_list(){return this.getTokens(i.COMMA)}COMMA(e){return this.getToken(i.COMMA,e)}SEMICOLON_list(){return this.getTokens(i.SEMICOLON)}SEMICOLON(e){return this.getToken(i.SEMICOLON,e)}NEWLINE_list(){return this.getTokens(i.NEWLINE)}NEWLINE(e){return this.getToken(i.NEWLINE,e)}get ruleIndex(){return i.RULE_sep}}t.SepContext=$e},7686(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MathML=t.format=void 0;class r{}t.MathML=r,r.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"><</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">/=</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=>'<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>",PERSIST:()=>"",FCNDEF:()=>"",VOID:()=>"",INVALID:()=>"<mi>invalid</mi>",UNDEFINED:()=>"<mi>undefined tree</mi>",ERROR:()=>"<mi>error</mi>",math:(e,t)=>"none"===t?e:'<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>Γ</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>'},r.formatFunction=e=>{const t=r.format[e];return"function"==typeof t?t:void 0},r.formatDynamic=(e,...t)=>{const n=r.formatFunction(e);if(!n)throw new Error(`MathML formatter '${e}' is not defined.`);return n(...t)};const n=r.format;t.format=n,t.default={format:n,MathML:r}},6554(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MathOperation=void 0;const n=r(5956),s=r(845),i=r(7679),a=r(5212),o=r(9770),l=r(4610),c=r(1604);class u{}t.MathOperation=u,u.elementWiseOperatorSymbols={add:"+",sub:"-",mod:"mod",rem:"rem",mul:".*",rdiv:"./",ldiv:".\\",power:".^",lt:"<",le:"<=",eq:"==",ge:">=",gt:">",ne:"~=",and:"&",or:"|",xor:"xor",minWise:"min",maxWise:"max"},u.unaryOperatorSymbols={copy:"+",neg:"-",not:"~"},u.copy=e=>c.RuntimeValue.copy(e),u.elementWiseOperation=(e,t,r)=>{if(n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),n.CharString.isInstanceOf(r)&&(r=i.MultiArray.fromCharString(r)),u.throwIfStructureBinaryOperand(u.elementWiseOperatorSymbols[e],t,r),u.throwIfCellBinaryOperand(u.elementWiseOperatorSymbols[e],t,r),("lt"===e||"le"===e||"eq"===e||"ge"===e||"gt"===e||"ne"===e)&&(u.hasClassInstanceOperand(t)||u.hasClassInstanceOperand(r)))return u.classInstanceRelationalOperation(e,t,r);if(s.Complex.isInstanceOf(t)&&s.Complex.isInstanceOf(r))return s.Complex[e](t,r);if(s.Complex.isInstanceOf(t)&&i.MultiArray.isInstanceOf(r))return i.MultiArray.scalarOpMultiArray(e,t,r);if(i.MultiArray.isInstanceOf(t)&&s.Complex.isInstanceOf(r))return i.MultiArray.MultiArrayOpScalar(e,t,r);if(i.MultiArray.isInstanceOf(t)&&i.MultiArray.isInstanceOf(r))return i.MultiArray.elementWiseOperation(e,t,r);throw new EvalError(`operator ${u.elementWiseOperatorSymbols[e]} is not defined for these operands.`)},u.hasStructureOperand=e=>a.Structure.isInstanceOf(e)||i.MultiArray.isInstanceOf(e)&&a.Structure.isStructure(e),u.hasCellOperand=e=>i.MultiArray.isInstanceOf(e)&&e.isCell,u.throwIfCellBinaryOperand=(e,t,r)=>{if(u.hasCellOperand(t)||u.hasCellOperand(r))throw new EvalError(`operator ${e} is not defined for cell operands.`)},u.throwIfStructureBinaryOperand=(e,t,r)=>{if(u.hasStructureOperand(t)||u.hasStructureOperand(r))throw new EvalError(`operator ${e} is not defined for struct operands.`)},u.throwIfCellUnaryOperand=(e,t)=>{if(u.hasCellOperand(t))throw new EvalError(`operator ${e} is not defined for cell operands.`)},u.throwIfStructureUnaryOperand=(e,t)=>{if(u.hasStructureOperand(t))throw new EvalError(`operator ${e} is not defined for struct operands.`)},u.hasClassInstanceOperand=e=>o.ClassInstance.isInstanceOf(e)||i.MultiArray.isInstanceOf(e)&&i.MultiArray.linearize(e).some(e=>o.ClassInstance.isInstanceOf(e)),u.handleComparisonOrder=new WeakMap,u.nextHandleComparisonOrder=1,u.handleOrder=e=>{let t=u.handleComparisonOrder.get(e);return void 0===t&&(t=u.nextHandleComparisonOrder++,u.handleComparisonOrder.set(e,t)),t},u.numericScalarValue=e=>{if(s.Complex.isInstanceOf(e))return e;if(i.MultiArray.isInstanceOf(e)&&c.RuntimeValue.isScalar(e)){const t=i.MultiArray.firstElement(e);return s.Complex.isInstanceOf(t)?t:void 0}},u.classInstanceRelationalOperation=(e,t,r)=>{const n=(t,r)=>{const n=o.ClassInstance.isInstanceOf(t),i=o.ClassInstance.isInstanceOf(r);if(!n||!i)return s.Complex.false();if(!t.classDefinition.isHandleClass()||!r.classDefinition.isHandleClass())throw new EvalError(`binary operator '${e}' is not defined for value class operands.`);if(t.classDefinition.name!==r.classDefinition.name)return s.Complex.false();const a=u.handleOrder(t),l=u.handleOrder(r);return("lt"===e?a<l:"le"===e?a<=l:"eq"===e?t===r:"ge"===e?a>=l:"gt"===e?a>l:t!==r)?s.Complex.true():s.Complex.false()},a=i.MultiArray.scalarToMultiArray(t),l=i.MultiArray.scalarToMultiArray(r),c=a.dimension.slice(),h=l.dimension.slice(),d=Math.max(c.length,h.length);for(;c.length<d;)c.push(1);for(;h.length<d;)h.push(1);const m=new Array(d),p=new Array(d),f=new Array(d);for(let t=0;t<d;t++)if(c[t]===h[t])m[t]=c[t],p[t]=f[t]=!1;else if(1===c[t])m[t]=h[t],p[t]=!0,f[t]=!1;else{if(1!==h[t])throw new EvalError(`operator ${e}: nonconformant arguments (op1 is ${c.join("x")}, op2 is ${h.join("x")}).`);m[t]=c[t],p[t]=!1,f[t]=!0}const g=i.MultiArray.computeStrides(c),y=i.MultiArray.computeStrides(h),x=i.MultiArray.computeStrides(m),C=new i.MultiArray(m),E=m.reduce((e,t)=>e*t,1);for(let e=0;e<E;e++){let t=0,r=0;for(let n=0;n<d;n++){const s=Math.floor(e/x[n])%m[n];t+=(p[n]?0:s)*g[n],r+=(f[n]?0:s)*y[n]}const[s,o]=i.MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],t),[u,E]=i.MultiArray.linearIndexToMultiArrayRowColumn(h[0],h[1],r),[v,A]=i.MultiArray.linearIndexToMultiArrayRowColumn(m[0],m[1],e);C.array[v][A]=n(a.array[s][o],l.array[u][E])}return C.type=s.Complex.LOGICAL,i.MultiArray.MultiArrayToScalar(C)},u.leftOperation=(e,t)=>{if(n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),u.throwIfStructureUnaryOperand(u.unaryOperatorSymbols[e],t),u.throwIfCellUnaryOperand(u.unaryOperatorSymbols[e],t),s.Complex.isInstanceOf(t))return s.Complex[e](t);if(i.MultiArray.isInstanceOf(t))return i.MultiArray.leftOperation(e,t);throw new EvalError(`operator ${u.unaryOperatorSymbols[e]} is not defined for this operand.`)},u.plus=(e,t)=>u.elementWiseOperation("add",e,t),u.minus=(e,t)=>u.elementWiseOperation("sub",e,t),u.mod=(e,t)=>u.elementWiseOperation("mod",e,t),u.rem=(e,t)=>u.elementWiseOperation("rem",e,t),u.times=(e,t)=>u.elementWiseOperation("mul",e,t),u.mtimes=(e,t)=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),u.throwIfStructureBinaryOperand("*",e,t),s.Complex.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.mul(e,t):s.Complex.isInstanceOf(e)&&i.MultiArray.isInstanceOf(t)?i.MultiArray.scalarOpMultiArray("mul",e,t):i.MultiArray.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?i.MultiArray.MultiArrayOpScalar("mul",e,t):l.LinearAlgebra.mul(e,t)),u.rdivide=(e,t)=>u.elementWiseOperation("rdiv",e,t),u.mrdivide=(e,t)=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),u.throwIfStructureBinaryOperand("/",e,t),s.Complex.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.rdiv(e,t):s.Complex.isInstanceOf(e)&&i.MultiArray.isInstanceOf(t)?i.MultiArray.scalarOpMultiArray("mul",e,l.LinearAlgebra.inv(t)):i.MultiArray.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?i.MultiArray.scalarOpMultiArray("mul",s.Complex.inv(t),e):l.LinearAlgebra.mrdivide(e,t)),u.ldivide=(e,t)=>u.elementWiseOperation("ldiv",e,t),u.mldivide=(e,t)=>{if(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),u.throwIfStructureBinaryOperand("\\",e,t),s.Complex.isInstanceOf(e)&&s.Complex.isInstanceOf(t))return s.Complex.ldiv(e,t);if(s.Complex.isInstanceOf(e)&&i.MultiArray.isInstanceOf(t))return i.MultiArray.scalarOpMultiArray("ldiv",e,t);if(i.MultiArray.isInstanceOf(e)&&s.Complex.isInstanceOf(t))throw new EvalError(`operator \\: nonconformant arguments (op1 is ${e.dimension.join("x")}, op2 is 1x1).`);return l.LinearAlgebra.mldivide(e,t)},u.power=(e,t)=>u.elementWiseOperation("power",e,t),u.mpower=(e,t)=>{n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),u.throwIfStructureBinaryOperand("^",e,t);const r=u.numericScalarValue(e),a=u.numericScalarValue(t);if(r&&a)return s.Complex.power(r,a);if(i.MultiArray.isInstanceOf(e)&&a)return l.LinearAlgebra.power(e,a);if(r&&i.MultiArray.isInstanceOf(t))return l.LinearAlgebra.scalarPower(r,t);throw new Error("invalid exponent in '^'.")},u.uplus=e=>u.leftOperation("copy",e),u.uminus=e=>u.leftOperation("neg",e),u.transpose=e=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.characterVectorFromCharString(e)),i.MultiArray.isInstanceOf(e)?l.LinearAlgebra.transpose(e):c.RuntimeValue.copy(e)),u.ctranspose=e=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.characterVectorFromCharString(e)),s.Complex.isInstanceOf(e)?s.Complex.conj(e):i.MultiArray.isInstanceOf(e)?l.LinearAlgebra.ctranspose(e):c.RuntimeValue.copy(e)),u.lt=(e,t)=>u.elementWiseOperation("lt",e,t),u.le=(e,t)=>u.elementWiseOperation("le",e,t),u.eq=(e,t)=>u.elementWiseOperation("eq",e,t),u.ge=(e,t)=>u.elementWiseOperation("ge",e,t),u.gt=(e,t)=>u.elementWiseOperation("gt",e,t),u.ne=(e,t)=>u.elementWiseOperation("ne",e,t),u.mand=(e,t)=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),s.Complex.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.and(e,t):s.Complex.isInstanceOf(e)&&i.MultiArray.isInstanceOf(t)?s.Complex.and(e,i.MultiArray.toLogical(t)):i.MultiArray.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.and(i.MultiArray.toLogical(e),t):s.Complex.and(i.MultiArray.toLogical(e),i.MultiArray.toLogical(t))),u.mor=(e,t)=>(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),n.CharString.isInstanceOf(t)&&(t=i.MultiArray.fromCharString(t)),s.Complex.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.or(e,t):s.Complex.isInstanceOf(e)&&i.MultiArray.isInstanceOf(t)?s.Complex.or(e,i.MultiArray.toLogical(t)):i.MultiArray.isInstanceOf(e)&&s.Complex.isInstanceOf(t)?s.Complex.or(i.MultiArray.toLogical(e),t):s.Complex.or(i.MultiArray.toLogical(e),i.MultiArray.toLogical(t))),u.not=e=>{if(n.CharString.isInstanceOf(e)&&(e=i.MultiArray.fromCharString(e)),u.throwIfStructureUnaryOperand(u.unaryOperatorSymbols.not,e),u.throwIfCellUnaryOperand(u.unaryOperatorSymbols.not,e),s.Complex.isInstanceOf(e))return s.Complex.not(e);if(i.MultiArray.isInstanceOf(e))return i.MultiArray.leftOperation("not",e);throw new EvalError(`operator ${u.unaryOperatorSymbols.not} is not defined for this operand.`)},u.and=(e,t)=>u.elementWiseOperation("and",e,t),u.or=(e,t)=>u.elementWiseOperation("or",e,t),u.xor=(e,t)=>u.elementWiseOperation("xor",e,t),u.unaryOperations={uplus:u.uplus,uminus:u.uminus,not:u.not,transpose:u.transpose,ctranspose:u.ctranspose},u.binaryOperations={minus:u.minus,mod:u.mod,rem:u.rem,rdivide:u.rdivide,mrdivide:u.mrdivide,ldivide:u.ldivide,mldivide:u.mldivide,power:u.power,mpower:u.mpower,lt:u.lt,le:u.le,ge:u.ge,gt:u.gt,eq:u.eq,ne:u.ne},u.leftAssociativeMultipleOperations={plus:u.plus,times:u.times,mtimes:u.mtimes,and:u.and,or:u.or,xor:u.xor},t.default={MathOperation:u}},7679(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MultiArray=void 0;const n=r(845),s=r(5956),i=r(1604),a=(e,t)=>{if(t>e)throw new EvalError(`element number ${t} undefined in return list`)},o=(e,t,r)=>((e,t)=>({type:"RETLIST",selector:e,handler:t}))((r,n)=>(a(e,r.length),t(r,n)),t=>(a(e,t),r?r(t):{length:t}));class l{get dimensionR(){return[this.dimension[0],...this.dimension.slice(2)]}static isIndexArgument(e){return n.Complex.isInstanceOf(e)||l.isInstanceOf(e)}static indexArguments(e,t="index"){return e.map((e,r)=>{if(!l.isIndexArgument(e))throw new EvalError(`${t}${r+1}: invalid subscript type.`);return e})}constructor(e,t,r){if(e)if(this.dimension=e.slice(),l.appendSingletonTail(this.dimension,2),l.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,s)=>t(...l.rowColumnToSubscript(e,n,s))));else if(Array.isArray(t)&&Array.isArray(t[0]))this.array=t.map(e=>e.map(e=>i.RuntimeValue.copy(e)));else{this.array=new Array(this.dimensionR.reduce((e,t)=>e*t,1));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]=i.RuntimeValue.copy(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=>n.Complex.zero())),this.type=-1;else this.dimension=[0,0],this.array=[],this.type=-1;this.isCell=null!=r&&r}toString(){return`array ${this.dimension.join("x")}`}copy(){const e=new l(this.dimension,void 0,this.isCell);return e.array=this.array.map(e=>e.map(e=>i.RuntimeValue.copy(e))),e.type=this.type,e}toLogical(){if(this.dimension.some(e=>0===e))return n.Complex.false();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=l.numericElement(t[e],"toLogical").toLogical();if(n.Complex.realEquals(r,0))return n.Complex.false()}}return n.Complex.true()}static colon(e){const t=new l([1,e],n.Complex.zero());for(let r=0;r<e;r++)t.array[0][r]=n.Complex.create(r+1);return t}static isLogicalIndex(e){return l.isInstanceOf(e)&&e.type===n.Complex.LOGICAL||n.Complex.isInstanceOf(e)&&e.type===n.Complex.LOGICAL}}t.MultiArray=l,l.isInstanceOf=e=>e instanceof l,l.numericElement=(e,t)=>{if(!n.Complex.isInstanceOf(e))throw new TypeError(`${t}: expected numeric array element.`);return e},l.LOGICAL=n.Complex.LOGICAL,l.REAL=n.Complex.REAL,l.COMPLEX=n.Complex.COMPLEX,l.STRING=s.CharString.STRING,l.STRUCTURE=4,l.FUNCTION_HANDLE=i.RuntimeValue.FUNCTION_HANDLE,l.invalidStructureReferenceMessage="value cannot be indexed with .",l.isScalar=e=>!(e instanceof l&&e.dimension.reduce((e,t)=>e*t,1)>1),l.isRowVector=e=>e instanceof l&&2===e.dimension.length&&1===e.dimension[0],l.toRowVector=e=>{const t=new l([1,e.length]);return t.array[0]=e.slice(),t},l.fromRowVector=e=>e.array[0],l.isColumnVector=e=>e instanceof l&&2===e.dimension.length&&1===e.dimension[1],l.toColumnVector=e=>{const t=new l([e.length,1]);return t.array.map((t,r,n)=>n[r][0]=e[r]),t},l.fromColumnVector=e=>e.array.map(e=>e[0]),l.arrayIsVector=e=>2===e.dimension.length&&(1===e.dimension[0]||1===e.dimension[1]),l.isVector=e=>e instanceof l&&2===e.dimension.length&&(1===e.dimension[0]||1===e.dimension[1]),l.toDiagonalMatrix=e=>{const t=new l([e.length,e.length]);return t.array.map((t,r,n)=>n[r][r]=e[r]),t},l.isMatrix=e=>!(e instanceof l)||2===e.dimension.length,l.isEmpty=e=>e instanceof l&&0===e.dimension.reduce((e,t)=>e*t,1),l.isReducedArrayLine=e=>Array.isArray(e),l.isReducedComplexArrayLine=e=>l.isReducedArrayLine(e)&&e.every(n.Complex.isInstanceOf),l.isCellArray=e=>e instanceof l&&e.isCell,l.isComplexMultiArray=e=>{let t=!1;for(let r=0;r<e.dimensionR.reduce((e,t)=>e*t,1);r++)for(let s=0;s<e.dimension[1];s++)if(n.Complex.isComplexValue(l.numericElement(e.array[r][s],"isComplexMultiArray"))){t=!0;break}return t},l.setType=e=>{e.type=Math.max(...e.array.map(e=>Math.max(...e.map(e=>e.type))))},l.arrayEquals=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]),l.rangeArray=e=>{const t=[];for(let r=1;r<=e;r++)t.push(r);return t},l.linearIndexToSubscript=(e,t)=>e.map((r,n)=>Math.floor(t/e.slice(0,n).reduce((e,t)=>e*t,1))%r+1),l.subscriptToLinearIndex=(e,t)=>t.reduce((t,r,n)=>t+(r-1)*e.slice(0,n).reduce((e,t)=>e*t,1),0),l.linearIndexToMultiArrayRowColumn=(e,t,r)=>{const n=e*t,s=r%n;return[Math.floor(r/n)*e+s%e,Math.floor(s/e)]},l.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],s=r%n;return[Math.floor(r/n)*e[0]+s%e[0],Math.floor(s/e[0])]},l.rowColumnToLinearIndex=(e,t,r)=>Math.floor(t/e[0])*e[0]*e[1]+r*e[0]+t%e[0],l.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)},l.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},l.getStride=(e,t)=>e.dimension.slice(t+1).reduce((e,t)=>e*t,1),l.pageSlice=(e,t)=>{const r=e.dimension;if(r.length<=2)return e.array.map(e=>e.map(e=>l.numericElement(e,"pageSlice")));const[n,s]=r.slice(-2),i=r.slice(0,-2).reduce((e,t)=>e*t,1);if(t>=i)throw new RangeError(`pageSlice: invalid page index ${t}/${i}`);const a=l.flatten(e).map(e=>l.numericElement(e,"pageSlice")),o=t*n*s,c=[];for(let e=0;e<n;e++){const t=[];for(let r=0;r<s;r++)t.push(a[o+e+r*n]);c.push(t)}return c},l.setPage=(e,t,r)=>{const[n,s,...i]=e.dimension,a=i.reduce((e,t)=>e*t,1)||1;if(t>=a)throw new RangeError(`setPage: invalid page index ${t}/${a}`);const o=t*n;for(let t=0;t<n;t++)e.array[o+t].splice(0,s,...r[t])},l.toFlatArray=e=>{const t=e.dimension,r=t.reduce((e,t)=>e*t,1),n=new Array(r);for(let s=0;s<r;s++){const[r,i]=l.linearIndexToMultiArrayRowColumn(t[0],t[1],s);if(!e.array[r]||void 0===e.array[r][i])throw new Error(`toFlatArray: missing element at linear ${s} -> array[${r}][${i}] is undefined.`);n[s]=l.numericElement(e.array[r][i],"toFlatArray")}return n},l.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 s=r[0],i=r.slice(2).reduce((e,t)=>e*t,1),a=s*Math.max(1,i);if(!Array.isArray(e.array)||e.array.length!==a){e.array=new Array(a);for(let t=0;t<a;t++)e.array[t]=new Array(r[1]).fill(void 0)}for(let s=0;s<n;s++){const[n,i]=l.linearIndexToMultiArrayRowColumn(r[0],r[1],s);e.array[n][i]=t[s]}},l.sameSizeExcept=(e,t)=>{const r=e.dimension,n=t.dimension;if(r.length!==n.length)return!1;let s=!0;for(let e=0;e<r.length;e++)if(r[e]!==n[e]){s=!1;break}if(s)return!0;for(let e=0;e<r.length;e++)if(3===r[e]&&3===n[e]){let t=!0;for(let s=0;s<r.length;s++)if(s!==e&&r[s]!==n[s]){t=!1;break}if(t)return!0}return!1},l.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),l.linearLength=e=>e.array.length*e.dimension[1],l.getDimension=(e,t)=>t<e.dimension.length?e.dimension[t]:1,l.removeSingletonTail=e=>{let t=e.length-1;for(;1===e[t]&&t>1;)e.pop(),t--},l.appendSingletonTail=(e,t)=>{t>e.length&&e.push(...new Array(t-e.length).fill(1))},l.firstNonSingleDimension=e=>{if(!e.dimension||0===e.dimension.length)return 0;const t=e.dimension.findIndex(e=>e>1);return t>=0?t:0},l.linkArrayElementParent=(e,t)=>{e&&"object"==typeof e&&(e.parent=t)},l.firstRow=(e,t)=>{const r=new l([1,e.length]);return r.array[0]=e,r.array[0].forEach(e=>l.linkArrayElementParent(e,r)),r.isCell=null!=t&&t,r},l.appendRow=(e,t)=>(t.forEach(t=>l.linkArrayElementParent(t,e)),e.array.push(t),e.dimension[0]++,e),l.unparse=(e,t,r=0)=>{const n=e=>e.map(e=>t.Unparse(e)).join()+";\n";let s="";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])s=e.array.slice(r,r+e.dimension[0]).map(n).join(""),s=s.substring(0,s.length-2),t+=`${e.isCell?"{":"["}${s}${e.isCell?"}":"]"} (:,:,${l.linearIndexToSubscript(e.dimensionR,r).slice(1).join()})\n`;return t}return s=e.array.map(n).join(""),s=s.substring(0,s.length-2),`${e.isCell?"{":"["}${s}${e.isCell?"}":"]"}`},l.unparseMathML=(e,t,r=0)=>{const n=e=>`<mtr>${e.map(e=>`<mtd>${t.UnparserMathML(e)}</mtd>`).join("")}</mtr>`,s=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`${s('<mspace width="0.5em"/>')}<mo fence="true" stretchy="true">(</mo><mn>${e.dimension.join("</mn><mi>×</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 i=e.array.slice(r,r+e.dimension[0]).map(n).join(""),a=l.linearIndexToSubscript(e.dimensionR,r).slice(1).map(e=>`<mn>${e}</mn>`).join("<mo>,</mo>");t+=`<mtr><mtd><msub>${s(i)}<mrow><mo fence="true" stretchy="true">(</mo><mo>:</mo><mo>,</mo><mo>:</mo><mo>,</mo>${a}<mo fence="true" stretchy="true">)</mo></mrow></msub></mtd></mtr>`}return`<mtable>${t}</mtable>`}return s(e.array.map(n).join(""))},l.fromCharString=e=>{if(e.length>0){const t=new l(e.dimension);return t.array=[e.vector().map(e=>n.Complex.create(e.charCodeAt(0)))],t.type=n.Complex.REAL,l.MultiArrayToScalar(t)}return l.emptyArray()},l.characterVectorFromCharString=e=>{const t=new l(e.dimension);return t.array[0]=e.toCharacterScalars(),t.type=s.CharString.STRING,t},l.charStringFromCharacterVectorResult=(e,t)=>{const r=l.isInstanceOf(e)?l.linearize(e):[e];if(0===r.length)return s.CharString.create("",t);if(!l.isCharStringList(r))throw new EvalError("character string indexing produced a non-character value.");return s.CharString.fromCharacterScalars(r,t)},l.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},l.linearize=e=>{if(e instanceof l){const t=e.dimension[0],r=e.dimension[1],n=new Array(l.linearLength(e));let s=0;for(let i=0;i<e.array.length;i+=t)for(let a=0;a<r;a++)for(let r=0;r<t;r++)n[s++]=e.array[i+r][a];return n}return[e]},l.emptyArray=e=>{const t=new l([0,0]);return t.isCell=null!=e&&e,t},l.isObjectRecord=e=>"object"==typeof e&&null!==e,l.isElementRecord=e=>l.isObjectRecord(e)&&!Array.isArray(e)&&Object.values(e).every(e=>null!=e),l.isStructureScalar=e=>l.isObjectRecord(e)&&Reflect.get(e,"type")===l.STRUCTURE&&l.isElementRecord(Reflect.get(e,"field")),l.structureElements=e=>{if(l.isStructureScalar(e))return[e];if(e instanceof l&&!e.isCell){const t=l.linearize(e);return 0!==t.length&&t.every(l.isStructureScalar)?t:[]}return[]},l.structureFieldValue=e=>null!=e?e:l.emptyArray(),l.structureFieldNames=e=>{var t,r;return Object.keys(null!==(r=null===(t=l.structureElements(e)[0])||void 0===t?void 0:t.field)&&void 0!==r?r:{}).sort()},l.createStructureValue=e=>{const t=i.RuntimeValue.createStructure(e);if(!l.isStructureScalar(t))throw new Error("runtime structure factory returned an invalid structure value.");return t},l.isCharStringList=e=>e.length>0&&e.every(e=>s.CharString.isInstanceOf(e)),l.cloneStructureFields=e=>{const t=l.createStructureValue({});return Object.keys(e.field).forEach(e=>{t.field[e]=l.emptyArray()}),t},l.structureHasField=(e,t)=>{const r=l.structureElements(e);return r.length>0&&r.every(e=>i.RuntimeValue.hasOwnField(e.field,t))},l.structureCollectFieldPath=(e,t)=>{if(0===t.length)return[e];const r=l.structureElements(e);if(r.length>0&&e instanceof l)return r.flatMap(e=>l.structureCollectFieldPath(e,t));if(l.isStructureScalar(e)){const r=e.field[t[0]];if(void 0===r)throw new EvalError(l.invalidStructureReferenceMessage);return 1===t.length?[r]:l.structureCollectFieldPath(r,t.slice(1))}throw new EvalError(l.invalidStructureReferenceMessage)},l.getStructureField=(e,t)=>{const r=l.structureCollectFieldPath(e,t);return 1===r.length?r[0]:l.toRowVector(r)},l.structureAssignFieldPath=(e,t,r)=>{if(e instanceof l){const n=l.structureElements(e);if(0===n.length)throw new EvalError(l.invalidStructureReferenceMessage);return void n.forEach(e=>l.structureAssignFieldPath(e,t,r))}if(!l.isStructureScalar(e)||0===t.length)throw new EvalError(l.invalidStructureReferenceMessage);if(1===t.length)return void(e.field[t[0]]=l.structureFieldValue(r));const n=t[0],s=e.field[n];if(void 0===s||l.isEmpty(s))e.field[n]=l.cloneStructureFields(e);else if(!l.isStructureScalar(s)&&0===l.structureElements(s).length)throw new EvalError(l.invalidStructureReferenceMessage);l.structureAssignFieldPath(e.field[n],t.slice(1),r)},l.setEmptyStructureField=(e,t)=>{const r=l.structureElements(e);if(0===r.length)throw new EvalError(l.invalidStructureReferenceMessage);e.isCell||l.structureHasField(e,t)||r.forEach(e=>{e.field[t]=l.emptyArray()})},l.blankValueForExpansion=e=>l.isStructureScalar(e)?l.cloneStructureFields(e):i.RuntimeValue.isClassInstance(e)?i.RuntimeValue.copy(e):s.CharString.isInstanceOf(e)?s.CharString.create(" ",e.quote):n.Complex.zero(),l.scalarToMultiArrayWithTest=(e,t)=>{var r;if(e instanceof l&&t)return e;{const t=new l([1,1]);return t.array[0]=[e],t.type=null!==(r=e.type)&&void 0!==r?r:-1,t}},l.scalarToMultiArray=e=>l.scalarToMultiArrayWithTest(e,!(l.isInstanceOf(e)&&e.isCell)),l.scalarOrCellToMultiArray=e=>l.scalarToMultiArrayWithTest(e,!0),l.MultiArrayToScalar=e=>e instanceof l&&2===e.dimension.length&&1===e.dimension[0]&&1===e.dimension[1]?e.array[0][0]:e,l.firstElement=e=>e instanceof l&&e.dimension.reduce((e,t)=>e*t,1)>0?e.array[0][0]:e,l.firstVector=e=>e instanceof l?1===e.dimension[0]?e.array[0]:e.array.map(e=>e[0]):[e],l.copy=e=>{const t=new l(e.dimension,void 0,e.isCell);return t.array=e.array.map(e=>e.map(e=>i.RuntimeValue.copy(e))),t.type=e.type,t},l.toLogical=e=>{if(e.dimension.some(e=>0===e))return n.Complex.false();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=l.numericElement(r[t],"toLogical").toLogical();if(n.Complex.realEquals(e,0))return n.Complex.false()}}return n.Complex.true()},l.expand=(e,t,r)=>{var n;let s=e.dimension.slice(),i=t.slice();s.length<i.length&&(s=s.concat(new Array(i.length-s.length).fill(1))),i.length<s.length&&(i=i.concat(new Array(s.length-i.length).fill(1)));const a=i.map((e,t)=>Math.max(e,s[t]));if(l.arrayEquals(s,a))return;const o=r?l.blankValueForExpansion(r):e.isCell?l.emptyArray():l.blankValueForExpansion(null===(n=e.array[0])||void 0===n?void 0:n[0]),c=new l(a,o,e.isCell);for(let t=0;t<l.linearLength(e);t++){const[r,n]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t),s=l.linearIndexToSubscript(e.dimension,t),[i,a]=l.subscriptToMultiArrayRowColumn(c.dimension,s);c.array[i][a]=e.array[r][n]}l.removeSingletonTail(c.dimension),e.dimension=c.dimension,e.array=c.array},l.reshape=(e,t,r=-1)=>{const n=e.dimension.reduce((e,t)=>e*t,1),s=t.slice();if(-1!==r){s[r]=1;const e=s.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})`);s[r]=n/e}else if(n!==s.reduce((e,t)=>e*t,1))throw new Error(`reshape: can't reshape ${e.dimension.join("x")} array to ${s.join("x")} array`);let i;return e.dimension[1]===s[1]?(i=l.copy(e),i.dimension=s):(i=new l(s),l.rawMapLinearIndex(e,(e,t)=>{const[r,n]=l.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t);return i.array[r][n]=e,e})),i.type=e.type,i.isCell=e.isCell,l.removeSingletonTail(i.dimension),i},l.expandRange=(e,t,r)=>{const s=[],i=r?n.Complex.realToNumber(r):1;for(let r=n.Complex.realToNumber(e),a=0;i>0?r<=n.Complex.realToNumber(t):r>=n.Complex.realToNumber(t);r+=i,a++)s[a]=n.Complex.create(r);const a=new l([1,s.length]);return a.array=[s],l.setType(a),a},l.expandColon=e=>{const t=new l([e,1]);for(let r=0;r<e;r++)t.array[r]=[n.Complex.create(r+1)];return l.setType(t),t},l.haveAnyComplex=e=>{for(let t=0;t<e.dimension[0];t++)for(let r=0;r<e.dimension[1];r++)if(!n.Complex.imagIsZero(l.numericElement(e.array[t][r],"haveAnyComplex")))return!0;return!1},l.testInteger=(e,t,r,s)=>{const i=(e,t,r)=>{throw new RangeError((e?e+": ":"")+t+" must be "+r)};if(n.Complex.realIsInteger(e)&&!n.Complex.realLessThan(e,1)||i(t,r,"either integers greater than or equal 1 or logicals."),!n.Complex.imagEquals(e,0))throw i(t,r,"real."),new RangeError((t?t+": ":"")+r+" must be real.");const a=n.Complex.realToNumber(e),o=typeof s;return"undefined"!==o&&("number"===o?a>s&&i(t,r,"less than or equal to "+s+" "):(a<s[0]&&i(t,r,"greater than or equal to"+s[0]+" "),a>s&&i(t,r,"less than or equal to"+s[1]+" "))),a},l.testIndex=(e,t)=>{if(!n.Complex.realIsInteger(e)||n.Complex.realLessThan(e,1))throw new RangeError((t?`${t}: `:"")+"subscripts must be either integers greater than or equal 1 or logicals.");if(!n.Complex.imagEquals(e,0))throw new RangeError((t?`${t}: `:"")+"subscripts must be real.");return n.Complex.realToNumber(e)},l.testIndexBound=(e,t,r,n)=>{const s=l.testIndex(e,n);if(s>t)throw new RangeError(`${n?`${n}: `:""}out of bound ${t} (dimensions are ${r.join("x")}).`);return s},l.parseSubscript=(e,t,r,n)=>{const s=t.map(e=>l.testIndex(e,`${r||""}${n?"("+t.map(e=>n.Unparse(e)).join()+")":""}`)),i=(t,n)=>{const i=e=>e>4?`...[x${e}]...`:new Array(e).fill("_").join(),a=i(t),o=i(s.length-t-1);throw new RangeError(`${r||""}(${a}${a?",":""}${s[t]}${o?",":""}${o}): out of bound ${n} (dimensions are ${e.join("x")}).`)},a=s.slice();if(l.removeSingletonTail(a),a.length>e.length){const t=s.map((t,r)=>t>e[r]).indexOf(!0);t>=0&&i(t,1)}let o;if(s.length<e.length){o=e.slice();const t=s.map((t,r)=>t>e[r]).indexOf(!0);if(t>=0)if(t===s.length-1){const e=o.slice(s.length-1).reduce((e,t)=>e*t,1);s[s.length-1]>e&&i(t,e)}else i(t,o[t])}else{o=e.concat(new Array(s.length-e.length).fill(1));const t=s.map((t,r)=>t>e[r]).indexOf(!0);t>=0&&i(t,o[t])}return a.reduce((t,r,n)=>t+(r-1)*e.slice(0,n).reduce((e,t)=>e*t,1),0)},l.scalarOpMultiArray=(e,t,r)=>{const s=new l(r.dimension);return s.array=r.array.map(r=>r.map(r=>n.Complex[e](t,r))),l.setType(s),s},l.MultiArrayOpScalar=(e,t,r)=>{const s=new l(t.dimension);return s.array=t.array.map(t=>t.map(t=>n.Complex[e](t,r))),l.setType(s),s},l.leftOperation=(e,t)=>{const r=new l(t.dimension);return r.array=t.array.map(t=>t.map(t=>n.Complex[e](t))),l.setType(r),r},l.elementWiseOperation=(e,t,r)=>{let s=t.dimension.slice(),i=r.dimension.slice();const a=Math.max(s.length,i.length);for(;s.length<a;)s.push(1);for(;i.length<a;)i.push(1);const o=new Array(a),c=new Array(a),u=new Array(a);for(let t=0;t<a;t++){const r=s[t],n=i[t];if(r===n)o[t]=r,c[t]=u[t]=!1;else if(1===r)o[t]=n,c[t]=!0,u[t]=!1;else{if(1!==n)throw new EvalError(`operator ${e}: nonconformant arguments (op1 is ${s.join("x")}, op2 is ${i.join("x")}).`);o[t]=r,c[t]=!1,u[t]=!0}}const h=l.computeStrides(s),d=l.computeStrides(i),m=l.computeStrides(o),p=o.reduce((e,t)=>e*t,1),f=new l(o),g=s[0],y=g*(s[1]||1),x=i[0],C=x*(i[1]||1),E=o[0],v=E*(o[1]||1);for(let s=0;s<p;s++){let i=0,l=0;for(let e=0;e<a;e++){const t=Math.floor(s/m[e])%o[e],r=c[e]?0:t,n=u[e]?0:t;i+=r*h[e],l+=n*d[e]}const p=Math.floor(i/y),A=i-p*y,S=p*g+A%g,_=Math.floor(A/g),b=Math.floor(l/C),T=l-b*C,M=b*x+T%x,N=Math.floor(T/x),I=Math.floor(s/v),L=s-I*v,w=I*E+L%E,O=Math.floor(L/E);f.array[w][O]=n.Complex[e](t.array[S][_],r.array[M][N])}return l.setType(f),f},l.rawMap=(e,t)=>{const r=new l(e.dimension);return r.array=e.array.map(e=>e.map(t)),l.setType(r),r},l.rawMapRowColumn=(e,t)=>{const r=new l(e.dimension);return r.array=e.array.map((e,r)=>e.map((e,n)=>t(e,r,n))),l.setType(r),r},l.rawMapLinearIndex=(e,t)=>{const r=new l(e.dimension);return r.array=e.array.map((r,n)=>r.map((r,s)=>t(r,Math.floor(n/e.dimension[0])*e.dimension[0]*e.dimension[1]+s*e.dimension[0]+n%e.dimension[0],n,s))),l.setType(r),r},l.alongDimensionMap=(e,t,r)=>{const n=new l(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 s=t.dimension.slice();s[e]=1;const i=s.reduce((e,t)=>e*t,1),a=s.map(e=>l.rangeArray(e));for(let o=0;o<i;o++)for(let i=1;i<=t.dimension[e];i++){const c=a.slice();c[e]=[i];const u=l.linearIndexToSubscript(s,o).map((e,t)=>c[t][e-1]),[h,d]=l.subscriptToMultiArrayRowColumn(t.dimension,u);n.array[h]||(n.array[h]=[]),n.array[h][d]=r(t.array[h][d],u[e]-1,h,d)}}return l.setType(n),n},l.sizeAlongDimension=(e,t)=>{const r=void 0!==t?n.Complex.realToNumber(l.firstElement(t))-1:Math.max(0,l.firstNonSingleDimension(e));return e.dimension[r]},l.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 s=new Array(n.length).fill(1);s[t]=r+1;const i=l.subscriptToLinearIndex(n,s),[a,o]=l.linearIndexToMultiArrayRowColumn(n[0],n[1],i);return e.array[a][o]},l.divideElementByScalar=(e,t)=>l.isInstanceOf(e)?l.rawMap(e,e=>n.Complex.rdiv(e,t)):n.Complex.rdiv(e,t),l.getMeanElementForPosition=(e,t,r)=>l.isInstanceOf(e)?l.getElementAlongDimension(e,t,r-1):e,l.reduceToArray=(e,t)=>{if(e>=t.dimension.length){const e=new l(t.dimension);return e.array=t.array.map(e=>e.map(e=>[e])),e.type=t.type,e}{const r=t.dimension.slice();r[e]=1;const n=new l(r),s=t.dimension.slice();s[e]=1;const i=s.reduce((e,t)=>e*t,1);for(let r=1;r<=t.dimension[e];r++){const s=t.dimension.slice();s[e]=1;const a=s.map(e=>l.rangeArray(e));a[e]=[r];for(let e=0;e<i;e++){const i=l.linearIndexToSubscript(s,e).map((e,t)=>a[t][e-1]),o=l.subscriptToLinearIndex(t.dimension,i),[c,u]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],o),[h,d]=l.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e);if(1===r)n.array[h][d]=[t.array[c][u]];else{const e=n.array[h][d];if(!l.isReducedArrayLine(e))throw new Error("reduceToArray: invalid reduced slot.");e.push(t.array[c][u])}}}return n.type=t.type,n}},l.reduce=(e,t,r,n)=>{if(e>=t.dimension.length)return t;{const s=t.dimension.slice();s[e]=1;const i=new l(s),a=t.dimension.slice();a[e]=1;const o=a.reduce((e,t)=>e*t,1),c=a.map(e=>l.rangeArray(e));for(let e=0;e<o;e++){const s=l.linearIndexToSubscript(a,e).map((e,t)=>c[t][e-1]),o=l.subscriptToLinearIndex(t.dimension,s),[u,h]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],o),[d,m]=l.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e);i.array[d][m]=n?r(n,t.array[u][h],e):t.array[u][h]}for(let n=2;n<=t.dimension[e];n++){const s=t.dimension.slice();s[e]=1;const a=s.map(e=>l.rangeArray(e));a[e]=[n];for(let n=0;n<o;n++){const o=l.linearIndexToSubscript(s,n).map((e,t)=>a[t][e-1]),c=l.subscriptToLinearIndex(t.dimension,o),[u,h]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],c),[d,m]=l.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],n),p=l.linearIndexToSubscript(i.dimension,n);p[e]=1;const[f,g]=l.subscriptToMultiArrayRowColumn(i.dimension,p);i.array[d][m]=r(i.array[f][g],t.array[u][h],n)}}return l.setType(i),l.MultiArrayToScalar(i)}},l.concatenate=(e,t,...r)=>{const n=r.some(e=>!l.isEmpty(e))?r.filter(e=>!l.isEmpty(e)):r;let s,a;for(const e of n)for(const r of l.linearize(e)){const e=i.RuntimeValue.classDefinitionOfInstance(r);if(s){if(e&&e!==s)throw new Error(`${t}: object arrays must contain objects of the same class.`)}else s=e;if(l.isStructureScalar(r)){const e=l.structureFieldNames(r);if(a){if(!l.arrayEquals(e,a))throw new Error(`${t}: structure arrays must contain structures with the same fields.`)}else a=e}}const o=[],c=n.map(t=>{const r=t.dimension.slice();return l.appendSingletonTail(r,e+1),o.push(r[e]),r[e]=0,r});if(!c.every(e=>l.arrayEquals(e,c[0])))throw new EvalError(`${t}: dimension mismatch`);const u=c[0].slice();u[e]=o.reduce((e,t)=>e+t,0);const h=new l(u);return n.forEach((t,r)=>{const n=o.slice(0,r).reduce((e,t)=>e+t,0);for(let r=0;r<l.linearLength(t);r++){const s=t.dimension.slice();l.appendSingletonTail(s,e+1);const i=l.linearIndexToSubscript(s,r);i[e]+=n;const[a,o]=l.subscriptToMultiArrayRowColumn(h.dimension,i),[c,u]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r);h.array[a][o]=t.array[c][u]}}),l.setType(h),h},l.splitLastDimension=e=>{const t=[],r=e.dimension[e.dimension.length-1];for(let n=0;n<r;n++){const s=e.array.length/r,i=new l(e.dimension.slice(0,-1));i.array=e.array.slice(n*s,(n+1)*s),t.push(i)}return t},l.evaluateRecursive=(e,t,r)=>{var n;if(e.dimension.length>2)return l.concatenate(e.dimension.length-1,"evaluate",...l.splitLastDimension(e).map(e=>l.scalarToMultiArray(l.evaluateRecursive(e,t,r))));{const i=[],a=e.array.map(n=>{var a;const o=n.flatMap(e=>(e=>{if(!t)return[e];t.context.pushCommaListExpansion();try{return t.context.expandCommaSeparatedList(t.Evaluator(e,r))}finally{t.context.popCommaListExpansion()}})(e)),c=o.length>1?null===(a=null==t?void 0:t.concatenateOverload)||void 0===a?void 0:a.call(t,"horzcat",o,e):void 0;if(void 0!==c)return i.push(c),l.scalarToMultiArray(c);if(i.push(void 0),l.isCharStringList(o)&&o.every(s.CharString.isChar)){const e=o[0].quote;return l.scalarToMultiArray(s.CharString.fromCharacterScalars(o,e))}return l.concatenate(1,"evaluate",...o.map(e=>l.scalarToMultiArray(e)))});if(1===a.length&&void 0!==i[0])return i[0];const o=a.map(e=>l.MultiArrayToScalar(e)),c=null===(n=null==t?void 0:t.concatenateOverload)||void 0===n?void 0:n.call(t,"vertcat",o,e);return void 0!==c?c:l.concatenate(0,"evaluate",...a)}},l.evaluate=(e,t,r)=>{var n,i;if(l.isEmpty(e))return e;if(e.isCell){const s=e.array.map(n=>n.flatMap(n=>(()=>{if(!t)return[n];t.context.pushCommaListExpansion();try{return t.context.expandCommaSeparatedList(t.Evaluator(n,r))}finally{t.context.popCommaListExpansion()}})().map(t=>(t&&(t.parent=e),t))));if(s.length>1&&s.some(e=>e.length!==s[0].length))throw new EvalError("evaluate: dimension mismatch");const a=new l([s.length,null!==(i=null===(n=s[0])||void 0===n?void 0:n.length)&&void 0!==i?i:0],void 0,!0);return a.array=s,a.array.forEach(e=>e.forEach(e=>{e&&(e.parent=a)})),a}{const n=l.evaluateRecursive(e,t,r);return l.isInstanceOf(n)?(n.isCell=e.isCell,l.setType(n),2===n.dimension.length&&1===n.dimension[0]&&1===n.dimension[1]&&s.CharString.isInstanceOf(n.array[0][0])?n.array[0][0]:n):n}},l.computeIndexingStructure=(e,t)=>{if(0===t.length)throw new RangeError("invalid empty index list.");const r=e.length,s=t.length;if(1===t.length){const r=t[0],i=l.linearize(r),a=e.reduce((e,t)=>e*t,1);return{isLinear:!0,isLinearColonOnly:l.isInstanceOf(r)&&l.isColumnVector(r)&&i.length===a&&i.every((e,t)=>n.Complex.isInstanceOf(e)&&n.Complex.realToNumber(e)===t+1),linearIndexDimension:l.isInstanceOf(r)?r.dimension.slice():[1,1],originalIndexCount:s,args:[i],argsLength:[i.length],total:i.length}}const i=t.slice();for(;i.length<r;)i.push(l.colon(e[i.length]));const a=i.map((t,r)=>l.linearize(((t,r)=>{if(!l.isLogicalIndex(t))return t;const s=l.logicalMaskFromIndexArgument(t),i=l.linearizedLogicalMask(s),a=[];for(let t=0;t<i.length;t++){if(t>=e[r])throw new RangeError(`logical index out of bound ${e[r]}.`);n.Complex.realToNumber(i[t])&&a.push(n.Complex.create(t+1))}return l.toColumnVector(a)})(t,r))),o=a.map(e=>e.length),c=o.reduce((e,t)=>e*t,1);return{isLinear:!1,isLinearColonOnly:!1,originalIndexCount:s,args:a,argsLength:o,total:c}},l.iterateWithLinearIndex=(e,t,r,n,s)=>{for(let i=0;i<e.total;i++){const a=l.linearIndexToSubscript(e.argsLength,i).map((t,r)=>e.args[r][t-1]);r(a,l.parseSubscript(t,a,n,s),i)}},l.resolveIndexPlan=(e,t)=>{const r=e.length;if(t.isLinear)return{isLinear:!0,isColonOnly:t.isLinearColonOnly,isRowSelection:!1,isColumnSelection:!1,requiresCollapse:!1,activeDimensions:[0],isFullSlice:[t.isLinearColonOnly],isScalarIndex:[1===t.argsLength[0]]};const n=t.argsLength.slice();for(;n.length<r;)n.push(e[n.length]);const s=[],i=[],a=[];for(let t=0;t<r;t++){const r=n[t],o=r===e[t],l=1===r;s.push(o),i.push(l),o||a.push(t)}return{isLinear:!1,isColonOnly:!1,isRowSelection:2===t.originalIndexCount&&1===t.argsLength[0],isColumnSelection:2===t.originalIndexCount&&1===t.argsLength[1],requiresCollapse:t.originalIndexCount<r,activeDimensions:a,isFullSlice:s,isScalarIndex:i}},l.getElementByLinearIndex=(e,t,r)=>{const[n,s]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);return r.length>0?l.getStructureField(e.array[n][s],r):e.array[n][s]},l.setElementByLinearIndex=(e,t,r,n)=>{const[s,i]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);n.length>0?l.structureAssignFieldPath(e.array[s][i],n,r):e.array[s][i]=r},l.collapseResult=(e,t,r,n)=>{if(!n.requiresCollapse)return e;const s=l.linearize(e);if(2===r.originalIndexCount&&1===r.argsLength[1]){const t=r.argsLength[0],n=new l([t,1]);for(let r=0;r<t;r++)n.array[r][0]=e.array[r][0];return l.setType(n),n}if(2===r.originalIndexCount&&1===r.argsLength[0]){const e=l.toRowVector(s);return l.setType(e),e}if(e.dimension.length>2){const t=e.dimension[0],r=s.length/t,n=new l([t,r]);let i=0;for(let e=0;e<r;e++)for(let r=0;r<t;r++)n.array[r][e]=s[i++];return l.setType(n),n}return e},l.linearIndexResult=(e,t,r,n)=>{var s;if(n.isColonOnly)return l.toColumnVector(t);const i=null!==(s=r.linearIndexDimension)&&void 0!==s?s:[1,t.length];if(l.arrayIsVector(e)&&2===i.length&&(1===i[0]||1===i[1]))return l.isRowVector(e)?l.toRowVector(t):l.toColumnVector(t);const a=new l(i);for(let e=0;e<t.length;e++){const[r,n]=l.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);a.array[r][n]=t[e]}return a},l.logicalIndexResult=(e,t,r)=>l.arrayIsVector(e)&&l.arrayIsVector(r)?l.isRowVector(e)?l.toRowVector(t):l.toColumnVector(t):l.arrayIsVector(r)&&l.isRowVector(r)?l.toRowVector(t):l.toColumnVector(t),l.logicalMaskFromIndexArgument=e=>n.Complex.isInstanceOf(e)?l.scalarToMultiArray(e):e,l.linearizedLogicalMask=(e,t)=>{const r=l.linearize(e);if(!r.every(n.Complex.isInstanceOf))throw new EvalError(`${null!=t?t:""}: invalid logical index.`);return r},l.logicalToLinearIndices=(e,t,r)=>{const s=l.linearize(e),i=l.linearizedLogicalMask(t,r);if(i.length>s.length)throw new EvalError(`${null!=r?r:""}(${i.length}): out of bound ${s.length} (dimensions are ${e.dimension.join("x")})`);const a=[];for(let e=0;e<i.length;e++)n.Complex.realToNumber(i[e])&&a.push(e);return a},l.logicalMaskToIndexList=(e,t,r)=>l.logicalToLinearIndices(e,t,r),l.applyLinearSelection=(e,t,r)=>{const n=[];for(const s of t)n.push(l.getElementByLinearIndex(e,s,r));return n},l.applyLinearAssignment=(e,t,r,n)=>{const s=1===r.length;if(!s&&r.length!==t.length)throw new EvalError(`=: nonconformant arguments (op1 is ${t.length}x1, op2 is ${r.length}x1)`);for(let i=0;i<t.length;i++){const a=s?r[0]:r[i];l.setElementByLinearIndex(e,t[i],a,n)}},l.resolveLinearIndices=(e,t,r,n)=>{if(1===r.length&&l.isLogicalIndex(r[0])){const n=l.logicalMaskFromIndexArgument(r[0]);return l.logicalToLinearIndices(e,n,t)}const s=l.computeIndexingStructure(e.dimension,r),i=[];return l.iterateWithLinearIndex(s,e.dimension,(e,t)=>{i.push(t)},t,n),i},l.collectLinearIndices=(e,t,r,n)=>{const s=[];return l.iterateWithLinearIndex(e,t,(e,t)=>{s.push(t)},r,n),s},l.applyDeletionFromIndices=(e,t)=>{const r=l.linearize(e),n=new Set(t),s=r.filter((e,t)=>!n.has(t));let i;i=l.arrayIsVector(e)&&l.isRowVector(e)?l.toRowVector(s):l.toColumnVector(s),e.array=i.array,e.dimension=i.dimension},l.getElements=(e,t,r,n,s)=>{if(0===n.length)return e;const i=l.resolveLinearIndices(e,t,n,s),a=l.applyLinearSelection(e,i,r);if(1===n.length&&l.isLogicalIndex(n[0])){const t=l.logicalMaskFromIndexArgument(n[0]),r=l.logicalIndexResult(e,a,t);return l.setType(r),r}const o=l.computeIndexingStructure(e.dimension,n),c=l.resolveIndexPlan(e.dimension,o);if(o.isLinear){const t=l.linearIndexResult(e,a,o,c);return l.setType(t),t}const u=new l(o.argsLength);for(let e=0;e<a.length;e++){const[t,r]=l.subscriptToMultiArrayRowColumn(u.dimension,l.linearIndexToSubscript(u.dimension,e));u.array[t][r]=a[e]}return l.setType(u),l.collapseResult(u,e.dimension,o,c)},l.setElementsNumerical=(e,t,r,n,s,i,a)=>{const o=l.linearize(s),c=r.length>0&&0===o.length?[s]:o;if(0===c.length){const r=e.resolveName(t);if(!(r&&r.node instanceof l))throw new RangeError(`A(I) = []: index out of bounds: value ${l.firstElement(n[0])} out of bound 0`);return void l.deleteElements(r.node,n,i,a)}if(0===n.length)throw new RangeError("invalid empty index list.");const u=e.resolveName(t),h=null==u?void 0:u.node,d=l.computeIndexingStructure(h instanceof l?h.dimension:[1],n);if(1!==c.length&&c.length!==d.total)throw new RangeError(`=: nonconformant arguments (op1 is ${d.argsLength.join("x")}, op2 is ${s.dimension.join("x")})`);let m=u;const p=d.args.map(e=>Math.max(...e.map(e=>l.testIndex(e))));if(m)if(m.node instanceof l)if(d.isLinear){if(p[0]>l.linearLength(m.node))if(l.isEmpty(m.node)){const e=r.length>0?l.createStructureValue(r):m.node.isCell?void 0:l.blankValueForExpansion(c[0]);l.expand(m.node,[1,p[0]],e)}else{if(!l.arrayIsVector(m.node))throw new RangeError("Invalid resizing operation or ambiguous assignment to an out-of-bounds array element.");1===m.node.dimension[0]?l.expand(m.node,[1,p[0]]):l.expand(m.node,[p[0],1])}}else l.expand(m.node,p);else{const r=m.node,n=l.blankValueForExpansion(r);if(m=d.isLinear?e.defineName(t,new l([1,p[0]],n)):e.defineName(t,new l(p,n)),!(m.node instanceof l))throw new TypeError("internal error: index assignment target is not an array.");m.node.array[0][0]=r}else{const n=0===r.length&&s.isCell,i=r.length>0?l.createStructureValue(r):n?l.emptyArray():l.blankValueForExpansion(c[0]);m=d.isLinear?e.defineName(t,new l([1,p[0]],i,n)):e.defineName(t,new l(p,i,n))}if(!(m.node instanceof l))throw new TypeError("internal error: index assignment target is not an array.");const f=m.node;r.length>0&&l.setEmptyStructureField(f,r[0]);const g=f.dimension.slice(),y=l.collectLinearIndices(d,g,i,a);l.applyLinearAssignment(f,y,c,r)},l.setElements=(e,t,r,n,s,i,a)=>{if(1===n.length&&l.isLogicalIndex(n[0])){const i=l.logicalMaskFromIndexArgument(n[0]),a=e.resolveName(t);if(!(a&&a.node instanceof l))throw new EvalError(`${t}(_): invalid matrix indexing.`);const o=a.node,c=l.logicalMaskToIndexList(o,i,t),u=l.linearize(s),h=r.length>0&&0===u.length?[s]:u;if(0===h.length){const e=l.linearize(o),t=new Set(c),r=e.filter((e,r)=>!t.has(r));let n;return n=l.isRowVector(o)?l.toRowVector(r):l.toColumnVector(r),o.array=n.array,void(o.dimension=n.dimension)}return void l.applyLinearAssignment(o,c,h,r)}l.setElementsNumerical(e,t,r,n,s,i,a)},l.deleteElements=(e,t,r,n)=>{if(0===t.length)throw new RangeError("invalid empty index list.");const s=l.computeIndexingStructure(e.dimension,t);if(s.isLinear){const t=l.collectLinearIndices(s,e.dimension,r,n);return void l.applyDeletionFromIndices(e,t)}let i=-1;for(let t=0;t<s.argsLength.length;t++)if(s.argsLength[t]!==e.dimension[t]){if(-1!==i)throw new RangeError("a null assignment can only have one non-colon index");i=t}if(-1===i)throw new RangeError("a null assignment can only have one non-colon index");const a=l.collectLinearIndices(s,e.dimension,r,n),o=new Set(a),c=e.dimension.slice();c[i]=0;const u=l.linearize(e),h=[];for(let e=0;e<u.length;e++)o.has(e)||h.push(u[e]);const d=u.length/e.dimension[i],m=h.length/d;c[i]=m;const p=new l(c);let f=0;for(let e=0;e<h.length;e++){const[t,r]=l.subscriptToMultiArrayRowColumn(p.dimension,l.linearIndexToSubscript(p.dimension,e));p.array[t][r]=h[f++]}l.setType(p),e.array=p.array,e.dimension=p.dimension},l.reduceFactory=(e,t,r)=>{switch(t){case"reduce":return void 0!==r?(t,s)=>{const i=l.scalarToMultiArray(t),a=void 0!==s?n.Complex.realToNumber(l.firstElement(s))-1:Math.max(0,l.firstNonSingleDimension(i));return l.reduce(a,i,e,r)}:(t,r)=>{const s=l.scalarToMultiArray(t),i=void 0!==r?n.Complex.realToNumber(l.firstElement(r))-1:Math.max(0,l.firstNonSingleDimension(s));return l.reduce(i,s,e)};case"cumulative":return void 0!==r?(t,s)=>{const i=l.scalarToMultiArray(t),a=void 0!==s?n.Complex.realToNumber(l.firstElement(s))-1:l.firstNonSingleDimension(i),o=l.alongDimensionMap(a,i,(c=void 0,(t,n)=>c=e(0===n?r:c,t)));var c;return l.setType(o),o}:(t,r)=>{const s=l.scalarToMultiArray(t),i=void 0!==r?n.Complex.realToNumber(l.firstElement(r))-1:l.firstNonSingleDimension(s),a=l.alongDimensionMap(i,s,(o=void 0,(t,r)=>o=0===r?t:e(o,t)));var o;return l.setType(a),a};case"cumcomparison":return(t,r)=>{const s=l.scalarToMultiArray(t),i=r?n.Complex.realToNumber(l.firstElement(r))-1:l.firstNonSingleDimension(s),a=new l(s.dimension);let c,u;const h=l.alongDimensionMap(i,s,(t,r,s,i)=>(0===r?(c=t,u=n.Complex.one()):n.Complex.realToNumber(n.Complex[e](t,c))&&(c=t,u=n.Complex.create(r+1)),a.array[s][i]=u,c));return l.setType(h),l.setType(a),o(2,(e,t)=>{if(1===e.length)return l.MultiArrayToScalar(h);if(2===e.length)return l.MultiArrayToScalar(0===t?h:a);throw new EvalError("unreachable cumulative comparison return-list selector branch.")},e=>({length:e}))};case"comparison":const s="lt"===e?"min":"max";return(...t)=>{const r=(t,r)=>{const i=l.reduceToArray(r,t),a=new l(i.dimension),c=new l(i.dimension);for(let t=0;t<c.array.length;t++)for(let r=0;r<c.array[t].length;r++){const o=i.array[t][r];if(!l.isReducedComplexArrayLine(o))throw new Error(`${s}: invalid reduced array slot.`);let u=o[0],h=1;for(let t=1;t<o.length;t++){const r=o[t];n.Complex.realToNumber(n.Complex[e](r,u))&&(u=r,h=t+1)}a.array[t][r]=u,c.array[t][r]=n.Complex.create(h)}return l.setType(a),l.setType(c),o(2,(e,t)=>{if(1===e.length)return l.MultiArrayToScalar(a);if(2===e.length)return l.MultiArrayToScalar(0===t?a:c);throw new EvalError("unreachable comparison return-list selector branch.")},e=>({length:e}))};switch(t.length){case 1:{const e=l.scalarToMultiArray(t[0]);return r(e,l.firstNonSingleDimension(e))}case 2:{const e=l.scalarToMultiArray(t[0]),n=t[1];if(l.isScalar(n))return r(e,l.testInteger(n,"reduceFactory","dimension",[1,1/0])-1);const i=l.scalarToMultiArray(n);return l.elementWiseOperation(s+"Wise",e,i)}case 3:if(!l.isEmpty(t[1]))throw new Error(`${s}: second argument must be [] or omitted`);return r(l.scalarToMultiArray(t[0]),n.Complex.realToNumber(l.firstElement(t[2]))-1);default:(e=>{throw new EvalError(`Invalid call to ${e}.`)})(s)}};default:throw TypeError(`reduceFactory: invalid type argument: ${t}`)}},t.default={MultiArray:l}},6430(e,t,r){"use strict";t.ParserErrorListener=void 0;const n=r(3222),s=r(2697);class i extends n.ErrorListener{constructor(e=""){super(),this.source=e}syntaxError(e,t,r,n,i,a){if(!s.SyntaxDiagnostic.isBenignEndOfInput(i))throw s.SyntaxDiagnostic.error(i,r,n,this.source)}}t.ParserErrorListener=i},7673(e,t){"use strict";t.RuntimeEquality=void 0;class r{}t.RuntimeEquality=r,r.isObject=e=>!!e&&"object"==typeof e,r.isComplexLike=e=>r.isObject(e)&&Object.prototype.hasOwnProperty.call(e,"re")&&Object.prototype.hasOwnProperty.call(e,"im"),r.isCharStringLike=e=>r.isObject(e)&&"string"==typeof e.str,r.isArrayLike=e=>r.isObject(e)&&Array.isArray(e.dimension)&&Array.isArray(e.array)&&"boolean"==typeof e.isCell,r.isStructureLike=e=>r.isObject(e)&&r.isObject(e.field),r.isFunctionHandleLike=e=>r.isObject(e)&&5===e.type,r.isClassInstanceLike=e=>r.isObject(e)&&7===e.type&&r.isObject(e.classDefinition)&&r.isObject(e.properties),r.isClassEnumerationValueLike=e=>r.isObject(e)&&10===e.type&&r.isObject(e.classDefinition)&&r.isObject(e.enumeration)&&"string"==typeof e.enumeration.name&&Array.isArray(e.args),r.scalarPartEqual=(e,t)=>{if(e===t)return!0;const n=r.partToString(e),s=r.partToString(t);return void 0!==n&&n===s},r.partToString=e=>"number"==typeof e||"bigint"==typeof e||"boolean"==typeof e||"string"==typeof e?String(e):r.isObject(e)&&"function"==typeof e.toString?e.toString():void 0,r.valuesEqual=(e,t)=>e===t||(null===e||null===t||void 0===e||void 0===t?e===t:r.isComplexLike(e)&&r.isComplexLike(t)?r.scalarPartEqual(e.re,t.re)&&r.scalarPartEqual(e.im,t.im):r.isCharStringLike(e)&&r.isCharStringLike(t)?e.str===t.str:r.isArrayLike(e)&&r.isArrayLike(t)?r.multiArraysEqual(e,t):r.isStructureLike(e)&&r.isStructureLike(t)?r.structuresEqual(e,t):r.isFunctionHandleLike(e)&&r.isFunctionHandleLike(t)?e.id===t.id&&r.functionHandleString(e)===r.functionHandleString(t):r.isClassInstanceLike(e)&&r.isClassInstanceLike(t)?e.classDefinition===t.classDefinition&&(e.classDefinition.isHandleClass()||t.classDefinition.isHandleClass()?e===t:r.propertyTablesEqual(e.properties,t.properties)):!(!r.isClassEnumerationValueLike(e)||!r.isClassEnumerationValueLike(t))&&e.classDefinition===t.classDefinition&&e.enumeration.name===t.enumeration.name&&r.elementListsEqual(e.args,t.args)),r.functionHandleString=e=>e.id?"@"+e.id:"@anonymous function handle",r.multiArraysEqual=(e,t)=>e.isCell===t.isCell&&r.arrayEquals(e.dimension,t.dimension)&&r.elementListsEqual(r.linearize(e),r.linearize(t)),r.structuresEqual=(e,t)=>r.propertyTablesEqual(e.field,t.field),r.propertyTablesEqual=(e,t)=>{const n=Object.keys(e).sort(),s=Object.keys(t).sort();return r.arrayEquals(n,s)&&n.every(n=>r.valuesEqual(e[n],t[n]))},r.elementListsEqual=(e,t)=>e.length===t.length&&e.every((e,n)=>r.valuesEqual(e,t[n])),r.arrayEquals=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]),r.linearize=e=>{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}},1604(e,t){"use strict";t.RuntimeValue=void 0;class r{}t.RuntimeValue=r,r.FUNCTION_HANDLE=5,r.CLASS_INSTANCE=7,r.hasCopy=e=>!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof Reflect.get(e,"copy"),r.copy=e=>r.hasCopy(e)?e.copy():e,r.hasOwnField=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.registerStructureFactory=e=>{r.structureFactory=e},r.createStructure=e=>{if(!r.structureFactory)throw new Error("runtime structure factory is not registered.");return r.structureFactory(e)},r.isClassInstance=e=>"object"==typeof e&&null!==e&&Reflect.get(e,"type")===r.CLASS_INSTANCE&&r.isNamedClassDefinition(Reflect.get(e,"classDefinition"))&&r.isObjectRecord(Reflect.get(e,"properties")),r.classDefinitionOfInstance=e=>r.isClassInstance(e)?e.classDefinition:void 0,r.hasDimensions=e=>"object"==typeof e&&null!==e&&r.isNumericDimensionVector(Reflect.get(e,"dimension")),r.isObjectRecord=e=>"object"==typeof e&&null!==e,r.isNamedClassDefinition=e=>r.isObjectRecord(e)&&"string"==typeof Reflect.get(e,"name"),r.isNumericDimensionVector=e=>Array.isArray(e)&&e.every(e=>"number"==typeof e),r.dimensions=(e,t=2)=>{const n=r.hasDimensions(e)?e.dimension.slice():[1,1];for(;n.length<t;)n.push(1);return n},r.elementCount=e=>r.dimensions(e).reduce((e,t)=>e*t,1),r.isEmpty=e=>r.dimensions(e).some(e=>0===e),r.isScalar=e=>1===r.elementCount(e),r.isMatrix=e=>2===r.dimensions(e).length,r.isVector=e=>{const t=r.dimensions(e);return 2===t.length&&(1===t[0]||1===t[1])},r.isRowVector=e=>{const t=r.dimensions(e);return 2===t.length&&1===t[0]},r.isColumnVector=e=>{const t=r.dimensions(e);return 2===t.length&&1===t[1]},r.isSquareMatrix=e=>{const t=r.dimensions(e);return 2===t.length&&t[0]===t[1]}},2981(e,t){"use strict";t.Scope=void 0;class r{constructor(e,t=Object.create(null),r=Object.create(null),n=Object.create(null),s={explicit:Object.create(null),wildcard:[]},i=!0,a=!1,o=!1,l){this.parent=e,this.nameTable=t,this.functionTable=r,this.undefinedReferenceTable=n,this.importTable=s,this.resolveParentNames=i,this.assignExistingParentNames=a,this.rejectDynamicNameCreation=o,this.staticWorkspaceNameSet=l}defineName(e,t,r){const n=this.nameTable[e];if(n)return n.node=t,r?n.undefinedReference=r:delete n.undefinedReference,n;if(!this.canCreateLocalName(e))throw new Error(`Attempt to add variable '${e}' to a static workspace.`);return this.nameTable[e]=r?{undefinedReference:r,node:t}:{node:t}}assignName(e,t,r){if(this.assignExistingParentNames&&!this.hasLocalName(e)&&this.parent){const n=this.parent.resolveName(e);if(n)return n.node=t,r?n.undefinedReference=r:delete n.undefinedReference,n}if(!this.canCreateLocalName(e))throw new Error(`Attempt to add variable '${e}' to a static workspace.`);return this.defineName(e,t,r)}canCreateLocalName(e){var t;return!this.rejectDynamicNameCreation||this.hasLocalName(e)||Boolean(null===(t=this.staticWorkspaceNameSet)||void 0===t?void 0:t.has(e))}allowStaticWorkspaceName(e){var t;(null!==(t=this.staticWorkspaceNameSet)&&void 0!==t?t:this.staticWorkspaceNameSet=new Set).add(e)}allowStaticWorkspaceNames(e){for(const t of e)this.allowStaticWorkspaceName(t)}defineNameTable(e){for(const[t,r]of Object.entries(e))this.nameTable[t]={node:r}}resolveName(e){return this.nameTable[e]||(this.resolveParentNames&&this.parent?this.parent.resolveName(e):void 0)}hasLocalName(e){return e in this.nameTable}removeName(e){delete this.nameTable[e]}clearName(e){let t=this;for(;t;)delete t.nameTable[e],t=t.parent}defineFunction(e,t){return this.functionTable[e]=t}defineFunctionTable(e){Object.assign(this.functionTable,e)}resolveFunction(e){return this.functionTable[e]||(this.parent?this.parent.resolveFunction(e):void 0)}hasLocalFunction(e){return e in this.functionTable}removeFunction(e){delete this.functionTable[e]}clearFunction(e){let t=this;for(;t;)delete t.functionTable[e],t=t.parent}bindParameters(e,t){for(let r=0;r<e.length;r++)this.defineName(e[r],t[r])}bindParametersChecked(e,t){if(e.length!==t.length)throw new Error(`Arity mismatch: expected ${e.length} argument(s), got ${t.length}`);this.bindParameters(e,t)}defineUndefinedReference(e,t){const r=this.resolveUndefinedReference(e);return r?(r.add(t),r):this.undefinedReferenceTable[e]=new Set([t])}resolveUndefinedReference(e){return this.undefinedReferenceTable[e]||(this.parent?this.parent.resolveUndefinedReference(e):void 0)}removeUndefinedReference(e){delete this.undefinedReferenceTable[e]}clearUndefinedReference(e){let t=this;for(;t;)delete t.undefinedReferenceTable[e],t=t.parent}defineImport(e){var t,r,n;if(e.endsWith(".*")){const t=e.slice(0,-2);return void(t&&!this.importTable.wildcard.includes(t)&&this.importTable.wildcard.push(t))}const s=null!==(t=e.split(".").pop())&&void 0!==t?t:e;if(s){const t=null!==(r=(n=this.importTable.explicit)[s])&&void 0!==r?r:n[s]=[];t.includes(e)||t.push(e)}}clearImports(){this.importTable.explicit=Object.create(null),this.importTable.wildcard=[]}importSnapshot(){return{explicit:r.cloneExplicitImports(this.importTable.explicit),wildcard:this.importTable.wildcard.slice()}}restoreImports(e){this.importTable={explicit:r.cloneExplicitImports(e.explicit),wildcard:e.wildcard.slice()}}importList(){const e=[],t=new Set;let r=this;for(;r;){for(const n of Object.values(r.importTable.explicit))for(const r of n)t.has(r)||(t.add(r),e.push(r));for(const n of r.importTable.wildcard){const r=`${n}.*`;t.has(r)||(t.add(r),e.push(r))}r=r.parent}return e}importedNameCandidates(e){const t=[];let r=this;for(;r;){const n=r.importTable.explicit[e];if(null==n?void 0:n.length){t.push(...n);break}for(const n of r.importTable.wildcard)t.push(`${n}.${e}`);r=r.parent}return t}snapshot(e){const t=this.parent?this.parent.snapshot(e):void 0,n=r.create(t);for(const[t,r]of Object.entries(this.nameTable))n.nameTable[t]=Object.assign(Object.assign({},r),{node:void 0!==r.node?e(r.node):r.node});n.functionTable=Object.assign({},this.functionTable),n.undefinedReferenceTable=Object.create(null);for(const[e,t]of Object.entries(this.undefinedReferenceTable))n.undefinedReferenceTable[e]=new Set(t);return n.importTable.explicit=r.cloneExplicitImports(this.importTable.explicit),n.importTable.wildcard=[...this.importTable.wildcard],n.assignExistingParentNames=this.assignExistingParentNames,n.rejectDynamicNameCreation=this.rejectDynamicNameCreation,n.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,n}capture(e,t=!0){const n=r.create(this,t);for(const[t,r]of Object.entries(this.nameTable))n.nameTable[t]=Object.assign(Object.assign({},r),{node:void 0!==r.node?e(r.node):r.node});n.functionTable=Object.assign({},this.functionTable),n.undefinedReferenceTable=Object.create(null);for(const[e,t]of Object.entries(this.undefinedReferenceTable))n.undefinedReferenceTable[e]=new Set(t);return n.importTable.explicit=r.cloneExplicitImports(this.importTable.explicit),n.importTable.wildcard=[...this.importTable.wildcard],n.assignExistingParentNames=this.assignExistingParentNames,n.rejectDynamicNameCreation=this.rejectDynamicNameCreation,n.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,n}static cloneExplicitImports(e){const t=Object.create(null);for(const[r,n]of Object.entries(e))t[r]=n.slice();return t}}t.Scope=r,r.create=(e,t=!0)=>new r(e,Object.create(null),Object.create(null),Object.create(null),{explicit:Object.create(null),wildcard:[]},t)},9274(e,t){"use strict";var r,n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(s,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,o)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.TableSourceResolver=t.ManifestSourceResolver=void 0;const s=(e,t,r)=>{var n,s;if(void 0!==t)return"string"==typeof t?{name:e,sourceName:r,source:t}:{name:null!==(n=t.name)&&void 0!==n?n:e,sourceName:null!==(s=t.sourceName)&&void 0!==s?s:r,source:t.source}},i=e=>/[\\/]/.test(e)||/\.m(?:[?#].*)?$/i.test(e)?e.replace(/\\/g,"/"):void 0,a=e=>e.replace(/\\/g,"/").split(/[?#]/,1)[0],o=e=>{var t,r;return null!==(r=null===(t=a(e).split("/").pop())||void 0===t?void 0:t.replace(/\.m$/i,""))&&void 0!==r?r:e},l=e=>{const t=a(e).replace(/^\.\//,"").replace(/\.m$/i,"").split("/").filter(Boolean),r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.startsWith("+"))r.push(n.slice(1));else if(n.startsWith("@")){const s=n.slice(1);r.push(s),e===t.length-2&&t[e+1]===s&&e++}else e===t.length-1&&r.push(n)}return r.join(".")},c=e=>a(e).replace(/^\.\//,"").replace(/\/+$/g,""),u=e=>{if(!e.includes(".")||/[\\/]/.test(e))return;const t=e.split(".").filter(Boolean),r=t.pop();return r?`${t.map(e=>`+${e}`).join("/")}/${r}.m`:void 0},h=(e,t)=>{const r=(e=>{const t=c(e),r=[t];if(!/[\\/]/.test(t)&&!t.startsWith("+")&&!t.startsWith("@")){const e=t.split(".").filter(Boolean).map(e=>`+${e}`).join("/");e&&r.push(e)}return[...new Set(r)]})(e);return t.some(e=>Boolean(e&&Object.entries(e).some(([e,t])=>((e,t)=>{const r=[e],n=u(e);if(n&&r.push(n),"string"!=typeof t){if(t.name){r.push(t.name);const e=u(t.name);e&&r.push(e)}t.sourceName&&r.push(t.sourceName)}return r.map(c)})(e,t).some(e=>r.some(t=>e!==t&&e.startsWith(`${t}/`))))))},d=e=>{const t=l(e);return[...new Set([e,t])]},m=e=>{const t=l(e);return[...new Set([e,o(e),t,o(t)])]},p=(e,t,r)=>{var n;for(const a of e){const e=null!==(n=null==t?void 0:t[a])&&void 0!==n?n:null==r?void 0:r(a);if(void 0!==e)return s(a,e,i(a))}},f=(e,t)=>{for(const r of e){const e=t[r];if(e)return s(r,e)}},g=(e,t,r,n=e=>e)=>{if(!t)return;const a=new Set(e.map(r));for(const[e,o]of Object.entries(t)){if(a.has(r(e)))return s(n(e),o,i(e));if("string"!=typeof o&&o.name&&a.has(r(o.name)))return s(n(o.name),o,i(o.name));if("string"!=typeof o&&o.sourceName&&a.has(r(o.sourceName)))return s(n(o.sourceName),o,i(o.sourceName))}},y=(e,t)=>/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:e?`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`:t;class x{constructor(e){this.config=e}resolve(e,t){var r,n,s;switch(e){case"function":{const e=d(t);return null!==(r=p(e,this.config.functionSourceTable,this.config.functionSourceProvider))&&void 0!==r?r:g(e,this.config.functionSourceTable,l,l)}case"script":return null!==(n=p(m(t),this.config.scriptSourceTable,this.config.scriptSourceProvider))&&void 0!==n?n:g(m(t),this.config.scriptSourceTable,o);case"class":{const e=d(t);return null!==(s=p(e,this.config.classSourceTable,this.config.classSourceProvider))&&void 0!==s?s:g(e,this.config.classSourceTable,l,l)}}}hasDirectory(e){return h(e,[this.config.functionSourceTable,this.config.scriptSourceTable,this.config.classSourceTable])}}t.TableSourceResolver=x,x.create=(e={})=>new x(e);class C{constructor(e){this.sources=e}resolve(e,t){return"script"===e?f(m(t),this.sources.script):f(d(t),this.sources[e])}hasDirectory(e){return h(e,[this.sources.function,this.sources.script,this.sources.class])}}t.ManifestSourceResolver=C,r=C,C.fromTable=e=>{const t={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const[r,n]of Object.entries(e)){const e="string"==typeof n?[r]:[r,...n.sourceName?[n.sourceName]:[],...n.name?[n.name]:[]];for(const r of e){const e=l(r),a=o(r),c=i(r),u=s(e,n,c),h=s(a,n,c);for(const e of d(r))t.function[e]=u,t.class[e]=u;for(const e of m(r))t.script[e]=h}}return new r(t)},C.fromManifest=(e,...t)=>n(void 0,[e,...t],void 0,function*(e,t=globalThis.fetch){var n,s,i,a;if(!t)throw new Error("ManifestSourceResolver.fromManifest requires a fetch implementation.");const c={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const r of e.files){const u="string"==typeof r?{path:r}:r,h=y(e.baseUrl,u.path),p=yield t(h);if(!1===p.ok)throw new Error(`failed to fetch ${h}: ${null!==(n=p.status)&&void 0!==n?n:""} ${null!==(s=p.statusText)&&void 0!==s?s:""}`.trim());const f=null!==(i=u.sourceName)&&void 0!==i?i:u.path,g=null!==(a=u.name)&&void 0!==a?a:l(f),x={name:g,sourceName:f,source:yield p.text()},C=u.kind?[u.kind]:["function","script","class"];for(const e of C){const t="script"===e?[...m(u.path),...m(f),...m(g)]:[...d(u.path),...d(f),...d(g)];for(const r of t)c[e][r]=x;"script"===e&&(c.script[o(g)]=x)}}return new r(c)}),t.default={ManifestSourceResolver:C,TableSourceResolver:x}},5212(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Structure=void 0;const n=r(845),s=r(7679),i=r(1604);class a{constructor(e){if(this.type=a.STRUCTURE,this.field={},Array.isArray(e)){let t=this;for(let r=0;r<e.length-1;r++){const n=new a({});t.field[e[r]]=n,t=n}t.field[e[e.length-1]]=s.MultiArray.emptyArray()}else for(const[t,r]of Object.entries(e))this.field[t]=i.RuntimeValue.copy(r)}copy(){return a.copy(this)}toLogical(){return a.toLogical(this)}}t.Structure=a,a.STRUCTURE=4,a.invalidReferenceMessage="value cannot be indexed with .",a.isInstanceOf=e=>e instanceof a,a.structureElements=e=>{if(e instanceof a)return[e];if(e instanceof s.MultiArray&&!e.isCell){const t=s.MultiArray.linearize(e);return 0!==t.length&&t.every(a.isInstanceOf)?t:[]}return[]},a.isStructure=e=>a.structureElements(e).length>0,a.fieldNames=e=>{var t,r;return Object.keys(null!==(r=null===(t=a.structureElements(e)[0])||void 0===t?void 0:t.field)&&void 0!==r?r:{}).sort()},a.hasField=(e,t)=>{const r=a.structureElements(e);return r.length>0&&r.every(e=>i.RuntimeValue.hasOwnField(e.field,t))},a.isMissingOrEmpty=e=>void 0===e||s.MultiArray.isEmpty(e),a.ensureStructureLike=e=>{if(a.isMissingOrEmpty(e))return new a({});if(e instanceof a)return e;if(e instanceof s.MultiArray&&a.isStructure(e))return e;throw new EvalError(a.invalidReferenceMessage)},a.assignFieldPath=(e,t,r)=>{if(e instanceof s.MultiArray){const n=a.structureElements(e);if(0===n.length)throw new EvalError(a.invalidReferenceMessage);return void n.forEach(e=>a.assignFieldPath(e,t,r))}if(0===t.length)throw new EvalError(a.invalidReferenceMessage);if(1===t.length)return void(e.field[t[0]]=null!=r?r:s.MultiArray.emptyArray());const n=t[0],i=a.ensureStructureLike(e.field[n]);e.field[n]=i,a.assignFieldPath(i,t.slice(1),r)},a.collectFieldPath=(e,t)=>{if(null==e)throw new EvalError(a.invalidReferenceMessage);if(0===t.length)return[e];if(e instanceof s.MultiArray&&a.isStructure(e))return a.structureElements(e).flatMap(e=>a.collectFieldPath(e,t));if(e instanceof a){const r=e.field[t[0]];if(void 0===r)throw new EvalError(a.invalidReferenceMessage);return 1===t.length?[r]:a.collectFieldPath(r,t.slice(1))}throw new EvalError(a.invalidReferenceMessage)},a.setField=(e,t,r)=>{a.assignFieldPath(e,t,r)},a.setNewField=(e,t,r)=>{a.assignFieldPath(e,t,r)},a.getField=(e,t)=>{const r=a.collectFieldPath(e,t);return 1===r.length?r[0]:s.MultiArray.toRowVector(r)},a.getFields=(e,t)=>a.collectFieldPath(e,t),a.removeFields=(e,t)=>{if(e instanceof a){const r=a.copy(e);return t.forEach(e=>{delete r.field[e]}),r}if(0===a.structureElements(e).length)throw new EvalError(a.invalidReferenceMessage);const r=s.MultiArray.copy(e);return a.structureElements(r).forEach(e=>{t.forEach(t=>{delete e.field[t]})}),r},a.orderFields=e=>{const t=e=>{const t=new a({});for(const r of Object.keys(e.field).sort())t.field[r]=i.RuntimeValue.copy(e.field[r]);return t};if(e instanceof a)return t(e);const r=a.structureElements(e);if(0===r.length)throw new EvalError(a.invalidReferenceMessage);const n=s.MultiArray.copy(e),o=r.map(t);for(let e=0;e<o.length;e++){const[t,r]=s.MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e);n.array[t][r]=o[e]}return n},a.unparse=(e,t,r=0)=>`struct {\n${Object.entries(e.field).map(e=>`${e[0]}: ${t.Unparse(e[1])}`).join("\n")}\n}`,a.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>`},a.copy=e=>{const t=new a({});for(const[r,n]of Object.entries(e.field))t.field[r]=i.RuntimeValue.copy(n);return t},a.cloneFields=e=>{const t=new a({});return Object.keys(e.field).forEach(e=>{t.field[e]=s.MultiArray.emptyArray()}),t},a.toLogical=e=>Object.keys(e.field).length>0?n.Complex.true():n.Complex.false(),a.setEmptyField=(e,t)=>{const r=a.structureElements(e);if(0===r.length)throw new EvalError(a.invalidReferenceMessage);e.isCell||a.hasField(e,t)||r.forEach(e=>{e.field[t]=s.MultiArray.emptyArray()})},t.default={Structure:a},i.RuntimeValue.registerStructureFactory(e=>new a(e))},2697(e,t,r){"use strict";t.SyntaxDiagnostic=void 0;const n=r(1201);class s{}t.SyntaxDiagnostic=s,s.benignEndOfInputMessages=new Set(["mismatched input '' expecting {';', SP}","missing ';' at ''","mismatched input '' expecting","mismatched input '' expecting "]),s.error=(e,t,r,i="")=>{const a=`syntax error at ${Math.max(1,t)}:${Math.max(1,r+1)}: ${s.normalizeMessage(e)}`,o=s.sourceLine(i,t);if(!o)return new n.SyntaxError(a);const l=s.displayColumn(o,r);return new n.SyntaxError(`${a}\n${o}\n${" ".repeat(l)}^`)},s.isBenignEndOfInput=e=>s.benignEndOfInputMessages.has(e),s.normalizeMessage=e=>e.replace(/\bEOF\b/g,(e,t,r)=>"<"===r[t-1]&&">"===r[t+e.length]?e:"<EOF>"),s.displayColumn=(e,t)=>{const r=Math.max(0,Math.min(t,e.length));return[...e.slice(0,r)].reduce((e,t)=>e+("\t"===t?4:1),0)},s.sourceLine=(e,t)=>{var r;return null!==(r=e.replace(/\r\n?/g,"\n").split("\n")[t-1])&&void 0!==r?r:""}},3504(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.MathML=t.Configuration=t.CoreFunctions=t.MathOperation=t.LinearAlgebra=t.ClassMetaEnumerationMember=t.ClassMetaEvent=t.ClassMetaMethod=t.ClassMetaProperty=t.ClassMetaMember=t.ClassMetaClass=t.ClassMetaObject=t.ClassPropertyEvent=t.ClassEventData=t.ClassEventListener=t.ClassEnumerationValue=t.ClassEmptyMethod=t.ClassStaticMethod=t.ClassBoundMethod=t.ClassInstance=t.ClassDefinition=t.ClassMember=t.FunctionHandle=t.Structure=t.MultiArray=t.Complex=t.ComplexDecimal=t.ComplexNumber=t.stringClass=t.doubleQuoteCharacter=t.singleQuoteCharacter=t.CharString=t.Decimal=void 0;var i=r(3110);Object.defineProperty(t,"Decimal",{enumerable:!0,get:function(){return i.Decimal}});var a=r(5956);Object.defineProperty(t,"CharString",{enumerable:!0,get:function(){return a.CharString}}),Object.defineProperty(t,"singleQuoteCharacter",{enumerable:!0,get:function(){return a.singleQuoteCharacter}}),Object.defineProperty(t,"doubleQuoteCharacter",{enumerable:!0,get:function(){return a.doubleQuoteCharacter}}),Object.defineProperty(t,"stringClass",{enumerable:!0,get:function(){return a.stringClass}});var o=r(3428);Object.defineProperty(t,"ComplexNumber",{enumerable:!0,get:function(){return o.ComplexNumber}});var l=r(3826);Object.defineProperty(t,"ComplexDecimal",{enumerable:!0,get:function(){return l.ComplexDecimal}});var c=r(845);Object.defineProperty(t,"Complex",{enumerable:!0,get:function(){return c.Complex}});var u=r(7679);Object.defineProperty(t,"MultiArray",{enumerable:!0,get:function(){return u.MultiArray}});var h=r(5212);Object.defineProperty(t,"Structure",{enumerable:!0,get:function(){return h.Structure}});var d=r(1271);Object.defineProperty(t,"FunctionHandle",{enumerable:!0,get:function(){return d.FunctionHandle}});var m=r(9283);Object.defineProperty(t,"ClassMember",{enumerable:!0,get:function(){return m.ClassMember}});var p=r(6816);Object.defineProperty(t,"ClassDefinition",{enumerable:!0,get:function(){return p.ClassDefinition}});var f=r(9770);Object.defineProperty(t,"ClassInstance",{enumerable:!0,get:function(){return f.ClassInstance}});var g=r(9656);Object.defineProperty(t,"ClassBoundMethod",{enumerable:!0,get:function(){return g.ClassBoundMethod}});var y=r(8986);Object.defineProperty(t,"ClassStaticMethod",{enumerable:!0,get:function(){return y.ClassStaticMethod}});var x=r(3226);Object.defineProperty(t,"ClassEmptyMethod",{enumerable:!0,get:function(){return x.ClassEmptyMethod}});var C=r(7325);Object.defineProperty(t,"ClassEnumerationValue",{enumerable:!0,get:function(){return C.ClassEnumerationValue}});var E=r(5577);Object.defineProperty(t,"ClassEventListener",{enumerable:!0,get:function(){return E.ClassEventListener}});var v=r(169);Object.defineProperty(t,"ClassEventData",{enumerable:!0,get:function(){return v.ClassEventData}});var A=r(482);Object.defineProperty(t,"ClassPropertyEvent",{enumerable:!0,get:function(){return A.ClassPropertyEvent}});var S=r(7268);Object.defineProperty(t,"ClassMetaObject",{enumerable:!0,get:function(){return S.ClassMetaObject}}),Object.defineProperty(t,"ClassMetaClass",{enumerable:!0,get:function(){return S.ClassMetaClass}}),Object.defineProperty(t,"ClassMetaMember",{enumerable:!0,get:function(){return S.ClassMetaMember}}),Object.defineProperty(t,"ClassMetaProperty",{enumerable:!0,get:function(){return S.ClassMetaProperty}}),Object.defineProperty(t,"ClassMetaMethod",{enumerable:!0,get:function(){return S.ClassMetaMethod}}),Object.defineProperty(t,"ClassMetaEvent",{enumerable:!0,get:function(){return S.ClassMetaEvent}}),Object.defineProperty(t,"ClassMetaEnumerationMember",{enumerable:!0,get:function(){return S.ClassMetaEnumerationMember}});var _=r(4610);Object.defineProperty(t,"LinearAlgebra",{enumerable:!0,get:function(){return _.LinearAlgebra}});var b=r(6554);Object.defineProperty(t,"MathOperation",{enumerable:!0,get:function(){return b.MathOperation}});var T=r(3717);Object.defineProperty(t,"CoreFunctions",{enumerable:!0,get:function(){return T.CoreFunctions}});var M=r(9947);Object.defineProperty(t,"Configuration",{enumerable:!0,get:function(){return M.Configuration}});var N=r(7686);Object.defineProperty(t,"MathML",{enumerable:!0,get:function(){return N.MathML}}),s(r(6109),t),s(r(7727),t)},21(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=i(r(6982));r(5323),globalThis.crypto=a.default,s(r(3504),t)},2424(e,t){"use strict";t.substSymbol=function(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$/,"∞").replace(/^NaN$|^nan$/,"<b>NaN</b>")}},6982(e){"use strict";e.exports=require("crypto")},9896(e){"use strict";e.exports=require("fs")},3222(e,t,r){(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{ATN:()=>J,ATNDeserializer:()=>Ne,BailErrorStrategy:()=>St,CharStream:()=>bt,CharStreams:()=>Lt,CommonToken:()=>Re,CommonTokenStream:()=>Dt,DFA:()=>lt,DefaultErrorStrategy:()=>At,DiagnosticErrorListener:()=>Ct,ErrorListener:()=>Ie,FailedPredicateException:()=>yt,FileStream:()=>It,InputMismatchException:()=>gt,InputStream:()=>Tt,Interval:()=>E,IntervalSet:()=>v,LL1Analyzer:()=>Q,Lexer:()=>Ve,LexerATNSimulator:()=>Ke,NoViableAltException:()=>tt,ParseTreeListener:()=>dt,ParseTreeVisitor:()=>mt,ParseTreeWalker:()=>pt,Parser:()=>Pt,ParserATNSimulator:()=>nt,ParserRuleContext:()=>Ut,PredictionContextCache:()=>st,PredictionMode:()=>et,RecognitionException:()=>Pe,RuleContext:()=>V,RuleNode:()=>R,TerminalNode:()=>D,Token:()=>s,TokenStreamRewriter:()=>$t,arrayToString:()=>d,default:()=>zt});class s{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 i(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}s.INVALID_TYPE=0,s.EPSILON=-2,s.MIN_USER_TOKEN_TYPE=1,s.EOF=-1,s.DEFAULT_CHANNEL=0,s.HIDDEN_CHANNEL=1;const a=Math.round(Math.random()*Math.pow(2,32));function o(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,s;const i=3&r.length,o=r.length-i;let l=a;const c=3432918353,u=461845907;let h=0;for(;h<o;)s=255&r.charCodeAt(h)|(255&r.charCodeAt(++h))<<8|(255&r.charCodeAt(++h))<<16|(255&r.charCodeAt(++h))<<24,++h,s=(65535&s)*c+(((s>>>16)*c&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*u+(((s>>>16)*u&65535)<<16)&4294967295,l^=s,l=l<<13|l>>>19,n=5*(65535&l)+((5*(l>>>16)&65535)<<16)&4294967295,l=27492+(65535&n)+((58964+(n>>>16)&65535)<<16);switch(s=0,i){case 3:s^=(255&r.charCodeAt(h+2))<<16;case 2:s^=(255&r.charCodeAt(h+1))<<8;case 1:s^=255&r.charCodeAt(h),s=(65535&s)*c+(((s>>>16)*c&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*u+(((s>>>16)*u&65535)<<16)&4294967295,l^=s}return l^=r.length,l^=l>>>16,l=2246822507*(65535&l)+((2246822507*(l>>>16)&65535)<<16)&4294967295,l^=l>>>13,l=3266489909*(65535&l)+((3266489909*(l>>>16)&65535)<<16)&4294967295,l^=l>>>16,l>>>0}class l{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=o(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 l;return e.update.apply(e,arguments),e.finish()}}function c(e){return e?"string"==typeof e?o(e):e.hashCode():-1}function u(e,t){return e&&e.equals?e.equals(t):e===t}function h(e){return null===e?"null":e}function d(e){return Array.isArray(e)?"["+e.map(h).join(", ")+"]":"null"}class m{constructor(e,t){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=e||c,this.equalsFunction=t||u}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 d(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 p{hashCode(){const e=new l;return this.updateHashCode(e),e.finish()}evaluate(e,t){}evalPrecedence(e,t){return this}static andContext(e,t){if(null===e||e===p.NONE)return t;if(null===t||t===p.NONE)return e;const r=new f(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===p.NONE||t===p.NONE)return p.NONE;const r=new g(e,t);return 1===r.opnds.length?r.opnds[0]:r}}class f extends p{constructor(e,t){super();const r=new m;e instanceof f?e.opnds.map(function(e){r.add(e)}):r.add(e),t instanceof f?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 f&&i(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 s=0;s<this.opnds.length;s++){const i=this.opnds[s],a=i.evalPrecedence(e,t);if(r|=a!==i,null===a)return null;a!==p.NONE&&n.push(a)}if(!r)return this;if(0===n.length)return p.NONE;let s=null;return n.map(function(e){s=null===s?e:p.andContext(s,e)}),s}toString(){const e=this.opnds.map(e=>e.toString());return(e.length>3?e.slice(3):e).join("&&")}}class g extends p{constructor(e,t){super();const r=new m;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){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 g&&i(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 s=0;s<this.opnds.length;s++){const i=this.opnds[s],a=i.evalPrecedence(e,t);if(r|=a!==i,a===p.NONE)return p.NONE;null!==a&&n.push(a)}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 p.PrecedencePredicate&&t.push(e)}),t}function x(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 C{constructor(e,t){this.checkContext(e,t),e=x(e),t=x(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:p.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 l;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 C&&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 l;return e.update(this.state.stateNumber,this.alt,this.semanticContext),e.finish()}equalsForConfigSet(e){return this===e||e instanceof C&&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!==p.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class E{constructor(e,t){this.start=e,this.stop=t}clone(){return new E(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}}E.INVALID_INTERVAL=new E(-1,-2);class v{constructor(){this.intervals=null,this.readOnly=!1}first(e){return null===this.intervals||0===this.intervals.length?s.INVALID_TYPE:this.intervals[0].start}addOne(e){this.addInterval(new E(e,e+1))}addRange(e,t){this.addInterval(new E(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 E(e.start,r.stop));if(e.start<=r.stop)return this.intervals[t]=new E(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 E(t.start,r.stop),this.intervals.splice(e+1,1))}}complement(e,t){const r=new v;return r.addInterval(new E(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 E(r.start,e.start);const n=new E(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 E(r.start,e.start):e.stop<r.stop&&(this.intervals[t]=new E(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 E(r.start+1,r.stop));if(e===r.stop-1)return void(this.intervals[t]=new E(r.start,r.stop-1));if(e<r.stop-1){const n=new E(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===s.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===s.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 s=this.intervals[n];for(let n=s.start;n<s.stop;n++)r.push(this.elementName(e,t,n))}return r.length>1?"{"+r.join(", ")+"}":r[0]}elementName(e,t,r){return r===s.EOF?"<EOF>":r===s.EPSILON?"<EPSILON>":e[r]||t[r]}get length(){return this.intervals.map(e=>e.length).reduce((e,t)=>e+t)}}class A{constructor(){this.atn=null,this.stateNumber=A.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 A&&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)}}A.INVALID_TYPE=0,A.BASIC=1,A.RULE_START=2,A.BLOCK_START=3,A.PLUS_BLOCK_START=4,A.STAR_BLOCK_START=5,A.TOKEN_START=6,A.RULE_STOP=7,A.BLOCK_END=8,A.STAR_LOOP_BACK=9,A.STAR_LOOP_ENTRY=10,A.PLUS_LOOP_BACK=11,A.LOOP_END=12,A.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"],A.INVALID_STATE_NUMBER=-1;class S extends A{constructor(){return super(),this.stateType=A.RULE_STOP,this}}class _{constructor(e){if(null==e)throw"target cannot be null.";this.target=e,this.isEpsilon=!1,this.label=null}}_.EPSILON=1,_.RANGE=2,_.RULE=3,_.PREDICATE=4,_.ATOM=5,_.ACTION=6,_.SET=7,_.NOT_SET=8,_.WILDCARD=9,_.PRECEDENCE=10,_.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],_.serializationTypes={EpsilonTransition:_.EPSILON,RangeTransition:_.RANGE,RuleTransition:_.RULE,PredicateTransition:_.PREDICATE,AtomTransition:_.ATOM,ActionTransition:_.ACTION,SetTransition:_.SET,NotSetTransition:_.NOT_SET,WildcardTransition:_.WILDCARD,PrecedencePredicateTransition:_.PRECEDENCE};class b extends _{constructor(e,t,r,n){super(e),this.ruleIndex=t,this.precedence=r,this.followState=n,this.serializationType=_.RULE,this.isEpsilon=!0}matches(e,t,r){return!1}}class T extends _{constructor(e,t){super(e),this.serializationType=_.SET,null!=t?this.label=t:(this.label=new v,this.label.addOne(s.INVALID_TYPE))}matches(e,t,r){return this.label.contains(e)}toString(){return this.label.toString()}}class M extends T{constructor(e,t){super(e,t),this.serializationType=_.NOT_SET}matches(e,t,r){return e>=t&&e<=r&&!super.matches(e,t,r)}toString(){return"~"+super.toString()}}class N extends _{constructor(e){super(e),this.serializationType=_.WILDCARD}matches(e,t,r){return e>=t&&e<=r}toString(){return"."}}class I extends _{constructor(e){super(e)}}class L{}class w extends L{}class O extends w{}class R extends O{get ruleContext(){throw new Error("missing interface implementation")}}class D extends O{}class F extends D{}const P={toStringTree:function(e,t,r){t=t||null,null!==(r=r||null)&&(t=r.ruleNames);let n=P.getNodeText(e,t);n=function(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(n);const s=e.getChildCount();if(0===s)return n;let i="("+n+" ";s>0&&(n=P.toStringTree(e.getChild(0),t),i=i.concat(n));for(let r=1;r<s;r++)n=P.toStringTree(e.getChild(r),t),i=i.concat(" "+n);return i=i.concat(")"),i},getNodeText:function(e,t,r){if(t=t||null,null!==(r=r||null)&&(t=r.ruleNames),null!==t){if(e instanceof R){const r=e.ruleContext.getAltNumber();return 0!=r?t[e.ruleIndex]+":"+r:t[e.ruleIndex]}if(e instanceof F)return e.toString();if(e instanceof D&&null!==e.symbol)return e.symbol.text}const n=e.getPayload();return n instanceof s?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 P.findAllNodes(e,t,!0)},findAllRuleNodes:function(e,t){return P.findAllNodes(e,t,!1)},findAllNodes:function(e,t,r){const n=[];return P._findAllNodes(e,t,r,n),n},_findAllNodes:function(e,t,r,n){r&&e instanceof D?e.symbol.type===t&&n.push(e):!r&&e instanceof R&&e.ruleIndex===t&&n.push(e);for(let s=0;s<e.getChildCount();s++)P._findAllNodes(e.getChild(s),t,r,n)},descendants:function(e){let t=[e];for(let r=0;r<e.getChildCount();r++)t=t.concat(P.descendants(e.getChild(r)));return t}},k=P;class V extends R{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 E.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 U{constructor(e){this.cachedHashCode=e}isEmpty(){return this===U.EMPTY}hasEmptyPath(){return this.getReturnState(this.length-1)===U.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}updateHashCode(e){e.update(this.cachedHashCode)}}U.EMPTY=null,U.EMPTY_RETURN_STATE=2147483647,U.globalNodeCount=1,U.id=U.globalNodeCount,U.trace_atn_sim=!1;class $ extends U{constructor(e,t){const r=new l;return r.update(e,t),super(r.finish()),this.parents=e,this.returnStates=t,this}isEmpty(){return this.returnStates[0]===U.EMPTY_RETURN_STATE}getParent(e){return this.parents[e]}getReturnState(e){return this.returnStates[e]}equals(e){return this===e||e instanceof $&&this.hashCode()===e.hashCode()&&i(this.returnStates,e.returnStates)&&i(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]!==U.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 B extends U{constructor(e,t){let r=0;const n=new l;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 B&&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===U.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+e}get length(){return 1}static create(e,t){return t===U.EMPTY_RETURN_STATE&&null===e?U.EMPTY:new B(e,t)}}class H extends B{constructor(){super(null,U.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(e){return null}getReturnState(e){return this.returnState}equals(e){return this===e}toString(){return"$"}}U.EMPTY=new H;class j{constructor(e,t){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=e||c,this.equalsFunction=t||u}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 s=n.find(t=>this.equalsFunction(t[0],e),this);if(s){const e=s[1];return s[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 q(e,t){if(null==t&&(t=V.EMPTY),null===t.parentCtx||t===V.EMPTY)return U.EMPTY;const r=q(e,t.parentCtx),n=e.states[t.invokingState].transitions[0];return B.create(r,n.followState.stateNumber)}function z(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 s=!1,i=[];for(let n=0;n<i.length;n++){const a=z(e.getParent(n),t,r);if(s||a!==e.getParent(n)){if(!s){i=[];for(let t=0;t<e.length;t++)i[t]=e.getParent(t);s=!0}i[n]=a}}if(!s)return t.add(e),r.set(e,e),e;let a=null;return a=0===i.length?U.EMPTY:1===i.length?B.create(i[0],e.getReturnState(0)):new $(i,e.returnStates),t.add(a),r.set(a,a),r.set(e,a),a}function G(e,t,r,n){if(e===t)return e;if(e instanceof B&&t instanceof B)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 s=function(e,t,r){if(r){if(e===U.EMPTY)return U.EMPTY;if(t===U.EMPTY)return U.EMPTY}else{if(e===U.EMPTY&&t===U.EMPTY)return U.EMPTY;if(e===U.EMPTY){const e=[t.returnState,U.EMPTY_RETURN_STATE],r=[t.parentCtx,null];return new $(r,e)}if(t===U.EMPTY){const t=[e.returnState,U.EMPTY_RETURN_STATE],r=[e.parentCtx,null];return new $(r,t)}}return null}(e,t,r);if(null!==s)return null!==n&&n.set(e,t,s),s;if(e.returnState===t.returnState){const s=G(e.parentCtx,t.parentCtx,r,n);if(s===e.parentCtx)return e;if(s===t.parentCtx)return t;const i=B.create(s,e.returnState);return null!==n&&n.set(e,t,i),i}{let r=null;if((e===t||null!==e.parentCtx&&e.parentCtx===t.parentCtx)&&(r=e.parentCtx),null!==r){const s=[e.returnState,t.returnState];e.returnState>t.returnState&&(s[0]=t.returnState,s[1]=e.returnState);const i=new $([r,r],s);return null!==n&&n.set(e,t,i),i}const s=[e.returnState,t.returnState];let i=[e.parentCtx,t.parentCtx];e.returnState>t.returnState&&(s[0]=t.returnState,s[1]=e.returnState,i=[t.parentCtx,e.parentCtx]);const a=new $(i,s);return null!==n&&n.set(e,t,a),a}}(e,t,r,n);if(r){if(e instanceof H)return e;if(t instanceof H)return t}return e instanceof B&&(e=new $([e.getParent()],[e.returnState])),t instanceof B&&(t=new $([t.getParent()],[t.returnState])),function(e,t,r,n){if(null!==n){let r=n.get(e,t);if(null!==r)return U.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> previous"),r;if(r=n.get(t,e),null!==r)return U.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> previous"),r}let s=0,i=0,a=0,o=new Array(e.returnStates.length+t.returnStates.length).fill(0),l=new Array(e.returnStates.length+t.returnStates.length).fill(null);for(;s<e.returnStates.length&&i<t.returnStates.length;){const c=e.parents[s],u=t.parents[i];if(e.returnStates[s]===t.returnStates[i]){const t=e.returnStates[s];t===U.EMPTY_RETURN_STATE&&null===c&&null===u||null!==c&&null!==u&&c===u?(l[a]=c,o[a]=t):(l[a]=G(c,u,r,n),o[a]=t),s+=1,i+=1}else e.returnStates[s]<t.returnStates[i]?(l[a]=c,o[a]=e.returnStates[s],s+=1):(l[a]=u,o[a]=t.returnStates[i],i+=1);a+=1}if(s<e.returnStates.length)for(let t=s;t<e.returnStates.length;t++)l[a]=e.parents[t],o[a]=e.returnStates[t],a+=1;else for(let e=i;e<t.returnStates.length;e++)l[a]=t.parents[e],o[a]=t.returnStates[e],a+=1;if(a<l.length){if(1===a){const r=B.create(l[0],o[0]);return null!==n&&n.set(e,t,r),r}l=l.slice(0,a),o=o.slice(0,a)}const c=new $(l,o);return c.equals(e)?(null!==n&&n.set(e,t,e),U.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> a"),e):c.equals(t)?(null!==n&&n.set(e,t,t),U.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),U.trace_atn_sim&&console.log("mergeArrays a="+e+",b="+t+" -> "+c),c)}(e,t,r,n)}class W{constructor(){this.data=new Uint32Array(1)}set(e){W._checkIndex(e),this._resize(e),this.data[e>>>5]|=1<<e%32}get(e){W._checkIndex(e);const t=e>>>5;return!(t>=this.data.length||!(this.data[t]&1<<e%32))}clear(e){W._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 s=r&-r;e[t++]=(n<<5)+W._bitCount(s-1),r^=s}}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 l.hashStuff(this.values())}equals(e){return e instanceof W&&i(this.data,e.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.data.map(e=>W._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 Q{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 v;const t=new m,s=!1;this._LOOK(e.transition(n).target,null,U.EMPTY,r[n],t,new W,s,!1),(0===r[n].length||r[n].contains(Q.HIT_PRED))&&(r[n]=null)}return r}LOOK(e,t,r){const n=new v,s=null!==(r=r||null)?q(e.atn,r):null;return this._LOOK(e,t,s,n,new m,new W,!0,!0),n}_LOOK(e,t,r,n,i,a,o,l){const c=new C({state:e,alt:0,context:r},null);if(!i.has(c)){if(i.add(c),e===t){if(null===r)return void n.addOne(s.EPSILON);if(r.isEmpty()&&l)return void n.addOne(s.EOF)}if(e instanceof S){if(null===r)return void n.addOne(s.EPSILON);if(r.isEmpty()&&l)return void n.addOne(s.EOF);if(r!==U.EMPTY){const s=a.get(e.ruleIndex);try{a.clear(e.ruleIndex);for(let e=0;e<r.length;e++){const s=this.atn.states[r.getReturnState(e)];this._LOOK(s,t,r.getParent(e),n,i,a,o,l)}}finally{s&&a.set(e.ruleIndex)}return}}for(let c=0;c<e.transitions.length;c++){const u=e.transitions[c];if(u.constructor===b){if(a.get(u.target.ruleIndex))continue;const e=B.create(r,u.followState.stateNumber);try{a.set(u.target.ruleIndex),this._LOOK(u.target,t,e,n,i,a,o,l)}finally{a.clear(u.target.ruleIndex)}}else if(u instanceof I)o?this._LOOK(u.target,t,r,n,i,a,o,l):n.addOne(Q.HIT_PRED);else if(u.isEpsilon)this._LOOK(u.target,t,r,n,i,a,o,l);else if(u.constructor===N)n.addRange(s.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);else{let e=u.label;null!==e&&(u instanceof M&&(e=e.complement(s.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),n.addSet(e))}}}}}Q.HIT_PRED=s.INVALID_TYPE;class J{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 Q(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(s.EPSILON))return n;const i=new v;for(i.addSet(n),i.removeOne(s.EPSILON);null!==t&&t.invokingState>=0&&n.contains(s.EPSILON);){const e=this.states[t.invokingState].transitions[0];n=this.nextTokens(e.followState),i.addSet(n),i.removeOne(s.EPSILON),t=t.parentCtx}return n.contains(s.EPSILON)&&i.addOne(s.EOF),i}}J.INVALID_ALT_NUMBER=0;class K extends A{constructor(){super(),this.stateType=A.BASIC}}class Z extends A{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class X extends Z{constructor(){return super(),this.endState=null,this}}class Y extends A{constructor(){return super(),this.stateType=A.BLOCK_END,this.startState=null,this}}class ee extends A{constructor(){return super(),this.stateType=A.LOOP_END,this.loopBackState=null,this}}class te extends A{constructor(){return super(),this.stateType=A.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class re extends Z{constructor(){return super(),this.stateType=A.TOKEN_START,this}}class ne extends Z{constructor(){return super(),this.stateType=A.PLUS_LOOP_BACK,this}}class se extends A{constructor(){return super(),this.stateType=A.STAR_LOOP_BACK,this}}class ie extends Z{constructor(){return super(),this.stateType=A.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class ae extends X{constructor(){return super(),this.stateType=A.PLUS_BLOCK_START,this.loopBackState=null,this}}class oe extends X{constructor(){return super(),this.stateType=A.STAR_BLOCK_START,this}}class le extends X{constructor(){return super(),this.stateType=A.BLOCK_START,this}}class ce extends _{constructor(e,t){super(e),this.label_=t,this.label=this.makeLabel(),this.serializationType=_.ATOM}makeLabel(){const e=new v;return e.addOne(this.label_),e}matches(e,t,r){return this.label_===e}toString(){return this.label_}}class ue extends _{constructor(e,t,r){super(e),this.serializationType=_.RANGE,this.start=t,this.stop=r,this.label=this.makeLabel()}makeLabel(){const e=new v;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 he extends _{constructor(e,t,r,n){super(e),this.serializationType=_.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 de extends _{constructor(e,t){super(e),this.serializationType=_.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=t}matches(e,t,r){return!1}toString(){return"epsilon"}}class me extends p{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 me&&this.ruleIndex===e.ruleIndex&&this.predIndex===e.predIndex&&this.isCtxDependent===e.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}p.NONE=new me;class pe extends I{constructor(e,t,r,n){super(e),this.serializationType=_.PREDICATE,this.ruleIndex=t,this.predIndex=r,this.isCtxDependent=n,this.isEpsilon=!0}matches(e,t,r){return!1}getPredicate(){return new me(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class fe extends p{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)?p.NONE:null}compareTo(e){return this.precedence-e.precedence}updateHashCode(e){e.update(this.precedence)}equals(e){return this===e||e instanceof fe&&this.precedence===e.precedence}toString(){return"{"+this.precedence+">=prec}?"}}p.PrecedencePredicate=fe;class ge extends I{constructor(e,t){super(e),this.serializationType=_.PRECEDENCE,this.precedence=t,this.isEpsilon=!0}matches(e,t,r){return!1}getPredicate(){return new fe(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 xe{constructor(e){this.actionType=e,this.isPositionDependent=!1}hashCode(){const e=new l;return this.updateHashCode(e),e.finish()}updateHashCode(e){e.update(this.actionType)}equals(e){return this===e}}class Ce extends xe{constructor(){super(6)}execute(e){e.skip()}toString(){return"skip"}}Ce.INSTANCE=new Ce;class Ee extends xe{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 Ee&&this.channel===e.channel}toString(){return"channel("+this.channel+")"}}class ve extends xe{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 ve&&this.ruleIndex===e.ruleIndex&&this.actionIndex===e.actionIndex}}class Ae extends xe{constructor(){super(3)}execute(e){e.more()}toString(){return"more"}}Ae.INSTANCE=new Ae;class Se extends xe{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 Se&&this.type===e.type}toString(){return"type("+this.type+")"}}class _e extends xe{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 _e&&this.mode===e.mode}toString(){return"pushMode("+this.mode+")"}}class be extends xe{constructor(){super(4)}execute(e){e.popMode()}toString(){return"popMode"}}be.INSTANCE=new be;class Te extends xe{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 Te&&this.mode===e.mode}toString(){return"mode("+this.mode+")"}}function Me(e,t){const r=[];return r[e-1]=t,r.map(function(e){return t})}class Ne{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 J(e,t)}readStates(e,t){let r,n,s;const i=[],a=[],o=this.readInt();for(let r=0;r<o;r++){const r=this.readInt();if(r===A.INVALID_TYPE){e.addState(null);continue}let n=this.readInt();t&&65535===n&&(n=-1);const s=this.stateFactory(r,n);if(r===A.LOOP_END){const e=this.readInt();i.push([s,e])}else if(s instanceof X){const e=this.readInt();a.push([s,e])}e.addState(s)}for(r=0;r<i.length;r++)n=i[r],n[0].loopBackState=e.states[n[1]];for(r=0;r<a.length;r++)n=a[r],n[0].endState=e.states[n[1]];let l=this.readInt();for(r=0;r<l;r++)s=this.readInt(),e.states[s].nonGreedy=!0;let c=this.readInt();for(r=0;r<c;r++)s=this.readInt(),e.states[s].isPrecedenceRule=!0}readRules(e,t){let r;const n=this.readInt();for(0===e.grammarType&&(e.ruleToTokenType=Me(n,0)),e.ruleToStartState=Me(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=s.EOF),e.ruleToTokenType[r]=n}}for(e.ruleToStopState=Me(n,0),r=0;r<e.states.length;r++){const t=e.states[r];t instanceof S&&(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 v;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,s,i,a;const o=this.readInt();for(r=0;r<o;r++){const r=this.readInt(),n=this.readInt(),s=this.readInt(),a=this.readInt(),o=this.readInt(),l=this.readInt();i=this.edgeFactory(e,s,r,n,a,o,l,t),e.states[r].addTransition(i)}for(r=0;r<e.states.length;r++)for(s=e.states[r],n=0;n<s.transitions.length;n++){const t=s.transitions[n];if(!(t instanceof b))continue;let r=-1;e.ruleToStartState[t.target.ruleIndex].isPrecedenceRule&&0===t.precedence&&(r=t.target.ruleIndex),i=new de(t.followState,r),e.ruleToStopState[t.target.ruleIndex].addTransition(i)}for(r=0;r<e.states.length;r++){if(s=e.states[r],s instanceof X){if(null===s.endState)throw"IllegalState";if(null!==s.endState.startState)throw"IllegalState";s.endState.startState=s}if(s instanceof ne)for(n=0;n<s.transitions.length;n++)a=s.transitions[n].target,a instanceof ae&&(a.loopBackState=s);else if(s instanceof se)for(n=0;n<s.transitions.length;n++)a=s.transitions[n].target,a instanceof ie&&(a.loopBackState=s)}}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=Me(r,null);for(let n=0;n<r;n++){const r=this.readInt();let s=this.readInt();t&&65535===s&&(s=-1);let i=this.readInt();t&&65535===i&&(i=-1),e.lexerActions[n]=this.lexerActionFactory(r,s,i)}}}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 s=new le;s.ruleIndex=t,e.addState(s);const i=new Y;i.ruleIndex=t,e.addState(i),s.endState=i,e.defineDecisionState(s),i.startState=s;let a=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,a=n.loopBackState.transitions[0];break}if(null===a)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!==a&&t.target===o&&(t.target=i)}}const l=e.ruleToStartState[t],c=l.transitions.length;for(;c>0;)s.addTransition(l.transitions[c-1]),l.transitions=l.transitions.slice(-1);e.ruleToStartState[t].addTransition(new de(s)),i.addTransition(new de(o));const u=new K;e.addState(u),u.addTransition(new ce(i,e.ruleToTokenType[t])),s.addTransition(new de(u))}stateIsEndStateFor(e,t){if(e.ruleIndex!==t)return null;if(!(e instanceof ie))return null;const r=e.transitions[e.transitions.length-1].target;return r instanceof ee&&r.epsilonOnlyTransitions&&r.transitions[0].target instanceof S?e:null}markPrecedenceDecisions(e){for(let t=0;t<e.states.length;t++){const r=e.states[t];if(r instanceof ie&&e.ruleToStartState[r.ruleIndex].isPrecedenceRule){const e=r.transitions[r.transitions.length-1].target;e instanceof ee&&e.epsilonOnlyTransitions&&e.transitions[0].target instanceof S&&(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 ae)this.checkCondition(null!==r.loopBackState);else if(r instanceof ie)if(this.checkCondition(null!==r.loopBackState),this.checkCondition(2===r.transitions.length),r.transitions[0].target instanceof oe)this.checkCondition(r.transitions[1].target instanceof ee),this.checkCondition(!r.nonGreedy);else{if(!(r.transitions[0].target instanceof ee))throw"IllegalState";this.checkCondition(r.transitions[1].target instanceof oe),this.checkCondition(r.nonGreedy)}else r instanceof se?(this.checkCondition(1===r.transitions.length),this.checkCondition(r.transitions[0].target instanceof ie)):r instanceof ee?this.checkCondition(null!==r.loopBackState):r instanceof te?this.checkCondition(null!==r.stopState):r instanceof X?this.checkCondition(null!==r.endState):r instanceof Y?this.checkCondition(null!==r.startState):r instanceof Z?this.checkCondition(r.transitions.length<=1||r.decision>=0):this.checkCondition(r.transitions.length<=1||r instanceof S)}}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,o,l){const c=e.states[n];switch(t){case _.EPSILON:return new de(c);case _.RANGE:return new ue(c,0!==o?s.EOF:i,a);case _.RULE:return new b(e.states[i],a,o,c);case _.PREDICATE:return new pe(c,i,a,0!==o);case _.PRECEDENCE:return new ge(c,i);case _.ATOM:return new ce(c,0!==o?s.EOF:i);case _.ACTION:return new he(c,i,a,0!==o);case _.SET:return new T(c,l[i]);case _.NOT_SET:return new M(c,l[i]);case _.WILDCARD:return new N(c);default:throw"The specified transition type: "+t+" is not valid."}}stateFactory(e,t){if(null===this.stateFactories){const e=[];e[A.INVALID_TYPE]=null,e[A.BASIC]=()=>new K,e[A.RULE_START]=()=>new te,e[A.BLOCK_START]=()=>new le,e[A.PLUS_BLOCK_START]=()=>new ae,e[A.STAR_BLOCK_START]=()=>new oe,e[A.TOKEN_START]=()=>new re,e[A.RULE_STOP]=()=>new S,e[A.BLOCK_END]=()=>new Y,e[A.STAR_LOOP_BACK]=()=>new se,e[A.STAR_LOOP_ENTRY]=()=>new ie,e[A.PLUS_LOOP_BACK]=()=>new ne,e[A.LOOP_END]=()=>new ee,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 Ee(e),e[1]=(e,t)=>new ve(e,t),e[2]=(e,t)=>new Te(e),e[3]=(e,t)=>Ae.INSTANCE,e[4]=(e,t)=>be.INSTANCE,e[5]=(e,t)=>new _e(e),e[6]=(e,t)=>Ce.INSTANCE,e[7]=(e,t)=>new Se(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 Ie{syntaxError(e,t,r,n,s,i){}reportAmbiguity(e,t,r,n,s,i,a){}reportAttemptingFullContext(e,t,r,n,s,i){}reportContextSensitivity(e,t,r,n,s,i){}}class Le extends Ie{constructor(){super()}syntaxError(e,t,r,n,s,i){console.error("line "+r+":"+n+" "+s)}}Le.INSTANCE=new Le;class we extends Ie{constructor(e){if(super(),null===e)throw"delegates";return this.delegates=e,this}syntaxError(e,t,r,n,s,i){this.delegates.map(a=>a.syntaxError(e,t,r,n,s,i))}reportAmbiguity(e,t,r,n,s,i,a){this.delegates.map(o=>o.reportAmbiguity(e,t,r,n,s,i,a))}reportAttemptingFullContext(e,t,r,n,s,i){this.delegates.map(a=>a.reportAttemptingFullContext(e,t,r,n,s,i))}reportContextSensitivity(e,t,r,n,s,i){this.delegates.map(a=>a.reportContextSensitivity(e,t,r,n,s,i))}}class Oe{constructor(){this._listeners=[Le.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=s.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:s.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===s.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 we(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}}Oe.tokenTypeMapCache={},Oe.ruleIndexMapCache={};class Re extends s{constructor(e,t,r,n,i){super(),this.source=void 0!==e?e:Re.EMPTY_SOURCE,this.type=void 0!==t?t:null,this.channel=void 0!==r?r:s.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 Re(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 Re(this.source,e,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,e===s.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}}Re.EMPTY_SOURCE=[null,null];class De{}class Fe extends De{constructor(e){super(),this.copyText=void 0!==e&&e}create(e,t,r,n,s,i,a,o){const l=new Re(e,t,n,s,i);return l.line=a,l.column=o,null!==r?l.text=r:this.copyText&&null!==e[1]&&(l.text=e[1].getText(s,i)),l}createThin(e,t){const r=new Re(null,e);return r.text=t,r}}Fe.DEFAULT=new Fe;class Pe extends Error{constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,Pe),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 Pe{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 E(this.startIndex,this.startIndex))),"LexerNoViableAltException"+e}}class Ve extends Oe{constructor(e){super(),this._input=e,this._factory=Fe.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=s.DEFAULT_CHANNEL,this._type=s.INVALID_TYPE,this._modeStack=[],this._mode=Ve.DEFAULT_MODE,this._text=null}reset(){null!==this._input&&this._input.seek(0),this._token=null,this._type=s.INVALID_TYPE,this._channel=s.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=Ve.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=s.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=s.INVALID_TYPE;let r=Ve.SKIP;try{r=this._interp.match(this._input,this._mode)}catch(e){if(!(e instanceof Pe))throw console.log(e.stack),e;this.notifyListeners(e),this.recover(e)}if(this._input.LA(1)===s.EOF&&(this._hitEOF=!0),this._type===s.INVALID_TYPE&&(this._type=r),this._type===Ve.SKIP){t=!0;break}if(this._type!==Ve.MORE)break}if(!t)return null===this._token&&this.emit(),this._token}}finally{this._input.release(e)}}skip(){this._type=Ve.SKIP}more(){this._type=Ve.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,s.EOF,null,s.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!==s.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),s="token recognition error at: '"+this.getErrorDisplay(n)+"'";this.getErrorListener().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,s,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)===s.EOF?"<EOF>":"\n"===e?"\\n":"\t"===e?"\\t":"\r"===e?"\\r":e}getCharErrorDisplay(e){return"'"+this.getErrorDisplayForChar(e)+"'"}recover(e){this._input.LA(1)!==s.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 Ue(e){return e.hashCodeForConfigSet()}function $e(e,t){return e===t||null!==e&&null!==t&&e.equalsForConfigSet(t)}Ve.DEFAULT_MODE=0,Ve.MORE=-2,Ve.SKIP=-3,Ve.DEFAULT_TOKEN_CHANNEL=s.DEFAULT_CHANNEL,Ve.HIDDEN=s.HIDDEN_CHANNEL,Ve.MIN_CHAR_VALUE=0,Ve.MAX_CHAR_VALUE=1114111;class Be{constructor(e){this.configLookup=new m(Ue,$e),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!==p.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,s=G(r.context,e.context,n,t);return r.reachesIntoOuterContext=Math.max(r.reachesIntoOuterContext,e.reachesIntoOuterContext),e.precedenceFilterSuppressed&&(r.precedenceFilterSuppressed=!0),r.context=s,!0}getStates(){const e=new m;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!==p.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 Be&&i(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 l;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 m}setReadonly(e){this.readOnly=e,e&&(this.configLookup=null)}toString(){return d(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==J.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 Be),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 m;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 l;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 z(e,this.sharedContextCache,t)}}je.ERROR=new He(2147483647,new Be);class qe extends Be{constructor(){super(),this.configLookup=new m}}class ze extends C{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=ze.prototype.hashCode,this.equalsForConfigSet=ze.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 ze&&this.passedThroughNonGreedyDecision===e.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(e.lexerActionExecutor):!e.lexerActionExecutor)&&super.equals(e)}checkNonGreedyDecision(e,t){return e.passedThroughNonGreedyDecision||t instanceof Z&&t.nonGreedy}}class Ge extends xe{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 Ge&&this.offset===e.offset&&this.action===e.action}}class We{constructor(e){return this.lexerActions=null===e?[]:e,this.cachedHashCode=l.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 Ge||(null===t&&(t=this.lexerActions.concat([])),t[r]=new Ge(e,this.lexerActions[r]));return null===t?this:new We(t)}execute(e,t,r){let n=!1;const s=t.index;try{for(let i=0;i<this.lexerActions.length;i++){let a=this.lexerActions[i];if(a instanceof Ge){const e=a.offset;t.seek(r+e),a=a.action,n=r+e!==s}else a.isPositionDependent&&(t.seek(s),n=!1);a.execute(e)}}finally{n&&t.seek(s)}}hashCode(){return this.cachedHashCode}updateHashCode(e){e.update(this.cachedHashCode)}equals(e){if(this===e)return!0;if(e instanceof We){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 We([t]);const r=e.lexerActions.concat([t]);return new We(r)}}function Qe(e){e.index=-1,e.line=0,e.column=-1,e.dfaState=null}class Je{constructor(){Qe(this)}reset(){Qe(this)}}class Ke 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=Ve.DEFAULT_MODE,this.prevAccept=new Je}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=Ve.DEFAULT_MODE}matchATN(e){const t=this.atn.modeToStartState[this.mode];Ke.debug&&console.log("matchATN mode "+this.mode+" start: "+t);const r=this.mode,n=this.computeStartState(e,t),s=n.hasSemanticContext;n.hasSemanticContext=!1;const i=this.addDFAState(n);s||(this.decisionToDFA[this.mode].s0=i);const a=this.execATN(e,i);return Ke.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[r].toLexerString()),a}execATN(e,t){Ke.debug&&console.log("start state closure="+t.configs),t.isAcceptState&&this.captureSimState(this.prevAccept,e,t);let r=e.LA(1),n=t;for(;;){Ke.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!==s.EOF&&this.consume(e),t.isAcceptState&&(this.captureSimState(this.prevAccept,e,t),r===s.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<Ke.MIN_DFA_EDGE||t>Ke.MAX_DFA_EDGE)return null;let r=e.edges[t-Ke.MIN_DFA_EDGE];return void 0===r&&(r=null),Ke.debug&&null!==r&&console.log("reuse state "+e.stateNumber+" edge to "+r.stateNumber),r}computeTargetState(e,t,r){const n=new qe;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===s.EOF&&t.index===this.startIndex)return s.EOF;throw new ke(this.recog,t,this.startIndex,r)}getReachableConfigSet(e,t,r,n){let i=J.INVALID_ALT_NUMBER;for(let a=0;a<t.items.length;a++){const o=t.items[a],l=o.alt===i;if(!l||!o.passedThroughNonGreedyDecision){Ke.debug&&console.log("testing %s at %s\n",this.getTokenName(n),o.toString(this.recog,!0));for(let t=0;t<o.state.transitions.length;t++){const a=o.state.transitions[t],c=this.getReachableTarget(a,n);if(null!==c){let t=o.lexerActionExecutor;null!==t&&(t=t.fixOffsetBeforeMatch(e.index-this.startIndex));const a=n===s.EOF,u=new ze({state:c,lexerActionExecutor:t},o);this.closure(e,u,r,l,!0,a)&&(i=o.alt)}}}}}accept(e,t,r,n,s,i){Ke.debug&&console.log("ACTION %s\n",t),e.seek(n),this.line=s,this.column=i,null!==t&&null!==this.recog&&t.execute(this.recog,e,r)}getReachableTarget(e,t){return e.matches(t,0,Ve.MAX_CHAR_VALUE)?e.target:null}computeStartState(e,t){const r=U.EMPTY,n=new qe;for(let s=0;s<t.transitions.length;s++){const i=t.transitions[s].target,a=new ze({state:i,alt:s+1,context:r},null);this.closure(e,a,n,!1,!1,!1)}return n}closure(e,t,r,n,s,i){let a=null;if(Ke.debug&&console.log("closure("+t.toString(this.recog,!0)+")"),t.state instanceof S){if(Ke.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 ze({state:t.state,context:U.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)!==U.EMPTY_RETURN_STATE){const l=t.context.getParent(o),c=this.atn.states[t.context.getReturnState(o)];a=new ze({state:c,context:l},t),n=this.closure(e,a,r,n,s,i)}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];a=this.getEpsilonTarget(e,t,l,r,s,i),null!==a&&(n=this.closure(e,a,r,n,s,i))}return n}getEpsilonTarget(e,t,r,n,i,a){let o=null;if(r.serializationType===_.RULE){const e=B.create(t.context,r.followState.stateNumber);o=new ze({state:r.target,context:e},t)}else{if(r.serializationType===_.PRECEDENCE)throw"Precedence predicates are not supported in lexers.";if(r.serializationType===_.PREDICATE)Ke.debug&&console.log("EVAL rule "+r.ruleIndex+":"+r.predIndex),n.hasSemanticContext=!0,this.evaluatePredicate(e,r.ruleIndex,r.predIndex,i)&&(o=new ze({state:r.target},t));else if(r.serializationType===_.ACTION)if(null===t.context||t.context.hasEmptyPath()){const e=We.append(t.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);o=new ze({state:r.target,lexerActionExecutor:e},t)}else o=new ze({state:r.target},t);else r.serializationType===_.EPSILON?o=new ze({state:r.target},t):r.serializationType!==_.ATOM&&r.serializationType!==_.RANGE&&r.serializationType!==_.SET||a&&r.matches(s.EOF,0,Ve.MAX_CHAR_VALUE)&&(o=new ze({state:r.target},t))}return o}evaluatePredicate(e,t,r,n){if(null===this.recog)return!0;if(!n)return this.recog.sempred(null,t,r);const s=this.column,i=this.line,a=e.index,o=e.mark();try{return this.consume(e),this.recog.sempred(null,t,r)}finally{this.column=s,this.line=i,e.seek(a),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<Ke.MIN_DFA_EDGE||t>Ke.MAX_DFA_EDGE||(Ke.debug&&console.log("EDGE "+e+" -> "+r+" upon "+t),null===e.edges&&(e.edges=[]),e.edges[t-Ke.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 S){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],s=n.states.get(t);if(null!==s)return s;const i=t;return i.stateNumber=n.states.length,e.setReadonly(!0),i.configs=e,n.states.add(i),i}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)+"'"}}Ke.debug=!1,Ke.dfa_debug=!1,Ke.MIN_DFA_EDGE=0,Ke.MAX_DFA_EDGE=127;class Ze{constructor(e,t){this.alt=t,this.pred=e}toString(){return"("+this.pred+", "+this.alt+")"}}class Xe{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 Ye={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(e,t){if(Ye.allConfigsInRuleStopStates(t))return!0;if(e===Ye.SLL&&t.hasSemanticContext){const e=new Be;for(let r=0;r<t.items.length;r++){let n=t.items[r];n=new C({semanticContext:p.NONE},n),e.add(n)}t=e}const r=Ye.getConflictingAltSubsets(t);return Ye.hasConflictingAltSet(r)&&!Ye.hasStateAssociatedWithOneAlt(t)},hasConfigInRuleStopState:function(e){for(let t=0;t<e.items.length;t++)if(e.items[t].state instanceof S)return!0;return!1},allConfigsInRuleStopStates:function(e){for(let t=0;t<e.items.length;t++)if(!(e.items[t].state instanceof S))return!1;return!0},resolvesToJustOneViableAlt:function(e){return Ye.getSingleViableAlt(e)},allSubsetsConflict:function(e){return!Ye.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=Ye.getAlts(e);return 1===t.length?t.minValue():J.INVALID_ALT_NUMBER},getAlts:function(e){const t=new W;return e.map(function(e){t.or(e)}),t},getConflictingAltSubsets:function(e){const t=new j;return t.hashFunction=function(e){l.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 W,t.set(e,r)),r.set(e.alt)}),t.getValues()},getStateToAltMap:function(e){const t=new Xe;return e.items.map(function(e){let r=t.get(e.state);null===r&&(r=new W,t.set(e.state,r)),r.set(e.alt)}),t},hasStateAssociatedWithOneAlt:function(e){const t=Ye.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 J.INVALID_ALT_NUMBER}return t}},et=Ye;class tt extends Pe{constructor(e,t,r,n,s,i){i=i||e._ctx,n=n||e.getCurrentToken(),r=r||e.getCurrentToken(),t=t||e.getInputStream(),super({message:"",recognizer:e,input:t,ctx:i}),this.deadEndConfigs=s,this.startToken=r,this.offendingToken=n}}class rt{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 nt extends je{constructor(e,t,r,n){super(t,n),this.parser=e,this.decisionToDFA=r,this.predictionMode=et.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 s=e.mark(),i=e.index;try{let t;if(t=n.precedenceDfa?n.getPrecedenceStartState(this.parser.getPrecedence()):n.s0,null===t){null===r&&(r=V.EMPTY),this.debug&&console.log("predictATN decision "+n.decision+" exec LA(1)=="+this.getLookaheadName(e)+", outerContext="+r.toString(this.parser.ruleNames));const s=!1;let i=this.computeStartState(n.atnStartState,V.EMPTY,s);n.precedenceDfa?(n.s0.configs=i,i=this.applyPrecedenceFilter(i),t=this.addDFAState(n,new He(null,i)),n.setPrecedenceStartState(this.parser.getPrecedence(),t)):(t=this.addDFAState(n,new He(null,i)),n.s0=t)}const s=this.execATN(n,t,e,i,r);return this.debug&&console.log("DFA after predictATN: "+n.toString(this.parser.literalNames,this.parser.symbolicNames)),s}finally{this._dfa=null,this.mergeCache=null,e.seek(i),e.release(s)}}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 o=t;this.debug&&console.log("s0 = "+t);let l=r.LA(1);for(;;){let t=this.getExistingTargetState(o,l);if(null===t&&(t=this.computeTargetState(e,o,l)),t===je.ERROR){const e=this.noViableAlt(r,i,o.configs,n);if(r.seek(n),a=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(o.configs,i),a!==J.INVALID_ALT_NUMBER)return a;throw e}if(t.requiresFullContext&&this.predictionMode!==et.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 s=r.index;r.seek(n);const a=this.evalSemanticContext(t.predicates,i,!0);if(0===a.length)throw this.noViableAlt(r,i,t.configs,n);return 1===a.length||this.reportAmbiguity(e,t,n,s,!1,a,t.configs),a.minValue()}o=t,l!==s.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 s=new He(null,n);const i=this.getUniqueAlt(n);if(this.debug){const e=et.getConflictingAltSubsets(n);console.log("SLL altSubSets="+d(e)+", configs="+n+", predict="+i+", allSubsetsConflict="+et.allSubsetsConflict(e)+", conflictingAlts="+this.getConflictingAlts(n))}return i!==J.INVALID_ALT_NUMBER?(s.isAcceptState=!0,s.configs.uniqueAlt=i,s.prediction=i):et.hasSLLConflictTerminatingPrediction(this.predictionMode,n)&&(s.configs.conflictingAlts=this.getConflictingAlts(n),s.requiresFullContext=!0,s.isAcceptState=!0,s.prediction=s.configs.conflictingAlts.minValue()),s.isAcceptState&&s.configs.hasSemanticContext&&(this.predicateDFAState(s,this.atn.getDecisionState(e.decision)),null!==s.predicates&&(s.prediction=J.INVALID_ALT_NUMBER)),s=this.addDFAEdge(e,t,r,s),s}predicateDFAState(e,t){const r=t.transitions.length,n=this.getConflictingAltsOrUniqueAlt(e.configs),s=this.getPredsForAmbigAlts(n,e.configs,r);null!==s?(e.predicates=this.getPredicatePredictions(n,s),e.prediction=J.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 o,l=!1,c=r;n.seek(i);let u=n.LA(1),h=-1;for(;;){if(o=this.computeReachSet(c,u,!0),null===o){const e=this.noViableAlt(n,a,c,i);n.seek(i);const t=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(c,a);if(t!==J.INVALID_ALT_NUMBER)return t;throw e}const e=et.getConflictingAltSubsets(o);if(this.debug&&console.log("LL altSubSets="+e+", predict="+et.getUniqueAlt(e)+", resolvesToJustOneViableAlt="+et.resolvesToJustOneViableAlt(e)),o.uniqueAlt=this.getUniqueAlt(o),o.uniqueAlt!==J.INVALID_ALT_NUMBER){h=o.uniqueAlt;break}if(this.predictionMode!==et.LL_EXACT_AMBIG_DETECTION){if(h=et.resolvesToJustOneViableAlt(e),h!==J.INVALID_ALT_NUMBER)break}else if(et.allSubsetsConflict(e)&&et.allSubsetsEqual(e)){l=!0,h=et.getSingleViableAlt(e);break}c=o,u!==s.EOF&&(n.consume(),u=n.LA(1))}return o.uniqueAlt!==J.INVALID_ALT_NUMBER?(this.reportContextSensitivity(e,h,o,i,n.index),h):(this.reportAmbiguity(e,t,i,n.index,l,null,o),h)}computeReachSet(e,t,r){this.debug&&console.log("in computeReachSet, starting closure: "+e),null===this.mergeCache&&(this.mergeCache=new rt);const n=new Be(r);let i=null;for(let a=0;a<e.items.length;a++){const o=e.items[a];if(this.debug&&console.log("testing "+this.getTokenName(t)+" at "+o),o.state instanceof S)(r||t===s.EOF)&&(null===i&&(i=[]),i.push(o),this.debug_add&&console.log("added "+o+" to skippedStopStates"));else for(let e=0;e<o.state.transitions.length;e++){const r=o.state.transitions[e],s=this.getReachableTarget(r,t);if(null!==s){const e=new C({state:s},o);n.add(e,this.mergeCache),this.debug_add&&console.log("added "+e+" to intermediate")}}}let a=null;if(null===i&&t!==s.EOF&&(1===n.items.length||this.getUniqueAlt(n)!==J.INVALID_ALT_NUMBER)&&(a=n),null===a){a=new Be(r);const e=new m,i=t===s.EOF;for(let t=0;t<n.items.length;t++)this.closure(n.items[t],a,e,!1,r,i)}if(t===s.EOF&&(a=this.removeAllConfigsNotInRuleStopState(a,a===n)),!(null===i||r&&et.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(et.allConfigsInRuleStopStates(e))return e;const r=new Be(e.fullCtx);for(let n=0;n<e.items.length;n++){const i=e.items[n];if(i.state instanceof S)r.add(i,this.mergeCache);else if(t&&i.state.epsilonOnlyTransitions&&this.atn.nextTokens(i.state).contains(s.EPSILON)){const e=this.atn.ruleToStopState[i.state.ruleIndex];r.add(new C({state:e},i),this.mergeCache)}}return r}computeStartState(e,t,r){const n=q(this.atn,t),s=new Be(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 i=e.transitions[t].target,a=new C({state:i,alt:t+1,context:n},null),o=new m;this.closure(a,s,o,!0,r,!1)}return s}applyPrecedenceFilter(e){let t;const r=[],n=new Be(e.fullCtx);for(let s=0;s<e.items.length;s++){if(t=e.items[s],1!==t.alt)continue;const i=t.semanticContext.evalPrecedence(this.parser,this._outerContext);null!==i&&(r[t.state.stateNumber]=t.context,i!==t.semanticContext?n.add(new C({semanticContext:i},t),this.mergeCache):n.add(t,this.mergeCache))}for(let s=0;s<e.items.length;s++)if(t=e.items[s],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 s=t.items[r];e.get(s.alt)&&(n[s.alt]=p.orContext(n[s.alt]||null,s.semanticContext))}let s=0;for(let e=1;e<r+1;e++){const t=n[e]||null;null===t?n[e]=p.NONE:t!==p.NONE&&(s+=1)}return 0===s&&(n=null),this.debug&&console.log("getPredsForAmbigAlts result "+d(n)),n}getPredicatePredictions(e,t){const r=[];let n=!1;for(let s=1;s<t.length;s++){const i=t[s];null!==e&&e.get(s)&&r.push(new Ze(i,s)),i!==p.NONE&&(n=!0)}return n?r:null}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(e,t){const r=this.splitAccordingToSemanticValidity(e,t),n=r[0],s=r[1];let i=this.getAltThatFinishedDecisionEntryRule(n);return i!==J.INVALID_ALT_NUMBER||s.items.length>0&&(i=this.getAltThatFinishedDecisionEntryRule(s),i!==J.INVALID_ALT_NUMBER)?i:J.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 S&&n.context.hasEmptyPath())&&t.indexOf(n.alt)<0&&t.push(n.alt)}return 0===t.length?J.INVALID_ALT_NUMBER:Math.min.apply(null,t)}splitAccordingToSemanticValidity(e,t){const r=new Be(e.fullCtx),n=new Be(e.fullCtx);for(let s=0;s<e.items.length;s++){const i=e.items[s];i.semanticContext!==p.NONE?i.semanticContext.evaluate(this.parser,t)?r.add(i):n.add(i):r.add(i)}return[r,n]}evalSemanticContext(e,t,r){const n=new W;for(let s=0;s<e.length;s++){const i=e[s];if(i.pred===p.NONE){if(n.set(i.alt),!r)break;continue}const a=i.pred.evaluate(this.parser,t);if((this.debug||this.dfa_debug)&&console.log("eval pred "+i+"="+a),a&&((this.debug||this.dfa_debug)&&console.log("PREDICT "+i.alt),n.set(i.alt),!r))break}return n}closure(e,t,r,n,s,i){this.closureCheckingStopState(e,t,r,n,s,0,i)}closureCheckingStopState(e,t,r,n,s,i,a){if((this.trace_atn_sim||this.debug_closure)&&console.log("closure("+e.toString(this.parser,!0)+")"),e.state instanceof S){if(!e.context.isEmpty()){for(let o=0;o<e.context.length;o++){if(e.context.getReturnState(o)===U.EMPTY_RETURN_STATE){if(s){t.add(new C({state:e.state,context:U.EMPTY},e),this.mergeCache);continue}this.debug&&console.log("FALLING off rule "+this.getRuleName(e.state.ruleIndex)),this.closure_(e,t,r,n,s,i,a);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},h=new C(u,null);h.reachesIntoOuterContext=e.reachesIntoOuterContext,this.closureCheckingStopState(h,t,r,n,s,i-1,a)}return}if(s)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,s,i,a)}closure_(e,t,r,n,s,i,a){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 he),h=this.getEpsilonTarget(e,c,u,0===i,s,a);if(null!==h){let n=i;if(e.state instanceof S){if(null!==this._dfa&&this._dfa.precedenceDfa&&c.outermostPrecedenceReturn===this._dfa.atnStartState.ruleIndex&&(h.precedenceFilterSuppressed=!0),h.reachesIntoOuterContext+=1,r.getOrAdd(h)!==h)continue;t.dipsIntoOuterContext=!0,n-=1,this.debug&&console.log("dips into outer ctx: "+h)}else{if(!c.isEpsilon&&r.getOrAdd(h)!==h)continue;c instanceof b&&n>=0&&(n+=1)}this.closureCheckingStopState(h,t,r,u,s,n,a)}}}canDropLoopEntryEdgeInLeftRecursiveRule(e){const t=e.state;if(t.stateType!==A.STAR_LOOP_ENTRY)return!1;if(t.stateType!==A.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,s=this.atn.states[n];for(let n=0;n<r;n++){const r=e.context.getReturnState(n),i=this.atn.states[r];if(1!==i.transitions.length||!i.transitions[0].isEpsilon)return!1;const a=i.transitions[0].target;if(!(i.stateType===A.BLOCK_END&&a===t||i===s||a===s||a.stateType===A.BLOCK_END&&1===a.transitions.length&&a.transitions[0].isEpsilon&&a.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 _.RULE:return this.ruleTransition(e,t);case _.PRECEDENCE:return this.precedenceTransition(e,t,r,n,i);case _.PREDICATE:return this.predTransition(e,t,r,n,i);case _.ACTION:return this.actionTransition(e,t);case _.EPSILON:return new C({state:t.target},e);case _.ATOM:case _.RANGE:case _.SET:return a&&t.matches(s.EOF,0,1)?new C({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 C({state:t.target},e)}precedenceTransition(e,t,r,n,s){this.debug&&(console.log("PRED (collectPredicates="+r+") "+t.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+d(this.parser.getRuleInvocationStack())));let i=null;if(r&&n)if(s){const r=this._input.index;this._input.seek(this._startIndex);const n=t.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),n&&(i=new C({state:t.target},e))}else{const r=p.andContext(e.semanticContext,t.getPredicate());i=new C({state:t.target,semanticContext:r},e)}else i=new C({state:t.target},e);return this.debug&&console.log("config from pred transition="+i),i}predTransition(e,t,r,n,s){this.debug&&(console.log("PRED (collectPredicates="+r+") "+t.ruleIndex+":"+t.predIndex+", ctx dependent="+t.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+d(this.parser.getRuleInvocationStack())));let i=null;if(r&&(t.isCtxDependent&&n||!t.isCtxDependent))if(s){const r=this._input.index;this._input.seek(this._startIndex);const n=t.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),n&&(i=new C({state:t.target},e))}else{const r=p.andContext(e.semanticContext,t.getPredicate());i=new C({state:t.target,semanticContext:r},e)}else i=new C({state:t.target},e);return this.debug&&console.log("config from pred transition="+i),i}ruleTransition(e,t){this.debug&&console.log("CALL rule "+this.getRuleName(t.target.ruleIndex)+", ctx="+e.context);const r=t.followState,n=B.create(e.context,r.stateNumber);return new C({state:t.target,context:n},e)}getConflictingAlts(e){const t=et.getConflictingAltSubsets(e);return et.getAlts(t)}getConflictingAltsOrUniqueAlt(e){let t=null;return e.uniqueAlt!==J.INVALID_ALT_NUMBER?(t=new W,t.set(e.uniqueAlt)):t=e.conflictingAlts,t}getTokenName(e){if(e===s.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 ce?n="Atom "+this.getTokenName(e.label):e instanceof T&&(n=(e instanceof M?"~":"")+"Set "+e.set)}console.error(r.toString(this.parser,!0)+":"+n)}}noViableAlt(e,t,r,n){return new tt(this.parser,e,e.get(n),e.LT(1),r,t)}getUniqueAlt(e){let t=J.INVALID_ALT_NUMBER;for(let r=0;r<e.items.length;r++){const n=e.items[r];if(t===J.INVALID_ALT_NUMBER)t=n.alt;else if(n.alt!==t)return J.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,s){if(this.debug||this.retry_debug){const t=new E(n,s+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,s,t,r)}reportContextSensitivity(e,t,r,n,s){if(this.debug||this.retry_debug){const t=new E(n,s+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,s,t,r)}reportAmbiguity(e,t,r,n,s,i,a){if(this.debug||this.retry_debug){const e=new E(r,n+1);console.log("reportAmbiguity "+i+":"+a+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportAmbiguity(this.parser,e,r,n,s,i,a)}}class st{constructor(){this.cache=new j}add(e){if(e===U.EMPTY)return U.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 it={ATN:J,ATNDeserializer:Ne,LexerATNSimulator:Ke,ParserATNSimulator:nt,PredictionMode:et,PredictionContextCache:st};class at{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+"=>"+d(e.predicates):t+"=>"+e.prediction.toString():t}}class ot extends at{constructor(e){super(e,null)}getEdgeLabel(e){return"'"+String.fromCharCode(e)+"'"}}class lt{constructor(e,t){if(void 0===t&&(t=0),this.atnStartState=e,this.decision=t,this._states=new m,this.s0=null,this.precedenceDfa=!1,e instanceof ie&&e.isPrecedenceDecision){this.precedenceDfa=!0;const e=new He(null,new Be);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 m,e){const e=new He(null,new Be);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 at(this,e,t).toString()}toLexerString(){return null===this.s0?"":new ot(this).toString()}get states(){return this._states}}const ct={DFA:lt,DFASerializer:at,LexerDFASerializer:ot,PredPrediction:Ze},ut={PredictionContext:U},ht={Interval:E,IntervalSet:v};class dt{visitTerminal(e){}visitErrorNode(e){}enterEveryRule(e){}exitEveryRule(e){}}class mt{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 pt{walk(e,t){if(t instanceof F||void 0!==t.isErrorNode&&t.isErrorNode())e.visitErrorNode(t);else if(t instanceof D)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)}}pt.DEFAULT=new pt;const ft={Trees:k,RuleNode:R,ErrorNode:F,TerminalNode:D,ParseTreeListener:dt,ParseTreeVisitor:mt,ParseTreeWalker:pt};class gt extends Pe{constructor(e){super({message:"",recognizer:e,input:e.getInputStream(),ctx:e._ctx}),this.offendingToken=e.getCurrentToken()}}class yt extends Pe{constructor(e,t,r){super({message:xt(t,r||null),recognizer:e,input:e.getInputStream(),ctx:e._ctx});const n=e._interp.atn.states[e.state].transitions[0];n instanceof pe?(this.ruleIndex=n.ruleIndex,this.predicateIndex=n.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=t,this.offendingToken=e.getCurrentToken()}}function xt(e,t){return null!==t?t:"failed predicate: {"+e+"}?"}class Ct extends Ie{constructor(e){super(),e=e||!0,this.exactOnly=e}reportAmbiguity(e,t,r,n,s,i,a){if(this.exactOnly&&!s)return;const o="reportAmbiguity d="+this.getDecisionDescription(e,t)+": ambigAlts="+this.getConflictingAlts(i,a)+", input='"+e.getTokenStream().getText(new E(r,n))+"'";e.notifyErrorListeners(o)}reportAttemptingFullContext(e,t,r,n,s,i){const a="reportAttemptingFullContext d="+this.getDecisionDescription(e,t)+", input='"+e.getTokenStream().getText(new E(r,n))+"'";e.notifyErrorListeners(a)}reportContextSensitivity(e,t,r,n,s,i){const a="reportContextSensitivity d="+this.getDecisionDescription(e,t)+", input='"+e.getTokenStream().getText(new E(r,n))+"'";e.notifyErrorListeners(a)}getDecisionDescription(e,t){const r=t.decision,n=t.atnStartState.ruleIndex,s=e.ruleNames;if(n<0||n>=s.length)return""+r;const i=s[n]||null;return null===i||0===i.length?""+r:`${r} (${i})`}getConflictingAlts(e,t){if(null!==e)return e;const r=new W;for(let e=0;e<t.items.length;e++)r.set(t.items[e].alt);return`{${r.values().join(", ")}}`}}class Et extends Error{constructor(){super(),Error.captureStackTrace(this,Et)}}class vt{reset(e){}recoverInline(e){}recover(e,t){}sync(e){}inErrorRecoveryMode(e){}reportError(e){}}class At extends vt{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 tt?this.reportNoViableAlternative(e,t):t instanceof gt?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=A.INVALID_STATE_NUMBER);if(n.contains(s.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=e._ctx,this.nextTokensState=e._stateNumber);else switch(t.stateType){case A.BLOCK_START:case A.STAR_BLOCK_START:case A.PLUS_BLOCK_START:case A.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(e))return;throw new gt(e);case A.PLUS_LOOP_BACK:case A.STAR_LOOP_BACK:{this.reportUnwantedToken(e);const t=new v;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===s.EOF?"<EOF>":r.getText(new E(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 gt(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===s.EOF?"<missing EOF>":"<missing "+e.literalNames[r]+">";let i=t;const a=e.getTokenStream().LT(-1);return i.type===s.EOF&&null!==a&&(i=a),e.getTokenFactory().create(i.source,r,n,s.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===s.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 v;for(;null!==r&&r.invokingState>=0;){const e=t.states[r.invokingState].transitions[0],s=t.nextTokens(e.followState);n.addSet(s),r=r.parentCtx}return n.removeOne(s.EPSILON),n}consumeUntil(e,t){let r=e.getTokenStream().LA(1);for(;r!==s.EOF&&!t.contains(r);)e.consume(),r=e.getTokenStream().LA(1)}}class St extends At{constructor(){super()}recover(e,t){let r=e._ctx;for(;null!==r;)r.exception=t,r=r.parentCtx;throw new Et(t)}recoverInline(e){this.recover(e,new gt(e))}sync(e){}}const _t={RecognitionException:Pe,NoViableAltException:tt,LexerNoViableAltException:ke,InputMismatchException:gt,FailedPredicateException:yt,DiagnosticErrorListener:Ct,BailErrorStrategy:St,DefaultErrorStrategy:At,ErrorListener:Ie};class bt{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?s.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 Tt extends bt{constructor(e,t){super(e,t)}}const Mt=r(9896),Nt="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;class It extends Tt{static fromPath(e,t,r){if(!Nt)throw new Error("FileStream is only available when running in Node!");Mt.readFile(e,t,function(e,t){let n=null;null!==t&&(n=new bt(t,!0)),r(e,n)})}constructor(e,t,r){if(!Nt)throw new Error("FileStream is only available when running in Node!");super(Mt.readFileSync(e,t||"utf-8"),r),this.fileName=e}}const Lt={fromString:function(e){return new bt(e,!0)},fromBlob:function(e,t,r,n){const s=new window.FileReader;s.onload=function(e){const t=new bt(e.target.result,!0);r(t)},s.onerror=n,s.readAsText(e,t)},fromBuffer:function(e,t){return new bt(e.toString(t),!0)},fromPath:function(e,t,r){It.fromPath(e,t,r)},fromPathSync:function(e,t){return new It(e,t)}},wt={arrayToString:d,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 Ot{}class Rt extends Ot{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)===s.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===s.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===s.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===s.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,Ve.DEFAULT_TOKEN_CHANNEL),n=e+1,s=-1===r?this.tokens.length-1:r;return this.filterForChannel(n,s,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,Ve.DEFAULT_TOKEN_CHANNEL);if(r===e-1)return null;const n=r+1,s=e-1;return this.filterForChannel(n,s,t)}filterForChannel(e,t,r){const n=[];for(let s=e;s<t+1;s++){const e=this.tokens[s];-1===r?e.channel!==Ve.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 E(0,this.tokens.length-1));let t=e.start;t instanceof s&&(t=t.tokenIndex);let r=e.stop;if(r instanceof s&&(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===s.EOF)break;n+=t.text}return n}fill(){for(this.lazyInit();1e3===this.fetch(1e3););}}Object.defineProperty(Rt,"size",{get:function(){return this.tokens.length}});class Dt extends Rt{constructor(e,t){super(e),this.channel=void 0===t?s.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===s.EOF)break}return e}}class Ft extends dt{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 Pt extends Oe{constructor(e){super(),this._input=null,this._errHandler=new At,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 Ne(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,s=t.column;this.getErrorListener().syntaxError(this,t,n,s,e,r)}consume(){const e=this.getCurrentToken();e.type!==s.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 F||void 0!==r.isErrorNode&&r.isErrorNode()?e.visitErrorNode(r):r instanceof D&&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(s.EPSILON))return!1;for(;null!==r&&r.invokingState>=0&&i.contains(s.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(s.EPSILON)||e!==s.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 Ft(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}Pt.bypassAltsAtnCache={};class kt extends D{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 E.INVALID_INTERVAL;const e=this.symbol.tokenIndex;return new E(e,e)}getChildCount(){return 0}accept(e){return e.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===s.EOF?"<EOF>":this.symbol.text}}class Vt extends kt{constructor(e){super(e)}isErrorNode(){return!0}accept(e){return e.visitErrorNode(this)}}class Ut extends V{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 Vt&&(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 Vt(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 D&&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 D&&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?E.INVALID_INTERVAL:new E(this.start.tokenIndex,this.stop.tokenIndex)}}V.EMPTY=new Ut;class $t{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]:$t.DEFAULT_PROGRAM_NAME;r="number"==typeof e?e:e.tokenIndex;let s=this.getProgram(n),i=new jt(this.tokens,r,s.length,t);s.push(i)}insertBefore(e,t){let r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$t.DEFAULT_PROGRAM_NAME;r="number"==typeof e?e:e.tokenIndex;const s=this.getProgram(n),i=new Ht(this.tokens,r,s.length,t);s.push(i)}replaceSingle(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$t.DEFAULT_PROGRAM_NAME;this.replace(e,e,t,r)}replace(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$t.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 s=this.getProgram(n),i=new qt(this.tokens,e,t,s.length,r);s.push(i)}delete(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$t.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]:$t.DEFAULT_PROGRAM_NAME;t=e instanceof E?e:new E(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 E(i,a));let o=[],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!==s.EOF&&o.push(String(t.text)),c++):c=e.execute(o)}if(a===this.tokens.size-1)for(const e of l.values())e.index>=this.tokens.size-1&&o.push(e.text.toString());return o.join("")}reduceToSingleOperationPerIndex(e){for(let t=0;t<e.length;t++){let r=e[t];if(null==r)continue;if(!(r instanceof qt))continue;let n=r,s=this.getKindOfOps(e,Ht,t);for(let t of s)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 i=this.getKindOfOps(e,qt,t);for(let t of i){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,s=this.getKindOfOps(e,Ht,t);for(let t of s)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 i=this.getKindOfOps(e,qt,t);for(let r of i)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 Bt{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 Bt{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!==s.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 qt extends Bt{constructor(e,t,r,n,s){super(e,t,n,s),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 zt={atn:it,dfa:ct,context:ut,misc:ht,tree:ft,error:_t,Token:s,CommonToken:Re,CharStreams:Lt,CharStream:bt,InputStream:Tt,FileStream:It,CommonTokenStream:Dt,Lexer:Ve,Parser:Pt,ParserRuleContext:Ut,Interval:E,IntervalSet:v,LL1Analyzer:Q,Utils:wt,TokenStreamRewriter:$t};var Gt=t;for(var Wt in n)Gt[Wt]=n[Wt];n.__esModule&&Object.defineProperty(Gt,"__esModule",{value:!0})})()}};const __webpack_module_cache__={};function __webpack_require__(e){const t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;const r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}let __webpack_exports__=__webpack_require__(21);exports.mathjslab=__webpack_exports__})();