blockly 9.3.3 → 10.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +9 -7
  2. package/blockly.min.js +1314 -1415
  3. package/blockly_compressed.js +1067 -1110
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +120 -136
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +59 -32
  8. package/core/block_dragger.d.ts +2 -2
  9. package/core/block_svg.d.ts +38 -67
  10. package/core/blockly.d.ts +18 -112
  11. package/core/browser_events.d.ts +1 -2
  12. package/core/bubble_dragger.d.ts +1 -2
  13. package/core/{bubble.d.ts → bubble_old.d.ts} +3 -7
  14. package/core/bubbles/bubble.d.ts +174 -0
  15. package/core/bubbles/mini_workspace_bubble.d.ts +80 -0
  16. package/core/bubbles/text_bubble.d.ts +35 -0
  17. package/core/bubbles/textinput_bubble.d.ts +89 -0
  18. package/core/bump_objects.d.ts +6 -4
  19. package/core/connection.d.ts +19 -9
  20. package/core/connection_db.d.ts +4 -4
  21. package/core/contextmenu.d.ts +1 -2
  22. package/core/events/events.d.ts +1 -4
  23. package/core/events/events_abstract.d.ts +0 -6
  24. package/core/events/events_block_base.d.ts +0 -6
  25. package/core/events/events_block_change.d.ts +0 -6
  26. package/core/events/events_block_create.d.ts +0 -6
  27. package/core/events/events_block_delete.d.ts +0 -6
  28. package/core/events/events_block_drag.d.ts +0 -6
  29. package/core/events/events_block_move.d.ts +21 -7
  30. package/core/events/events_bubble_open.d.ts +0 -6
  31. package/core/events/events_click.d.ts +0 -6
  32. package/core/events/events_comment_base.d.ts +0 -6
  33. package/core/events/events_comment_change.d.ts +0 -6
  34. package/core/events/events_comment_create.d.ts +0 -6
  35. package/core/events/events_comment_move.d.ts +0 -6
  36. package/core/events/events_marker_move.d.ts +0 -6
  37. package/core/events/events_selected.d.ts +0 -6
  38. package/core/events/events_theme_change.d.ts +0 -6
  39. package/core/events/events_toolbox_item_select.d.ts +0 -6
  40. package/core/events/events_trashcan_open.d.ts +0 -6
  41. package/core/events/events_var_base.d.ts +0 -6
  42. package/core/events/events_var_create.d.ts +0 -6
  43. package/core/events/events_var_delete.d.ts +0 -6
  44. package/core/events/events_var_rename.d.ts +0 -6
  45. package/core/events/events_viewport.d.ts +0 -6
  46. package/core/events/utils.d.ts +1 -1
  47. package/core/events/workspace_events.d.ts +1 -16
  48. package/core/field.d.ts +31 -5
  49. package/core/field_checkbox.d.ts +1 -1
  50. package/core/field_colour.d.ts +0 -2
  51. package/core/field_dropdown.d.ts +11 -13
  52. package/core/field_image.d.ts +5 -5
  53. package/core/field_input.d.ts +9 -2
  54. package/core/field_label.d.ts +3 -1
  55. package/core/field_number.d.ts +4 -4
  56. package/core/field_variable.d.ts +5 -5
  57. package/core/flyout_base.d.ts +23 -25
  58. package/core/flyout_button.d.ts +9 -9
  59. package/core/flyout_horizontal.d.ts +1 -1
  60. package/core/flyout_vertical.d.ts +1 -1
  61. package/core/generator.d.ts +15 -2
  62. package/core/gesture.d.ts +58 -41
  63. package/core/icons/comment_icon.d.ts +108 -0
  64. package/core/icons/exceptions.d.ts +14 -0
  65. package/core/icons/icon.d.ts +38 -0
  66. package/core/icons/icon_types.d.ts +22 -0
  67. package/core/icons/mutator_icon.d.ts +90 -0
  68. package/core/icons/registry.d.ts +23 -0
  69. package/core/icons/warning_icon.d.ts +67 -0
  70. package/core/icons.d.ts +12 -0
  71. package/core/inputs/dummy_input.d.ts +20 -0
  72. package/core/{input.d.ts → inputs/input.d.ts} +20 -13
  73. package/core/{input_types.d.ts → inputs/input_types.d.ts} +2 -1
  74. package/core/inputs/statement_input.d.ts +22 -0
  75. package/core/inputs/value_input.d.ts +20 -0
  76. package/core/interfaces/i_block_dragger.d.ts +1 -1
  77. package/core/interfaces/i_bounded_element.d.ts +2 -1
  78. package/core/interfaces/i_bubble.d.ts +2 -14
  79. package/core/interfaces/i_has_bubble.d.ts +14 -0
  80. package/core/interfaces/i_icon.d.ts +75 -0
  81. package/core/interfaces/i_serializable.d.ts +24 -0
  82. package/core/keyboard_nav/ast_node.d.ts +15 -15
  83. package/core/keyboard_nav/basic_cursor.d.ts +2 -2
  84. package/core/keyboard_nav/marker.d.ts +2 -2
  85. package/core/main.d.ts +0 -10
  86. package/core/marker_manager.d.ts +0 -1
  87. package/core/names.d.ts +4 -4
  88. package/core/options.d.ts +3 -3
  89. package/core/procedures.d.ts +1 -4
  90. package/core/registry.d.ts +5 -0
  91. package/core/render_management.d.ts +9 -1
  92. package/core/rendered_connection.d.ts +7 -7
  93. package/core/renderers/common/block_rendering.d.ts +0 -10
  94. package/core/renderers/common/constants.d.ts +5 -7
  95. package/core/renderers/common/drawer.d.ts +7 -2
  96. package/core/renderers/common/info.d.ts +1 -4
  97. package/core/renderers/common/marker_svg.d.ts +4 -4
  98. package/core/renderers/common/renderer.d.ts +0 -9
  99. package/core/renderers/geras/highlighter.d.ts +1 -1
  100. package/core/renderers/geras/info.d.ts +1 -1
  101. package/core/renderers/geras/measurables/inline_input.d.ts +1 -1
  102. package/core/renderers/geras/measurables/statement_input.d.ts +1 -1
  103. package/core/renderers/geras/renderer.d.ts +1 -1
  104. package/core/renderers/measurables/external_value_input.d.ts +1 -1
  105. package/core/renderers/measurables/field.d.ts +1 -1
  106. package/core/renderers/measurables/icon.d.ts +5 -1
  107. package/core/renderers/measurables/inline_input.d.ts +1 -1
  108. package/core/renderers/measurables/input_connection.d.ts +1 -1
  109. package/core/renderers/measurables/statement_input.d.ts +1 -1
  110. package/core/renderers/zelos/constants.d.ts +2 -2
  111. package/core/renderers/zelos/info.d.ts +2 -2
  112. package/core/renderers/zelos/marker_svg.d.ts +3 -3
  113. package/core/renderers/zelos/measurables/inputs.d.ts +1 -1
  114. package/core/renderers/zelos/path_object.d.ts +3 -3
  115. package/core/scrollbar.d.ts +0 -2
  116. package/core/scrollbar_pair.d.ts +0 -2
  117. package/core/serialization/blocks.d.ts +3 -3
  118. package/core/serialization/exceptions.d.ts +11 -0
  119. package/core/shortcut_registry.d.ts +2 -2
  120. package/core/theme_manager.d.ts +0 -1
  121. package/core/touch.d.ts +0 -43
  122. package/core/trashcan.d.ts +19 -21
  123. package/core/utils/dom.d.ts +2 -2
  124. package/core/utils/object.d.ts +0 -25
  125. package/core/utils/rect.d.ts +2 -0
  126. package/core/utils/style.d.ts +0 -12
  127. package/core/utils/svg_math.d.ts +0 -8
  128. package/core/utils/xml.d.ts +15 -22
  129. package/core/utils.d.ts +0 -138
  130. package/core/widgetdiv.d.ts +5 -0
  131. package/core/workspace.d.ts +9 -3
  132. package/core/workspace_comment.d.ts +3 -3
  133. package/core/workspace_comment_svg.d.ts +31 -44
  134. package/core/workspace_dragger.d.ts +1 -4
  135. package/core/workspace_svg.d.ts +13 -50
  136. package/core/xml.d.ts +0 -12
  137. package/core-browser.js +0 -1
  138. package/core.js +0 -1
  139. package/dart_compressed.js +124 -159
  140. package/dart_compressed.js.map +1 -1
  141. package/javascript_compressed.js +127 -169
  142. package/javascript_compressed.js.map +1 -1
  143. package/lua_compressed.js +119 -142
  144. package/lua_compressed.js.map +1 -1
  145. package/msg/constants.d.ts +1 -3
  146. package/msg/msg.d.ts +1 -2
  147. package/msg/qqq.d.ts +1 -3
  148. package/msg/synonyms.d.ts +1 -3
  149. package/package.json +12 -13
  150. package/php_compressed.js +131 -161
  151. package/php_compressed.js.map +1 -1
  152. package/python_compressed.js +118 -149
  153. package/python_compressed.js.map +1 -1
  154. package/core/comment.d.ts +0 -115
  155. package/core/events/events_ui.d.ts +0 -40
  156. package/core/icon.d.ts +0 -89
  157. package/core/mutator.d.ts +0 -142
  158. package/core/renderers/common/debug.d.ts +0 -29
  159. package/core/renderers/common/debugger.d.ts +0 -117
  160. package/core/warning.d.ts +0 -53
