php_compressed.js 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. // Do not edit this file; automatically generated.
  2. /* eslint-disable */
  3. ;(function(root, factory) {
  4. if (typeof define === 'function' && define.amd) { // AMD
  5. define(["./blockly_compressed.js"], factory);
  6. } else if (typeof exports === 'object') { // Node.js
  7. module.exports = factory(require("./blockly_compressed.js"));
  8. } else { // Browser
  9. var factoryExports = factory(root.Blockly);
  10. root.Blockly.PHP = factoryExports.phpGenerator;
  11. root.Blockly.PHP.__namespace__ = factoryExports.__namespace__;
  12. }
  13. }(this, function(__parent__) {
  14. var $=__parent__.__namespace__;
  15. var module$exports$Blockly$PHP={},module$contents$Blockly$PHP_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP_CodeGenerator=$.CodeGenerator$$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 $.CodeGenerator$$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__");
  16. 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;
  17. 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;
  18. 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;
  19. 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;
  20. 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;
  21. 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],
  22. [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;
  23. 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};
  24. module$exports$Blockly$PHP.phpGenerator.finish=function(a){const b=Object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};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+"'"};
  25. module$exports$Blockly$PHP.phpGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(' . "\\n" .\n')};
  26. 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;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&
  27. a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
  28. module$exports$Blockly$PHP.phpGenerator.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;let f=a.workspace.options.oneBasedIndex?"1":"0",g=e,h;0<c?h=g=this.ORDER_ADDITION:0>c?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)):(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="("+
  29. 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]};
  30. 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]};
  31. 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]};
  32. 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)||"''";
  33. 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<a.itemCount_;c++)b[c]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["implode('', array("+b.join(",")+"))",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  34. module$exports$Blockly$PHP.phpGenerator.text_append=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"''";return b+" .= "+a+";\n"};module$exports$Blockly$PHP.phpGenerator.text_length=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("length",`
  35. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
  36. if (is_string($value)) {
  37. return strlen($value);
  38. }
  39. return count($value);
  40. }
  41. `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.text_isEmpty=function(a){return["empty("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  42. module$exports$Blockly$PHP.phpGenerator.text_indexOf=function(a){const b="FIRST"===a.getFieldValue("END")?"strpos":"strrpos",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FIND",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";let e=" -1",f="";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("FIRST"===
  43. a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",`
  44. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {
  45. $pos = ${b}($text, $search);
  46. return $pos === false ? ${e} : $pos${f};
  47. }
  48. `)+"("+d+", "+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  49. module$exports$Blockly$PHP.phpGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";switch(b){case "FIRST":return["substr("+c+", 0, 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "LAST":return["substr("+c+", -1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "FROM_START":return a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
  50. "AT"),["substr("+c+", "+a+", 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "FROM_END":return a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!0),["substr("+c+", "+a+", 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "RANDOM":return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("text_random_letter",`
  51. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text) {
  52. return $text[rand(0, strlen($text) - 1)];
  53. }
  54. `)+"("+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
  55. module$exports$Blockly$PHP.phpGenerator.text_getSubstring=function(a){const b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"STRING",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[d,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE];const e=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("text_get_substring",
  56. `
  57. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $where1, $at1, $where2, $at2) {
  58. if ($where1 == 'FROM_END') {
  59. $at1 = strlen($text) - 1 - $at1;
  60. } else if ($where1 == 'FIRST') {
  61. $at1 = 0;
  62. } else if ($where1 != 'FROM_START') {
  63. throw new Exception('Unhandled option (text_get_substring).');
  64. }
  65. $length = 0;
  66. if ($where2 == 'FROM_START') {
  67. $length = $at2 - $at1 + 1;
  68. } else if ($where2 == 'FROM_END') {
  69. $length = strlen($text) - $at1 - $at2;
  70. } else if ($where2 == 'LAST') {
  71. $length = strlen($text) - $at1;
  72. } else {
  73. throw new Exception('Unhandled option (text_get_substring).');
  74. }
  75. return substr($text, $at1, $length);
  76. }
  77. `)+"("+d+", '"+b+"', "+e+", '"+c+"', "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  78. module$exports$Blockly$PHP.phpGenerator.text_changeCase=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";let c;"UPPERCASE"===a.getFieldValue("CASE")?c="strtoupper("+b+")":"LOWERCASE"===a.getFieldValue("CASE")?c="strtolower("+b+")":"TITLECASE"===a.getFieldValue("CASE")&&(c="ucwords(strtolower("+b+"))");return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  79. module$exports$Blockly$PHP.phpGenerator.text_trim=function(a){const b={LEFT:"ltrim",RIGHT:"rtrim",BOTH:"trim"}[a.getFieldValue("MODE")];a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  80. module$exports$Blockly$PHP.phpGenerator.text_print=function(a){return"print("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+");\n"};
  81. module$exports$Blockly$PHP.phpGenerator.text_prompt_ext=function(a){let b="readline("+(a.getField("TEXT")?module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="floatval("+b+")");return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.text_prompt=module$exports$Blockly$PHP.phpGenerator.text_prompt_ext;
  82. module$exports$Blockly$PHP.phpGenerator.text_count=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"SUB",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["strlen("+a+") === 0 ? strlen("+b+") + 1 : substr_count("+b+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL]};
  83. module$exports$Blockly$PHP.phpGenerator.text_replace=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["str_replace("+c+", "+a+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  84. module$exports$Blockly$PHP.phpGenerator.text_reverse=function(a){return["strrev("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$procedures={},module$contents$Blockly$PHP$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$PHP$procedures_NameType=$.NameType$$module$build$src$core$names;
  85. module$exports$Blockly$PHP.phpGenerator.procedures_defreturn=function(a){var b=[],c=a.workspace,d=$.module$build$src$core$variables.allUsedVarModels(c)||[];for(let m=0,n;n=d[m];m++){var e=n.name;-1===a.getVars().indexOf(e)&&b.push(module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(e,$.NameType$$module$build$src$core$names.VARIABLE))}c=$.module$build$src$core$variables.allDeveloperVariables(c);for(d=0;d<c.length;d++)b.push(module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
  86. c=b.length?module$exports$Blockly$PHP.phpGenerator.INDENT+"global "+b.join(", ")+";\n":"";b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);d="";module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(d+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(d+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,
  87. a));d&&(d=module$exports$Blockly$PHP.phpGenerator.prefixLines(d,module$exports$Blockly$PHP.phpGenerator.INDENT));e="";module$exports$Blockly$PHP.phpGenerator.INFINITE_LOOP_TRAP&&(e=module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.INFINITE_LOOP_TRAP,a),module$exports$Blockly$PHP.phpGenerator.INDENT));const f=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"STACK");let g=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
  88. "RETURN",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"",h="";f&&g&&(h=d);g&&(g=module$exports$Blockly$PHP.phpGenerator.INDENT+"return "+g+";\n");const k=[],l=a.getVars();for(let m=0;m<l.length;m++)k[m]=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(l[m],$.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+k.join(", ")+") {\n"+c+d+e+f+h+g+"}";c=module$exports$Blockly$PHP.phpGenerator.scrub_(a,c);module$exports$Blockly$PHP.phpGenerator.definitions_["%"+b]=c;return null};
  89. module$exports$Blockly$PHP.phpGenerator.procedures_defnoreturn=module$exports$Blockly$PHP.phpGenerator.procedures_defreturn;
  90. module$exports$Blockly$PHP.phpGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  91. module$exports$Blockly$PHP.phpGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$PHP.phpGenerator.procedures_callreturn(a)[0]+";\n"};
  92. module$exports$Blockly$PHP.phpGenerator.procedures_ifreturn=function(a){let b="if ("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false")+") {\n";module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(b+=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));a.hasReturnValue_?
  93. (a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null",b+=module$exports$Blockly$PHP.phpGenerator.INDENT+"return "+a+";\n"):b+=module$exports$Blockly$PHP.phpGenerator.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$PHP$math={},module$contents$Blockly$PHP$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));const b=0<=a?module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC:module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION;Infinity===a?a="INF":-Infinity===a&&(a="-INF");return[a,b]};
  94. module$exports$Blockly$PHP.phpGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION],MINUS:[" - ",module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION],POWER:[" ** ",module$exports$Blockly$PHP.phpGenerator.ORDER_POWER]}[a.getFieldValue("OP")];const c=b[0];b=b[1];const d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
  95. "A",b)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
  96. module$exports$Blockly$PHP.phpGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION)||"0":module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
  97. "NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "LN":c="log("+a+")";break;case "EXP":c="exp("+a+")";break;case "POW10":c="pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="ceil("+a+")";break;case "ROUNDDOWN":c="floor("+a+")";break;case "SIN":c="sin("+a+" / 180 * pi())";break;case "COS":c="cos("+a+" / 180 * pi())";break;case "TAN":c="tan("+a+" / 180 * pi())"}if(c)return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];
  98. switch(b){case "LOG10":c="log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / pi() * 180";break;case "ACOS":c="acos("+a+") / pi() * 180";break;case "ATAN":c="atan("+a+") / pi() * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION]};
  99. module$exports$Blockly$PHP.phpGenerator.math_constant=function(a){return{PI:["M_PI",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],E:["M_E",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION],SQRT2:["M_SQRT2",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],SQRT1_2:["M_SQRT1_2",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],INFINITY:["INF",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
  100. module$exports$Blockly$PHP.phpGenerator.math_number_property=function(a){var b={EVEN:[""," % 2 == 0",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],ODD:[""," % 2 == 1",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],WHOLE:["is_int(",")",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL],POSITIVE:[""," > 0",module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,
  101. 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]=
  102. 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",`
  103. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($n) {
  104. // https://en.wikipedia.org/wiki/Primality_test#Naive_methods
  105. if ($n == 2 || $n == 3) {
  106. return true;
  107. }
  108. // False if n is NaN, negative, is 1, or not whole.
  109. // And false if n is divisible by 2 or 3.
  110. if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {
  111. return false;
  112. }
  113. // Check all the numbers of form 6k +/- 1, up to sqrt(n).
  114. for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {
  115. if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {
  116. return false;
  117. }
  118. }
  119. return true;
  120. }
  121. `)+"("+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]};
  122. 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;
  123. 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,
  124. "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",`
  125. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($myList) {
  126. return array_sum($myList) / count($myList);
  127. }
  128. `);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",`
  129. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($arr) {
  130. sort($arr,SORT_NUMERIC);
  131. return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :
  132. ($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;
  133. }
  134. `);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",`
  135. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($values) {
  136. if (empty($values)) return array();
  137. $counts = array_count_values($values);
  138. arsort($counts); // Sort counts in descending order
  139. $modes = array_keys($counts, current($counts), true);
  140. return $modes;
  141. }
  142. `);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",`
  143. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($numbers) {
  144. $n = count($numbers);
  145. if (!$n) return null;
  146. $mean = array_sum($numbers) / count($numbers);
  147. foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);
  148. return sqrt(array_sum($devs) / (count($devs) - 1));
  149. }
  150. `);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",`
  151. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
  152. $x = rand(0, count($list)-1);
  153. return $list[$x];
  154. }
  155. `);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]};
  156. 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]};
  157. 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]};
  158. 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",`
  159. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
  160. if ($a > $b) {
  161. return rand($b, $a);
  162. }
  163. return rand($a, $b);
  164. }
  165. `)+"("+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]};
  166. 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;
  167. 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);
  168. 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;
  169. 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"};
  170. 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,
  171. "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);
  172. 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+
  173. "_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};
  174. 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+
  175. "}\n"};
  176. 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();
  177. 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={};
  178. 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=
  179. 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<b?" else ":"")+"if ("+e+") {\n"+d+"}",b++;while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX)d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"ELSE"),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,
  180. a),module$exports$Blockly$PHP.phpGenerator.INDENT)+d),c+=" else {\n"+d+"}";return c+"\n"};module$exports$Blockly$PHP.phpGenerator.controls_ifelse=module$exports$Blockly$PHP.phpGenerator.controls_if;
  181. module$exports$Blockly$PHP.phpGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",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]};
  182. 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]};
  183. 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]};
  184. 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]};
  185. module$exports$Blockly$PHP.phpGenerator.lists_create_with=function(a){let b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";b="array("+b.join(", ")+")";return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_repeat=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_repeat",`
  186. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value, $count) {
  187. $array = array();
  188. for ($index = 0; $index < $count; $index++) {
  189. $array[] = $value;
  190. }
  191. return $array;
  192. }
  193. `),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ITEM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_length=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("length",`
  194. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
  195. if (is_string($value)) {
  196. return strlen($value);
  197. } else {
  198. return count($value);
  199. }
  200. }
  201. `);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_isEmpty=function(a){return["empty("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  202. module$exports$Blockly$PHP.phpGenerator.lists_indexOf=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FIND",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"[]";let d=" -1",e="";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1");return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$PHP.phpGenerator.provideFunction_("indexOf",`
  203. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
  204. for ($index = 0; $index < count($haystack); $index++) {
  205. if ($haystack[$index] == $needle) return $index${e};
  206. }
  207. return ${d};
  208. }
  209. `):module$exports$Blockly$PHP.phpGenerator.provideFunction_("lastIndexOf",`
  210. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
  211. $last = ${d};
  212. for ($index = 0; $index < count($haystack); $index++) {
  213. if ($haystack[$index] == $needle) $last = $index${e};
  214. }
  215. return $last;
  216. }
  217. `))+"("+c+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  218. module$exports$Blockly$PHP.phpGenerator.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET";switch(a.getFieldValue("WHERE")||"FROM_START"){case "FIRST":if("GET"===b)return[(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_shift("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
  219. "array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_shift("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+");\n";break;case "LAST":if("GET"===b)return["end("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===
  220. b)return["array_pop("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_pop("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+");\n";break;case "FROM_START":var c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT");if("GET"===b)return[(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
  221. "VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"["+c+"]",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+c+", 1)[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
  222. "array()")+", "+c+", 1);\n";break;case "FROM_END":if("GET"===b)return b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!0),["array_slice("+b+", "+a+", 1)[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b||"REMOVE"===b){c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
  223. "array()";a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);a="array_splice("+c+", count("+c+") - "+a+", 1)[0]";if("GET_REMOVE"===b)return[a,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return a+";\n"}break;case "RANDOM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";if("GET"===b)return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_random_item",
  224. `
  225. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
  226. return $list[rand(0,count($list)-1)];
  227. }
  228. `)+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b)return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_remove_random_item",`
  229. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
  230. $x = rand(0,count($list)-1);
  231. unset($list[$x]);
  232. return array_values($list);
  233. }
  234. `)+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_remove_random_item",`
  235. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
  236. unset($list[rand(0,count($list)-1)]);
  237. }
  238. `)+"("+a+");\n"}throw Error("Unhandled combination (lists_getIndex).");};
  239. module$exports$Blockly$PHP.phpGenerator.lists_setIndex=function(a){const b=a.getFieldValue("MODE")||"GET";var c=a.getFieldValue("WHERE")||"FROM_START";const d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"null";switch(c){case "FIRST":if("SET"===b)return(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"[0] = "+d+";\n";if("INSERT"===b)return"array_unshift("+
  240. (module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+d+");\n";break;case "LAST":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";if("SET"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_set_last_item",`
  241. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $value) {
  242. $list[count($list) - 1] = $value;
  243. }
  244. `)+"("+a+", "+d+");\n";if("INSERT"===b)return"array_push("+a+", "+d+");\n";break;case "FROM_START":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT");if("SET"===b)return(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"["+c+"] = "+d+";\n";if("INSERT"===b)return"array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+c+", 0, "+
  245. d+");\n";break;case "FROM_END":c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1);if("SET"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_set_from_end",`
  246. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
  247. $list[count($list) - $at] = $value;
  248. }
  249. `)+"("+c+", "+a+", "+d+");\n";if("INSERT"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_insert_from_end",`
  250. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
  251. return array_splice($list, count($list) - $at, 0, $value);
  252. }
  253. `)+"("+c+", "+a+", "+d+");\n";break;case "RANDOM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_REFERENCE)||"array()";if(a.match(/^\$\w+$/))c="";else{c=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE);var e=c+" = &"+a+";\n";a=c;c=e}e=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);c+=e+" = rand(0, count("+
  254. a+")-1);\n";if("SET"===b)return c+(a+"["+e+"] = "+d+";\n");if("INSERT"===b)return c+("array_splice("+a+", "+e+", 0, "+d+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
  255. module$exports$Blockly$PHP.phpGenerator.lists_getSublist=function(a){var b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"!==c||"LAST"!==d)if(b.match(/^\$\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT1");break;case "FROM_END":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
  256. "AT1",1,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);c="count("+b+") - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":d=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);d+=" - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");d+=" + 1";break;case "FROM_END":d=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
  257. "AT2",0,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);d="count("+b+") - "+d+" - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;case "LAST":d="count("+b+") - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;default:throw Error("Unhandled option (lists_getSublist).");}b="array_slice("+b+", "+c+", "+d+")"}else{const e=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
  258. "AT1");a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2");b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_sublist",`
  259. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list, $where1, $at1, $where2, $at2) {
  260. if ($where1 == 'FROM_END') {
  261. $at1 = count($list) - 1 - $at1;
  262. } else if ($where1 == 'FIRST') {
  263. $at1 = 0;
  264. } else if ($where1 != 'FROM_START') {
  265. throw new Exception('Unhandled option (lists_get_sublist).');
  266. }
  267. $length = 0;
  268. if ($where2 == 'FROM_START') {
  269. $length = $at2 - $at1 + 1;
  270. } else if ($where2 == 'FROM_END') {
  271. $length = count($list) - $at1 - $at2;
  272. } else if ($where2 == 'LAST') {
  273. $length = count($list) - $at1;
  274. } else {
  275. throw new Exception('Unhandled option (lists_get_sublist).');
  276. }
  277. return array_slice($list, $at1, $length);
  278. }
  279. `)+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")"}return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_sort=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_sort",`
  280. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list, $type, $direction) {
  281. $sortCmpFuncs = array(
  282. 'NUMERIC' => 'strnatcasecmp',
  283. 'TEXT' => 'strcmp',
  284. 'IGNORE_CASE' => 'strcasecmp'
  285. );
  286. $sortCmp = $sortCmpFuncs[$type];
  287. $list2 = $list;
  288. usort($list2, $sortCmp);
  289. if ($direction == -1) {
  290. $list2 = array_reverse($list2);
  291. }
  292. return $list2;
  293. }
  294. `)+"("+b+', "'+a+'", '+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  295. 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]};
  296. 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",`
  297. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
  298. return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
  299. }
  300. `)+"()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  301. 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",`
  302. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) {
  303. $r = round(max(min($r, 100), 0) * 2.55);
  304. $g = round(max(min($g, 100), 0) * 2.55);
  305. $b = round(max(min($b, 100), 0) * 2.55);
  306. $hex = '#';
  307. $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
  308. $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
  309. $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
  310. return $hex;
  311. }
  312. `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
  313. 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",
  314. `
  315. function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) {
  316. $ratio = max(min($ratio, 1), 0);
  317. $r1 = hexdec(substr($c1, 1, 2));
  318. $g1 = hexdec(substr($c1, 3, 2));
  319. $b1 = hexdec(substr($c1, 5, 2));
  320. $r2 = hexdec(substr($c2, 1, 2));
  321. $g2 = hexdec(substr($c2, 3, 2));
  322. $b2 = hexdec(substr($c2, 5, 2));
  323. $r = round($r1 * (1 - $ratio) + $r2 * $ratio);
  324. $g = round($g1 * (1 - $ratio) + $g2 * $ratio);
  325. $b = round($b1 * (1 - $ratio) + $b2 * $ratio);
  326. $hex = '#';
  327. $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
  328. $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
  329. $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
  330. return $hex;
  331. }
  332. `)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$all=module$exports$Blockly$PHP;
  333. module$exports$Blockly$PHP.__namespace__=$;
  334. return module$exports$Blockly$PHP;
  335. }));
  336. //# sourceMappingURL=php_compressed.js.map
粤ICP备19079148号