// Do not edit this file; automatically generated. /* eslint-disable */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD define(["./blockly_compressed.js"], factory); } else if (typeof exports === 'object') { // Node.js module.exports = factory(require("./blockly_compressed.js")); } else { // Browser var factoryExports = factory(root.Blockly); root.Blockly.PHP = factoryExports.phpGenerator; root.Blockly.PHP.__namespace__ = factoryExports.__namespace__; } }(this, function(__parent__) { var $=__parent__.__namespace__; var module$exports$Blockly$PHP={},module$contents$Blockly$PHP_objectUtils=$.module$build$src$core$utils$object,module$contents$Blockly$PHP_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$PHP_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$PHP_Names=$.module$build$src$core$names.Names;module$exports$Blockly$PHP.phpGenerator=new $.Generator$$module$build$src$core$generator("PHP"); module$exports$Blockly$PHP.phpGenerator.addReservedWords("__halt_compiler,abstract,and,array,as,break,callable,case,catch,class,clone,const,continue,declare,default,die,do,echo,else,elseif,empty,enddeclare,endfor,endforeach,endif,endswitch,endwhile,eval,exit,extends,final,for,foreach,function,global,goto,if,implements,include,include_once,instanceof,insteadof,interface,isset,list,namespace,new,or,print,private,protected,public,require,require_once,return,static,switch,throw,trait,try,unset,use,var,while,xor,PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_VERSION_ID,PHP_EXTRA_VERSION,PHP_ZTS,PHP_DEBUG,PHP_MAXPATHLEN,PHP_OS,PHP_SAPI,PHP_EOL,PHP_INT_MAX,PHP_INT_SIZE,DEFAULT_INCLUDE_PATH,PEAR_INSTALL_DIR,PEAR_EXTENSION_DIR,PHP_EXTENSION_DIR,PHP_PREFIX,PHP_BINDIR,PHP_BINARY,PHP_MANDIR,PHP_LIBDIR,PHP_DATADIR,PHP_SYSCONFDIR,PHP_LOCALSTATEDIR,PHP_CONFIG_FILE_PATH,PHP_CONFIG_FILE_SCAN_DIR,PHP_SHLIB_SUFFIX,E_ERROR,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_DEPRECATED,E_USER_DEPRECATED,E_ALL,E_STRICT,__COMPILER_HALT_OFFSET__,TRUE,FALSE,NULL,__CLASS__,__DIR__,__FILE__,__FUNCTION__,__LINE__,__METHOD__,__NAMESPACE__,__TRAIT__"); module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC=0;module$exports$Blockly$PHP.phpGenerator.ORDER_CLONE=1;module$exports$Blockly$PHP.phpGenerator.ORDER_NEW=1;module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER=2.1;module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL=2.2;module$exports$Blockly$PHP.phpGenerator.ORDER_POWER=3;module$exports$Blockly$PHP.phpGenerator.ORDER_INCREMENT=4;module$exports$Blockly$PHP.phpGenerator.ORDER_DECREMENT=4; module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_NOT=4;module$exports$Blockly$PHP.phpGenerator.ORDER_CAST=4;module$exports$Blockly$PHP.phpGenerator.ORDER_SUPPRESS_ERROR=4;module$exports$Blockly$PHP.phpGenerator.ORDER_INSTANCEOF=5;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT=6;module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_PLUS=7.1;module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION=7.2;module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION=8.1; module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION=8.2;module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS=8.3;module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION=9.1;module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION=9.2;module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT=9.3;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_SHIFT=10;module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL=11;module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY=12; module$exports$Blockly$PHP.phpGenerator.ORDER_REFERENCE=13;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_AND=13;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_XOR=14;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_OR=15;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND=16;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR=17;module$exports$Blockly$PHP.phpGenerator.ORDER_IF_NULL=18;module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL=19; module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT=20;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND_WEAK=21;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_XOR=22;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR_WEAK=23;module$exports$Blockly$PHP.phpGenerator.ORDER_NONE=99; module$exports$Blockly$PHP.phpGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER,module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION,module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION], [module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION,module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR]];module$exports$Blockly$PHP.phpGenerator.isInitialized=!1; module$exports$Blockly$PHP.phpGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_,"$");this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0}; module$exports$Blockly$PHP.phpGenerator.finish=function(a){const b=$.module$build$src$core$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$exports$Blockly$PHP.phpGenerator.scrubNakedValue=function(a){return a+";\n"};module$exports$Blockly$PHP.phpGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"}; module$exports$Blockly$PHP.phpGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(' . "\\n" .\n')}; module$exports$Blockly$PHP.phpGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"// ")+"\n");for(let f=0;fc?h=g=this.ORDER_SUBTRACTION:d&&(h=g=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;$.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+c,d&&(a=-a)):(0c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+ a+")"));return a};var module$exports$Blockly$PHP$variables={},module$contents$Blockly$PHP$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.variables_get=function(a){return[module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]}; module$exports$Blockly$PHP.phpGenerator.variables_set=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";return module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$PHP$variablesDynamic={};module$exports$Blockly$PHP.phpGenerator.variables_get_dynamic=module$exports$Blockly$PHP.phpGenerator.variables_get;module$exports$Blockly$PHP.phpGenerator.variables_set_dynamic=module$exports$Blockly$PHP.phpGenerator.variables_set;var module$exports$Blockly$PHP$texts={},module$contents$Blockly$PHP$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.text=function(a){return[module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]}; module$exports$Blockly$PHP.phpGenerator.text_multiline=function(a){a=module$exports$Blockly$PHP.phpGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf(".")?module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT:module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC;return[a,b]}; module$exports$Blockly$PHP.phpGenerator.text_join=function(a){if(0===a.itemCount_)return["''",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC];if(1===a.itemCount_)return[module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD0",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE];if(2===a.itemCount_){var b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD0",module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT)||"''"; a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD1",module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT)||"''";return[b+" . "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT]}b=Array(a.itemCount_);for(let c=0;c 0",module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL, module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL],NEGATIVE:[""," < 0",module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,null,module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],PRIME:[null,null,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f,g]= b[c];b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"===c)a=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_isPrime",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($n) { // https://en.wikipedia.org/wiki/Primality_test#Naive_methods if ($n == 2 || $n == 3) { return true; } // False if n is NaN, negative, is 1, or not whole. // And false if n is divisible by 2 or 3. if (!is_numeric($n) || $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 ($x = 6; $x <= sqrt($n) + 1; $x += 6) { if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) { return false; } } return true; } `)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";if("0"===a)return["false",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=d+b+e;return[a,g]}; module$exports$Blockly$PHP.phpGenerator.math_change=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DELTA",module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION)||"0";return module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" += "+b+";\n"};module$exports$Blockly$PHP.phpGenerator.math_round=module$exports$Blockly$PHP.phpGenerator.math_single;module$exports$Blockly$PHP.phpGenerator.math_trig=module$exports$Blockly$PHP.phpGenerator.math_single; module$exports$Blockly$PHP.phpGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="array_sum("+a+")";break;case "MIN":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="min("+a+")";break;case "MAX":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a, "LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="max("+a+")";break;case "AVERAGE":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_mean",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($myList) { return array_sum($myList) / count($myList); } `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";a=b+"("+a+")";break;case "MEDIAN":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_median",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($arr) { sort($arr,SORT_NUMERIC); return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] : ($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2; } `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_modes",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($values) { if (empty($values)) return array(); $counts = array_count_values($values); arsort($counts); // Sort counts in descending order $modes = array_keys($counts, current($counts), true); return $modes; } `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_standard_deviation",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($numbers) { $n = count($numbers); if (!$n) return null; $mean = array_sum($numbers) / count($numbers); foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2); return sqrt(array_sum($devs) / (count($devs) - 1)); } `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_random_list",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) { $x = rand(0, count($list)-1); return $list[$x]; } `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.math_modulo=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";return[b+" % "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS]}; module$exports$Blockly$PHP.phpGenerator.math_constrain=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LOW",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"HIGH",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"Infinity";return["min(max("+b+", "+c+"), "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.math_random_int=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_random_int",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($a, $b) { if ($a > $b) { return rand($b, $a); } return rand($a, $b); } `)+"("+b+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.math_random_float=function(a){return["(float)rand()/(float)getrandmax()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.math_atan2=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"X",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return["atan2("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"Y",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0")+", "+b+") / pi() * 180",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION]};var module$exports$Blockly$PHP$loops={},module$contents$Blockly$PHP$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP$loops_NameType=$.NameType$$module$build$src$core$names; module$exports$Blockly$PHP.phpGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TIMES",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";let c=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");c=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(c,a);a="";const d=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE); let e=b;b.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(b)||(e=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("repeat_end",$.NameType$$module$build$src$core$names.VARIABLE),a+=e+" = "+b+";\n");return a+("for ("+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};module$exports$Blockly$PHP.phpGenerator.controls_repeat=module$exports$Blockly$PHP.phpGenerator.controls_repeat_ext; module$exports$Blockly$PHP.phpGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");d=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"}; module$exports$Blockly$PHP.phpGenerator.controls_for=function(a){var b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0",d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";const e=module$exports$Blockly$PHP.phpGenerator.valueToCode(a, "BY",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"1";let f=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");f=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(f,a);if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b); a+=") {\n"+f+"}\n"}else a="",g=c,c.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(c)||(g=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+"_start",$.NameType$$module$build$src$core$names.VARIABLE),a+=g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(d)||(c=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+"_end",$.NameType$$module$build$src$core$names.VARIABLE),a+=c+" = "+d+";\n"),d=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+ "_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+=d+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+";\n"):a+("abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=module$exports$Blockly$PHP.phpGenerator.INDENT+d+" = -"+d+";\n",a=a+"}\nfor ("+(b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a}; module$exports$Blockly$PHP.phpGenerator.controls_forEach=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"[]";let d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");d=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(d,a);return"foreach ("+c+" as "+b+") {\n"+d+ "}\n"}; module$exports$Blockly$PHP.phpGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop(); c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.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$PHP$logic={}; module$exports$Blockly$PHP.phpGenerator.controls_if=function(a){let b=0,c="",d,e;module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));do e=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO"+b),module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(d= module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$PHP.phpGenerator.INDENT)+d),c+=(0",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY:module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]}; module$exports$Blockly$PHP.phpGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",c);if(d||a){const e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]}; module$exports$Blockly$PHP.phpGenerator.logic_negate=function(a){const b=module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT;return["!"+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BOOL",b)||"true"),b]};module$exports$Blockly$PHP.phpGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};module$exports$Blockly$PHP.phpGenerator.logic_null=function(a){return["null",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]}; module$exports$Blockly$PHP.phpGenerator.logic_ternary=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"IF",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"false",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"THEN",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"null";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ELSE",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$PHP$lists={},module$contents$Blockly$PHP$lists_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.lists_create_empty=function(a){return["array()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.lists_create_with=function(a){let b=Array(a.itemCount_);for(let c=0;c 'strnatcasecmp', 'TEXT' => 'strcmp', 'IGNORE_CASE' => 'strcasecmp' ); $sortCmp = $sortCmpFuncs[$type]; $list2 = $list; usort($list2, $sortCmp); if ($direction == -1) { $list2 = array_reverse($list2); } return $list2; } `)+"("+b+', "'+a+'", '+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.lists_split=function(a){let b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"INPUT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE);const c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DELIM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="explode";else if("JOIN"===a)b||(b="array()"),a="implode";else throw Error("Unknown mode: "+a);return[a+"("+c+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.lists_reverse=function(a){return["array_reverse("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$colour={};module$exports$Blockly$PHP.phpGenerator.colour_picker=function(a){return[module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};module$exports$Blockly$PHP.phpGenerator.colour_random=function(a){return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_random",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}() { return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); } `)+"()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.colour_rgb=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"RED",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0,c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"GREEN",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0;a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BLUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0;return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_rgb",` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) { $r = round(max(min($r, 100), 0) * 2.55); $g = round(max(min($g, 100), 0) * 2.55); $b = round(max(min($b, 100), 0) * 2.55); $hex = '#'; $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT); $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT); $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT); return $hex; } `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}; module$exports$Blockly$PHP.phpGenerator.colour_blend=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"'#000000'",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"RATIO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||.5;return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_blend", ` function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) { $ratio = max(min($ratio, 1), 0); $r1 = hexdec(substr($c1, 1, 2)); $g1 = hexdec(substr($c1, 3, 2)); $b1 = hexdec(substr($c1, 5, 2)); $r2 = hexdec(substr($c2, 1, 2)); $g2 = hexdec(substr($c2, 3, 2)); $b2 = hexdec(substr($c2, 5, 2)); $r = round($r1 * (1 - $ratio) + $r2 * $ratio); $g = round($g1 * (1 - $ratio) + $g2 * $ratio); $b = round($b1 * (1 - $ratio) + $b2 * $ratio); $hex = '#'; $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT); $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT); $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT); return $hex; } `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$all=module$exports$Blockly$PHP; module$exports$Blockly$PHP.__namespace__=$; return module$exports$Blockly$PHP; })); //# sourceMappingURL=php_compressed.js.map