@@ -6,40 +6,27 @@
6
6
  define(["./blockly_compressed.js"], factory);
7
7
  } else if (typeof exports === 'object') { // Node.js
8
8
  module.exports = factory(require("./blockly_compressed.js"));
9
- } else { // Browser
10
- var factoryExports = factory(root.Blockly);
11
- root.Blockly.JavaScript = factoryExports.javascriptGenerator;
12
- root.Blockly.JavaScript.__namespace__ = factoryExports.__namespace__;
9
+ } else { // Script
10
+ root.javascript = factory(root.Blockly);
11
+ root.Blockly.Javascript = root.javascript.javascriptGenerator;
13
12
  }
14
13
  }(this, function(__parent__) {
15
14
  var $=__parent__.__namespace__;
16
- 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=
17
- $.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator=new $.CodeGenerator$$module$build$src$core$generator("JavaScript");
18
- 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;
19
- 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;
20
- 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;
21
- 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;
22
- 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;
23
- 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;
24
- 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;
25
- 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,
26
- 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],
27
- [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;
28
- 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));
29
- 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};
30
- 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")};
31
- 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=
32
- a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
33
- 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),
34
- g&&e>=g&&(a="("+a+")"));return a};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",`
35
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
15
+ var Order$$module$build$src$generators$javascript={ATOMIC:0,NEW:1.1,MEMBER:1.2,FUNCTION_CALL:2,INCREMENT:3,DECREMENT:3,BITWISE_NOT:4.1,UNARY_PLUS:4.2,UNARY_NEGATION:4.3,LOGICAL_NOT:4.4,TYPEOF:4.5,VOID:4.6,DELETE:4.7,AWAIT:4.8,EXPONENTIATION:5,MULTIPLICATION:5.1,DIVISION:5.2,MODULUS:5.3,SUBTRACTION:6.1,ADDITION:6.2,BITWISE_SHIFT:7,RELATIONAL:8,IN:8,INSTANCEOF:8,EQUALITY:9,BITWISE_AND:10,BITWISE_XOR:11,BITWISE_OR:12,LOGICAL_AND:13,LOGICAL_OR:14,CONDITIONAL:15,ASSIGNMENT:16,YIELD:17,COMMA:18,NONE:99},
16
+ JavascriptGenerator$$module$build$src$generators$javascript=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a){super(null!=a?a:"JavaScript");this.ORDER_OVERRIDES=[[Order$$module$build$src$generators$javascript.FUNCTION_CALL,Order$$module$build$src$generators$javascript.MEMBER],[Order$$module$build$src$generators$javascript.FUNCTION_CALL,Order$$module$build$src$generators$javascript.FUNCTION_CALL],[Order$$module$build$src$generators$javascript.MEMBER,Order$$module$build$src$generators$javascript.MEMBER],
17
+ [Order$$module$build$src$generators$javascript.MEMBER,Order$$module$build$src$generators$javascript.FUNCTION_CALL],[Order$$module$build$src$generators$javascript.LOGICAL_NOT,Order$$module$build$src$generators$javascript.LOGICAL_NOT],[Order$$module$build$src$generators$javascript.MULTIPLICATION,Order$$module$build$src$generators$javascript.MULTIPLICATION],[Order$$module$build$src$generators$javascript.ADDITION,Order$$module$build$src$generators$javascript.ADDITION],[Order$$module$build$src$generators$javascript.LOGICAL_AND,
18
+ Order$$module$build$src$generators$javascript.LOGICAL_AND],[Order$$module$build$src$generators$javascript.LOGICAL_OR,Order$$module$build$src$generators$javascript.LOGICAL_OR]];this.isInitialized=!1;for(const b in Order$$module$build$src$generators$javascript)this["ORDER_"+b]=Order$$module$build$src$generators$javascript[b];this.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,"+
19
+ Object.getOwnPropertyNames(globalThis).join(","))}init(a){super.init(a);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.Names$$module$build$src$core$names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.allDeveloperVariables$$module$build$src$core$variables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));a=$.allUsedVarModels$$module$build$src$core$variables(a);
20
+ 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}finish(a){const b=Object.values(this.definitions_);super.finish(a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a}scrubNakedValue(a){return a+";\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")}scrub_(a,
21
+ b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.wrap$$module$build$src$core$utils$string(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","// "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);
22
+ return d+b+c}getAdjusted(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;$.isNumber$$module$build$src$core$utils$string(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),g&&e>=g&&(a="("+a+")"));return a}},javascriptGenerator$$module$build$src$generators$javascript=
23
+ new JavascriptGenerator$$module$build$src$generators$javascript,module$build$src$generators$javascript={};module$build$src$generators$javascript.JavascriptGenerator=JavascriptGenerator$$module$build$src$generators$javascript;module$build$src$generators$javascript.Order=Order$$module$build$src$generators$javascript;module$build$src$generators$javascript.javascriptGenerator=javascriptGenerator$$module$build$src$generators$javascript;javascriptGenerator$$module$build$src$generators$javascript.forBlock.colour_picker=function(a,b){return[b.quote_(a.getFieldValue("COLOUR")),Order$$module$build$src$generators$javascript.ATOMIC]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.colour_random=function(a,b){return[b.provideFunction_("colourRandom",`
24
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}() {
36
25
  var num = Math.floor(Math.random() * Math.pow(2, 24));
37
26
  return '#' + ('00000' + num.toString(16)).substr(-6);
38
27
  }
39
- `)+"()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
40
- 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)||
41
- 0;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourRgb",`
42
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
28
+ `)+"()",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.colour_rgb=function(a,b){const c=b.valueToCode(a,"RED",Order$$module$build$src$generators$javascript.NONE)||0,d=b.valueToCode(a,"GREEN",Order$$module$build$src$generators$javascript.NONE)||0;a=b.valueToCode(a,"BLUE",Order$$module$build$src$generators$javascript.NONE)||0;return[b.provideFunction_("colourRgb",`
29
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
43
30
  r = Math.max(Math.min(Number(r), 100), 0) * 2.55;
44
31
  g = Math.max(Math.min(Number(g), 100), 0) * 2.55;
45
32
  b = Math.max(Math.min(Number(b), 100), 0) * 2.55;
@@ -48,10 +35,8 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
48
35
  b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
49
36
  return '#' + r + g + b;
50
37
  }
51
- `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
52
- 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)||
53
- .5;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourBlend",`
54
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
38
+ `)+"("+c+", "+d+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.colour_blend=function(a,b){const c=b.valueToCode(a,"COLOUR1",Order$$module$build$src$generators$javascript.NONE)||"'#000000'",d=b.valueToCode(a,"COLOUR2",Order$$module$build$src$generators$javascript.NONE)||"'#000000'";a=b.valueToCode(a,"RATIO",Order$$module$build$src$generators$javascript.NONE)||.5;return[b.provideFunction_("colourBlend",`
39
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
55
40
  ratio = Math.max(Math.min(Number(ratio), 1), 0);
56
41
  var r1 = parseInt(c1.substring(1, 3), 16);
57
42
  var g1 = parseInt(c1.substring(3, 5), 16);
@@ -67,26 +52,22 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
67
52
  b = ('0' + (b || 0).toString(16)).slice(-2);
68
53
  return '#' + r + g + b;
69
54
  }
