0;--r)c[a++]=0;for(r=p.length;r>o;){if(c[--r](a=(o=Math.ceil(s/7))>a?o+1:a+1)&&(i=a,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for((a=c.length)-(i=l.length)<0&&(i=a,n=l,l=c,c=n),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/Ze|0,c[i]%=Ze;for(t&&(c.unshift(t),++r),a=c.length;0==c[--a];)c.pop();return e.d=c,e.e=st(c,r),Ge?ot(e,s,u):e},Xe.precision=Xe.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(Me+e);return n.d?(t=lt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Xe.round=function(){var e=this,t=e.constructor;return ot(new t(e),e.e+1,t.rounding)},Xe.sine=Xe.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:xt(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=xt(e,2,t=t.times(1/bt(5,n)),t);for(var i,o=new e(5),a=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(o.plus(i.times(a.times(i).minus(s))));return t}(r,wt(r,n)),r.precision=e,r.rounding=t,ot(Ie>2?n.neg():n,e,t,!0)):new r(NaN)},Xe.squareRoot=Xe.sqrt=function(){var e,t,n,r,i,o,a=this,s=a.d,u=a.e,c=a.s,l=a.constructor;if(1!==c||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);for(Ge=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=et(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=qe((u+1)/2)-(u<0||u%2),r=new l(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new l(c.toString()),n=(u=l.precision)+3;;)if(r=(o=r).plus(it(a,o,n+2,1)).times(.5),et(o.d).slice(0,n)===(t=et(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(ot(r,u+1,1),e=!r.times(r).eq(a));break}if(!i&&(ot(o,u+1,0),o.times(o).eq(a))){r=o;break}n+=4,i=1}return Ge=!0,ot(r,u,l.rounding,e)},Xe.tangent=Xe.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=it(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,ot(2==Ie||4==Ie?n.neg():n,e,t,!0)):new r(NaN)},Xe.times=Xe.mul=function(e){var t,n,r,i,o,a,s,u,c,l=this,f=l.constructor,p=l.d,d=(e=new f(e)).d;if(e.s*=l.s,!(p&&p[0]&&d&&d[0]))return new f(!e.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:p&&d?0*e.s:e.s/0);for(n=qe(l.e/7)+qe(e.e/7),(u=p.length)<(c=d.length)&&(o=p,p=d,d=o,a=u,u=c,c=a),o=[],r=a=u+c;r--;)o.push(0);for(r=c;--r>=0;){for(t=0,i=u+r;i>r;)s=o[i]+d[r]*p[i-r-1]+t,o[i--]=s%Ze|0,t=s/Ze|0;o[i]=(o[i]+t)%Ze|0}for(;!o[--a];)o.pop();return t?++n:o.shift(),e.d=o,e.e=st(o,n),Ge?ot(e,f.precision,f.rounding):e},Xe.toBinary=function(e,t){return Et(this,2,e,t)},Xe.toDecimalPlaces=Xe.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(tt(e,0,Oe),void 0===t?t=r.rounding:tt(t,0,8),ot(n,e+n.e+1,t))},Xe.toExponential=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=at(r,!0):(tt(e,0,Oe),void 0===t?t=i.rounding:tt(t,0,8),n=at(r=ot(new i(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},Xe.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return void 0===e?n=at(i):(tt(e,0,Oe),void 0===t?t=o.rounding:tt(t,0,8),n=at(r=ot(new o(i),e+i.e+1,t),!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},Xe.toFraction=function(e){var t,n,r,i,o,a,s,u,c,l,f,p,d=this,h=d.d,m=d.constructor;if(!h)return new m(d);if(c=n=new m(1),r=u=new m(0),a=(o=(t=new m(r)).e=lt(h)-d.e-1)%7,t.d[0]=je(10,a<0?7+a:a),null==e)e=o>0?t:c;else{if(!(s=new m(e)).isInt()||s.lt(c))throw Error(Me+s);e=s.gt(t)?o>0?t:c:s}for(Ge=!1,s=new m(et(h)),l=m.precision,m.precision=o=7*h.length*2;f=it(s,t,0,1,1),1!=(i=n.plus(f.times(r))).cmp(e);)n=r,r=i,i=c,c=u.plus(f.times(i)),u=i,i=t,t=s.minus(f.times(i)),s=i;return i=it(e.minus(n),r,0,1,1),u=u.plus(i.times(c)),n=n.plus(i.times(r)),u.s=c.s=d.s,p=it(c,r,o,1).minus(d).abs().cmp(it(u,n,o,1).minus(d).abs())<1?[c,r]:[u,n],m.precision=l,Ge=!0,p},Xe.toHexadecimal=Xe.toHex=function(e,t){return Et(this,16,e,t)},Xe.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:tt(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(Ge=!1,n=it(n,e,0,t,1).times(e),Ge=!0,ot(n)):(e.s=n.s,n=e),n},Xe.toNumber=function(){return+this},Xe.toOctal=function(e,t){return Et(this,8,e,t)},Xe.toPower=Xe.pow=function(e){var t,n,r,i,o,a,s=this,u=s.constructor,c=+(e=new u(e));if(!(s.d&&e.d&&s.d[0]&&e.d[0]))return new u(je(+s,c));if((s=new u(s)).eq(1))return s;if(r=u.precision,o=u.rounding,e.eq(1))return ot(s,r,o);if((t=qe(e.e/7))>=e.d.length-1&&(n=c<0?-c:c)<=9007199254740991)return i=pt(u,s,n,r),e.s<0?new u(1).div(i):ot(i,r,o);if((a=s.s)<0){if(tu.maxE+1||t0?a/0:0):(Ge=!1,u.rounding=s.s=1,n=Math.min(12,(t+"").length),(i=mt(e.times(_t(s,r+n)),r)).d&&nt((i=ot(i,r+5,1)).d,r,o)&&(t=r+10,+et((i=ot(mt(e.times(_t(s,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=ot(i,r+1,0))),i.s=a,Ge=!0,u.rounding=o,ot(i,r,o))},Xe.toPrecision=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=at(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(tt(e,1,Oe),void 0===t?t=i.rounding:tt(t,0,8),n=at(r=ot(new i(r),e,t),e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},Xe.toSignificantDigits=Xe.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(tt(e,1,Oe),void 0===t?t=n.rounding:tt(t,0,8)),ot(new n(this),e,t)},Xe.toString=function(){var e=this,t=e.constructor,n=at(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},Xe.truncated=Xe.trunc=function(){return ot(new this.constructor(this),this.e+1,1)},Xe.valueOf=Xe.toJSON=function(){var e=this,t=e.constructor,n=at(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var it=function(){function e(e,t,n){var r,i=0,o=e.length;for(e=e.slice();o--;)r=e[o]*t+i,e[o]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]1;)e.shift()}return function(r,i,o,a,s,u){var c,l,f,p,d,h,m,_,v,y,g,x,b,w,E,$,R,k,T,N,I=r.constructor,A=r.s==i.s?1:-1,S=r.d,C=i.d;if(!(S&&S[0]&&C&&C[0]))return new I(r.s&&i.s&&(S?!C||S[0]!=C[0]:C)?S&&0==S[0]||!C?0*A:A/0:NaN);for(u?(d=1,l=r.e-i.e):(u=Ze,d=7,l=qe(r.e/d)-qe(i.e/d)),T=C.length,R=S.length,y=(v=new I(A)).d=[],f=0;C[f]==(S[f]||0);f++);if(C[f]>(S[f]||0)&&l--,null==o?(w=o=I.precision,a=I.rounding):w=s?o+(r.e-i.e)+1:o,w<0)y.push(1),h=!0;else{if(w=w/d+2|0,f=0,1==T){for(p=0,C=C[0],w++;(f1&&(C=e(C,p,u),S=e(S,p,u),T=C.length,R=S.length),$=T,x=(g=S.slice(0,T)).length;x=u/2&&++k;do{p=0,(c=t(C,g,T,x))<0?(b=g[0],T!=x&&(b=b*u+(g[1]||0)),(p=b/k|0)>1?(p>=u&&(p=u-1),1==(c=t(m=e(C,p,u),g,_=m.length,x=g.length))&&(p--,n(m,T<_?N:C,_,u))):(0==p&&(c=p=1),m=C.slice()),(_=m.length)=10;p/=10)f++;v.e=f+l*d-1,ot(v,s?o+v.e+1:o,a,h)}return v}}();function ot(e,t,n,r){var i,o,a,s,u,c,l,f,p,d=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(i=1,s=f[0];s>=10;s/=10)i++;if((o=t-i)<0)o+=7,a=t,u=(l=f[p=0])/je(10,i-a-1)%10|0;else if((p=Math.ceil((o+1)/7))>=(s=f.length)){if(!r)break e;for(;s++<=p;)f.push(0);l=u=0,i=1,a=(o%=7)-7+1}else{for(l=s=f[p],i=1;s>=10;s/=10)i++;u=(a=(o%=7)-7+i)<0?0:l/je(10,i-a-1)%10|0}if(r=r||t<0||void 0!==f[p+1]||(a<0?l:l%je(10,i-a-1)),c=n<4?(u||r)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(o>0?a>0?l/je(10,i-a):0:f[p-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=je(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=p,s=1,p--):(f.length=p+1,s=je(10,7-o),f[p]=a>0?(l/je(10,i-a)%je(10,a)|0)*s:0),c)for(;;){if(0==p){for(o=1,a=f[0];a>=10;a/=10)o++;for(a=f[0]+=s,s=1;a>=10;a/=10)s++;o!=s&&(e.e++,f[0]==Ze&&(f[0]=1));break}if(f[p]+=s,f[p]!=Ze)break;f[p--]=0,s=1}for(o=f.length;0===f[--o];)f.pop()}return Ge&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e0?o=o.charAt(0)+"."+o.slice(1)+ft(r):a>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+ft(-i-1)+o,n&&(r=n-a)>0&&(o+=ft(r))):i>=a?(o+=ft(i+1-a),n&&(r=n-i-1)>0&&(o=o+"."+ft(r))):((r=i+1)0&&(i+1===a&&(o+="."),o+=ft(r))),o}function st(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function ut(e,t,n){if(t>Qe)throw Ge=!0,n&&(e.precision=n),Error(Ue);return ot(new e(De),t,1,!0)}function ct(e,t,n){if(t>Je)throw Error(Ue);return ot(new e(Be),t,n,!0)}function lt(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ft(e){for(var t="";e--;)t+="0";return t}function pt(e,t,n,r){var i,o=new e(1),a=Math.ceil(r/7+4);for(Ge=!1;;){if(n%2&&$t((o=o.times(t)).d,a)&&(i=!0),0===(n=qe(n/2))){n=o.d.length-1,i&&0===o.d[n]&&++o.d[n];break}$t((t=t.times(t)).d,a)}return Ge=!0,o}function dt(e){return 1&e.d[e.d.length-1]}function ht(e,t,n){for(var r,i=new e(t[0]),o=0;++o17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(Ge=!1,u=h):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=r=Math.log(je(2,f))/Math.LN10*2+5|0,n=o=a=new p(1),p.precision=u;;){if(o=ot(o.times(e),u,1),n=n.times(++l),et((s=a.plus(it(o,n,u,1))).d).slice(0,u)===et(a.d).slice(0,u)){for(i=f;i--;)a=ot(a.times(a),u,1);if(null!=t)return p.precision=h,a;if(!(c<3&&nt(a.d,u-r,d,c)))return ot(a,p.precision=h,d,Ge=!0);p.precision=u+=10,n=o=s=new p(1),l=0,c++}a=s}}function _t(e,t){var n,r,i,o,a,s,u,c,l,f,p,d=1,h=e,m=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!m||!m[0]||!h.e&&1==m[0]&&1==m.length)return new _(m&&!m[0]?-1/0:1!=h.s?NaN:m?0:h);if(null==t?(Ge=!1,l=y):l=t,_.precision=l+=10,r=(n=et(m)).charAt(0),!(Math.abs(o=h.e)<15e14))return c=ut(_,l+2,y).times(o+""),h=_t(new _(r+"."+n.slice(1)),l-10).plus(c),_.precision=y,null==t?ot(h,y,v,Ge=!0):h;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=et((h=h.times(e)).d)).charAt(0),d++;for(o=h.e,r>1?(h=new _("0."+n),o++):h=new _(r+"."+n.slice(1)),f=h,u=a=h=it(h.minus(1),h.plus(1),l,1),p=ot(h.times(h),l,1),i=3;;){if(a=ot(a.times(p),l,1),et((c=u.plus(it(a,new _(i),l,1))).d).slice(0,l)===et(u.d).slice(0,l)){if(u=u.times(2),0!==o&&(u=u.plus(ut(_,l+2,y).times(o+""))),u=it(u,new _(d),l,1),null!=t)return _.precision=y,u;if(!nt(u.d,l-10,v,s))return ot(u,_.precision=y,v,Ge=!0);_.precision=l+=10,c=a=h=it(f.minus(1),f.plus(1),l,1),p=ot(h.times(h),l,1),i=s=1}u=c,i+=2}}function vt(e){return String(e.s*e.s/0)}function yt(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(r,i)){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),We.test(t))return yt(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(He.test(t))n=16,t=t.toLowerCase();else if(Ve.test(t))n=2;else{if(!Ye.test(t))throw Error(Me+t);n=8}for((o=t.search(/p/i))>0?(u=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),a=(o=t.indexOf("."))>=0,r=e.constructor,a&&(o=(s=(t=t.replace(".","")).length)-o,i=pt(r,new r(n),o,2*o)),o=l=(c=rt(t,n,Ze)).length-1;0===c[o];--o)c.pop();return o<0?new r(0*e.s):(e.e=st(c,l),e.d=c,Ge=!1,a&&(e=it(e,i,4*s)),u&&(e=e.times(Math.abs(u)<54?je(2,u):pn.pow(2,u))),Ge=!0,e)}function xt(e,t,n,r,i){var o,a,s,u,c=e.precision,l=Math.ceil(c/7);for(Ge=!1,u=n.times(n),s=new e(r);;){if(a=it(s.times(u),new e(t++*t++),c,1),s=i?r.plus(a):r.minus(a),r=it(a.times(u),new e(t++*t++),c,1),void 0!==(a=s.plus(r)).d[l]){for(o=l;a.d[o]===s.d[o]&&o--;);if(-1==o)break}o=s,s=r,r=a,a=o}return Ge=!0,a.d.length=l+1,a}function bt(e,t){for(var n=e;--t;)n*=e;return n}function wt(e,t){var n,r=t.s<0,i=ct(e,e.precision,1),o=i.times(.5);if((t=t.abs()).lte(o))return Ie=r?4:1,t;if((n=t.divToInt(i)).isZero())Ie=r?3:2;else{if((t=t.minus(n.times(i))).lte(o))return Ie=dt(n)?r?2:3:r?4:1,t;Ie=dt(n)?r?1:4:r?3:2}return t.minus(i).abs()}function Et(e,t,n,r){var i,o,a,s,u,c,l,f,p,d=e.constructor,h=void 0!==n;if(h?(tt(n,1,Oe),void 0===r?r=d.rounding:tt(r,0,8)):(n=d.precision,r=d.rounding),e.isFinite()){for(h?(i=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):i=t,(a=(l=at(e)).indexOf("."))>=0&&(l=l.replace(".",""),(p=new d(1)).e=l.length-a,p.d=rt(at(p),10,i),p.e=p.d.length),o=u=(f=rt(l,10,i)).length;0==f[--u];)f.pop();if(f[0]){if(a<0?o--:((e=new d(e)).d=f,e.e=o,f=(e=it(e,p,n,r,0,i)).d,o=e.e,c=Ne),a=f[n],s=i/2,c=c||void 0!==f[n+1],c=r<4?(void 0!==a||c)&&(0===r||r===(e.s<0?3:2)):a>s||a===s&&(4===r||c||6===r&&1&f[n-1]||r===(e.s<0?8:7)),f.length=n,c)for(;++f[--n]>i-1;)f[n]=0,n||(++o,f.unshift(1));for(u=f.length;!f[u-1];--u);for(a=0,l="";a1)if(16==t||8==t){for(a=16==t?4:3,--u;u%a;u++)l+="0";for(u=(f=rt(l,i,t)).length;!f[u-1];--u);for(a=1,l="1.";au)for(o-=u;o--;)l+="0";else ot)return e.length=t,!0}function Rt(e){return new this(e).abs()}function kt(e){return new this(e).acos()}function Tt(e){return new this(e).acosh()}function Nt(e,t){return new this(e).plus(t)}function It(e){return new this(e).asin()}function At(e){return new this(e).asinh()}function St(e){return new this(e).atan()}function Ct(e){return new this(e).atanh()}function Ot(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,o=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?ct(this,r,i):new this(0)).s=e.s:!e.d||t.isZero()?(n=ct(this,o,1).times(.5)).s=e.s:t.s<0?(this.precision=o,this.rounding=1,n=this.atan(it(e,t,o,1)),t=ct(this,o,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(it(e,t,o,1)):(n=ct(this,o,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function Lt(e){return new this(e).cbrt()}function Dt(e){return ot(e=new this(e),e.e+1,2)}function Bt(e,t,n){return new this(e).clamp(t,n)}function Pt(e){if(!e||"object"!=typeof e)throw Error(Fe+"Object expected");var t,n,r,i=!0===e.defaults,o=["precision",1,Oe,"rounding",0,8,"toExpNeg",-Ce,0,"toExpPos",0,Ce,"maxE",0,Ce,"minE",-Ce,0,"modulo",0,9];for(t=0;t=o[t+1]&&r<=o[t+2]))throw Error(Me+n+": "+r);this[n]=r}if(n="crypto",i&&(this[n]=Pe[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(Me+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(Ke);this[n]=!0}else this[n]=!1}return this}function Gt(e){return new this(e).cos()}function Ft(e){return new this(e).cosh()}function Mt(e,t){return new this(e).div(t)}function Ut(e){return new this(e).exp()}function Kt(e){return ot(e=new this(e),e.e+1,3)}function zt(){var e,t,n=new this(0);for(Ge=!1,e=0;e=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:s[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(Ke);for(t=crypto.randomBytes(r*=4);o=214e7?crypto.randomBytes(4).copy(t,o):(s.push(i%1e7),o+=4);o=r/4}else for(;o=10;i/=10)r++;r<7&&(n-=7-r)}return a.e=n,a.d=s,a}function tn(e){return ot(e=new this(e),e.e+1,this.rounding)}function nn(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function rn(e){return new this(e).sin()}function on(e){return new this(e).sinh()}function an(e){return new this(e).sqrt()}function sn(e,t){return new this(e).sub(t)}function un(){var e=0,t=arguments,n=new this(t[e]);for(Ge=!1;n.s&&++eo.maxE?(i.e=NaN,i.d=null):e.e=10;n/=10)t++;return void(Ge?t>o.maxE?(i.e=NaN,i.d=null):t1&&void 0!==arguments[1]?arguments[1]:[],n=ir();return new $n(n.getError(e,t),e)}function Tn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=ir();return new Rn(n.getError(e,t),e)}var Nn=Object.freeze({symbol_not_found_full:function(e,t){if(t){var n=Tn("symbol_not_found_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Nn.symbol_not_found(e)},symbol_not_found:function(e){return Tn("symbol_not_found",[e])},function_missing_full:function(e,t){if(t){var n=Tn("function_missing_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Nn.function_missing(e)},function_missing:function(e){return Tn("function_missing",[e])},main_missing:function(){return Tn("main_missing")},array_dimension_not_int_full:function(e){if(e){var t=Tn("array_dimension_not_int_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Nn.array_dimension_not_int()},array_dimension_not_int:function(){return Tn("array_dimension_not_int")},unknown_command_full:function(e){if(e){var t=kn("unknown_command_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Nn.unknown_command()},unknown_command:function(){return kn("unknown_command")},incompatible_types_full:function(e,t,n,r,i,o){var a=ir();if(o){var s=Tn("incompatible_types_full",[a.translateType(e,t),i,o.line,a.translateType(n,r)]);return s.context={line:o.line,column:o.column},s}return Nn.incompatible_types(e,t,n,r,i)},incompatible_types:function(e,t,n,r,i){var o=ir();return Tn("incompatible_types",[o.translateType(e,t),i,o.translateType(n,r)])},incompatible_types_array_full:function(e,t,n,r){var i=ir();if(r){var o=Tn("incompatible_types_array_full",[e,i.translateType(t,n),r.line,r.column]);return o.context={line:r.line,column:r.column},o}return Nn.incompatible_types_array(e,t,n)},incompatible_types_array:function(e,t,n){return Tn("incompatible_types_array",[e,ir().translateType(t,n)])},loop_condition_type_full:function(e,t){if(t){var n=Tn("loop_condition_type_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Nn.loop_condition_type(e)},loop_condition_type:function(e){return Tn("loop_condition_type",[e])},endless_loop_full:function(e){if(e){var t=Tn("endless_loop_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Nn.endless_loop()},endless_loop:function(){return Tn("endless_loop")},if_condition_type_full:function(e,t){if(t){var n=Tn("if_condition_type_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Nn.if_condition_type(e)},if_condition_type:function(e){return Tn("if_condition_type",[e])},invalid_global_var:function(){return kn("invalid_global_var")},not_implemented:function(e){return kn("not_implemented",[e])},invalid_case_type_full:function(e,t,n,r){var i=ir();if(r){var o=Tn("invalid_case_type_full",[e,i.translateType(t,n),r.line,r.column]);return o.context={line:r.line,column:r.column},o}return Nn.invalid_case_type(e,t,n)},invalid_case_type:function(e,t,n){return Tn("invalid_case_type",[e,ir().translateType(t,n)])},void_in_expression_full:function(e,t){if(t){var n=Tn("void_in_expression_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Nn.void_in_expression(e)},void_in_expression:function(e){return Tn("void_in_expression",[e])},invalid_array_access_full:function(e,t){if(t){var n=Tn("invalid_array_access_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Nn.invalid_array_access(e)},invalid_array_access:function(e){return Tn("invalid_array_access",[e])},invalid_matrix_access_full:function(e,t){if(t){var n=Tn("invalid_matrix_access_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Nn.invalid_matrix_access(e)},invalid_matrix_access:function(e){return Tn("invalid_matrix_access",[e])},matrix_column_outbounds_full:function(e,t,n,r){if(r){var i=kn("matrix_column_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Nn.matrix_column_outbounds(e,t,n)},matrix_column_outbounds:function(e,t,n){return kn("matrix_column_outbounds",[t,e,n])},matrix_line_outbounds_full:function(e,t,n,r){if(r){var i=kn("matrix_line_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Nn.matrix_line_outbounds(e,t,n)},matrix_line_outbounds:function(e,t,n){return kn("matrix_line_outbounds",[t,e,n])},vector_line_outbounds_full:function(e,t,n,r){if(r){var i=kn("vector_line_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Nn.vector_line_outbounds(e,t,n)},vector_line_outbounds:function(e,t,n){return kn("vector_line_outbounds",[t,e,n])},vector_not_matrix_full:function(e,t){if(t){var n=kn("vector_not_matrix_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Nn.vector_not_matrix(e)},vector_not_matrix:function(e){return kn("vector_not_matrix",[e])},function_no_return:function(e){return Tn("function_no_return",[e])},invalid_void_return_full:function(e,t,n,r){var i=ir();if(r){var o=Tn("invalid_void_return_full",[r.line,e,i.translateType(t,n)]);return o.context={line:r.line,column:r.column},o}return Nn.invalid_void_return(e,t,n)},invalid_void_return:function(e,t,n){return Tn("invalid_void_return_full",[e,ir().translateType(t,n)])},invalid_return_type_full:function(e,t,n,r){var i=ir();if(r){var o=Tn("invalid_return_type_full",[r.line,e,i.translateType(t,n)]);return o.context={line:r.line,column:r.column},o}return Nn.invalid_return_type(e,t,n)},invalid_return_type:function(e,t,n){return Tn("invalid_return_type",[e,ir().translateType(t,n)])},invalid_parameters_size_full:function(e,t,n,r){if(r){var i=Tn("invalid_parameters_size_full",[r.line,e,t,n]);return i.context={line:r.line,column:r.column},i}return Nn.invalid_parameters_size(e,t,n)},invalid_parameters_size:function(e,t,n){return Tn("invalid_parameters_size",[e,t,n])},invalid_parameter_type_full:function(e,t,n){if(n){var r=Tn("invalid_parameter_type_full",[t,nr.getLocalName(e),n.line]);return r.context={line:n.line,column:n.column},r}return Nn.invalid_parameter_type(e,t)},invalid_parameter_type:function(e,t){return Tn("invalid_parameter_type_full",[t,nr.getLocalName(e)])},invalid_ref_full:function(e,t,n){if(n){var r=Tn("invalid_ref_full",[t,e,n.line]);return r.context={line:n.line,column:n.column},r}return Nn.invalid_ref(e,t)},invalid_ref:function(e,t){return Tn("invalid_ref",[t,e])},unexpected_break_command_full:function(e){if(e){var t=kn("unexpected_break_command_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Nn.unexpected_break_command()},unexpected_break_command:function(){return kn("unexpected_break_command")},invalid_array_literal_type_full:function(e,t){if(t){var n=kn("invalid_array_literal_type_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Nn.invalid_array_literal_type(e)},invalid_array_literal_type:function(e){return kn("invalid_array_literal_type",[e])},invalid_array_literal_line_full:function(e,t,n){if(n){var r=kn("invalid_array_literal_line_full",[n.line,e,t]);return r.context={line:n.line,column:n.column},r}return Nn.invalid_array_literal_type(e,t)},invalid_array_literal_line:function(e,t){return kn("invalid_array_literal_line",[e,t])},invalid_array_literal_column_full:function(e,t,n){if(n){var r=kn("invalid_array_literal_column_full",[n.line,e,t]);return r.context={line:n.line,column:n.column},r}return Nn.invalid_array_literal_column(e,t)},invalid_array_literal_column:function(e,t){return kn("invalid_array_literal_column",[e,t])},invalid_unary_op_full:function(e,t,n,r,i){var o=ir();if(i){var a=kn("invalid_unary_op_full",[i.line,e,o.translateOp(t),o.translateType(n,r)]);return a.context={line:i.line,column:i.column},a}return Nn.invalid_unary_op(t,n,r)},invalid_unary_op:function(e,t,n,r){var i=ir();return kn("invalid_unary_op",[e,i.translateOp(t),i.translateType(n,r)])},invalid_infix_op_full:function(e,t,n,r,i,o,a){var s=ir();if(a){var u=kn("invalid_infix_op_full",[a.line,e,s.translateOp(t),s.translateType(n,r),s.translateType(i,o)]);return u.context={line:a.line,column:a.column},u}return Nn.invalid_infix_op(t,n,r,i,o)},invalid_infix_op:function(e,t,n,r,i,o){var a=ir();return kn("invalid_infix_op",[e,a.translateOp(t),a.translateType(n,r),a.translateType(i,o)])},array_dimension_not_positive_full:function(e){if(e){var t=Tn("array_dimension_not_positive_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Nn.array_dimension_not_positive()},array_dimension_not_positive:function(){return Tn("array_dimension_not_positive")},invalid_type_conversion:function(e,t,n){return kn("invalid_type_conversion",[e,ir().translateType(t,n)])},invalid_read_type:function(e,t,n,r,i){var o=ir(),a=kn("invalid_read_type",[i.line,e,o.translateType(t,n),r]);return a.context={line:i.line,column:i.column},a},invalid_read_type_array:function(e,t,n,r,i,o,a){var s=ir(),u=kn("invalid_read_type_array",[a.line,e,s.translateType(t,n),r,s.translateType(i,o)]);return u.context={line:a.line,column:a.column},u},invalid_const_ref_full:function(e,t,n){if(n){var r=Tn("invalid_const_ref_full",[t,nr.getLocalName(e),n.line]);return r.context={line:n.line,column:n.column},r}return Nn.invalid_const_ref(e,t)},invalid_const_ref:function(e,t){return Tn("invalid_const_ref",[t,nr.getLocalName(e)])},invalid_const_assignment_full:function(e,t){if(t){var n=Tn("invalid_const_assignment_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Nn.invalid_const_assignment(e)},invalid_const_assignment:function(e){return Tn("invalid_const_assignment",[e])},invalid_vector_assignment_full:function(e,t,n,r,i){if(i){var o=kn("invalid_vector_assignment_full",[i.line,e,t,n,r]);return o.context={line:i.line,column:i.column},o}return Nn.invalid_vector_assignment(e,t,n,r)},invalid_vector_assignment:function(e,t,n,r){return kn("invalid_vector_assignment",[e,t,n,r])},invalid_matrix_assignment_full:function(e,t,n,r,i,o,a){if(a){var s=kn("invalid_matrix_assignment_full",[a.line,e,t,n,r,i,o]);return s.context={line:a.line,column:a.column},s}return Nn.invalid_matrix_assignment(e,t,n,r,i,o)},invalid_matrix_assignment:function(e,t,n,r,i,o){return kn("invalid_matrix_assignment",[e,t,n,r,i,o])},matrix_to_vector_attr:function(e,t,n){var r=Tn("matrix_to_vector_attr",[n.line,t,e]);return r.context={line:n.line,column:n.column},r},vector_to_matrix_attr:function(e,t,n){var r=Tn("vector_to_matrix_attr",[n.line,t,e]);return r.context={line:n.line,column:n.column},r},invalid_matrix_index_assign_full:function(e,t,n,r,i,o){if(o){var a=kn("invalid_matrix_index_assign_full",[o.line,t,e,n,r,i]);return a.context={line:o.line,column:o.column},a}return Nn.invalid_matrix_index_assign(e,t,n,r,i)},invalid_matrix_index_assign:function(e,t,n,r,i){return kn("invalid_matrix_index_assign",[t,e,n,r,i])},invalid_number_elements_vector:function(e,t,n,r){var i=kn("invalid_number_elements_vector",[e,r.line,t,n]);return i.context={line:r.line,column:r.column},i},invalid_number_lines_matrix:function(e,t,n,r){var i=kn("invalid_number_lines_matrix",[e,r.line,t,n]);return i.context={line:r.line,column:r.column},i},divsion_by_zero_full:function(e,t){if(t){var n=kn("divsion_by_zero_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Nn.divsion_by_zero(e)},divsion_by_zero:function(e){return kn("divsion_by_zero",[e])},undefined_tanget_value:function(e,t){var n=kn("undefined_tanget_value",[t.line,e]);return n.context={line:t.line,column:t.column},n},negative_log_value:function(e){var t=kn("negative_log_value",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_string_index:function(e,t,n){var r=nr.getLocalName("$charAt"),i=kn("invalid_string_index",[n.line,r,e,t,t.length-1]);return i.context={line:n.line,column:n.column},i},negative_sqrt_value:function(e){var t=kn("negative_sqrt_value",[e.line]);return t.context={line:e.line,column:e.column},t},exceeded_recursive_calls:function(e){var t=kn("exceeded_recursive_calls",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_for_variable:function(e,t){var n=Tn("invalid_for_variable",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_from:function(e,t){var n=Tn("invalid_for_from",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_to:function(e,t){var n=Tn("invalid_for_to",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_pass:function(e,t){var n=Tn("invalid_for_pass",[t.line,e]);return n.context={line:t.line,column:t.column},n},exceed_max_instructions:function(){return kn("exceed_max_instructions")}}),In=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a(this,e),K(this,"type",void 0),K(this,"id",void 0),K(this,"isConst",void 0),K(this,"value",void 0),this.type=t,this.id=r,this.isConst=i,this.value=n}return l(e,[{key:"get",value:function(){return this.value}},{key:"inStore",value:function(){return null!=this.id}}]),e}(),An=function(){function e(t,n){a(this,e),this.dimensions=n,K(this,"innerType",void 0),this.innerType=t}return l(e,[{key:"isVector",get:function(){return 1==this.dimensions}},{key:"isCompatible",value:function(t){return t instanceof e&&this.dimensions===t.dimensions&&this.innerType.isCompatible(t.innerType)}},{key:"stringInfo",value:function(){var e=this,t=this.innerType.stringInfo();return t.forEach((function(t){t.dim=e.dimensions})),t}},{key:"value",get:function(){}},{key:"ord",get:function(){}},{key:"canAccept",value:function(t,n){var r=this.dimensions-n;return t instanceof e?r==t.dimensions&&this.innerType.isCompatible(t.innerType):0==r&&this.innerType.isCompatible(t)}}]),e}();var Sn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t,n){var o;return a(this,i),(o=r.call(this)).id=e,o.line=t,o.column=n,o}return l(i,[{key:"toString",value:function(){var e=this.line.toString(),t=null;this.column&&(t=this.column.toString());var n;return n=t?"".concat(this.id,"[").concat(e,"][").concat(t,"]"):"".concat(this.id,"[").concat(e,"]"),this.parenthesis?"(".concat(n,")"):n}}]),i}(Te);var Cn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this)).type=e,t}return l(i)}(Te);var On=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.INTEGER)).value=e,t}return l(i,[{key:"toString",value:function(){var e=xn(this.value,this.type);return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Ln=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.REAL)).value=e,t}return l(i,[{key:"toString",value:function(){var e=xn(this.value,this.type);return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Dn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.BOOLEAN)).value=e,t}return l(i,[{key:"toString",value:function(){var e=gn(this.value);return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Bn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.CHAR)).value=e,t}return l(i,[{key:"toString",value:function(){var e="'".concat(this.value,"'");return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Pn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.STRING)).value=e,t}return l(i,[{key:"toString",value:function(){var e='"'+this.value+'"';return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Gn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t){var n;return a(this,i),(n=r.call(this,e)).value=t,n}return l(i,[{key:"subtype",get:function(){var e=this.value[0];return e instanceof i?e.value[0].type:e.type}},{key:"lines",get:function(){return this.value.length}},{key:"columns",get:function(){var e=this.value[0];return e instanceof i?e.value.length:null}},{key:"isVector",get:function(){return null===this.columns}},{key:"isValid",get:function(){return this.validateSize()&&this.validateType()}},{key:"validateType",value:function(){return!0}},{key:"validateSize",value:function(){return!0}},{key:"toString",value:function(){var e="{"+this.value.map((function(e){return e.toString()})).join(",")+"}";return this.parenthesis?"(".concat(e,")"):e}}]),i}(Cn);var Fn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this,ye.UNDEFINED)).id=e,t}return l(i,[{key:"toString",value:function(){return this.parenthesis?"(".concat(this.id,")"):this.id}}]),i}(Cn);var Mn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t,n){var o;return a(this,i),(o=r.call(this)).op=e,o.left=t,o.right=n,o}return l(i,[{key:"toString",value:function(){var e=this.left.toString(),t=this.op.value,n=this.right.toString();return this.parenthesis?"(".concat(e+t+n,")"):e+t+n}}]),i}(Te);var Un=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t){return a(this,i),r.call(this,e,t,null)}return l(i,[{key:"toString",value:function(){var e=this.left.toString(),t=this.op.value;return this.parenthesis?"(".concat(t+e,")"):t+e}}]),i}(Mn),Kn=function(){function e(t,n,r,i){a(this,e),this.line=t,this.column=n,this.text=r,this.size=i}return l(e,null,[{key:"createSourceInfo",value:function(t){return new e(t.line,t.col,t.text,t.text.length)}},{key:"createSourceInfoFromList",value:function(t,n){return new e(t.line,t.col,"",n.offset+1-t.offset)}}]),e}(),zn=Object.freeze({ADD:{ord:0,value:"+"},SUB:{ord:1,value:"-"},MULT:{ord:2,value:"*"},DIV:{ord:3,value:"/"},MOD:{ord:4,value:"%"},GT:{ord:5,value:">"},GE:{ord:6,value:">="},LT:{ord:7,value:"<"},LE:{ord:8,value:"<="},EQ:{ord:9,value:"=="},NEQ:{ord:10,value:"!="},AND:{ord:11,value:"and"},OR:{ord:12,value:"or"},NOT:{ord:13,value:"not"}});function qn(e){switch(e){case"+":return zn.ADD;case"-":return zn.SUB;case"*":return zn.MULT;case"/":return zn.DIV;case"%":return zn.MOD;case">":return zn.GT;case">=":return zn.GE;case"<":return zn.LT;case"<=":return zn.LE;case"==":return zn.EQ;case"!=":return zn.NEQ;case"and":return zn.AND;case"or":return zn.OR;case"not":return zn.NOT}return null}var jn=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t){var n;return a(this,i),(n=r.call(this,e)).id=t,n._context={},Error.captureStackTrace&&Error.captureStackTrace(d(n),i),n}return l(i,[{key:"context",get:function(){return this._context},set:function(e){this._context=e}}]),i}(En(Error));function Vn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=ir().getError(e,t);return new jn(n,e)}var Hn=Object.freeze({extra_lines:function(){return new jn(ir().getError("extra_lines"))},token_missing_one:function(e,t){var n=Vn("token_missing_one",[e,t.text,t.line,t.col]);return n.context={line:t.line,column:t.col},n},token_missing_list:function(e,t){var n=e.join(ir().getOR()),r=Hn.token_missing_one(n,t);return r.context={line:t.line,column:t.col},r},id_missing:function(e){var t=Vn("id_missing",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},eos_missing:function(e){var t=Vn("eos_missing",[e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_array_dimension:function(e,t){var n=Vn("invalid_array_dimension",[t.line,t.col,e]);return n.context={line:t.line,column:t.col},n},invalid_array_size:function(e){var t=Vn("invalid_array_size",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_main_return:function(e,t,n){var r=Vn("invalid_main_return",[e,t,n.line]);return r.context={line:n.line,column:n.col},r},invalid_var_declaration:function(e){var t=Vn("invalid_var_declaration",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_break_command:function(e,t){var n=Vn("invalid_break_command",[t.line,e]);return n.context={line:t.line,column:t.col},n},invalid_terminal:function(e){var t=Vn("invalid_terminal",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_type:function(e,t){var n=e.join(ir().getOR()),r=Vn("invalid_type",[t.text,t.line,t.col,n]);return r.context={line:t.line,column:t.col},r},const_not_init:function(e){var t=Vn("const_not_init",[e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_id_format:function(e){var t=Vn("invalid_id_format",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},duplicate_function:function(e){var t=Vn("duplicate_function",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},main_parameters:function(){return Vn("main_parameters")},duplicate_variable:function(e){var t=Vn("duplicate_variable",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_character:function(e,t,n){var r=Vn("invalid_character",[e,t]);return r.context={line:t,column:n},r},annonymous_array_literal:function(e){var t=Vn("annonymous_array_literal",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_matrix_literal_line:function(e,t){var n=Vn("invalid_matrix_literal_line",[e,t.line]);return n.context={line:t.line,column:t.column},n},cannot_infer_matrix_line:function(e,t){var n=Vn("cannot_infer_matrix_line",[e,t.line]);return n.context={line:t.line,column:t.column},n},cannot_infer_matrix_column:function(e,t){var n=Vn("cannot_infer_matrix_column",[e,t.line]);return n.context={line:t.line,column:t.column},n},cannot_infer_vector_size:function(e,t){var n=Vn("cannot_infer_vector_size",[e,t.line]);return n.context={line:t.line,column:t.column},n},matrix_to_vector_literal_attr:function(e,t,n){var r=Vn("matrix_to_vector_literal_attr",[n.line,t,e]);return r.context={line:n.line,column:n.column},r},vector_to_matrix_literal_attr:function(e,t,n){var r=Vn("vector_to_matrix_literal_attr",[n.line,t,e]);return r.context={line:n.line,column:n.column},r},array_init_not_literal:function(e){var t=Vn("array_init_not_literal",[e.line]);return t.context={line:e.line,column:e.column},t},array_exceeds_2d:function(e){var t=Vn("array_exceeds_2d",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_matrix_id_dimension:function(e){var t=Vn("invalid_matrix_id_dimension",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_vector_init:function(e){var t=Vn("invalid_vector_init",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_matrix_init:function(e){var t=Vn("invalid_matrix_init",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_syntax:function(e,t,n){var r=Vn("invalid_syntax",[e,t]);return r.context={line:t,column:n},r}}),Yn=function(){function e(t,n){a(this,e),this.ivprogLexer=n,this.inputStream=t,this.lexer=n.lexer,this.tokenStream=[],this.pos=0,this.ruleNames=n.getRules(),this.variableTypes=Object.entries(this.ivprogLexer.getTypeKeys()).map((function(e){var t=y(e,2),n=t[0];return t[1],n})),this.functionTypes=this.variableTypes.concat(this.ruleNames.RK_VOID),this.parsingArrayDimension=0,this.scope=[],this.langFuncs=this.ivprogLexer.getLangFuncs(),this.definedFuncsNameList=[],this.definedVariablesStack=[]}return l(e,[{key:"fill",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t?this.tokenStream=t:(this.tokenStream=Array.from(this.lexer.reset(this.inputStream)),this.tokenStream=this.tokenStream.filter((function(t){if(t.type===e.ruleNames.ERROR){var n=t.text,r=t.line,i=t.col;throw Hn.invalid_syntax(n,r,i)}return t.type!==e.ruleNames.WHITESPACE&&t.type!==e.ruleNames.COMMENTS})))}},{key:"parseTree",value:function(){return this.parseProgram()}},{key:"getToken",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pos;return t>=this.tokenStream.length?e.EOF_TOKEN:this.tokenStream[t]}},{key:"insideScope",value:function(t){return this.scope.length<=0?e.BASE===t:this.scope[this.scope.length-1]===t}},{key:"pushScope",value:function(e){this.scope.push(e)}},{key:"pushVariableStack",value:function(){this.definedVariablesStack.push([])}},{key:"popScope",value:function(){return this.scope.pop()}},{key:"popVariableStack",value:function(){return this.definedVariablesStack.pop()}},{key:"getCurrentVariableStack",value:function(){return this.definedVariablesStack[this.definedVariablesStack.length-1]}},{key:"isEOF",value:function(){return this.getToken(this.pos).type===e.EOF_TOKEN.type}},{key:"parseProgram",value:function(){this.consumeNewLines();var e=this.getToken(),t=[],n=[];if(this.ruleNames.RK_PROGRAM===e.type){for(this.pos++,this.consumeNewLines(),this.checkOpenCurly(),this.pos++,this.pushVariableStack();;){this.consumeNewLines();var r=this.getToken();if(r.type===this.ruleNames.RK_CONST||this.isVariableType(r))t=t.concat(this.parseGlobalVariables());else{if(r.type!==this.ruleNames.RK_FUNCTION)break;this.pushVariableStack(),n=n.concat(this.parseFunction()),this.popVariableStack()}}if(this.consumeNewLines(),this.checkCloseCurly(),this.pos++,this.consumeNewLines(),!this.isEOF())throw console.log(this.getToken()),Hn.extra_lines();return this.popVariableStack(),{global:t,functions:n}}throw Hn.token_missing_one(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_PROGRAM],e)}},{key:"checkOpenCurly",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.OPEN_CURLY!==t.type){if(e)return!1;throw Hn.token_missing_one("{",t)}return!0}},{key:"checkCloseCurly",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.CLOSE_CURLY!==t.type){if(e)return!1;throw Hn.token_missing_one("}",t)}return!0}},{key:"checkOpenBrace",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.OPEN_BRACE!==t.type){if(e)return!1;throw Hn.token_missing_one("[",t)}return!0}},{key:"checkCloseBrace",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.CLOSE_BRACE!==t.type){if(e)return!1;throw Hn.token_missing_one("]",t)}return!0}},{key:"checkOpenParenthesis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.OPEN_PARENTHESIS!==t.type){if(e)return!1;throw Hn.token_missing_one("(",t)}return!0}},{key:"checkCloseParenthesis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(this.ruleNames.CLOSE_PARENTHESIS!==t.type){if(e)return!1;throw Hn.token_missing_one(")",t)}return!0}},{key:"checkEOS",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getToken();if(t.type!==this.ruleNames.EOS){if(e)return!1;throw Hn.eos_missing(t)}return!0}},{key:"checkFunctionDuplicate",value:function(e,t){var n=null===e?"$main":e;if(-1!==this.definedFuncsNameList.indexOf(n))throw Hn.duplicate_function(t);this.definedFuncsNameList.push(n)}},{key:"checkVariableDuplicate",value:function(e,t){if(-1!==this.getCurrentVariableStack().indexOf(e))throw Hn.duplicate_variable(t);this.getCurrentVariableStack().push(e)}},{key:"consumeForSemiColon",value:function(){var e=this.getToken();if(e.type!==this.ruleNames.EOS||!e.text.match("^;$"))throw Hn.token_missing_one(";",e);this.pos++}},{key:"parseGlobalVariables",value:function(){var e=this.parseMaybeConst();return this.checkEOS(),this.pos++,e}},{key:"parseMaybeConst",value:function(){var e=this.getToken();if(e.type===this.ruleNames.RK_CONST){this.pos++;var t=this.parseType();return this.parseDeclaration(t,!0)}if(this.isVariableType(e)){var n=this.parseType();return this.parseDeclaration(n)}throw Hn.token_missing_list([this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_CONST]].concat(this.getTypeArray()),e)}},{key:"parseDeclaration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null,r=null,i=null,o=0,a=Kn.createSourceInfo(this.getToken()),s=this.parseID();if(this.checkVariableDuplicate(s,a),this.checkOpenBrace(!0))return this.pos+=1,this.consumeNewLines(),r=this.parseArrayDimension(),this.consumeNewLines(),this.checkCloseBrace(),this.pos+=1,o+=1,this.checkOpenBrace(!0)&&(this.pos+=1,this.consumeNewLines(),i=this.parseArrayDimension(),this.consumeNewLines(),this.checkCloseBrace(),this.pos+=1,o+=1),this.parseArrayDeclaration(e,t,s,a,o,r,i);var u=this.getToken();if(t&&u.type!==this.ruleNames.ASSIGNMENT)throw Hn.const_not_init(a);u.type===this.ruleNames.ASSIGNMENT&&(this.pos++,n=this.parseExpressionOR());var c=new ie(s,e,n,t);c.sourceInfo=a;var l=this.getToken();return l.type===this.ruleNames.COMMA?(this.pos++,this.consumeNewLines(),[c].concat(this.parseDeclaration(e,t))):[c]}},{key:"parseArrayDeclaration",value:function(e,t,n,r,i,o,a){var s=this.getToken(),u=o,c=a,l=null,f=!1;if((o instanceof Fn||a instanceof Fn)&&(f=!0,i>1&&(null==o||null==a)))throw Hn.invalid_matrix_id_dimension(Kn.createSourceInfo(s));if(t&&s.type!==this.ruleNames.ASSIGNMENT)throw Hn.const_not_init(r);if(s.type===this.ruleNames.ASSIGNMENT){if(f)throw 1==i?Hn.invalid_vector_init(Kn.createSourceInfo(s)):Hn.invalid_matrix_init(Kn.createSourceInfo(s));this.pos+=1,l=this.parseArrayLiteral(e)}if(null==l&&null==o){if(i>1)throw Hn.cannot_infer_matrix_line(n,r);throw Hn.cannot_infer_vector_size(n,r)}if(i>1&&null==l&&null==a)throw Hn.cannot_infer_matrix_column(n,r);if(1===i&&null!=l&&!l.isVector){var p=l.toString();throw Hn.matrix_to_vector_literal_attr(n,p,l.sourceInfo)}if(i>1&&null!=l&&l.isVector){var d=l.toString();throw Hn.vector_to_matrix_literal_attr(n,d,l.sourceInfo)}null==o&&((u=new On(hn(l.lines))).sourceInfo=r),i>1&&null==a&&((c=new On(hn(l.columns))).sourceInfo=r);var h=new oe(n,new An(e,i),u,c,l,t);return h.sourceInfo=r,this.getToken().type===this.ruleNames.COMMA?(this.pos++,this.consumeNewLines(),[h].concat(this.parseDeclaration(e,t))):[h]}},{key:"consumeNewLines",value:function(){for(var e=this.getToken();e&&e.type===this.ruleNames.EOS&&e.text.match("^[\r\n]+$");)this.pos++,e=this.getToken()}},{key:"isVariableType",value:function(e){return this.variableTypes.find((function(t){return t===e.type}))}},{key:"parseArrayDimension",value:function(){var e=this.getToken();if(e.type===this.ruleNames.INTEGER)return this.pos++,this.getIntLiteral(e);if(e.type===this.ruleNames.ID)return this.pos++,this.parseVariable(e);if(e.type===this.ruleNames.CLOSE_BRACE)return null;throw Hn.invalid_array_dimension(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_INTEGER],e)}},{key:"getIntLiteral",value:function(e){var t=e.text,n=Kn.createSourceInfo(e),r=new On(hn(t));return r.sourceInfo=n,r}},{key:"getRealLiteral",value:function(e){var t=Kn.createSourceInfo(e),n=new Ln(vn(e.text));return n.sourceInfo=t,n}},{key:"getStringLiteral",value:function(e){var t=e.text,n=Kn.createSourceInfo(e),r=new Pn(mn(t));return r.sourceInfo=n,r}},{key:"getCharLiteral",value:function(e){var t=e.text,n=new Bn(_n(t));return n.sourceInfo=Kn.createSourceInfo(e),n}},{key:"getBoolLiteral",value:function(e){var t=yn(e.text),n=new Dn(t);return n.sourceInfo=Kn.createSourceInfo(e),n}},{key:"parseArrayLiteral",value:function(e){if(!this.checkOpenCurly(!0)){var t=this.getToken();throw Hn.array_init_not_literal(Kn.createSourceInfo(t))}var n=this.getToken();if(this.parsingArrayDimension>=2)throw Hn.array_exceeds_2d(Kn.createSourceInfo(n));this.pos+=1,this.parsingArrayDimension+=1,this.consumeNewLines();var r;r=this.checkOpenCurly(!0)?this.parseVectorList(e):this.parseExpressionList(),this.consumeNewLines(),this.checkCloseCurly();var i=this.getToken();this.pos+=1,this.parsingArrayDimension-=1;var o=Kn.createSourceInfoFromList(n,i),a=1;r[0]instanceof Gn?a+=1:1==r.length&&console.log("Talvez uma variável seja uma melhor opção");var s=new An(e,a),u=new Gn(s,r);return u.sourceInfo=o,u}},{key:"parseVectorList",value:function(e){for(var t=[],n=null;;){this.checkOpenCurly();var r=this.getToken();if(this.parsingArrayDimension>=2)throw Hn.array_exceeds_2d(Kn.createSourceInfo(r));this.pos+=1,this.parsingArrayDimension+=1,this.consumeNewLines();var i=this.parseExpressionList();this.consumeNewLines(),this.checkCloseCurly();var o=this.getToken();this.pos+=1,this.parsingArrayDimension-=1;var a=Kn.createSourceInfoFromList(r,o);if(null==n)n=i.length;else if(n!==i.length){var s=this.inputStream.substring(r.offset,o.offset+o.text.length);throw Hn.invalid_matrix_literal_line(s,a)}var u=new An(e,1),c=new Gn(u,i);if(c.sourceInfo=a,t.push(c),this.getToken().type!==this.ruleNames.COMMA)break;this.pos+=1,this.consumeNewLines()}return 1==t.length&&console.log("Talvez um vetor seja uma melhor opção"),t}},{key:"parseVariable",value:function(e){var t=Kn.createSourceInfo(e),n=new Fn(e.text);return n.sourceInfo=t,n}},{key:"parseFunction",value:function(){this.pushScope(e.FUNCTION);var t=[],n=this.getToken();if(n.type!==this.ruleNames.RK_FUNCTION)return null;this.pos++;var r=this.parseType(),i=0;this.checkOpenBrace(!0)&&(this.pos++,this.checkCloseBrace(),this.pos++,i++,this.checkOpenBrace(!0)&&(this.pos++,this.checkCloseBrace(),this.pos++,i++));var o=this.getToken(),a=this.parseID();this.checkFunctionDuplicate(a,o),this.checkOpenParenthesis(),this.pos++,this.consumeNewLines(),this.checkCloseParenthesis(!0)||(t=this.parseFormalParameters(),this.consumeNewLines(),this.checkCloseParenthesis()),this.pos++,this.consumeNewLines();var s=this.parseCommandBlock(),u=r;i>0&&(u=new An(r,i));var c=new ge(a,u,t,s);if(null===a&&!c.isMain)throw Hn.invalid_main_return(nr.getMainFunctionName(),this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_VOID],n.line);if(c.isMain&&0!==t.length)throw Hn.main_parameters();return this.popScope(),c.sourceInfo=Kn.createSourceInfo(o),c}},{key:"parseFormalParameters",value:function(){for(var e=[];;){var t=0,n=!1,r=this.parseType(),i=this.getToken();i.type===this.ruleNames.RK_REFERENCE&&(n=!0,this.pos+=1,i=this.getToken());var o=this.parseID();this.checkVariableDuplicate(o,i),this.checkOpenBrace(!0)&&(this.pos+=1,t+=1,this.checkCloseBrace(),this.pos+=1,this.checkOpenBrace(!0)&&(this.pos+=1,t+=1,this.checkCloseBrace(),this.pos+=1));var a;a=t>0?new An(r,t):r;var s=new ke(a,o,n);if(s.sourceInfo=Kn.createSourceInfo(i),e.push(s),this.getToken().type!==this.ruleNames.COMMA)break;this.pos++,this.consumeNewLines()}return e}},{key:"parseID",value:function(){var t=this.getToken();if(t.type!==this.ruleNames.ID)throw Hn.id_missing(t);return this.pos++,this.insideScope(e.FUNCTION)&&t.text===nr.getMainFunctionName()?null:t.text}},{key:"parseMaybeLibID",value:function(){var e=this.getToken();if(e.type!==this.ruleNames.ID)throw Hn.id_missing(e);if(this.getToken(this.pos+1).type===this.ruleNames.DOT){this.pos+=2;var t=this.getToken();if(t.type!==this.ruleNames.ID)throw Hn.id_missing(t);return this.pos++,"".concat(e.text,".").concat(t.text)}return this.pos++,e.text}},{key:"parseType",value:function(){var t=this.getToken();if(t.type===this.ruleNames.ID&&this.insideScope(e.FUNCTION))return ye.VOID;if(t.type===this.ruleNames.RK_VOID&&this.insideScope(e.FUNCTION))return this.pos++,ye.VOID;if(this.isVariableType(t))switch(this.pos++,t.type){case this.ruleNames.RK_INTEGER:return ye.INTEGER;case this.ruleNames.RK_BOOLEAN:return ye.BOOLEAN;case this.ruleNames.RK_REAL:return ye.REAL;case this.ruleNames.RK_STRING:return ye.STRING;case this.ruleNames.RK_CHARACTER:return ye.CHAR}throw Hn.invalid_type(this.getTypeArray(),t)}},{key:"parseCommandBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=[],n=[],r=!1;this.checkOpenCurly(e)&&(this.pos++,r=!0),this.consumeNewLines();for(var i=!1;;){var o=this.parseCommand();if(null===o)break;if(-1!==o)if(o instanceof Array){if(i){var a=this.getToken(this.pos-1);throw Hn.invalid_var_declaration(a)}t=t.concat(o)}else i=!0,n.push(o)}return this.consumeNewLines(),r&&(this.checkCloseCurly(),this.pos++,this.consumeNewLines()),new be(t,n)}},{key:"parseCommand",value:function(){var t=this.getToken();if(this.isVariableType(t)){if(!this.insideScope(e.FUNCTION))throw Hn.invalid_var_declaration(t);this.pushScope(e.BASE);var n=this.parseType();this.popScope();var r=this.parseDeclaration(n);return this.checkEOS(),this.pos++,r}if(t.type===this.ruleNames.ID)return this.parseIDCommand();if(t.type===this.ruleNames.DOT)throw Hn.invalid_syntax(t.text,t.line,t.col);if(t.type===this.ruleNames.RK_RETURN)return this.parseReturn();if(t.type===this.ruleNames.RK_WHILE||t.type===this.ruleNames.RK_WHILE_ALT)return this.parseWhile();if(t.type===this.ruleNames.RK_FOR||t.type===this.ruleNames.RK_FOR_ALT)return this.parseFor();if(t.type===this.ruleNames.RK_BREAK){if(!this.insideScope(e.BREAKABLE))throw Hn.invalid_break_command(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_BREAK],t);return this.parseBreak()}return t.type===this.ruleNames.RK_SWITCH?this.parseSwitchCase():t.type===this.ruleNames.RK_DO?this.parseRepeatUntil():t.type===this.ruleNames.RK_IF?this.parseIfThenElse():this.checkEOS(!0)?(this.pos++,-1):null}},{key:"parseSwitchCase",value:function(){var t=this.getToken();this.pushScope(e.BREAKABLE),this.pos++,this.checkOpenParenthesis(),this.pos++,this.consumeNewLines();var n=this.parseExpressionOR();this.consumeNewLines(),this.checkCloseParenthesis(),this.pos++,this.consumeNewLines(),this.checkOpenCurly(),this.pos++,this.consumeNewLines();var r=this.parseCases();this.consumeNewLines(),this.checkCloseCurly(),this.pos++,this.consumeNewLines(),this.popScope();var i=new Ee(n,r);return i.sourceInfo=Kn.createSourceInfo(t),i}},{key:"parseRepeatUntil",value:function(){var t=this.getToken();this.pos++,this.consumeNewLines(),this.pushScope(e.BREAKABLE);var n=this.parseCommandBlock();this.consumeNewLines();var r=this.getToken();if(r.type!==this.ruleNames.RK_DO_UNTIL)throw Hn.token_missing_one(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_DO_UNTIL],r);this.pos++,this.checkOpenParenthesis(),this.pos++,this.consumeNewLines();var i=this.parseExpressionOR();this.consumeNewLines(),this.checkCloseParenthesis(),this.pos++,this.checkEOS(),this.popScope();var o=new we(i,n);return o.sourceInfo=Kn.createSourceInfo(t),o}},{key:"parseIfThenElse",value:function(){this.insideScope(e.BREAKABLE)?this.pushScope(e.BREAKABLE):this.pushScope(e.COMMAND);var t=this.getToken();this.pos++,this.checkOpenParenthesis(),this.pos++,this.consumeNewLines();var n=this.parseExpressionOR();this.consumeNewLines(),this.checkCloseParenthesis(),this.pos++,this.consumeNewLines();var r=this.parseCommandBlock();if(this.getToken().type===this.ruleNames.RK_ELSE){this.pos++,this.consumeNewLines();var i=this.getToken(),o=null;if(this.checkOpenCurly(!0))o=this.parseCommandBlock();else{if(i.type!==this.ruleNames.RK_IF)throw Hn.token_missing_list([this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_IF],"{"],i);o=this.parseIfThenElse()}this.popScope();var a=new xe(n,r,o);return a.sourceInfo=Kn.createSourceInfo(t),a}this.popScope();var s=new xe(n,r,null);return s.sourceInfo=Kn.createSourceInfo(t),s}},{key:"parseFor",value:function(){this.pushScope(e.BREAKABLE);var t=this.getToken();this.pos+=1;var n=this.getToken(),r=this.parseID(),i=new Fn(r);i.sourceInfo=Kn.createSourceInfo(n);var o=this.parseForParameters(this.ruleNames.RK_FOR_FROM),a=this.parseForParameters(this.ruleNames.RK_FOR_TO),s=this.parseForParameters(this.ruleNames.RK_FOR_PASS);this.consumeNewLines();var u=this.parseCommandBlock();this.popScope();var c=new se(i,o,a,s,u);return c.sourceInfo=Kn.createSourceInfo(t),c}},{key:"parseWhile",value:function(){this.pushScope(e.BREAKABLE);var t=this.getToken();this.pos++,this.checkOpenParenthesis(),this.pos++,this.consumeNewLines();var n=this.parseExpressionOR();this.consumeNewLines(),this.checkCloseParenthesis(),this.pos++,this.consumeNewLines();var r=this.parseCommandBlock();this.popScope();var i=new ae(n,r);return i.sourceInfo=Kn.createSourceInfo(t),i}},{key:"parseBreak",value:function(){var e=this.getToken();this.pos++,this.checkEOS(),this.pos++;var t=new ee;return t.sourceInfo=Kn.createSourceInfo(e),t}},{key:"parseReturn",value:function(){var e=this.getToken();this.pos++;var t=null;this.checkEOS(!0)||(t=this.parseExpressionOR(),this.checkEOS()),this.pos++;var n=new te(t);return n.sourceInfo=Kn.createSourceInfo(e),n}},{key:"parseIDCommand",value:function(){var e=this.getToken(),t=this.parseMaybeLibID(),n=-1===t.indexOf(".");if(this.checkOpenBrace(!0)){this.pos++;var r,i=null;this.consumeNewLines(),r=this.parseExpression(),this.consumeNewLines(),this.checkCloseBrace(),this.pos++,this.checkOpenBrace(!0)&&(this.pos++,this.consumeNewLines(),i=this.parseExpression(),this.consumeNewLines(),this.checkCloseBrace(),this.pos++);var o=this.getToken();if(o.type!==this.ruleNames.ASSIGNMENT)throw Hn.token_missing_one("<-",o);this.pos++;var a=this.parseExpressionOR();this.checkEOS(),this.pos++;var s=new re(t,r,i,a);return s.sourceInfo=Kn.createSourceInfo(o),s}var u=this.getToken();if(n&&u.type===this.ruleNames.ASSIGNMENT){this.pos++;var c=this.parseExpressionOR();this.checkEOS(),this.pos++;var l=new ne(t,c);return l.sourceInfo=Kn.createSourceInfo(u),l}if(u.type===this.ruleNames.OPEN_PARENTHESIS){var f=this.parseFunctionCallCommand(t);return this.checkEOS(),this.pos++,f}throw n?Hn.token_missing_list(["<-","("],u):Hn.invalid_id_format(e)}},{key:"parseForParameters",value:function(e){if(e===this.ruleNames.RK_FOR_PASS&&this.checkOpenCurly(!0))return null;var t=this.getToken();if(t.type!==e){var n=this.ivprogLexer.getReservedKeys()[e];throw new Error("Error de sintaxe no comando repita_para: esperava-se "+n+" mas encontrou "+t.text)}this.pos+=1;var r=this.getToken(),i=!1,o=null;r.type===this.ruleNames.SUM_OP&&(i=!0,o=r.text,this.pos+=1,r=this.getToken());var a=null;if(r.type===this.ruleNames.ID?(a=new Fn(this.parseID())).sourceInfo=Kn.createSourceInfo(r):r.type===this.ruleNames.INTEGER&&(this.pos+=1,a=this.getIntLiteral(r)),null==a){var s=this.ivprogLexer.getReservedKeys()[e];throw new Error("Error de sintaxe no comando repeita_para: "+r.text+" não é compativel com o esperado para o paramentro "+s+". O valor deve ser um inteiro ou variável.")}return i&&(a=new Un(qn(o),a)),a}},{key:"parseCases",value:function(){var e=this.getToken();if(e.type!==this.ruleNames.RK_CASE)throw Hn.token_missing_one(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_CASE],e);if(this.pos++,this.getToken().type===this.ruleNames.RK_DEFAULT){this.pos++;var t=this.getToken();if(t.type!==this.ruleNames.COLON)throw Hn.token_missing_one(":",t);this.pos++,this.consumeNewLines();var n=this.parseCommandBlock(!0),r=new $e(null);return r.sourceInfo=Kn.createSourceInfo(e),r.setCommands(n.commands),[r]}var i=this.parseExpressionOR(),o=this.getToken();if(o.type!==this.ruleNames.COLON)throw Hn.token_missing_one(":",o);this.pos++,this.consumeNewLines();var a=this.parseCommandBlock(!0),s=new $e(i);return s.sourceInfo=Kn.createSourceInfo(e),s.setCommands(a.commands),this.getToken().type===this.ruleNames.RK_CASE?[s].concat(this.parseCases()):[s]}},{key:"parseExpressionOR",value:function(){for(var e=this.parseExpressionAND();this.getToken().type===this.ruleNames.RK_LOGICAL_OR;){var t=this.getToken();this.pos++;var n=qn("or");this.consumeNewLines();var r=this.parseExpressionAND(),i=new Mn(n,e,r);i.sourceInfo=Kn.createSourceInfo(t),e=i}return e}},{key:"parseExpressionAND",value:function(){for(var e=this.parseExpressionNot();this.getToken().type===this.ruleNames.RK_LOGICAL_AND;){var t=this.getToken();this.pos++;var n=qn("and");this.consumeNewLines();var r=this.parseExpressionNot(),i=new Mn(n,e,r);i.sourceInfo=Kn.createSourceInfo(t),e=i}return e}},{key:"parseExpressionNot",value:function(){if(this.getToken().type===this.ruleNames.RK_LOGICAL_NOT){var e=this.getToken();this.pos++;var t=qn("not"),n=this.parseExpressionRel(),r=new Un(t,n);return r.sourceInfo=Kn.createSourceInfo(e),r}return this.parseExpressionRel()}},{key:"parseExpressionRel",value:function(){for(var e=this.parseExpression();this.getToken().type===this.ruleNames.RELATIONAL_OPERATOR;){var t=this.getToken();this.pos++;var n=qn(t.text),r=this.parseExpression(),i=new Mn(n,e,r);i.sourceInfo=Kn.createSourceInfo(t),e=i}return e}},{key:"parseExpression",value:function(){for(var e=this.parseFactor();this.getToken().type===this.ruleNames.SUM_OP;){var t=this.getToken();this.pos++;var n=qn(t.text),r=this.parseFactor(),i=new Mn(n,e,r);i.sourceInfo=Kn.createSourceInfo(t),e=i}return e}},{key:"parseFactor",value:function(){for(var e=this.parseTerm();this.getToken().type===this.ruleNames.MULTI_OP;){var t=this.getToken();this.pos++;var n=qn(t.text),r=this.parseTerm(),i=new Mn(n,e,r);i.sourceInfo=Kn.createSourceInfo(t),e=i}return e}},{key:"parseTerm",value:function(){var e=this.getToken(),t=null,n=null;switch(e.type){case this.ruleNames.SUM_OP:return this.pos++,t=Kn.createSourceInfo(e),(n=new Un(qn(e.text),this.parseTerm())).sourceInfo=t,n;case this.ruleNames.INTEGER:return this.pos++,this.getIntLiteral(e);case this.ruleNames.REAL:return this.pos++,this.getRealLiteral(e);case this.ruleNames.STRING:return this.pos++,this.getStringLiteral(e);case this.ruleNames.CHARACTER:return this.pos++,this.getCharLiteral(e);case this.ruleNames.RK_TRUE:case this.ruleNames.RK_FALSE:return this.pos++,this.getBoolLiteral(e);case this.ruleNames.OPEN_CURLY:throw Hn.annonymous_array_literal(e);case this.ruleNames.ID:return this.parseIDTerm();case this.ruleNames.OPEN_PARENTHESIS:return this.parseParenthesisExp();default:throw Hn.invalid_terminal(e)}}},{key:"parseIDTerm",value:function(){var e=this.getToken(),t=this.parseMaybeLibID(),n=-1===t.indexOf(".");if(n&&this.checkOpenBrace(!0)){var r=null;this.pos++;var i=this.parseExpression(),o=null;this.consumeNewLines(),this.checkCloseBrace(),r=this.getToken(),this.pos++,this.checkOpenBrace(!0)&&(this.pos++,o=this.parseExpression(),this.consumeNewLines(),this.checkCloseBrace(),r=this.getToken(),this.pos++);var a=Kn.createSourceInfoFromList(e,r),s=new Sn(t,i,o);return s.sourceInfo=a,s}if(this.checkOpenParenthesis(!0))return this.parseFunctionCallExpression(t);if(n){var u=Kn.createSourceInfo(e),c=new Fn(t);return c.sourceInfo=u,c}throw Hn.invalid_id_format(e)}},{key:"getFunctionName",value:function(e){var t=nr.getInternalName(e);return null===t?e===nr.getMainFunctionName()?null:e:t}},{key:"parseFunctionCallExpression",value:function(e){var t=-1===e.indexOf(".")?1:3,n=this.getToken(this.pos-t),r=this.parseActualParameters(),i=this.getToken(this.pos-1),o=this.getFunctionName(e),a=Kn.createSourceInfoFromList(n,i),s=new Ae(o,r);return s.sourceInfo=a,s}},{key:"parseFunctionCallCommand",value:function(e){return this.parseFunctionCallExpression(e)}},{key:"parseParenthesisExp",value:function(){this.checkOpenParenthesis();var e=this.getToken();this.pos+=1,this.consumeNewLines();var t=this.parseExpressionOR();this.consumeNewLines(),this.checkCloseParenthesis();var n=this.getToken();return this.pos+=1,t.sourceInfo=Kn.createSourceInfoFromList(e,n),t.parenthesis=!0,t}},{key:"parseActualParameters",value:function(){if(this.checkOpenParenthesis(),this.pos++,this.checkCloseParenthesis(!0))return this.pos++,[];this.consumeNewLines();var e=this.parseExpressionList();return this.consumeNewLines(),this.checkCloseParenthesis(),this.pos++,e}},{key:"parseExpressionList",value:function(){for(var e=[];;){var t=this.parseExpressionOR();if(e.push(t),this.getToken().type!==this.ruleNames.COMMA)break;this.pos++,this.consumeNewLines()}return e}},{key:"getTypeArray",value:function(){var t=this;return(this.insideScope(e.FUNCTION)?this.functionTypes:this.variableTypes).map((function(e){return t.lexer.literalNames[e]}))}}],[{key:"createParser",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=j.getCurrentLexer(),i=new e(t,r);return n&&i.fill(),i}},{key:"BASE",get:function(){return 0}},{key:"FUNCTION",get:function(){return 1}},{key:"COMMAND",get:function(){return 2}},{key:"BREAKABLE",get:function(){return 4}},{key:"EOF_TOKEN",get:function(){return{text:null,line:-1,col:-1,value:null,offset:-1,lineBreaks:!1,type:"EOF"}}}]),e}();function Wn(e){return function(e){if(Array.isArray(e))return _(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zn(e){return e.times(pn.acos(-1)).div(180)}var Qn=Date.now();function Jn(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]===e)return n;return null}var Xn,er={$mathLib:{$sin:(Xn=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().mod(360),null,a=i.eq(90)?new pn(1):i.eq(180)?new pn(0):i.eq(270)?new pn(-1):pn.sin(Zn(i)),s=new In(ye.REAL,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]),new ge("$sin",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],Xn)),$cos:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().mod(360),a=null,i.eq(90)?a=new pn(0):i.eq(180)?a=new pn(-1):i.eq(270)&&(a=new pn(0)),a=pn.cos(Zn(i)),s=new In(ye.REAL,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$cos",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$tan:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.applyStore("x"),!(i=r.get().mod(360)).eq(90)&&!i.eq(270)){e.next=4;break}throw Nn.undefined_tanget_value(r.get().toNumber(),this.function_call_stack.pop());case 4:return a=pn.tan(Zn(i)),s=new In(ye.REAL,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$tan",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$sqrt:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.applyStore("x")).get().isNeg()){e.next=3;break}return e.abrupt("return",Promise.reject(Nn.negative_sqrt_value(this.function_call_stack.pop())));case 3:return i=r.get().sqrt(),a=new In(ye.REAL,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$sqrt",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$pow:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=t.applyStore("y"),a=r.get().pow(i.get()),s=new In(ye.REAL,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$pow",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1),new ke(new ce([ye.INTEGER,ye.REAL]),"y",!1)],e)}(),$log:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.applyStore("x")).get().isNegative()){e.next=3;break}return e.abrupt("return",Promise.reject(Nn.negative_log_value(this.function_call_stack.pop())));case 3:return i=pn.log10(r.get()),a=new In(ye.REAL,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$log",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$abs:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().abs(),a=new In(r.type,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$abs",new ce([ye.INTEGER,ye.REAL]),[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$negate:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().negated(),a=new In(r.type,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$negate",new ce([ye.INTEGER,ye.REAL]),[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$invert:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=vn(1).dividedBy(r.get()),a=new In(ye.REAL,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$invert",ye.REAL,[new ke(new ce([ye.INTEGER,ye.REAL]),"x",!1)],e)}(),$max:function(){var e=function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().map((function(e){return e.get()})),a=pn.max.apply(pn,Wn(i)),s=new In(r.type.innerType,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n=new An(new ce([ye.INTEGER,ye.REAL]),1),r=new be([],[new Re(e)]);return new ge("$max",new ce([ye.INTEGER,ye.REAL]),[new ke(n,"x",!1)],r)}(),$min:function(){var e=function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().map((function(e){return e.get()})),a=pn.min.apply(pn,Wn(i)),s=new In(r.type.innerType,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n=new An(new ce([ye.INTEGER,ye.REAL]),1),r=new be([],[new Re(e)]);return new ge("$min",new ce([ye.INTEGER,ye.REAL]),[new ke(n,"x",!1)],r)}(),$rand:function(){var e=2147483647,n=new be([],[new Re(function(){var n=t(o().mark((function t(n,r){var i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=(Qn=(16807*Qn+12345)%e)/(e-1),a=new In(ye.REAL,new pn(i)),n.insertStore("$",a),n.mode=Se.RETURN,t.abrupt("return",n);case 6:case"end":return t.stop()}}),t)})));return function(e,t){return n.apply(this,arguments)}}())]);return new ge("$rand",ye.REAL,[],n)}()},$ioLib:{$read:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f,p;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.input.requestInput();case 2:if(r=e.sent,i=t.applyStore("p1").type,a=null,s=null,e.prev=6,!i.isCompatible(ye.INTEGER)){e.next=12;break}s=hn(r.trim()).trunc(),a=ye.INTEGER,e.next=33;break;case 12:if(!i.isCompatible(ye.REAL)){e.next=17;break}s=vn(r.trim()),a=ye.REAL,e.next=33;break;case 17:if(!i.isCompatible(ye.BOOLEAN)){e.next=22;break}s=yn(r.trim()),a=ye.BOOLEAN,e.next=33;break;case 22:if(!i.isCompatible(ye.STRING)){e.next=27;break}s=mn(r),a=ye.STRING,e.next=33;break;case 27:if(!i.isCompatible(ye.CHAR)){e.next=32;break}s=_n(r),a=ye.CHAR,e.next=33;break;case 32:throw new Error("!!!!Critical error: Unknown type in readFunction!!!!");case 33:e.next=47;break;case 35:if(e.prev=35,e.t0=e.catch(6),this.mode!=Se.ABORT){e.next=40;break}return t.mode=Se.RETURN,e.abrupt("return",t);case 40:if(u=i.stringInfo()[0],!((c=t.getStoreObject("p1")).getReferenceDimension()>0)){e.next=46;break}throw l=c.type.stringInfo()[0],f=c.getReferenceDimension(),Nn.invalid_read_type_array(r,u.type,u.dim,c.getRefObj(),l.type,f,this.function_call_stack.pop());case 46:throw Nn.invalid_read_type(r,u.type,u.dim,c.getRefObj(),this.function_call_stack.pop());case 47:return p=new In(a,s),t.updateStore("p1",p),t.mode=Se.RETURN,e.abrupt("return",t);case 51:case"end":return e.stop()}}),e,this,[[6,35]])})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$read",ye.VOID,[new ke(ye.ALL,"p1",!0)],e)}(),$write:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=t.applyStore("p1.0"),i=r.get(),a=1;a=r.get().length)){e.next=4;break}throw Nn.invalid_string_index(i.get().toNumber(),r.get(),this.function_call_stack.pop());case 4:return a=new In(ye.CHAR,r.get().charAt(i.get().toNumber())),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$charAt",ye.CHAR,[new ke(ye.STRING,"str",!1),new ke(ye.INTEGER,"index",!1)],e)}()},$arrayLib:{$numElements:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("vector"),i=new In(ye.INTEGER,hn(r.lines)),t.mode=Se.RETURN,t.insertStore("$",i),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$numElements",ye.INTEGER,[new ke(new An(ye.ALL,1),"vector",!1)],e)}(),$matrixLines:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("matrix"),i=new In(ye.INTEGER,hn(r.lines)),t.mode=Se.RETURN,t.insertStore("$",i),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$matrixLines",ye.INTEGER,[new ke(new An(ye.ALL,2),"matrix",!1)],e)}(),$matrixColumns:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("matrix"),i=new In(ye.INTEGER,hn(r.columns)),t.mode=Se.RETURN,t.insertStore("$",i),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$matrixColumns",ye.INTEGER,[new ke(new An(ye.ALL,2),"matrix",!1)],e)}()},$langLib:{$isReal:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("str"),i=Yn.createParser(r.get()),a=!1;try{i.parseTerm()instanceof Ln&&(a=!0)}catch(e){}return s=new In(ye.BOOLEAN,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$isReal",ye.BOOLEAN,[new ke(ye.STRING,"str",!1)],e)}(),$isInt:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("str"),i=Yn.createParser(r.get()),a=!1;try{i.parseTerm()instanceof On&&(a=!0)}catch(e){}return s=new In(ye.BOOLEAN,a),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$isInt",ye.BOOLEAN,[new ke(ye.STRING,"str",!1)],e)}(),$isBool:function(){var e=new be([],[new Re((function(e,t){var n=e.applyStore("str"),r=Yn.createParser(n.get()),i=!1;try{r.parseTerm()instanceof Dn&&(i=!0)}catch(e){}var o=new In(ye.BOOLEAN,i);return e.insertStore("$",o),e.mode=Se.RETURN,e}))]);return new ge("$isBool",ye.BOOLEAN,[new ke(ye.STRING,"str",!1)],e)}(),$castReal:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("val"),i=r.get(),e.t0=r.type.ord,e.next=e.t0===ye.INTEGER.ord?5:e.t0===ye.STRING.ord?10:22;break;case 5:return i=i.toNumber(),a=new In(ye.REAL,vn(i)),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 10:if(s=Yn.createParser(i),e.prev=11,!((u=s.parseTerm())instanceof Ln)){e.next=18;break}return c=new In(ye.REAL,vn(u.value)),t.insertStore("$",c),t.mode=Se.RETURN,e.abrupt("return",t);case 18:e.next=22;break;case 20:e.prev=20,e.t1=e.catch(11);case 22:throw l=ye.REAL.stringInfo(),f=l[0],Nn.invalid_type_conversion(i,f.type,f.dim);case 25:case"end":return e.stop()}}),e,null,[[11,20]])})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$castReal",ye.REAL,[new ke(new ce([ye.INTEGER,ye.STRING]),"val",!1)],e)}(),$castInt:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f,p;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("val"),i=r.get(),e.t0=r.type.ord,e.next=e.t0===ye.REAL.ord?5:e.t0===ye.CHAR.ord?10:e.t0===ye.STRING.ord?14:26;break;case 5:return i=i.toNumber(),a=new In(ye.INTEGER,hn(Math.floor(i))),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 10:return s=new In(ye.INTEGER,hn(i.charCodeAt(0))),t.insertStore("$",s),t.mode=Se.RETURN,e.abrupt("return",t);case 14:if(u=Yn.createParser(i),e.prev=15,!((c=u.parseTerm())instanceof On)){e.next=22;break}return l=new In(ye.INTEGER,hn(c.value)),t.insertStore("$",l),t.mode=Se.RETURN,e.abrupt("return",t);case 22:e.next=26;break;case 24:e.prev=24,e.t1=e.catch(15);case 26:throw f=ye.INTEGER.stringInfo(),p=f[0],Nn.invalid_type_conversion(i,p.type,p.dim);case 29:case"end":return e.stop()}}),e,null,[[15,24]])})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$castInt",ye.INTEGER,[new ke(new ce([ye.REAL,ye.STRING,ye.CHAR]),"val",!1)],e)}(),$castBool:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a,s,u,c,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.applyStore("str"),i=r.get(),a=Yn.createParser(i),e.prev=3,!((s=a.parseTerm())instanceof Dn)){e.next=10;break}return u=new In(ye.BOOLEAN,s.value),t.insertStore("$",u),t.mode=Se.RETURN,e.abrupt("return",t);case 10:e.next=14;break;case 12:e.prev=12,e.t0=e.catch(3);case 14:throw c=ye.BOOLEAN.stringInfo(),l=c[0],Nn.invalid_type_conversion(i,l.type,l.dim);case 17:case"end":return e.stop()}}),e,null,[[3,12]])})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$castBool",ye.BOOLEAN,[new ke(ye.STRING,"str",!1)],e)}(),$castString:function(){var e=new be([],[new Re(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("str"),i=xn(r.get(),r.type),a=new In(ye.STRING,i),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}())]);return new ge("$castString",ye.STRING,[new ke(ye.ALL,"str",!1)],e)}(),$castChar:function(){var e=new be([],[new Re((function(e,t){var n=255&e.applyStore("charCode").get().toNumber(),r=String.fromCharCode(n),i=new In(ye.CHAR,r);return e.insertStore("$",i),e.mode=Se.RETURN,e}))]);return new ge("$castChar",ye.CHAR,[new ke(ye.INTEGER,"charCode",!1)],e)}()}},tr=function(){for(var e={},t=0;t2&&void 0!==arguments[2]&&arguments[2];return a(this,i),r.call(this,e,t,n)}return l(i,[{key:"translateType",value:function(e,t){var n=this.getUI("type_".concat(e));return 0===t?n:t>1?this.getUI("matrix_info_string",[n]):this.getUI("vector_info_string",[n])}},{key:"translateOp",value:function(e){switch(e.ord){case zn.AND.ord:case zn.OR.ord:case zn.NOT.ord:return this.getUI("logic_operator_".concat(e.value));default:return e.value}}},{key:"translateInternalFunction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null==t?nr.getLocalName(e):nr.getLocalName("".concat(t,".").concat(e))}}]),i}(U.LocalizedStrings))(j,J),ir=function(){return rr};function or(e,t){if(0==e.length)return t.length;if(0==t.length)return e.length;var n,r,i=[];for(n=0;n<=t.length;n++)i[n]=[n];for(r=0;r<=e.length;r++)i[0][r]=r;for(n=1;n<=t.length;n++)for(r=1;r<=e.length;r++)t.charCodeAt(n-1)==e.charCodeAt(r-1)?i[n][r]=i[n-1][r-1]:i[n][r]=Math.min(i[n-1][r-1]+1,Math.min(i[n][r-1]+1,i[n-1][r]+1));return i[t.length][e.length]}var ar=null;function sr(e){e.preventDefault();var t=e.currentTarget.dataset.page;null!=ar&&ar.close(),(ar=window.open("","DetailWindow","width=550,height=600")).document.open(),ar.document.write(t),ar.document.close()}function ur(e){return cr.apply(this,arguments)}function cr(){return(cr=t(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){return setTimeout(e,t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return fr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function fr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0})).map((function(e){return e.split(",")})).map((function(e){var t={};return e.forEach((function(e,r){return t[n[r]]=e})),t})),p=f.reduce(i,new Map),d=function(){var e=t(o().mark((function e(t){var n,r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(c).concat(t.file),r=s.find((function(e){return e.webkitRelativePath==n})),e.next=4,r.text();case 4:return i=e.sent,e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),h={},m=0,p.forEach((function(e,n){var i=[];e.forEach(function(){var e=t(o().mark((function e(a,s){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=a.sort((function(e,t){return parseInt(e.timestamp)-parseInt(t.timestamp)})),m++,a.forEach(function(){var e=t(o().mark((function e(t,a,u){var c,l,f,p,h,_,v,y,g,x;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(m++,(c={}).grade=Math.max(0,parseFloat(t.grade)),c.timestamp=parseInt(t.timestamp),c.student_id=s,c.TES=0,c.DES=0,c["D/T"]=0,l="",!(a>0)){e.next=19;break}return c.TES=parseInt(t.timestamp)-parseInt(u[a-1].timestamp),e.next=13,d(u[a-1]);case 13:if(f=e.sent,1!=(p=window.ivprogCore.prepareActivityToStudentHelper(f).getOrElse(1))){e.next=18;break}return console.error("A submission from ".concat(s," to ").concat(n," is invalid")),e.abrupt("return");case 18:l=r(p.algorithmInIlm);case 19:return e.next=21,d(t);case 21:if(h=e.sent,2!=(_=window.ivprogCore.prepareActivityToStudentHelper(h).getOrElse(2))){e.next=26;break}return console.error("A submission from ".concat(s," to ").concat(n," is invalid")),e.abrupt("return");case 26:v=r(_.algorithmInIlm),""===l&&(y=JSON.parse(h.split("::logs::")[1]),null==(g=y[0])?c.TES=0:4===g.length?c.TES=parseInt(t.timestamp)-Math.floor(parseInt(g[2])/1e3):c.TES=parseInt(t.timestamp)-Math.floor(parseInt(g[1])/1e3)),c.DES=window.ivprogCore.levenshteinDistance(l,v),x=0===c.TES?0:c.DES/c.TES,c["D/T"]=isNaN(x)?0:x,i.push(c),m--;case 33:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()),m--;case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),h[n]=i})),y=setInterval((function(){if(0==m)for(var e in clearInterval(y),h){var t="",n="student_id,";n+=v(e);var r,i=lr(h[e]);try{for(i.s();!(r=i.n()).done;){var o=r.value;t+="".concat(o.student_id,","),t+="".concat(o.TES,","),t+="".concat(o.DES,","),t+="".concat(o.grade,","),t+="".concat(o["D/T"],","),t+="".concat(o.timestamp),t+="\n"}}catch(e){i.e(e)}finally{i.f()}_("".concat(e,".csv"),"".concat(n,"\n").concat(t))}}),1e3);case 15:case"end":return a.stop()}}),a)}))))}var dr="var",hr="const",mr="relational",_r="logic",vr="arithmetic";function yr(e,t){switch(e){case vr:case mr:return t.value;case _r:return 11===t.ord?"and":12===t.ord?"or":"not"}}function gr(e){switch(e.ord){case 0:case 1:case 2:case 3:case 4:return vr;case 5:case 6:case 7:case 8:case 9:case 10:return mr;default:return _r}}function xr(e){var t=e.commands.map(wr),n=e.isDefault?null:Tr(e.expression);return{type:"switchcase",line:e.sourceInfo.line,expression:n,commands:t}}function br(e){var t=Tr(e.condition),n=e.ifTrue.commands.map(wr),r=[];return e.ifFalse&&(r=e.ifFalse instanceof be?e.ifFalse.commands.map(wr):[br(e.ifFalse)]),{type:"iftrue",expression:t,ifTrue:n,ifFalse:r}}function wr(e){var t,n,r,i,o,a=null;if(e instanceof Ae)a=function(e){var t=e.id;-1!==t.indexOf(".")&&(t=t.split(".")[1]);var n=e.actualParameters.map(Tr);if("$write"===t){var r=n[n.length-1][0],i=r.value&&null!==r.value.match(/^\n$/);return{type:"writer",newLine:i,content:i?n.slice(0,n.length-1):n}}return"$read"===t?{type:"reader",variable:n[0]}:{type:"functioncall",parameters_list:n,name:e.id}}(e);else if(e instanceof ne)a=function(e){var t=null;if(e instanceof re){var n=Tr(e.line),r="vector",i=null;e.column&&(r="matrix",i=Tr(e.column)),t=[{instance:"expression",type:dr,class:r,column:i,line:n,value:e.id}]}else t=[{instance:"expression",type:dr,value:e.id}];return{type:"attribution",variable:t,expression:Tr(e.expression)}}(e);else if(e instanceof xe)a=br(e);else if(e instanceof ae)i=Tr((r=e).expression),o=r.commands.map(wr),a={type:r.testFirst?"whiletrue":"dowhiletrue",expression:i,commands:o};else if(e instanceof ee)a={type:"break"};else if(e instanceof te)a={type:"return",expression:Tr(e.expression)};else if(e instanceof Ee)a={type:"switch",expression:Tr((n=e).expression),cases:n.cases.map(xr)};else{if(!(e instanceof se))throw new Error("not implemented");a={type:"repeatNtimes",var_attribution:Tr((t=e).for_id),var_initial:Tr(t.for_from),condition:Tr(t.for_to),step_expression:t.for_pass?Tr(t.for_pass):[],commands:t.commands.map(wr)}}return a.line=e.sourceInfo.line,a}function Er(e){var t={name:e.name,line:e.sourceInfo.line,return_type:"",return_dimensions:0,parameters_list:[],variables_list:[],commands:[]};return e.returnType instanceof An?(t.return_type=e.returnType.innerType.value,t.return_dimensions=e.returnType.dimensions):t.return_type=e.returnType.value,t.parameters_list=e.formalParameters.map($r),t.variables_list=e.variablesDeclarations.map(Rr),t.commands=e.commands.map(wr),t}function $r(e){var t={name:e.id,line:e.sourceInfo.line,type:"",rows:0,columns:0,dimension:0,value:0,is_const:!1,reference:e.byRef};return e.type instanceof An?(t.type=e.type.innerType.value,t.dimension=e.type.dimensions):t.type=e.type.value,t}function Rr(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n={name:e.id,line:e.sourceInfo.line,type:"",rows:0,columns:0,dimension:0,value:0,is_const:!1};if(n.is_const=t&&e.isConst,e instanceof oe){var r=Tr(e.lines).pop();if(n.type=e.type.innerType.value,e.isVector){n.columns=r.value,n.dimension=1;var i=e.initial.value.map((function(e){return kr(e)}));n.value=i}else{var o=Tr(e.columns).pop();n.dimension=2,n.rows=r.value,n.columns=o.value;var a=e.initial.value.map((function(e){return e.value.map((function(e){return kr(e)}))}));n.value=a}}else n.type=e.type.value,n.value=kr(e.initial);return n}function kr(e){if(e instanceof Un){var t=kr(e.left);if(gr(e.op)!==vr)throw new Error("invalid variable initial value: "+e.toString());return"".concat(e.op.value).concat(t)}if(e instanceof Dn)return gn(e.value);if(e instanceof Cn){var n=e.value;return e.value.toNumber&&(n=ye.REAL.isCompatible(e.type)&&0==e.value.decimalPlaces()?Number(e.value.toFixed(2)):e.value.toNumber()),n}throw new Error("invalid variable initial value: "+e.toString())}function Tr(e){var t;if(e instanceof Fn)t=[{instance:"expression",type:dr,value:e.id}];else if(e instanceof Ae){var n={instance:"expression",type:"function",value:e.id},r=e.actualParameters.map((function(e){return Tr(e)}));n.params=r,t=[n]}else if(e instanceof Un){var i=Tr(e.left),o=gr(e.op);t=[{instance:"operator",type:o,value:yr(o,e.op)}].concat(Wn(i))}else if(e instanceof Mn){var a=Tr(e.left),s=Tr(e.right),u=gr(e.op),c=yr(u,e.op);t=[].concat(Wn(a),[{instance:"operator",type:u,value:c}],Wn(s))}else if(e instanceof Sn){var l=Tr(e.line),f="vector",p=null;e.column&&(f="matrix",p=Tr(e.column)),t=[{instance:"expression",type:dr,class:f,column:p,line:l,value:e.id}]}else if(e instanceof Dn){var d=e.value;t=[{instance:"expression",class:"simple",type:hr,value:gn(d)}]}else{var h=e.value;e.value.toNumber&&(h=ye.REAL.isCompatible(e.type)&&0==e.value.decimalPlaces()?Number(e.value.toFixed(2)):e.value.toNumber()),t=[{instance:"expression",class:"simple",type:hr,value:h}]}return e.parenthesis?["("].concat(Wn(t),[")"]):t}function Nr(e){return Tr(Yn.createParser(e).parseExpressionOR())}function Ir(e){for(var t=Yn.createParser(e,!1),n=new Map,r=[],i=0,o=Array.from(t.lexer.reset(e));i=5&&e.ord<=10)return ye.BOOLEAN}return ye.UNDEFINED}return s}catch(e){if(e instanceof TypeError)return ye.UNDEFINED;throw e}}function Mr(e,t){try{if(t instanceof ce){for(var n=[],r=0;ri.id?t=r:n=r}}},{key:"getAddressAt",value:function(e){return this.data[e]}},{key:"findIndex",value:function(e){for(var t=0,n=this.data.length;ti.id?t=r:n=r}return-1}},{key:"updateAddress",value:function(e,t){var n=this.findIndex(e);if(-1===n)throw new Error("Invalid address..."+e);this.data[n].value=t}},{key:"clear",value:function(){for(var e=0;e2&&void 0!==arguments[2]&&arguments[2];a(this,e),K(this,"_type",void 0),K(this,"_loc_address",void 0),K(this,"_readOnly",void 0),K(this,"_id",void 0),this._loc_address=n,this._type=t,this._readOnly=r,this._id=void 0}return l(e,[{key:"setID",value:function(e){this._id=e}},{key:"id",get:function(){return this._id}},{key:"inStore",get:function(){return null!==this.id}},{key:"type",get:function(){return this._type}},{key:"value",get:function(){var e=zr.find(this._loc_address);if(null!=e)return e.value;throw new Error("!!!Critical Error: variable "+this.id+" does not have a valid address. Loc-Address "+this.locAddress)}},{key:"number",get:function(){throw new Error("DOT NOT USE THIS PROPERTY!")}},{key:"readOnly",get:function(){return this._readOnly},set:function(e){this._readOnly=e}},{key:"isCompatible",value:function(e){return this.type.isCompatible(e.type)}},{key:"destroy",value:function(){return zr.deallocate(this._loc_address)}},{key:"locAddress",get:function(){return this._loc_address}}]),e}();var jr=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),K(d(t=r.call(this,e.type,e.getRefAddress(),!1)),"refObj",void 0),K(d(t),"reference_dimension",void 0),t.refObj=e.id,t.reference_dimension=e.getReferenceDimension(),t}return l(i,[{key:"isRef",get:function(){return!0}},{key:"getRefObj",value:function(){return this.refObj}},{key:"getReferenceDimension",value:function(){return this.reference_dimension}},{key:"destroy",value:function(){return!1}}]),i}(qr);var Vr=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e,t,n,o,s){var u,c=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return a(this,i),(u=r.call(this,e,t,s,c)).line=n,u.column=o,u}return l(i)}(In),Hr=function(){function e(t,n,r,i,o){var s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];a(this,e),K(this,"type",void 0),K(this,"id",void 0),K(this,"isConst",void 0),K(this,"lines",void 0),K(this,"columns",void 0),K(this,"values",void 0),this.type=t,this.id=o,this.isConst=s,this.values=n,this.lines=r,this.columns=i}return l(e,[{key:"get",value:function(){return this.values}},{key:"getAt",value:function(t,n){if(console.log("Column ",n),this.isVector()){if(null!=n)throw new Error(this.id+" is not a matrix!");n=t,t=0}else if(null==n){for(var r=[],i=0;i4&&void 0!==arguments[4]&&arguments[4];return a(this,i),(s=r.call(this,e,-1,u))._lines=t,s._columns=n,s.loc_addresses=o,s}return l(i,[{key:"lines",get:function(){return this._lines}},{key:"columns",get:function(){return this._columns}},{key:"isCompatible",value:function(e){if(e instanceof Hr){var t=null==e.columns?0:e.columns;if(this.lines===e.lines&&this.columns===t)return Wr(m(i.prototype),"isCompatible",this).call(this,e)}return!1}},{key:"isVector",get:function(){return 1===this.type.dimensions}},{key:"value",get:function(){for(var e=[],t=0;t=r.columns&&(a=0,o+=1),new Vr(i.innerType,e,o,a++,r.id,r.readOnly))}));n=new Hr(i,s,r.lines,r.columns,t.id,t.readOnly)}else n=new In(t.type,t.value,t.id,t.readOnly);return n}},{key:"updateStore",value:function(e,t){if(this.store.has(e)){var n=this.store.get(e);if(n.readOnly)throw new Error("Cannot change value of a read only variable: "+e);if(n instanceof Zr){var r=t;if(n.isCompatible(r)){if(n.isVector)r.get().forEach((function(e,t){n.setAt(e,t,void 0)}));else{var i=0,o=0;r.get().forEach((function(e){n.setAt(e,i,o),(o+=1)>=n.columns&&(i+=1,o=0)}))}return this}}else if(n.isCompatible(t)){var a=n.locAddress;return zr.updateAddress(a,t.get()),this}var s=n.type,u=t.type;throw new Error("".concat(s.value," is not compatible with type ").concat(u.value," given"))}if(null!=this.nextStore)return this.nextStore.updateStore(e,t),this;throw new Error("Variable ".concat(e," not found."))}},{key:"updateStoreArray",value:function(e,t,n,r){if(this.store.has(e)){var i=this.store.get(e);if(i.readOnly)throw new Error("Cannot change value of a read only variable: "+e);if(!(i instanceof Zr))throw new Error("Cannot update a non-array variable using updateStoreArray");if(t instanceof Hr){var o=t.get();if(i.isVector&&t.isVector())for(var a=0;a0)for(var a=0;a1?t.insertSymbol(e.id,{id:e.id,lines:-1,columns:-1,type:e.type}):t.insertSymbol(e.id,{id:e.id,lines:-1,columns:null,type:e.type}):t.insertSymbol(e.id,{id:e.id,type:e.type})})),this.assertDeclarations(e.variablesDeclarations);var n=e.returnType.isCompatible(ye.VOID);if(!this.assertReturn(e,n))throw Nn.function_no_return(e.name);this.popMap()}},{key:"assertReturn",value:function(e,t){var n=this;return e.commands.reduce((function(r,i){return n.checkCommand(e.returnType,i,t)||r}),t)}},{key:"checkCommand",value:function(e,t,n){if(t instanceof ae){if(!this.evaluateExpressionType(t.expression).isCompatible(ye.BOOLEAN))throw Nn.loop_condition_type_full(t.expression.toString(),t.sourceInfo);return this.checkCommands(e,t.commands,n),!1}if(t instanceof se){if(!this.evaluateExpressionType(t.for_id).isCompatible(ye.INTEGER))throw Nn.invalid_for_variable(t.for_id,t.sourceInfo);if(!this.evaluateExpressionType(t.for_from).isCompatible(ye.INTEGER))throw Nn.invalid_for_from(t.for_from,t.sourceInfo);if(!this.evaluateExpressionType(t.for_to).isCompatible(ye.INTEGER))throw Nn.invalid_for_to(t.for_to,t.sourceInfo);if(null!=t.for_pass&&!this.evaluateExpressionType(t.for_pass).isCompatible(ye.INTEGER))throw Nn.invalid_for_pass(t.for_pass,t.sourceInfo);return this.checkCommands(e,t.commands,n),!1}if(t instanceof Ee){for(var r=this.evaluateExpressionType(t.expression),i=n,o=!1,a=0;at.length||n.length!==t.length&&!e.hasVariadic())throw Nn.invalid_parameters_size_full(e.name,t.length,e.formalParameters.length,null);for(var r=0,i=0;rr.length)){t.next=4;break}throw Nn.invalid_parameters_size(s,n.length,r.length);case 4:c=0,l=0;case 5:if(!(c5&&void 0!==b[5]?b[5]:0,e.next=3,this.evaluateExpression(i,r);case 3:if(u=e.sent,c=!1,n.type.isCompatible(u.type)){e.next=11;break}if(!q.enable_type_casting||n.byRef||!ei.canImplicitTypeCast(n.type,u.type)){e.next=10;break}c=!0,e.next=11;break;case 10:throw Nn.invalid_parameter_type(t,r.toString());case 11:if(!n.byRef||u.inStore()){e.next=13;break}throw Nn.invalid_ref(t,r.toString());case 13:return n.byRef?(l=i.getStoreObject(u.id),f=null,u instanceof Hr?(p=u.get(),d=u.type,h=p.map((function(e){return l.getLocAddressOf(e.line,e.column)})),m=u.isVector()?0:u.columns,f=new Jr(d,p,h,u.lines,m,l.id)):u instanceof Vr?(_=u.line,v=u.column,(f=new Qr(u.type,u.get(),l.getLocAddressOf(_,v),l.id)).setReferenceDimension(l.type.dimensions)):f=new Qr(u.type,u.get(),l.locAddress,l.id),y=n.id,n.variadic&&(y="".concat(y,".").concat(s)),a.insertStore(y,f)):(g=u,c&&(g=ei.doImplicitCasting(n.type,g)),x=n.id,n.variadic&&(x="".concat(x,".").concat(s)),a.insertStore(x,g)),e.abrupt("return",a);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r,i){return S.apply(this,arguments)})},{key:"executeCommands",value:(A=t(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t,i=0;case 2:if(!(i=q.max_instruction_count)){e.next=8;break}throw Nn.exceed_max_instructions();case 8:if(!this.forceKill){e.next=12;break}throw"FORCED_KILL!";case 12:if(t.mode!==Se.PAUSE){e.next=16;break}return e.abrupt("return",this.executeCommand(t,n));case 16:if(t.mode!==Se.RETURN){e.next=20;break}return e.abrupt("return",t);case 20:if(!this.checkContext(ni.BREAKABLE)||t.mode!==Se.BREAK){e.next=24;break}return e.abrupt("return",t);case 24:if(this.mode!==Se.ABORT){e.next=26;break}throw ir().getMessage("aborted_execution");case 26:if(!(n instanceof ie)){e.next=30;break}return e.abrupt("return",this.executeDeclaration(t,n));case 30:if(!(n instanceof re)){e.next=34;break}return e.abrupt("return",this.executeArrayIndexAssign(t,n));case 34:if(!(n instanceof ne)){e.next=38;break}return e.abrupt("return",this.executeAssign(t,n));case 38:if(!(n instanceof ee)){e.next=42;break}return e.abrupt("return",this.executeBreak(t,n));case 42:if(!(n instanceof te)){e.next=46;break}return e.abrupt("return",this.executeReturn(t,n));case 46:if(!(n instanceof xe)){e.next=50;break}return e.abrupt("return",this.executeIfThenElse(t,n));case 50:if(!(n instanceof we)){e.next=54;break}return e.abrupt("return",this.executeRepeatUntil(t,n));case 54:if(!(n instanceof ae)){e.next=58;break}return e.abrupt("return",this.executeWhile(t,n));case 58:if(!(n instanceof se)){e.next=62;break}return e.abrupt("return",this.executeFor(t,n));case 62:if(!(n instanceof Ee)){e.next=66;break}return e.abrupt("return",this.executeSwitch(t,n));case 66:if(!(n instanceof Ae)){e.next=70;break}return e.abrupt("return",this.executeFunctionCall(t,n));case 70:if(!(n instanceof Re)){e.next=74;break}return e.abrupt("return",this.executeSysCall(t,n));case 74:throw Nn.unknown_command(n.sourceInfo);case 75:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"executeSysCall",value:(N=t(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.langFunc.bind(this),e.abrupt("return",r(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"executeFunctionCall",value:(T=t(o().mark((function t(n,r){var i,a,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=null,i=r.isMainCall?this.findMainFunction():this.findFunction(r.id),this.function_call_stack.push(r.sourceInfo),t.next=5,this.runFunction(i,r.actualParameters,n);case 5:if((a=t.sent).destroy(),ye.VOID.isCompatible(i.returnType)||a.mode===Se.RETURN){t.next=12;break}throw s=i.name===e.MAIN_INTERNAL_ID?nr.getMainFunctionName():i.name,Nn.function_no_return(s);case 12:return this.function_call_stack.pop(),t.abrupt("return",n);case 14:case"end":return t.stop()}}),t,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"executeSwitch",value:(k=t(o().mark((function e(t,n){var r,i,a,s,u,c,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.context.push(ni.BREAKABLE),r=n.cases,i=t,a=!1,s=0;case 5:if(!(s=r.lines)){e.next=34;break}if(!r.isVector){e.next=31;break}throw Nn.vector_line_outbounds_full(n.id,s,r.lines,n.sourceInfo);case 31:throw Nn.matrix_line_outbounds_full(n.id,s,r.lines,n.sourceInfo);case 32:e.next=36;break;case 34:if(!(s<0)){e.next=36;break}throw Nn.array_dimension_not_positive_full(n.sourceInfo);case 36:if(null==c||0!==r.columns){e.next=38;break}throw Nn.vector_not_matrix_full(n.id,n.sourceInfo);case 38:if(null==c){e.next=45;break}if(!(c>=r.columns)){e.next=43;break}throw Nn.matrix_column_outbounds_full(n.id,c,r.columns,n.sourceInfo);case 43:if(!(c<0)){e.next=45;break}throw Nn.array_dimension_not_positive_full(n.sourceInfo);case 45:if(r.type.canAccept(l.type,i)){e.next=55;break}if(q.enable_type_casting&&ei.canImplicitTypeCast(r.type.innerType,l.type)){e.next=54;break}throw p=r.type.innerType,d=p.stringInfo(),h=d[0],m=l.type.stringInfo(),_=m[0],v=n.expression.toString(),Nn.incompatible_types_full(h.type,h.dim,_.type,_.dim,v,n.sourceInfo);case 54:f=ei.doImplicitCasting(r.type.innerType,l);case 55:if(!((y=r.getAt(s,c))instanceof Hr)){e.next=60;break}if(y.lines===f.lines&&y.columns===f.columns){e.next=60;break}throw g=n.expression.toString(),Nn.invalid_matrix_index_assign_full(n.id,s,y.lines,g,f.lines,n.sourceInfo);case 60:return e.abrupt("return",t.updateStoreArray(n.id,f,s,c));case 61:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"executeDeclaration",value:(_=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n instanceof oe)){e.next=4;break}return e.abrupt("return",this.executeArrayDeclaration(t,n));case 4:if(r=new In(n.type,null,null,n.isConst),null===n.initial){e.next=22;break}return e.next=8,this.evaluateExpression(t,n.initial);case 8:if(i=e.sent,a=i,i.type.isCompatible(n.type)){e.next=21;break}if(!q.enable_type_casting||!ei.canImplicitTypeCast(n.type,i.type)){e.next=15;break}a=ei.doImplicitCasting(n.type,a),e.next=21;break;case 15:throw s=i.type.stringInfo(),u=s[0],c=i.type.stringInfo(),l=c[0],f=n.expression.toString(),Nn.incompatible_types_full(u.type,u.dim,l.type,l.dim,f,n.sourceInfo);case 21:r=new In(n.type,a.get(),null,n.isConst);case 22:return t.insertStore(n.id,r),e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"executeArrayDeclaration",value:(m=t(o().mark((function e(t,n){var r,i,a,s,u,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.evaluateExpression(t,n.lines);case 2:if(r=e.sent,ye.INTEGER.isCompatible(r.type)){e.next=5;break}throw Nn.array_dimension_not_int_full(n.sourceInfo);case 5:return i=r.get().toNumber(),e.next=8,this.evaluateExpression(t,n.columns);case 8:if(a=e.sent,s=null,null===a){e.next=16;break}if(ye.INTEGER.isCompatible(a.type)){e.next=13;break}throw Nn.array_dimension_not_int_full(n.sourceInfo);case 13:if(!((s=a.get().toNumber())<0)){e.next=16;break}throw Nn.array_dimension_not_positive_full(n.sourceInfo);case 16:if(u=new Hr(n.type,[],i,s,null,n.isConst),null===n.initial){e.next=22;break}return e.next=20,this.evaluateArrayLiteral(t,n.initial,n.type,i,s);case 20:c=e.sent,u=new Hr(n.type,c,i,s,null,n.isConst);case 22:return t.insertStore(n.id,u),e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"evaluateExpression",value:(h=t(o().mark((function e(t,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.instruction_count+=1,this.instruction_count%q.suspend_threshold!=0){e.next=4;break}return e.next=4,ur(3);case 4:if(this.mode!==Se.ABORT){e.next=6;break}throw ir().getMessage("aborted_execution");case 6:if(!(this.instruction_count>=q.max_instruction_count)){e.next=8;break}throw new Error("Número de instruções excedeu o limite definido. Verifique se seu código não possui laços infinitos ou muitas chamadas de funções recursivas.");case 8:if(!(n instanceof Un)){e.next=12;break}return e.abrupt("return",this.evaluateUnaryApp(t,n));case 12:if(!(n instanceof Mn)){e.next=16;break}return e.abrupt("return",this.evaluateInfixApp(t,n));case 16:if(!(n instanceof Sn)){e.next=20;break}return e.abrupt("return",this.evaluateArrayAccess(t,n));case 20:if(!(n instanceof Fn)){e.next=24;break}return e.abrupt("return",this.evaluateVariableLiteral(t,n));case 24:if(!(n instanceof On)){e.next=28;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 28:if(!(n instanceof Ln)){e.next=32;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 32:if(!(n instanceof Dn)){e.next=36;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 36:if(!(n instanceof Pn)){e.next=40;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 40:if(!(n instanceof Bn)){e.next=44;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 44:if(!(n instanceof Gn)){e.next=48;break}throw new Error("Internal Error: The system should not eval an array literal.");case 48:if(!(n instanceof Ae)){e.next=50;break}return e.abrupt("return",this.evaluateFunctionCall(t,n));case 50:return e.abrupt("return",null);case 51:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"evaluateFunctionCall",value:(d=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.isMainCall){e.next=2;break}throw Nn.void_in_expression_full(nr.getMainFunctionName(),n.sourceInfo);case 2:if(r=this.findFunction(n.id),!ye.VOID.isCompatible(r.returnType)){e.next=5;break}throw Nn.void_in_expression_full(n.id,n.sourceInfo);case 5:if(!(this.function_call_stack.length>=q.max_call_stack)){e.next=7;break}throw Nn.exceeded_recursive_calls(n.sourceInfo);case 7:return this.function_call_stack.push(n.sourceInfo),e.next=10,this.runFunction(r,n.actualParameters,t);case 10:if((i=e.sent).mode===Se.RETURN){e.next=13;break}throw new Error("!!!Internal error: the function that was called did not have a return command or did not set the store mode properly -> "+n.id);case 13:return a=i.applyStore("$"),i.destroy(),this.function_call_stack.pop(),e.abrupt("return",a);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"evaluateArrayLiteral",value:(p=t(o().mark((function e(t,n,r,i,a){var s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.isVector){e.next=9;break}if(null!=a){e.next=3;break}throw new Error("This should never happen: Vector cannot be initialized by a matrix");case 3:return e.next=5,this.evaluateMatrix(t,n,r,i,a);case 5:return s=e.sent,e.abrupt("return",s.reduce((function(e,t){return e.concat(t)}),[]));case 9:if(null==a){e.next=11;break}throw new Error("This should never happen: Matrix cannot be initialized by a vector");case 11:return e.abrupt("return",this.evaluateVector(t,n,r,i));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r,i){return p.apply(this,arguments)})},{key:"evaluateVector",value:(f=t(o().mark((function e(t,n,r,i){var a,s,u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.value,i===a.length){e.next=3;break}throw Nn.invalid_number_elements_vector(i,n.toString(),a.length,n.sourceInfo);case 3:return e.next=5,Promise.all(a.map((function(e){return u.evaluateExpression(t,e)})));case 5:return s=e.sent,e.abrupt("return",s.map((function(e,t){if(!r.canAccept(e.type,1)){if(!q.enable_type_casting||!ei.canImplicitTypeCast(r.innerType,e.type)){var n=a[t].toString();throw Nn.invalid_array_literal_type_full(n,a[t].sourceInfo)}return ei.doImplicitCasting(r.innerType,e)}return e})));case 7:case"end":return e.stop()}}),e)}))),function(e,t,n,r){return f.apply(this,arguments)})},{key:"evaluateMatrix",value:(c=t(o().mark((function e(t,n,r,i,a){var s,u,c=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((s=n.value).length===i){e.next=3;break}throw Nn.invalid_number_lines_matrix(i,n.toString(),s.length,n.sourceInfo);case 3:return u=s.map((function(e){var n=new An(r.innerType,1);return c.evaluateVector(t,e,n,a)})),e.next=6,Promise.all(u);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)}))),function(e,t,n,r,i){return c.apply(this,arguments)})},{key:"evaluateLiteral",value:(u=t(o().mark((function e(t,n){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new In(n.type,n.value));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return u.apply(this,arguments)})},{key:"evaluateVariableLiteral",value:(s=t(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore(n.id),e.abrupt("return",r);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"evaluateArrayAccess",value:(i=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=t.getStoreObject(n.id)).type instanceof An){e.next=3;break}throw Nn.invalid_array_access_full(n.id,n.sourceInfo);case 3:return e.next=5,this.evaluateExpression(t,n.line);case 5:if(i=e.sent,ye.INTEGER.isCompatible(i.type)){e.next=8;break}throw Nn.array_dimension_not_int_full(n.sourceInfo);case 8:return a=i.get().toNumber(),e.next=11,this.evaluateExpression(t,n.column);case 11:if(s=e.sent,u=null,null===s){e.next=17;break}if(ye.INTEGER.isCompatible(s.type)){e.next=16;break}throw Nn.array_dimension_not_int_full(n.sourceInfo);case 16:u=s.get().toNumber();case 17:if(!(a>=r.lines)){e.next=25;break}if(!r.isVector){e.next=22;break}throw Nn.vector_line_outbounds_full(n.id,a,r.lines,n.sourceInfo);case 22:throw Nn.matrix_line_outbounds_full(n.id,a,r.lines,n.sourceInfo);case 23:e.next=27;break;case 25:if(!(a<0)){e.next=27;break}throw Nn.array_dimension_not_positive_full(n.sourceInfo);case 27:if(null===u||0!==r.columns){e.next=29;break}throw Nn.vector_not_matrix_full(n.id,n.sourceInfo);case 29:if(null===u){e.next=36;break}if(!(u>=r.columns)){e.next=34;break}throw Nn.matrix_column_outbounds_full(n.id,u,r.columns,n.sourceInfo);case 34:if(!(u<0)){e.next=36;break}throw Nn.array_dimension_not_positive_full(n.sourceInfo);case 36:if(c=r.getAt(a,u),l=r.type.innerType,!Array.isArray(c)){e.next=43;break}return f=c.map((function(e,t){return new Vr(l,e,a,t,r.id,r.readOnly)})),e.abrupt("return",new Hr(new An(l,1),f,r.columns,null,r.id,r.readOnly));case 43:return e.abrupt("return",new Vr(l,c,a,u,r.id,r.readOnly));case 44:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"evaluateUnaryApp",value:(r=t(o().mark((function e(t,n){var r,i,a,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.evaluateExpression(t,n.left);case 2:if(r=e.sent,i=Mr(n.op,r.type),!ye.UNDEFINED.isCompatible(i)){e.next=8;break}throw a=r.type.stringInfo(),s=a[0],Nn.invalid_unary_op_full(n.op,s.type,s.dim,n.sourceInfo);case 8:e.t0=n.op.ord,e.next=e.t0===zn.ADD.ord?11:e.t0===zn.SUB.ord?12:e.t0===zn.NOT.ord?13:14;break;case 11:return e.abrupt("return",new In(i,r.get()));case 12:return e.abrupt("return",new In(i,r.get().negated()));case 13:return e.abrupt("return",new In(i,!r.get()));case 14:throw new $n("!!!Critical Invalid UnaryApp "+n.op);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"evaluateInfixApp",value:(n=t(o().mark((function e(t,n){var r,i,a,s,u,c,l,f,p,d,h,m,_,v,y,g,x,b,w,E,$,R,k,T,N,I,A;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.evaluateExpression(t,n.left);case 2:return r=e.sent,e.next=5,this.evaluateExpression(t,n.right);case 5:if(i=e.sent,a=!1,s=Fr(n.op,r.type,i.type),!ye.UNDEFINED.isCompatible(s)){e.next=18;break}if(!q.enable_type_casting||!ei.canImplicitTypeCast(r.type,i.type)){e.next=13;break}a=!0,e.next=18;break;case 13:throw u=r.type.stringInfo(),c=u[0],l=i.type.stringInfo(),f=l[0],Nn.invalid_infix_op_full(n.op,c.type,c.dim,f.type,f.dim,n.sourceInfo);case 18:p=null,e.t0=n.op.ord,e.next=e.t0===zn.ADD.ord?22:e.t0===zn.SUB.ord?39:e.t0===zn.MULT.ord?40:e.t0===zn.DIV.ord?42:e.t0===zn.MOD.ord?46:e.t0===zn.GT.ord?51:e.t0===zn.GE.ord?55:e.t0===zn.LT.ord?59:e.t0===zn.LE.ord?63:e.t0===zn.EQ.ord?67:e.t0===zn.NEQ.ord?71:e.t0===zn.AND.ord?75:e.t0===zn.OR.ord?76:77;break;case 22:if(!ye.STRING.isCompatible(r.type)){e.next=27;break}return d=xn(i.get(),i.type),e.abrupt("return",new In(s,r.get()+d));case 27:if(!ye.STRING.isCompatible(i.type)){e.next=32;break}return h=xn(r.get(),r.type),e.abrupt("return",new In(s,h+i.get()));case 32:if(!ye.CHAR.isCompatible(r.type)){e.next=38;break}return m=xn(r.get(),r.type),_=xn(i.get(),i.type),e.abrupt("return",new In(s,m+_));case 38:return e.abrupt("return",new In(s,r.get().plus(i.get())));case 39:return e.abrupt("return",new In(s,r.get().minus(i.get())));case 40:return p=r.get().times(i.get()),e.abrupt("return",new In(s,p));case 42:if(0!=i.get()){e.next=44;break}throw Nn.divsion_by_zero_full(n.toString(),n.sourceInfo);case 44:return p=ye.INTEGER.isCompatible(s)?r.get().divToInt(i.get()):r.get().div(i.get()),e.abrupt("return",new In(s,p));case 46:return v=r.get(),y=i.get(),a&&(s=ye.INTEGER,v=v.trunc(),y=y.trunc()),p=v.modulo(y),e.abrupt("return",new In(s,p));case 51:return g=r.get(),x=i.get(),ye.STRING.isCompatible(r.type)?p=g.length>x.length:ye.CHAR.isCompatible(r.type)?p=g.charCodeAt(0)>x.charCodeAt(0):(a&&(s=ye.BOOLEAN,g=g.trunc(),x=x.trunc()),p=g.gt(x)),e.abrupt("return",new In(s,p));case 55:return b=r.get(),w=i.get(),ye.STRING.isCompatible(r.type)?p=b.length>=w.length:ye.CHAR.isCompatible(r.type)?p=b.charCodeAt(0)>=w.charCodeAt(0):(a&&(s=ye.BOOLEAN,b=b.trunc(),w=w.trunc()),p=b.gte(w)),e.abrupt("return",new In(s,p));case 59:return E=r.get(),$=i.get(),ye.STRING.isCompatible(r.type)?p=E.length<$.length:ye.CHAR.isCompatible(r.type)?p=E.charCodeAt(0)<$.charCodeAt(0):(a&&(s=ye.BOOLEAN,E=E.trunc(),$=$.trunc()),p=E.lt($)),e.abrupt("return",new In(s,p));case 63:return R=r.get(),k=i.get(),ye.STRING.isCompatible(r.type)?p=R.length<=k.length:ye.CHAR.isCompatible(r.type)?p=R.charCodeAt(0)<=k.charCodeAt(0):(a&&(s=ye.BOOLEAN,R=R.trunc(),k=k.trunc()),p=R.lte(k)),e.abrupt("return",new In(s,p));case 67:return T=r.get(),N=i.get(),ye.INTEGER.isCompatible(r.type)||ye.REAL.isCompatible(r.type)?(a&&(s=ye.BOOLEAN,T=T.trunc(),N=N.trunc()),p=T.eq(N)):p=T===N,e.abrupt("return",new In(s,p));case 71:return I=r.get(),A=i.get(),ye.INTEGER.isCompatible(r.type)||ye.REAL.isCompatible(r.type)?(a&&(s=ye.BOOLEAN,I=I.trunc(),A=A.trunc()),p=!I.eq(A)):p=I!==A,e.abrupt("return",new In(s,p));case 75:return e.abrupt("return",new In(s,r.get()&&i.get()));case 76:return e.abrupt("return",new In(s,r.get()||i.get()));case 77:throw new $n("!!!Critical Invalid InfixApp "+n.op);case 78:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})}],[{key:"MAIN_INTERNAL_ID",get:function(){return"$main"}}]),e}();var ii=function(e){p(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=m(t);if(n){var i=m(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h(this,e)});function i(e){var t;return a(this,i),(t=r.call(this)).index=0,t.inputList=e,t}return l(i,[{key:"requestInput",value:function(){var e=this;return new Promise((function(t,n){e.index1&&void 0!==arguments[1]&&arguments[1];null==this.currentLine&&(this.currentLine=this.list.push("")-1),this.list[this.currentLine]+=e,t&&(this.currentLine=null)}},{key:"sendOutput",value:function(e){var t=this,n=""+e;if(-1!==n.indexOf("\n")){var r=n.split("\n"),i=r.pop();r.forEach((function(e){0==e.length?t.currentLine=null:t.write(e,!0)})),0!=i.length&&this.write(i)}else this.write(n)}}]),i}(function(){function e(){a(this,e)}return l(e,[{key:"sendOutput",value:function(e){throw new Error("Must be implemented")}},{key:"writeRawHTML",value:function(e,t){throw new Error("Must be implemented")}},{key:"write",value:function(e){throw new Error("Must be implemented")}},{key:"info",value:function(e){throw new Error("Must be implemented")}},{key:"err",value:function(e){throw new Error("Must be implemented")}}],[{key:"USER",get:function(){return 0}},{key:"INFO",get:function(){return 1}},{key:"ERR",get:function(){return 2}},{key:"INPUT",get:function(){return 3}}]),e}());function ai(e,t,n){return si.apply(this,arguments)}function si(){return si=t(o().mark((function e(n,r,i){var a,s,u,c,l,f,p,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=r.map((function(e){return Object.assign({},e)})),e.prev=1,s=ti.analyseFromSource(n),u=r.map(function(){var e=t(o().mark((function e(t,n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new ii(t.input),i=new oi,(a=new ri(s)).registerInput(r),a.registerOutput(i),e.next=7,a.interpretAST();case 7:return e.abrupt("return",{id:n,program:a});case 8:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),e.next=6,Promise.all(u);case 6:c=e.sent,l=0;case 8:if(!(l "+e),ir().getString(e,n))}}),li={programming:[],functions:[],datatypes:[],commands:[],filter:[]},fi=ci.i18n})(),r})()));
//# sourceMappingURL=main.js.map