-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 43.5 KB
/
index.js
1
(()=>{var e={698:function(e){var t;t=()=>{return e={202:(e,t,r)=>{const{Types:s,Errors:n,Interruptions:i,InterpretError:o,Interrupt:a,Void:c}=r(746);class E{constructor(e={}){this.variables=new Map,this.parent=null,e&&Object.entries(e).forEach((([e,t])=>this.variables.set(e,t)))}hasVariable(e){return!!this.variables.has(e)||!(!this.variables.has("$")||!this.variables.get("$").hasAttribute(e))||!!this.parent&&this.parent.hasVariable(e)}getVariable(e){if(this.variables.has(e))return this.variables.get(e);if(this.variables.has("$")){const t=this.variables.get("$");if(t.hasAttribute(e))return t.attribute(e)}return!!this.parent&&this.parent.getVariable(e)}setVariable(e,t,r=!1){if(r)return void this.variables.set(e,t);let s=!1,n=this;do{n.variables.has(e)&&(n.variables.set(e,t),s=!0),n=n.parent}while(!s&&n);s||this.variables.set(e,t)}pushScope(){const e=new E;return e.parent=this,e}popScope(){const e=this.parent;return this.parent=null,e}copy(){const e=new E(this.imports);return e.variables=this.variables,e.parent=this.parent,e}}class l{constructor(e,t){this.funcExp=e,this.params=t,this.isFunctionExecution=!0}}class u{constructor(e,t){this.maxSteps=e,this.isInterruptedFn=t,this.steps=0}step(e){if(this.isInterruptedFn&&this.isInterruptedFn())throw new a(i.USER_SUSSPEND);if(this.steps++,this.steps>this.maxSteps)throw new o(n.EXECUTION_STEPS_EXCEEDED,e)}reset(e=null){this.steps=0,e&&(this.maxSteps=e)}}e.exports=class{constructor(e={},t,r=1e5){this.imports=e,this.stepper=new u(r,t&&t.isInterrupted)}async execute(e){return this.variables=new E(this.imports),this.stepper.reset(),await this.executeBlock(e,!1)}async executeBlock(e,t=!0){let r;t&&(this.variables=this.variables.pushScope());for(let t of e.statements)r=await this.executeStatement(t);return t&&(this.variables=this.variables.popScope()),r||new c}async executeStatement(e){return this.stepper.step(e.source),e.isExpression?await this.executeExpression(e):e.isAssignment?await this.executeAssignment(e):e.isWhile?await this.executeWhile(e):e.isIf?await this.executeIf(e):e}async executeExpression(e,t=null){if(this.stepper.step(e.source),!e.parts)throw new o(n.EMPTY_EXPRESSION,e.source);let r=[...e.parts];return await this.executeExpressionParts(r,t)}async executeExpressionParts(e,t=null){const r=async(e,t,r,i)=>{const a=N(e);if(a){const e=await this.executeExpressionParts(t.slice(0,a),r);if(e.type!==s.BOOLEAN)throw new o(n.WRONG_BI_OPERATOR_SUBJECTS,e.source);if(i(e.value))return e;const c=await this.executeExpressionParts(t.slice(a+1),r);if(c.type!==s.BOOLEAN)throw new o(n.WRONG_BI_OPERATOR_SUBJECTS,c.source);return c}},i=await r("|",e,t,(e=>e));if(i)return i;const a=await r("&",e,t,(e=>!e));if(a)return a;let c,E=!1;for(;(c=u())>-1;){const r=e[c];if(t&&!r.isObjectAccess&&!r.isArrayAccess)throw new o(n.ACCESS_OPERATOR_EXPECTED,r.source);try{if(r.isUni){const t=await this.executeExpressionPart(e[c+1]);if(!t.type)throw new o(n.WRONG_UNI_OPERATOR_SUBJECT,r.source);e[c]=r.apply(t),e=h(e,c+1)}else if(r.isBi){const t=await this.executeExpressionPart(e[c-1]),i=await this.executeExpressionPart(e[c+1]);if(!t.type||!i.type)throw new o(n.WRONG_BI_OPERATOR_SUBJECTS,r.source);if(!(t.type===i.type||r.isAddition&&s.STRING===t.type&&i.isPrimitive))throw new o(n.UNMATCHING_BI_OPERATOR_SUBJECTS,r.source);e[c]=r.apply(t,i),e=h(e,c-1,c+1)}else if(r.isArrayAccess){const i=await this.executeExpressionPart(e[c-1]);if(s.ARRAY!==i.type)throw new o(n.EXPECTED_ARRAY,r.source);if(t&&i.protectedAttributes())throw new o(n.PROTECTED_FROM_MODIFICATION,r.source);const a=await Promise.all(r.indexes.map((e=>this.executeExpressionPart(e))));if(e[c]=r.apply(i,a,t&&p()?t:null),!e[c])throw new o(n.ATTRIBUTE_NOT_FOUND,r.source);e=h(e,c-1),E=!0}else if(r.isObjectAccess){const s=await this.executeExpressionPart(e[c-1]);if(!s.isObject&&!s.isFunction)throw new o(n.EXPECTED_OBJECT,r.source);if(t&&s.protectedAttributes())throw new o(n.PROTECTED_FROM_MODIFICATION,r.source);if(e[c]=r.apply(s,t&&p()?t:null),!e[c])throw new o(n.ATTRIBUTE_NOT_FOUND,r.source);e=h(e,c-1),E=!0}else{if(!r.isCall)throw new o(n.UNKNOWN_OPERATOR,r.source);e[c]=new l(e[c-1],r.params),e=h(e,c-1)}}catch(e){if(!e.isLangError)throw new o(n.UNKNOWN_ERROR,r.source,e);if(!e.isInterpretError)throw new o(e.id,r.source,e.arg1,e.arg2);throw e}}if(t&&!E)throw new o(n.ACCESS_OPERATOR_EXPECTED,e[0].source);return await this.executeExpressionPart(e[0]);function u(){let t=-1,r=Number.MIN_SAFE_INTEGER;for(let s=0;s<e.length;s++){const n=e[s];n.isOperator&&(r<n.precedence||n.isUni&&r===n.precedence)&&(t=s,r=n.precedence)}return t}function h(e,...t){return e.filter(((e,r)=>!t.includes(r)))}function p(){return 2===e.length}function N(t){for(let r=0;r<e.length;r++)if(e[r].isBi&&e[r].op===t)return r}}async executeExpressionPart(e){if(this.stepper.step(e.source),e.isReference){if(!this.variables.hasVariable(e.varName))throw new o(n.UNREFERENCED_VARIABLE,e.source-e.varName.length,e.varName);return this.variables.getVariable(e.varName)}if(e.isFunctionExecution){const t=await this.executeExpressionPart(e.funcExp),r=await Promise.all(e.params.map((e=>this.executeExpressionPart(e))));return await this.executeFunctionCall(t,r)}if(e.isExpression)return await this.executeExpression(e);if(s.ARRAY===e.type){const t=e.value;for(let e=0;e<t.length;e++)t[e]=await this.executeExpressionPart(t[e])}else if(s.OBJECT===e.type){const t=e.value;for(let r of Object.keys(t))t[r]=await this.executeExpressionPart(t[r]),(t[r].isObject||t[r].isFunction)&&(t[r].parent=e)}return e.isFunction&&!e.scope&&(e.scope=this.variables.copy()),e}async executeFunctionCall(e,t){if(e.isNative)return await e.call(...t)||new c;if(!t&&e.args||t.length!==e.args.length)throw new o(n.FUNC_ARGUMENTS_MISHMASH,e.source);let r=0;const s=this.variables;this.variables=e.scope.pushScope();for(let s of e.args)this.variables.setVariable(s,t[r++],!0);e.parent&&this.variables.setVariable("$",e.parent,!0);try{const t=e.body.copy();return await this.executeBlock(t,!1)}finally{this.variables.popScope(),this.variables=s}}async executeAssignment(e){if(!e.left||!e.right)throw new o(n.WRONG_ASSIGNMENT,e.source);const t=await this.executeExpressionPart(e.right);if(e.left.isVariable){const r=this.variables.getVariable(e.left.name);if(r.protected&&r.protected())throw new o(n.PROTECTED_FROM_MODIFICATION,e.left.source);this.variables.setVariable(e.left.name,t)}else{if(!e.left.isExpression)throw new o(n.WRONG_ASSIGNEE_TYPE);await this.executeExpression(e.left,t)}}async executeWhile(e){if(!e.condition||!e.condition.isExpression)throw new o(n.WRONG_CONDITION,e.source);for(;;){const t=await this.executeExpressionPart(e.condition);if(t.type!==s.BOOLEAN)throw new o(n.WRONG_CONDITION_VALUE,t.source);if(!t.value)break;await this.executeBlock(e.body.copy())}}async executeIf(e){if(!e.condition||!e.condition.isExpression)throw new o(n.WRONG_CONDITION,e.source);const t=await this.executeExpressionPart(e.condition);if(t.type!==s.BOOLEAN)throw new o(n.WRONG_CONDITION_VALUE,t.source);t.value?await this.executeBlock(e.body):e.elseBody&&await this.executeBlock(e.elseBody)}}},746:e=>{const t={SIZE:["size","velikost","größe"]},r={INVALID_UNI_OPERATOR:"INVALID_UNI_OPERATOR",INVALID_BI_OPERATOR:"INVALID_BI_OPERATOR",UNEXPECTED_END:"UNEXPECTED_END",UNEXPECTED_SYMBOL:"UNEXPECTED_SYMBOL",EXPECTED_SYMBOL:"EXPECTED_SYMBOL",UNREFERENCED_VARIABLE:"UNREFERENCED_VARIABLE",UNEXPECTED_KEYWORD:"UNEXPECTED_KEYWORD",INVALID_IDENTIFIER:"INVALID_IDENTIFIER",UNEVEN_OPERATORS:"UNEVEN_OPERATORS",EXPECTED_FUNCTION:"EXPECTED_FUNCTION",EXPECTED_STATEMENT_END:"EXPECTED_STATEMENT_END",ARRAY_INDEX_NOT_NUMBER:"ARRAY_INDEX_NOT_NUMBER",ARRAY_INDEX_MISSING:"ARRAY_INDEX_MISSING",ARRAY_INDEX_OUT_BOUNDS:"ARRAY_INDEX_OUT_BOUNDS",FUNC_ARGUMENTS_MISHMASH:"FUNC_ARGUMENTS_MISHMASH",ATTRIBUTE_ALREADY_EXISTS:"ATTRIBUTE_ALREADY_EXISTS",ATTRIBUTE_NOT_FOUND:"ATTRIBUTE_NOT_FOUND",ELEMENT_NOT_FOUND:"ELEMENT_NOT_FOUND",EMPTY_EXPRESSION:"EMPTY_EXPRESSION",UNKNOWN_OPERATOR:"UNKNOWN_OPERATOR",OPERATOR_NOT_APPLICABLE:"OPERATOR_NOT_APPLICABLE",ACCESS_OPERATOR_EXPECTED:"ACCESS_OPERATOR_EXPECTED",WRONG_UNI_OPERATOR_SUBJECT:"WRONG_UNI_OPERATOR_SUBJECT",WRONG_BI_OPERATOR_SUBJECTS:"WRONG_BI_OPERATOR_SUBJECTS",UNMATCHING_BI_OPERATOR_SUBJECTS:"UNMATCHING_BI_OPERATOR_SUBJECTS",EXPECTED_ARRAY:"EXPECTED_ARRAY",EXPECTED_OBJECT:"EXPECTED_OBJECT",EXPECTED_IDENTIFIER:"EXPECTED_IDENTIFIER",WRONG_ASSIGNMENT:"WRONG_ASSIGNMENT",WRONG_ASSIGNEE_TYPE:"WRONG_ASSIGNEE_TYPE",READONLY_ATTRIBUTE:"READONLY_ATTRIBUTE",WRONG_CONDITION:"WRONG_CONDITION",WRONG_CONDITION_VALUE:"WRONG_CONDITION_VALUE",EXECUTION_STEPS_EXCEEDED:"EXECUTION_STEPS_EXCEEDED",PARSER_STEPS_EXCEEDED:"PARSER_STEPS_EXCEEDED",PROTECTED_FROM_MODIFICATION:"PROTECTED_FROM_MODIFICATION",DIVISION_BY_ZERO:"DIVISION_BY_ZERO",UNKNOWN_ERROR:"UNKNOWN_ERROR"},s={NUMBER:"NUMBER",BOOLEAN:"BOOLEAN",STRING:"STRING",ARRAY:"ARRAY",OBJECT:"OBJECT",FUNCTION:"FUNCTION",VOID:"VOID"};class n extends Error{constructor(e,t,r,s){super(e),this.details=`${r?`"${r}"`:""} ${s?`"${s}"`:""}`,this.message=`${e} ${this.details}`,this.id=e,this.arg1=r,this.arg2=s,this.position=t,this.isLangError=!0}}class i{constructor(e,t){this.statements=e,this.source=t}copy(){return new i(this.statements.map((e=>e.copy())),this.source)}}class o{constructor(e){this.isExpression=!1,this.isAssignment=!1,this.isWhile=!1,this.isIf=!1,this.source=e}copy(){return this}}class a extends o{constructor(e,t,r){super(r),this.isAssignment=!0,this.left=e,this.right=t}copy(){return new a(this.left.copy(),this.right.copy(),this.source)}}class c extends o{constructor(e,t,r){super(r),this.isWhile=!0,this.condition=e,this.body=t}copy(){return new c(this.condition.copy(),this.body.copy(),this.source)}}class E extends o{constructor(e,t,r,s){super(s),this.isIf=!0,this.condition=e,this.body=t,this.elseBody=r}copy(){return new E(this.condition.copy(),this.body.copy(),this.elseBody?.copy(),this.source)}}class l extends o{constructor(e,t){super(t),this.isExpression=!0,this.parts=e}copy(){return new l(this.parts.map((e=>e.copy())),this.source)}}class u{constructor(e,t=-1){this.op=e,this.isOperator=!0,this.precedence=t}copy(){return this}}class h{constructor(e,t,r=s.OBJECT){this.value=e,this.type=r,this.isObject=!0,this.parent=null,this.source=t,this.eq=new R((e=>new _(function(e,t){const r=Object.keys(e.value),s=Object.keys(t.value);if(r.length!==s.length)return!1;for(k of r)if(!e.value[k].eq.call(t.value[k]))return!1;return!0}(this,e)))),this.ne=new R((e=>new _(!this.eq.call(e).value)))}attribute(e,t){const r=this[e]?this[e]:this.value[e];return t&&this.value[e]&&(this.value[e]=t),r||(this.parent?this.parent.attribute(e):void 0)}hasAttribute(e){return this[e]||this.value[e]||this.parent&&this.parent.hasAttribute(e)}protected(){return this.isProtected||this.parent&&this.parent.protected()}protectedAttributes(){return this.protected()}copy(){const e={};return Object.keys(this.value).forEach((t=>e[t]=this.value[t].copy())),new h(e,this.source)}}class p extends h{constructor(e,t,r){super(e,t,r),this.eq=new R((e=>new _(this.value===e.value))),this.ne=new R((e=>new _(this.value!==e.value)))}copy(){return this}}class N extends p{constructor(e,t){super(e,t,s.NUMBER),this.isPrimitive=!0,this.mult=new R((e=>new N(this.value*e.value))),this.div=new R((e=>new N(this.value/e.value))),this.mod=new R((e=>new N(this.value%e.value))),this.plus=new R((e=>new N(this.value+e.value))),this.minus=new R((e=>new N(this.value-e.value))),this.lt=new R((e=>new _(this.value<e.value))),this.le=new R((e=>new _(this.value<=e.value))),this.gt=new R((e=>new _(this.value>e.value))),this.ge=new R((e=>new _(this.value>=e.value))),this.neg=new R((()=>new N(-this.value))),this.sum=new R(((...e)=>new N(e.reduce(((e,t)=>e+t.value),this.value)))),this.round=new R((()=>new N(Math.round(this.value)))),this.floor=new R((()=>new N(Math.floor(this.value)))),this.ceil=new R((()=>new N(Math.ceil(this.value))))}}class O extends p{constructor(e,r){super(e,r,s.STRING),this.isPrimitive=!0,this.concat=new R((e=>new O(this.value+e.value))),this.length=new R((()=>new N(this.value.length))),this.charAt=new R((e=>new O(this.value.charAt(e.value)))),this.sub=new R(((e,t)=>e.value>this.value.length-1||e.value<0||t&&t.value<=e.value||t&&t.value>this.value.length?new O(""):new O(this.value.substring(e.value,t?t.value:this.value.length)))),this.plus=this.concat;for(let e of t.SIZE)this[e]=new N(this.value.length)}}class _ extends p{constructor(e,t){super(e,t,s.BOOLEAN),this.isPrimitive=!0,this.and=new R((e=>new _(this.value&&e.value))),this.or=new R((e=>new _(this.value||e.value))),this.xor=new R((e=>new _(this.value?!e.value:e.value))),this.nand=new R((e=>new _(!(this.value&&e.value)))),this.neg=new R((()=>new _(!this.value))),this.mult=this.and,this.plus=this.or}}class d extends p{constructor(e,r){super(e,r,s.ARRAY),this.concat=new R((e=>new d(this.value.concat(e.value)))),this.plus=this.concat;for(let e of t.SIZE)this[e]=new N(this.value.length);this.eq=new R((e=>{if(!e||!e.value)return new _(!1);if(this.value.length!==e.value.length)return new _(!1);for(let t=0;t<this.value.length;t++)if(!this.value[t].eq||!this.value[t].eq.isNative||!this.value[t].eq.call(e.value[t]).value)return new _(!1);return new _(!0)})),this.ne=new R((e=>new _(!this.eq.call(e).value)))}element(e,t){return e.reduce(((s,i,o)=>{const a=Math.ceil(i.value);if(a<0||a>=s.value.length)throw new n(r.ARRAY_INDEX_OUT_BOUNDS,null,a);const c=s.value[a];return t&&o===e.length-1&&(s.value[a]=t),c}),this)}attribute(e,s){if(t.SIZE.includes(e.toLowerCase())){if(s)throw new n(r.READONLY_ATTRIBUTE);return new N(this.value.length)}return super.attribute(e,s)}hasAttribute(e){return t.SIZE.includes(e.toLowerCase())||super.attribute(e,newValue)}copy(){return new d(this.value.map((e=>e.copy())),this.source)}}class T{constructor(e,t,r,n){this.type=s.FUNCTION,this.body=e,this.args=t,this.isFunction=!0,this.source=n,this.funcId=r,this.eq=new R((e=>new _(e.funcId===this.funcId))),this.ne=new R((e=>new _(e.funcId!==this.funcId)))}attribute(e,t){if(t)throw new n(r.READONLY_ATTRIBUTE);const s=this[e]?this[e]:this.value[e];if(s)return s}hasAttribute(e){return this[e]||this.value[e]}protectedAttributes(){return!0}copy(){return new T(this.body,this.args,this.funcId,this.source)}}class R{constructor(e,t){this.type=s.FUNCTION,this.func=e,this.isNative=!0,this.source=t}call(...e){return this.func(...e)}copy(){return this}}e.exports={Keywords:{TRUE:["true","pravda","wahr"],FALSE:["false","nepravda","falsch"],IF:["if","pokud","falls"],ELSE:["else","jinak","sonst"],WHILE:["while","dokud","solange"]},Errors:r,Interruptions:{USER_SUSSPEND:"USER_SUSSPEND"},Types:s,Block:i,Assignment:a,While:c,If:E,Expression:l,Variable:class{constructor(e,t){this.isVariable=!0,this.name=e,this.source=t}copy(){return this}},UniOperator:class extends u{constructor(e,t){super(e),this.isUni=!0,this.precedence=this.getPrecedence(),this.source=t}apply(e){const t=function(t){switch(t){case"!":case"-":return e.neg;default:throw new n(r.INVALID_UNI_OPERATOR,null,this.op)}}(this.op);if(!t||!t.call)throw new n(r.OPERATOR_NOT_APPLICABLE,null,this.op);return t.call()}getPrecedence(){switch(this.op){case"!":case"-":return 14}}},BiOperator:class extends u{constructor(e,t){super(e),this.isBi=!0,this.precedence=this.getPrecedence(),this.isAddition="+"===e,this.source=t}apply(e,t){const i=function(t){switch(t){case"*":return e.mult;case"/":return e.div;case"%":return e.mod;case"+":return e.plus;case"-":return e.minus;case"<":return e.lt;case"<=":return e.le;case">":return e.gt;case">=":return e.ge;case"=":return e.eq;case"!=":return e.ne;case"&":return e.and;case"|":return e.or;default:throw new n(r.INVALID_BI_OPERATOR,null,this.op)}}(this.op);if(!i||!i.call){if("="===this.op)return new _(!1);throw new n(r.OPERATOR_NOT_APPLICABLE,null,this.op)}if("/"===this.op&&s.NUMBER===t.type&&0===t.value)throw new n(r.DIVISION_BY_ZERO,null,this.op);return i.call(t)}getPrecedence(){switch(this.op){case"*":case"/":case"%":return 12;case"+":case"-":return 11;case"<":case"<=":case">":case">=":return 9;case"=":case"!=":return 8;case"&":return 4;case"|":return 3}}},ArrayAccess:class extends u{constructor(e,t){super("[]",17),this.isAccess=!0,this.isArrayAccess=!0,this.indexes=e,this.source=t}apply(e,t,r){return e.element(t,r)}},ObjectAccess:class extends u{constructor(e,t){super(".",17),this.isAccess=!0,this.isObjectAccess=!0,this.attrName=e,this.source=t}apply(e,t){return e.attribute(this.attrName,t)}},FunctionCall:class extends u{constructor(e,t){super("()",17),this.isAccess=!0,this.isCall=!0,this.params=e,this.source=t}},VarReference:class{constructor(e,t){this.isReference=!0,this.varName=e,this.source=t}copy(){return this}},ParseError:class extends n{constructor(e,t,r,s){super(e,t,r,s),this.isParseError=!0}},InterpretError:class extends n{constructor(e,t,r,s){super(e,t,r,s),this.isInterpretError=!0}},Interrupt:class{constructor(e){this.id=e,this.isLangInterruption=!0}},Object:h,Number:N,String:O,Boolean:_,Array:d,Function:T,NativeFunction:R,Void:class extends p{constructor(e){super(null,e,s.VOID),this.eq=new R((e=>new _(!1))),this.ne=new R((e=>new _(!1)))}}}},337:(e,t,r)=>{const s=r(746),n=r(417),i=r(202);e.exports={LudolfC:class{constructor(e={},t={}){this.parser=new n,this.interpret=new i(e,t)}async execute(e){try{const t=this.parser.parse(e);return await this.interpret.execute(t)}catch(e){if(e.isLangError&&(e.position||0===e.position)){const{line:t,col:r}=function(e,t){let r=1,s=1;for(let n=0;n<e.length&&n<=t;n++)s++,"\n"===e.charAt(n)&&(r++,s=1);return s=Math.max(1,s-1),{line:r,col:s}}(this.parser.source.code,e.position);e.line=t,e.col=r}throw e}}hasVariable(e){return this.interpret.variables.hasVariable(e)}getVariable(e){return this.interpret.variables.getVariable(e)}},lang:s}},417:(e,t,r)=>{const{Errors:s,Keywords:n,Block:i,Assignment:o,While:a,If:c,Expression:E,Variable:l,UniOperator:u,BiOperator:h,ArrayAccess:p,ObjectAccess:N,FunctionCall:O,VarReference:_,ParseError:d,Object:T,Number:R,String:g,Boolean:w,Array:f,Function:I,Void:A}=r(746),v=["!","-"],P=["*","/","%","+","-","<","<=",">",">=","=","!=","&","|"],S="ěščřžťďýáíéúůüöäňñĚŠČŘŽŤĎÝÁÍÉÚŮÜÖÄŇÑß",C=`[a-zA-Z_${S}][a-zA-Z0-9_${S}]*`,b=`\\((\\s*(${C})\\s*(,\\s*(${C}))*)?\\s*\\)\\s*{(.|\\s)*\\}`;class m{constructor(e,t=0){this.code=function(e){if(!e.length)return e;let t="",r=null,s=!1,n=!1,i=0;for(;i<e.length-1;i++){const o=e.charAt(i);!s&&M(o)?(s=!0,r=o):s&&X(o,r)?(s=!1,r=null):s||"/"!==o||"/"!==e.charAt(i+1)?"\n"===o&&(n=!1):n=!0,n||(t+=o)}return t+e.charAt(e.length-1)}(e+"\n"),this.pos=0,this.startingAt=t}move(e=1){this.pos+=e}currentChar(){return this.code.charAt(this.pos)}remaining(e=void 0){return this.code.substring(this.pos,Math.min(e?this.pos+e:this.code.length-1,this.code.length-1))}next(e=1){return this.code.substring(Math.min(this.pos+1,this.code.length-1),Math.min(this.pos+1+e,this.code.length-1))}finished(){return this.pos>=this.code.length}absPos(){return this.pos+this.startingAt-1}}function D(e,t=!1){for(;!e.finished()&&/\s/.test(e.currentChar())&&(!t||"\n"!==e.currentChar());)e.move()}function y(e,t){const r=new RegExp(t);for(;!e.finished()&&!r.test(e.currentChar());)e.move()}function U(e){return e=e.toLowerCase(),Object.values(n).some((t=>t.includes(e)))||n.WHILE.includes(e)||n.IF.includes(e)}function B(e,t=!1){return("\n"!==e||t)&&/\s+/g.test(e)}function x(e){return B(e)||L(e)||"("===e||")"===e||"["===e||"]"===e||"{"===e||"}"===e||"."===e||","===e||P.some((t=>t.startsWith(e)))||v.some((t=>t.startsWith(e)))}function L(e){return"\n"===e||";"===e}function M(e){return'"'===e||"“"===e||"”"===e||"'"===e}function X(e,t){return t===e||"”"===e&&"“"===t}function F(e){return new RegExp(`^${C}$`).test(e)}function Y(e){return n.WHILE.some((t=>new RegExp(`^\\s*${t}\\s(.+)\\s{`,"s").test(e)))}function W(e){return n.IF.some((t=>new RegExp(`^\\s*${t}\\s(.+)\\s{`,"s").test(e)))}e.exports=class{constructor(){this.steps=0,this.maxSteps=1e6,this.fcount=0,this.source=new m("")}parse(e){return this.steps=0,this.source=new m(e),this.parseBlock(this.source)}parseBlock(e){const t=[];for(;!e.finished();){const r=this.parseStatement(e);r&&t.push(r)}return new i(t,e.absPos())}parseStatement(e){this._stepper();let t="",r=null,n=!1;const i={arrays:0,objects:0,groups:0,ops:0};for(;!e.finished();e.move()){this._stepper();const a=e.currentChar();if(!n&&M(a)){let r=a;do{t+=r,e.move(),r=e.currentChar()}while(!e.finished()&&!X(r,a))}if(r||!B(a)||!B(t.charAt(t.length-1))){if(r&&a!==r)throw new d(s.EXPECTED_SYMBOL,e.absPos(),r,a);if("="!==r||a!==r){if("["===a&&i.arrays++,"]"===a&&i.arrays--,"{"===a&&i.objects++,"}"===a&&i.objects--,"("===a&&i.groups++,")"===a&&i.groups--,"+"===a||"-"===a||"*"===a||"/"===a||"<"===a||">"===a||"="===a?i.ops++:i.ops&&!B(a,!0)&&i.ops--,L(a)&&!i.arrays&&!i.objects&&!i.groups&&!i.ops){e.move();break}if(Y(e.remaining())){if(t.length)throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),t);D(e),y(e,"\\s");const r=this.parseWhile(e);if(D(e,!0),!L(e.currentChar()))throw new d(s.EXPECTED_STATEMENT_END,e.absPos());return r}if(W(e.remaining())){if(t.length)throw new d(s.UNEXPECTED_SYMBOL,t);return this.parseIfStatement(e)}if(":"!==a||i.objects){if(n){const r=this.parseExpression(e,i);if(t=t.trim(),F(t)){const s=new l(t,e.absPos());return new o(s,r,e.absPos())}{const n=this.parseExpression(new m(t,e.absPos()-t.length),{});if(!n||n.parts.some((e=>e.isOperator&&!e.isAccess)))throw new d(s.INVALID_IDENTIFIER,e.absPos(),t);return new o(n,r,e.absPos())}}t+=a}else{if(!t.trim().length)throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),a);if(U(t.trim()))throw new d(s.UNEXPECTED_KEYWORD,e.absPos(),a);r="="}}else n=!0,r=null}}if(t.length)return this.parseExpression(new m(t,e.absPos()-t.length),{})}parseExpression(e,t,r=null){this._stepper();const n=[];for(;!e.finished();){this._stepper();const l=e.currentChar();if(B(l)){e.move();continue}if(L(l)||")"===l||"]"===l||"}"===l||","===l){if(!(")"!==l&&"]"!==l&&"}"!==l||(r||r===l)&&n.length))throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),l);if(n.length&&(!n[n.length-1].isOperator||n[n.length-1].isAccess))return new E(n,e.absPos());e.move();continue}if(o=e.remaining(),new RegExp(`^${b}`).test(o)){if(n.length&&!n[n.length-1].isOperator)throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),l);const t=this.parseFunction(e);n.push(t);continue}if("{"===l){if(!a())throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),l);e.move();const r=this.readAttributes(e,")");if(D(e),"}"===e.currentChar()){const s=new T(r,e.absPos());for(let e of Object.values(r))e.isObject&&(e.parent=s);n.push(s),e.move(),t.objects--;continue}throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar(),"}")}if("("===l){if(e.move(),c()){const t=this.readList(e,")");if(D(e),")"!==e.currentChar())throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar(),")");var i=new O(t,e.absPos());n.push(i),e.move()}else{const r=this.parseExpression(e,t,!0);if(n.push(r),D(e),")"!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),")");e.move()}continue}if("."===l&&c()){e.move();const t=this.readIdentifier(e);n.push(new N(t,e.absPos()));continue}if("["===l){if(e.move(),c()){const t=this.readList(e,"]");if(D(e),!t.length)throw new d(s.ARRAY_INDEX_MISSING,e.absPos());if("]"!==e.currentChar())throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar(),"]");if(t.some((e=>!e.isExpression||!e.parts.length)))throw new d(s.ARRAY_INDEX_NOT_NUMBER,e.absPos());e.move(),n.push(new p(t,e.absPos()))}else{const r=this.readList(e,"]");if(D(e),"]"!==e.currentChar())throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar(),"]");n.push(new f(r,e.absPos())),e.move(),t.arrays--}continue}if(a()){if(v.includes(l)){if(n.push(new u(l,e.absPos())),e.move(),B(e.currentChar()))throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar());continue}}else if(c()){const t=e.remaining(2);if(P.includes(t)){n.push(new h(t,e.absPos())),e.move(t.length);continue}if(P.includes(l)){n.push(new h(l,e.absPos())),e.move();continue}}if(c())throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),e.currentChar());const _=this.parseMemberExpression(e);n.push(_)}var o;if(n.length&&n[n.length-1].isOperator&&!n[n.length-1].isAccess)throw new d(s.UNEVEN_OPERATORS,e.absPos()-1);function a(){return!n.length||n[n.length-1].isOperator&&!n[n.length-1].isAccess}function c(){return n.length&&(!n[n.length-1].isOperator||n[n.length-1].isAccess)}}parseMemberExpression(e){this._stepper();let t="";for(;!e.finished();e.move()){this._stepper();const i=e.currentChar();if(x(i)){if("."===i&&/^(0|([1-9][0-9]*))$/.test(t)&&/[0-9]/.test(e.next())){t+=i;continue}if(n.TRUE.includes(t.toLowerCase()))return new w(!0,e.absPos());if(n.FALSE.includes(t.toLowerCase()))return new w(!1,e.absPos());if(r=t,!isNaN(r)&&!isNaN(parseFloat(r)))return new R(t.includes(".")?parseFloat(t):parseInt(t),e.absPos());if(F(t)||"$"===t)return new _(t,e.absPos());throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),t)}if(M(i))return e.move(),new g(this.readString(e,i),e.absPos());t+=i}var r}parseIfStatement(e){D(e),y(e,"\\s");const t=this.parseIf(e);D(e,!0);let r=L(e.currentChar());if(D(e),o=e.remaining(),n.ELSE.some((e=>new RegExp(`^\\s*${e}\\s+{`,"s").test(o))))y(e,"\\s"),t.elseBody=this.parseBody(e),D(e,!0);else if(function(e){return n.ELSE.some((t=>new RegExp(`^\\s*${t}\\s+(${n.IF.join("|")})`).test(e)))}(e.remaining())){y(e,"\\s");const s=this.parseIfStatement(e);t.elseBody=new i([s],e.absPos()),r=!0}var o;if(!r&&!L(e.currentChar()))throw new d(s.EXPECTED_STATEMENT_END,e.absPos());return t}readList(e,t){if(D(e),t===e.currentChar())return[];{const r=[];do{const s=this.parseExpression(e,{},t);r.push(s),D(e)}while(","===e.currentChar()&&!e.finished());return r}}readAttributes(e){if(D(e),"}"===e.currentChar())return{};{const t={};let r=!0;do{r||e.move(),r=!1,D(e);const n=this.readIdentifier(e);if(t[n])throw new d(s.ATTRIBUTE_ALREADY_EXISTS,e.absPos(),n);if(D(e),":"!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),":",e.currentChar());e.move();const i=this.parseExpression(e,{},"}");t[n]=i,D(e)}while(","===e.currentChar()&&!e.finished());return t}}parseWhile(e){const t=this.readUntilBodyOpens(e),r=this.parseExpression(new m(t,e.absPos()-t.length),{},null),s=this.parseBody(e);return new a(r,s,e.absPos())}parseIf(e){const t=this.readUntilBodyOpens(e),r=this.parseExpression(new m(t,e.absPos()-t.length),{},null),s=this.parseBody(e);return new c(r,s,null,e.absPos())}parseFunction(e){const t=this.readArguments(e),r=this.parseBody(e);return new I(r,t,++this.fcount,e.absPos())}readArguments(e){if(D(e),"("!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),"(",e.currentChar());e.move(),D(e);const t=[];let r=!0;for(;(","===e.currentChar()||")"!==e.currentChar())&&!e.finished();){r||e.move(),r=!1;const s=this.readIdentifier(e);t.push(s),D(e)}if(")"!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),")",e.currentChar());return e.move(),t}parseBody(e){if(D(e),"{"!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),"{",e.currentChar());e.move(),D(e);let t="",r=0;for(;(r||"}"!==e.currentChar())&&!e.finished();){const s=e.currentChar();t+=s,e.move(),"{"===s&&r++,"}"===s&&r--}if("}"!==e.currentChar())throw new d(s.EXPECTED_SYMBOL,e.absPos(),"}",e.currentChar());return e.move(),/^\s*$/.test(t)?new i([new A(e.absPos())],e.absPos()):this.parseBlock(new m(t,e.absPos()-t.length))}readString(e,t){let r="";for(;!e.finished();e.move()){const s=e.currentChar();if(X(s,t))return e.move(),r;r+=s}throw new d(s.UNEXPECTED_END,e.absPos())}readIdentifier(e){let t="";for(;!e.finished();e.move()){const r=e.currentChar();if(!B(r)){if(!new RegExp(`^${C}$`).test(t+r))break;t+=r}}if(t)return t;throw new d(s.EXPECTED_IDENTIFIER,e.absPos())}readUntilBodyOpens(e){let t=0,r=0,n="";for(;!e.finished();e.move()){const i=e.currentChar();if(M(i))n+=this.readString(e,i);else{if("("===i)r++;else if(")"===i)r--;else if("{"===i){if(!t&&!r)break;t++}else if("}"===i&&(t--,t<0))throw new d(s.UNEXPECTED_SYMBOL,e.absPos(),i);n+=i}}if(n)return n}_stepper(){if(this.steps++,this.steps>this.maxSteps)throw new d(s.PARSER_STEPS_EXCEEDED,source.absPos())}}}},t={},function r(s){var n=t[s];if(void 0!==n)return n.exports;var i=t[s]={exports:{}};return e[s](i,i.exports,r),i.exports}(337);var e,t},e.exports=t()}},t={};function r(s){var n=t[s];if(void 0!==n)return n.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,r),i.exports}(()=>{"use strict";var e=r(698);const t=Math.floor(5.5),s=1,n=20,i=30,o=40,a=t,c=t,E=t,l=t-1;function u(e){return"VOID"===e.type?"":"ARRAY"===e.type?"["+e.value.map(u)+"]":"OBJECT"===e.type?"{"+Object.keys(e.value).map((t=>t+": "+u(e.value[t]))).join(", ")+"}":"BOOLEAN"===e.type?e.value?"<b>✓</b>":"<b>✗</b>":"STRING"===e.type?e.value:null!==e.value&&void 0!==e.value?u(e.value):e.isFunction?"⚙️":"string"==typeof e?e:JSON.stringify(e)}const h=[];for(let e=0;e<11;e++){h[e]=[];for(let t=0;t<11;t++)h[e][t]=0}let p=0;for(;p<10;){const e=_(2,9),t=_(2,9);0===h[e][t]&&(h[e][t]=i,p++)}let N=0;for(;N<20;){const e=Math.random()>.5?_(0,2):_(9,11),t=_(0,11),[r,s]=Math.random()>.5?[e,t]:[t,e];0===h[r][s]&&(h[r][s]=o,N++)}h[a][c]=n,h[E][l]=0;const O=[];function _(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e}h.forEach(((e,t)=>O[t]=[...e]));const d={raw:h,mapped:function(t){const r=t.map((t=>n(t.map((t=>new e.lang.Number(t)))))),s=n(r);return s.isMap=!0,s;function n(t){const r=new e.lang.Array(t);return r.isProtected=!0,r}}(h),reset:()=>O.forEach(((e,t)=>e.map(((e,r)=>h[t][r]=e))))},T={x:E,y:l},R=new e.lang.Object({x:new e.lang.Number(T.x),y:new e.lang.Number(T.y)}),g={move:null},w={trapped:!1,charging:!1,energy:30},f=new e.lang.Number(w.energy);function I(e){w.energy+=e,f.value=w.energy}function A(){return w.charging=!1,!(w.trapped||w.energy<1)}function v(){i===d.raw[T.x][T.y]&&(w.trapped=!0),I(-1)}const P={position:R,positionRaw:T,energy:f,status:w,callback:g,up:new e.lang.NativeFunction((async()=>{console.debug("Robot up",JSON.stringify(T)),A()&&(T.y>=10||(T.y++,R.value.y.value++,v(),g.move&&await g.move()))})),down:new e.lang.NativeFunction((async()=>{console.debug("Robot down",JSON.stringify(T)),A()&&(T.y<=0||(T.y--,R.value.y.value--,v(),g.move&&await g.move()))})),right:new e.lang.NativeFunction((async()=>{console.debug("Robot right",JSON.stringify(T)),A()&&(T.x>=10||(T.x++,R.value.x.value++,v(),g.move&&await g.move()))})),left:new e.lang.NativeFunction((async()=>{console.debug("Robot left",JSON.stringify(T)),A()&&(T.x<=0||(T.x--,R.value.x.value--,v(),g.move&&await g.move()))})),avoid:new e.lang.NativeFunction((async()=>{console.debug("Robot avoid",JSON.stringify(T)),w.energy<2||(w.trapped=!1,d.raw[T.x][T.y]=0,I(-2),g.move&&await g.move())})),charge:new e.lang.NativeFunction((async()=>{console.debug("Robot charge",JSON.stringify(T)),o===d.raw[T.x][T.y]&&(w.charging=!0,d.raw[T.x][T.y]=0,I(10),g.move&&await g.move())})),reset:()=>{T.x=E,T.y=l,R.value.x.value=T.x,R.value.y.value=T.y,w.trapped=!1,w.energy=30,f.value=w.energy}},S=new e.lang.Object(P);S.isRobot=!0,S.isProtected=!0,P.nahoru=P.up,P.hoch=P.up,P["dolů"]=P.down,P.runter=P.down,P.doprava=P.right,P.rechts=P.right,P.doleva=P.left,P.links=P.left,P.poloha=P.position,P.vyhnout=P.avoid,P.vermeiden=P.avoid,P["dobít"]=P.charge,P.aufladen=P.charge,P.energie=P.energy;const C={raw:P,mapped:S,reset:P.reset},b=C.raw,m={x:a,y:c},D=new e.lang.Object({x:new e.lang.Number(m.x),y:new e.lang.Number(m.y)}),y={position:()=>console.log("robot is not in the same position"),energy:()=>console.log("not enough energy"),start:()=>console.log("rocket is starting!!!")},U={position:D,positionRaw:m,callback:y,start:new e.lang.NativeFunction((async()=>(console.debug("Rocket start",b.status.energy,m),b.positionRaw.x!==m.x||b.positionRaw.y!==m.y?await y.position():b.status.energy<100?await y.energy():void await y.start())))},B=new e.lang.Object(U);B.isRocket=!0,B.isProtected=!0,U.poloha=U.position;const x={raw:U,mapped:B,MIN_ENERGY:100},L=document.getElementById("map"),M=document.getElementById("result"),X=document.getElementById("score");async function F(e,...t){if(!t||!t[0])return;if("VOID"===t[0].type)return;t.some(s)&&W(1===t.length);const r=t.filter((e=>!s(e))).map((e=>u(e))).join(" ");function s(e){return e.isMap||e.isRobot||e.isRocket}console.log("Display:",r),M.innerHTML=r,await k(e)}async function Y(...e){await F(500,...e)}function W(e=!0){e&&G();const t=d.raw,r=C.raw;X.innerHTML=r.status.energy,r.status.energy>=x.MIN_ENERGY?X.classList.add("full"):X.classList.remove("full"),r.status.energy<=0?X.classList.add("empty"):X.classList.remove("empty");const E=t.length;let l="";for(let e=E-1;e>=0;e--){l+="<tr>";for(let a=0;a<E;a++){const c=h(a,e)&&!p(a,e)?s:t[a][e],N=c===s&&r.status.trapped?"trapped":c===s&&r.status.charging?"charging":c===s&&r.status.energy<=0?"dead":"";l+=`<td class="map-cell map-${a}-${e} map-value-${u=c,u===s?"robot":u===n?"rocket":u===i?"crater":u===o?"energy":"sand"} ${N} `,0!==a&&0!==e&&a!==E-1&&e!==E-1||(l+="side "),0===a&&0===e?l+="corner bottom-left":0===e&&a===E-1?l+="corner bottom-right":e===E-1&&0===a?l+="corner top-left":e===E-1&&a===E-1&&(l+="corner top-right"),l+='"> </td>'}l+="</tr>"}var u;function h(e,t){return e===r.positionRaw.x&&t===r.positionRaw.y}function p(e,t){return e===a&&t===c}L.innerHTML=l}function G(){L.classList.remove("universe"),M.innerHTML="",L.innerHTML=""}function k(e=250){return new Promise((t=>setTimeout(t,e)))}C.raw.callback.move=async()=>{W(),await k()},x.raw.callback.start=async()=>{const e=1e3;await F(e,"...5..."),await F(e,"...4..."),await F(e,"...3..."),await F(e,"...2..."),await F(e,"...1..."),await F(e,"🥳🚀🏠"),G(),L.classList.add("universe")};let V=(localStorage.getItem("localization")||navigator.language||"en").substring(0,2);const j={en:'i := 3\nwhile i > 0 {\n Display(i, "...")\n i := i - 1\n}\nDisplay(Map)',de:'i := 3\nsolange i > 0 {\n Anzeigen(i, "...")\n i := i - 1\n}\nAnzeigen(Map)',cs:'i := 3\ndokud i > 0 {\n Zobraz(i, "...")\n i := i - 1\n}\nZobraz(Map)'},J={en:[],de:[],cs:[]};function z(){document.querySelectorAll(".localization:not(."+V+")").forEach((e=>e.classList.remove("current"))),document.querySelectorAll(".localization."+V).forEach((e=>e.classList.add("current")))}J.en[e.lang.Errors.INVALID_UNI_OPERATOR]="Invalid operator",J.en[e.lang.Errors.INVALID_BI_OPERATOR]="Invalid operator",J.en[e.lang.Errors.UNEXPECTED_END]="Unexpected end",J.en[e.lang.Errors.UNEXPECTED_SYMBOL]="Unexpected symbol",J.en[e.lang.Errors.EXPECTED_SYMBOL]="Expected symbol",J.en[e.lang.Errors.UNREFERENCED_VARIABLE]="Unreferenced variable",J.en[e.lang.Errors.UNEXPECTED_KEYWORD]="Unexpected keyword",J.en[e.lang.Errors.INVALID_IDENTIFIER]="Invalid identifier",J.en[e.lang.Errors.UNEVEN_OPERATORS]="Uneven operators",J.en[e.lang.Errors.EXPECTED_FUNCTION]="Expected function",J.en[e.lang.Errors.EXPECTED_STATEMENT_END]="Expected statement end",J.en[e.lang.Errors.ARRAY_INDEX_NOT_NUMBER]="Array index is not a number",J.en[e.lang.Errors.ARRAY_INDEX_MISSING]="Array index is missing",J.en[e.lang.Errors.ARRAY_INDEX_OUT_BOUNDS]="Array index is out of bounds",J.en[e.lang.Errors.FUNC_ARGUMENTS_MISHMASH]="Function arguments mishmash",J.en[e.lang.Errors.ATTRIBUTE_ALREADY_EXISTS]="Attribute already exists",J.en[e.lang.Errors.ATTRIBUTE_NOT_FOUND]="Attribute not found",J.en[e.lang.Errors.ELEMENT_NOT_FOUND]="Element not found",J.en[e.lang.Errors.EMPTY_EXPRESSION]="Empty expression",J.en[e.lang.Errors.UNKNOWN_OPERATOR]="Unknown operator",J.en[e.lang.Errors.OPERATOR_NOT_APPLICABLE]="Operator not applicable",J.en[e.lang.Errors.ACCESS_OPERATOR_EXPECTED]="Access operator expected",J.en[e.lang.Errors.WRONG_UNI_OPERATOR_SUBJECT]="Wrong operator subject",J.en[e.lang.Errors.WRONG_BI_OPERATOR_SUBJECTS]="Wrong operator subject",J.en[e.lang.Errors.UNMATCHING_BI_OPERATOR_SUBJECTS]="Operator subjects do not match",J.en[e.lang.Errors.EXPECTED_ARRAY]="Expected an array",J.en[e.lang.Errors.EXPECTED_OBJECT]="Expected an object",J.en[e.lang.Errors.EXPECTED_IDENTIFIER]="Expected an identifier",J.en[e.lang.Errors.WRONG_ASSIGNMENT]="Wrong assignment",J.en[e.lang.Errors.WRONG_ASSIGNEE_TYPE]="Wrong assignee type",J.en[e.lang.Errors.READONLY_ATTRIBUTE]="Read-only attribute",J.en[e.lang.Errors.WRONG_CONDITION]="Wrong condition",J.en[e.lang.Errors.WRONG_CONDITION_VALUE]="Wrong condition value",J.en[e.lang.Errors.EXECUTION_STEPS_EXCEEDED]="Run out of power",J.en[e.lang.Errors.PARSER_STEPS_EXCEEDED]="Parsing exhausted",J.en[e.lang.Errors.PROTECTED_FROM_MODIFICATION]="Protected from modification",J.en[e.lang.Errors.DIVISION_BY_ZERO]="Division by zero",J.en[e.lang.Errors.UNKNOWN_ERROR]="Error",J.de[e.lang.Errors.INVALID_UNI_OPERATOR]="Ungültiger Operator",J.de[e.lang.Errors.INVALID_BI_OPERATOR]="Ungültiger Operator",J.de[e.lang.Errors.UNEXPECTED_END]="Unerwartetes Ende",J.de[e.lang.Errors.UNEXPECTED_SYMBOL]="Unerwartetes Symbol",J.de[e.lang.Errors.EXPECTED_SYMBOL]="Erwartetes Symbol",J.de[e.lang.Errors.UNREFERENCED_VARIABLE]="Nicht referenzierte Variable",J.de[e.lang.Errors.UNEXPECTED_KEYWORD]="Unerwartetes Schlüsselwort",J.de[e.lang.Errors.INVALID_IDENTIFIER]="Ungültige Kennung",J.de[e.lang.Errors.UNEVEN_OPERATORS]="Ungerade Operatoren",J.de[e.lang.Errors.EXPECTED_FUNCTION]="Erwartete Funktion",J.de[e.lang.Errors.EXPECTED_STATEMENT_END]="Erwartetes Ende der Anweisung",J.de[e.lang.Errors.ARRAY_INDEX_NOT_NUMBER]="Array-Index ist keine Zahl",J.de[e.lang.Errors.ARRAY_INDEX_MISSING]="Array-Index fehlt",J.de[e.lang.Errors.ARRAY_INDEX_OUT_BOUNDS]="Array-Index ist außerhalb der Grenzen",J.de[e.lang.Errors.FUNC_ARGUMENTS_MISHMASH]="Mischmasch der Funktionsargumente",J.de[e.lang.Errors.ATTRIBUTE_ALREADY_EXISTS]="Attribut existiert bereits",J.de[e.lang.Errors.ATTRIBUTE_NOT_FOUND]="Attribut nicht gefunden",J.de[e.lang.Errors.ELEMENT_NOT_FOUND]="Element nicht gefunden",J.de[e.lang.Errors.EMPTY_EXPRESSION]="Leerer Ausdruck",J.de[e.lang.Errors.UNKNOWN_OPERATOR]="Unbekannter Operator",J.de[e.lang.Errors.OPERATOR_NOT_APPLICABLE]="Operator nicht zutreffend",J.de[e.lang.Errors.ACCESS_OPERATOR_EXPECTED]="Zugriffsoperator erwartet",J.de[e.lang.Errors.WRONG_UNI_OPERATOR_SUBJECT]="Falscher Operand des Operators",J.de[e.lang.Errors.WRONG_BI_OPERATOR_SUBJECTS]="Falscher Operator Operand",J.de[e.lang.Errors.UNMATCHING_BI_OPERATOR_SUBJECTS]="Operator-Themen stimmen nicht überein",J.de[e.lang.Errors.EXPECTED_ARRAY]="Array erwartet",J.de[e.lang.Errors.EXPECTED_OBJECT]="Objekt erwartet",J.de[e.lang.Errors.EXPECTED_IDENTIFIER]="Bezeichner erwartet",J.de[e.lang.Errors.WRONG_ASSIGNMENT]="Falsche Zuordnung",J.de[e.lang.Errors.WRONG_ASSIGNEE_TYPE]="Falscher Empfängertyp",J.de[e.lang.Errors.READONLY_ATTRIBUTE]="Schreibgeschütztes Attribut",J.de[e.lang.Errors.WRONG_CONDITION]="Falsche Bedingung",J.de[e.lang.Errors.WRONG_CONDITION_VALUE]="Falscher Bedingungswert",J.de[e.lang.Errors.EXECUTION_STEPS_EXCEEDED]="Energiemangel",J.de[e.lang.Errors.PARSER_STEPS_EXCEEDED]="Parsing erschöpft",J.de[e.lang.Errors.PROTECTED_FROM_MODIFICATION]="Vor Änderungen geschützt",J.de[e.lang.Errors.DIVISION_BY_ZERO]="Division durch Null",J.de[e.lang.Errors.UNKNOWN_ERROR]="Fehler",J.cs[e.lang.Errors.INVALID_UNI_OPERATOR]="Neplatný operátor",J.cs[e.lang.Errors.INVALID_BI_OPERATOR]="Neplatný operátor",J.cs[e.lang.Errors.UNEXPECTED_END]="Neočekávaný konec",J.cs[e.lang.Errors.UNEXPECTED_SYMBOL]="Neočekávaný symbol",J.cs[e.lang.Errors.EXPECTED_SYMBOL]="Očekávaný symbol",J.cs[e.lang.Errors.UNREFERENCED_VARIABLE]="Neznámá proměnná",J.cs[e.lang.Errors.UNEXPECTED_KEYWORD]="Neočekávané klíčové slovo",J.cs[e.lang.Errors.INVALID_IDENTIFIER]="Neplatný identifikátor",J.cs[e.lang.Errors.UNEVEN_OPERATORS]="Neplatní operátoři",J.cs[e.lang.Errors.EXPECTED_FUNCTION]="Očekávána funkce",J.cs[e.lang.Errors.EXPECTED_STATEMENT_END]="Očekávaný konec výpisu",J.cs[e.lang.Errors.ARRAY_INDEX_NOT_NUMBER]="Index pole není číslo",J.cs[e.lang.Errors.ARRAY_INDEX_MISSING]="Chybí index pole",J.cs[e.lang.Errors.ARRAY_INDEX_OUT_BOUNDS]="Index pole je mimo rozsah",J.cs[e.lang.Errors.FUNC_ARGUMENTS_MISHMASH]="Funkční argumenty mišmaš",J.cs[e.lang.Errors.ATTRIBUTE_ALREADY_EXISTS]="Atribut již existuje",J.cs[e.lang.Errors.ATTRIBUTE_NOT_FOUND]="Atribut nenalezen",J.cs[e.lang.Errors.ELEMENT_NOT_FOUND]="Prvek nenalezen",J.cs[e.lang.Errors.EMPTY_EXPRESSION]="Prázdný výraz",J.cs[e.lang.Errors.UNKNOWN_OPERATOR]="Neznámý operátor",J.cs[e.lang.Errors.OPERATOR_NOT_APPLICABLE]="Operátor nelze použít",J.cs[e.lang.Errors.ACCESS_OPERATOR_EXPECTED]="Očekává se přístupový operátor",J.cs[e.lang.Errors.WRONG_UNI_OPERATOR_SUBJECT]="Nesprávný operand",J.cs[e.lang.Errors.WRONG_BI_OPERATOR_SUBJECTS]="Nesprávný operand",J.cs[e.lang.Errors.UNMATCHING_BI_OPERATOR_SUBJECTS]="Typ operandů se neshoduje",J.cs[e.lang.Errors.EXPECTED_ARRAY]="Očekáváno pole",J.cs[e.lang.Errors.EXPECTED_OBJECT]="Očekáván objekt",J.cs[e.lang.Errors.EXPECTED_IDENTIFIER]="Očekáván identifikátor",J.cs[e.lang.Errors.WRONG_ASSIGNMENT]="Chybné přiřazení",J.cs[e.lang.Errors.WRONG_ASSIGNEE_TYPE]="Chybný typ příjemce",J.cs[e.lang.Errors.READONLY_ATTRIBUTE]="Atribut pouze pro čtení",J.cs[e.lang.Errors.WRONG_CONDITION]="Chybná podmínka",J.cs[e.lang.Errors.WRONG_CONDITION_VALUE]="Chybná hodnota podmínky",J.cs[e.lang.Errors.EXECUTION_STEPS_EXCEEDED]="Energie vyčerpána",J.cs[e.lang.Errors.PARSER_STEPS_EXCEEDED]="Analýza vyčerpána",J.cs[e.lang.Errors.PROTECTED_FROM_MODIFICATION]="Chráněno před změnami",J.cs[e.lang.Errors.DIVISION_BY_ZERO]="Dělení nulou",J.cs[e.lang.Errors.UNKNOWN_ERROR]="Chyba",z();const H=new e.lang.NativeFunction(((...e)=>Y(...e))),$={Display:H,Zobraz:H,Anzeigen:H,Map:d.mapped,Mapa:d.mapped,Karte:d.mapped,Rocket:x.mapped,Raketa:x.mapped,Rakete:x.mapped,Ludolf:C.mapped};let K=!1;const Z={isInterrupted:()=>K},q=new e.LudolfC($,Z),Q=document.getElementById("code"),ee=document.getElementById("position"),te=document.getElementById("errorMarker"),re=document.querySelector(".line-numbers"),se=document.getElementById("display"),ne=document.getElementById("result"),ie=document.getElementById("runButton"),oe=document.querySelectorAll(".controls .char"),ae=document.getElementById("map");let ce,Ee,le=!1;function ue(){const e=Q.value.split("\n").length;re.innerHTML=Array(e).fill("<span></span>").join("")}function he(e){e=e.replace("<","<").replace(">",">").replace("&","&");const t=Q.selectionStart,r=Q.selectionEnd;Q.value=Q.value.substring(0,t)+e+Q.value.substring(r),Q.selectionEnd=t+1,Q.focus()}function pe(){const e=Q.value,t=Q.selectionEnd;let r=1,s=1;for(let n=0;n<e.length&&n<t;n++)s++,"\n"===e[n]&&(r++,s=1);ee.innerHTML=r+":"+s}function Ne(e,t){if(Oe(),!e||!t)return;ce=e,Ee=t;let{top:r}=o(re);const{left:s}=o(Q);r+=re.childNodes[0].offsetHeight*(e-1);const n=te.offsetWidth,i=te.cloneNode(!0);function o(e){let t=0,r=0;for(;null!==e;)t+=e.offsetTop,r+=e.offsetLeft,e=e.offsetParent;return{top:t,left:r}}i.id=te.id+"-copy",i.style.visibility="visible",i.style.letterSpacing=4*n+"px",i.style.top=r+"px",i.style.left=s+n+(n*t-3*n)+"px",te.parentNode.insertBefore(i,te)}function Oe(){const e=document.getElementById(te.id+"-copy");e&&e.remove(),ce=null,Ee=null}function _e(){localStorage.setItem("ludolfcCode",Q.value)}function de(){const e=localStorage.getItem("ludolfcCode");Q.value=e||j[V]}function Te(){se.style.height=se.offsetWidth+"px",ce&&Ee&&Ne(ce,Ee)}ie.addEventListener("click",(async()=>{if(le)K=!0;else{le=!0,Oe(),G(),_e(),ie.classList.remove("run"),ie.classList.add("stop"),ae.classList.remove("interrupted"),se.focus(),d.reset(),C.reset(),ne.classList.contains("error")&&ne.classList.remove("error");try{Y(await q.execute(Q.value))}catch(t){if(ae.classList.add("interrupted"),t.isLangInterruption)return void(ne.innerHTML+='\n<div class="error">❌⛔❌</div>');if(console.error(t),ne.classList.contains("error")||ne.classList.add("error"),t.isLangError){const r=t.line||0,s=t.col||0,n=(t.isParseError?"PARSE ":"")+"ERROR",i=r&&s?"(ln "+r+", col "+s+")":"";ne.innerHTML=n+" "+i+":<br>"+(e=t.id,(J[V]?.[e]||J.en?.[e]||e)+" ")+t.details,console.error(n,i,t.message),Ne(r,t.col)}else ne.innerHTML="ERROR "+t,console.error(t)}finally{ie.classList.add("run"),ie.classList.remove("stop"),K=!1,le=!1}var e}})),de(),ue(),Q.addEventListener("keyup",(e=>{pe(),ue(),Oe(),_e()})),Q.addEventListener("keydown",(e=>{"Tab"===e.key&&(he(" "),e.preventDefault())})),Q.addEventListener("mouseup",(e=>pe())),oe.forEach((e=>e.addEventListener("click",(t=>he(e.innerHTML))))),Te(),addEventListener("resize",(e=>Te())),document.querySelectorAll(".localization-control").forEach((e=>e.addEventListener("click",(()=>{var t;t=e.getAttribute("lang"),V=t||"en",localStorage.setItem("localization",V),z(),de()}))))})()})();