70
- `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};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]};
71
- 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]};
72
- module$exports$Blockly$JavaScript.javascriptGenerator.lists_repeat=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsRepeat",`
73
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
55
+ `)+"("+c+", "+d+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};var module$build$src$generators$javascript$colour={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_create_empty=function(a,b){return["[]",Order$$module$build$src$generators$javascript.ATOMIC]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_create_with=function(a,b){const c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$javascript.NONE)||"null";return["["+c.join(", ")+"]",Order$$module$build$src$generators$javascript.ATOMIC]};
56
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_repeat=function(a,b){const c=b.provideFunction_("listsRepeat",`
57
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
74
58
  var array = [];
75
59
  for (var i = 0; i < n; i++) {
76
60
  array[i] = value;
77
61
  }
78
62
  return array;
79
63
  }
80
- `),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]};
81
- 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]};
82
- 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]};
83
- 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?
84
- [b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
85
- 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];
86
- 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,
87
- "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"===
88
- 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",`
89
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
64
+ `),d=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$javascript.NONE)||"null";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$javascript.NONE)||"0";return[c+"("+d+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_length=function(a,b){return[(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"[]")+".length",Order$$module$build$src$generators$javascript.MEMBER]};
65
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_isEmpty=function(a,b){return["!"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"[]")+".length",Order$$module$build$src$generators$javascript.LOGICAL_NOT]};
66
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_indexOf=function(a,b){const c="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",d=b.valueToCode(a,"FIND",Order$$module$build$src$generators$javascript.NONE)||"''";b=(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"[]")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$javascript.ADDITION]:[b,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
67
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_getIndex=function(a,b){const c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START";var e=b.valueToCode(a,"VALUE","RANDOM"===d?Order$$module$build$src$generators$javascript.NONE:Order$$module$build$src$generators$javascript.MEMBER)||"[]";switch(d){case "FIRST":if("GET"===c)return[e+"[0]",Order$$module$build$src$generators$javascript.MEMBER];if("GET_REMOVE"===c)return[e+".shift()",Order$$module$build$src$generators$javascript.MEMBER];
68
+ if("REMOVE"===c)return e+".shift();\n";break;case "LAST":if("GET"===c)return[e+".slice(-1)[0]",Order$$module$build$src$generators$javascript.MEMBER];if("GET_REMOVE"===c)return[e+".pop()",Order$$module$build$src$generators$javascript.MEMBER];if("REMOVE"===c)return e+".pop();\n";break;case "FROM_START":a=b.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",Order$$module$build$src$generators$javascript.MEMBER];if("GET_REMOVE"===c)return[e+".splice("+a+", 1)[0]",Order$$module$build$src$generators$javascript.FUNCTION_CALL];
69
+ if("REMOVE"===c)return e+".splice("+a+", 1);\n";break;case "FROM_END":a=b.getAdjusted(a,"AT",1,!0);if("GET"===c)return[e+".slice("+a+")[0]",Order$$module$build$src$generators$javascript.FUNCTION_CALL];if("GET_REMOVE"===c)return[e+".splice("+a+", 1)[0]",Order$$module$build$src$generators$javascript.FUNCTION_CALL];if("REMOVE"===c)return e+".splice("+a+", 1);";break;case "RANDOM":e=b.provideFunction_("listsGetRandomItem",`
70
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
90
71
  var x = Math.floor(Math.random() * list.length);
