forked from google/blockly
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zig_compressed.js
132 lines (128 loc) · 49.4 KB
/
zig_compressed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Do not edit this file; automatically generated.
/* eslint-disable */
;(function(root, factory) {
if (typeof define === 'function' && define.amd) { // AMD
define(["./blockly_compressed.js"], factory);
} else if (typeof exports === 'object') { // Node.js
module.exports = factory(require("./blockly_compressed.js"));
} else { // Browser
var factoryExports = factory(root.Blockly);
root.Blockly.Zig = factoryExports;
}
}(this, function(__parent__) {
var $=__parent__.__namespace__;
/*
SPDX-License-Identifier: Apache-2.0
*/
var module$contents$Blockly$Zig$functions_alignComments=function(a){for(var b=-1,c=!0,d=$.$jscomp.makeIterator(a),e=d.next();!e.done;e=d.next())e=e.value.indexOf("//"),c||0>e?c=!1:b=Math.max(b,e);if(0>b)return a;d=[];c=!0;a=$.$jscomp.makeIterator(a);for(e=a.next();!e.done;e=a.next()){e=e.value;var f=e.indexOf("//");c||0>f?(c=!1,d.push(e)):(e=e.replace("//"," ".repeat(b-f)+"//"),d.push(e))}return d},module$exports$Blockly$Zig$composeMessage={blocks:{}};
module$exports$Blockly$Zig$composeMessage.blocks.HUE=120;
$.Blockly.defineBlocksWithJsonArray([{type:"compose_msg",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"Compose Message",mutator:"compose_msg_mutator"},{type:"compose_msg_container",message0:"compose message %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"Message Fields",enableContextMenu:!1},{type:"compose_msg_item",message0:"item",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"Message Field",
enableContextMenu:!1}]);
module$exports$Blockly$Zig$composeMessage.blocks.COMPOSE_MSG_MUTATOR_MIXIN={mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},decompose:function(a){var b=a.newBlock("compose_msg_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("compose_msg_item");e.initSvg();c.connect(e.previousConnection);
c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)$.Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=
this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField("compose message")}for(;this.getInput("ADD"+
a);)this.removeInput("ADD"+a),a++}};module$exports$Blockly$Zig$composeMessage.blocks.COMPOSE_MSG_EXTENSION=function(){this.itemCount_=2;this.updateShape_();this.setMutator(new $.Blockly.Mutator(["compose_msg_item"]))};$.Blockly.Extensions.registerMutator("compose_msg_mutator",module$exports$Blockly$Zig$composeMessage.blocks.COMPOSE_MSG_MUTATOR_MIXIN,module$exports$Blockly$Zig$composeMessage.blocks.COMPOSE_MSG_EXTENSION);var module$contents$Blockly$Zig_Zig=new $.module$exports$Blockly$Generator.Generator("Zig");module$contents$Blockly$Zig_Zig.addReservedWords("assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError");
module$contents$Blockly$Zig_Zig.ORDER_ATOMIC=0;module$contents$Blockly$Zig_Zig.ORDER_UNARY_POSTFIX=1;module$contents$Blockly$Zig_Zig.ORDER_UNARY_PREFIX=2;module$contents$Blockly$Zig_Zig.ORDER_MULTIPLICATIVE=3;module$contents$Blockly$Zig_Zig.ORDER_ADDITIVE=4;module$contents$Blockly$Zig_Zig.ORDER_SHIFT=5;module$contents$Blockly$Zig_Zig.ORDER_BITWISE_AND=6;module$contents$Blockly$Zig_Zig.ORDER_BITWISE_XOR=7;module$contents$Blockly$Zig_Zig.ORDER_BITWISE_OR=8;
module$contents$Blockly$Zig_Zig.ORDER_RELATIONAL=9;module$contents$Blockly$Zig_Zig.ORDER_EQUALITY=10;module$contents$Blockly$Zig_Zig.ORDER_LOGICAL_AND=11;module$contents$Blockly$Zig_Zig.ORDER_LOGICAL_OR=12;module$contents$Blockly$Zig_Zig.ORDER_IF_NULL=13;module$contents$Blockly$Zig_Zig.ORDER_CONDITIONAL=14;module$contents$Blockly$Zig_Zig.ORDER_CASCADE=15;module$contents$Blockly$Zig_Zig.ORDER_ASSIGNMENT=16;module$contents$Blockly$Zig_Zig.ORDER_NONE=99;
module$contents$Blockly$Zig_Zig.isInitialized=!1;
module$contents$Blockly$Zig_Zig.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));a=
(0,$.module$exports$Blockly$Variables.allUsedVarModels)(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.module$exports$Blockly$Names.NameType.VARIABLE));this.isInitialized=!0};
module$contents$Blockly$Zig_Zig.finish=function(a){a&&(a=this.prefixLines(a,this.INDENT));a=["/// Main Function\npub fn main() !void {\n",a,"}"].join("");var b=[],c=[],d;for(d in this.definitions_){var e=this.definitions_[d];e.match(/^import\s/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();b=[c.join("\n\n")].join("");return['/// Import Standard Library\nconst std = @import("std");\n\n',a,""==b?"":"\n\n",b.replace(/\n\n+/g,"\n\n").replace(/\n*$/,
"\n\n"),"/// Aliases for Standard Library\nconst assert = std.debug.assert;\nconst debug = std.log.debug;\n"].join("")};module$contents$Blockly$Zig_Zig.scrubNakedValue=function(a){return a+";\n"};module$contents$Blockly$Zig_Zig.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/"/g,'\\"');return'"'+a+'"'};module$contents$Blockly$Zig_Zig.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
module$contents$Blockly$Zig_Zig.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d=a.getProcedureDef?d+this.prefixLines(e+"\n","/// "):d+this.prefixLines(e+"\n","// "));for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.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);return d+b+c};
module$contents$Blockly$Zig_Zig.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g;if(c)var h=g=this.ORDER_ADDITIVE;else d?h=g=this.ORDER_UNARY_PREFIX:g=e;a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+a+")"));return a};
$.Blockly.Zig=module$contents$Blockly$Zig_Zig;var module$exports$Blockly$Zig$functions={};$.Blockly.Zig.compose_msg=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Zig.valueToCode(a,"ADD"+c,$.Blockly.Zig.ORDER_NONE)||"''";return[["try composeCbor(.{ // Compose CBOR Message",$.Blockly.Zig.prefixLines(b.join("\n"),$.Blockly.Zig.INDENT),"})"].join("\n"),$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.field=function(a){var b=a.getFieldValue("NAME");a=$.Blockly.Zig.valueToCode(a,"name",$.Blockly.JavaScript.ORDER_ATOMIC);return['"'+b+'", '+a+",",$.Blockly.Zig.ORDER_NONE]};$.Blockly.Zig.every=function(a){var b=a.getFieldValue("DURATION");a=$.Blockly.Zig.statementToCode(a,"STMTS");return["","// Every "+b+" seconds...","while (true) {",a,$.Blockly.Zig.INDENT+("// Wait "+b+" seconds"),$.Blockly.Zig.INDENT+("_ = c.sleep("+b+");"),"}\n"].join("\n")};
$.Blockly.Zig.bme280=function(a){var b=a.getFieldValue("FIELD");a=a.getFieldValue("PATH");return[module$contents$Blockly$Zig$functions_alignComments(["try sen.readSensor( // Read BME280 Sensor",$.Blockly.Zig.INDENT+("c."+("humidity"==b?"struct_sensor_humi":"struct_sensor_baro")+", // Sensor Data Struct"),$.Blockly.Zig.INDENT+('"'+b+'", // Sensor Data Field'),$.Blockly.Zig.INDENT+('"'+a+'" // Path of Sensor Device'),")"]).join("\n"),$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.transmit_msg=function(a){var b=$.Blockly.Zig.valueToCode(a,"MSG",$.Blockly.Zig.ORDER_ATOMIC);a.getFieldValue("TO");return["\n// Transmit message to LoRaWAN","try transmitLorawan("+b+");",""].join("\n")};var module$exports$Blockly$Zig$blocks={};
$.Blockly.Zig.blocks=[{type:"every",message0:"every %1 seconds %2 %3",args0:[{type:"field_number",name:"DURATION",value:10,min:0},{type:"input_dummy"},{type:"input_statement",name:"STMTS"}],colour:120,tooltip:"",helpUrl:""},{type:"field",message0:"field %1 %2 value %3",args0:[{type:"input_dummy"},{type:"field_input",name:"NAME",text:"name"},{type:"input_value",name:"name"}],inputsInline:!0,output:null,colour:180,tooltip:"",helpUrl:""},{type:"bme280",message0:"BME280 Sensor %1 read %2 %3 from %4",args0:[{type:"input_dummy"},
{type:"field_dropdown",name:"FIELD",options:[["temperature","temperature"],["pressure","pressure"],["humidity","humidity"]]},{type:"input_dummy"},{type:"field_input",name:"PATH",text:"/dev/uorb/sensor_baro0"}],output:"Number",colour:230,tooltip:"",helpUrl:""},{type:"transmit_msg",message0:"transmit message %1 to %2",args0:[{type:"input_value",name:"MSG"},{type:"field_dropdown",name:"TO",options:[["LoRaWAN","lorawan"]]}],previousStatement:"Action",nextStatement:"Action",colour:230,tooltip:"",helpUrl:""}];var module$exports$Blockly$Zig$variables={};$.Blockly.Zig.variables_get=function(a){return[$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Zig.ORDER_ATOMIC]};$.Blockly.Zig.variables_set=function(a){var b=$.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_ASSIGNMENT)||"0";return"const "+$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Zig$variablesDynamic={};$.Blockly.Zig.variables_get_dynamic=$.Blockly.Zig.variables_get;$.Blockly.Zig.variables_set_dynamic=$.Blockly.Zig.variables_set;var module$exports$Blockly$Zig$texts={};$.Blockly.Zig.addReservedWords("Html,Math");$.Blockly.Zig.text=function(a){return[$.Blockly.Zig.quote_(a.getFieldValue("TEXT")),$.Blockly.Zig.ORDER_ATOMIC]};$.Blockly.Zig.text_multiline=function(a){a=$.Blockly.Zig.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.Zig.ORDER_ADDITIVE:$.Blockly.Zig.ORDER_ATOMIC;return[a,b]};
$.Blockly.Zig.text_join=function(a){switch(a.itemCount_){case 0:return['""',$.Blockly.Zig.ORDER_ATOMIC];case 1:return[($.Blockly.Zig.valueToCode(a,"ADD0",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+".toString()",$.Blockly.Zig.ORDER_UNARY_POSTFIX];default:for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Zig.valueToCode(a,"ADD"+c,$.Blockly.Zig.ORDER_NONE)||'""';return["["+b.join(",")+"].join()",$.Blockly.Zig.ORDER_UNARY_POSTFIX]}};
$.Blockly.Zig.text_append=function(a){var b=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_NONE)||'""';return b+" = ["+b+", "+a+"].join();\n"};$.Blockly.Zig.text_length=function(a){return[($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+".length",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.text_isEmpty=function(a){return[($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+".isEmpty",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Zig.valueToCode(a,"FIND",$.Blockly.Zig.ORDER_NONE)||'""';b=($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Zig.ORDER_ADDITIVE]:[b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Zig.valueToCode(a,"VALUE","FIRST"===b||"FROM_START"===b?$.Blockly.Zig.ORDER_UNARY_POSTFIX:$.Blockly.Zig.ORDER_NONE)||'""';switch(b){case "FIRST":return[c+"[0]",$.Blockly.Zig.ORDER_UNARY_POSTFIX];case "FROM_START":return a=$.Blockly.Zig.getAdjusted(a,"AT"),[c+"["+a+"]",$.Blockly.Zig.ORDER_UNARY_POSTFIX];case "LAST":case "FROM_END":return a=$.Blockly.Zig.getAdjusted(a,"AT",1),[$.Blockly.Zig.provideFunction_("text_get_from_end",
"\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String text, num x) {\n return text[text.length - x];\n}\n")+"("+c+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX];case "RANDOM":return $.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;",[$.Blockly.Zig.provideFunction_("text_random_letter","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String text) {\n int x = new Math.Random().nextInt(text.length);\n return text[x];\n}\n")+"("+c+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).");
};
$.Blockly.Zig.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"FROM_START"===c,e=$.Blockly.Zig.valueToCode(a,"STRING",d?$.Blockly.Zig.ORDER_UNARY_POSTFIX:$.Blockly.Zig.ORDER_NONE)||'""';if("FIRST"===b&&"LAST"===c)return[e,$.Blockly.Zig.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=$.Blockly.Zig.getAdjusted(a,"AT1");break;case "FROM_END":b=$.Blockly.Zig.getAdjusted(a,"AT1",1,!1,$.Blockly.Zig.ORDER_ADDITIVE);b=e+".length - "+b;
break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":var f=$.Blockly.Zig.getAdjusted(a,"AT2",1);break;case "FROM_END":f=$.Blockly.Zig.getAdjusted(a,"AT2",0,!1,$.Blockly.Zig.ORDER_ADDITIVE);f=e+".length - "+f;break;case "LAST":break;default:throw Error("Unhandled option (text_getSubstring).");}c="LAST"===c?e+".substring("+b+")":e+".substring("+b+", "+f+")"}else f=$.Blockly.Zig.getAdjusted(a,"AT1"),a=$.Blockly.Zig.getAdjusted(a,"AT2"),
c=$.Blockly.Zig.provideFunction_("text_get_substring","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String text, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = text.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = text.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (text_getSubstring).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return text.substring(at1, at2);\n}\n")+
"("+e+", '"+b+"', "+f+", '"+c+"', "+a+")";return[c,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=$.Blockly.Zig.valueToCode(a,"TEXT",b?$.Blockly.Zig.ORDER_UNARY_POSTFIX:$.Blockly.Zig.ORDER_NONE)||'""';return[b?a+b:$.Blockly.Zig.provideFunction_("text_toTitleCase","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String str) {\n RegExp exp = new RegExp(r'\\b');\n List<String> list = str.split(exp);\n final title = new StringBuffer();\n for (String part in list) {\n if (part.length > 0) {\n title.write(part[0].toUpperCase());\n if (part.length > 0) {\n title.write(part.substring(1).toLowerCase());\n }\n }\n }\n return title.toString();\n}\n")+"("+
a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.text_trim=function(a){var b={LEFT:".replaceFirst(new RegExp(r'^\\s+'), '')",RIGHT:".replaceFirst(new RegExp(r'\\s+$'), '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[($.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.text_print=function(a){a=$.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_NONE)||'""';return'debug("'+a+'={}", .{ '+a+" });\n"};
$.Blockly.Zig.text_prompt_ext=function(a){$.Blockly.Zig.definitions_.import_zig_html="import 'zig:html' as Html;";var b="Html.window.prompt("+(a.getField("TEXT")?$.Blockly.Zig.quote_(a.getFieldValue("TEXT")):$.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_NONE)||'""')+", '')";"NUMBER"===a.getFieldValue("TYPE")&&($.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;",b="Math.parseDouble("+b+")");return[b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.text_prompt=$.Blockly.Zig.text_prompt_ext;
$.Blockly.Zig.text_count=function(a){var b=$.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_NONE)||'""';a=$.Blockly.Zig.valueToCode(a,"SUB",$.Blockly.Zig.ORDER_NONE)||'""';return[$.Blockly.Zig.provideFunction_("text_count","\nint "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String haystack, String needle) {\n if (needle.length == 0) {\n return haystack.length + 1;\n }\n int index = 0;\n int count = 0;\n while (index != -1) {\n index = haystack.indexOf(needle, index);\n if (index != -1) {\n count++;\n index += needle.length;\n }\n }\n return count;\n}\n")+
"("+b+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.text_replace=function(a){var b=$.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""',c=$.Blockly.Zig.valueToCode(a,"FROM",$.Blockly.Zig.ORDER_NONE)||'""';a=$.Blockly.Zig.valueToCode(a,"TO",$.Blockly.Zig.ORDER_NONE)||'""';return[b+".replaceAll("+c+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.text_reverse=function(a){return["new String.fromCharCodes("+($.Blockly.Zig.valueToCode(a,"TEXT",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||'""')+".runes.toList().reversed)",$.Blockly.Zig.ORDER_UNARY_PREFIX]};var module$exports$Blockly$Zig$procedures={};
$.Blockly.Zig.procedures_defreturn=function(a){var b=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.Zig.STATEMENT_PREFIX&&(c+=$.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_PREFIX,a));$.Blockly.Zig.STATEMENT_SUFFIX&&(c+=$.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.Zig.prefixLines(c,$.Blockly.Zig.INDENT));var d="";$.Blockly.Zig.INFINITE_LOOP_TRAP&&(d=$.Blockly.Zig.prefixLines($.Blockly.Zig.injectId($.Blockly.Zig.INFINITE_LOOP_TRAP,a),
$.Blockly.Zig.INDENT));var e=$.Blockly.Zig.statementToCode(a,"STACK"),f=$.Blockly.Zig.valueToCode(a,"RETURN",$.Blockly.Zig.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=$.Blockly.Zig.INDENT+"return "+f+";\n");for(var h=f?"!f32":"!void",k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=[$.Blockly.Zig.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE),": f32"].join("");c=["fn "+b+"("+k.join(", ")+") "+h+" {\n",c,d,e,g,f,"}"].join("");c=$.Blockly.Zig.scrub_(a,c);$.Blockly.Zig.definitions_["%"+
b]=c;return null};$.Blockly.Zig.procedures_defnoreturn=$.Blockly.Zig.procedures_defreturn;$.Blockly.Zig.procedures_callreturn=function(a){for(var b=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Zig.valueToCode(a,"ARG"+e,$.Blockly.Zig.ORDER_NONE)||"null";return[["try ",b,"(",c.join(", "),")"].join(""),$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.procedures_callnoreturn=function(a){return $.Blockly.Zig.procedures_callreturn(a)[0]+";\n"};
$.Blockly.Zig.procedures_ifreturn=function(a){var b="if ("+($.Blockly.Zig.valueToCode(a,"CONDITION",$.Blockly.Zig.ORDER_NONE)||"false")+") {\n";$.Blockly.Zig.STATEMENT_SUFFIX&&(b+=$.Blockly.Zig.prefixLines($.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_SUFFIX,a),$.Blockly.Zig.INDENT));a.hasReturnValue_?(a=$.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_NONE)||"null",b+=$.Blockly.Zig.INDENT+"return "+a+";\n"):b+=$.Blockly.Zig.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$Zig$math={};$.Blockly.Zig.addReservedWords("Math");$.Blockly.Zig.math_number=function(a){a=Number(a.getFieldValue("NUM"));if(Infinity===a){a="double.infinity";var b=$.Blockly.Zig.ORDER_UNARY_POSTFIX}else-Infinity===a?(a="-double.infinity",b=$.Blockly.Zig.ORDER_UNARY_PREFIX):b=0>a?$.Blockly.Zig.ORDER_UNARY_PREFIX:$.Blockly.Zig.ORDER_ATOMIC;return[a,b]};
$.Blockly.Zig.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Zig.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Zig.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Zig.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Zig.ORDER_MULTIPLICATIVE],POWER:[null,$.Blockly.Zig.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Zig.valueToCode(a,"A",b)||"0";a=$.Blockly.Zig.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:($.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;",["Math.pow("+
d+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX])};
$.Blockly.Zig.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.Zig.valueToCode(a,"NUM",$.Blockly.Zig.ORDER_UNARY_PREFIX)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.Zig.ORDER_UNARY_PREFIX];$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";a="ABS"===b||"ROUND"===b.substring(0,5)?$.Blockly.Zig.valueToCode(a,"NUM",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"0":"SIN"===b||"COS"===b||"TAN"===b?$.Blockly.Zig.valueToCode(a,"NUM",$.Blockly.Zig.ORDER_MULTIPLICATIVE)||
"0":$.Blockly.Zig.valueToCode(a,"NUM",$.Blockly.Zig.ORDER_NONE)||"0";switch(b){case "ABS":var c=a+".abs()";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=a+".round()";break;case "ROUNDUP":c=a+".ceil()";break;case "ROUNDDOWN":c=a+".floor()";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,$.Blockly.Zig.ORDER_UNARY_POSTFIX];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";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.Zig.ORDER_MULTIPLICATIVE]};
$.Blockly.Zig.math_constant=function(a){var b={PI:["Math.pi",$.Blockly.Zig.ORDER_UNARY_POSTFIX],E:["Math.e",$.Blockly.Zig.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",$.Blockly.Zig.ORDER_MULTIPLICATIVE],SQRT2:["Math.sqrt2",$.Blockly.Zig.ORDER_UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",$.Blockly.Zig.ORDER_UNARY_POSTFIX],INFINITY:["double.infinity",$.Blockly.Zig.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&($.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;");
return b[a]};
$.Blockly.Zig.math_number_property=function(a){var b={EVEN:[" % 2 == 0",$.Blockly.Zig.ORDER_MULTIPLICATIVE,$.Blockly.Zig.ORDER_EQUALITY],ODD:[" % 2 == 1",$.Blockly.Zig.ORDER_MULTIPLICATIVE,$.Blockly.Zig.ORDER_EQUALITY],WHOLE:[" % 1 == 0",$.Blockly.Zig.ORDER_MULTIPLICATIVE,$.Blockly.Zig.ORDER_EQUALITY],POSITIVE:[" > 0",$.Blockly.Zig.ORDER_RELATIONAL,$.Blockly.Zig.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.Zig.ORDER_RELATIONAL,$.Blockly.Zig.ORDER_RELATIONAL],DIVISIBLE_BY:[null,$.Blockly.Zig.ORDER_MULTIPLICATIVE,$.Blockly.Zig.ORDER_EQUALITY],
PRIME:[null,$.Blockly.Zig.ORDER_NONE,$.Blockly.Zig.ORDER_UNARY_POSTFIX]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.Zig.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;",a=$.Blockly.Zig.provideFunction_("math_isPrime","\nbool "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is null, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n")+
"("+e+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.Zig.valueToCode(a,"DIVISOR",$.Blockly.Zig.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["false",$.Blockly.Zig.ORDER_ATOMIC];a=e+" % "+a+" == 0"}else a=e+d;return[a,b]};$.Blockly.Zig.math_change=function(a){var b=$.Blockly.Zig.valueToCode(a,"DELTA",$.Blockly.Zig.ORDER_ADDITIVE)||"0";a=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};
$.Blockly.Zig.math_round=$.Blockly.Zig.math_single;$.Blockly.Zig.math_trig=$.Blockly.Zig.math_single;
$.Blockly.Zig.math_on_list=function(a){var b=a.getFieldValue("OP");a=$.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_NONE)||"[]";switch(b){case "SUM":b=$.Blockly.Zig.provideFunction_("math_sum","\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n num sumVal = 0;\n myList.forEach((num entry) {sumVal += entry;});\n return sumVal;\n}\n")+"("+a+")";break;case "MIN":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";b=$.Blockly.Zig.provideFunction_("math_min",
"\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num minVal = myList[0];\n myList.forEach((num entry) {minVal = Math.min(minVal, entry);});\n return minVal;\n}\n")+"("+a+")";break;case "MAX":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";b=$.Blockly.Zig.provideFunction_("math_max","\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num maxVal = myList[0];\n myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});\n return maxVal;\n}\n")+
"("+a+")";break;case "AVERAGE":b=$.Blockly.Zig.provideFunction_("math_mean","\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n num sumVal = 0;\n localList.forEach((var entry) {sumVal += entry;});\n return sumVal / localList.length;\n}\n")+"("+a+")";break;case "MEDIAN":b=$.Blockly.Zig.provideFunction_("math_median",
"\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only, then sort, then return middle value\n // or the average of two middle values if list has an even number of elements.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n localList.sort((a, b) => (a - b));\n int index = localList.length ~/ 2;\n if (localList.length % 2 == 1) {\n return localList[index];\n } else {\n return (localList[index - 1] + localList[index]) / 2;\n }\n}\n")+
"("+a+")";break;case "MODE":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";b=$.Blockly.Zig.provideFunction_("math_modes","\nList "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List values) {\n List modes = [];\n List counts = [];\n int maxCount = 0;\n for (int i = 0; i < values.length; i++) {\n var value = values[i];\n bool found = false;\n int thisCount;\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][0] == value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.add([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][1] == maxCount) {\n modes.add(counts[j][0]);\n }\n }\n return modes;\n}\n")+
"("+a+")";break;case "STD_DEV":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";b=$.Blockly.Zig.provideFunction_("math_standard_deviation","\nnum "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List numbers = new List.from(myList);\n numbers.removeWhere((a) => a is! num);\n if (numbers.isEmpty) return null;\n num n = numbers.length;\n num sum = 0;\n numbers.forEach((x) => sum += x);\n num mean = sum / n;\n num sumSquare = 0;\n numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));\n return Math.sqrt(sumSquare / n);\n}\n")+
"("+a+")";break;case "RANDOM":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";b=$.Blockly.Zig.provideFunction_("math_random_item","\ndynamic "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n int x = new Math.Random().nextInt(myList.length);\n return myList[x];\n}\n")+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.math_modulo=function(a){var b=$.Blockly.Zig.valueToCode(a,"DIVIDEND",$.Blockly.Zig.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Zig.valueToCode(a,"DIVISOR",$.Blockly.Zig.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Zig.ORDER_MULTIPLICATIVE]};
$.Blockly.Zig.math_constrain=function(a){$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";var b=$.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_NONE)||"0",c=$.Blockly.Zig.valueToCode(a,"LOW",$.Blockly.Zig.ORDER_NONE)||"0";a=$.Blockly.Zig.valueToCode(a,"HIGH",$.Blockly.Zig.ORDER_NONE)||"double.infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.math_random_int=function(a){$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";var b=$.Blockly.Zig.valueToCode(a,"FROM",$.Blockly.Zig.ORDER_NONE)||"0";a=$.Blockly.Zig.valueToCode(a,"TO",$.Blockly.Zig.ORDER_NONE)||"0";return[$.Blockly.Zig.provideFunction_("math_random_int","\nint "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(num a, num b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n num c = a;\n a = b;\n b = c;\n }\n return new Math.Random().nextInt(b - a + 1) + a;\n}\n")+
"("+b+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.math_random_float=function(a){$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";return["new Math.Random().nextDouble()",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.math_atan2=function(a){$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";var b=$.Blockly.Zig.valueToCode(a,"X",$.Blockly.Zig.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.Zig.valueToCode(a,"Y",$.Blockly.Zig.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",$.Blockly.Zig.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Zig$loops={};
$.Blockly.Zig.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.Zig.valueToCode(a,"TIMES",$.Blockly.Zig.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.Zig.statementToCode(a,"DO");c=$.Blockly.Zig.addLoopTrap(c,a);a="";var d=$.Blockly.Zig.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.Zig.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),
a+="var "+e+" = "+b+";\n");return a+=["var "+d+": usize = 0;\n","while ("+d+" < "+e+") : ("+d+" += 1) {\n",c,"}\n"].join("")};$.Blockly.Zig.controls_repeat=$.Blockly.Zig.controls_repeat_ext;$.Blockly.Zig.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Zig.valueToCode(a,"BOOL",b?$.Blockly.Zig.ORDER_UNARY_PREFIX:$.Blockly.Zig.ORDER_NONE)||"false",d=$.Blockly.Zig.statementToCode(a,"DO");d=$.Blockly.Zig.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
$.Blockly.Zig.controls_for=function(a){var b=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Zig.valueToCode(a,"FROM",$.Blockly.Zig.ORDER_ASSIGNMENT)||"0",d=$.Blockly.Zig.valueToCode(a,"TO",$.Blockly.Zig.ORDER_ASSIGNMENT)||"0",e=$.Blockly.Zig.valueToCode(a,"BY",$.Blockly.Zig.ORDER_ASSIGNMENT)||"1",f=$.Blockly.Zig.statementToCode(a,"DO");f=$.Blockly.Zig.addLoopTrap(f,a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&
(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.Zig.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||
(c=$.Blockly.Zig.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.Zig.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="num "+d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.Zig.INDENT+d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+
d+") {\n"+f+"}\n";return a};$.Blockly.Zig.controls_forEach=function(a){var b=$.Blockly.Zig.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.Zig.statementToCode(a,"DO");d=$.Blockly.Zig.addLoopTrap(d,a);return"for (var "+b+" in "+c+") {\n"+d+"}\n"};
$.Blockly.Zig.controls_flow_statements=function(a){var b="";$.Blockly.Zig.STATEMENT_PREFIX&&(b+=$.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_PREFIX,a));$.Blockly.Zig.STATEMENT_SUFFIX&&(b+=$.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_SUFFIX,a));if($.Blockly.Zig.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Zig.injectId($.Blockly.Zig.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$Zig$logic={};
$.Blockly.Zig.controls_if=function(a){var b=0,c="";$.Blockly.Zig.STATEMENT_PREFIX&&(c+=$.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_PREFIX,a));do{var d=$.Blockly.Zig.valueToCode(a,"IF"+b,$.Blockly.Zig.ORDER_NONE)||"false";var e=$.Blockly.Zig.statementToCode(a,"DO"+b);$.Blockly.Zig.STATEMENT_SUFFIX&&(e=$.Blockly.Zig.prefixLines($.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_SUFFIX,a),$.Blockly.Zig.INDENT)+e);c+=(0<b?"else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
$.Blockly.Zig.STATEMENT_SUFFIX)e=$.Blockly.Zig.statementToCode(a,"ELSE"),$.Blockly.Zig.STATEMENT_SUFFIX&&(e=$.Blockly.Zig.prefixLines($.Blockly.Zig.injectId($.Blockly.Zig.STATEMENT_SUFFIX,a),$.Blockly.Zig.INDENT)+e),c+=" else {\n"+e+"}";return c+"\n"};$.Blockly.Zig.controls_ifelse=$.Blockly.Zig.controls_if;
$.Blockly.Zig.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.Zig.ORDER_EQUALITY:$.Blockly.Zig.ORDER_RELATIONAL,d=$.Blockly.Zig.valueToCode(a,"A",c)||"0";a=$.Blockly.Zig.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
$.Blockly.Zig.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.Zig.ORDER_LOGICAL_AND:$.Blockly.Zig.ORDER_LOGICAL_OR,d=$.Blockly.Zig.valueToCode(a,"A",c);a=$.Blockly.Zig.valueToCode(a,"B",c);if(d||a){var e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};$.Blockly.Zig.logic_negate=function(a){var b=$.Blockly.Zig.ORDER_UNARY_PREFIX;return["!"+($.Blockly.Zig.valueToCode(a,"BOOL",b)||"true"),b]};
$.Blockly.Zig.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.Zig.ORDER_ATOMIC]};$.Blockly.Zig.logic_null=function(a){return["null",$.Blockly.Zig.ORDER_ATOMIC]};
$.Blockly.Zig.logic_ternary=function(a){var b=$.Blockly.Zig.valueToCode(a,"IF",$.Blockly.Zig.ORDER_CONDITIONAL)||"false",c=$.Blockly.Zig.valueToCode(a,"THEN",$.Blockly.Zig.ORDER_CONDITIONAL)||"null";a=$.Blockly.Zig.valueToCode(a,"ELSE",$.Blockly.Zig.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.Zig.ORDER_CONDITIONAL]};var module$exports$Blockly$Zig$lists={};$.Blockly.Zig.addReservedWords("Math");$.Blockly.Zig.lists_create_empty=function(a){return["[]",$.Blockly.Zig.ORDER_ATOMIC]};$.Blockly.Zig.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Zig.valueToCode(a,"ADD"+c,$.Blockly.Zig.ORDER_NONE)||"null";return["["+b.join(", ")+"]",$.Blockly.Zig.ORDER_ATOMIC]};
$.Blockly.Zig.lists_repeat=function(a){var b=$.Blockly.Zig.valueToCode(a,"ITEM",$.Blockly.Zig.ORDER_NONE)||"null";return["new List.filled("+($.Blockly.Zig.valueToCode(a,"NUM",$.Blockly.Zig.ORDER_NONE)||"0")+", "+b+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.lists_length=function(a){return[($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]")+".length",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.lists_isEmpty=function(a){return[($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Zig.valueToCode(a,"FIND",$.Blockly.Zig.ORDER_NONE)||'""';b=($.Blockly.Zig.valueToCode(a,"VALUE",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Zig.ORDER_ADDITIVE]:[b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.lists_getIndex=function(a){function b(){var f=$.Blockly.Zig.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),g="List "+f+" = "+e+";\n";e=f;return g}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Zig.valueToCode(a,"VALUE","RANDOM"===d||"FROM_END"===d?$.Blockly.Zig.ORDER_NONE:$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]";if(("RANDOM"!==d||"REMOVE"!==c)&&"FROM_END"!==d||e.match(/^\w+$/))switch(d){case "FIRST":if("GET"===
c)return[e+".first",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt(0)",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt(0);\n";break;case "LAST":if("GET"===c)return[e+".last",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeLast()",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeLast();\n";break;case "FROM_START":a=$.Blockly.Zig.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",$.Blockly.Zig.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[e+".removeAt("+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt("+a+");\n";break;case "FROM_END":a=$.Blockly.Zig.getAdjusted(a,"AT",1,!1,$.Blockly.Zig.ORDER_ADDITIVE);if("GET"===c)return[e+"["+e+".length - "+a+"]",$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c||"REMOVE"===c){a=e+".removeAt("+e+".length - "+a+")";if("GET_REMOVE"===c)return[a,$.Blockly.Zig.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return a+";\n"}break;case "RANDOM":$.Blockly.Zig.definitions_.import_zig_math=
"import 'zig:math' as Math;";if("REMOVE"===c)return c=$.Blockly.Zig.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),"int "+c+" = new Math.Random().nextInt("+e+".length);\n"+(e+".removeAt("+c+");\n");if("GET"===c)return[$.Blockly.Zig.provideFunction_("lists_get_random_item","\ndynamic "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list[x];\n}\n")+"("+e+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[$.Blockly.Zig.provideFunction_("lists_remove_random_item","\ndynamic "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list.removeAt(x);\n}\n")+"("+e+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]}else{if("RANDOM"===d)return $.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;",c=b(),a=$.Blockly.Zig.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),c+("int "+
a+" = new Math.Random().nextInt("+e+".length);\n")+(e+".removeAt("+a+");\n");if("REMOVE"===c)return c=$.Blockly.Zig.getAdjusted(a,"AT",1,!1,$.Blockly.Zig.ORDER_ADDITIVE),b()+(e+".removeAt("+e+".length - "+c+");\n");if("GET"===c)return c=$.Blockly.Zig.getAdjusted(a,"AT",1),[$.Blockly.Zig.provideFunction_("lists_get_from_end","\ndynamic "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list[x];\n}\n")+"("+e+", "+c+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return c=$.Blockly.Zig.getAdjusted(a,"AT",1),[$.Blockly.Zig.provideFunction_("lists_remove_from_end","\ndynamic "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list.removeAt(x);\n}\n")+"("+e+", "+c+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).");};
$.Blockly.Zig.lists_setIndex=function(a){function b(){if(e.match(/^\w+$/))return"";var g=$.Blockly.Zig.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),h="List "+g+" = "+e+";\n";e=g;return h}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]",f=$.Blockly.Zig.valueToCode(a,"TO",$.Blockly.Zig.ORDER_ASSIGNMENT)||"null";switch(d){case "FIRST":if("SET"===c)return e+
"[0] = "+f+";\n";if("INSERT"===c)return e+".insert(0, "+f+");\n";break;case "LAST":if("SET"===c)return b()+(e+"["+e+".length - 1] = "+f+";\n");if("INSERT"===c)return e+".add("+f+");\n";break;case "FROM_START":a=$.Blockly.Zig.getAdjusted(a,"AT");if("SET"===c)return e+"["+a+"] = "+f+";\n";if("INSERT"===c)return e+".insert("+a+", "+f+");\n";break;case "FROM_END":a=$.Blockly.Zig.getAdjusted(a,"AT",1,!1,$.Blockly.Zig.ORDER_ADDITIVE);d=b();if("SET"===c)return d+(e+"["+e+".length - "+a+"] = "+f+";\n");if("INSERT"===
c)return d+(e+".insert("+e+".length - "+a+", "+f+");\n");break;case "RANDOM":$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";a=b();d=$.Blockly.Zig.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE);a+="int "+d+" = new Math.Random().nextInt("+e+".length);\n";if("SET"===c)return a+(e+"["+d+"] = "+f+";\n");if("INSERT"===c)return a+(e+".insert("+d+", "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
$.Blockly.Zig.lists_getSublist=function(a){var b=$.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_UNARY_POSTFIX)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=$.Blockly.Zig.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.Zig.getAdjusted(a,"AT1",1,!1,$.Blockly.Zig.ORDER_ADDITIVE);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");
}switch(d){case "FROM_START":var e=$.Blockly.Zig.getAdjusted(a,"AT2",1);break;case "FROM_END":e=$.Blockly.Zig.getAdjusted(a,"AT2",0,!1,$.Blockly.Zig.ORDER_ADDITIVE);e=b+".length - "+e;break;case "LAST":break;default:throw Error("Unhandled option (lists_getSublist).");}b="LAST"===d?b+".sublist("+c+")":b+".sublist("+c+", "+e+")"}else e=$.Blockly.Zig.getAdjusted(a,"AT1"),a=$.Blockly.Zig.getAdjusted(a,"AT2"),b=$.Blockly.Zig.provideFunction_("lists_get_sublist","\nList "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+
"(List list, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = list.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = list.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (lists_getSublist).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return list.sublist(at1, at2);\n}\n")+
"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.lists_sort=function(a){var b=$.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.Zig.provideFunction_("lists_sort","\nList "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(List list, String type, int direction) {\n var compareFuncs = {\n 'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),\n 'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),\n 'IGNORE_CASE':\n (a, b) => direction *\n a.toString().toLowerCase().compareTo(b.toString().toLowerCase())\n };\n list = new List.from(list);\n var compare = compareFuncs[type];\n list.sort(compare);\n return list;\n}\n")+"("+
b+', "'+a+'", '+c+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};$.Blockly.Zig.lists_split=function(a){var b=$.Blockly.Zig.valueToCode(a,"INPUT",$.Blockly.Zig.ORDER_UNARY_POSTFIX),c=$.Blockly.Zig.valueToCode(a,"DELIM",$.Blockly.Zig.ORDER_NONE)||'""';a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b='""'),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.lists_reverse=function(a){return["new List.from("+($.Blockly.Zig.valueToCode(a,"LIST",$.Blockly.Zig.ORDER_NONE)||"[]")+".reversed)",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Zig$colour={};$.Blockly.Zig.addReservedWords("Math");$.Blockly.Zig.colour_picker=function(a){return[$.Blockly.Zig.quote_(a.getFieldValue("COLOUR")),$.Blockly.Zig.ORDER_ATOMIC]};
$.Blockly.Zig.colour_random=function(a){$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";return[$.Blockly.Zig.provideFunction_("colour_random","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"() {\n String hex = '0123456789abcdef';\n var rnd = new Math.Random();\n return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';\n}\n")+"()",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.colour_rgb=function(a){var b=$.Blockly.Zig.valueToCode(a,"RED",$.Blockly.Zig.ORDER_NONE)||0,c=$.Blockly.Zig.valueToCode(a,"GREEN",$.Blockly.Zig.ORDER_NONE)||0;a=$.Blockly.Zig.valueToCode(a,"BLUE",$.Blockly.Zig.ORDER_NONE)||0;$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";return[$.Blockly.Zig.provideFunction_("colour_rgb","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {\n num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();\n String rs = rn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();\n String gs = gn.toInt().toRadixString(16);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();\n String bs = bn.toInt().toRadixString(16);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
"("+b+", "+c+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};
$.Blockly.Zig.colour_blend=function(a){var b=$.Blockly.Zig.valueToCode(a,"COLOUR1",$.Blockly.Zig.ORDER_NONE)||"'#000000'",c=$.Blockly.Zig.valueToCode(a,"COLOUR2",$.Blockly.Zig.ORDER_NONE)||"'#000000'";a=$.Blockly.Zig.valueToCode(a,"RATIO",$.Blockly.Zig.ORDER_NONE)||.5;$.Blockly.Zig.definitions_.import_zig_math="import 'zig:math' as Math;";return[$.Blockly.Zig.provideFunction_("colour_blend","\nString "+$.Blockly.Zig.FUNCTION_NAME_PLACEHOLDER_+"(String c1, String c2, num ratio) {\n ratio = Math.max(Math.min(ratio, 1), 0);\n int r1 = int.parse('0x${c1.substring(1, 3)}');\n int g1 = int.parse('0x${c1.substring(3, 5)}');\n int b1 = int.parse('0x${c1.substring(5, 7)}');\n int r2 = int.parse('0x${c2.substring(1, 3)}');\n int g2 = int.parse('0x${c2.substring(3, 5)}');\n int b2 = int.parse('0x${c2.substring(5, 7)}');\n num rn = (r1 * (1 - ratio) + r2 * ratio).round();\n String rs = rn.toInt().toRadixString(16);\n num gn = (g1 * (1 - ratio) + g2 * ratio).round();\n String gs = gn.toInt().toRadixString(16);\n num bn = (b1 * (1 - ratio) + b2 * ratio).round();\n String bs = bn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
"("+b+", "+c+", "+a+")",$.Blockly.Zig.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Zig$all={};
$.Blockly.Zig.__namespace__=$;
return $.Blockly.Zig;
}));
//# sourceMappingURL=zig_compressed.js.map