1 Star 0 Fork 19

smart_research/blockly

forked from Gitee 极速下载/blockly 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dart_compressed.js 43.97 KB
一键复制 编辑 原始数据 按行查看 历史
Maribeth Bottorff 提交于 2021-12-09 11:17 . Rebuild
// 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
root.Blockly.Dart = factory(root.Blockly);
}
}(this, function(Blockly) {
const $=Blockly.internal_;
var module$contents$Blockly$Dart_Dart=new $.module$exports$Blockly$Generator.Generator("Dart");module$contents$Blockly$Dart_Dart.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$Dart_Dart.ORDER_ATOMIC=0;module$contents$Blockly$Dart_Dart.ORDER_UNARY_POSTFIX=1;module$contents$Blockly$Dart_Dart.ORDER_UNARY_PREFIX=2;module$contents$Blockly$Dart_Dart.ORDER_MULTIPLICATIVE=3;module$contents$Blockly$Dart_Dart.ORDER_ADDITIVE=4;module$contents$Blockly$Dart_Dart.ORDER_SHIFT=5;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_AND=6;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_XOR=7;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_OR=8;
module$contents$Blockly$Dart_Dart.ORDER_RELATIONAL=9;module$contents$Blockly$Dart_Dart.ORDER_EQUALITY=10;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_AND=11;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_OR=12;module$contents$Blockly$Dart_Dart.ORDER_IF_NULL=13;module$contents$Blockly$Dart_Dart.ORDER_CONDITIONAL=14;module$contents$Blockly$Dart_Dart.ORDER_CASCADE=15;module$contents$Blockly$Dart_Dart.ORDER_ASSIGNMENT=16;module$contents$Blockly$Dart_Dart.ORDER_NONE=99;
module$contents$Blockly$Dart_Dart.isInitialized=!1;
module$contents$Blockly$Dart_Dart.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));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
module$contents$Blockly$Dart_Dart.finish=function(a){a&&(a=this.prefixLines(a,this.INDENT));a="main() {\n"+a+"}";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();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};module$contents$Blockly$Dart_Dart.scrubNakedValue=function(a){return a+";\n"};
module$contents$Blockly$Dart_Dart.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return"'"+a+"'"};module$contents$Blockly$Dart_Dart.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
module$contents$Blockly$Dart_Dart.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$Dart_Dart.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.Dart=module$contents$Blockly$Dart_Dart;var module$exports$Blockly$Dart$variables={};$.Blockly.Dart.variables_get=function(a){return[$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.variables_set=function(a){var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";return $.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Dart$variablesDynamic={};$.Blockly.Dart.variables_get_dynamic=$.Blockly.Dart.variables_get;$.Blockly.Dart.variables_set_dynamic=$.Blockly.Dart.variables_set;var module$exports$Blockly$Dart$texts={};$.Blockly.Dart.addReservedWords("Html,Math");$.Blockly.Dart.text=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("TEXT")),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.text_multiline=function(a){a=$.Blockly.Dart.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.Dart.ORDER_ADDITIVE:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
$.Blockly.Dart.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.Dart.ORDER_ATOMIC];case 1:return[($.Blockly.Dart.valueToCode(a,"ADD0",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".toString()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];default:for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"''";return["["+b.join(",")+"].join()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}};
$.Blockly.Dart.text_append=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";return b+" = ["+b+", "+a+"].join();\n"};$.Blockly.Dart.text_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Dart.valueToCode(a,"VALUE","FIRST"===b||"FROM_START"===b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";switch(b){case "FIRST":return[c+"[0]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "FROM_START":return a=$.Blockly.Dart.getAdjusted(a,"AT"),[c+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "LAST":case "FROM_END":return a=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("text_get_from_end",
["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, num x) {"," return text[text.length - x];","}"])+"("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "RANDOM":return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",[$.Blockly.Dart.provideFunction_("text_random_letter",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text) {"," int x = new Math.Random().nextInt(text.length);"," return text[x];","}"])+"("+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).");
};
$.Blockly.Dart.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"FROM_START"===c,e=$.Blockly.Dart.valueToCode(a,"STRING",d?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,$.Blockly.Dart.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=$.Blockly.Dart.getAdjusted(a,"AT1");break;case "FROM_END":b=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.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.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":f=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.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.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,
"AT2"),c=$.Blockly.Dart.provideFunction_("text_get_substring",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, String where1, num at1, String where2, num at2) {"," int getAt(String where, num at) {"," if (where == 'FROM_END') {"," at = text.length - 1 - at;"," } else if (where == 'FIRST') {"," at = 0;"," } else if (where == 'LAST') {"," at = text.length - 1;"," } else if (where != 'FROM_START') {"," throw 'Unhandled option (text_getSubstring).';",
" }"," return at;"," }"," at1 = getAt(where1, at1);"," at2 = getAt(where2, at2) + 1;"," return text.substring(at1, at2);","}"])+"("+e+", '"+b+"', "+f+", '"+c+"', "+a+")";return[c,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=$.Blockly.Dart.valueToCode(a,"TEXT",b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";return[b?a+b:$.Blockly.Dart.provideFunction_("text_toTitleCase",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String str) {"," RegExp exp = new RegExp(r'\\b');"," List<String> list = str.split(exp);"," final title = new StringBuffer();",
" for (String part in list) {"," if (part.length > 0) {"," title.write(part[0].toUpperCase());"," if (part.length > 0) {"," title.write(part.substring(1).toLowerCase());"," }"," }"," }"," return title.toString();","}"])+"("+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.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.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_print=function(a){return"print("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+");\n"};
$.Blockly.Dart.text_prompt_ext=function(a){$.Blockly.Dart.definitions_.import_dart_html="import 'dart:html' as Html;";var b="Html.window.prompt("+(a.getField("TEXT")?$.Blockly.Dart.quote_(a.getFieldValue("TEXT")):$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+", '')";"NUMBER"===a.getFieldValue("TYPE")&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",b="Math.parseDouble("+b+")");return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_prompt=$.Blockly.Dart.text_prompt_ext;
$.Blockly.Dart.text_count=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"SUB",$.Blockly.Dart.ORDER_NONE)||"''";return[$.Blockly.Dart.provideFunction_("text_count",["int "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String haystack, String needle) {"," if (needle.length == 0) {"," return haystack.length + 1;"," }"," int index = 0;"," int count = 0;"," while (index != -1) {"," index = haystack.indexOf(needle, index);",
" if (index != -1) {"," count++;"," index += needle.length;"," }"," }"," return count;","}"])+"("+b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_replace=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''",c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"''";return[b+".replaceAll("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_reverse=function(a){return["new String.fromCharCodes("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".runes.toList().reversed)",$.Blockly.Dart.ORDER_UNARY_PREFIX]};var module$exports$Blockly$Dart$procedures={};
$.Blockly.Dart.procedures_defreturn=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.Dart.prefixLines(c,$.Blockly.Dart.INDENT));var d="";$.Blockly.Dart.INFINITE_LOOP_TRAP&&(d=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.INFINITE_LOOP_TRAP,
a),$.Blockly.Dart.INDENT));var e=$.Blockly.Dart.statementToCode(a,"STACK"),f=$.Blockly.Dart.valueToCode(a,"RETURN",$.Blockly.Dart.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=$.Blockly.Dart.INDENT+"return "+f+";\n");for(var h=f?"dynamic":"void",k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=$.Blockly.Dart.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE);c=h+" "+b+"("+k.join(", ")+") {\n"+c+d+e+g+f+"}";c=$.Blockly.Dart.scrub_(a,c);$.Blockly.Dart.definitions_["%"+b]=c;return null};
$.Blockly.Dart.procedures_defnoreturn=$.Blockly.Dart.procedures_defreturn;$.Blockly.Dart.procedures_callreturn=function(a){for(var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Dart.valueToCode(a,"ARG"+e,$.Blockly.Dart.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.procedures_callnoreturn=function(a){return $.Blockly.Dart.procedures_callreturn(a)[0]+";\n"};
$.Blockly.Dart.procedures_ifreturn=function(a){var b="if ("+($.Blockly.Dart.valueToCode(a,"CONDITION",$.Blockly.Dart.ORDER_NONE)||"false")+") {\n";$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT));a.hasReturnValue_?(a=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"null",b+=$.Blockly.Dart.INDENT+"return "+a+";\n"):b+=$.Blockly.Dart.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$Dart$math={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.math_number=function(a){a=Number(a.getFieldValue("NUM"));if(Infinity===a){a="double.infinity";var b=$.Blockly.Dart.ORDER_UNARY_POSTFIX}else-Infinity===a?(a="-double.infinity",b=$.Blockly.Dart.ORDER_UNARY_PREFIX):b=0>a?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
$.Blockly.Dart.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Dart.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Dart.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],POWER:[null,$.Blockly.Dart.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Dart.valueToCode(a,"A",b)||"0";a=$.Blockly.Dart.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",
["Math.pow("+d+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX])};
$.Blockly.Dart.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_PREFIX)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.Dart.ORDER_UNARY_PREFIX];$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a="ABS"===b||"ROUND"===b.substring(0,5)?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"0":"SIN"===b||"COS"===b||"TAN"===b?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||
"0":$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.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.Dart.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.Dart.ORDER_MULTIPLICATIVE]};
$.Blockly.Dart.math_constant=function(a){var b={PI:["Math.pi",$.Blockly.Dart.ORDER_UNARY_POSTFIX],E:["Math.e",$.Blockly.Dart.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",$.Blockly.Dart.ORDER_MULTIPLICATIVE],SQRT2:["Math.sqrt2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],INFINITY:["double.infinity",$.Blockly.Dart.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;");
return b[a]};
$.Blockly.Dart.math_number_property=function(a){var b=$.Blockly.Dart.valueToCode(a,"NUMBER_TO_CHECK",$.Blockly.Dart.ORDER_MULTIPLICATIVE);if(!b)return["false",$.Blockly.Dart.ORDER_ATOMIC];var c=a.getFieldValue("PROPERTY");if("PRIME"===c)return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",[$.Blockly.Dart.provideFunction_("math_isPrime",["bool "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(n) {"," // https://en.wikipedia.org/wiki/Primality_test#Naive_methods"," if (n == 2 || n == 3) {",
" return true;"," }"," // False if n is null, negative, is 1, or not whole."," // And false if n is divisible by 2 or 3."," if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {"," return false;"," }"," // Check all the numbers of form 6k +/- 1, up to sqrt(n)."," for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {"," if (n % (x - 1) == 0 || n % (x + 1) == 0) {"," return false;"," }"," }"," return true;","}"])+"("+b+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];switch(c){case "EVEN":var d=
b+" % 2 == 0";break;case "ODD":d=b+" % 2 == 1";break;case "WHOLE":d=b+" % 1 == 0";break;case "POSITIVE":d=b+" > 0";break;case "NEGATIVE":d=b+" < 0";break;case "DIVISIBLE_BY":a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE);if(!a)return["false",$.Blockly.Dart.ORDER_ATOMIC];d=b+" % "+a+" == 0"}return[d,$.Blockly.Dart.ORDER_EQUALITY]};
$.Blockly.Dart.math_change=function(a){var b=$.Blockly.Dart.valueToCode(a,"DELTA",$.Blockly.Dart.ORDER_ADDITIVE)||"0";a=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};$.Blockly.Dart.math_round=$.Blockly.Dart.math_single;$.Blockly.Dart.math_trig=$.Blockly.Dart.math_single;
$.Blockly.Dart.math_on_list=function(a){var b=a.getFieldValue("OP");a=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]";switch(b){case "SUM":b=$.Blockly.Dart.provideFunction_("math_sum",["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {"," num sumVal = 0;"," myList.forEach((num entry) {sumVal += entry;});"," return sumVal;","}"])+"("+a+")";break;case "MIN":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_min",
["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {"," if (myList.isEmpty) return null;"," num minVal = myList[0];"," myList.forEach((num entry) {minVal = Math.min(minVal, entry);});"," return minVal;","}"])+"("+a+")";break;case "MAX":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_max",["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {"," if (myList.isEmpty) return null;"," num maxVal = myList[0];",
" myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});"," return maxVal;","}"])+"("+a+")";break;case "AVERAGE":b=$.Blockly.Dart.provideFunction_("math_mean",["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {"," // First filter list for numbers only."," List localList = new List.from(myList);"," localList.removeWhere((a) => a is! num);"," if (localList.isEmpty) return null;"," num sumVal = 0;"," localList.forEach((var entry) {sumVal += entry;});"," return sumVal / localList.length;",
"}"])+"("+a+")";break;case "MEDIAN":b=$.Blockly.Dart.provideFunction_("math_median",["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {"," // First filter list for numbers only, then sort, then return middle value"," // or the average of two middle values if list has an even number of elements."," List localList = new List.from(myList);"," localList.removeWhere((a) => a is! num);"," if (localList.isEmpty) return null;"," localList.sort((a, b) => (a - b));"," int index = localList.length ~/ 2;",
" if (localList.length % 2 == 1) {"," return localList[index];"," } else {"," return (localList[index - 1] + localList[index]) / 2;"," }","}"])+"("+a+")";break;case "MODE":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_modes",["List "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List values) {"," List modes = [];"," List counts = [];"," int maxCount = 0;"," for (int i = 0; i < values.length; i++) {"," var value = values[i];",
" bool found = false;"," int thisCount;"," for (int j = 0; j < counts.length; j++) {"," if (counts[j][0] == value) {"," thisCount = ++counts[j][1];"," found = true;"," break;"," }"," }"," if (!found) {"," counts.add([value, 1]);"," thisCount = 1;"," }"," maxCount = Math.max(thisCount, maxCount);"," }"," for (int j = 0; j < counts.length; j++) {"," if (counts[j][1] == maxCount) {"," modes.add(counts[j][0]);"," }"," }"," return modes;",
"}"])+"("+a+")";break;case "STD_DEV":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_standard_deviation",["num "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {"," // First filter list for numbers only."," List numbers = new List.from(myList);"," numbers.removeWhere((a) => a is! num);"," if (numbers.isEmpty) return null;"," num n = numbers.length;"," num sum = 0;"," numbers.forEach((x) => sum += x);"," num mean = sum / n;",
" num sumSquare = 0;"," numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));"," return Math.sqrt(sumSquare / n);","}"])+"("+a+")";break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_random_item",["dynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {"," int x = new Math.Random().nextInt(myList.length);"," return myList[x];","}"])+"("+a+")";break;default:throw Error("Unknown operator: "+b);
}return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.math_modulo=function(a){var b=$.Blockly.Dart.valueToCode(a,"DIVIDEND",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Dart.ORDER_MULTIPLICATIVE]};
$.Blockly.Dart.math_constrain=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"0",c=$.Blockly.Dart.valueToCode(a,"LOW",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"HIGH",$.Blockly.Dart.ORDER_NONE)||"double.infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.math_random_int=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"0";return[$.Blockly.Dart.provideFunction_("math_random_int",["int "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num a, num b) {"," if (a > b) {"," // Swap a and b to ensure a is smaller."," num c = a;"," a = b;"," b = c;"," }"," return new Math.Random().nextInt(b - a + 1) + a;",
"}"])+"("+b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.math_random_float=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return["new Math.Random().nextDouble()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.math_atan2=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"X",$.Blockly.Dart.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.Dart.valueToCode(a,"Y",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",$.Blockly.Dart.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Dart$loops={};
$.Blockly.Dart.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.Dart.valueToCode(a,"TIMES",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.Dart.statementToCode(a,"DO");c=$.Blockly.Dart.addLoopTrap(c,a);a="";var d=$.Blockly.Dart.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.Dart.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),
a+="var "+e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.Dart.controls_repeat=$.Blockly.Dart.controls_repeat_ext;$.Blockly.Dart.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Dart.valueToCode(a,"BOOL",b?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_NONE)||"false",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
$.Blockly.Dart.controls_for=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",d=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",e=$.Blockly.Dart.valueToCode(a,"BY",$.Blockly.Dart.ORDER_ASSIGNMENT)||"1",f=$.Blockly.Dart.statementToCode(a,"DO");f=$.Blockly.Dart.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.Dart.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.Dart.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.Dart.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.Dart.INDENT+d+" = -"+d+";\n"),a+="}\n",
a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a};$.Blockly.Dart.controls_forEach=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);return"for (var "+b+" in "+c+") {\n"+d+"}\n"};
$.Blockly.Dart.controls_flow_statements=function(a){var b="";$.Blockly.Dart.STATEMENT_PREFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));if($.Blockly.Dart.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.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$Dart$logic={};
$.Blockly.Dart.controls_if=function(a){var b=0,c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));do{var d=$.Blockly.Dart.valueToCode(a,"IF"+b,$.Blockly.Dart.ORDER_NONE)||"false";var e=$.Blockly.Dart.statementToCode(a,"DO"+b);$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e);c+=(0<b?"else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
$.Blockly.Dart.STATEMENT_SUFFIX)e=$.Blockly.Dart.statementToCode(a,"ELSE"),$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e),c+=" else {\n"+e+"}";return c+"\n"};$.Blockly.Dart.controls_ifelse=$.Blockly.Dart.controls_if;
$.Blockly.Dart.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.Dart.ORDER_EQUALITY:$.Blockly.Dart.ORDER_RELATIONAL,d=$.Blockly.Dart.valueToCode(a,"A",c)||"0";a=$.Blockly.Dart.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
$.Blockly.Dart.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.Dart.ORDER_LOGICAL_AND:$.Blockly.Dart.ORDER_LOGICAL_OR,d=$.Blockly.Dart.valueToCode(a,"A",c);a=$.Blockly.Dart.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.Dart.logic_negate=function(a){var b=$.Blockly.Dart.ORDER_UNARY_PREFIX;return["!"+($.Blockly.Dart.valueToCode(a,"BOOL",b)||"true"),b]};
$.Blockly.Dart.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.logic_null=function(a){return["null",$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.logic_ternary=function(a){var b=$.Blockly.Dart.valueToCode(a,"IF",$.Blockly.Dart.ORDER_CONDITIONAL)||"false",c=$.Blockly.Dart.valueToCode(a,"THEN",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";a=$.Blockly.Dart.valueToCode(a,"ELSE",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.Dart.ORDER_CONDITIONAL]};var module$exports$Blockly$Dart$lists={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.lists_create_empty=function(a){return["[]",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"null";return["["+b.join(", ")+"]",$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.lists_repeat=function(a){var b=$.Blockly.Dart.valueToCode(a,"ITEM",$.Blockly.Dart.ORDER_NONE)||"null";return["new List.filled("+($.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.lists_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_getIndex=function(a){function b(){var f=$.Blockly.Dart.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.Dart.valueToCode(a,"VALUE","RANDOM"===d||"FROM_END"===d?$.Blockly.Dart.ORDER_NONE:$.Blockly.Dart.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.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt(0)",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt(0);\n";break;case "LAST":if("GET"===c)return[e+".last",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeLast()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeLast();\n";break;case "FROM_START":a=$.Blockly.Dart.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[e+".removeAt("+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt("+a+");\n";break;case "FROM_END":a=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);if("GET"===c)return[e+"["+e+".length - "+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c||"REMOVE"===c){a=e+".removeAt("+e+".length - "+a+")";if("GET_REMOVE"===c)return[a,$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return a+";\n"}break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math=
"import 'dart:math' as Math;";if("REMOVE"===c)return c=$.Blockly.Dart.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.Dart.provideFunction_("lists_get_random_item",["dynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {"," int x = new Math.Random().nextInt(my_list.length);"," return my_list[x];","}"])+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[$.Blockly.Dart.provideFunction_("lists_remove_random_item",["dynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {"," int x = new Math.Random().nextInt(my_list.length);"," return my_list.removeAt(x);","}"])+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}else{if("RANDOM"===d)return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",c=b(),a=$.Blockly.Dart.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.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE),b()+(e+".removeAt("+e+".length - "+c+");\n");if("GET"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_get_from_end",["dynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {"," x = my_list.length - x;"," return my_list[x];","}"])+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_remove_from_end",["dynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {"," x = my_list.length - x;"," return my_list.removeAt(x);","}"])+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).");};
$.Blockly.Dart.lists_setIndex=function(a){function b(){if(e.match(/^\w+$/))return"";var g=$.Blockly.Dart.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.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]",f=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.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.Dart.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.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.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.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a=b();d=$.Blockly.Dart.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.Dart.lists_getSublist=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.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.Dart.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.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.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":e=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.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.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,"AT2"),b=$.Blockly.Dart.provideFunction_("lists_get_sublist",["List "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+
"(List list, String where1, num at1, String where2, num at2) {"," int getAt(String where, num at) {"," if (where == 'FROM_END') {"," at = list.length - 1 - at;"," } else if (where == 'FIRST') {"," at = 0;"," } else if (where == 'LAST') {"," at = list.length - 1;"," } else if (where != 'FROM_START') {"," throw 'Unhandled option (lists_getSublist).';"," }"," return at;"," }"," at1 = getAt(where1, at1);"," at2 = getAt(where2, at2) + 1;"," return list.sublist(at1, at2);",
"}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_sort=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.Dart.provideFunction_("lists_sort",["List "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List list, String type, int direction) {"," var compareFuncs = {",' "NUMERIC": (a, b) => (direction * a.compareTo(b)).toInt(),',' "TEXT": (a, b) => direction * a.toString().compareTo(b.toString()),',' "IGNORE_CASE": ',
" (a, b) => direction * "," a.toString().toLowerCase().compareTo(b.toString().toLowerCase())"," };"," list = new List.from(list);"," var compare = compareFuncs[type];"," list.sort(compare);"," return list;","}"])+"("+b+', "'+a+'", '+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_split=function(a){var b=$.Blockly.Dart.valueToCode(a,"INPUT",$.Blockly.Dart.ORDER_UNARY_POSTFIX),c=$.Blockly.Dart.valueToCode(a,"DELIM",$.Blockly.Dart.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.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_reverse=function(a){return["new List.from("+($.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]")+".reversed)",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$colour={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.colour_picker=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("COLOUR")),$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.colour_random=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_random",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"() {"," String hex = '0123456789abcdef';"," var rnd = new Math.Random();"," return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'"," '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'"," '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';","}"])+"()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.colour_rgb=function(a){var b=$.Blockly.Dart.valueToCode(a,"RED",$.Blockly.Dart.ORDER_NONE)||0,c=$.Blockly.Dart.valueToCode(a,"GREEN",$.Blockly.Dart.ORDER_NONE)||0;a=$.Blockly.Dart.valueToCode(a,"BLUE",$.Blockly.Dart.ORDER_NONE)||0;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_rgb",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {"," num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();",
" String rs = rn.toInt().toRadixString(16);"," rs = '0$rs';"," rs = rs.substring(rs.length - 2);"," num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();"," String gs = gn.toInt().toRadixString(16);"," gs = '0$gs';"," gs = gs.substring(gs.length - 2);"," num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();"," String bs = bn.toInt().toRadixString(16);"," bs = '0$bs';"," bs = bs.substring(bs.length - 2);"," return '#$rs$gs$bs';","}"])+"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.colour_blend=function(a){var b=$.Blockly.Dart.valueToCode(a,"COLOUR1",$.Blockly.Dart.ORDER_NONE)||"'#000000'",c=$.Blockly.Dart.valueToCode(a,"COLOUR2",$.Blockly.Dart.ORDER_NONE)||"'#000000'";a=$.Blockly.Dart.valueToCode(a,"RATIO",$.Blockly.Dart.ORDER_NONE)||.5;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_blend",["String "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String c1, String c2, num ratio) {"," ratio = Math.max(Math.min(ratio, 1), 0);",
" int r1 = int.parse('0x${c1.substring(1, 3)}');"," int g1 = int.parse('0x${c1.substring(3, 5)}');"," int b1 = int.parse('0x${c1.substring(5, 7)}');"," int r2 = int.parse('0x${c2.substring(1, 3)}');"," int g2 = int.parse('0x${c2.substring(3, 5)}');"," int b2 = int.parse('0x${c2.substring(5, 7)}');"," num rn = (r1 * (1 - ratio) + r2 * ratio).round();"," String rs = rn.toInt().toRadixString(16);"," num gn = (g1 * (1 - ratio) + g2 * ratio).round();"," String gs = gn.toInt().toRadixString(16);",
" num bn = (b1 * (1 - ratio) + b2 * ratio).round();"," String bs = bn.toInt().toRadixString(16);"," rs = '0$rs';"," rs = rs.substring(rs.length - 2);"," gs = '0$gs';"," gs = gs.substring(gs.length - 2);"," bs = '0$bs';"," bs = bs.substring(bs.length - 2);"," return '#$rs$gs$bs';","}"])+"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$all={};
return $.Blockly.Dart;
}));
//# sourceMappingURL=dart_compressed.js.map
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/smart_research/blockly.git
git@gitee.com:smart_research/blockly.git
smart_research
blockly
blockly
master

搜索帮助