91
72
  if (remove) {
92
73
  return list.splice(x, 1)[0];
@@ -94,22 +75,21 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
94
75
  return list[x];
95
76
  }
96
77
  }
97
- `)+"("+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).");};
98
- 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";
99
- 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,
100
- "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",
101
- $.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};
102
- 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");
103
- 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);
104
- 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],`
105
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===c||"FROM_START"===c?", at1":""}${"FROM_END"===d||"FROM_START"===d?", at2":""}) {
106
- var start = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",c,"at1")};
107
- var end = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",d,"at2")} + 1;
78
+ `)+"("+e+", "+("GET"!==c)+")";if("GET"===c||"GET_REMOVE"===c)return[e,Order$$module$build$src$generators$javascript.FUNCTION_CALL];if("REMOVE"===c)return e+";\n"}throw Error("Unhandled combination (lists_getIndex).");};
79
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_setIndex=function(a,b){function c(){if(d.match(/^\w+$/))return"";const h=b.nameDB_.getDistinctName("tmpList",$.NameType$$module$build$src$core$names.VARIABLE),k="var "+h+" = "+d+";\n";d=h;return k}let d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.MEMBER)||"[]";const e=a.getFieldValue("MODE")||"GET";var f=a.getFieldValue("WHERE")||"FROM_START";const g=b.valueToCode(a,"TO",Order$$module$build$src$generators$javascript.ASSIGNMENT)||
80
+ "null";switch(f){case "FIRST":if("SET"===e)return d+"[0] = "+g+";\n";if("INSERT"===e)return d+".unshift("+g+");\n";break;case "LAST":if("SET"===e)return c()+(d+"["+d+".length - 1] = "+g+";\n");if("INSERT"===e)return d+".push("+g+");\n";break;case "FROM_START":a=b.getAdjusted(a,"AT");if("SET"===e)return d+"["+a+"] = "+g+";\n";if("INSERT"===e)return d+".splice("+a+", 0, "+g+");\n";break;case "FROM_END":a=b.getAdjusted(a,"AT",1,!1,Order$$module$build$src$generators$javascript.SUBTRACTION);f=c();if("SET"===
81
+ e)return f+(d+"["+d+".length - "+a+"] = "+g+";\n");if("INSERT"===e)return f+(d+".splice("+d+".length - "+a+", 0, "+g+");\n");break;case "RANDOM":a=c();f=b.nameDB_.getDistinctName("tmpX",$.NameType$$module$build$src$core$names.VARIABLE);a+="var "+f+" = Math.floor(Math.random() * "+d+".length);\n";if("SET"===e)return a+(d+"["+f+"] = "+g+";\n");if("INSERT"===e)return a+(d+".splice("+f+", 0, "+g+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
82
+ var getSubstringIndex$$module$build$src$generators$javascript$lists=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":c};
83
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_getSublist=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.MEMBER)||"[]",d=a.getFieldValue("WHERE1");const e=a.getFieldValue("WHERE2");if("FIRST"===d&&"LAST"===e)c+=".slice(0)";else if(c.match(/^\w+$/)||"FROM_END"!==d&&"FROM_START"===e){switch(d){case "FROM_START":d=b.getAdjusted(a,"AT1");break;case "FROM_END":d=b.getAdjusted(a,"AT1",1,!1,Order$$module$build$src$generators$javascript.SUBTRACTION);
84
+ d=c+".length - "+d;break;case "FIRST":d="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(e){case "FROM_START":b=b.getAdjusted(a,"AT2",1);break;case "FROM_END":b=b.getAdjusted(a,"AT2",0,!1,Order$$module$build$src$generators$javascript.SUBTRACTION);b=c+".length - "+b;break;case "LAST":b=c+".length";break;default:throw Error("Unhandled option (lists_getSublist).");}c=c+".slice("+d+", "+b+")"}else{const f=b.getAdjusted(a,"AT1");a=b.getAdjusted(a,"AT2");const g={FIRST:"First",
85
+ LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};c=b.provideFunction_("subsequence"+g[d]+g[e],`
86
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===d||"FROM_START"===d?", at1":""}${"FROM_END"===e||"FROM_START"===e?", at2":""}) {
87
+ var start = ${getSubstringIndex$$module$build$src$generators$javascript$lists("sequence",d,"at1")};
88
+ var end = ${getSubstringIndex$$module$build$src$generators$javascript$lists("sequence",e,"at2")} + 1;
108
89
  return sequence.slice(start, end);
109
90
  }
110
- `)+"("+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]};
111
- 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",`
112
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
91
+ `)+"("+c+("FROM_END"===d||"FROM_START"===d?", "+f:"")+("FROM_END"===e||"FROM_START"===e?", "+a:"")+")"}return[c,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_sort=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.FUNCTION_CALL)||"[]",d="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");b=b.provideFunction_("listsGetSortCompare",`
92
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
113
93
  var compareFuncs = {
114
94
  'NUMERIC': function(a, b) {
115
95
  return Number(a) - Number(b); },
@@ -121,45 +101,37 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
121
101
  var compare = compareFuncs[type];
122
102
  return function(a, b) { return compare(a, b) * direction; };
123
103
  }
