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)/R|0,c[i]%=R;for(t&&(c.unshift(t),++r),a=c.length;0==c[--a];)c.pop();return e.d=c,e.e=G(c,r),h?O(e,s,u):e},N.precision=N.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(_+e);return n.d?(t=M(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},N.round=function(){var e=this,t=e.constructor;return O(new t(e),e.e+1,t.rounding)},N.sine=N.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 W(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=W(e,2,t=t.times(1/Z(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,Q(r,n)),r.precision=e,r.rounding=t,O(s>2?n.neg():n,e,t,!0)):new r(NaN)},N.squareRoot=N.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(h=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=I(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=g((u+1)/2)-(u<0||u%2),r=new l(t=c==1/0?"1e"+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(L(a,o,n+2,1)).times(.5),I(o.d).slice(0,n)===(t=I(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))||(O(r,u+1,1),e=!r.times(r).eq(a));break}if(!i&&(O(o,u+1,0),o.times(o).eq(a))){r=o;break}n+=4,i=1}return h=!0,O(r,u,l.rounding,e)},N.tangent=N.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=L(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,O(2==s||4==s?n.neg():n,e,t,!0)):new r(NaN)},N.times=N.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=g(l.e/7)+g(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%R|0,t=s/R|0;o[i]=(o[i]+t)%R|0}for(;!o[--a];)o.pop();return t?++n:o.shift(),e.d=o,e.e=G(o,n),h?O(e,f.precision,f.rounding):e},N.toBinary=function(e,t){return J(this,2,e,t)},N.toDecimalPlaces=N.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(S(e,0,c),void 0===t?t=r.rounding:S(t,0,8),O(n,e+n.e+1,t))},N.toExponential=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=D(r,!0):(S(e,0,c),void 0===t?t=i.rounding:S(t,0,8),n=D(r=O(new i(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},N.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return void 0===e?n=D(i):(S(e,0,c),void 0===t?t=o.rounding:S(t,0,8),n=D(r=O(new o(i),e+i.e+1,t),!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},N.toFraction=function(e){var t,n,r,i,o,a,s,u,c,l,f,p,d=this,m=d.d,v=d.constructor;if(!m)return new v(d);if(c=n=new v(1),r=u=new v(0),a=(o=(t=new v(r)).e=M(m)-d.e-1)%7,t.d[0]=x(10,a<0?7+a:a),null==e)e=o>0?t:c;else{if(!(s=new v(e)).isInt()||s.lt(c))throw Error(_+s);e=s.gt(t)?o>0?t:c:s}for(h=!1,s=new v(I(m)),l=v.precision,v.precision=o=7*m.length*2;f=L(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=L(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=L(c,r,o,1).minus(d).abs().cmp(L(u,n,o,1).minus(d).abs())<1?[c,r]:[u,n],v.precision=l,h=!0,p},N.toHexadecimal=N.toHex=function(e,t){return J(this,16,e,t)},N.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:S(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]?(h=!1,n=L(n,e,0,t,1).times(e),h=!0,O(n)):(e.s=n.s,n=e),n},N.toNumber=function(){return+this},N.toOctal=function(e,t){return J(this,8,e,t)},N.toPower=N.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(x(+s,c));if((s=new u(s)).eq(1))return s;if(r=u.precision,o=u.rounding,e.eq(1))return O(s,r,o);if((t=g(e.e/7))>=e.d.length-1&&(n=c<0?-c:c)<=9007199254740991)return i=U(u,s,n,r),e.s<0?new u(1).div(i):O(i,r,o);if((a=s.s)<0){if(tu.maxE+1||t0?a/0:0):(h=!1,u.rounding=s.s=1,n=Math.min(12,(t+"").length),(i=V(e.times(q(s,r+n)),r)).d&&A((i=O(i,r+5,1)).d,r,o)&&(t=r+10,+I((i=O(V(e.times(q(s,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=O(i,r+1,0))),i.s=a,h=!0,u.rounding=o,O(i,r,o))},N.toPrecision=function(e,t){var n,r=this,i=r.constructor;return void 0===e?n=D(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(S(e,1,c),void 0===t?t=i.rounding:S(t,0,8),n=D(r=O(new i(r),e,t),e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},N.toSignificantDigits=N.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(S(e,1,c),void 0===t?t=n.rounding:S(t,0,8)),O(new n(this),e,t)},N.toString=function(){var e=this,t=e.constructor,n=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},N.truncated=N.trunc=function(){return O(new this.constructor(this),this.e+1,1)},N.valueOf=N.toJSON=function(){var e=this,t=e.constructor,n=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var L=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,s,u,c){var l,f,p,d,h,m,_,v,y,x,b,w,E,$,k,T,N,I,S,A,C=r.constructor,L=r.s==i.s?1:-1,D=r.d,G=i.d;if(!(D&&D[0]&&G&&G[0]))return new C(r.s&&i.s&&(D?!G||D[0]!=G[0]:G)?D&&0==D[0]||!G?0*L:L/0:NaN);for(c?(h=1,f=r.e-i.e):(c=R,h=7,f=g(r.e/h)-g(i.e/h)),S=G.length,N=D.length,x=(y=new C(L)).d=[],p=0;G[p]==(D[p]||0);p++);if(G[p]>(D[p]||0)&&f--,null==o?($=o=C.precision,s=C.rounding):$=u?o+(r.e-i.e)+1:o,$<0)x.push(1),m=!0;else{if($=$/h+2|0,p=0,1==S){for(d=0,G=G[0],$++;(p1&&(G=e(G,d,c),D=e(D,d,c),S=G.length,N=D.length),T=S,w=(b=D.slice(0,S)).length;w=c/2&&++I;do{d=0,(l=t(G,b,S,w))<0?(E=b[0],S!=w&&(E=E*c+(b[1]||0)),(d=E/I|0)>1?(d>=c&&(d=c-1),1==(l=t(_=e(G,d,c),b,v=_.length,w=b.length))&&(d--,n(_,S=10;d/=10)p++;y.e=p+f*h-1,O(y,u?o+y.e+1:o,s,m)}return y}}();function O(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])/x(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/x(10,i-a-1)%10|0}if(r=r||t<0||void 0!==f[p+1]||(a<0?l:l%x(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/x(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]=x(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=x(10,7-o),f[p]=a>0?(l/x(10,i-a)%x(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]==R&&(f[0]=1));break}if(f[p]+=s,f[p]!=R)break;f[p--]=0,s=1}for(o=f.length;0===f[--o];)f.pop()}return h&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e0?o=o.charAt(0)+"."+o.slice(1)+B(r):a>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+B(-i-1)+o,n&&(r=n-a)>0&&(o+=B(r))):i>=a?(o+=B(i+1-a),n&&(r=n-i-1)>0&&(o=o+"."+B(r))):((r=i+1)0&&(i+1===a&&(o+="."),o+=B(r))),o}function G(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function F(e,t,n){if(t>k)throw h=!0,n&&(e.precision=n),Error(v);return O(new e(f),t,1,!0)}function P(e,t,n){if(t>T)throw Error(v);return O(new e(p),t,n,!0)}function M(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 B(e){for(var t="";e--;)t+="0";return t}function U(e,t,n,r){var i,o=new e(1),a=Math.ceil(r/7+4);for(h=!1;;){if(n%2&&X((o=o.times(t)).d,a)&&(i=!0),0===(n=g(n/2))){n=o.d.length-1,i&&0===o.d[n]&&++o.d[n];break}X((t=t.times(t)).d,a)}return h=!0,o}function K(e){return 1&e.d[e.d.length-1]}function z(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?(h=!1,u=m):u=t,s=new p(.03125);e.e>-2;)e=e.times(s),f+=5;for(u+=r=Math.log(x(2,f))/Math.LN10*2+5|0,n=o=a=new p(1),p.precision=u;;){if(o=O(o.times(e),u,1),n=n.times(++l),I((s=a.plus(L(o,n,u,1))).d).slice(0,u)===I(a.d).slice(0,u)){for(i=f;i--;)a=O(a.times(a),u,1);if(null!=t)return p.precision=m,a;if(!(c<3&&A(a.d,u-r,d,c)))return O(a,p.precision=m,d,h=!0);p.precision=u+=10,n=o=s=new p(1),l=0,c++}a=s}}function q(e,t){var n,r,i,o,a,s,u,c,l,f,p,d=1,m=e,_=m.d,v=m.constructor,y=v.rounding,g=v.precision;if(m.s<0||!_||!_[0]||!m.e&&1==_[0]&&1==_.length)return new v(_&&!_[0]?-1/0:1!=m.s?NaN:_?0:m);if(null==t?(h=!1,l=g):l=t,v.precision=l+=10,r=(n=I(_)).charAt(0),!(Math.abs(o=m.e)<15e14))return c=F(v,l+2,g).times(o+""),m=q(new v(r+"."+n.slice(1)),l-10).plus(c),v.precision=g,null==t?O(m,g,y,h=!0):m;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=I((m=m.times(e)).d)).charAt(0),d++;for(o=m.e,r>1?(m=new v("0."+n),o++):m=new v(r+"."+n.slice(1)),f=m,u=a=m=L(m.minus(1),m.plus(1),l,1),p=O(m.times(m),l,1),i=3;;){if(a=O(a.times(p),l,1),I((c=u.plus(L(a,new v(i),l,1))).d).slice(0,l)===I(u.d).slice(0,l)){if(u=u.times(2),0!==o&&(u=u.plus(F(v,l+2,g).times(o+""))),u=L(u,new v(d),l,1),null!=t)return v.precision=g,u;if(!A(u.d,l-10,y,s))return O(u,v.precision=g,y,h=!0);v.precision=l+=10,c=a=m=L(f.minus(1),f.plus(1),l,1),p=O(m.times(m),l,1),i=s=1}u=c,i+=2}}function j(e){return String(e.s*e.s/0)}function H(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.e0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),s=(a=t.indexOf("."))>=0,r=e.constructor,s&&(a=(u=(t=t.replace(".","")).length)-a,i=U(r,new r(n),a,2*a)),a=f=(l=C(t,n,R)).length-1;0===l[a];--a)l.pop();return a<0?new r(0*e.s):(e.e=G(l,f),e.d=l,h=!1,s&&(e=L(e,i,4*u)),c&&(e=e.times(Math.abs(c)<54?x(2,c):o.pow(2,c))),h=!0,e)}function W(e,t,n,r,i){var o,a,s,u,c=e.precision,l=Math.ceil(c/7);for(h=!1,u=n.times(n),s=new e(r);;){if(a=L(s.times(u),new e(t++*t++),c,1),s=i?r.plus(a):r.minus(a),r=L(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 h=!0,a.d.length=l+1,a}function Z(e,t){for(var n=e;--t;)n*=e;return n}function Q(e,t){var n,r=t.s<0,i=P(e,e.precision,1),o=i.times(.5);if((t=t.abs()).lte(o))return s=r?4:1,t;if((n=t.divToInt(i)).isZero())s=r?3:2;else{if((t=t.minus(n.times(i))).lte(o))return s=K(n)?r?2:3:r?4:1,t;s=K(n)?r?1:4:r?3:2}return t.minus(i).abs()}function J(e,t,n,r){var i,o,s,u,f,p,d,h,m,_=e.constructor,v=void 0!==n;if(v?(S(n,1,c),void 0===r?r=_.rounding:S(r,0,8)):(n=_.precision,r=_.rounding),e.isFinite()){for(v?(i=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):i=t,(s=(d=D(e)).indexOf("."))>=0&&(d=d.replace(".",""),(m=new _(1)).e=d.length-s,m.d=C(D(m),10,i),m.e=m.d.length),o=f=(h=C(d,10,i)).length;0==h[--f];)h.pop();if(h[0]){if(s<0?o--:((e=new _(e)).d=h,e.e=o,h=(e=L(e,m,n,r,0,i)).d,o=e.e,p=a),s=h[n],u=i/2,p=p||void 0!==h[n+1],p=r<4?(void 0!==s||p)&&(0===r||r===(e.s<0?3:2)):s>u||s===u&&(4===r||p||6===r&&1&h[n-1]||r===(e.s<0?8:7)),h.length=n,p)for(;++h[--n]>i-1;)h[n]=0,n||(++o,h.unshift(1));for(f=h.length;!h[f-1];--f);for(s=0,d="";s1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)d+="0";for(f=(h=C(d,i,t)).length;!h[f-1];--f);for(s=1,d="1.";sf)for(o-=f;o--;)d+="0";else ot)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function ne(e){return new this(e).acosh()}function re(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function oe(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ue(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?P(this,r,i):new this(0)).s=e.s:!e.d||t.isZero()?(n=P(this,o,1).times(.5)).s=e.s:t.s<0?(this.precision=o,this.rounding=1,n=this.atan(L(e,t,o,1)),t=P(this,o,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(L(e,t,o,1)):(n=P(this,o,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function ce(e){return new this(e).cbrt()}function le(e){return O(e=new this(e),e.e+1,2)}function fe(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,n,r,i=!0===e.defaults,o=["precision",1,c,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=o[t+1]&&r<=o[t+2]))throw Error(_+n+": "+r);this[n]=r}if(n="crypto",i&&(this[n]=d[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(_+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(y);this[n]=!0}else this[n]=!1}return this}function pe(e){return new this(e).cos()}function de(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function me(e){return new this(e).exp()}function _e(e){return O(e=new this(e),e.e+1,3)}function ve(){var e,t,n=new this(0);for(h=!1,e=0;e=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:s[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(y);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 Ie(e){return O(e=new this(e),e.e+1,this.rounding)}function Se(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Ae(e){return new this(e).sin()}function Ce(e){return new this(e).sinh()}function Le(e){return new this(e).sqrt()}function Oe(e,t){return new this(e).sub(t)}function De(e){return new this(e).tan()}function Ge(e){return new this(e).tanh()}function Fe(e){return O(e=new this(e),e.e+1,1)}(o=function e(t){var n,r,i;function o(e){var t,n,r,i=this;if(!(i instanceof o))return new o(e);if(i.constructor=o,e instanceof o)return i.s=e.s,void(h?!e.d||e.e>o.maxE?(i.e=NaN,i.d=null):e.e=10;n/=10)t++;return void(h?t>o.maxE?(i.e=NaN,i.d=null):t0)throw new Error("RegExp has capture groups: "+x+"\nUse (?: … ) instead");if(!m.lineBreaks&&x.test("\n"))throw new Error("Rule should declare lineBreaks: "+x);d.push(o(g))}}var b=i&&i.fallback,w=n&&!b?"ym":"gm",E=n||b?"":"|";return!0===f&&(w+="u"),{regexp:new RegExp(a(d)+E,w),groups:p,fast:u,error:i||l}}function p(e,t,n){var r=e&&(e.push||e.next);if(r&&!n[r])throw new Error("Missing state '"+r+"' (in token '"+e.defaultType+"' of state '"+t+"')");if(e&&e.pop&&1!=+e.pop)throw new Error("pop must be 1 (in token '"+e.defaultType+"' of state '"+t+"')")}var d=function(e,t){this.startState=t,this.states=e,this.buffer="",this.stack=[],this.reset()};d.prototype.reset=function(e,t){return this.buffer=e||"",this.index=0,this.line=t?t.line:1,this.col=t?t.col:1,this.queuedToken=t?t.queuedToken:null,this.queuedThrow=t?t.queuedThrow:null,this.setState(t?t.state:this.startState),this.stack=t&&t.stack?t.stack.slice():[],this},d.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},d.prototype.setState=function(e){if(e&&this.state!==e){this.state=e;var t=this.states[e];this.groups=t.groups,this.error=t.error,this.re=t.regexp,this.fast=t.fast}},d.prototype.popState=function(){this.setState(this.stack.pop())},d.prototype.pushState=function(e){this.stack.push(this.state),this.setState(e)};var h=n?function(e,t){return e.exec(t)}:function(e,t){var n=e.exec(t);return 0===n[0].length?null:n};function m(){return this.value}if(d.prototype._getGroup=function(e){for(var t=this.groups.length,n=0;n{var t=function(e){"use strict";var t,n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,o=Object.create(i.prototype),a=new T(r||[]);return o._invoke=function(e,t,n){var r=l;return function(i,o){if(r===p)throw new Error("Generator is already running");if(r===d){if("throw"===i)throw o;return I()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=$(a,n);if(s){if(s===h)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===l)throw r=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var u=c(e,t,n);if("normal"===u.type){if(r=n.done?d:f,u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=d,n.method="throw",n.arg=u.arg)}}}(e,n,a),o}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l="suspendedStart",f="suspendedYield",p="executing",d="completed",h={};function m(){}function _(){}function v(){}var y={};y[o]=function(){return this};var g=Object.getPrototypeOf,x=g&&g(g(N([])));x&&x!==n&&r.call(x,o)&&(y=x);var b=v.prototype=m.prototype=Object.create(y);function w(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function E(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function $(e,n){var r=e.iterator[n.method];if(r===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,$(e,n),"throw"===n.method))return h;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var i=c(r,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,h;var o=i.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,h):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function N(e){if(e){var n=e[o];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function n(){for(;++i=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:N(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{Config:()=>l,IVProgProcessor:()=>An,LocalizedStrings:()=>Pn,Location:()=>vn,Modes:()=>Se,SemanticAnalyser:()=>In,Settings:()=>Gn,autoGenerateTestCaseOutput:()=>On,i18n:()=>Fn,levenshteinDistance:()=>Ct,openAssessmentDetail:()=>Ot,parseCode:()=>nn,parseExpression:()=>tn,processData:()=>Mt});var e,t=n(575),i=n.n(t),o=n(913),a=n.n(o),s=n(713),u=n.n(s),c=function(){function e(){i()(this,e),u()(this,"decimalPlaces",void 0),u()(this,"intConvertRoundMode",void 0),u()(this,"default_lang",void 0),u()(this,"enable_type_casting",void 0),u()(this,"idle_input_interval",void 0),u()(this,"suspend_threshold",void 0),u()(this,"max_instruction_count",void 0),u()(this,"activity_programming_type",void 0),u()(this,"activity_functions",void 0),u()(this,"activity_datatypes",void 0),u()(this,"activity_commands",void 0),u()(this,"activity_filter",void 0),this.decimalPlaces=8,this.intConvertRoundMode=2,this.default_lang="pt",this.enable_type_casting=!0,this.idle_input_interval=5e3,this.suspend_threshold=1e3,this.max_instruction_count=Number.MAX_SAFE_INTEGER,this.activity_programming_type=new Map,this.activity_functions=new Map,this.activity_datatypes=new Map,this.activity_commands=new Map,this.activity_filter=new Map}return a()(e,[{key:"setConfig",value:function(e){var t=e;for(var n in t)Object.prototype.hasOwnProperty.call(this,n)&&(this[n]=t[n])}}]),e}(),l=new c,f=function(){function e(e,t){void 0===t&&(t="pt"),this.lsKey=e,this.defaultLang=t,this.listeners=[],this.document=document,this.setupListener()}return e.prototype.setupListener=function(){var e=this;null!==this.document&&this.document.addEventListener("storage",(function(t){t.key===e.lsKey&&e.listeners.forEach((function(e){return e()}))}))},e.prototype.getLang=function(){var e=localStorage.getItem(this.lsKey);return null==e?(console.warn("Internal Error: User language information has not been set. Returning default..."),this.getDefaultLang()):e},e.prototype.getDefaultLang=function(){return this.defaultLang},e.prototype.registerLanguageChangeListener=function(e){this.listeners.push(e)},e}();!function(e){e.ERROR="error",e.MESSAGE="message",e.UI="ui"}(e||(e={}));var p=function(){function t(e,t,n){var r=this;void 0===n&&(n=!1),this.service=e,this.i18nData=t,this.listenToChange=n,this.document=document,this.listenToChange&&e.registerLanguageChangeListener((function(){r.updateTagText()}))}return t.prototype.getString=function(e,t){var n=this.i18nData[this.service.getLang()];return n?n[t]&&n[t][e]?n[t][e]:this.getDefaultString(e,t):(console.warn("Internal Error. The language set at ivprog.lang is not valid: "+this.service.getLang()),this.getDefaultString(e,t))},t.prototype.getDefaultString=function(e,t){var n=this.i18nData[this.service.getDefaultLang()];return n[t]?n[t][e]?n[t][e]:"{MISSING_I18N_IDENTIFIER: "+e+"}":"{MISSING_I18N_TYPE_IDENTIFIER: "+t+"}"},t.prototype.getOR=function(){return this.getUI("string_join_or")},t.prototype.getError=function(t,n){void 0===n&&(n=[]);var r=this.getString(t,e.ERROR);return this.processString(r,n)},t.prototype.getMessage=function(t,n){void 0===n&&(n=[]);var r=this.getString(t,e.MESSAGE);return this.processString(r,n)},t.prototype.getUI=function(t,n){void 0===n&&(n=[]);var r=this.getString(t,e.UI);return this.processString(r,n)},t.prototype.processString=function(e,t){for(var n=0;n";var n=t.split(":"),r=n[0].toLowerCase(),i=n[1];return e.ERROR===r?this.getError(i):e.MESSAGE===r?this.getMessage(i):e.UI===r?this.getUI(i):(console.warn(" A string has been passed to the i18n helper function that was not in the form type:id -> "+t),this.getString(i,r))},t}();const d={LanguageService:f,LanguageServiceNoLS:function(){function e(e){this.lang=e,this.listeners=[]}return e.prototype.setupListener=function(){},e.prototype.notifyChange=function(){this.listeners.forEach((function(e){return e()}))},e.prototype.setLang=function(e){this.lang=e,this.notifyChange()},e.prototype.getLang=function(){return this.lang},e.prototype.getDefaultLang=function(){return this.lang},e.prototype.registerLanguageChangeListener=function(e){this.listeners.push(e)},e}(),LocalizedStrings:p,StringTypes:e};var h=n(205),m=n.n(h),_=n(585),v=n.n(_),y=n(754),g=n.n(y),x=n(597),b=n(548),w=n(186),E={};for(var $ in b){var R={};R.error=w[$],R.message=x[$],R.ui=b[$],E[$]=R}const k=E;var T=n(38),N=n.n(T),I=n(655),S=n.n(I),A=n(271);function C(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r=|==|<=|>|<|!=/,COLON:/:/,STRING:C(O(),z),CHARACTER:C(L(),K),EOS:{match:/;\r?\n?|[\r\n]+/,lineBreaks:!0},WHITESPACE:/(?: |\t)+/,RK_REFERENCE:RegExp(e.commands.RK_REFERENCE),ID:{match:RegExp("[a-zA-Z_][a-zA-Z0-9_]*"),type:r},DOT:/\./,ERROR:{match:/[\$?`]/,error:!0}};Object.entries(i).forEach((function(e){var t=N()(e,2),r=t[0];return t[1],n[r]=r}));var o=A.compile(i);return new F(t,o,n,e)}var q=V({commands:{RK_VOID:"vazio",RK_PROGRAM:"programa",RK_SWITCH:"escolha",RK_CASE:"caso",RK_DEFAULT:"contrario",RK_CONST:"const",RK_FUNCTION:"funcao",RK_RETURN:"devolva",RK_FOR:"para",RK_FOR_ALT:"repita_para",RK_FOR_FROM:"de",RK_FOR_TO:"ate",RK_FOR_PASS:"passo",RK_BREAK:"pare",RK_DO:"repita",RK_DO_UNTIL:"ate_que",RK_WHILE:"enquanto",RK_WHILE_ALT:"repita_enquanto",RK_IF:"se",RK_ELSE:"senao",RK_REFERENCE:"&"},boolVal:{RK_FALSE:"falso",RK_TRUE:"verdadeiro"},logicOp:{RK_LOGICAL_NOT:"nao",RK_LOGICAL_AND:"E",RK_LOGICAL_OR:"OU"},types:{RK_REAL:"real",RK_INTEGER:"inteiro",RK_BOOLEAN:"logico",RK_CHARACTER:"caractere",RK_STRING:"cadeia"},langLibs:{$mathLib:"Matematica",$ioLib:"ES",$strLib:"Texto",$arrayLib:"Arranjo",$langLib:"Conversao"},langFuncs:{main_function:"inicio",$read:"leia",$write:"escreva",$numElements:"total_de_elementos",$matrixLines:"total_de_linhas",$matrixColumns:"total_de_colunas",$substring:"subcadeia",$length:"comprimento",$uppercase:"caixa_alta",$lowercase:"caixa_baixa",$charAt:"caractere_na_posicao",$isReal:"e_real",$isInt:"e_inteiro",$isBool:"e_logico",$castReal:"como_real",$castInt:"como_inteiro",$castBool:"como_logico",$castString:"como_cadeia",$castChar:"como_caractere",$sin:"seno",$cos:"cosseno",$tan:"tangente",$sqrt:"raiz_quadrada",$pow:"potencia",$log:"logaritmo",$abs:"modulo",$negate:"trocar_sinal",$invert:"inverter_valor",$max:"maximo",$min:"minimo",$rand:"numero_aleatorio"}}),j=V({commands:{RK_VOID:"vazio",RK_PROGRAM:"program",RK_SWITCH:"switch",RK_CASE:"case",RK_DEFAULT:"otherwise",RK_CONST:"const",RK_FUNCTION:"function",RK_RETURN:"return",RK_FOR:"for",RK_FOR_ALT:"repeat_for",RK_FOR_FROM:"from",RK_FOR_TO:"to",RK_FOR_PASS:"pass",RK_BREAK:"break",RK_DO:"repeat",RK_DO_UNTIL:"until",RK_WHILE:"while",RK_WHILE_ALT:"repeat_while",RK_IF:"if",RK_ELSE:"else",RK_REFERENCE:"&"},boolVal:{RK_FALSE:"false",RK_TRUE:"true"},logicOp:{RK_LOGICAL_NOT:"not",RK_LOGICAL_AND:"AND",RK_LOGICAL_OR:"OR"},types:{RK_REAL:"real",RK_INTEGER:"int",RK_BOOLEAN:"bool",RK_CHARACTER:"char",RK_STRING:"string"},langLibs:{$mathLib:"Mathematics",$ioLib:"IO",$strLib:"Text",$arrayLib:"Array",$langLib:"Conversion"},langFuncs:{main_function:"main",$read:"read",$write:"write",$numElements:"total_of_elements",$matrixLines:"total_of_lines",$matrixColumns:"total_of_columns",$substring:"substring",$length:"length",$uppercase:"uppercase",$lowercase:"lowercase",$charAt:"char_at",$isReal:"is_real",$isInt:"is_integer",$isBool:"is_logic",$castReal:"to_real",$castInt:"to_integer",$castBool:"to_logic",$castString:"to_string",$castChar:"to_char",$sin:"sin",$cos:"cos",$tan:"tan",$sqrt:"sqrt",$pow:"pow",$log:"log",$abs:"abs",$negate:"negate",$invert:"invert",$max:"maximum",$min:"minimum",$rand:"random"}}),H={};H.pt=q,H.en=j;const Y=H;var W=new(function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(){return i()(this,o),r.call(this,"undefined"==typeof iLMparameters?l.default_lang:iLMparameters.lang)}return a()(o,[{key:"getDefaultLang",value:function(){return"en"}},{key:"getCurrentLexer",value:function(){var e=Y[this.getLang()];return null==e?Y[this.getDefaultLang()]:e}},{key:"getCurrentLangFuncs",value:function(){var e=Y[this.getLang()];return null==e?Y[this.getDefaultLang()].getLangFuncs():e.getLangFuncs()}},{key:"getCurrentLangLibs",value:function(){var e=Y[this.getLang()];return null==e?Y[this.getDefaultLang()].getLangLibs():e.getLangLibs()}}]),o}(d.LanguageServiceNoLS)),Z=n(757),Q=n.n(Z),J=n(926),X=n.n(J),ee=function(){function e(){i()(this,e),this._sourceInfo=null}return a()(e,[{key:"sourceInfo",set:function(e){this._sourceInfo=e},get:function(){return this._sourceInfo}}]),e}();var te=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(){return i()(this,o),r.call(this)}return o}(ee);var ne=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this)).expression=e,t}return o}(ee);var re=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this)).id=e,n.expression=t,n}return o}(ee);var ie=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n,a){var s;return i()(this,o),(s=r.call(this,e,a)).line=t,s.column=n,s}return o}(re);var oe=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n,a){var s;return i()(this,o),(s=r.call(this)).id=e,s.type=t,s.initial=n,s.isConst=a,s}return o}(ee);var ae=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n,a,s,u){var c;return i()(this,o),(c=r.call(this,e,t,s,u)).lines=n,c.columns=a,c}return a()(o,[{key:"isVector",get:function(){return null==this.columns}}]),o}(oe);var se=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this)).expression=e,n.commandBlock=t,n}return a()(o,[{key:"commands",get:function(){return this.commandBlock.commands}},{key:"testFirst",get:function(){return!0}}]),o}(ee);var ue=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n,a,s){var u;return i()(this,o),(u=r.call(this)).for_id=e,u.for_from=t,u.for_to=n,u.for_pass=a,u.commandBlock=s,u}return a()(o,[{key:"commands",get:function(){return this.commandBlock.commands}}]),o}(ee),ce=function(){function e(t,n){i()(this,e),u()(this,"value",void 0),u()(this,"ord",void 0),this.value=t,this.ord=n}return a()(e,[{key:"stringInfo",value:function(){return[{type:this.value,dim:0}]}},{key:"isCompatible",value:function(e){return this.value===e.value&&this.ord===e.ord}}]),e}(),le=function(){function e(t){i()(this,e),this.types=t}return a()(e,[{key:"stringInfo",value:function(){for(var e=[],t=0;t2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i()(this,e),this.type=t,this.id=n,this.byRef=r,this.variadic=o,this._sourceInfo=null}return a()(e,[{key:"sourceInfo",set:function(e){this._sourceInfo=e},get:function(){return this._sourceInfo}}]),e}();var Ie=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this)).id=e,n.actualParameters=t,n}return a()(o,[{key:"toString",value:function(){var e;e=this.isMainCall?Rt.getMainFunctionName():Rt.getLocalName(this.id);var t=null;return t=0==this.actualParameters.length?"()":"("+this.actualParameters.map((function(e){return e.toString()})).join(",")+")",this.parenthesis?"(".concat(e+t,")"):e+t}},{key:"isMainCall",get:function(){return null===this.id}},{key:"parametersSize",get:function(){return this.actualParameters.length}}]),o}($e),Se=Object.freeze({RETURN:Symbol("mode:return"),BREAK:Symbol("mode:break"),PAUSE:Symbol("mode:pause"),RUN:Symbol("mode:run"),ABORT:Symbol("mode:abort")}),Ae=n(776),Ce=n.n(Ae);function Le(e){return new(Ce())(e)}function Oe(e){var t=e.replace(/^"/,"");return(t=(t=(t=(t=(t=(t=(t=t.replace(/"$/,"")).replace(/\\b/g,"\b")).replace(/\\t/g,"\t")).replace(/\\n/g,"\n")).replace(/\\r/g,"\r")).replace(/\\"/g,'"')).replace(/\\'/g,"'")).replace(/\\\\/g,"\\")}function De(e){var t=e.replace(/^'/,"");return(t=(t=(t=(t=(t=(t=(t=t.replace(/'$/,"")).replace(/\\b/g,"\b")).replace(/\\t/g,"\t")).replace(/\\n/g,"\n")).replace(/\\r/g,"\r")).replace(/\\"/g,'"')).replace(/\\'/g,"'"))[0]}function Ge(e){return new(Ce())(e)}function Fe(e){var t=e,n=W.getCurrentLexer();if(n.getReservedKeys()[n.getRules().RK_TRUE]===t)return!0;if(n.getReservedKeys()[n.getRules().RK_FALSE]===t)return!1;throw new Error(e+"not a valid boolean")}function Pe(e){var t=W.getCurrentLexer();return(e?t.getReservedKeys()[t.getRules().RK_TRUE]:t.getReservedKeys()[t.getRules().RK_FALSE]).replace(/'/g,"")}function Me(e,t){switch(t.ord){case ge.INTEGER.ord:return e.toString();case ge.REAL.ord:return e.dp()<=0?e.toFixed(1):e.toFixed(l.decimalPlaces);case ge.BOOLEAN.ord:return Pe(e);default:return e}}var Be=n(506),Ue=n.n(Be),Ke=n(957),ze=n.n(Ke);var Ve=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this,e)).id=t,n._context={},Error.captureStackTrace&&Error.captureStackTrace(Ue()(n),o),n}return a()(o,[{key:"context",get:function(){return this._context},set:function(e){this._context=e}}]),o}(ze()(Error));var qe=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this,e)).id=t,n._context={},Error.captureStackTrace&&Error.captureStackTrace(Ue()(n),o),n}return a()(o,[{key:"context",get:function(){return this._context},set:function(e){this._context=e}}]),o}(ze()(Error));function je(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=It();return new Ve(n.getError(e,t),e)}function He(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=It();return new qe(n.getError(e,t),e)}var Ye=Object.freeze({symbol_not_found_full:function(e,t){if(t){var n=He("symbol_not_found_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Ye.symbol_not_found(e)},symbol_not_found:function(e){return He("symbol_not_found",[e])},function_missing_full:function(e,t){if(t){var n=He("function_missing_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Ye.function_missing(e)},function_missing:function(e){return He("function_missing",[e])},main_missing:function(){return He("main_missing")},array_dimension_not_int_full:function(e){if(e){var t=He("array_dimension_not_int_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Ye.array_dimension_not_int()},array_dimension_not_int:function(){return He("array_dimension_not_int")},unknown_command_full:function(e){if(e){var t=je("unknown_command_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Ye.unknown_command()},unknown_command:function(){return je("unknown_command")},incompatible_types_full:function(e,t,n,r,i,o){var a=It();if(o){var s=He("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 Ye.incompatible_types(e,t,n,r,i)},incompatible_types:function(e,t,n,r,i){var o=It();return He("incompatible_types",[o.translateType(e,t),i,o.translateType(n,r)])},incompatible_types_array_full:function(e,t,n,r){var i=It();if(r){var o=He("incompatible_types_array_full",[e,i.translateType(t,n),r.line,r.column]);return o.context={line:r.line,column:r.column},o}return Ye.incompatible_types_array(e,t,n)},incompatible_types_array:function(e,t,n){return He("incompatible_types_array",[e,It().translateType(t,n)])},loop_condition_type_full:function(e,t){if(t){var n=He("loop_condition_type_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Ye.loop_condition_type(e)},loop_condition_type:function(e){return He("loop_condition_type",[e])},endless_loop_full:function(e){if(e){var t=He("endless_loop_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Ye.endless_loop()},endless_loop:function(){return He("endless_loop")},if_condition_type_full:function(e,t){if(t){var n=He("if_condition_type_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Ye.if_condition_type(e)},if_condition_type:function(e){return He("if_condition_type",[e])},invalid_global_var:function(){return je("invalid_global_var")},not_implemented:function(e){return je("not_implemented",[e])},invalid_case_type_full:function(e,t,n,r){var i=It();if(r){var o=He("invalid_case_type_full",[e,i.translateType(t,n),r.line,r.column]);return o.context={line:r.line,column:r.column},o}return Ye.invalid_case_type(e,t,n)},invalid_case_type:function(e,t,n){return He("invalid_case_type",[e,It().translateType(t,n)])},void_in_expression_full:function(e,t){if(t){var n=He("void_in_expression_full",[t.line,t.column,e]);return n.context={line:t.line,column:t.column},n}return Ye.void_in_expression(e)},void_in_expression:function(e){return He("void_in_expression",[e])},invalid_array_access_full:function(e,t){if(t){var n=He("invalid_array_access_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Ye.invalid_array_access(e)},invalid_array_access:function(e){return He("invalid_array_access",[e])},invalid_matrix_access_full:function(e,t){if(t){var n=He("invalid_matrix_access_full",[e,t.line,t.column]);return n.context={line:t.line,column:t.column},n}return Ye.invalid_matrix_access(e)},invalid_matrix_access:function(e){return He("invalid_matrix_access",[e])},matrix_column_outbounds_full:function(e,t,n,r){if(r){var i=je("matrix_column_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Ye.matrix_column_outbounds(e,t,n)},matrix_column_outbounds:function(e,t,n){return je("matrix_column_outbounds",[t,e,n])},matrix_line_outbounds_full:function(e,t,n,r){if(r){var i=je("matrix_line_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Ye.matrix_line_outbounds(e,t,n)},matrix_line_outbounds:function(e,t,n){return je("matrix_line_outbounds",[t,e,n])},vector_line_outbounds_full:function(e,t,n,r){if(r){var i=je("vector_line_outbounds_full",[r.line,t,e,n]);return i.context={line:r.line,column:r.column},i}return Ye.vector_line_outbounds(e,t,n)},vector_line_outbounds:function(e,t,n){return je("vector_line_outbounds",[t,e,n])},vector_not_matrix_full:function(e,t){if(t){var n=je("vector_not_matrix_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Ye.vector_not_matrix(e)},vector_not_matrix:function(e){return je("vector_not_matrix",[e])},function_no_return:function(e){return He("function_no_return",[e])},invalid_void_return_full:function(e,t,n,r){var i=It();if(r){var o=He("invalid_void_return_full",[r.line,e,i.translateType(t,n)]);return o.context={line:r.line,column:r.column},o}return Ye.invalid_void_return(e,t,n)},invalid_void_return:function(e,t,n){return He("invalid_void_return_full",[e,It().translateType(t,n)])},invalid_return_type_full:function(e,t,n,r){var i=It();if(r){var o=He("invalid_return_type_full",[r.line,e,i.translateType(t,n)]);return o.context={line:r.line,column:r.column},o}return Ye.invalid_return_type(e,t,n)},invalid_return_type:function(e,t,n){return He("invalid_return_type",[e,It().translateType(t,n)])},invalid_parameters_size_full:function(e,t,n,r){if(r){var i=He("invalid_parameters_size_full",[r.line,e,t,n]);return i.context={line:r.line,column:r.column},i}return Ye.invalid_parameters_size(e,t,n)},invalid_parameters_size:function(e,t,n){return He("invalid_parameters_size",[e,t,n])},invalid_parameter_type_full:function(e,t,n){if(n){var r=He("invalid_parameter_type_full",[t,Rt.getLocalName(e),n.line]);return r.context={line:n.line,column:n.column},r}return Ye.invalid_parameter_type(e,t)},invalid_parameter_type:function(e,t){return He("invalid_parameter_type_full",[t,Rt.getLocalName(e)])},invalid_ref_full:function(e,t,n){if(n){var r=He("invalid_ref_full",[t,e,n.line]);return r.context={line:n.line,column:n.column},r}return Ye.invalid_ref(e,t)},invalid_ref:function(e,t){return He("invalid_ref",[t,e])},unexpected_break_command_full:function(e){if(e){var t=je("unexpected_break_command_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Ye.unexpected_break_command()},unexpected_break_command:function(){return je("unexpected_break_command")},invalid_array_literal_type_full:function(e,t){if(t){var n=je("invalid_array_literal_type_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Ye.invalid_array_literal_type(e)},invalid_array_literal_type:function(e){return je("invalid_array_literal_type",[e])},invalid_array_literal_line_full:function(e,t,n){if(n){var r=je("invalid_array_literal_line_full",[n.line,e,t]);return r.context={line:n.line,column:n.column},r}return Ye.invalid_array_literal_type(e,t)},invalid_array_literal_line:function(e,t){return je("invalid_array_literal_line",[e,t])},invalid_array_literal_column_full:function(e,t,n){if(n){var r=je("invalid_array_literal_column_full",[n.line,e,t]);return r.context={line:n.line,column:n.column},r}return Ye.invalid_array_literal_column(e,t)},invalid_array_literal_column:function(e,t){return je("invalid_array_literal_column",[e,t])},invalid_unary_op_full:function(e,t,n,r,i){var o=It();if(i){var a=je("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 Ye.invalid_unary_op(t,n,r)},invalid_unary_op:function(e,t,n,r){var i=It();return je("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=It();if(a){var u=je("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 Ye.invalid_infix_op(t,n,r,i,o)},invalid_infix_op:function(e,t,n,r,i,o){var a=It();return je("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=He("array_dimension_not_positive_full",[e.line]);return t.context={line:e.line,column:e.column},t}return Ye.array_dimension_not_positive()},array_dimension_not_positive:function(){return He("array_dimension_not_positive")},invalid_type_conversion:function(e,t,n){return je("invalid_type_conversion",[e,It().translateType(t,n)])},invalid_read_type:function(e,t,n,r,i){var o=It(),a=je("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=It(),u=je("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=He("invalid_const_ref_full",[t,Rt.getLocalName(e),n.line]);return r.context={line:n.line,column:n.column},r}return Ye.invalid_const_ref(e,t)},invalid_const_ref:function(e,t){return He("invalid_const_ref",[t,Rt.getLocalName(e)])},invalid_const_assignment_full:function(e,t){if(t){var n=He("invalid_const_assignment_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Ye.invalid_const_assignment(e)},invalid_const_assignment:function(e){return He("invalid_const_assignment",[e])},invalid_vector_assignment_full:function(e,t,n,r,i){if(i){var o=je("invalid_vector_assignment_full",[i.line,e,t,n,r]);return o.context={line:i.line,column:i.column},o}return Ye.invalid_vector_assignment(e,t,n,r)},invalid_vector_assignment:function(e,t,n,r){return je("invalid_vector_assignment",[e,t,n,r])},invalid_matrix_assignment_full:function(e,t,n,r,i,o,a){if(a){var s=je("invalid_matrix_assignment_full",[a.line,e,t,n,r,i,o]);return s.context={line:a.line,column:a.column},s}return Ye.invalid_matrix_assignment(e,t,n,r,i,o)},invalid_matrix_assignment:function(e,t,n,r,i,o){return je("invalid_matrix_assignment",[e,t,n,r,i,o])},matrix_to_vector_attr:function(e,t,n){var r=He("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=He("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=je("invalid_matrix_index_assign_full",[o.line,t,e,n,r,i]);return a.context={line:o.line,column:o.column},a}return Ye.invalid_matrix_index_assign(e,t,n,r,i)},invalid_matrix_index_assign:function(e,t,n,r,i){return je("invalid_matrix_index_assign",[t,e,n,r,i])},invalid_number_elements_vector:function(e,t,n,r){var i=je("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=je("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=je("divsion_by_zero_full",[t.line,e]);return n.context={line:t.line,column:t.column},n}return Ye.divsion_by_zero(e)},divsion_by_zero:function(e){return je("divsion_by_zero",[e])},undefined_tanget_value:function(e,t){var n=je("undefined_tanget_value",[t.line,e]);return n.context={line:t.line,column:t.column},n},negative_log_value:function(e){var t=je("negative_log_value",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_string_index:function(e,t,n){var r=Rt.getLocalName("$charAt"),i=je("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=je("negative_sqrt_value",[e.line]);return t.context={line:e.line,column:e.column},t},exceeded_recursive_calls:function(e){var t=je("exceeded_recursive_calls",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_for_variable:function(e,t){var n=He("invalid_for_variable",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_from:function(e,t){var n=He("invalid_for_from",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_to:function(e,t){var n=He("invalid_for_to",[t.line,e]);return n.context={line:t.line,column:t.column},n},invalid_for_pass:function(e,t){var n=He("invalid_for_pass",[t.line,e]);return n.context={line:t.line,column:t.column},n},exceed_max_instructions:function(){return je("exceed_max_instructions")}}),We=function(){function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i()(this,e),u()(this,"type",void 0),u()(this,"id",void 0),u()(this,"isConst",void 0),u()(this,"value",void 0),this.type=t,this.id=r,this.isConst=o,this.value=n}return a()(e,[{key:"get",value:function(){return this.value}},{key:"inStore",value:function(){return null!=this.id}}]),e}(),Ze=function(){function e(t,n){i()(this,e),this.dimensions=n,u()(this,"innerType",void 0),this.innerType=t}return a()(e,[{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:"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)}},{key:"isVector",get:function(){return 1==this.dimensions}},{key:"value",get:function(){}},{key:"ord",get:function(){}}]),e}();var Qe=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n){var a;return i()(this,o),(a=r.call(this)).id=e,a.line=t,a.column=n,a}return a()(o,[{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}}]),o}($e);var Je=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this)).type=e,t}return o}($e);var Xe=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.INTEGER)).value=e,t}return a()(o,[{key:"toString",value:function(){var e=Me(this.value,this.type);return this.parenthesis?"(".concat(e,")"):e}}]),o}(Je);var et=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.REAL)).value=e,t}return a()(o,[{key:"toString",value:function(){var e=Me(this.value,this.type);return this.parenthesis?"(".concat(e,")"):e}}]),o}(Je);var tt=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.BOOLEAN)).value=e,t}return a()(o,[{key:"toString",value:function(){var e=Pe(this.value);return this.parenthesis?"(".concat(e,")"):e}}]),o}(Je);var nt=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.CHAR)).value=e,t}return a()(o,[{key:"toString",value:function(){var e="'".concat(this.value,"'");return this.parenthesis?"(".concat(e,")"):e}}]),o}(Je);var rt=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.STRING)).value=e,t}return a()(o,[{key:"toString",value:function(){var e='"'+this.value+'"';return this.parenthesis?"(".concat(e,")"):e}}]),o}(Je);var it=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this,e)).value=t,n}return a()(o,[{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}},{key:"subtype",get:function(){var e=this.value[0];return e instanceof o?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 o?e.value.length:null}},{key:"isVector",get:function(){return null===this.columns}},{key:"isValid",get:function(){return this.validateSize()&&this.validateType()}}]),o}(Je);var ot=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this,ge.UNDEFINED)).id=e,t}return a()(o,[{key:"toString",value:function(){return this.parenthesis?"(".concat(this.id,")"):this.id}}]),o}(Je);var at=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n){var a;return i()(this,o),(a=r.call(this)).op=e,a.left=t,a.right=n,a}return a()(o,[{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}}]),o}($e);var st=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){return i()(this,o),r.call(this,e,t,null)}return a()(o,[{key:"toString",value:function(){var e=this.left.toString(),t=this.op.value;return this.parenthesis?"(".concat(t+e,")"):t+e}}]),o}(at),ut=function(){function e(t,n,r,o){i()(this,e),this.line=t,this.column=n,this.text=r,this.size=o}return a()(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}(),ct=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 lt(e){switch(e){case"+":return ct.ADD;case"-":return ct.SUB;case"*":return ct.MULT;case"/":return ct.DIV;case"%":return ct.MOD;case">":return ct.GT;case">=":return ct.GE;case"<":return ct.LT;case"<=":return ct.LE;case"==":return ct.EQ;case"!=":return ct.NEQ;case"and":return ct.AND;case"or":return ct.OR;case"not":return ct.NOT}return null}var ft=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t){var n;return i()(this,o),(n=r.call(this,e)).id=t,n._context={},Error.captureStackTrace&&Error.captureStackTrace(Ue()(n),o),n}return a()(o,[{key:"context",get:function(){return this._context},set:function(e){this._context=e}}]),o}(ze()(Error)),pt=It();function dt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new ft(pt.getError(e,t),e)}var ht=Object.freeze({extra_lines:function(){return new ft(pt.getError("extra_lines"))},token_missing_one:function(e,t){var n=dt("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(pt.getOR()),r=ht.token_missing_one(n,t);return r.context={line:t.line,column:t.col},r},id_missing:function(e){var t=dt("id_missing",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},eos_missing:function(e){var t=dt("eos_missing",[e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_array_dimension:function(e,t){var n=dt("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=dt("invalid_array_size",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_main_return:function(e,t,n){var r=dt("invalid_main_return",[e,t,n.line]);return r.context={line:n.line,column:n.col},r},invalid_var_declaration:function(e){var t=dt("invalid_var_declaration",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_break_command:function(e,t){var n=dt("invalid_break_command",[t.line,e]);return n.context={line:t.line,column:t.col},n},invalid_terminal:function(e){var t=dt("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(pt.getOR()),r=dt("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=dt("const_not_init",[e.line,e.col]);return t.context={line:e.line,column:e.col},t},invalid_id_format:function(e){var t=dt("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=dt("duplicate_function",[e.text,e.line,e.col]);return t.context={line:e.line,column:e.col},t},main_parameters:function(){return dt("main_parameters")},duplicate_variable:function(e){var t=dt("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=dt("invalid_character",[e,t]);return r.context={line:t,column:n},r},annonymous_array_literal:function(e){var t=dt("annonymous_array_literal",[e.line]);return t.context={line:e.line,column:e.col},t},invalid_matrix_literal_line:function(e,t){var n=dt("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=dt("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=dt("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=dt("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=dt("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=dt("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=dt("array_init_not_literal",[e.line]);return t.context={line:e.line,column:e.column},t},array_exceeds_2d:function(e){var t=dt("array_exceeds_2d",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_matrix_id_dimension:function(e){var t=dt("invalid_matrix_id_dimension",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_vector_init:function(e){var t=dt("invalid_vector_init",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_matrix_init:function(e){var t=dt("invalid_matrix_init",[e.line]);return t.context={line:e.line,column:e.column},t},invalid_syntax:function(e,t,n){var r=dt("invalid_syntax",[e,t]);return r.context={line:t,column:n},r}}),mt=function(){function e(t,n){i()(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=N()(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 a()(e,null,[{key:"createParser",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=W.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"}}}]),a()(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 ht.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()),ht.extra_lines();return this.popVariableStack(),{global:t,functions:n}}throw ht.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 ht.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 ht.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 ht.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 ht.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 ht.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 ht.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 ht.eos_missing(t)}return!0}},{key:"checkFunctionDuplicate",value:function(e,t){var n=null===e?"$main":e;if(-1!==this.definedFuncsNameList.indexOf(n))throw ht.duplicate_function(t);this.definedFuncsNameList.push(n)}},{key:"checkVariableDuplicate",value:function(e,t){if(-1!==this.getCurrentVariableStack().indexOf(e))throw ht.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 ht.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 ht.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=ut.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 ht.const_not_init(a);u.type===this.ruleNames.ASSIGNMENT&&(this.pos++,n=this.parseExpressionOR());var c=new oe(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 ot||a instanceof ot)&&(f=!0,i>1&&(null==o||null==a)))throw ht.invalid_matrix_id_dimension(ut.createSourceInfo(s));if(t&&s.type!==this.ruleNames.ASSIGNMENT)throw ht.const_not_init(r);if(s.type===this.ruleNames.ASSIGNMENT){if(f)throw 1==i?ht.invalid_vector_init(ut.createSourceInfo(s)):ht.invalid_matrix_init(ut.createSourceInfo(s));this.pos+=1,l=this.parseArrayLiteral(e)}if(null==l&&null==o){if(i>1)throw ht.cannot_infer_matrix_line(n,r);throw ht.cannot_infer_vector_size(n,r)}if(i>1&&null==l&&null==a)throw ht.cannot_infer_matrix_column(n,r);if(1===i&&null!=l&&!l.isVector){var p=l.toString();throw ht.matrix_to_vector_literal_attr(n,p,l.sourceInfo)}if(i>1&&null!=l&&l.isVector){var d=l.toString();throw ht.vector_to_matrix_literal_attr(n,d,l.sourceInfo)}null==o&&((u=new Xe(Le(l.lines))).sourceInfo=r),i>1&&null==a&&((c=new Xe(Le(l.columns))).sourceInfo=r);var h=new ae(n,new Ze(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 ht.invalid_array_dimension(this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_INTEGER],e)}},{key:"getIntLiteral",value:function(e){var t=e.text,n=ut.createSourceInfo(e),r=new Xe(Le(t));return r.sourceInfo=n,r}},{key:"getRealLiteral",value:function(e){var t=ut.createSourceInfo(e),n=new et(Ge(e.text));return n.sourceInfo=t,n}},{key:"getStringLiteral",value:function(e){var t=e.text,n=ut.createSourceInfo(e),r=new rt(Oe(t));return r.sourceInfo=n,r}},{key:"getCharLiteral",value:function(e){var t=e.text,n=new nt(De(t));return n.sourceInfo=ut.createSourceInfo(e),n}},{key:"getBoolLiteral",value:function(e){var t=Fe(e.text),n=new tt(t);return n.sourceInfo=ut.createSourceInfo(e),n}},{key:"parseArrayLiteral",value:function(e){if(!this.checkOpenCurly(!0)){var t=this.getToken();throw ht.array_init_not_literal(ut.createSourceInfo(t))}var n=this.getToken();if(this.parsingArrayDimension>=2)throw ht.array_exceeds_2d(ut.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=ut.createSourceInfoFromList(n,i),a=1;r[0]instanceof it?a+=1:1==r.length&&console.log("Talvez uma variável seja uma melhor opção");var s=new Ze(e,a),u=new it(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 ht.array_exceeds_2d(ut.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=ut.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 ht.invalid_matrix_literal_line(s,a)}var u=new Ze(e,1),c=new it(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=ut.createSourceInfo(e),n=new ot(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 Ze(r,i));var c=new xe(a,u,t,s);if(null===a&&!c.isMain)throw ht.invalid_main_return(Rt.getMainFunctionName(),this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_VOID],n.line);if(c.isMain&&0!==t.length)throw ht.main_parameters();return this.popScope(),c.sourceInfo=ut.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 Ze(r,t):r;var s=new Ne(a,o,n);if(s.sourceInfo=ut.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 ht.id_missing(t);return this.pos++,this.insideScope(e.FUNCTION)&&t.text===Rt.getMainFunctionName()?null:t.text}},{key:"parseMaybeLibID",value:function(){var e=this.getToken();if(e.type!==this.ruleNames.ID)throw ht.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 ht.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 ge.VOID;if(t.type===this.ruleNames.RK_VOID&&this.insideScope(e.FUNCTION))return this.pos++,ge.VOID;if(this.isVariableType(t))switch(this.pos++,t.type){case this.ruleNames.RK_INTEGER:return ge.INTEGER;case this.ruleNames.RK_BOOLEAN:return ge.BOOLEAN;case this.ruleNames.RK_REAL:return ge.REAL;case this.ruleNames.RK_STRING:return ge.STRING;case this.ruleNames.RK_CHARACTER:return ge.CHAR}throw ht.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 ht.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 we(t,n)}},{key:"parseCommand",value:function(){var t=this.getToken();if(this.isVariableType(t)){if(!this.insideScope(e.FUNCTION))throw ht.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 ht.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 ht.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 Re(n,r);return i.sourceInfo=ut.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 ht.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 Ee(i,n);return o.sourceInfo=ut.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 ht.token_missing_list([this.ivprogLexer.getReservedKeys()[this.ruleNames.RK_IF],"{"],i);o=this.parseIfThenElse()}this.popScope();var a=new be(n,r,o);return a.sourceInfo=ut.createSourceInfo(t),a}this.popScope();var s=new be(n,r,null);return s.sourceInfo=ut.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 ot(r);i.sourceInfo=ut.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 ue(i,o,a,s,u);return c.sourceInfo=ut.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 se(n,r);return i.sourceInfo=ut.createSourceInfo(t),i}},{key:"parseBreak",value:function(){var e=this.getToken();this.pos++,this.checkEOS(),this.pos++;var t=new te;return t.sourceInfo=ut.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 ne(t);return n.sourceInfo=ut.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 ht.token_missing_one("<-",o);this.pos++;var a=this.parseExpressionOR();this.checkEOS(),this.pos++;var s=new ie(t,r,i,a);return s.sourceInfo=ut.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 re(t,c);return l.sourceInfo=ut.createSourceInfo(u),l}if(u.type===this.ruleNames.OPEN_PARENTHESIS){var f=this.parseFunctionCallCommand(t);return this.checkEOS(),this.pos++,f}throw n?ht.token_missing_list(["<-","("],u):ht.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 ot(this.parseID())).sourceInfo=ut.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 st(lt(o),a)),a}},{key:"parseCases",value:function(){var e=this.getToken();if(e.type!==this.ruleNames.RK_CASE)throw ht.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 ht.token_missing_one(":",t);this.pos++,this.consumeNewLines();var n=this.parseCommandBlock(!0),r=new ke(null);return r.sourceInfo=ut.createSourceInfo(e),r.setCommands(n.commands),[r]}var i=this.parseExpressionOR(),o=this.getToken();if(o.type!==this.ruleNames.COLON)throw ht.token_missing_one(":",o);this.pos++,this.consumeNewLines();var a=this.parseCommandBlock(!0),s=new ke(i);return s.sourceInfo=ut.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=lt("or");this.consumeNewLines();var r=this.parseExpressionAND(),i=new at(n,e,r);i.sourceInfo=ut.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=lt("and");this.consumeNewLines();var r=this.parseExpressionNot(),i=new at(n,e,r);i.sourceInfo=ut.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=lt("not"),n=this.parseExpressionRel(),r=new st(t,n);return r.sourceInfo=ut.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=lt(t.text),r=this.parseExpression(),i=new at(n,e,r);i.sourceInfo=ut.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=lt(t.text),r=this.parseFactor(),i=new at(n,e,r);i.sourceInfo=ut.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=lt(t.text),r=this.parseTerm(),i=new at(n,e,r);i.sourceInfo=ut.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=ut.createSourceInfo(e),(n=new st(lt(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 ht.annonymous_array_literal(e);case this.ruleNames.ID:return this.parseIDTerm();case this.ruleNames.OPEN_PARENTHESIS:return this.parseParenthesisExp();default:throw ht.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=ut.createSourceInfoFromList(e,r),s=new Qe(t,i,o);return s.sourceInfo=a,s}if(this.checkOpenParenthesis(!0))return this.parseFunctionCallExpression(t);if(n){var u=ut.createSourceInfo(e),c=new ot(t);return c.sourceInfo=u,c}throw ht.invalid_id_format(e)}},{key:"getFunctionName",value:function(e){var t=Rt.getInternalName(e);return null===t?e===Rt.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=ut.createSourceInfoFromList(n,i),s=new Ie(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=ut.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]}))}}]),e}(),_t=n(319),vt=n.n(_t);function yt(e){return e.times(Ae.Decimal.acos(-1)).div(180)}var gt=Date.now();function xt(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]===e)return n;return null}var bt,wt,Et={$mathLib:{$sin:(bt=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().mod(360),null,o=i.eq(90)?new Ae.Decimal(1):i.eq(180)?new Ae.Decimal(0):i.eq(270)?new Ae.Decimal(-1):Ae.Decimal.sin(yt(i)),a=new We(ge.REAL,o),t.insertStore("$",a),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)}}(),wt=new we([],[new Te(bt)]),new xe("$sin",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],wt)),$cos:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().mod(360),o=null,i.eq(90)?o=new Ae.Decimal(0):i.eq(180)?o=new Ae.Decimal(-1):i.eq(270)&&(o=new Ae.Decimal(0)),o=Ae.Decimal.cos(yt(i)),a=new We(ge.REAL,o),t.insertStore("$",a),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)}}(),t=new we([],[new Te(e)]);return new xe("$cos",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$tan:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().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 Ye.undefined_tanget_value(r.get().toNumber(),this.function_call_stack.pop());case 4:return o=Ae.Decimal.tan(yt(i)),a=new We(ge.REAL,o),t.insertStore("$",a),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)}}(),t=new we([],[new Te(e)]);return new xe("$tan",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$sqrt:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().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(Ye.negative_sqrt_value(this.function_call_stack.pop())));case 3:return i=r.get().sqrt(),o=new We(ge.REAL,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$sqrt",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$pow:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=t.applyStore("y"),o=r.get().pow(i.get()),a=new We(ge.REAL,o),t.insertStore("$",a),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)}}(),t=new we([],[new Te(e)]);return new xe("$pow",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1),new Ne(new le([ge.INTEGER,ge.REAL]),"y",!1)],t)}(),$log:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().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(Ye.negative_log_value(this.function_call_stack.pop())));case 3:return i=Ae.Decimal.log10(r.get()),o=new We(ge.REAL,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$log",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$abs:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().abs(),o=new We(r.type,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$abs",new le([ge.INTEGER,ge.REAL]),[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$negate:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=r.get().negated(),o=new We(r.type,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$negate",new le([ge.INTEGER,ge.REAL]),[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$invert:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("x"),i=Ge(1).dividedBy(r.get()),o=new We(ge.REAL,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$invert",ge.REAL,[new Ne(new le([ge.INTEGER,ge.REAL]),"x",!1)],t)}(),$max:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().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()})),o=Ae.Decimal.max.apply(Ae.Decimal,vt()(i)),a=new We(r.type.innerType,o),t.insertStore("$",a),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)}}(),t=new Ze(new le([ge.INTEGER,ge.REAL]),1),n=new we([],[new Te(e)]);return new xe("$max",new le([ge.INTEGER,ge.REAL]),[new Ne(t,"x",!1)],n)}(),$min:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().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()})),o=Ae.Decimal.min.apply(Ae.Decimal,vt()(i)),a=new We(r.type.innerType,o),t.insertStore("$",a),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)}}(),t=new Ze(new le([ge.INTEGER,ge.REAL]),1),n=new we([],[new Te(e)]);return new xe("$min",new le([ge.INTEGER,ge.REAL]),[new Ne(t,"x",!1)],n)}(),$rand:function(){var e=2147483647,t=function(){var t=X()(Q().mark((function t(n,r){var i,o;return Q().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=(gt=(16807*gt+12345)%e)/(e-1),o=new We(ge.REAL,new Ae.Decimal(i)),n.insertStore("$",o),n.mode=Se.RETURN,t.abrupt("return",n);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),n=new we([],[new Te(t)]);return new xe("$rand",ge.REAL,[],n)}()},$ioLib:{$read:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,l,f;return Q().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,o=null,a=null,e.prev=6,!i.isCompatible(ge.INTEGER)){e.next=12;break}a=Le(r.trim()).trunc(),o=ge.INTEGER,e.next=33;break;case 12:if(!i.isCompatible(ge.REAL)){e.next=17;break}a=Ge(r.trim()),o=ge.REAL,e.next=33;break;case 17:if(!i.isCompatible(ge.BOOLEAN)){e.next=22;break}a=Fe(r.trim()),o=ge.BOOLEAN,e.next=33;break;case 22:if(!i.isCompatible(ge.STRING)){e.next=27;break}a=Oe(r),o=ge.STRING,e.next=33;break;case 27:if(!i.isCompatible(ge.CHAR)){e.next=32;break}a=De(r),o=ge.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(s=i.stringInfo()[0],!((u=t.getStoreObject("p1")).getReferenceDimension()>0)){e.next=46;break}throw c=u.type.stringInfo()[0],l=u.getReferenceDimension(),Ye.invalid_read_type_array(r,s.type,s.dim,u.getRefObj(),c.type,l,this.function_call_stack.pop());case 46:throw Ye.invalid_read_type(r,s.type,s.dim,u.getRefObj(),this.function_call_stack.pop());case 47:return f=new We(o,a),t.updateStore("p1",f),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)}}(),t=new we([],[new Te(e)]);return new xe("$read",ge.VOID,[new Ne(ge.ALL,"p1",!0)],t)}(),$write:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=t.applyStore("p1.0"),i=r.get(),o=1;o=r.get().length)){e.next=4;break}throw Ye.invalid_string_index(i.get().toNumber(),r.get(),this.function_call_stack.pop());case 4:return o=new We(ge.CHAR,r.get().charAt(i.get().toNumber())),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$charAt",ge.CHAR,[new Ne(ge.STRING,"str",!1),new Ne(ge.INTEGER,"index",!1)],t)}()},$arrayLib:{$numElements:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("vector"),i=new We(ge.INTEGER,Le(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)}}(),t=new we([],[new Te(e)]);return new xe("$numElements",ge.INTEGER,[new Ne(new Ze(ge.ALL,1),"vector",!1)],t)}(),$matrixLines:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("matrix"),i=new We(ge.INTEGER,Le(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)}}(),t=new we([],[new Te(e)]);return new xe("$matrixLines",ge.INTEGER,[new Ne(new Ze(ge.ALL,2),"matrix",!1)],t)}(),$matrixColumns:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("matrix"),i=new We(ge.INTEGER,Le(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)}}(),t=new we([],[new Te(e)]);return new xe("$matrixColumns",ge.INTEGER,[new Ne(new Ze(ge.ALL,2),"matrix",!1)],t)}()},$langLib:{$isReal:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("str"),i=mt.createParser(r.get()),o=!1;try{i.parseTerm()instanceof et&&(o=!0)}catch(e){}return a=new We(ge.BOOLEAN,o),t.insertStore("$",a),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)}}(),t=new we([],[new Te(e)]);return new xe("$isReal",ge.BOOLEAN,[new Ne(ge.STRING,"str",!1)],t)}(),$isInt:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.applyStore("str"),i=mt.createParser(r.get()),o=!1;try{i.parseTerm()instanceof Xe&&(o=!0)}catch(e){}return a=new We(ge.BOOLEAN,o),t.insertStore("$",a),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)}}(),t=new we([],[new Te(e)]);return new xe("$isInt",ge.BOOLEAN,[new Ne(ge.STRING,"str",!1)],t)}(),$isBool:function(){var e=new we([],[new Te((function(e,t){var n=e.applyStore("str"),r=mt.createParser(n.get()),i=!1;try{r.parseTerm()instanceof tt&&(i=!0)}catch(e){}var o=new We(ge.BOOLEAN,i);return e.insertStore("$",o),e.mode=Se.RETURN,e}))]);return new xe("$isBool",ge.BOOLEAN,[new Ne(ge.STRING,"str",!1)],e)}(),$castReal:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,l;return Q().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===ge.INTEGER.ord?5:e.t0===ge.STRING.ord?10:22;break;case 5:return i=i.toNumber(),o=new We(ge.REAL,Ge(i)),t.insertStore("$",o),t.mode=Se.RETURN,e.abrupt("return",t);case 10:if(a=mt.createParser(i),e.prev=11,!((s=a.parseTerm())instanceof et)){e.next=18;break}return u=new We(ge.REAL,Ge(s.value)),t.insertStore("$",u),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 c=ge.REAL.stringInfo(),l=c[0],Ye.invalid_type_conversion(i,l.type,l.dim);case 25:case"end":return e.stop()}}),e,null,[[11,20]])})));return function(t,n){return e.apply(this,arguments)}}(),t=new we([],[new Te(e)]);return new xe("$castReal",ge.REAL,[new Ne(new le([ge.INTEGER,ge.STRING]),"val",!1)],t)}(),$castInt:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,l,f;return Q().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===ge.REAL.ord?5:e.t0===ge.CHAR.ord?10:e.t0===ge.STRING.ord?14:26;break;case 5:return i=i.toNumber(),o=new We(ge.INTEGER,Le(Math.floor(i))),t.insertStore("$",o),t.mode=Se.RETURN,e.abrupt("return",t);case 10:return a=new We(ge.INTEGER,Le(i.charCodeAt(0))),t.insertStore("$",a),t.mode=Se.RETURN,e.abrupt("return",t);case 14:if(s=mt.createParser(i),e.prev=15,!((u=s.parseTerm())instanceof Xe)){e.next=22;break}return c=new We(ge.INTEGER,Le(u.value)),t.insertStore("$",c),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 l=ge.INTEGER.stringInfo(),f=l[0],Ye.invalid_type_conversion(i,f.type,f.dim);case 29:case"end":return e.stop()}}),e,null,[[15,24]])})));return function(t,n){return e.apply(this,arguments)}}(),t=new we([],[new Te(e)]);return new xe("$castInt",ge.INTEGER,[new Ne(new le([ge.REAL,ge.STRING,ge.CHAR]),"val",!1)],t)}(),$castBool:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.applyStore("str"),i=r.get(),o=mt.createParser(i),e.prev=3,!((a=o.parseTerm())instanceof tt)){e.next=10;break}return s=new We(ge.BOOLEAN,a.value),t.insertStore("$",s),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 u=ge.BOOLEAN.stringInfo(),c=u[0],Ye.invalid_type_conversion(i,c.type,c.dim);case 17:case"end":return e.stop()}}),e,null,[[3,12]])})));return function(t,n){return e.apply(this,arguments)}}(),t=new we([],[new Te(e)]);return new xe("$castBool",ge.BOOLEAN,[new Ne(ge.STRING,"str",!1)],t)}(),$castString:function(){var e=function(){var e=X()(Q().mark((function e(t,n){var r,i,o;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.applyStore("str"),i=Me(r.get(),r.type),o=new We(ge.STRING,i),t.insertStore("$",o),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)}}(),t=new we([],[new Te(e)]);return new xe("$castString",ge.STRING,[new Ne(ge.ALL,"str",!1)],t)}(),$castChar:function(){var e=new we([],[new Te((function(e,t){var n=255&e.applyStore("charCode").get().toNumber(),r=String.fromCharCode(n),i=new We(ge.CHAR,r);return e.insertStore("$",i),e.mode=Se.RETURN,e}))]);return new xe("$castChar",ge.CHAR,[new Ne(ge.INTEGER,"charCode",!1)],e)}()}},$t=function(){for(var e={},t=0;t2&&void 0!==arguments[2]&&arguments[2];return i()(this,o),r.call(this,e,t,n)}return a()(o,[{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 ct.AND.ord:case ct.OR.ord:case ct.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?Rt.getLocalName(e):Rt.getLocalName("".concat(t,".").concat(e))}}]),o}(d.LocalizedStrings),Tt=Object.freeze(new kt(W,k)),Nt=new kt(W,k);function It(){return Nt}var St=d.StringTypes,At=Object.freeze({i18n:function(e){var t=e.split(":"),n=t[0].toLowerCase(),r=t[1];return St.ERROR===n?Tt.getError(r):St.MESSAGE===n?Tt.getMessage(r):St.UI===n?Tt.getUI(r):(console.warn("A string has been passed to the i18n helper function that was not in the form type:id -> "+e),Tt.getString(e,n))}});function Ct(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 Lt=null;function Ot(e){e.preventDefault();var t=e.currentTarget.dataset.page;null!=Lt&&Lt.close(),(Lt=window.open("","DetailWindow","width=550,height=600")).document.open(),Lt.document.write(t),Lt.document.close()}function Dt(e){return Gt.apply(this,arguments)}function Gt(){return(Gt=X()(Q().mark((function e(t){return Q().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 Ft(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Pt(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)?Pt(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=e[Symbol.iterator]()},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 Pt(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 n={};return e.forEach((function(e,r){return n[t[r]]=e})),n})),l=c.reduce(r,new Map),f=function(){var e=X()(Q().mark((function e(t){var n,r,i;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(s).concat(t.file),r=o.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)}}(),p={},d=0,l.forEach((function(e,t){var r=[];e.forEach(function(){var e=X()(Q().mark((function e(i,o){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=i.sort((function(e,t){return parseInt(e.timestamp)-parseInt(t.timestamp)})),d++,i.forEach(function(){var e=X()(Q().mark((function e(i,a,s){var u,c,l,p,h,m,_,v,y,g;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d++,(u={}).grade=Math.max(0,parseFloat(i.grade)),u.timestamp=parseInt(i.timestamp),u.student_id=o,u.TES=0,u.DES=0,u["D/T"]=0,c="",!(a>0)){e.next=19;break}return u.TES=parseInt(i.timestamp)-parseInt(s[a-1].timestamp),e.next=13,f(s[a-1]);case 13:if(l=e.sent,1!=(p=window.ivprogCore.prepareActivityToStudentHelper(l).getOrElse(1))){e.next=18;break}return console.error("A submission from ".concat(o," to ").concat(t," is invalid")),e.abrupt("return");case 18:c=n(p.algorithmInIlm);case 19:return e.next=21,f(i);case 21:if(h=e.sent,2!=(m=window.ivprogCore.prepareActivityToStudentHelper(h).getOrElse(2))){e.next=26;break}return console.error("A submission from ".concat(o," to ").concat(t," is invalid")),e.abrupt("return");case 26:_=n(m.algorithmInIlm),""===c&&(v=JSON.parse(h.split("::logs::")[1]),null==(y=v[0])?u.TES=0:4===y.length?u.TES=parseInt(i.timestamp)-Math.floor(parseInt(y[2])/1e3):u.TES=parseInt(i.timestamp)-Math.floor(parseInt(y[1])/1e3)),u.DES=window.ivprogCore.levenshteinDistance(c,_),g=0===u.TES?0:u.DES/u.TES,u["D/T"]=isNaN(g)?0:g,r.push(u),d--;case 33:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()),d--;case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),p[t]=r})),_=setInterval((function(){if(0==d)for(var e in clearInterval(_),p){var t="",n="student_id,";n+=m(e);var r,i=Ft(p[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()}h("".concat(e,".csv"),"".concat(n,"\n").concat(t))}}),1e3);case 15:case"end":return i.stop()}}),i)}))))}var Bt="var",Ut="const",Kt="relational",zt="logic",Vt="arithmetic";function qt(e,t){switch(e){case Vt:case Kt:return t.value;case zt:return 11===t.ord?"and":12===t.ord?"or":"not"}}function jt(e){switch(e.ord){case 0:case 1:case 2:case 3:case 4:return Vt;case 5:case 6:case 7:case 8:case 9:case 10:return Kt;default:return zt}}function Ht(e){var t=e.commands.map(Wt),n=e.isDefault?null:en(e.expression);return{type:"switchcase",line:e.sourceInfo.line,expression:n,commands:t}}function Yt(e){var t=en(e.condition),n=e.ifTrue.commands.map(Wt),r=[];return e.ifFalse&&(r=e.ifFalse instanceof we?e.ifFalse.commands.map(Wt):[Yt(e.ifFalse)]),{type:"iftrue",expression:t,ifTrue:n,ifFalse:r}}function Wt(e){var t,n,r,i,o,a=null;if(e instanceof Ie)a=function(e){var t=e.id;-1!==t.indexOf(".")&&(t=t.split(".")[1]);var n=e.actualParameters.map(en);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 re)a=function(e){var t=null;if(e instanceof ie){var n=en(e.line),r="vector",i=null;e.column&&(r="matrix",i=en(e.column)),t=[{instance:"expression",type:Bt,class:r,column:i,line:n,value:e.id}]}else t=[{instance:"expression",type:Bt,value:e.id}];return{type:"attribution",variable:t,expression:en(e.expression)}}(e);else if(e instanceof be)a=Yt(e);else if(e instanceof se)i=en((r=e).expression),o=r.commands.map(Wt),a={type:r.testFirst?"whiletrue":"dowhiletrue",expression:i,commands:o};else if(e instanceof te)a={type:"break"};else if(e instanceof ne)a={type:"return",expression:en(e.expression)};else if(e instanceof Re)a={type:"switch",expression:en((n=e).expression),cases:n.cases.map(Ht)};else{if(!(e instanceof ue))throw new Error("not implemented");a={type:"repeatNtimes",var_attribution:en((t=e).for_id),var_initial:en(t.for_from),condition:en(t.for_to),step_expression:t.for_pass?en(t.for_pass):[],commands:t.commands.map(Wt)}}return a.line=e.sourceInfo.line,a}function Zt(e){var t={name:e.name,line:e.sourceInfo.line,return_type:"",return_dimensions:0,parameters_list:[],variables_list:[],commands:[]};return e.returnType instanceof Ze?(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(Qt),t.variables_list=e.variablesDeclarations.map(Jt),t.commands=e.commands.map(Wt),t}function Qt(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 Ze?(t.type=e.type.innerType.value,t.dimension=e.type.dimensions):t.type=e.type.value,t}function Jt(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 ae){var r=en(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 Xt(e)}));n.value=i}else{var o=en(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 Xt(e)}))}));n.value=a}}else n.type=e.type.value,n.value=Xt(e.initial);return n}function Xt(e){if(e instanceof st){var t=Xt(e.left);if(jt(e.op)!==Vt)throw new Error("invalid variable initial value: "+e.toString());return"".concat(e.op.value).concat(t)}if(e instanceof tt)return Pe(e.value);if(e instanceof Je){var n=e.value;return e.value.toNumber&&(n=ge.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 en(e){var t;if(e instanceof ot)t=[{instance:"expression",type:Bt,value:e.id}];else if(e instanceof Ie){var n={instance:"expression",type:"function",value:e.id},r=e.actualParameters.map((function(e){return en(e)}));n.params=r,t=[n]}else if(e instanceof st){var i=en(e.left),o=jt(e.op);t=[{instance:"operator",type:o,value:qt(o,e.op)}].concat(vt()(i))}else if(e instanceof at){var a=en(e.left),s=en(e.right),u=jt(e.op),c=qt(u,e.op);t=[].concat(vt()(a),[{instance:"operator",type:u,value:c}],vt()(s))}else if(e instanceof Qe){var l=en(e.line),f="vector",p=null;e.column&&(f="matrix",p=en(e.column)),t=[{instance:"expression",type:Bt,class:f,column:p,line:l,value:e.id}]}else if(e instanceof tt){var d=e.value;t=[{instance:"expression",class:"simple",type:Ut,value:Pe(d)}]}else{var h=e.value;e.value.toNumber&&(h=ge.REAL.isCompatible(e.type)&&0==e.value.decimalPlaces()?Number(e.value.toFixed(2)):e.value.toNumber()),t=[{instance:"expression",class:"simple",type:Ut,value:h}]}return e.parenthesis?["("].concat(vt()(t),[")"]):t}function tn(e){return en(mt.createParser(e).parseExpressionOR())}function nn(e){for(var t=mt.createParser(e,!1),n=new Map,r=[],i=0,o=Array.from(t.lexer.reset(e));i=5&&e.ord<=10)return ge.BOOLEAN}return ge.UNDEFINED}return s}catch(e){if(e instanceof TypeError)return ge.UNDEFINED;throw e}}function hn(e,t){try{if(t instanceof le){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];i()(this,e),u()(this,"_type",void 0),u()(this,"_loc_address",void 0),u()(this,"_readOnly",void 0),u()(this,"_id",void 0),this._loc_address=n,this._type=t,this._readOnly=r,this._id=void 0}return a()(e,[{key:"setID",value:function(e){this._id=e}},{key:"isCompatible",value:function(e){return this.type.isCompatible(e.type)}},{key:"destroy",value:function(){return vn.deallocate(this._loc_address)}},{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=vn.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:"locAddress",get:function(){return this._loc_address}}]),e}();var gn=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),t=r.call(this,e.type,e.getRefAddress(),!1),u()(Ue()(t),"refObj",void 0),u()(Ue()(t),"reference_dimension",void 0),t.refObj=e.id,t.reference_dimension=e.getReferenceDimension(),t}return a()(o,[{key:"getRefObj",value:function(){return this.refObj}},{key:"getReferenceDimension",value:function(){return this.reference_dimension}},{key:"destroy",value:function(){return!1}},{key:"isRef",get:function(){return!0}}]),o}(yn);var xn=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e,t,n,a,s){var u,c=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return i()(this,o),(u=r.call(this,e,t,s,c)).line=n,u.column=a,u}return o}(We),bn=function(){function e(t,n,r,o,a){var s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];i()(this,e),u()(this,"type",void 0),u()(this,"id",void 0),u()(this,"isConst",void 0),u()(this,"lines",void 0),u()(this,"columns",void 0),u()(this,"values",void 0),this.type=t,this.id=a,this.isConst=s,this.values=n,this.lines=r,this.columns=o}return a()(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 i()(this,o),(s=r.call(this,e,-1,u))._lines=t,s._columns=n,s.loc_addresses=a,s}return a()(o,[{key:"isCompatible",value:function(e){if(e instanceof bn){var t=null==e.columns?0:e.columns;if(this.lines===e.lines&&this.columns===t)return En()(g()(o.prototype),"isCompatible",this).call(this,e)}return!1}},{key:"destroy",value:function(){for(var e=!0,t=0;t=r.columns&&(a=0,o+=1),new xn(i.innerType,e,o,a++,r.id,r.readOnly))}));n=new bn(i,s,r.lines,r.columns,t.id,t.readOnly)}else n=new We(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 $n){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 vn.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 $n))throw new Error("Cannot update a non-array variable using updateStoreArray");if(t instanceof bn){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(ge.VOID);if(!this.assertReturn(e,n))throw Ye.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 se){if(!this.evaluateExpressionType(t.expression).isCompatible(ge.BOOLEAN))throw Ye.loop_condition_type_full(t.expression.toString(),t.sourceInfo);return this.checkCommands(e,t.commands,n),!1}if(t instanceof ue){if(!this.evaluateExpressionType(t.for_id).isCompatible(ge.INTEGER))throw Ye.invalid_for_variable(t.for_id,t.sourceInfo);if(!this.evaluateExpressionType(t.for_from).isCompatible(ge.INTEGER))throw Ye.invalid_for_from(t.for_from,t.sourceInfo);if(!this.evaluateExpressionType(t.for_to).isCompatible(ge.INTEGER))throw Ye.invalid_for_to(t.for_to,t.sourceInfo);if(null!=t.for_pass&&!this.evaluateExpressionType(t.for_pass).isCompatible(ge.INTEGER))throw Ye.invalid_for_pass(t.for_pass,t.sourceInfo);return this.checkCommands(e,t.commands,n),!1}if(t instanceof Re){for(var r=this.evaluateExpressionType(t.expression),i=n,o=!1,a=0;at.length||n.length!==t.length&&!e.hasVariadic())throw Ye.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 Ye.invalid_parameters_size(a,n.length,r.length);case 4:u=0,c=0;case 5:if(!(u5&&void 0!==b[5]?b[5]:0,e.next=3,this.evaluateExpression(i,r);case 3:if(s=e.sent,u=!1,n.type.isCompatible(s.type)){e.next=11;break}if(!l.enable_type_casting||n.byRef||!Nn.canImplicitTypeCast(n.type,s.type)){e.next=10;break}u=!0,e.next=11;break;case 10:throw Ye.invalid_parameter_type(t,r.toString());case 11:if(!n.byRef||s.inStore()){e.next=13;break}throw Ye.invalid_ref(t,r.toString());case 13:return n.byRef?(c=i.getStoreObject(s.id),f=null,s instanceof bn?(p=s.get(),d=s.type,h=p.map((function(e){return c.getLocAddressOf(e.line,e.column)})),m=s.isVector()?0:s.columns,f=new kn(d,p,h,s.lines,m,c.id)):s instanceof xn?(_=s.line,v=s.column,(f=new Rn(s.type,s.get(),c.getLocAddressOf(_,v),c.id)).setReferenceDimension(c.type.dimensions)):f=new Rn(s.type,s.get(),c.locAddress,c.id),y=n.id,n.variadic&&(y="".concat(y,".").concat(a)),o.insertStore(y,f)):(g=s,u&&(g=Nn.doImplicitCasting(n.type,g)),x=n.id,n.variadic&&(x="".concat(x,".").concat(a)),o.insertStore(x,g)),e.abrupt("return",o);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r,i){return S.apply(this,arguments)})},{key:"executeCommands",value:(I=X()(Q().mark((function e(t,n){var r,i;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t,i=0;case 2:if(!(i=l.max_instruction_count)){e.next=8;break}throw Ye.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(Sn.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 Tt.getMessage("aborted_execution");case 26:if(!(n instanceof oe)){e.next=30;break}return e.abrupt("return",this.executeDeclaration(t,n));case 30:if(!(n instanceof ie)){e.next=34;break}return e.abrupt("return",this.executeArrayIndexAssign(t,n));case 34:if(!(n instanceof re)){e.next=38;break}return e.abrupt("return",this.executeAssign(t,n));case 38:if(!(n instanceof te)){e.next=42;break}return e.abrupt("return",this.executeBreak(t,n));case 42:if(!(n instanceof ne)){e.next=46;break}return e.abrupt("return",this.executeReturn(t,n));case 46:if(!(n instanceof be)){e.next=50;break}return e.abrupt("return",this.executeIfThenElse(t,n));case 50:if(!(n instanceof Ee)){e.next=54;break}return e.abrupt("return",this.executeRepeatUntil(t,n));case 54:if(!(n instanceof se)){e.next=58;break}return e.abrupt("return",this.executeWhile(t,n));case 58:if(!(n instanceof ue)){e.next=62;break}return e.abrupt("return",this.executeFor(t,n));case 62:if(!(n instanceof Re)){e.next=66;break}return e.abrupt("return",this.executeSwitch(t,n));case 66:if(!(n instanceof Ie)){e.next=70;break}return e.abrupt("return",this.executeFunctionCall(t,n));case 70:if(!(n instanceof Te)){e.next=74;break}return e.abrupt("return",this.executeSysCall(t,n));case 74:throw Ye.unknown_command(n.sourceInfo);case 75:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"executeSysCall",value:(k=X()(Q().mark((function e(t,n){var r;return Q().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 k.apply(this,arguments)})},{key:"executeFunctionCall",value:(R=X()(Q().mark((function t(n,r){var i,o,a;return Q().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((o=t.sent).destroy(),ge.VOID.isCompatible(i.returnType)||o.mode===Se.RETURN){t.next=12;break}throw a=i.name===e.MAIN_INTERNAL_ID?Rt.getMainFunctionName():i.name,Ye.function_no_return(a);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 R.apply(this,arguments)})},{key:"executeSwitch",value:($=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.context.push(Sn.BREAKABLE),r=n.cases,i=t,o=!1,a=0;case 5:if(!(a=r.lines)){e.next=34;break}if(!r.isVector){e.next=31;break}throw Ye.vector_line_outbounds_full(n.id,a,r.lines,n.sourceInfo);case 31:throw Ye.matrix_line_outbounds_full(n.id,a,r.lines,n.sourceInfo);case 32:e.next=36;break;case 34:if(!(a<0)){e.next=36;break}throw Ye.array_dimension_not_positive_full(n.sourceInfo);case 36:if(null==u||0!==r.columns){e.next=38;break}throw Ye.vector_not_matrix_full(n.id,n.sourceInfo);case 38:if(null==u){e.next=45;break}if(!(u>=r.columns)){e.next=43;break}throw Ye.matrix_column_outbounds_full(n.id,u,r.columns,n.sourceInfo);case 43:if(!(u<0)){e.next=45;break}throw Ye.array_dimension_not_positive_full(n.sourceInfo);case 45:if(r.type.canAccept(c.type,i)){e.next=55;break}if(l.enable_type_casting&&Nn.canImplicitTypeCast(r.type.innerType,c.type)){e.next=54;break}throw p=r.type.innerType,d=p.stringInfo(),h=d[0],m=c.type.stringInfo(),_=m[0],v=n.expression.toString(),Ye.incompatible_types_full(h.type,h.dim,_.type,_.dim,v,n.sourceInfo);case 54:f=Nn.doImplicitCasting(r.type.innerType,c);case 55:if(!((y=r.getAt(a,u))instanceof bn)){e.next=60;break}if(y.lines===f.lines&&y.columns===f.columns){e.next=60;break}throw g=n.expression.toString(),Ye.invalid_matrix_index_assign_full(n.id,a,y.lines,g,f.lines,n.sourceInfo);case 60:return e.abrupt("return",t.updateStoreArray(n.id,f,a,u));case 61:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"executeDeclaration",value:(m=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,f;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n instanceof ae)){e.next=4;break}return e.abrupt("return",this.executeArrayDeclaration(t,n));case 4:if(r=new We(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,o=i,i.type.isCompatible(n.type)){e.next=21;break}if(!l.enable_type_casting||!Nn.canImplicitTypeCast(n.type,i.type)){e.next=15;break}o=Nn.doImplicitCasting(n.type,o),e.next=21;break;case 15:throw a=i.type.stringInfo(),s=a[0],u=i.type.stringInfo(),c=u[0],f=n.expression.toString(),Ye.incompatible_types_full(s.type,s.dim,c.type,c.dim,f,n.sourceInfo);case 21:r=new We(n.type,o.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 m.apply(this,arguments)})},{key:"executeArrayDeclaration",value:(h=X()(Q().mark((function e(t,n){var r,i,o,a,s,u;return Q().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,ge.INTEGER.isCompatible(r.type)){e.next=5;break}throw Ye.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(o=e.sent,a=null,null===o){e.next=16;break}if(ge.INTEGER.isCompatible(o.type)){e.next=13;break}throw Ye.array_dimension_not_int_full(n.sourceInfo);case 13:if(!((a=o.get().toNumber())<0)){e.next=16;break}throw Ye.array_dimension_not_positive_full(n.sourceInfo);case 16:if(s=new bn(n.type,[],i,a,null,n.isConst),null===n.initial){e.next=22;break}return e.next=20,this.evaluateArrayLiteral(t,n.initial,n.type,i,a);case 20:u=e.sent,s=new bn(n.type,u,i,a,null,n.isConst);case 22:return t.insertStore(n.id,s),e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"evaluateExpression",value:(d=X()(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.instruction_count+=1,this.instruction_count%l.suspend_threshold!=0){e.next=4;break}return e.next=4,Dt(3);case 4:if(this.mode!==Se.ABORT){e.next=6;break}throw Tt.getMessage("aborted_execution");case 6:if(!(this.instruction_count>=l.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 st)){e.next=12;break}return e.abrupt("return",this.evaluateUnaryApp(t,n));case 12:if(!(n instanceof at)){e.next=16;break}return e.abrupt("return",this.evaluateInfixApp(t,n));case 16:if(!(n instanceof Qe)){e.next=20;break}return e.abrupt("return",this.evaluateArrayAccess(t,n));case 20:if(!(n instanceof ot)){e.next=24;break}return e.abrupt("return",this.evaluateVariableLiteral(t,n));case 24:if(!(n instanceof Xe)){e.next=28;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 28:if(!(n instanceof et)){e.next=32;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 32:if(!(n instanceof tt)){e.next=36;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 36:if(!(n instanceof rt)){e.next=40;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 40:if(!(n instanceof nt)){e.next=44;break}return e.abrupt("return",this.evaluateLiteral(t,n));case 44:if(!(n instanceof it)){e.next=48;break}throw new Error("Internal Error: The system should not eval an array literal.");case 48:if(!(n instanceof Ie)){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 d.apply(this,arguments)})},{key:"evaluateFunctionCall",value:(p=X()(Q().mark((function e(t,n){var r,i,o;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.isMainCall){e.next=2;break}throw Ye.void_in_expression_full(Rt.getMainFunctionName(),n.sourceInfo);case 2:if(r=this.findFunction(n.id),!ge.VOID.isCompatible(r.returnType)){e.next=5;break}throw Ye.void_in_expression_full(n.id,n.sourceInfo);case 5:if(!(this.function_call_stack.length>=l.max_call_stack)){e.next=7;break}throw Ye.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 o=i.applyStore("$"),i.destroy(),this.function_call_stack.pop(),e.abrupt("return",o);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"evaluateArrayLiteral",value:(f=X()(Q().mark((function e(t,n,r,i,o){var a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.isVector){e.next=9;break}if(null!=o){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,o);case 5:return a=e.sent,e.abrupt("return",a.reduce((function(e,t){return e.concat(t)}),[]));case 9:if(null==o){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 f.apply(this,arguments)})},{key:"evaluateVector",value:(c=X()(Q().mark((function e(t,n,r,i){var o,a,s=this;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.value,i===o.length){e.next=3;break}throw Ye.invalid_number_elements_vector(i,n.toString(),o.length,n.sourceInfo);case 3:return e.next=5,Promise.all(o.map((function(e){return s.evaluateExpression(t,e)})));case 5:return a=e.sent,e.abrupt("return",a.map((function(e,t){if(!r.canAccept(e.type,1)){if(!l.enable_type_casting||!Nn.canImplicitTypeCast(r.innerType,e.type)){var n=o[t].toString();throw Ye.invalid_array_literal_type_full(n,o[t].sourceInfo)}return Nn.doImplicitCasting(r.innerType,e)}return e})));case 7:case"end":return e.stop()}}),e)}))),function(e,t,n,r){return c.apply(this,arguments)})},{key:"evaluateMatrix",value:(u=X()(Q().mark((function e(t,n,r,i,o){var a,s,u=this;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=n.value).length===i){e.next=3;break}throw Ye.invalid_number_lines_matrix(i,n.toString(),a.length,n.sourceInfo);case 3:return s=a.map((function(e){var n=new Ze(r.innerType,1);return u.evaluateVector(t,e,n,o)})),e.next=6,Promise.all(s);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)}))),function(e,t,n,r,i){return u.apply(this,arguments)})},{key:"evaluateLiteral",value:(s=X()(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new We(n.type,n.value));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"evaluateVariableLiteral",value:(o=X()(Q().mark((function e(t,n){var r;return Q().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 o.apply(this,arguments)})},{key:"evaluateArrayAccess",value:(r=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,l;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=t.getStoreObject(n.id)).type instanceof Ze){e.next=3;break}throw Ye.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,ge.INTEGER.isCompatible(i.type)){e.next=8;break}throw Ye.array_dimension_not_int_full(n.sourceInfo);case 8:return o=i.get().toNumber(),e.next=11,this.evaluateExpression(t,n.column);case 11:if(a=e.sent,s=null,null===a){e.next=17;break}if(ge.INTEGER.isCompatible(a.type)){e.next=16;break}throw Ye.array_dimension_not_int_full(n.sourceInfo);case 16:s=a.get().toNumber();case 17:if(!(o>=r.lines)){e.next=25;break}if(!r.isVector){e.next=22;break}throw Ye.vector_line_outbounds_full(n.id,o,r.lines,n.sourceInfo);case 22:throw Ye.matrix_line_outbounds_full(n.id,o,r.lines,n.sourceInfo);case 23:e.next=27;break;case 25:if(!(o<0)){e.next=27;break}throw Ye.array_dimension_not_positive_full(n.sourceInfo);case 27:if(null===s||0!==r.columns){e.next=29;break}throw Ye.vector_not_matrix_full(n.id,n.sourceInfo);case 29:if(null===s){e.next=36;break}if(!(s>=r.columns)){e.next=34;break}throw Ye.matrix_column_outbounds_full(n.id,s,r.columns,n.sourceInfo);case 34:if(!(s<0)){e.next=36;break}throw Ye.array_dimension_not_positive_full(n.sourceInfo);case 36:if(u=r.getAt(o,s),c=r.type.innerType,!Array.isArray(u)){e.next=43;break}return l=u.map((function(e,t){return new xn(c,e,o,t,r.id,r.readOnly)})),e.abrupt("return",new bn(new Ze(c,1),l,r.columns,null,r.id,r.readOnly));case 43:return e.abrupt("return",new xn(c,u,o,s,r.id,r.readOnly));case 44:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"evaluateUnaryApp",value:(n=X()(Q().mark((function e(t,n){var r,i,o,a;return Q().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=hn(n.op,r.type),!ge.UNDEFINED.isCompatible(i)){e.next=8;break}throw o=r.type.stringInfo(),a=o[0],Ye.invalid_unary_op_full(n.op,a.type,a.dim,n.sourceInfo);case 8:e.t0=n.op.ord,e.next=e.t0===ct.ADD.ord?11:e.t0===ct.SUB.ord?12:e.t0===ct.NOT.ord?13:14;break;case 11:return e.abrupt("return",new We(i,r.get()));case 12:return e.abrupt("return",new We(i,r.get().negated()));case 13:return e.abrupt("return",new We(i,!r.get()));case 14:throw new Ve("!!!Critical Invalid UnaryApp "+n.op);case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"evaluateInfixApp",value:(t=X()(Q().mark((function e(t,n){var r,i,o,a,s,u,c,f,p,d,h,m,_,v,y,g,x,b,w,E,$,R,k,T,N,I,S;return Q().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,o=!1,a=dn(n.op,r.type,i.type),!ge.UNDEFINED.isCompatible(a)){e.next=18;break}if(!l.enable_type_casting||!Nn.canImplicitTypeCast(r.type,i.type)){e.next=13;break}o=!0,e.next=18;break;case 13:throw s=r.type.stringInfo(),u=s[0],c=i.type.stringInfo(),f=c[0],Ye.invalid_infix_op_full(n.op,u.type,u.dim,f.type,f.dim,n.sourceInfo);case 18:p=null,e.t0=n.op.ord,e.next=e.t0===ct.ADD.ord?22:e.t0===ct.SUB.ord?39:e.t0===ct.MULT.ord?40:e.t0===ct.DIV.ord?42:e.t0===ct.MOD.ord?46:e.t0===ct.GT.ord?51:e.t0===ct.GE.ord?55:e.t0===ct.LT.ord?59:e.t0===ct.LE.ord?63:e.t0===ct.EQ.ord?67:e.t0===ct.NEQ.ord?71:e.t0===ct.AND.ord?75:e.t0===ct.OR.ord?76:77;break;case 22:if(!ge.STRING.isCompatible(r.type)){e.next=27;break}return d=Me(i.get(),i.type),e.abrupt("return",new We(a,r.get()+d));case 27:if(!ge.STRING.isCompatible(i.type)){e.next=32;break}return h=Me(r.get(),r.type),e.abrupt("return",new We(a,h+i.get()));case 32:if(!ge.CHAR.isCompatible(r.type)){e.next=38;break}return m=Me(r.get(),r.type),_=Me(i.get(),i.type),e.abrupt("return",new We(a,m+_));case 38:return e.abrupt("return",new We(a,r.get().plus(i.get())));case 39:return e.abrupt("return",new We(a,r.get().minus(i.get())));case 40:return p=r.get().times(i.get()),e.abrupt("return",new We(a,p));case 42:if(0!=i.get()){e.next=44;break}throw Ye.divsion_by_zero_full(n.toString(),n.sourceInfo);case 44:return p=ge.INTEGER.isCompatible(a)?r.get().divToInt(i.get()):r.get().div(i.get()),e.abrupt("return",new We(a,p));case 46:return v=r.get(),y=i.get(),o&&(a=ge.INTEGER,v=v.trunc(),y=y.trunc()),p=v.modulo(y),e.abrupt("return",new We(a,p));case 51:return g=r.get(),x=i.get(),ge.STRING.isCompatible(r.type)?p=g.length>x.length:ge.CHAR.isCompatible(r.type)?p=g.charCodeAt(0)>x.charCodeAt(0):(o&&(a=ge.BOOLEAN,g=g.trunc(),x=x.trunc()),p=g.gt(x)),e.abrupt("return",new We(a,p));case 55:return b=r.get(),w=i.get(),ge.STRING.isCompatible(r.type)?p=b.length>=w.length:ge.CHAR.isCompatible(r.type)?p=b.charCodeAt(0)>=w.charCodeAt(0):(o&&(a=ge.BOOLEAN,b=b.trunc(),w=w.trunc()),p=b.gte(w)),e.abrupt("return",new We(a,p));case 59:return E=r.get(),$=i.get(),ge.STRING.isCompatible(r.type)?p=E.length<$.length:ge.CHAR.isCompatible(r.type)?p=E.charCodeAt(0)<$.charCodeAt(0):(o&&(a=ge.BOOLEAN,E=E.trunc(),$=$.trunc()),p=E.lt($)),e.abrupt("return",new We(a,p));case 63:return R=r.get(),k=i.get(),ge.STRING.isCompatible(r.type)?p=R.length<=k.length:ge.CHAR.isCompatible(r.type)?p=R.charCodeAt(0)<=k.charCodeAt(0):(o&&(a=ge.BOOLEAN,R=R.trunc(),k=k.trunc()),p=R.lte(k)),e.abrupt("return",new We(a,p));case 67:return T=r.get(),N=i.get(),ge.INTEGER.isCompatible(r.type)||ge.REAL.isCompatible(r.type)?(o&&(a=ge.BOOLEAN,T=T.trunc(),N=N.trunc()),p=T.eq(N)):p=T===N,e.abrupt("return",new We(a,p));case 71:return I=r.get(),S=i.get(),ge.INTEGER.isCompatible(r.type)||ge.REAL.isCompatible(r.type)?(o&&(a=ge.BOOLEAN,I=I.trunc(),S=S.trunc()),p=!I.eq(S)):p=I!==S,e.abrupt("return",new We(a,p));case 75:return e.abrupt("return",new We(a,r.get()&&i.get()));case 76:return e.abrupt("return",new We(a,r.get()||i.get()));case 77:throw new Ve("!!!Critical Invalid InfixApp "+n.op);case 78:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();var Cn=function(e){m()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=g()(t);if(n){var i=g()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return v()(this,e)});function o(e){var t;return i()(this,o),(t=r.call(this)).index=0,t.inputList=e,t}return a()(o,[{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)}}]),o}(function(){function e(){i()(this,e)}return a()(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 On(e,t,n){return Dn.apply(this,arguments)}function Dn(){return Dn=X()(Q().mark((function e(t,n,r){var i,o,a,s,u,c,l,f;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.map((function(e){return Object.assign({},e)})),e.prev=1,o=In.analyseFromSource(t),a=n.map(function(){var e=X()(Q().mark((function e(t,n){var r,i,a;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Cn(t.input),i=new Ln,(a=new An(o)).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(a);case 6:s=e.sent,u=0;case 8:if(!(u