2022-01-03 14:02:41 +00:00
// Do not edit this file; automatically generated.
2021-01-16 14:07:51 +00:00
/* eslint-disable */
; ( function ( root , factory ) {
if ( typeof define === 'function' && define . amd ) { // AMD
2022-01-03 14:02:41 +00:00
define ( [ "./blockly_compressed.js" ] , factory ) ;
2021-01-16 14:07:51 +00:00
} else if ( typeof exports === 'object' ) { // Node.js
2022-01-03 14:02:41 +00:00
module . exports = factory ( require ( "./blockly_compressed.js" ) ) ;
2021-01-16 14:07:51 +00:00
} else { // Browser
2022-06-07 11:14:29 +00:00
var factoryExports = factory ( root . Blockly ) ;
root . Blockly . JavaScript = factoryExports ;
2021-01-16 14:07:51 +00:00
}
2022-06-07 11:14:29 +00:00
} ( this , function ( _ _parent _ _ ) {
var $ = _ _parent _ _ . _ _namespace _ _ ;
2022-01-03 14:02:41 +00:00
var module$contents$Blockly$JavaScript _JavaScript = new $ . module$exports$Blockly$Generator . Generator ( "JavaScript" ) ; module$contents$Blockly$JavaScript _JavaScript . addReservedWords ( "break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments," + Object . getOwnPropertyNames ( $ . module$exports$Blockly$utils$global . globalThis ) . join ( "," ) ) ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _ATOMIC = 0 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _NEW = 1.1 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _MEMBER = 1.2 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _FUNCTION _CALL = 2 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _INCREMENT = 3 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _DECREMENT = 3 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _BITWISE _NOT = 4.1 ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _UNARY _PLUS = 4.2 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _UNARY _NEGATION = 4.3 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _NOT = 4.4 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _TYPEOF = 4.5 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _VOID = 4.6 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _DELETE = 4.7 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _AWAIT = 4.8 ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _EXPONENTIATION = 5 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _MULTIPLICATION = 5.1 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _DIVISION = 5.2 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _MODULUS = 5.3 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _SUBTRACTION = 6.1 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _ADDITION = 6.2 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _BITWISE _SHIFT = 7 ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _RELATIONAL = 8 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _IN = 8 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _INSTANCEOF = 8 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _EQUALITY = 9 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _BITWISE _AND = 10 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _BITWISE _XOR = 11 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _BITWISE _OR = 12 ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _AND = 13 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _OR = 14 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _CONDITIONAL = 15 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _ASSIGNMENT = 16 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _YIELD = 17 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _COMMA = 18 ; module$contents$Blockly$JavaScript _JavaScript . ORDER _NONE = 99 ;
module$contents$Blockly$JavaScript _JavaScript . ORDER _OVERRIDES = [ [ module$contents$Blockly$JavaScript _JavaScript . ORDER _FUNCTION _CALL , module$contents$Blockly$JavaScript _JavaScript . ORDER _MEMBER ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _FUNCTION _CALL , module$contents$Blockly$JavaScript _JavaScript . ORDER _FUNCTION _CALL ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _MEMBER , module$contents$Blockly$JavaScript _JavaScript . ORDER _MEMBER ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _MEMBER ,
module$contents$Blockly$JavaScript _JavaScript . ORDER _FUNCTION _CALL ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _NOT , module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _NOT ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _MULTIPLICATION , module$contents$Blockly$JavaScript _JavaScript . ORDER _MULTIPLICATION ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _ADDITION , module$contents$Blockly$JavaScript _JavaScript . ORDER _ADDITION ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _AND ,
module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _AND ] , [ module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _OR , module$contents$Blockly$JavaScript _JavaScript . ORDER _LOGICAL _OR ] ] ; module$contents$Blockly$JavaScript _JavaScript . isInitialized = ! 1 ;
module$contents$Blockly$JavaScript _JavaScript . init = function ( a ) { Object . getPrototypeOf ( this ) . init . call ( this ) ; this . nameDB _ ? this . nameDB _ . reset ( ) : this . nameDB _ = new $ . module$exports$Blockly$Names . Names ( this . RESERVED _WORDS _ ) ; this . nameDB _ . setVariableMap ( a . getVariableMap ( ) ) ; this . nameDB _ . populateVariables ( a ) ; this . nameDB _ . populateProcedures ( a ) ; for ( var b = [ ] , c = ( 0 , $ . module$exports$Blockly$Variables . allDeveloperVariables ) ( a ) , d = 0 ; 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$JavaScript _JavaScript . finish = function ( a ) { var b = ( 0 , $ . module$exports$Blockly$utils$object . values ) ( this . definitions _ ) ; a = Object . getPrototypeOf ( this ) . finish . call ( this , a ) ; this . isInitialized = ! 1 ; this . nameDB _ . reset ( ) ; return b . join ( "\n\n" ) + "\n\n\n" + a } ; module$contents$Blockly$JavaScript _JavaScript . scrubNakedValue = function ( a ) { return a + ";\n" } ;
module$contents$Blockly$JavaScript _JavaScript . quote _ = function ( a ) { a = a . replace ( /\\/g , "\\\\" ) . replace ( /\n/g , "\\\n" ) . replace ( /'/g , "\\'" ) ; return "'" + a + "'" } ; module$contents$Blockly$JavaScript _JavaScript . multiline _quote _ = function ( a ) { return a . split ( /\n/g ) . map ( this . quote _ ) . join ( " + '\\n' +\n" ) } ;
module$contents$Blockly$JavaScript _JavaScript . 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 += 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$JavaScript _JavaScript . 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 = e ; if ( 0 < c ) var h = g = this . ORDER _ADDITION ; else 0 > c ? h = g = this . ORDER _SUBTRACTION : d && ( h = g = this . ORDER _UNARY _NEGATION ) ; a = this . valueToCode ( a , b , g ) || f ; ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( a ) ? ( a = Number ( a ) + c , d && ( a = - a ) ) : ( 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 . JavaScript = module$contents$Blockly$JavaScript _JavaScript ; var module$exports$Blockly$JavaScript$variables = { } ; $ . Blockly . JavaScript . variables _get = function ( a ) { return [ $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ;
$ . Blockly . JavaScript . variables _set = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "0" ; return $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) + " = " + b + ";\n" } ; var module$exports$Blockly$JavaScript$variablesDynamic = { } ; $ . Blockly . JavaScript . variables _get _dynamic = $ . Blockly . JavaScript . variables _get ; $ . Blockly . JavaScript . variables _set _dynamic = $ . Blockly . JavaScript . variables _set ; var module$exports$Blockly$JavaScript$texts = { } , module$contents$Blockly$JavaScript$texts _strRegExp = /^\s*'([^']|\\')*'\s*$/ , module$contents$Blockly$JavaScript$texts _forceString = function ( a ) { return module$contents$Blockly$JavaScript$texts _strRegExp . test ( a ) ? [ a , $ . Blockly . JavaScript . ORDER _ATOMIC ] : [ "String(" + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } , module$contents$Blockly$JavaScript$texts _getSubstringIndex = function ( a , b , c ) { return "FIRST" === b ? "0" : "FROM_END" === b ? a + ".length - 1 - " + c : "LAST" === b ? a + ".length - 1" :
c } ; $ . Blockly . JavaScript . text = function ( a ) { return [ $ . Blockly . JavaScript . quote _ ( a . getFieldValue ( "TEXT" ) ) , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ; $ . Blockly . JavaScript . text _multiline = function ( a ) { a = $ . Blockly . JavaScript . multiline _quote _ ( a . getFieldValue ( "TEXT" ) ) ; var b = - 1 !== a . indexOf ( "+" ) ? $ . Blockly . JavaScript . ORDER _ADDITION : $ . Blockly . JavaScript . ORDER _ATOMIC ; return [ a , b ] } ;
$ . Blockly . JavaScript . text _join = function ( a ) { switch ( a . itemCount _ ) { case 0 : return [ "''" , $ . Blockly . JavaScript . ORDER _ATOMIC ] ; case 1 : return a = $ . Blockly . JavaScript . valueToCode ( a , "ADD0" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" , module$contents$Blockly$JavaScript$texts _forceString ( a ) ; case 2 : var b = $ . Blockly . JavaScript . valueToCode ( a , "ADD0" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; a = $ . Blockly . JavaScript . valueToCode ( a , "ADD1" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return [ module$contents$Blockly$JavaScript$texts _forceString ( b ) [ 0 ] +
" + " + module$contents$Blockly$JavaScript$texts _forceString ( a ) [ 0 ] , $ . Blockly . JavaScript . ORDER _ADDITION ] ; default : b = Array ( a . itemCount _ ) ; for ( var c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = $ . Blockly . JavaScript . valueToCode ( a , "ADD" + c , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return [ "[" + b . join ( "," ) + "].join('')" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } } ;
$ . Blockly . JavaScript . text _append = function ( a ) { var b = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ; a = $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return b + " += " + module$contents$Blockly$JavaScript$texts _forceString ( a ) [ 0 ] + ";\n" } ; $ . Blockly . JavaScript . text _length = function ( a ) { return [ ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ) + ".length" , $ . Blockly . JavaScript . ORDER _MEMBER ] } ;
$ . Blockly . JavaScript . text _isEmpty = function ( a ) { return [ "!" + ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ) + ".length" , $ . Blockly . JavaScript . ORDER _LOGICAL _NOT ] } ;
$ . Blockly . JavaScript . text _indexOf = function ( a ) { var b = "FIRST" === a . getFieldValue ( "END" ) ? "indexOf" : "lastIndexOf" , c = $ . Blockly . JavaScript . valueToCode ( a , "FIND" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; b = ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ) + "." + b + "(" + c + ")" ; return a . workspace . options . oneBasedIndex ? [ b + " + 1" , $ . Blockly . JavaScript . ORDER _ADDITION ] : [ b , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . text _charAt = function ( a ) { var b = a . getFieldValue ( "WHERE" ) || "FROM_START" , c = $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , "RANDOM" === b ? $ . Blockly . JavaScript . ORDER _NONE : $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ; switch ( b ) { case "FIRST" : return [ c + ".charAt(0)" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; case "LAST" : return [ c + ".slice(-1)" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; case "FROM_START" : return a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" ) , [ c + ".charAt(" + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ;
2022-06-07 11:14:29 +00:00
case "FROM_END" : return a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" , 1 , ! 0 ) , [ c + ".slice(" + a + ").charAt(0)" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; case "RANDOM" : return [ $ . Blockly . JavaScript . provideFunction _ ( "textRandomLetter" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(text) {\n var x = Math.floor(Math.random() * text.length);\n return text[x];\n}\n" ) + "(" + c + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } throw Error ( "Unhandled option (text_charAt)." ) ; } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . text _getSubstring = function ( a ) { var b = a . getFieldValue ( "WHERE1" ) , c = a . getFieldValue ( "WHERE2" ) , d = "FROM_END" !== b && "LAST" !== b && "FROM_END" !== c && "LAST" !== c , e = $ . Blockly . JavaScript . valueToCode ( a , "STRING" , d ? $ . Blockly . JavaScript . ORDER _MEMBER : $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; if ( "FIRST" === b && "LAST" === c ) return [ e , $ . Blockly . JavaScript . ORDER _NONE ] ; if ( e . match ( /^'?\w+'?$/ ) || d ) { switch ( b ) { case "FROM_START" : b = $ . Blockly . JavaScript . getAdjusted ( a , "AT1" ) ; break ; case "FROM_END" : b = $ . Blockly . JavaScript . getAdjusted ( a ,
"AT1" , 1 , ! 1 , $ . Blockly . JavaScript . ORDER _SUBTRACTION ) ; b = e + ".length - " + b ; break ; case "FIRST" : b = "0" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)." ) ; } switch ( c ) { case "FROM_START" : c = $ . Blockly . JavaScript . getAdjusted ( a , "AT2" , 1 ) ; break ; case "FROM_END" : c = $ . Blockly . JavaScript . getAdjusted ( a , "AT2" , 0 , ! 1 , $ . Blockly . JavaScript . ORDER _SUBTRACTION ) ; c = e + ".length - " + c ; break ; case "LAST" : c = e + ".length" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)." ) ; } e = e + ".slice(" + b + ", " + c + ")" } else { d = $ . Blockly . JavaScript . getAdjusted ( a ,
2022-06-07 11:14:29 +00:00
"AT1" ) ; a = $ . Blockly . JavaScript . getAdjusted ( a , "AT2" ) ; var f = { FIRST : "First" , LAST : "Last" , FROM _START : "FromStart" , FROM _END : "FromEnd" } ; e = $ . Blockly . JavaScript . provideFunction _ ( "subsequence" + f [ b ] + f [ c ] , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(sequence" + ( "FROM_END" === b || "FROM_START" === b ? ", at1" : "" ) + ( "FROM_END" === c || "FROM_START" === c ? ", at2" : "" ) + ") {\n var start = " + module$contents$Blockly$JavaScript$texts _getSubstringIndex ( "sequence" , b , "at1" ) + ";\n var end = " + module$contents$Blockly$JavaScript$texts _getSubstringIndex ( "sequence" ,
c , "at2" ) + " + 1;\n return sequence.slice(start, end);\n}\n" ) + "(" + e + ( "FROM_END" === b || "FROM_START" === b ? ", " + d : "" ) + ( "FROM_END" === c || "FROM_START" === c ? ", " + a : "" ) + ")" } return [ e , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . text _changeCase = function ( a ) { var b = { UPPERCASE : ".toUpperCase()" , LOWERCASE : ".toLowerCase()" , TITLECASE : null } [ a . getFieldValue ( "CASE" ) ] ; a = $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , b ? $ . Blockly . JavaScript . ORDER _MEMBER : $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return [ b ? a + b : $ . Blockly . JavaScript . provideFunction _ ( "textToTitleCase" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(str) {\n return str.replace(/\\S+/g,\n function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});\n}\n" ) +
"(" + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . text _trim = function ( a ) { var b = { LEFT : ".replace(/^[\\s\\xa0]+/, '')" , RIGHT : ".replace(/[\\s\\xa0]+$/, '')" , BOTH : ".trim()" } [ a . getFieldValue ( "MODE" ) ] ; return [ ( $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ) + b , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . text _print = function ( a ) { return "window.alert(" + ( $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ) + ");\n" } ; $ . Blockly . JavaScript . text _prompt _ext = function ( a ) { var b = "window.prompt(" + ( a . getField ( "TEXT" ) ? $ . Blockly . JavaScript . quote _ ( a . getFieldValue ( "TEXT" ) ) : $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ) + ")" ; "NUMBER" === a . getFieldValue ( "TYPE" ) && ( b = "Number(" + b + ")" ) ; return [ b , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . text _prompt = $ . Blockly . JavaScript . text _prompt _ext ;
2022-06-07 11:14:29 +00:00
$ . Blockly . JavaScript . text _count = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; a = $ . Blockly . JavaScript . valueToCode ( a , "SUB" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return [ $ . Blockly . JavaScript . provideFunction _ ( "textCount" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(haystack, needle) {\n if (needle.length === 0) {\n return haystack.length + 1;\n } else {\n return haystack.split(needle).length - 1;\n }\n}\n" ) + "(" + b + ", " + a +
")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . text _replace = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" , c = $ . Blockly . JavaScript . valueToCode ( a , "FROM" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; a = $ . Blockly . JavaScript . valueToCode ( a , "TO" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; return [ $ . Blockly . JavaScript . provideFunction _ ( "textReplace" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(haystack, needle, replacement) {\n needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')\n .replace(/\\x08/g, '\\\\x08');\n return haystack.replace(new RegExp(needle, 'g'), replacement);\n}\n" ) + "(" +
b + ", " + c + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . text _reverse = function ( a ) { return [ ( $ . Blockly . JavaScript . valueToCode ( a , "TEXT" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "''" ) + ".split('').reverse().join('')" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; var module$exports$Blockly$JavaScript$procedures = { } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . procedures _defreturn = function ( a ) { var b = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "NAME" ) , $ . module$exports$Blockly$Names . NameType . PROCEDURE ) , c = "" ; $ . Blockly . JavaScript . STATEMENT _PREFIX && ( c += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _PREFIX , a ) ) ; $ . Blockly . JavaScript . STATEMENT _SUFFIX && ( c += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _SUFFIX , a ) ) ; c && ( c = $ . Blockly . JavaScript . prefixLines ( c , $ . Blockly . JavaScript . INDENT ) ) ; var d = "" ; $ . Blockly . JavaScript . INFINITE _LOOP _TRAP &&
( d = $ . Blockly . JavaScript . prefixLines ( $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . INFINITE _LOOP _TRAP , a ) , $ . Blockly . JavaScript . INDENT ) ) ; var e = $ . Blockly . JavaScript . statementToCode ( a , "STACK" ) , f = $ . Blockly . JavaScript . valueToCode ( a , "RETURN" , $ . Blockly . JavaScript . ORDER _NONE ) || "" , g = "" ; e && f && ( g = c ) ; f && ( f = $ . Blockly . JavaScript . INDENT + "return " + f + ";\n" ) ; for ( var h = [ ] , k = a . getVars ( ) , l = 0 ; l < k . length ; l ++ ) h [ l ] = $ . Blockly . JavaScript . nameDB _ . getName ( k [ l ] , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ; c = "async function " +
b + "(" + h . join ( ", " ) + ") {\n" + c + d + e + g + f + "}" ; c = $ . Blockly . JavaScript . scrub _ ( a , c ) ; $ . Blockly . JavaScript . definitions _ [ "%" + b ] = c ; return null } ; $ . Blockly . JavaScript . procedures _defnoreturn = $ . Blockly . JavaScript . procedures _defreturn ;
$ . Blockly . JavaScript . procedures _callreturn = function ( a ) { for ( var b = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "NAME" ) , $ . module$exports$Blockly$Names . NameType . PROCEDURE ) , c = [ ] , d = a . getVars ( ) , e = 0 ; e < d . length ; e ++ ) c [ e ] = $ . Blockly . JavaScript . valueToCode ( a , "ARG" + e , $ . Blockly . JavaScript . ORDER _NONE ) || "null" ; return [ 'await ' + b + "(" + c . join ( ", " ) + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . procedures _callnoreturn = function ( a ) { return $ . Blockly . JavaScript . procedures _callreturn ( a ) [ 0 ] + ";\n" } ;
$ . Blockly . JavaScript . procedures _ifreturn = function ( a ) { var b = "if (" + ( $ . Blockly . JavaScript . valueToCode ( a , "CONDITION" , $ . Blockly . JavaScript . ORDER _NONE ) || "false" ) + ") {\n" ; $ . Blockly . JavaScript . STATEMENT _SUFFIX && ( b += $ . Blockly . JavaScript . prefixLines ( $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _SUFFIX , a ) , $ . Blockly . JavaScript . INDENT ) ) ; a . hasReturnValue _ ? ( a = $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _NONE ) || "null" , b += $ . Blockly . JavaScript . INDENT + "return " + a + ";\n" ) : b += $ . Blockly . JavaScript . INDENT +
"return;\n" ; return b + "}\n" } ; var module$exports$Blockly$JavaScript$math = { } ; $ . Blockly . JavaScript . math _number = function ( a ) { a = Number ( a . getFieldValue ( "NUM" ) ) ; return [ a , 0 <= a ? $ . Blockly . JavaScript . ORDER _ATOMIC : $ . Blockly . JavaScript . ORDER _UNARY _NEGATION ] } ;
$ . Blockly . JavaScript . math _arithmetic = function ( a ) { var b = { ADD : [ " + " , $ . Blockly . JavaScript . ORDER _ADDITION ] , MINUS : [ " - " , $ . Blockly . JavaScript . ORDER _SUBTRACTION ] , MULTIPLY : [ " * " , $ . Blockly . JavaScript . ORDER _MULTIPLICATION ] , DIVIDE : [ " / " , $ . Blockly . JavaScript . ORDER _DIVISION ] , POWER : [ null , $ . Blockly . JavaScript . ORDER _NONE ] } [ a . getFieldValue ( "OP" ) ] , c = b [ 0 ] ; b = b [ 1 ] ; var d = $ . Blockly . JavaScript . valueToCode ( a , "A" , b ) || "0" ; a = $ . Blockly . JavaScript . valueToCode ( a , "B" , b ) || "0" ; return c ? [ d + c + a , b ] : [ "Math.pow(" + d + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . math _single = function ( a ) { var b = a . getFieldValue ( "OP" ) ; if ( "NEG" === b ) return a = $ . Blockly . JavaScript . valueToCode ( a , "NUM" , $ . Blockly . JavaScript . ORDER _UNARY _NEGATION ) || "0" , "-" === a [ 0 ] && ( a = " " + a ) , [ "-" + a , $ . Blockly . JavaScript . ORDER _UNARY _NEGATION ] ; a = "SIN" === b || "COS" === b || "TAN" === b ? $ . Blockly . JavaScript . valueToCode ( a , "NUM" , $ . Blockly . JavaScript . ORDER _DIVISION ) || "0" : $ . Blockly . JavaScript . valueToCode ( a , "NUM" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; switch ( b ) { case "ABS" : var c = "Math.abs(" + a + ")" ; break ;
case "ROOT" : c = "Math.sqrt(" + a + ")" ; break ; case "LN" : c = "Math.log(" + a + ")" ; break ; case "EXP" : c = "Math.exp(" + a + ")" ; break ; case "POW10" : c = "Math.pow(10," + a + ")" ; break ; case "ROUND" : c = "Math.round(" + a + ")" ; break ; case "ROUNDUP" : c = "Math.ceil(" + a + ")" ; break ; case "ROUNDDOWN" : c = "Math.floor(" + a + ")" ; break ; case "SIN" : c = "Math.sin(" + a + " / 180 * Math.PI)" ; break ; case "COS" : c = "Math.cos(" + a + " / 180 * Math.PI)" ; break ; case "TAN" : c = "Math.tan(" + a + " / 180 * Math.PI)" } if ( c ) return [ c , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; switch ( b ) { case "LOG10" : c =
"Math.log(" + a + ") / Math.log(10)" ; break ; case "ASIN" : c = "Math.asin(" + a + ") / Math.PI * 180" ; break ; case "ACOS" : c = "Math.acos(" + a + ") / Math.PI * 180" ; break ; case "ATAN" : c = "Math.atan(" + a + ") / Math.PI * 180" ; break ; default : throw Error ( "Unknown math operator: " + b ) ; } return [ c , $ . Blockly . JavaScript . ORDER _DIVISION ] } ;
$ . Blockly . JavaScript . math _constant = function ( a ) { return { PI : [ "Math.PI" , $ . Blockly . JavaScript . ORDER _MEMBER ] , E : [ "Math.E" , $ . Blockly . JavaScript . ORDER _MEMBER ] , GOLDEN _RATIO : [ "(1 + Math.sqrt(5)) / 2" , $ . Blockly . JavaScript . ORDER _DIVISION ] , SQRT2 : [ "Math.SQRT2" , $ . Blockly . JavaScript . ORDER _MEMBER ] , SQRT1 _2 : [ "Math.SQRT1_2" , $ . Blockly . JavaScript . ORDER _MEMBER ] , INFINITY : [ "Infinity" , $ . Blockly . JavaScript . ORDER _ATOMIC ] } [ a . getFieldValue ( "CONSTANT" ) ] } ;
2022-06-07 11:14:29 +00:00
$ . Blockly . JavaScript . math _number _property = function ( a ) { var b = { EVEN : [ " % 2 === 0" , $ . Blockly . JavaScript . ORDER _MODULUS , $ . Blockly . JavaScript . ORDER _EQUALITY ] , ODD : [ " % 2 === 1" , $ . Blockly . JavaScript . ORDER _MODULUS , $ . Blockly . JavaScript . ORDER _EQUALITY ] , WHOLE : [ " % 1 === 0" , $ . Blockly . JavaScript . ORDER _MODULUS , $ . Blockly . JavaScript . ORDER _EQUALITY ] , POSITIVE : [ " > 0" , $ . Blockly . JavaScript . ORDER _RELATIONAL , $ . Blockly . JavaScript . ORDER _RELATIONAL ] , NEGATIVE : [ " < 0" , $ . Blockly . JavaScript . ORDER _RELATIONAL , $ . Blockly . JavaScript . ORDER _RELATIONAL ] ,
DIVISIBLE _BY : [ null , $ . Blockly . JavaScript . ORDER _MODULUS , $ . Blockly . JavaScript . ORDER _EQUALITY ] , PRIME : [ null , $ . Blockly . JavaScript . ORDER _NONE , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } , c = a . getFieldValue ( "PROPERTY" ) ; b = $ . $jscomp . makeIterator ( b [ c ] ) ; var d = b . next ( ) . value , e = b . next ( ) . value ; b = b . next ( ) . value ; e = $ . Blockly . JavaScript . valueToCode ( a , "NUMBER_TO_CHECK" , e ) || "0" ; "PRIME" === c ? a = $ . Blockly . JavaScript . provideFunction _ ( "mathIsPrime" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n" ) +
"(" + e + ")" : "DIVISIBLE_BY" === c ? ( a = $ . Blockly . JavaScript . valueToCode ( a , "DIVISOR" , $ . Blockly . JavaScript . ORDER _MODULUS ) || "0" , a = e + " % " + a + " === 0" ) : a = e + d ; return [ a , b ] } ; $ . Blockly . JavaScript . math _change = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "DELTA" , $ . Blockly . JavaScript . ORDER _ADDITION ) || "0" ; a = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ; return a + " = (typeof " + a + " === 'number' ? " + a + " : 0) + " + b + ";\n" } ;
$ . Blockly . JavaScript . math _round = $ . Blockly . JavaScript . math _single ; $ . Blockly . JavaScript . math _trig = $ . Blockly . JavaScript . math _single ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . math _on _list = function ( a ) { var b = a . getFieldValue ( "OP" ) ; switch ( b ) { case "SUM" : a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" ; a += ".reduce(function(x, y) {return x + y;})" ; break ; case "MIN" : a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = "Math.min.apply(null, " + a + ")" ; break ; case "MAX" : a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = "Math.max.apply(null, " + a + ")" ; break ; case "AVERAGE" : b =
2022-06-07 11:14:29 +00:00
$ . Blockly . JavaScript . provideFunction _ ( "mathMean" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(myList) {\n return myList.reduce(function(x, y) {return x + y;}) / myList.length;\n}\n" ) ; a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = b + "(" + a + ")" ; break ; case "MEDIAN" : b = $ . Blockly . JavaScript . provideFunction _ ( "mathMedian" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n" ) ;
a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = b + "(" + a + ")" ; break ; case "MODE" : b = $ . Blockly . JavaScript . provideFunction _ ( "mathModes" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n" ) ;
a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = b + "(" + a + ")" ; break ; case "STD_DEV" : b = $ . Blockly . JavaScript . provideFunction _ ( "mathStandardDeviation" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance = variance / n;\n return Math.sqrt(variance);\n}\n" ) ;
a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = b + "(" + a + ")" ; break ; case "RANDOM" : b = $ . Blockly . JavaScript . provideFunction _ ( "mathRandomList" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n" ) ; a = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _NONE ) || "[]" ; a = b + "(" + a + ")" ; break ; default : throw Error ( "Unknown operator: " + b ) ; } return [ a , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . math _modulo = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "DIVIDEND" , $ . Blockly . JavaScript . ORDER _MODULUS ) || "0" ; a = $ . Blockly . JavaScript . valueToCode ( a , "DIVISOR" , $ . Blockly . JavaScript . ORDER _MODULUS ) || "0" ; return [ b + " % " + a , $ . Blockly . JavaScript . ORDER _MODULUS ] } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . math _constrain = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" , c = $ . Blockly . JavaScript . valueToCode ( a , "LOW" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; a = $ . Blockly . JavaScript . valueToCode ( a , "HIGH" , $ . Blockly . JavaScript . ORDER _NONE ) || "Infinity" ; return [ "Math.min(Math.max(" + b + ", " + c + "), " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
2022-06-07 11:14:29 +00:00
$ . Blockly . JavaScript . math _random _int = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "FROM" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; a = $ . Blockly . JavaScript . valueToCode ( a , "TO" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; return [ $ . Blockly . JavaScript . provideFunction _ ( "mathRandomInt" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n" ) +
"(" + b + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . math _random _float = function ( a ) { return [ "Math.random()" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . math _atan2 = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "X" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; return [ "Math.atan2(" + ( $ . Blockly . JavaScript . valueToCode ( a , "Y" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ) + ", " + b + ") / Math.PI * 180" , $ . Blockly . JavaScript . ORDER _DIVISION ] } ; var module$exports$Blockly$JavaScript$loops = { } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . controls _repeat _ext = function ( a ) { var b = a . getField ( "TIMES" ) ? String ( Number ( a . getFieldValue ( "TIMES" ) ) ) : $ . Blockly . JavaScript . valueToCode ( a , "TIMES" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "0" ; var c = $ . Blockly . JavaScript . statementToCode ( a , "DO" ) ; c = $ . Blockly . JavaScript . addLoopTrap ( c , a ) ; a = "" ; var d = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( "count" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , e = b ; b . match ( /^\w+$/ ) || ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( b ) || ( e = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( "repeat_end" ,
$ . module$exports$Blockly$Names . NameType . VARIABLE ) , a += "var " + e + " = " + b + ";\n" ) ; return a + ( "for (var " + d + " = 0; " + d + " < " + e + "; " + d + "++) {\n" + c + "}\n" ) } ; $ . Blockly . JavaScript . controls _repeat = $ . Blockly . JavaScript . controls _repeat _ext ;
$ . Blockly . JavaScript . controls _whileUntil = function ( a ) { var b = "UNTIL" === a . getFieldValue ( "MODE" ) , c = $ . Blockly . JavaScript . valueToCode ( a , "BOOL" , b ? $ . Blockly . JavaScript . ORDER _LOGICAL _NOT : $ . Blockly . JavaScript . ORDER _NONE ) || "false" , d = $ . Blockly . JavaScript . statementToCode ( a , "DO" ) ; d = $ . Blockly . JavaScript . addLoopTrap ( d , a ) ; b && ( c = "!" + c ) ; return "while (" + c + ") {\n" + d + "}\n" } ;
$ . Blockly . JavaScript . controls _for = function ( a ) { var b = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , c = $ . Blockly . JavaScript . valueToCode ( a , "FROM" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "0" , d = $ . Blockly . JavaScript . valueToCode ( a , "TO" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "0" , e = $ . Blockly . JavaScript . valueToCode ( a , "BY" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "1" , f = $ . Blockly . JavaScript . statementToCode ( a , "DO" ) ; f = $ . Blockly . JavaScript . addLoopTrap ( f ,
a ) ; if ( ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( c ) && ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( d ) && ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( e ) ) { var g = Number ( c ) <= Number ( d ) ; a = "for (" + b + " = " + c + "; " + b + ( g ? " <= " : " >= " ) + d + "; " + b ; b = Math . abs ( Number ( e ) ) ; a = ( 1 === b ? a + ( g ? "++" : "--" ) : a + ( ( g ? " += " : " -= " ) + b ) ) + ( ") {\n" + f + "}\n" ) } else a = "" , g = c , c . match ( /^\w+$/ ) || ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( c ) || ( g = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( b + "_start" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ,
a += "var " + g + " = " + c + ";\n" ) , c = d , d . match ( /^\w+$/ ) || ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( d ) || ( c = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( b + "_end" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , a += "var " + c + " = " + d + ";\n" ) , d = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( b + "_inc" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , a += "var " + d + " = " , a = ( 0 , $ . module$exports$Blockly$utils$string . isNumber ) ( e ) ? a + ( Math . abs ( e ) + ";\n" ) : a + ( "Math.abs(" + e + ");\n" ) , a = a + ( "if (" + g + " > " + c + ") {\n" ) + ( $ . Blockly . JavaScript . INDENT +
d + " = -" + d + ";\n" ) , a += "}\n" , a += "for (" + b + " = " + g + "; " + d + " >= 0 ? " + b + " <= " + c + " : " + b + " >= " + c + "; " + b + " += " + d + ") {\n" + f + "}\n" ; return a } ;
$ . Blockly . JavaScript . controls _forEach = function ( a ) { var b = $ . Blockly . JavaScript . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , c = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "[]" , d = $ . Blockly . JavaScript . statementToCode ( a , "DO" ) ; d = $ . Blockly . JavaScript . addLoopTrap ( d , a ) ; a = "" ; var e = c ; c . match ( /^\w+$/ ) || ( e = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( b + "_list" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , a += "var " + e + " = " + c +
";\n" ) ; c = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( b + "_index" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ; d = $ . Blockly . JavaScript . INDENT + b + " = " + e + "[" + c + "];\n" + d ; return a + ( "for (var " + c + " in " + e + ") {\n" + d + "}\n" ) } ;
$ . Blockly . JavaScript . controls _flow _statements = function ( a ) { var b = "" ; $ . Blockly . JavaScript . STATEMENT _PREFIX && ( b += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _PREFIX , a ) ) ; $ . Blockly . JavaScript . STATEMENT _SUFFIX && ( b += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _SUFFIX , a ) ) ; if ( $ . Blockly . JavaScript . STATEMENT _PREFIX ) { var c = a . getSurroundLoop ( ) ; c && ! c . suppressPrefixSuffix && ( b += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _PREFIX , c ) ) } switch ( a . getFieldValue ( "FLOW" ) ) { case "BREAK" : return b +
"break;\n" ; case "CONTINUE" : return b + "continue;\n" } throw Error ( "Unknown flow statement." ) ; } ; var module$exports$Blockly$JavaScript$logic = { } ;
$ . Blockly . JavaScript . controls _if = function ( a ) { var b = 0 , c = "" ; $ . Blockly . JavaScript . STATEMENT _PREFIX && ( c += $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _PREFIX , a ) ) ; do { var d = $ . Blockly . JavaScript . valueToCode ( a , "IF" + b , $ . Blockly . JavaScript . ORDER _NONE ) || "false" , e = $ . Blockly . JavaScript . statementToCode ( a , "DO" + b ) ; $ . Blockly . JavaScript . STATEMENT _SUFFIX && ( e = $ . Blockly . JavaScript . prefixLines ( $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _SUFFIX , a ) , $ . Blockly . JavaScript . INDENT ) + e ) ; c += ( 0 < b ?
" else " : "" ) + "if (" + d + ") {\n" + e + "}" ; b ++ } while ( a . getInput ( "IF" + b ) ) ; if ( a . getInput ( "ELSE" ) || $ . Blockly . JavaScript . STATEMENT _SUFFIX ) b = $ . Blockly . JavaScript . statementToCode ( a , "ELSE" ) , $ . Blockly . JavaScript . STATEMENT _SUFFIX && ( b = $ . Blockly . JavaScript . prefixLines ( $ . Blockly . JavaScript . injectId ( $ . Blockly . JavaScript . STATEMENT _SUFFIX , a ) , $ . Blockly . JavaScript . INDENT ) + b ) , c += " else {\n" + b + "}" ; return c + "\n" } ; $ . Blockly . JavaScript . controls _ifelse = $ . Blockly . JavaScript . controls _if ;
$ . Blockly . JavaScript . logic _compare = function ( a ) { var b = { EQ : "==" , NEQ : "!=" , LT : "<" , LTE : "<=" , GT : ">" , GTE : ">=" } [ a . getFieldValue ( "OP" ) ] , c = "==" === b || "!=" === b ? $ . Blockly . JavaScript . ORDER _EQUALITY : $ . Blockly . JavaScript . ORDER _RELATIONAL , d = $ . Blockly . JavaScript . valueToCode ( a , "A" , c ) || "0" ; a = $ . Blockly . JavaScript . valueToCode ( a , "B" , c ) || "0" ; return [ d + " " + b + " " + a , c ] } ;
$ . Blockly . JavaScript . logic _operation = function ( a ) { var b = "AND" === a . getFieldValue ( "OP" ) ? "&&" : "||" , c = "&&" === b ? $ . Blockly . JavaScript . ORDER _LOGICAL _AND : $ . Blockly . JavaScript . ORDER _LOGICAL _OR , d = $ . Blockly . JavaScript . valueToCode ( a , "A" , c ) ; a = $ . Blockly . JavaScript . valueToCode ( a , "B" , c ) ; if ( d || a ) { var e = "&&" === b ? "true" : "false" ; d || ( d = e ) ; a || ( a = e ) } else a = d = "false" ; return [ d + " " + b + " " + a , c ] } ;
$ . Blockly . JavaScript . logic _negate = function ( a ) { var b = $ . Blockly . JavaScript . ORDER _LOGICAL _NOT ; return [ "!" + ( $ . Blockly . JavaScript . valueToCode ( a , "BOOL" , b ) || "true" ) , b ] } ; $ . Blockly . JavaScript . logic _boolean = function ( a ) { return [ "TRUE" === a . getFieldValue ( "BOOL" ) ? "true" : "false" , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ; $ . Blockly . JavaScript . logic _null = function ( a ) { return [ "null" , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ;
$ . Blockly . JavaScript . logic _ternary = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "IF" , $ . Blockly . JavaScript . ORDER _CONDITIONAL ) || "false" , c = $ . Blockly . JavaScript . valueToCode ( a , "THEN" , $ . Blockly . JavaScript . ORDER _CONDITIONAL ) || "null" ; a = $ . Blockly . JavaScript . valueToCode ( a , "ELSE" , $ . Blockly . JavaScript . ORDER _CONDITIONAL ) || "null" ; return [ b + " ? " + c + " : " + a , $ . Blockly . JavaScript . ORDER _CONDITIONAL ] } ; var module$exports$Blockly$JavaScript$lists = { } ; $ . Blockly . JavaScript . lists _create _empty = function ( a ) { return [ "[]" , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ; $ . Blockly . JavaScript . lists _create _with = function ( a ) { for ( var b = Array ( a . itemCount _ ) , c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = $ . Blockly . JavaScript . valueToCode ( a , "ADD" + c , $ . Blockly . JavaScript . ORDER _NONE ) || "null" ; return [ "[" + b . join ( ", " ) + "]" , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ;
2022-06-07 11:14:29 +00:00
$ . Blockly . JavaScript . lists _repeat = function ( a ) { var b = $ . Blockly . JavaScript . provideFunction _ ( "listsRepeat" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(value, n) {\n var array = [];\n for (var i = 0; i < n; i++) {\n array[i] = value;\n }\n return array;\n}\n" ) , c = $ . Blockly . JavaScript . valueToCode ( a , "ITEM" , $ . Blockly . JavaScript . ORDER _NONE ) || "null" ; a = $ . Blockly . JavaScript . valueToCode ( a , "NUM" , $ . Blockly . JavaScript . ORDER _NONE ) || "0" ; return [ b + "(" + c + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . lists _length = function ( a ) { return [ ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" ) + ".length" , $ . Blockly . JavaScript . ORDER _MEMBER ] } ; $ . Blockly . JavaScript . lists _isEmpty = function ( a ) { return [ "!" + ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" ) + ".length" , $ . Blockly . JavaScript . ORDER _LOGICAL _NOT ] } ;
$ . Blockly . JavaScript . lists _indexOf = function ( a ) { var b = "FIRST" === a . getFieldValue ( "END" ) ? "indexOf" : "lastIndexOf" , c = $ . Blockly . JavaScript . valueToCode ( a , "FIND" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; b = ( $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" ) + "." + b + "(" + c + ")" ; return a . workspace . options . oneBasedIndex ? [ b + " + 1" , $ . Blockly . JavaScript . ORDER _ADDITION ] : [ b , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . lists _getIndex = function ( a ) { var b = a . getFieldValue ( "MODE" ) || "GET" , c = a . getFieldValue ( "WHERE" ) || "FROM_START" , d = $ . Blockly . JavaScript . valueToCode ( a , "VALUE" , "RANDOM" === c ? $ . Blockly . JavaScript . ORDER _NONE : $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" ; switch ( c ) { case "FIRST" : if ( "GET" === b ) return [ d + "[0]" , $ . Blockly . JavaScript . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".shift()" , $ . Blockly . JavaScript . ORDER _MEMBER ] ; if ( "REMOVE" === b ) return d + ".shift();\n" ; break ; case "LAST" : if ( "GET" === b ) return [ d + ".slice(-1)[0]" ,
$ . Blockly . JavaScript . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".pop()" , $ . Blockly . JavaScript . ORDER _MEMBER ] ; if ( "REMOVE" === b ) return d + ".pop();\n" ; break ; case "FROM_START" : a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" ) ; if ( "GET" === b ) return [ d + "[" + a + "]" , $ . Blockly . JavaScript . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".splice(" + a + ", 1)[0]" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".splice(" + a + ", 1);\n" ; break ; case "FROM_END" : a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" , 1 , ! 0 ) ; if ( "GET" ===
2022-06-07 11:14:29 +00:00
b ) return [ d + ".slice(" + a + ")[0]" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; if ( "GET_REMOVE" === b ) return [ d + ".splice(" + a + ", 1)[0]" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".splice(" + a + ", 1);" ; break ; case "RANDOM" : d = $ . Blockly . JavaScript . provideFunction _ ( "listsGetRandomItem" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(list, remove) {\n var x = Math.floor(Math.random() * list.length);\n if (remove) {\n return list.splice(x, 1)[0];\n } else {\n return list[x];\n }\n}\n" ) +
"(" + d + ", " + ( "GET" !== b ) + ")" ; if ( "GET" === b || "GET_REMOVE" === b ) return [ d , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ";\n" } throw Error ( "Unhandled combination (lists_getIndex)." ) ; } ;
2022-01-03 14:02:41 +00:00
$ . Blockly . JavaScript . lists _setIndex = function ( a ) { function b ( ) { if ( c . match ( /^\w+$/ ) ) return "" ; var g = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( "tmpList" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) , h = "var " + g + " = " + c + ";\n" ; c = g ; return h } var c = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" , d = a . getFieldValue ( "MODE" ) || "GET" , e = a . getFieldValue ( "WHERE" ) || "FROM_START" , f = $ . Blockly . JavaScript . valueToCode ( a , "TO" , $ . Blockly . JavaScript . ORDER _ASSIGNMENT ) || "null" ; switch ( e ) { case "FIRST" : if ( "SET" ===
d ) return c + "[0] = " + f + ";\n" ; if ( "INSERT" === d ) return c + ".unshift(" + f + ");\n" ; break ; case "LAST" : if ( "SET" === d ) return b ( ) + ( c + "[" + c + ".length - 1] = " + f + ";\n" ) ; if ( "INSERT" === d ) return c + ".push(" + f + ");\n" ; break ; case "FROM_START" : a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" ) ; if ( "SET" === d ) return c + "[" + a + "] = " + f + ";\n" ; if ( "INSERT" === d ) return c + ".splice(" + a + ", 0, " + f + ");\n" ; break ; case "FROM_END" : a = $ . Blockly . JavaScript . getAdjusted ( a , "AT" , 1 , ! 1 , $ . Blockly . JavaScript . ORDER _SUBTRACTION ) ; e = b ( ) ; if ( "SET" === d ) return e + ( c + "[" +
c + ".length - " + a + "] = " + f + ";\n" ) ; if ( "INSERT" === d ) return e + ( c + ".splice(" + c + ".length - " + a + ", 0, " + f + ");\n" ) ; break ; case "RANDOM" : a = b ( ) ; e = $ . Blockly . JavaScript . nameDB _ . getDistinctName ( "tmpX" , $ . module$exports$Blockly$Names . NameType . VARIABLE ) ; a += "var " + e + " = Math.floor(Math.random() * " + c + ".length);\n" ; if ( "SET" === d ) return a + ( c + "[" + e + "] = " + f + ";\n" ) ; if ( "INSERT" === d ) return a + ( c + ".splice(" + e + ", 0, " + f + ");\n" ) } throw Error ( "Unhandled combination (lists_setIndex)." ) ; } ;
var module$contents$Blockly$JavaScript$lists _getSubstringIndex = function ( a , b , c ) { return "FIRST" === b ? "0" : "FROM_END" === b ? a + ".length - 1 - " + c : "LAST" === b ? a + ".length - 1" : c } ;
$ . Blockly . JavaScript . lists _getSublist = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _MEMBER ) || "[]" , c = a . getFieldValue ( "WHERE1" ) , d = a . getFieldValue ( "WHERE2" ) ; if ( "FIRST" === c && "LAST" === d ) b += ".slice(0)" ; else if ( b . match ( /^\w+$/ ) || "FROM_END" !== c && "FROM_START" === d ) { switch ( c ) { case "FROM_START" : c = $ . Blockly . JavaScript . getAdjusted ( a , "AT1" ) ; break ; case "FROM_END" : c = $ . Blockly . JavaScript . getAdjusted ( a , "AT1" , 1 , ! 1 , $ . Blockly . JavaScript . ORDER _SUBTRACTION ) ; c = b + ".length - " + c ; break ;
case "FIRST" : c = "0" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)." ) ; } switch ( d ) { case "FROM_START" : d = $ . Blockly . JavaScript . getAdjusted ( a , "AT2" , 1 ) ; break ; case "FROM_END" : d = $ . Blockly . JavaScript . getAdjusted ( a , "AT2" , 0 , ! 1 , $ . Blockly . JavaScript . ORDER _SUBTRACTION ) ; d = b + ".length - " + d ; break ; case "LAST" : d = b + ".length" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)." ) ; } b = b + ".slice(" + c + ", " + d + ")" } else { var e = $ . Blockly . JavaScript . getAdjusted ( a , "AT1" ) ; a = $ . Blockly . JavaScript . getAdjusted ( a ,
2022-06-07 11:14:29 +00:00
"AT2" ) ; var f = { FIRST : "First" , LAST : "Last" , FROM _START : "FromStart" , FROM _END : "FromEnd" } ; b = $ . Blockly . JavaScript . provideFunction _ ( "subsequence" + f [ c ] + f [ d ] , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(sequence" + ( "FROM_END" === c || "FROM_START" === c ? ", at1" : "" ) + ( "FROM_END" === d || "FROM_START" === d ? ", at2" : "" ) + ") {\n var start = " + module$contents$Blockly$JavaScript$lists _getSubstringIndex ( "sequence" , c , "at1" ) + ";\n var end = " + module$contents$Blockly$JavaScript$lists _getSubstringIndex ( "sequence" ,
d , "at2" ) + " + 1;\n return sequence.slice(start, end);\n}\n" ) + "(" + b + ( "FROM_END" === c || "FROM_START" === c ? ", " + e : "" ) + ( "FROM_END" === d || "FROM_START" === d ? ", " + a : "" ) + ")" } return [ b , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . lists _sort = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ) || "[]" , c = "1" === a . getFieldValue ( "DIRECTION" ) ? 1 : - 1 ; a = a . getFieldValue ( "TYPE" ) ; var d = $ . Blockly . JavaScript . provideFunction _ ( "listsGetSortCompare" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(type, direction) {\n var compareFuncs = {\n 'NUMERIC': function(a, b) {\n return Number(a) - Number(b); },\n 'TEXT': function(a, b) {\n return a.toString() > b.toString() ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n " ) ;
return [ b + ".slice().sort(" + d + '("' + a + '", ' + c + "))" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; $ . Blockly . JavaScript . lists _split = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "INPUT" , $ . Blockly . JavaScript . ORDER _MEMBER ) , c = $ . Blockly . JavaScript . valueToCode ( a , "DELIM" , $ . Blockly . JavaScript . ORDER _NONE ) || "''" ; a = a . getFieldValue ( "MODE" ) ; if ( "SPLIT" === a ) b || ( b = "''" ) , a = "split" ; else if ( "JOIN" === a ) b || ( b = "[]" ) , a = "join" ; else throw Error ( "Unknown mode: " + a ) ; return [ b + "." + a + "(" + c + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . lists _reverse = function ( a ) { return [ ( $ . Blockly . JavaScript . valueToCode ( a , "LIST" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ) || "[]" ) + ".slice().reverse()" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; var module$exports$Blockly$JavaScript$colour = { } ; $ . Blockly . JavaScript . colour _picker = function ( a ) { return [ $ . Blockly . JavaScript . quote _ ( a . getFieldValue ( "COLOUR" ) ) , $ . Blockly . JavaScript . ORDER _ATOMIC ] } ; $ . Blockly . JavaScript . colour _random = function ( a ) { return [ $ . Blockly . JavaScript . provideFunction _ ( "colourRandom" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "() {\n var num = Math.floor(Math.random() * Math.pow(2, 24));\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n" ) + "()" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . colour _rgb = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "RED" , $ . Blockly . JavaScript . ORDER _NONE ) || 0 , c = $ . Blockly . JavaScript . valueToCode ( a , "GREEN" , $ . Blockly . JavaScript . ORDER _NONE ) || 0 ; a = $ . Blockly . JavaScript . valueToCode ( a , "BLUE" , $ . Blockly . JavaScript . ORDER _NONE ) || 0 ; return [ $ . Blockly . JavaScript . provideFunction _ ( "colourRgb" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n" ) +
"(" + b + ", " + c + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ;
$ . Blockly . JavaScript . colour _blend = function ( a ) { var b = $ . Blockly . JavaScript . valueToCode ( a , "COLOUR1" , $ . Blockly . JavaScript . ORDER _NONE ) || "'#000000'" , c = $ . Blockly . JavaScript . valueToCode ( a , "COLOUR2" , $ . Blockly . JavaScript . ORDER _NONE ) || "'#000000'" ; a = $ . Blockly . JavaScript . valueToCode ( a , "RATIO" , $ . Blockly . JavaScript . ORDER _NONE ) || . 5 ; return [ $ . Blockly . JavaScript . provideFunction _ ( "colourBlend" , "\nfunction " + $ . Blockly . JavaScript . FUNCTION _NAME _PLACEHOLDER _ + "(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n" ) +
"(" + b + ", " + c + ", " + a + ")" , $ . Blockly . JavaScript . ORDER _FUNCTION _CALL ] } ; var module$exports$Blockly$JavaScript$all = { } ;
$ . Blockly . JavaScript . _ _namespace _ _ = $ ;
2022-01-03 14:02:41 +00:00
return $ . Blockly . JavaScript ;
2021-01-16 14:07:51 +00:00
} ) ) ;
//# sourceMappingURL=javascript_compressed.js.map