124
- `);return[b+".slice().sort("+d+'("'+a+'", '+c+"))",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
125
- 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: "+
126
- 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$logic={};
127
- 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,
128
- "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=
129
- 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"};
130
- module$exports$Blockly$JavaScript.javascriptGenerator.controls_ifelse=module$exports$Blockly$JavaScript.javascriptGenerator.controls_if;
131
- 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+
132
- " "+a,c]};
133
- 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=
134
- 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]};
135
- module$exports$Blockly$JavaScript.javascriptGenerator.logic_null=function(a){return["null",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
136
- 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)||
137
- "null";return[b+" ? "+c+" : "+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL]};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;
138
- 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",
139
- $.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;
140
- 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,
141
- a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
142
- 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)||
143
- "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=
144
- "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+
145
- "_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+" <= "+
146
- c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a};
147
- 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,
148
- 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")};
149
- 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,
150
- 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$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]};
151
- 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")];
152
- 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]};
153
- 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",
154
- 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;
155
- 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";
156
- break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION]};
157
- 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],
158
- INFINITY:["Infinity",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
159
- 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],
160
- 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,
161
- 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",`
162
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) {
104
+ `);return[c+".slice().sort("+b+'("'+a+'", '+d+"))",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
105
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_split=function(a,b){let c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$javascript.MEMBER);b=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$javascript.NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)c||(c="''"),a="split";else if("JOIN"===a)c||(c="[]"),a="join";else throw Error("Unknown mode: "+a);return[c+"."+a+"("+b+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
106
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.lists_reverse=function(a,b){return[(b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.FUNCTION_CALL)||"[]")+".slice().reverse()",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};var module$build$src$generators$javascript$lists={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_if=function(a,b){var c=0;let d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{const e=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$javascript.NONE)||"false";let f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(0<c?" else ":"")+"if ("+e+") {\n"+f+"}";c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)c=b.statementToCode(a,
107
+ "ELSE"),b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+=" else {\n"+c+"}";return d+"\n"};javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_ifelse=javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_if;
108
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_compare=function(a,b){const c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d="=="===c||"!="===c?Order$$module$build$src$generators$javascript.EQUALITY:Order$$module$build$src$generators$javascript.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]};
109
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_operation=function(a,b){const c="AND"===a.getFieldValue("OP")?"&&":"||",d="&&"===c?Order$$module$build$src$generators$javascript.LOGICAL_AND:Order$$module$build$src$generators$javascript.LOGICAL_OR;let e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b="&&"===c?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]};
110
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_negate=function(a,b){const c=Order$$module$build$src$generators$javascript.LOGICAL_NOT;return["!"+(b.valueToCode(a,"BOOL",c)||"true"),c]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_boolean=function(a,b){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",Order$$module$build$src$generators$javascript.ATOMIC]};
111
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_null=function(a,b){return["null",Order$$module$build$src$generators$javascript.ATOMIC]};
112
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.logic_ternary=function(a,b){const c=b.valueToCode(a,"IF",Order$$module$build$src$generators$javascript.CONDITIONAL)||"false",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$javascript.CONDITIONAL)||"null";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$javascript.CONDITIONAL)||"null";return[c+" ? "+d+" : "+a,Order$$module$build$src$generators$javascript.CONDITIONAL]};
113
+ var module$build$src$generators$javascript$logic={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_repeat_ext=function(a,b){let c;c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"0";let d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a);a="";const e=b.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE);let f=c;c.match(/^\w+$/)||$.isNumber$$module$build$src$core$utils$string(c)||(f=b.nameDB_.getDistinctName("repeat_end",
114
+ $.NameType$$module$build$src$core$names.VARIABLE),a+="var "+f+" = "+c+";\n");return a+("for (var "+e+" = 0; "+e+" < "+f+"; "+e+"++) {\n"+d+"}\n")};javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_repeat=javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_repeat_ext;
115
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_whileUntil=function(a,b){const c="UNTIL"===a.getFieldValue("MODE");let d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$javascript.LOGICAL_NOT:Order$$module$build$src$generators$javascript.NONE)||"false",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);c&&(d="!"+d);return"while ("+d+") {\n"+e+"}\n"};
116
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_for=function(a,b){var c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"0",e=b.valueToCode(a,"TO",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"0";const f=b.valueToCode(a,"BY",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"1";let g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,
117
+ a);if($.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f))b=Number(d)<=Number(e),a="for ("+c+" = "+d+"; "+c+(b?" <= ":" >= ")+e+"; "+c,c=Math.abs(Number(f)),a=1===c?a+(b?"++":"--"):a+((b?" += ":" -= ")+c),a+=") {\n"+g+"}\n";else{a="";let h=d;d.match(/^\w+$/)||$.isNumber$$module$build$src$core$utils$string(d)||(h=b.nameDB_.getDistinctName(c+"_start",$.NameType$$module$build$src$core$names.VARIABLE),
118
+ a+="var "+h+" = "+d+";\n");d=e;e.match(/^\w+$/)||$.isNumber$$module$build$src$core$utils$string(e)||(d=b.nameDB_.getDistinctName(c+"_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+d+" = "+e+";\n");e=b.nameDB_.getDistinctName(c+"_inc",$.NameType$$module$build$src$core$names.VARIABLE);a+="var "+e+" = ";a=$.isNumber$$module$build$src$core$utils$string(f)?a+(Math.abs(f)+";\n"):a+("Math.abs("+f+");\n");a+="if ("+h+" > "+d+") {\n";a+=b.INDENT+e+" = -"+e+";\n";a=a+"}\nfor ("+(c+" = "+h+
119
+ "; "+e+" >= 0 ? "+c+" <= "+d+" : "+c+" >= "+d+"; "+c+" += "+e+") {\n"+g+"}\n")}return a};
120
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_forEach=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"[]";let e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);a="";let f=d;d.match(/^\w+$/)||(f=b.nameDB_.getDistinctName(c+"_list",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+f+" = "+d+";\n");d=b.nameDB_.getDistinctName(c+
121
+ "_index",$.NameType$$module$build$src$core$names.VARIABLE);e=b.INDENT+c+" = "+f+"["+d+"];\n"+e;return a+("for (var "+d+" in "+f+") {\n"+e+"}\n")};
122
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.controls_flow_statements=function(a,b){let c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){const d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break;\n";case "CONTINUE":return c+"continue;\n"}throw Error("Unknown flow statement.");};
123
+ var module$build$src$generators$javascript$loops={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_number=function(a,b){a=Number(a.getFieldValue("NUM"));return[a,0<=a?Order$$module$build$src$generators$javascript.ATOMIC:Order$$module$build$src$generators$javascript.UNARY_NEGATION]};
124
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_arithmetic=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$javascript.ADDITION],MINUS:[" - ",Order$$module$build$src$generators$javascript.SUBTRACTION],MULTIPLY:[" * ",Order$$module$build$src$generators$javascript.MULTIPLICATION],DIVIDE:[" / ",Order$$module$build$src$generators$javascript.DIVISION],POWER:[null,Order$$module$build$src$generators$javascript.NONE]}[a.getFieldValue("OP")];const d=c[0];c=c[1];
125
+ const e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return d?[e+d+a,c]:["Math.pow("+e+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
126
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_single=function(a,b){const c=a.getFieldValue("OP");let d;if("NEG"===c)return a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$javascript.UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,Order$$module$build$src$generators$javascript.UNARY_NEGATION];a="SIN"===c||"COS"===c||"TAN"===c?b.valueToCode(a,"NUM",Order$$module$build$src$generators$javascript.DIVISION)||"0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$javascript.NONE)||
127
+ "0";switch(c){case "ABS":d="Math.abs("+a+")";break;case "ROOT":d="Math.sqrt("+a+")";break;case "LN":d="Math.log("+a+")";break;case "EXP":d="Math.exp("+a+")";break;case "POW10":d="Math.pow(10,"+a+")";break;case "ROUND":d="Math.round("+a+")";break;case "ROUNDUP":d="Math.ceil("+a+")";break;case "ROUNDDOWN":d="Math.floor("+a+")";break;case "SIN":d="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":d="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":d="Math.tan("+a+" / 180 * Math.PI)"}if(d)return[d,Order$$module$build$src$generators$javascript.FUNCTION_CALL];
128
+ switch(c){case "LOG10":d="Math.log("+a+") / Math.log(10)";break;case "ASIN":d="Math.asin("+a+") / Math.PI * 180";break;case "ACOS":d="Math.acos("+a+") / Math.PI * 180";break;case "ATAN":d="Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,Order$$module$build$src$generators$javascript.DIVISION]};
129
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_constant=function(a,b){return{PI:["Math.PI",Order$$module$build$src$generators$javascript.MEMBER],E:["Math.E",Order$$module$build$src$generators$javascript.MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",Order$$module$build$src$generators$javascript.DIVISION],SQRT2:["Math.SQRT2",Order$$module$build$src$generators$javascript.MEMBER],SQRT1_2:["Math.SQRT1_2",Order$$module$build$src$generators$javascript.MEMBER],INFINITY:["Infinity",
130
+ Order$$module$build$src$generators$javascript.ATOMIC]}[a.getFieldValue("CONSTANT")]};
131
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_number_property=function(a,b){var c={EVEN:[" % 2 === 0",Order$$module$build$src$generators$javascript.MODULUS,Order$$module$build$src$generators$javascript.EQUALITY],ODD:[" % 2 === 1",Order$$module$build$src$generators$javascript.MODULUS,Order$$module$build$src$generators$javascript.EQUALITY],WHOLE:[" % 1 === 0",Order$$module$build$src$generators$javascript.MODULUS,Order$$module$build$src$generators$javascript.EQUALITY],POSITIVE:[" > 0",
132
+ Order$$module$build$src$generators$javascript.RELATIONAL,Order$$module$build$src$generators$javascript.RELATIONAL],NEGATIVE:[" < 0",Order$$module$build$src$generators$javascript.RELATIONAL,Order$$module$build$src$generators$javascript.RELATIONAL],DIVISIBLE_BY:[null,Order$$module$build$src$generators$javascript.MODULUS,Order$$module$build$src$generators$javascript.EQUALITY],PRIME:[null,Order$$module$build$src$generators$javascript.NONE,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
133
+ const d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";"PRIME"===d?a=b.provideFunction_("mathIsPrime",`
134
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(n) {
163
135
  // https://en.wikipedia.org/wiki/Primality_test#Naive_methods
164
136
  if (n == 2 || n == 3) {
165
137
  return true;
@@ -177,16 +149,16 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
177
149
  }
178
150
  return true;
179
151
  }
180
- `)+"("+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]};
181
- 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"};
182
- 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;
183
- 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, "+
184
- 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",`
185
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
152
+ `)+"("+c+")":"DIVISIBLE_BY"===d?(a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$javascript.MODULUS)||"0",a=c+" % "+a+" === 0"):a=c+e;return[a,g]};
153
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_change=function(a,b){const c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$javascript.ADDITION)||"0";a=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+c+";\n"};javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_round=javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_single;
154
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_trig=javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_single;
155
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_on_list=function(a,b){var c=a.getFieldValue("OP");switch(c){case "SUM":a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.MEMBER)||"[]";a+=".reduce(function(x, y) {return x + y;}, 0)";break;case "MIN":a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a="Math.min.apply(null, "+a+")";break;case "MAX":a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||
156
+ "[]";a="Math.max.apply(null, "+a+")";break;case "AVERAGE":c=b.provideFunction_("mathMean",`
157
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(myList) {
186
158
  return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
187
159
  }
188
- `);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",`
189
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
160
+ `);a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a=c+"("+a+")";break;case "MEDIAN":c=b.provideFunction_("mathMedian",`
161
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(myList) {
190
162
  var localList = myList.filter(function (x) {return typeof x === 'number';});
191
163
  if (!localList.length) return null;
192
164
  localList.sort(function(a, b) {return b - a;});
@@ -196,8 +168,8 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
196
168
  return localList[(localList.length - 1) / 2];
197
169
  }
198
170
  }
