javascript_compressed.js 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. // Do not edit this file; automatically generated.
  2. /* eslint-disable */
  3. ;(function(root, factory) {
  4. if (typeof define === 'function' && define.amd) { // AMD
  5. define(["./blockly_compressed.js"], factory);
  6. } else if (typeof exports === 'object') { // Node.js
  7. module.exports = factory(require("./blockly_compressed.js"));
  8. } else { // Browser
  9. var factoryExports = factory(root.Blockly);
  10. root.Blockly.JavaScript = factoryExports.javascriptGenerator;
  11. root.Blockly.JavaScript.__namespace__ = factoryExports.__namespace__;
  12. }
  13. }(this, function(__parent__) {
  14. var $=__parent__.__namespace__;
  15. var module$exports$Blockly$JavaScript={},module$contents$Blockly$JavaScript_Variables=$.module$build$src$core$variables,module$contents$Blockly$JavaScript_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$JavaScript_CodeGenerator=$.CodeGenerator$$module$build$src$core$generator,module$contents$Blockly$JavaScript_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$JavaScript_Names=$.module$build$src$core$names.Names,module$contents$Blockly$JavaScript_NameType=
  16. $.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator=new $.CodeGenerator$$module$build$src$core$generator("JavaScript");
  17. module$exports$Blockly$JavaScript.javascriptGenerator.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(globalThis).join(","));module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC=0;
  18. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NEW=1.1;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER=1.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL=2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_INCREMENT=3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DECREMENT=3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_NOT=4.1;
  19. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_PLUS=4.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION=4.3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT=4.4;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_TYPEOF=4.5;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_VOID=4.6;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DELETE=4.7;
  20. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_AWAIT=4.8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EXPONENTIATION=5;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION=5.1;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION=5.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS=5.3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION=6.1;
  21. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION=6.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_SHIFT=7;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_IN=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_INSTANCEOF=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY=9;
  22. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_AND=10;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_XOR=11;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_OR=12;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND=13;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR=14;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL=15;
  23. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT=16;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_YIELD=17;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_COMMA=18;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE=99;
  24. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER,
  25. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION],
  26. [module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR]];module$exports$Blockly$JavaScript.javascriptGenerator.isInitialized=!1;
  27. module$exports$Blockly$JavaScript.javascriptGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.module$build$src$core$variables.allDeveloperVariables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
  28. a=$.module$build$src$core$variables.allUsedVarModels(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};module$exports$Blockly$JavaScript.javascriptGenerator.finish=function(a){const b=Object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};
  29. module$exports$Blockly$JavaScript.javascriptGenerator.scrubNakedValue=function(a){return a+";\n"};module$exports$Blockly$JavaScript.javascriptGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};module$exports$Blockly$JavaScript.javascriptGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")};
  30. module$exports$Blockly$JavaScript.javascriptGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","// "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=
  31. a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
  32. module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;const f=a.workspace.options.oneBasedIndex?"1":"0";let g,h=e;0<c?g=h=this.ORDER_ADDITION:0>c?g=h=this.ORDER_SUBTRACTION:d&&(g=h=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,h)||f;$.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),g=Math.floor(g),e=Math.floor(e),
  33. g&&e>=g&&(a="("+a+")"));return a};var module$exports$Blockly$JavaScript$variables={},module$contents$Blockly$JavaScript$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.variables_get=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  34. module$exports$Blockly$JavaScript.javascriptGenerator.variables_set=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0";return module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$JavaScript$variablesDynamic={};module$exports$Blockly$JavaScript.javascriptGenerator.variables_get_dynamic=module$exports$Blockly$JavaScript.javascriptGenerator.variables_get;module$exports$Blockly$JavaScript.javascriptGenerator.variables_set_dynamic=module$exports$Blockly$JavaScript.javascriptGenerator.variables_set;var module$exports$Blockly$JavaScript$texts={},module$contents$Blockly$JavaScript$texts_NameType=$.NameType$$module$build$src$core$names,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,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]:["String("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]},
  35. 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};module$exports$Blockly$JavaScript.javascriptGenerator.text=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  36. module$exports$Blockly$JavaScript.javascriptGenerator.text_multiline=function(a){a=module$exports$Blockly$JavaScript.javascriptGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("+")?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC;return[a,b]};
  37. module$exports$Blockly$JavaScript.javascriptGenerator.text_join=function(a){switch(a.itemCount_){case 0:return["''",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC];case 1:return a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''",module$contents$Blockly$JavaScript$texts_forceString(a);case 2:var b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  38. "''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[module$contents$Blockly$JavaScript$texts_forceString(b)[0]+" + "+module$contents$Blockly$JavaScript$texts_forceString(a)[0],module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION];default:b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  39. "''";return["["+b.join(",")+"].join('')",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}};
  40. module$exports$Blockly$JavaScript.javascriptGenerator.text_append=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return b+" += "+module$contents$Blockly$JavaScript$texts_forceString(a)[0]+";\n"};
  41. module$exports$Blockly$JavaScript.javascriptGenerator.text_length=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER]};
  42. module$exports$Blockly$JavaScript.javascriptGenerator.text_isEmpty=function(a){return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT]};
  43. module$exports$Blockly$JavaScript.javascriptGenerator.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FIND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?
  44. [b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  45. module$exports$Blockly$JavaScript.javascriptGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE","RANDOM"===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+".charAt(0)",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "LAST":return[c+".slice(-1)",
  46. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "FROM_START":return a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT"),[c+".charAt("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "FROM_END":return a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!0),[c+".slice("+a+").charAt(0)",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "RANDOM":return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textRandomLetter",
  47. `
  48. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(text) {
  49. var x = Math.floor(Math.random() * text.length);
  50. return text[x];
  51. }
  52. `)+"("+c+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
  53. module$exports$Blockly$JavaScript.javascriptGenerator.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"LAST"!==b&&"FROM_END"!==c&&"LAST"!==c,e=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"STRING",d?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE];
  54. if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");break;case "FROM_END":b=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);b=e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
  55. "AT2",1);break;case "FROM_END":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);c=e+".length - "+c;break;case "LAST":c=e+".length";break;default:throw Error("Unhandled option (text_getSubstring).");}e=e+".slice("+b+", "+c+")"}else{d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2");const f={FIRST:"First",
  56. LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};e=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("subsequence"+f[b]+f[c],`
  57. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===b||"FROM_START"===b?", at1":""}${"FROM_END"===c||"FROM_START"===c?", at2":""}) {
  58. var start = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",b,"at1")};
  59. var end = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",c,"at2")} + 1;
  60. return sequence.slice(start, end);
  61. }
  62. `)+"("+e+("FROM_END"===b||"FROM_START"===b?", "+d:"")+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")"}return[e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  63. module$exports$Blockly$JavaScript.javascriptGenerator.text_changeCase=function(a){const b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[b?a+b:module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textToTitleCase",
  64. `
  65. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(str) {
  66. return str.replace(/\\S+/g,
  67. function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
  68. }
  69. `)+"("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.text_trim=function(a){const b={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  70. module$exports$Blockly$JavaScript.javascriptGenerator.text_print=function(a){return"window.alert("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''")+");\n"};
  71. module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt_ext=function(a){let b="window.prompt("+(a.getField("TEXT")?module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="Number("+b+")");return[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  72. module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt=module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt_ext;
  73. module$exports$Blockly$JavaScript.javascriptGenerator.text_count=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"SUB",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textCount",`
  74. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
  75. if (needle.length === 0) {
  76. return haystack.length + 1;
  77. } else {
  78. return haystack.split(needle).length - 1;
  79. }
  80. }
  81. `)+"("+b+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  82. module$exports$Blockly$JavaScript.javascriptGenerator.text_replace=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  83. "''";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textReplace",`
  84. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
  85. needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
  86. .replace(/\\x08/g, '\\\\x08');
  87. return haystack.replace(new RegExp(needle, 'g'), replacement);
  88. }
  89. `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.text_reverse=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".split('').reverse().join('')",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$procedures={},module$contents$Blockly$JavaScript$procedures_NameType=$.NameType$$module$build$src$core$names;
  90. module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defreturn=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var c="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&
  91. (c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a));c&&(c=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(c,module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));let d="";module$exports$Blockly$JavaScript.javascriptGenerator.INFINITE_LOOP_TRAP&&(d=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.INFINITE_LOOP_TRAP,
  92. a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));const e=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"STACK");let f=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RETURN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return "+f+";\n");const h=[],k=a.getVars();for(let l=0;l<k.length;l++)h[l]=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(k[l],
  93. $.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+h.join(", ")+") {\n"+c+d+e+g+f+"}";c=module$exports$Blockly$JavaScript.javascriptGenerator.scrub_(a,c);module$exports$Blockly$JavaScript.javascriptGenerator.definitions_["%"+b]=c;return null};module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defnoreturn=module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defreturn;
  94. module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  95. module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callreturn(a)[0]+";\n"};
  96. module$exports$Blockly$JavaScript.javascriptGenerator.procedures_ifreturn=function(a){let b="if ("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false")+") {\n";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,
  97. a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));a.hasReturnValue_?(a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null",b+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return "+a+";\n"):b+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$JavaScript$math={},module$contents$Blockly$JavaScript$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0<=a?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION]};
  98. module$exports$Blockly$JavaScript.javascriptGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION],MINUS:[" - ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION],POWER:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE]}[a.getFieldValue("OP")];
  99. const c=b[0];b=b[1];const d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",b)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["Math.pow("+d+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  100. module$exports$Blockly$JavaScript.javascriptGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",
  101. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION)||"0":module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="Math.abs("+a+")";break;case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c="Math.round("+a+")";break;case "ROUNDUP":c="Math.ceil("+a+")";break;
  102. case "ROUNDDOWN":c="Math.floor("+a+")";break;case "SIN":c="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":c="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":c="Math.tan("+a+" / 180 * Math.PI)"}if(c)return[c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];switch(b){case "LOG10":c="Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.PI * 180";break;case "ACOS":c="Math.acos("+a+") / Math.PI * 180";break;case "ATAN":c="Math.atan("+a+") / Math.PI * 180";
  103. break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION]};
  104. module$exports$Blockly$JavaScript.javascriptGenerator.math_constant=function(a){return{PI:["Math.PI",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],E:["Math.E",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION],SQRT2:["Math.SQRT2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],
  105. INFINITY:["Infinity",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
  106. module$exports$Blockly$JavaScript.javascriptGenerator.math_number_property=function(a){var b={EVEN:[" % 2 === 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],ODD:[" % 2 === 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],WHOLE:[" % 1 === 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],
  107. POSITIVE:[" > 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],PRIME:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE,
  108. module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";"PRIME"===c?a=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathIsPrime",`
  109. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) {
  110. // https://en.wikipedia.org/wiki/Primality_test#Naive_methods
  111. if (n == 2 || n == 3) {
  112. return true;
  113. }
  114. // False if n is NaN, negative, is 1, or not whole.
  115. // And false if n is divisible by 2 or 3.
  116. if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {
  117. return false;
  118. }
  119. // Check all the numbers of form 6k +/- 1, up to sqrt(n).
  120. for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
  121. if (n % (x - 1) === 0 || n % (x + 1) === 0) {
  122. return false;
  123. }
  124. }
  125. return true;
  126. }
  127. `)+"("+b+")":"DIVISIBLE_BY"===c?(a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0",a=b+" % "+a+" === 0"):a=b+d;return[a,f]};
  128. module$exports$Blockly$JavaScript.javascriptGenerator.math_change=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DELTA",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+b+";\n"};
  129. module$exports$Blockly$JavaScript.javascriptGenerator.math_round=module$exports$Blockly$JavaScript.javascriptGenerator.math_single;module$exports$Blockly$JavaScript.javascriptGenerator.math_trig=module$exports$Blockly$JavaScript.javascriptGenerator.math_single;
  130. module$exports$Blockly$JavaScript.javascriptGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";a+=".reduce(function(x, y) {return x + y;}, 0)";break;case "MIN":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a="Math.min.apply(null, "+
  131. a+")";break;case "MAX":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a="Math.max.apply(null, "+a+")";break;case "AVERAGE":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathMean",`
  132. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
  133. return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
  134. }
  135. `);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MEDIAN":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathMedian",`
  136. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
  137. var localList = myList.filter(function (x) {return typeof x === 'number';});
  138. if (!localList.length) return null;
  139. localList.sort(function(a, b) {return b - a;});
  140. if (localList.length % 2 === 0) {
  141. return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;
  142. } else {
  143. return localList[(localList.length - 1) / 2];
  144. }
  145. }
  146. `);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathModes",`
  147. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) {
  148. var modes = [];
  149. var counts = [];
  150. var maxCount = 0;
  151. for (var i = 0; i < values.length; i++) {
  152. var value = values[i];
  153. var found = false;
  154. var thisCount;
  155. for (var j = 0; j < counts.length; j++) {
  156. if (counts[j][0] === value) {
  157. thisCount = ++counts[j][1];
  158. found = true;
  159. break;
  160. }
  161. }
  162. if (!found) {
  163. counts.push([value, 1]);
  164. thisCount = 1;
  165. }
  166. maxCount = Math.max(thisCount, maxCount);
  167. }
  168. for (var j = 0; j < counts.length; j++) {
  169. if (counts[j][1] === maxCount) {
  170. modes.push(counts[j][0]);
  171. }
  172. }
  173. return modes;
  174. }
  175. `);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathStandardDeviation",`
  176. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
  177. var n = numbers.length;
  178. if (!n) return null;
  179. var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
  180. var variance = 0;
  181. for (var j = 0; j < n; j++) {
  182. variance += Math.pow(numbers[j] - mean, 2);
  183. }
  184. variance = variance / n;
  185. return Math.sqrt(variance);
  186. }
  187. `);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathRandomList",`
  188. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list) {
  189. var x = Math.floor(Math.random() * list.length);
  190. return list[x];
  191. }
  192. `);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  193. module$exports$Blockly$JavaScript.javascriptGenerator.math_modulo=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0";return[b+" % "+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS]};
  194. module$exports$Blockly$JavaScript.javascriptGenerator.math_constrain=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LOW",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"HIGH",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  195. "Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  196. module$exports$Blockly$JavaScript.javascriptGenerator.math_random_int=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathRandomInt",`
  197. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
  198. if (a > b) {
  199. // Swap a and b to ensure a is smaller.
  200. var c = a;
  201. a = b;
  202. b = c;
  203. }
  204. return Math.floor(Math.random() * (b - a + 1) + a);
  205. }
  206. `)+"("+b+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.math_random_float=function(a){return["Math.random()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  207. module$exports$Blockly$JavaScript.javascriptGenerator.math_atan2=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"X",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return["Math.atan2("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"Y",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0")+", "+b+") / Math.PI * 180",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION]};var module$exports$Blockly$JavaScript$loops={},module$contents$Blockly$JavaScript$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$JavaScript$loops_NameType=$.NameType$$module$build$src$core$names;
  208. module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TIMES",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0";let c=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");c=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(c,a);a="";const d=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("count",
  209. $.NameType$$module$build$src$core$names.VARIABLE);let e=b;b.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(b)||(e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("repeat_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+e+" = "+b+";\n");return a+("for (var "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat=module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat_ext;
  210. module$exports$Blockly$JavaScript.javascriptGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");d=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(d,
  211. a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
  212. module$exports$Blockly$JavaScript.javascriptGenerator.controls_for=function(a){var b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0",d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||
  213. "0";const e=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BY",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"1";let f=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");f=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(f,a);if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)){var g=Number(c)<=Number(d);a=
  214. "for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b);a+=") {\n"+f+"}\n"}else a="",g=c,c.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(c)||(g=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_start",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(d)||(c=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+
  215. "_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+c+" = "+d+";\n"),d=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+d+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+d+" = -"+d+";\n",a=a+"}\nfor ("+(b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+
  216. c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a};
  217. module$exports$Blockly$JavaScript.javascriptGenerator.controls_forEach=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"[]";let d=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");d=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(d,
  218. a);a="";let e=c;c.match(/^\w+$/)||(e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_list",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+e+" = "+c+";\n");c=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_index",$.NameType$$module$build$src$core$names.VARIABLE);d=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")};
  219. module$exports$Blockly$JavaScript.javascriptGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,
  220. a));if(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.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={};
  221. module$exports$Blockly$JavaScript.javascriptGenerator.controls_if=function(a){var b=0;let c="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));do{const d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false";let e=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,
  222. "DO"+b);module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(e=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT)+e);c+=(0<b?" else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX)b=
  223. module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT)+b),c+=" else {\n"+b+"}";return c+"\n"};
  224. module$exports$Blockly$JavaScript.javascriptGenerator.controls_ifelse=module$exports$Blockly$JavaScript.javascriptGenerator.controls_if;
  225. module$exports$Blockly$JavaScript.javascriptGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+
  226. " "+a,c]};
  227. module$exports$Blockly$JavaScript.javascriptGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",c);if(d||a){const e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=
  228. d="false";return[d+" "+b+" "+a,c]};module$exports$Blockly$JavaScript.javascriptGenerator.logic_negate=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT;return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BOOL",b)||"true"),b]};module$exports$Blockly$JavaScript.javascriptGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  229. module$exports$Blockly$JavaScript.javascriptGenerator.logic_null=function(a){return["null",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  230. module$exports$Blockly$JavaScript.javascriptGenerator.logic_ternary=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"IF",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||"false",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"THEN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||"null";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ELSE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||
  231. "null";return[b+" ? "+c+" : "+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$JavaScript$lists={},module$contents$Blockly$JavaScript$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.lists_create_empty=function(a){return["[]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  232. module$exports$Blockly$JavaScript.javascriptGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";return["["+b.join(", ")+"]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
  233. module$exports$Blockly$JavaScript.javascriptGenerator.lists_repeat=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsRepeat",`
  234. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
  235. var array = [];
  236. for (var i = 0; i < n; i++) {
  237. array[i] = value;
  238. }
  239. return array;
  240. }
  241. `),c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ITEM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  242. module$exports$Blockly$JavaScript.javascriptGenerator.lists_length=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER]};
  243. module$exports$Blockly$JavaScript.javascriptGenerator.lists_isEmpty=function(a){return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT]};
  244. module$exports$Blockly$JavaScript.javascriptGenerator.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FIND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?
  245. [b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  246. module$exports$Blockly$JavaScript.javascriptGenerator.lists_getIndex=function(a){const b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";var d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE","RANDOM"===c?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];
  247. if("GET_REMOVE"===b)return[d+".shift()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("REMOVE"===b)return d+".shift();\n";break;case "LAST":if("GET"===b)return[d+".slice(-1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("REMOVE"===b)return d+".pop();\n";break;case "FROM_START":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
  248. "AT");if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".splice("+a+", 1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);\n";break;case "FROM_END":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!0);if("GET"===b)return[d+".slice("+a+")[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===
  249. b)return[d+".splice("+a+", 1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);";break;case "RANDOM":d=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsGetRandomItem",`
  250. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
  251. var x = Math.floor(Math.random() * list.length);
  252. if (remove) {
  253. return list.splice(x, 1)[0];
  254. } else {
  255. return list[x];
  256. }
  257. }
  258. `)+"("+d+", "+("GET"!==b)+")";if("GET"===b||"GET_REMOVE"===b)return[d,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+";\n"}throw Error("Unhandled combination (lists_getIndex).");};
  259. module$exports$Blockly$JavaScript.javascriptGenerator.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))return"";const g=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("tmpList",$.NameType$$module$build$src$core$names.VARIABLE),h="var "+g+" = "+c+";\n";c=g;return h}let c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";const d=a.getFieldValue("MODE")||"GET";
  260. var e=a.getFieldValue("WHERE")||"FROM_START";const f=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"null";switch(e){case "FIRST":if("SET"===d)return c+"[0] = "+f+";\n";if("INSERT"===d)return c+".unshift("+f+");\n";break;case "LAST":if("SET"===d)return b()+(c+"["+c+".length - 1] = "+f+";\n");if("INSERT"===d)return c+".push("+f+");\n";break;case "FROM_START":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
  261. "AT");if("SET"===d)return c+"["+a+"] = "+f+";\n";if("INSERT"===d)return c+".splice("+a+", 0, "+f+");\n";break;case "FROM_END":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);e=b();if("SET"===d)return e+(c+"["+c+".length - "+a+"] = "+f+";\n");if("INSERT"===d)return e+(c+".splice("+c+".length - "+a+", 0, "+f+");\n");break;case "RANDOM":a=b();e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("tmpX",
  262. $.NameType$$module$build$src$core$names.VARIABLE);a+="var "+e+" = Math.floor(Math.random() * "+c+".length);\n";if("SET"===d)return a+(c+"["+e+"] = "+f+";\n");if("INSERT"===d)return a+(c+".splice("+e+", 0, "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};var module$contents$Blockly$JavaScript$lists_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":c};
  263. module$exports$Blockly$JavaScript.javascriptGenerator.lists_getSublist=function(a){var b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"===c&&"LAST"===d)b+=".slice(0)";else if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");
  264. break;case "FROM_END":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",1);break;case "FROM_END":d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);
  265. d=b+".length - "+d;break;case "LAST":d=b+".length";break;default:throw Error("Unhandled option (lists_getSublist).");}b=b+".slice("+c+", "+d+")"}else{const e=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2");const f={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("subsequence"+f[c]+f[d],`
  266. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===c||"FROM_START"===c?", at1":""}${"FROM_END"===d||"FROM_START"===d?", at2":""}) {
  267. var start = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",c,"at1")};
  268. var end = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",d,"at2")} + 1;
  269. return sequence.slice(start, end);
  270. }
  271. `)+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")"}return[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  272. module$exports$Blockly$JavaScript.javascriptGenerator.lists_sort=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");const d=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsGetSortCompare",`
  273. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
  274. var compareFuncs = {
  275. 'NUMERIC': function(a, b) {
  276. return Number(a) - Number(b); },
  277. 'TEXT': function(a, b) {
  278. return a.toString() > b.toString() ? 1 : -1; },
  279. 'IGNORE_CASE': function(a, b) {
  280. return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },
  281. };
  282. var compare = compareFuncs[type];
  283. return function(a, b) { return compare(a, b) * direction; };
  284. }
  285. `);return[b+".slice().sort("+d+'("'+a+'", '+c+"))",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  286. module$exports$Blockly$JavaScript.javascriptGenerator.lists_split=function(a){let b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"INPUT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER);const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DELIM",module$exports$Blockly$JavaScript.javascriptGenerator.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: "+
  287. a);return[b+"."+a+"("+c+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.lists_reverse=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$colour={};module$exports$Blockly$JavaScript.javascriptGenerator.colour_picker=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};module$exports$Blockly$JavaScript.javascriptGenerator.colour_random=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourRandom",`
  288. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
  289. var num = Math.floor(Math.random() * Math.pow(2, 24));
  290. return '#' + ('00000' + num.toString(16)).substr(-6);
  291. }
  292. `)+"()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  293. module$exports$Blockly$JavaScript.javascriptGenerator.colour_rgb=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RED",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||0,c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"GREEN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||0;a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BLUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  294. 0;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourRgb",`
  295. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
  296. r = Math.max(Math.min(Number(r), 100), 0) * 2.55;
  297. g = Math.max(Math.min(Number(g), 100), 0) * 2.55;
  298. b = Math.max(Math.min(Number(b), 100), 0) * 2.55;
  299. r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);
  300. g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);
  301. b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
  302. return '#' + r + g + b;
  303. }
  304. `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
  305. module$exports$Blockly$JavaScript.javascriptGenerator.colour_blend=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"'#000000'",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RATIO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
  306. .5;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourBlend",`
  307. function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
  308. ratio = Math.max(Math.min(Number(ratio), 1), 0);
  309. var r1 = parseInt(c1.substring(1, 3), 16);
  310. var g1 = parseInt(c1.substring(3, 5), 16);
  311. var b1 = parseInt(c1.substring(5, 7), 16);
  312. var r2 = parseInt(c2.substring(1, 3), 16);
  313. var g2 = parseInt(c2.substring(3, 5), 16);
  314. var b2 = parseInt(c2.substring(5, 7), 16);
  315. var r = Math.round(r1 * (1 - ratio) + r2 * ratio);
  316. var g = Math.round(g1 * (1 - ratio) + g2 * ratio);
  317. var b = Math.round(b1 * (1 - ratio) + b2 * ratio);
  318. r = ('0' + (r || 0).toString(16)).slice(-2);
  319. g = ('0' + (g || 0).toString(16)).slice(-2);
  320. b = ('0' + (b || 0).toString(16)).slice(-2);
  321. return '#' + r + g + b;
  322. }
  323. `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$all=module$exports$Blockly$JavaScript;
  324. module$exports$Blockly$JavaScript.__namespace__=$;
  325. return module$exports$Blockly$JavaScript;
  326. }));
  327. //# sourceMappingURL=javascript_compressed.js.map