// Do not edit this file; automatically generated. /* eslint-disable */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD define(["./blockly_compressed.js"], factory); } else if (typeof exports === 'object') { // Node.js module.exports = factory(require("./blockly_compressed.js")); } else { // Browser var factoryExports = factory(root.Blockly); root.Blockly.JavaScript = factoryExports; } }(this, function(__parent__) { var $=__parent__.__namespace__; var module$contents$Blockly$JavaScript_JavaScript=new $.module$exports$Blockly$Generator.Generator("JavaScript");module$contents$Blockly$JavaScript_JavaScript.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+Object.getOwnPropertyNames($.module$exports$Blockly$utils$global.globalThis).join(",")); module$contents$Blockly$JavaScript_JavaScript.ORDER_ATOMIC=0;module$contents$Blockly$JavaScript_JavaScript.ORDER_NEW=1.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER=1.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL=2;module$contents$Blockly$JavaScript_JavaScript.ORDER_INCREMENT=3;module$contents$Blockly$JavaScript_JavaScript.ORDER_DECREMENT=3;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_NOT=4.1; module$contents$Blockly$JavaScript_JavaScript.ORDER_UNARY_PLUS=4.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_UNARY_NEGATION=4.3;module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT=4.4;module$contents$Blockly$JavaScript_JavaScript.ORDER_TYPEOF=4.5;module$contents$Blockly$JavaScript_JavaScript.ORDER_VOID=4.6;module$contents$Blockly$JavaScript_JavaScript.ORDER_DELETE=4.7;module$contents$Blockly$JavaScript_JavaScript.ORDER_AWAIT=4.8; module$contents$Blockly$JavaScript_JavaScript.ORDER_EXPONENTIATION=5;module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION=5.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_DIVISION=5.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_MODULUS=5.3;module$contents$Blockly$JavaScript_JavaScript.ORDER_SUBTRACTION=6.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION=6.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_SHIFT=7; module$contents$Blockly$JavaScript_JavaScript.ORDER_RELATIONAL=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_IN=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_INSTANCEOF=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_EQUALITY=9;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_AND=10;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_XOR=11;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_OR=12; module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND=13;module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR=14;module$contents$Blockly$JavaScript_JavaScript.ORDER_CONDITIONAL=15;module$contents$Blockly$JavaScript_JavaScript.ORDER_ASSIGNMENT=16;module$contents$Blockly$JavaScript_JavaScript.ORDER_YIELD=17;module$contents$Blockly$JavaScript_JavaScript.ORDER_COMMA=18;module$contents$Blockly$JavaScript_JavaScript.ORDER_NONE=99; module$contents$Blockly$JavaScript_JavaScript.ORDER_OVERRIDES=[[module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL,module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER],[module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL,module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER,module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER, module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT,module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION,module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION],[module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION,module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND, module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR,module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR]];module$contents$Blockly$JavaScript_JavaScript.isInitialized=!1; module$contents$Blockly$JavaScript_JavaScript.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;dc?h=g=this.ORDER_SUBTRACTION:d&&(h=g=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=Number(a)+c,d&&(a=-a)):(0c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e), h&&e>=h&&(a="("+a+")"));return a};$.Blockly.JavaScript=module$contents$Blockly$JavaScript_JavaScript;var module$exports$Blockly$JavaScript$variables={};$.Blockly.JavaScript.variables_get=function(a){return[$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.JavaScript.ORDER_ATOMIC]}; $.Blockly.JavaScript.variables_set=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";return $.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$JavaScript$variablesDynamic={};$.Blockly.JavaScript.variables_get_dynamic=$.Blockly.JavaScript.variables_get;$.Blockly.JavaScript.variables_set_dynamic=$.Blockly.JavaScript.variables_set;var module$exports$Blockly$JavaScript$texts={},module$contents$Blockly$JavaScript$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$JavaScript$texts_forceString=function(a){return module$contents$Blockly$JavaScript$texts_strRegExp.test(a)?[a,$.Blockly.JavaScript.ORDER_ATOMIC]:["String("+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]},module$contents$Blockly$JavaScript$texts_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1": c};$.Blockly.JavaScript.text=function(a){return[$.Blockly.JavaScript.quote_(a.getFieldValue("TEXT")),$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.text_multiline=function(a){a=$.Blockly.JavaScript.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.JavaScript.ORDER_ADDITION:$.Blockly.JavaScript.ORDER_ATOMIC;return[a,b]}; $.Blockly.JavaScript.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.JavaScript.ORDER_ATOMIC];case 1:return a=$.Blockly.JavaScript.valueToCode(a,"ADD0",$.Blockly.JavaScript.ORDER_NONE)||"''",module$contents$Blockly$JavaScript$texts_forceString(a);case 2:var b=$.Blockly.JavaScript.valueToCode(a,"ADD0",$.Blockly.JavaScript.ORDER_NONE)||"''";a=$.Blockly.JavaScript.valueToCode(a,"ADD1",$.Blockly.JavaScript.ORDER_NONE)||"''";return[module$contents$Blockly$JavaScript$texts_forceString(b)[0]+ " + "+module$contents$Blockly$JavaScript$texts_forceString(a)[0],$.Blockly.JavaScript.ORDER_ADDITION];default:b=Array(a.itemCount_);for(var c=0;c 0",$.Blockly.JavaScript.ORDER_RELATIONAL,$.Blockly.JavaScript.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.JavaScript.ORDER_RELATIONAL,$.Blockly.JavaScript.ORDER_RELATIONAL], DIVISIBLE_BY:[null,$.Blockly.JavaScript.ORDER_MODULUS,$.Blockly.JavaScript.ORDER_EQUALITY],PRIME:[null,$.Blockly.JavaScript.ORDER_NONE,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.JavaScript.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";"PRIME"===c?a=$.Blockly.JavaScript.provideFunction_("mathIsPrime","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n")+ "("+e+")":"DIVISIBLE_BY"===c?(a=$.Blockly.JavaScript.valueToCode(a,"DIVISOR",$.Blockly.JavaScript.ORDER_MODULUS)||"0",a=e+" % "+a+" === 0"):a=e+d;return[a,b]};$.Blockly.JavaScript.math_change=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"DELTA",$.Blockly.JavaScript.ORDER_ADDITION)||"0";a=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+b+";\n"}; $.Blockly.JavaScript.math_round=$.Blockly.JavaScript.math_single;$.Blockly.JavaScript.math_trig=$.Blockly.JavaScript.math_single; $.Blockly.JavaScript.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_MEMBER)||"[]";a+=".reduce(function(x, y) {return x + y;})";break;case "MIN":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a="Math.min.apply(null, "+a+")";break;case "MAX":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a="Math.max.apply(null, "+a+")";break;case "AVERAGE":b= $.Blockly.JavaScript.provideFunction_("mathMean","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(myList) {\n return myList.reduce(function(x, y) {return x + y;}) / myList.length;\n}\n");a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MEDIAN":b=$.Blockly.JavaScript.provideFunction_("mathMedian","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n"); a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=$.Blockly.JavaScript.provideFunction_("mathModes","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n"); a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=$.Blockly.JavaScript.provideFunction_("mathStandardDeviation","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance = variance / n;\n return Math.sqrt(variance);\n}\n"); a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=$.Blockly.JavaScript.provideFunction_("mathRandomList","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n");a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}; $.Blockly.JavaScript.math_modulo=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"DIVIDEND",$.Blockly.JavaScript.ORDER_MODULUS)||"0";a=$.Blockly.JavaScript.valueToCode(a,"DIVISOR",$.Blockly.JavaScript.ORDER_MODULUS)||"0";return[b+" % "+a,$.Blockly.JavaScript.ORDER_MODULUS]}; $.Blockly.JavaScript.math_constrain=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_NONE)||"0",c=$.Blockly.JavaScript.valueToCode(a,"LOW",$.Blockly.JavaScript.ORDER_NONE)||"0";a=$.Blockly.JavaScript.valueToCode(a,"HIGH",$.Blockly.JavaScript.ORDER_NONE)||"Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}; $.Blockly.JavaScript.math_random_int=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"FROM",$.Blockly.JavaScript.ORDER_NONE)||"0";a=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_NONE)||"0";return[$.Blockly.JavaScript.provideFunction_("mathRandomInt","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n")+ "("+b+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.math_random_float=function(a){return["Math.random()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.math_atan2=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"X",$.Blockly.JavaScript.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.JavaScript.valueToCode(a,"Y",$.Blockly.JavaScript.ORDER_NONE)||"0")+", "+b+") / Math.PI * 180",$.Blockly.JavaScript.ORDER_DIVISION]};var module$exports$Blockly$JavaScript$loops={}; $.Blockly.JavaScript.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.JavaScript.valueToCode(a,"TIMES",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.JavaScript.statementToCode(a,"DO");c=$.Blockly.JavaScript.addLoopTrap(c,a);a="";var d=$.Blockly.JavaScript.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.JavaScript.nameDB_.getDistinctName("repeat_end", $.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+e+" = "+b+";\n");return a+("for (var "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.JavaScript.controls_repeat=$.Blockly.JavaScript.controls_repeat_ext; $.Blockly.JavaScript.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.JavaScript.valueToCode(a,"BOOL",b?$.Blockly.JavaScript.ORDER_LOGICAL_NOT:$.Blockly.JavaScript.ORDER_NONE)||"false",d=$.Blockly.JavaScript.statementToCode(a,"DO");d=$.Blockly.JavaScript.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"}; $.Blockly.JavaScript.controls_for=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.JavaScript.valueToCode(a,"FROM",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",d=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",e=$.Blockly.JavaScript.valueToCode(a,"BY",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"1",f=$.Blockly.JavaScript.statementToCode(a,"DO");f=$.Blockly.JavaScript.addLoopTrap(f, a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE), a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||(c=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.JavaScript.INDENT+ d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a}; $.Blockly.JavaScript.controls_forEach=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.JavaScript.statementToCode(a,"DO");d=$.Blockly.JavaScript.addLoopTrap(d,a);a="";var e=c;c.match(/^\w+$/)||(e=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_list",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+e+" = "+c+ ";\n");c=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_index",$.module$exports$Blockly$Names.NameType.VARIABLE);d=$.Blockly.JavaScript.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")}; $.Blockly.JavaScript.controls_flow_statements=function(a){var b="";$.Blockly.JavaScript.STATEMENT_PREFIX&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,a));$.Blockly.JavaScript.STATEMENT_SUFFIX&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a));if($.Blockly.JavaScript.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+ "break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$JavaScript$logic={}; $.Blockly.JavaScript.controls_if=function(a){var b=0,c="";$.Blockly.JavaScript.STATEMENT_PREFIX&&(c+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,a));do{var d=$.Blockly.JavaScript.valueToCode(a,"IF"+b,$.Blockly.JavaScript.ORDER_NONE)||"false",e=$.Blockly.JavaScript.statementToCode(a,"DO"+b);$.Blockly.JavaScript.STATEMENT_SUFFIX&&(e=$.Blockly.JavaScript.prefixLines($.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a),$.Blockly.JavaScript.INDENT)+e);c+=(0",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.JavaScript.ORDER_EQUALITY:$.Blockly.JavaScript.ORDER_RELATIONAL,d=$.Blockly.JavaScript.valueToCode(a,"A",c)||"0";a=$.Blockly.JavaScript.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]}; $.Blockly.JavaScript.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.JavaScript.ORDER_LOGICAL_AND:$.Blockly.JavaScript.ORDER_LOGICAL_OR,d=$.Blockly.JavaScript.valueToCode(a,"A",c);a=$.Blockly.JavaScript.valueToCode(a,"B",c);if(d||a){var e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]}; $.Blockly.JavaScript.logic_negate=function(a){var b=$.Blockly.JavaScript.ORDER_LOGICAL_NOT;return["!"+($.Blockly.JavaScript.valueToCode(a,"BOOL",b)||"true"),b]};$.Blockly.JavaScript.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.logic_null=function(a){return["null",$.Blockly.JavaScript.ORDER_ATOMIC]}; $.Blockly.JavaScript.logic_ternary=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"IF",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"false",c=$.Blockly.JavaScript.valueToCode(a,"THEN",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"null";a=$.Blockly.JavaScript.valueToCode(a,"ELSE",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.JavaScript.ORDER_CONDITIONAL]};var module$exports$Blockly$JavaScript$lists={};$.Blockly.JavaScript.lists_create_empty=function(a){return["[]",$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c b.toString() ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n "); return[b+".slice().sort("+d+'("'+a+'", '+c+"))",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.lists_split=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"INPUT",$.Blockly.JavaScript.ORDER_MEMBER),c=$.Blockly.JavaScript.valueToCode(a,"DELIM",$.Blockly.JavaScript.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}; $.Blockly.JavaScript.lists_reverse=function(a){return[($.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$colour={};$.Blockly.JavaScript.colour_picker=function(a){return[$.Blockly.JavaScript.quote_(a.getFieldValue("COLOUR")),$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.colour_random=function(a){return[$.Blockly.JavaScript.provideFunction_("colourRandom","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"() {\n var num = Math.floor(Math.random() * Math.pow(2, 24));\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n")+"()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}; $.Blockly.JavaScript.colour_rgb=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"RED",$.Blockly.JavaScript.ORDER_NONE)||0,c=$.Blockly.JavaScript.valueToCode(a,"GREEN",$.Blockly.JavaScript.ORDER_NONE)||0;a=$.Blockly.JavaScript.valueToCode(a,"BLUE",$.Blockly.JavaScript.ORDER_NONE)||0;return[$.Blockly.JavaScript.provideFunction_("colourRgb","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n")+ "("+b+", "+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}; $.Blockly.JavaScript.colour_blend=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"COLOUR1",$.Blockly.JavaScript.ORDER_NONE)||"'#000000'",c=$.Blockly.JavaScript.valueToCode(a,"COLOUR2",$.Blockly.JavaScript.ORDER_NONE)||"'#000000'";a=$.Blockly.JavaScript.valueToCode(a,"RATIO",$.Blockly.JavaScript.ORDER_NONE)||.5;return[$.Blockly.JavaScript.provideFunction_("colourBlend","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n")+ "("+b+", "+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$all={}; $.Blockly.JavaScript.__namespace__=$; return $.Blockly.JavaScript; })); //# sourceMappingURL=javascript_compressed.js.map