199
- `);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",`
200
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) {
171
+ `);a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a=c+"("+a+")";break;case "MODE":c=b.provideFunction_("mathModes",`
172
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(values) {
201
173
  var modes = [];
202
174
  var counts = [];
203
175
  var maxCount = 0;
@@ -225,8 +197,8 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
225
197
  }
226
198
  return modes;
227
199
  }
228
- `);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",`
229
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
200
+ `);a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a=c+"("+a+")";break;case "STD_DEV":c=b.provideFunction_("mathStandardDeviation",`
201
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
230
202
  var n = numbers.length;
231
203
  if (!n) return null;
232
204
  var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
@@ -237,17 +209,16 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
237
209
  variance = variance / n;
238
210
  return Math.sqrt(variance);
239
211
  }
240
- `);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",`
241
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list) {
212
+ `);a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a=c+"("+a+")";break;case "RANDOM":c=b.provideFunction_("mathRandomList",`
213
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(list) {
242
214
  var x = Math.floor(Math.random() * list.length);
243
215
  return list[x];
244
216
  }
245
- `);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]};
246
- 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]};
247
- 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)||
248
- "Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
249
- 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",`
250
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
217
+ `);a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$javascript.NONE)||"[]";a=c+"("+a+")";break;default:throw Error("Unknown operator: "+c);}return[a,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
218
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_modulo=function(a,b){const c=b.valueToCode(a,"DIVIDEND",Order$$module$build$src$generators$javascript.MODULUS)||"0";a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$javascript.MODULUS)||"0";return[c+" % "+a,Order$$module$build$src$generators$javascript.MODULUS]};
219
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_constrain=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.NONE)||"0",d=b.valueToCode(a,"LOW",Order$$module$build$src$generators$javascript.NONE)||"0";a=b.valueToCode(a,"HIGH",Order$$module$build$src$generators$javascript.NONE)||"Infinity";return["Math.min(Math.max("+c+", "+d+"), "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
220
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_random_int=function(a,b){const c=b.valueToCode(a,"FROM",Order$$module$build$src$generators$javascript.NONE)||"0";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$javascript.NONE)||"0";return[b.provideFunction_("mathRandomInt",`
221
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
251
222
  if (a > b) {
252
223
  // Swap a and b to ensure a is smaller.
253
224
  var c = a;
@@ -256,74 +227,61 @@ function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_P
256
227
  }
257
228
  return Math.floor(Math.random() * (b - a + 1) + a);
258
229
  }
259
- `)+"("+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]};
260
- 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$procedures={},module$contents$Blockly$JavaScript$procedures_NameType=$.NameType$$module$build$src$core$names;
261
- 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&&
262
- (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,
263
- 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],
264
- $.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;
265
- 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]};
266
- module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callreturn(a)[0]+";\n"};
267
- 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,
268
- 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$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]},
269
- 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]};
270
- 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]};
271
- 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)||
272
- "''";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)||
273
- "''";return["["+b.join(",")+"].join('')",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}};
274
- 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"};
275
- 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]};
276
- 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]};
277
- 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?
278
- [b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
279
- 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)",
280
- 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",
281
- `
282
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(text) {
230
+ `)+"("+c+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_random_float=function(a,b){return["Math.random()",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
231
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.math_atan2=function(a,b){const c=b.valueToCode(a,"X",Order$$module$build$src$generators$javascript.NONE)||"0";return["Math.atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$javascript.NONE)||"0")+", "+c+") / Math.PI * 180",Order$$module$build$src$generators$javascript.DIVISION]};var module$build$src$generators$javascript$math={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_defreturn=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(d+=b.injectId(b.STATEMENT_SUFFIX,a));d&&(d=b.prefixLines(d,b.INDENT));let e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));const f=b.statementToCode(a,"STACK");let g=b.valueToCode(a,
232
+ "RETURN",Order$$module$build$src$generators$javascript.NONE)||"",h="";f&&g&&(h=d);g&&(g=b.INDENT+"return "+g+";\n");const k=[],l=a.getVars();for(let n=0;n<l.length;n++)k[n]=b.nameDB_.getName(l[n],$.NameType$$module$build$src$core$names.VARIABLE);d="function "+c+"("+k.join(", ")+") {\n"+d+e+f+h+g+"}";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null};javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_defnoreturn=javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_defreturn;
233
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_callreturn=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),d=[],e=a.getVars();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$javascript.NONE)||"null";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
234
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_callnoreturn=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+";\n"};
235
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.procedures_ifreturn=function(a,b){let c="if ("+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$javascript.NONE)||"false")+") {\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.NONE)||"null",c+=b.INDENT+"return "+a+";\n"):c+=b.INDENT+"return;\n";return c+"}\n"};
236
+ var module$build$src$generators$javascript$procedures={};var strRegExp$$module$build$src$generators$javascript$text=/^\s*'([^']|\\')*'\s*$/,forceString$$module$build$src$generators$javascript$text=function(a){return strRegExp$$module$build$src$generators$javascript$text.test(a)?[a,Order$$module$build$src$generators$javascript.ATOMIC]:["String("+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]},getSubstringIndex$$module$build$src$generators$javascript$text=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===
237
+ b?a+".length - 1":c};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text=function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Order$$module$build$src$generators$javascript.ATOMIC]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_multiline=function(a,b){a=b.multiline_quote_(a.getFieldValue("TEXT"));b=-1!==a.indexOf("+")?Order$$module$build$src$generators$javascript.ADDITION:Order$$module$build$src$generators$javascript.ATOMIC;return[a,b]};
238
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_join=function(a,b){switch(a.itemCount_){case 0:return["''",Order$$module$build$src$generators$javascript.ATOMIC];case 1:return a=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$javascript.NONE)||"''",forceString$$module$build$src$generators$javascript$text(a);case 2:var c=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$javascript.NONE)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$javascript.NONE)||
239
+ "''";return[forceString$$module$build$src$generators$javascript$text(c)[0]+" + "+forceString$$module$build$src$generators$javascript$text(a)[0],Order$$module$build$src$generators$javascript.ADDITION];default:c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$javascript.NONE)||"''";return["["+c.join(",")+"].join('')",Order$$module$build$src$generators$javascript.FUNCTION_CALL]}};
240
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_append=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.NONE)||"''";return c+" += "+forceString$$module$build$src$generators$javascript$text(a)[0]+";\n"};
241
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_length=function(a,b){return[(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"''")+".length",Order$$module$build$src$generators$javascript.MEMBER]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_isEmpty=function(a,b){return["!"+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"''")+".length",Order$$module$build$src$generators$javascript.LOGICAL_NOT]};
242
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_indexOf=function(a,b){const c="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",d=b.valueToCode(a,"FIND",Order$$module$build$src$generators$javascript.NONE)||"''";b=(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.MEMBER)||"''")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$javascript.ADDITION]:[b,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
243
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_charAt=function(a,b){const c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE","RANDOM"===c?Order$$module$build$src$generators$javascript.NONE:Order$$module$build$src$generators$javascript.MEMBER)||"''";switch(c){case "FIRST":return[d+".charAt(0)",Order$$module$build$src$generators$javascript.FUNCTION_CALL];case "LAST":return[d+".slice(-1)",Order$$module$build$src$generators$javascript.FUNCTION_CALL];case "FROM_START":return a=
244
+ b.getAdjusted(a,"AT"),[d+".charAt("+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL];case "FROM_END":return a=b.getAdjusted(a,"AT",1,!0),[d+".slice("+a+").charAt(0)",Order$$module$build$src$generators$javascript.FUNCTION_CALL];case "RANDOM":return[b.provideFunction_("textRandomLetter",`
245
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(text) {
283
246
  var x = Math.floor(Math.random() * text.length);
284
247
  return text[x];
285
248
  }
286
- `)+"("+c+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
287
- 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];
288
- 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,
289
- "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",
290
- LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};e=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("subsequence"+f[b]+f[c],`
291
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===b||"FROM_START"===b?", at1":""}${"FROM_END"===c||"FROM_START"===c?", at2":""}) {
292
- var start = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",b,"at1")};
293
- var end = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",c,"at2")} + 1;
249
+ `)+"("+d+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
250
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_getSubstring=function(a,b){var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2");var e="FROM_END"!==c&&"LAST"!==c&&"FROM_END"!==d&&"LAST"!==d,f=b.valueToCode(a,"STRING",e?Order$$module$build$src$generators$javascript.MEMBER:Order$$module$build$src$generators$javascript.NONE)||"''";if("FIRST"===c&&"LAST"===d)return[f,Order$$module$build$src$generators$javascript.NONE];if(f.match(/^'?\w+'?$/)||e){switch(c){case "FROM_START":c=
251
+ b.getAdjusted(a,"AT1");break;case "FROM_END":c=b.getAdjusted(a,"AT1",1,!1,Order$$module$build$src$generators$javascript.SUBTRACTION);c=f+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(d){case "FROM_START":b=b.getAdjusted(a,"AT2",1);break;case "FROM_END":b=b.getAdjusted(a,"AT2",0,!1,Order$$module$build$src$generators$javascript.SUBTRACTION);b=f+".length - "+b;break;case "LAST":b=f+".length";break;default:throw Error("Unhandled option (text_getSubstring).");
252
+ }f=f+".slice("+c+", "+b+")"}else{e=b.getAdjusted(a,"AT1");a=b.getAdjusted(a,"AT2");const g={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};f=b.provideFunction_("subsequence"+g[c]+g[d],`
253
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===c||"FROM_START"===c?", at1":""}${"FROM_END"===d||"FROM_START"===d?", at2":""}) {
254
+ var start = ${getSubstringIndex$$module$build$src$generators$javascript$text("sequence",c,"at1")};
255
+ var end = ${getSubstringIndex$$module$build$src$generators$javascript$text("sequence",d,"at2")} + 1;
294
256
  return sequence.slice(start, end);
295
257
  }
296
- `)+"("+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]};
297
- 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",
298
- `
299
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(str) {
258
+ `)+"("+f+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")"}return[f,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
259
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_changeCase=function(a,b){const c={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=b.valueToCode(a,"TEXT",c?Order$$module$build$src$generators$javascript.MEMBER:Order$$module$build$src$generators$javascript.NONE)||"''";return[c?a+c:b.provideFunction_("textToTitleCase",`
260
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(str) {
300
261
  return str.replace(/\\S+/g,
301
262
  function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
302
263
  }
303
- `)+"("+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]};
304
- 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"};
305
- 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]};
306
- module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt=module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt_ext;
307
- 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",`
308
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
264
+ `)+"("+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_trim=function(a,b){const c={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.MEMBER)||"''")+c,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};
265
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_print=function(a,b){return"window.alert("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.NONE)||"''")+");\n"};
266
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_prompt_ext=function(a,b){b="window.prompt("+(a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="Number("+b+")");return[b,Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_prompt=javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_prompt_ext;
267
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_count=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.NONE)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$javascript.NONE)||"''";return[b.provideFunction_("textCount",`
268
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
309
269
  if (needle.length === 0) {
310
270
  return haystack.length + 1;
311
271
  } else {
312
272
  return haystack.split(needle).length - 1;
313
273
  }
314
274
  }
315
- `)+"("+b+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
316
- 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)||
317
- "''";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textReplace",`
318
- function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
275
+ `)+"("+c+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_replace=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.NONE)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$javascript.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$javascript.NONE)||"''";return[b.provideFunction_("textReplace",`
276
+ function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
319
277
  needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
320
278
  .replace(/\\x08/g, '\\\\x08');
321
279
  return haystack.replace(new RegExp(needle, 'g'), replacement);
322
280
  }
323
- `)+"("+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$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]};
324
- 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$all=module$exports$Blockly$JavaScript;
325
- module$exports$Blockly$JavaScript.__namespace__=$;
326
- return module$exports$Blockly$JavaScript;
281
+ `)+"("+c+", "+d+", "+a+")",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};javascriptGenerator$$module$build$src$generators$javascript.forBlock.text_reverse=function(a,b){return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$javascript.MEMBER)||"''")+".split('').reverse().join('')",Order$$module$build$src$generators$javascript.FUNCTION_CALL]};var module$build$src$generators$javascript$text={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_get=function(a,b){return[b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),Order$$module$build$src$generators$javascript.ATOMIC]};
282
+ javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_set=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$javascript.ASSIGNMENT)||"0";return b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+c+";\n"};var module$build$src$generators$javascript$variables={};javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_get_dynamic=javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_get;javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_set_dynamic=javascriptGenerator$$module$build$src$generators$javascript.forBlock.variables_set;var module$build$src$generators$javascript$variables_dynamic={};var module$build$src$generators$javascript$all={};module$build$src$generators$javascript$all.JavascriptGenerator=JavascriptGenerator$$module$build$src$generators$javascript;module$build$src$generators$javascript$all.Order=Order$$module$build$src$generators$javascript;module$build$src$generators$javascript$all.javascriptGenerator=javascriptGenerator$$module$build$src$generators$javascript;
283
+ module$build$src$generators$javascript$all.__namespace__=$;
284
+ return module$build$src$generators$javascript$all;
327
285
  }));
328
286
 
329
287