text: // Do not edit this file; automatically generated by build.py.
  'use strict';
  
  /*
   Licensed under the Apache License, Version 2.0 (the "License"):
            http://www.apache.org/licenses/LICENSE-2.0
  */
  Blockly.xrplhook=new Blockly.Generator("xrplhook");Blockly.xrplhook.StaticTyping=new Blockly.StaticTyping;Blockly.xrplhook.addReservedWords("Blockly,setup,loop,if,else,for,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,integer,constants,floating,point,void,boolean,char,unsigned,byte,int,word,long,float,double,string,String,array,static,volatile,const,sizeofshiftOut,shitIn,millis,micros,delay,min,max,abs,constrain,map,pow,sqrt,sin,cos,tan,randomSeed,random");
  Blockly.xrplhook.ORDER_ATOMIC=0;Blockly.xrplhook.ORDER_UNARY_POSTFIX=1;Blockly.xrplhook.ORDER_UNARY_PREFIX=2;Blockly.xrplhook.ORDER_MULTIPLICATIVE=3;Blockly.xrplhook.ORDER_ADDITIVE=4;Blockly.xrplhook.ORDER_SHIFT=5;Blockly.xrplhook.ORDER_RELATIONAL=6;Blockly.xrplhook.ORDER_EQUALITY=7;Blockly.xrplhook.ORDER_BITWISE_AND=8;Blockly.xrplhook.ORDER_BITWISE_XOR=9;Blockly.xrplhook.ORDER_BITWISE_OR=10;Blockly.xrplhook.ORDER_LOGICAL_AND=11;Blockly.xrplhook.ORDER_LOGICAL_OR=12;
  Blockly.xrplhook.ORDER_CONDITIONAL=13;Blockly.xrplhook.ORDER_ASSIGNMENT=14;Blockly.xrplhook.ORDER_NONE=99;Blockly.xrplhook.DEF_FUNC_NAME=Blockly.xrplhook.FUNCTION_NAME_PLACEHOLDER_;
  Blockly.xrplhook.init=function(a){Blockly.xrplhook.includes_=Object.create(null);Blockly.xrplhook.definitions_=Object.create(null);Blockly.xrplhook.variables_=Object.create(null);Blockly.xrplhook.codeFunctions_=Object.create(null);Blockly.xrplhook.userFunctions_=Object.create(null);Blockly.xrplhook.functionNames_=Object.create(null);Blockly.xrplhook.setups_=Object.create(null);Blockly.xrplhook.pins_=Object.create(null);Blockly.xrplhook.variableDB_?Blockly.xrplhook.variableDB_.reset():Blockly.xrplhook.variableDB_=
  new Blockly.Names(Blockly.xrplhook.RESERVED_WORDS_);var b=Blockly.xrplhook.StaticTyping.collectVarsWithTypes(a);Blockly.xrplhook.StaticTyping.setProcedureArgs(a,b)};
  Blockly.xrplhook.finish=function(a){var b=[],c=[],d=[],e;for(e in Blockly.xrplhook.includes_)b.push(Blockly.xrplhook.includes_[e]);b.length&&b.push("\n");for(e in Blockly.xrplhook.definitions_)c.push(Blockly.xrplhook.definitions_[e]);c.length&&c.push("\n");for(e in Blockly.xrplhook.codeFunctions_)d.push(Blockly.xrplhook.codeFunctions_[e]);for(e in Blockly.xrplhook.userFunctions_)d.push(Blockly.xrplhook.userFunctions_[e]);d.length&&d.push("\n");var f=[""],g="";void 0!==Blockly.xrplhook.setups_.userSetupCode&&
  (g="\n"+Blockly.xrplhook.setups_.userSetupCode,delete Blockly.xrplhook.setups_.userSetupCode);for(e in Blockly.xrplhook.setups_)f.push(Blockly.xrplhook.setups_[e]);g&&f.push(g);delete Blockly.xrplhook.includes_;delete Blockly.xrplhook.definitions_;delete Blockly.xrplhook.codeFunctions_;delete Blockly.xrplhook.userFunctions_;delete Blockly.xrplhook.functionNames_;delete Blockly.xrplhook.setups_;delete Blockly.xrplhook.pins_;Blockly.xrplhook.variableDB_.reset();b=b.join("\n")+""+c.join("\n")+d.join("\n\n");
  f="int64_t cbak(int64_t reserved) {"+f.join("\n  ")+"\n return 0;\n}\n\n";a="int64_t hook(int64_t reserved) {\n"+a.replace(/\n/g,"\n")+"\n return 0;\n}\n\n";return b+"//Executed when an emitted transaction is successfully accepted into a ledger \n"+f+"//Executed whenever a transaction comes into or leaves from the account the Hook is set on \n"+a};Blockly.xrplhook.addInclude=function(a,b){void 0===Blockly.xrplhook.includes_[a]&&(Blockly.xrplhook.includes_[a]=b)};
  Blockly.xrplhook.addDeclaration=function(a,b){void 0===Blockly.xrplhook.definitions_[a]&&(Blockly.xrplhook.definitions_[a]=b)};Blockly.xrplhook.addVariable=function(a,b,c){var d=!1;if(c||void 0===Blockly.xrplhook.variables_[a])Blockly.xrplhook.variables_[a]=b,d=!0;return d};Blockly.xrplhook.addSetup=function(a,b,c){var d=!1;if(c||void 0===Blockly.xrplhook.setups_[a])Blockly.xrplhook.setups_[a]=b,d=!0;return d};
  Blockly.xrplhook.addFunction=function(a,b){if(void 0===Blockly.xrplhook.codeFunctions_[a]){var c=Blockly.xrplhook.variableDB_.getDistinctName(a,Blockly.Generator.NAME_TYPE);Blockly.xrplhook.codeFunctions_[a]=b.replace(Blockly.xrplhook.DEF_FUNC_NAME,c);Blockly.xrplhook.functionNames_[a]=c}return Blockly.xrplhook.functionNames_[a]};
  Blockly.xrplhook.reservePin=function(a,b,c,d){void 0!==Blockly.xrplhook.pins_[b]?Blockly.xrplhook.pins_[b]!=c?a.setWarningText(Blockly.Msg.ARD_PIN_WARN1.replace("%1",b).replace("%2",d).replace("%3",c).replace("%4",Blockly.xrplhook.pins_[b]),d):a.setWarningText(null,d):(Blockly.xrplhook.pins_[b]=c,a.setWarningText(null,d))};Blockly.xrplhook.scrubNakedValue=function(a){return a+";\n"};
  Blockly.xrplhook.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return'"'+a+'"'};
  Blockly.xrplhook.scrub_=function(a,b){if(null===b)return"";var c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var d=a.getCommentText();d&&(c+=this.prefixLines(d,"// ")+"\n");for(var e=0;e<a.inputList.length;e++)a.inputList[e].type==Blockly.INPUT_VALUE&&(d=a.inputList[e].connection.targetBlock())&&(d=this.allNestedComments(d))&&(c+=this.prefixLines(d,"// "))}e=a.nextConnection&&a.nextConnection.targetBlock();e=this.blockToCode(e);return c+b+e};
  Blockly.xrplhook.getxrplhookType_=function(a){switch(a.typeId){case Blockly.Types.SHORT_NUMBER.typeId:return"char";case Blockly.Types.NUMBER.typeId:return"int";case Blockly.Types.LARGE_NUMBER.typeId:return"long";case Blockly.Types.DECIMAL.typeId:return"float";case Blockly.Types.TEXT.typeId:return"String";case Blockly.Types.CHARACTER.typeId:return"char";case Blockly.Types.BOOLEAN.typeId:return"boolean";case Blockly.Types.NULL.typeId:return"void";case Blockly.Types.UNDEF.typeId:return"undefined";case Blockly.Types.CHILD_BLOCK_MISSING.typeId:return"int";
  case "uint8":return"uint8";default:return"Invalid Blockly Type"}};Blockly.xrplhook.noGeneratorCodeInline=function(){return["",Blockly.xrplhook.ORDER_ATOMIC]};Blockly.xrplhook.noGeneratorCodeLine=function(){return""};Blockly.xrplhook["float"]={};Blockly.xrplhook.float_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"exponent",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"mantissa",Blockly.xrplhook.ORDER_ATOMIC);return["float_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_multiply=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"float2",Blockly.xrplhook.ORDER_ATOMIC);return["float_multiply("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_mulratio=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"round_up",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"numerator",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"denominator",Blockly.xrplhook.ORDER_ATOMIC);return["float_mulratio("+b+","+c+","+d+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_negate=function(a){return["float_negate("+Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_compare=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"float2",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"mode",Blockly.xrplhook.ORDER_ATOMIC);return["float_compare("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_sum=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"float2",Blockly.xrplhook.ORDER_ATOMIC);return["float_sum("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_sto=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"cread_ptr",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"cread_len",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"iread_ptr",Blockly.xrplhook.ORDER_ATOMIC),g=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,
  "field_code",Blockly.xrplhook.ORDER_ATOMIC);return["float_sto("+b+","+c+","+d+","+e+","+f+","+g+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_sto_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);return["float_sto_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_invert=function(a){return["float_invert("+Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_divide=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"float2",Blockly.xrplhook.ORDER_ATOMIC);return["float_divide("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_one=function(a){return["float_one()",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_exponent=function(a){return["float_exponent("+Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_mantissa=function(a){return["float_mantissa("+Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_sign=function(a){return["float_sign("+Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_exponent_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"exponent",Blockly.xrplhook.ORDER_ATOMIC);return["float_exponent_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_mantissa_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"mantissa",Blockly.xrplhook.ORDER_ATOMIC);return["float_mantissa_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.float_sign_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"sign",Blockly.xrplhook.ORDER_ATOMIC);return["float_sign_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.float_int=function(a){var b=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"decimal_places",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"absolute",Blockly.xrplhook.ORDER_ATOMIC);return["float_int("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.variables={};Blockly.xrplhook.variables_get=function(a){return[Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.xrplhook.ORDER_ATOMIC]};Blockly.xrplhook.variables_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0";return Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};
  Blockly.xrplhook.variables_set_type=function(a){var b=Blockly.xrplhook.valueToCode(a,"VARIABLE_SETTYPE_INPUT",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0";return["("+a.getFieldValue("VARIABLE_SETTYPE_TYPE")+")("+b+")",Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.pointer=function(a){var b=a.getFieldValue("type"),c=a.getFieldValue("NAME"),d=a.getFieldValue("pointer_name");a=Blockly.xrplhook.valueToCode(a,"initial",Blockly.xrplhook.ORDER_ATOMIC);b=b+" "+c+d+" = "+a+";\n";return Blockly.xrplhook.variables_.test1=b};
  Blockly.xrplhook.string=function(a){var b=a.getFieldValue("type"),c=a.getFieldValue("mystring"),d=Blockly.xrplhook.valueToCode(a,"length",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"string_var",Blockly.xrplhook.ORDER_ATOMIC);b=b+" "+c+"["+d+"] = "+a+";\n";return Blockly.xrplhook.variables_.test2=b};Blockly.xrplhook.define_get=function(a){return[Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.define_declare=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0",c=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);-1==Blockly.Blocks.checkLegalName(Blockly.Msg.VARIABLES_ILLEGALNAME,c)&&this.initVar();a=Blockly.xrplhook.scrub_(a,"#define "+c+" "+b);Blockly.xrplhook.definitions_["define_"+c]=a;return null};
  Blockly.xrplhook.variables_get=function(a){return[Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.xrplhook.ORDER_ATOMIC]};Blockly.xrplhook.variables_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0";return Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};
  Blockly.xrplhook.variables_declare=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0",c=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return a.getFieldValue("TYPES")+" "+c+" = "+b+";\n"};Blockly.xrplhook.variables_pointer_get=function(a){return[Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.variables_pointer_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0";return Blockly.xrplhook.valueToCode(a,"VAR",Blockly.xrplhook.ORDER_ASSIGNMENT)+" = "+b+";\n"};
  Blockly.xrplhook.variables_pointer_declare=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0",c=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),d=a.getFieldValue("TYPES");if("*"==a.getFieldValue("ITERATION")||"**"==a.getFieldValue("ITERATION")||"***"==a.getFieldValue("ITERATION"))a=a.getFieldValue("ITERATION");else return window.alert("please confirm asterisk. that must be among *, **, and  ***."),0;return d+" "+
  a+c+" = "+b+";\n"};Blockly.xrplhook.variables_array_get=function(a){var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=a.getFieldValue("LENGTH_1");0==isNaN(a)&&(a=""==a?-1:1*a);return[b+"["+a+"]",Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.variables_array_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0",c=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),d=a.getFieldValue("LENGTH_1");d=""==d?-1:1*d;var e=Blockly.Blocks.getWantedBlockArray("a");e=Blockly.Blocks.getIndexArray(e,c);var f;e=Blockly.Blocks.checkArrayIndex(d,e[0]);0==e&&-1!=d?(window.alert("\uc778\ub371\uc2a4 \ucd08\uacfc"),a.initIdx(e)):1==e&&0==isAvbNum2?f=c+"["+
  d+"] = "+b+";\n":a.initIdx(e,isAvbNum2,isAvbNum3);return f};Blockly.xrplhook.variables_array_declare=function(a){Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_ASSIGNMENT);var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=a.getFieldValue("TYPES");a=a.getFieldValue("LENGTH_1");return c+" "+b+"["+a+"];\n"};Blockly.xrplhook.logic={};Blockly.xrplhook.controls_if=function(a){var b=0,c=Blockly.xrplhook.valueToCode(a,"IF"+b,Blockly.xrplhook.ORDER_NONE)||"false",d=Blockly.xrplhook.statementToCode(a,"DO"+b),e="if ("+c+") {\n"+d+"}";for(b=1;b<=a.elseifCount_;b++)c=Blockly.xrplhook.valueToCode(a,"IF"+b,Blockly.xrplhook.ORDER_NONE)||"false",d=Blockly.xrplhook.statementToCode(a,"DO"+b),e+=" else if ("+c+") {\n"+d+"}";a.elseCount_&&(d=Blockly.xrplhook.statementToCode(a,"ELSE"),e+=" else {\n"+d+"}");return e+"\n"};
  Blockly.xrplhook.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="==b||"!="==b?Blockly.xrplhook.ORDER_EQUALITY:Blockly.xrplhook.ORDER_RELATIONAL,d=Blockly.xrplhook.valueToCode(a,"A",c)||"0";a=Blockly.xrplhook.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
  Blockly.xrplhook.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"&&":"||",c="&&"==b?Blockly.xrplhook.ORDER_LOGICAL_AND:Blockly.xrplhook.ORDER_LOGICAL_OR,d=Blockly.xrplhook.valueToCode(a,"A",c)||"false";a=Blockly.xrplhook.valueToCode(a,"B",c)||"false";if(d||a){var e="&&"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
  Blockly.xrplhook.logic_negate=function(a){var b=Blockly.xrplhook.ORDER_UNARY_PREFIX;return["!"+(Blockly.xrplhook.valueToCode(a,"BOOL",b)||"false"),b]};Blockly.xrplhook.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.xrplhook.ORDER_ATOMIC]};Blockly.xrplhook.logic_null=function(a){return["NULL",Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.logic_ternary=function(a){var b=Blockly.xrplhook.valueToCode(a,"IF",Blockly.xrplhook.ORDER_CONDITIONAL)||"false",c=Blockly.xrplhook.valueToCode(a,"THEN",Blockly.xrplhook.ORDER_CONDITIONAL)||"null";a=Blockly.xrplhook.valueToCode(a,"ELSE",Blockly.xrplhook.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,Blockly.xrplhook.ORDER_CONDITIONAL]};Blockly.xrplhook.emittedtransaction={};Blockly.xrplhook.etxn_burden=function(a){return["etxn_burden()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.etxn_details=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);return["etxn_details("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.etxn_fee_base=function(a){return["etxn_fee_base("+Blockly.xrplhook.valueToCode(a,"tx_byte_count",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.etxn_reserve=function(a){return"etxn_reserve("+Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.emit=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);return"emit("+Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC)+","+b+");\n"};Blockly.xrplhook.etxn_generation=function(a){return["etxn_generation()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.slot={};Blockly.xrplhook.slot=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC);return["slot("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.slot_clear=function(a){return["slot_clear("+Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.slot_count=function(a){return["slot_count("+Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.slot_id=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC);return["slot_id("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.slot_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC);return["slot_set("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.slot_size=function(a){return["slot_size("+Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.slot_subarray=function(a){var b=Blockly.xrplhook.valueToCode(a,"parent_slot",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"array_id",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"new_slot",Blockly.xrplhook.ORDER_ATOMIC);return["slot_subarray("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.slot_subfield=function(a){var b=Blockly.xrplhook.valueToCode(a,"parent_slot",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"new_slot",Blockly.xrplhook.ORDER_ATOMIC);return["slot_subfield("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.slot_type=function(a){var b=Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"flags",Blockly.xrplhook.ORDER_ATOMIC);return["slot_type("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.slot_float=function(a){return["slot_float("+Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.ledger={};Blockly.xrplhook.hook_hash=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);return["hook_hash("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.ledger_last_hash=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);return["ledger_last_hash("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.nonce=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);return["nonce("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.fee_base=function(a){return["fee_base()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.ledger_seq=function(a){return["ledger_seq()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.hook_account=function(a){return["hook_account("+Blockly.xrplhook.valueToCode(a,"VAR",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.hook_account_statment=function(a){return"hook_account("+Blockly.xrplhook.valueToCode(a,"VAR",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.hooks={};Blockly.xrplhook.firewall=function(a){a.getFieldValue("block_account");var b=Blockly.xrplhook.valueToCode(a,"x",Blockly.xrplhook.ORDER_ATOMIC);a.getFieldValue("wallet_address");Blockly.xrplhook.valueToCode(a,"y",Blockly.xrplhook.ORDER_ATOMIC);a.getFieldValue("blacklist_server");Blockly.xrplhook.valueToCode(a,"z",Blockly.xrplhook.ORDER_ATOMIC);Blockly.xrplhook.addDeclaration("hooks","#defind BLACKLIST_ACCOUNT "+b);return'GUARD(1);\n// fetch the originating account ID \nuint8_t otxn_accid[20];\nif (otxn_field(otxn_accid, 20, sfAccount) != 20)\n    rollback(SBUF("Firewall: Could not fetch sfAccount from originating transaction!!!"), 100);\n\n// RH NOTE in production you should always specify account IDs directly as a preset 20 byte array\n// translating from r-addr here is just for demonstration purposes.\nuint8_t blacklist_accid[20];\nif (util_accid(SBUF(blacklist_accid), SBUF(BLACKLIST_ACCOUNT)) != 20)\n    rollback(SBUF("Firewall: Could not decode blacklist account id."), 200);\n\n// look up the account ID in the foreign state (blacklist accounts hook state)\nuint8_t blacklist_status[1] = { 0 };\nint64_t lookup = state_foreign(SBUF(blacklist_status), SBUF(otxn_accid), SBUF(blacklist_accid));\nif (lookup == INVALID_ACCOUNT)\n    trace(SBUF("Firewall: Warning specified blacklist account does not exist."), 0, 0, 0);\n\nif (blacklist_status[0] == 0)\n    accept(SBUF("Firewall: Allowing transaction."), 0);\n\nrollback(SBUF("Firewall: Blocking transaction from blacklisted account."), 1);\n\n'};
  Blockly.xrplhook.accept=function(a){return'/** \n* This hook just accepts any transaction coming through it\n*/\nTRACESTR("Accept.c: Called.");\naccept (0,0,0); \n_g(1,1);   // every hook needs to import guard function and use it at least once \n// unreachable \n'};Blockly.xrplhook.controls={};Blockly.xrplhook.control_accept=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"error_code",Blockly.xrplhook.ORDER_ATOMIC);return"accept("+b+","+a+");\n"};Blockly.xrplhook.control_rollback=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"error_code",Blockly.xrplhook.ORDER_ATOMIC);return"rollback("+b+","+a+");\n"};Blockly.xrplhook.trace={};Blockly.xrplhook.trace=function(a){var b=Blockly.xrplhook.valueToCode(a,"mread_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"mread_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"dread_ptr",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"dread_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"as_hex",Blockly.xrplhook.ORDER_ATOMIC);return["trace("+b+","+c+","+d+","+e+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.trace_slot=function(a){var b=Blockly.xrplhook.valueToCode(a,"mread_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"mread_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC);return["trace_slot("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.trace_num=function(a){var b=Blockly.xrplhook.valueToCode(a,"mread_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"mread_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"number",Blockly.xrplhook.ORDER_ATOMIC);return["trace_slot("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.trace_float=function(a){var b=Blockly.xrplhook.valueToCode(a,"mread_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"mread_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"float1",Blockly.xrplhook.ORDER_ATOMIC);return["trace_float("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.state=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"kread_len",Blockly.xrplhook.ORDER_ATOMIC);return["state("+b+","+c+","+d+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.state_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"kread_len",Blockly.xrplhook.ORDER_ATOMIC);return["state_set("+b+","+c+","+d+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.state_foreign=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"kread_len",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"aread_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"aread_len",Blockly.xrplhook.ORDER_ATOMIC);
  return["state_foreign("+b+","+c+","+d+","+e+","+f+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.lists={};Blockly.xrplhook.lists_create_empty=function(a){return["[]",Blockly.xrplhook.ORDER_ATOMIC]};Blockly.xrplhook.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=Blockly.xrplhook.valueToCode(a,"ADD"+c,Blockly.xrplhook.ORDER_COMMA)||"null";b="["+b.join(", ")+"]";return[b,Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.lists_repeat=function(a){var b=Blockly.xrplhook.provideFunction_("lists_repeat",["function "+Blockly.xrplhook.FUNCTION_NAME_PLACEHOLDER_+"(value, n) {","  var array = [];","  for (var i = 0; i < n; i++) {","    array[i] = value;","  }","  return array;","}"]),c=Blockly.xrplhook.valueToCode(a,"ITEM",Blockly.xrplhook.ORDER_COMMA)||"null";a=Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_COMMA)||"0";return[b+"("+c+", "+a+")",Blockly.xrplhook.ORDER_FUNCTION_CALL]};
  Blockly.xrplhook.lists_length=function(a){return[(Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_FUNCTION_CALL)||"[]")+".length",Blockly.xrplhook.ORDER_MEMBER]};Blockly.xrplhook.lists_isEmpty=function(a){return["!"+(Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_MEMBER)||"[]")+".length",Blockly.xrplhook.ORDER_LOGICAL_NOT]};
  Blockly.xrplhook.lists_indexOf=function(a){var b="FIRST"==a.getFieldValue("END")?"indexOf":"lastIndexOf",c=Blockly.xrplhook.valueToCode(a,"FIND",Blockly.xrplhook.ORDER_NONE)||"''";return[(Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_MEMBER)||"[]")+"."+b+"("+c+") + 1",Blockly.xrplhook.ORDER_MEMBER]};
  Blockly.xrplhook.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=Blockly.xrplhook.valueToCode(a,"AT",Blockly.xrplhook.ORDER_UNARY_NEGATION)||"1";a=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_MEMBER)||"[]";if("FIRST"==c){if("GET"==b)return[a+"[0]",Blockly.xrplhook.ORDER_MEMBER];if("GET_REMOVE"==b)return[a+".shift()",Blockly.xrplhook.ORDER_MEMBER];if("REMOVE"==b)return a+".shift();\n"}else if("LAST"==c){if("GET"==b)return[a+
  ".slice(-1)[0]",Blockly.xrplhook.ORDER_MEMBER];if("GET_REMOVE"==b)return[a+".pop()",Blockly.xrplhook.ORDER_MEMBER];if("REMOVE"==b)return a+".pop();\n"}else if("FROM_START"==c){d=Blockly.isNumber(d)?parseFloat(d)-1:d+" - 1";if("GET"==b)return[a+"["+d+"]",Blockly.xrplhook.ORDER_MEMBER];if("GET_REMOVE"==b)return[a+".splice("+d+", 1)[0]",Blockly.xrplhook.ORDER_FUNCTION_CALL];if("REMOVE"==b)return a+".splice("+d+", 1);\n"}else if("FROM_END"==c){if("GET"==b)return[a+".slice(-"+d+")[0]",Blockly.xrplhook.ORDER_FUNCTION_CALL];
  if("GET_REMOVE"==b||"REMOVE"==b){c=Blockly.xrplhook.provideFunction_("lists_remove_from_end",["function "+Blockly.xrplhook.FUNCTION_NAME_PLACEHOLDER_+"(list, x) {","  x = list.length - x;","  return list.splice(x, 1)[0];","}"]);d=c+"("+a+", "+d+")";if("GET_REMOVE"==b)return[d,Blockly.xrplhook.ORDER_FUNCTION_CALL];if("REMOVE"==b)return d+";\n"}}else if("RANDOM"==c){c=Blockly.xrplhook.provideFunction_("lists_get_random_item",["function "+Blockly.xrplhook.FUNCTION_NAME_PLACEHOLDER_+"(list, remove) {",
  "  var x = Math.floor(Math.random() * list.length);","  if (remove) {","    return list.splice(x, 1)[0];","  } else {","    return list[x];","  }","}"]);d=c+"("+a+", "+("GET"!=b)+")";if("GET"==b||"GET_REMOVE"==b)return[d,Blockly.xrplhook.ORDER_FUNCTION_CALL];if("REMOVE"==b)return d+";\n"}throw"Unhandled combination (lists_getIndex).";};
  Blockly.xrplhook.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))return"";var g=Blockly.xrplhook.variableDB_.getDistinctName("tmp_list",Blockly.Variables.NAME_TYPE),h="var "+g+" = "+c+";\n";c=g;return h}var c=Blockly.xrplhook.valueToCode(a,"LIST",Blockly.xrplhook.ORDER_MEMBER)||"[]",d=a.getFieldValue("MODE")||"GET",e=a.getFieldValue("WHERE")||"FROM_START",f=Blockly.xrplhook.valueToCode(a,"AT",Blockly.xrplhook.ORDER_NONE)||"1";a=Blockly.xrplhook.valueToCode(a,"TO",Blockly.xrplhook.ORDER_ASSIGNMENT)||
  "null";if("FIRST"==e){if("SET"==d)return c+"[0] = "+a+";\n";if("INSERT"==d)return c+".unshift("+a+");\n"}else if("LAST"==e){if("SET"==d)return e=b(),e+(c+"["+c+".length - 1] = "+a+";\n");if("INSERT"==d)return c+".push("+a+");\n"}else if("FROM_START"==e){f=Blockly.isNumber(f)?parseFloat(f)-1:f+" - 1";if("SET"==d)return c+"["+f+"] = "+a+";\n";if("INSERT"==d)return c+".splice("+f+", 0, "+a+");\n"}else if("FROM_END"==e){e=b();if("SET"==d)return e+(c+"["+c+".length - "+f+"] = "+a+";\n");if("INSERT"==d)return e+
  (c+".splice("+c+".length - "+f+", 0, "+a+");\n")}else if("RANDOM"==e){e=b();f=Blockly.xrplhook.variableDB_.getDistinctName("tmp_x",Blockly.Variables.NAME_TYPE);e+="var "+f+" = Math.floor(Math.random() * "+c+".length);\n";if("SET"==d)return e+(c+"["+f+"] = "+a+";\n");if("INSERT"==d)return e+(c+".splice("+f+", 0, "+a+");\n")}throw"Unhandled combination (lists_setIndex).";};Blockly.xrplhook.utilities={};Blockly.xrplhook.util_raddr=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["util_raddr("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.util_accid=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["util_accid("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.util_verify=function(a){var b=Blockly.xrplhook.valueToCode(a,"dread_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"sread_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["util_verify("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.util_sha512h=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["util_sha512h("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.util_keylet=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"keylet_type",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"a",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"b",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"c",Blockly.xrplhook.ORDER_ATOMIC),g=Blockly.xrplhook.valueToCode(a,"d",Blockly.xrplhook.ORDER_ATOMIC),h=Blockly.xrplhook.valueToCode(a,
  "e",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"f",Blockly.xrplhook.ORDER_ATOMIC);return["util_keylet("+b+","+c+","+d+","+e+","+f+","+g+","+h+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.procedures={};
  Blockly.xrplhook.procedures_defreturn=function(a){var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.xrplhook.statementToCode(a,"STACK");Blockly.xrplhook.STATEMENT_PREFIX&&(c=Blockly.xrplhook.prefixLines(Blockly.xrplhook.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),Blockly.xrplhook.INDENT)+c);Blockly.xrplhook.INFINITE_LOOP_TRAP&&(c=Blockly.xrplhook.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=Blockly.xrplhook.valueToCode(a,"RETURN",
  Blockly.xrplhook.ORDER_NONE)||"";d&&(d="  return "+d+";\n");for(var e=[],f=0;f<a.arguments_.length;f++)e[f]=Blockly.xrplhook.getxrplhookType_(a.getArgType(a.arguments_[f]))+" "+Blockly.xrplhook.variableDB_.getName(a.arguments_[f],Blockly.Variables.NAME_TYPE);f=Blockly.Types.NULL;a.getReturnType&&(f=a.getReturnType());f=Blockly.xrplhook.getxrplhookType_(f);c=f+" "+b+"("+e.join(", ")+") {\n"+c+d+"}";c=Blockly.xrplhook.scrub_(a,c);Blockly.xrplhook.userFunctions_[b]=c;return null};
  Blockly.xrplhook.procedures_defnoreturn=Blockly.xrplhook.procedures_defreturn;Blockly.xrplhook.procedures_callreturn=function(a){for(var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.xrplhook.valueToCode(a,"ARG"+d,Blockly.xrplhook.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.procedures_callnoreturn=function(a){for(var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.xrplhook.valueToCode(a,"ARG"+d,Blockly.xrplhook.ORDER_NONE)||"null";return b+"("+c.join(", ")+");\n"};
  Blockly.xrplhook.procedures_ifreturn=function(a){var b="if ("+(Blockly.xrplhook.valueToCode(a,"CONDITION",Blockly.xrplhook.ORDER_NONE)||"false")+") {\n";a.hasReturnValue_?(a=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_NONE)||"null",b+="  return "+a+";\n"):b+="  return;\n";return b+"}\n"};
  Blockly.xrplhook.xrplhook_functions=function(a){var b=Blockly.xrplhook.statementToCode(a,"SETUP_FUNC");b&&Blockly.xrplhook.addSetup("userSetupCode",b,!0);a=a.getInputTargetBlock("LOOP_FUNC");b=Blockly.xrplhook.blockToCode(a);if(!goog.isString(b))throw'Expecting code from statement block "'+a.type+'".';return b};Blockly.xrplhook.math={};Blockly.xrplhook.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));Infinity==a?a="INFINITY":-Infinity==a&&(a="-INFINITY");return[a,Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.xrplhook.ORDER_ADDITIVE],MINUS:[" - ",Blockly.xrplhook.ORDER_ADDITIVE],MULTIPLY:[" * ",Blockly.xrplhook.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",Blockly.xrplhook.ORDER_MULTIPLICATIVE],POWER:[null,Blockly.xrplhook.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=Blockly.xrplhook.valueToCode(a,"A",b)||"0";a=Blockly.xrplhook.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["Math.pow("+d+", "+a+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"==b)return a=Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_UNARY_PREFIX)||"0","-"==a[0]&&(a=" "+a),["-"+a,Blockly.xrplhook.ORDER_UNARY_PREFIX];a="ABS"==b||"ROUND"==b.substring(0,5)?Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_UNARY_POSTFIX)||"0":"SIN"==b||"COS"==b||"TAN"==b?Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_MULTIPLICATIVE)||"0":Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_NONE)||
  "0";switch(b){case "ABS":var 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 * Math.PI)";break;case "COS":c="cos("+a+" / 180 * Math.PI)";break;case "TAN":c="tan("+a+" / 180 * Math.PI)"}if(c)return[c,Blockly.xrplhook.ORDER_UNARY_POSTFIX];switch(b){case "LOG10":c=
  "log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / M_PI * 180";break;case "ACOS":c="acos("+a+") / M_PI * 180";break;case "ATAN":c="atan("+a+") / M_PI * 180";break;default:throw"Unknown math operator: "+b;}return[c,Blockly.xrplhook.ORDER_MULTIPLICATIVE]};
  Blockly.xrplhook.math_constant=function(a){return{PI:["M_PI",Blockly.xrplhook.ORDER_UNARY_POSTFIX],E:["M_E",Blockly.xrplhook.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",Blockly.xrplhook.ORDER_MULTIPLICATIVE],SQRT2:["M_SQRT2",Blockly.xrplhook.ORDER_UNARY_POSTFIX],SQRT1_2:["M_SQRT1_2",Blockly.xrplhook.ORDER_UNARY_POSTFIX],INFINITY:["INFINITY",Blockly.xrplhook.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
  Blockly.xrplhook.math_number_property=function(a){var b=Blockly.xrplhook.valueToCode(a,"NUMBER_TO_CHECK",Blockly.xrplhook.ORDER_MULTIPLICATIVE)||"0",c=a.getFieldValue("PROPERTY");if("PRIME"==c)return a=Blockly.xrplhook.addFunction("mathIsPrime",["boolean "+Blockly.xrplhook.DEF_FUNC_NAME+"(int 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.\n  // And false if n is divisible by 2 or 3.\n  if (isnan(n) || (n <= 1) || (n == 1) || (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 (int x = 6; x <= sqrt(n) + 1; x += 6) {\n    if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n      return false;\n    }\n  }\n  return true;\n}"].join("\n")),
  Blockly.xrplhook.addInclude("math","#include <math.h>"),[a+"("+b+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX];switch(c){case "EVEN":var d=b+" % 2 == 0";break;case "ODD":d=b+" % 2 == 1";break;case "WHOLE":Blockly.xrplhook.addInclude("math","#include <math.h>");d="(floor("+b+") == "+b+")";break;case "POSITIVE":d=b+" > 0";break;case "NEGATIVE":d=b+" < 0";break;case "DIVISIBLE_BY":a=Blockly.xrplhook.valueToCode(a,"DIVISOR",Blockly.xrplhook.ORDER_MULTIPLICATIVE)||"0",d=b+" % "+a+" == 0"}return[d,Blockly.xrplhook.ORDER_EQUALITY]};
  Blockly.xrplhook.math_change=function(a){var b=Blockly.xrplhook.valueToCode(a,"DELTA",Blockly.xrplhook.ORDER_ADDITIVE)||"0";return Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" += "+b+";\n"};Blockly.xrplhook.math_round=Blockly.xrplhook.math_single;Blockly.xrplhook.math_trig=Blockly.xrplhook.math_single;Blockly.xrplhook.math_on_list=Blockly.xrplhook.noGeneratorCodeInline;
  Blockly.xrplhook.math_modulo=function(a){var b=Blockly.xrplhook.valueToCode(a,"DIVIDEND",Blockly.xrplhook.ORDER_MULTIPLICATIVE)||"0";a=Blockly.xrplhook.valueToCode(a,"DIVISOR",Blockly.xrplhook.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,Blockly.xrplhook.ORDER_MULTIPLICATIVE]};
  Blockly.xrplhook.math_constrain=function(a){var b=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_NONE)||"0",c=Blockly.xrplhook.valueToCode(a,"LOW",Blockly.xrplhook.ORDER_NONE)||"0";a=Blockly.xrplhook.valueToCode(a,"HIGH",Blockly.xrplhook.ORDER_NONE)||"0";return["("+b+" < "+c+" ? "+c+" : ( "+b+" > "+a+" ? "+a+" : "+b+"))",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.math_random_int=function(a){var b=Blockly.xrplhook.valueToCode(a,"FROM",Blockly.xrplhook.ORDER_NONE)||"0";a=Blockly.xrplhook.valueToCode(a,"TO",Blockly.xrplhook.ORDER_NONE)||"0";var c=Blockly.xrplhook.variableDB_.getDistinctName("math_random_int",Blockly.Generator.NAME_TYPE);Blockly.xrplhook.math_random_int.random_function=c;return[Blockly.xrplhook.addFunction("mathRandomInt",["int "+Blockly.xrplhook.DEF_FUNC_NAME+"(int min, int max) {","  if (min > max) {\n    // Swap min and max to ensure min is smaller.\n    int temp = min;\n    min = max;\n    max = temp;\n  }\n  return min + (rand() % (max - min + 1));\n}"].join("\n"))+
  "("+b+", "+a+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.math_random_float=function(a){return["(rand() / RAND_MAX)",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.math_post_inc_decrement=function(a){var b=Blockly.xrplhook.valueToCode(a,"VAR",Blockly.xrplhook.ORDER_ATOMIC);a=a.getFieldValue("op");return[b+a,Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.state={};Blockly.xrplhook.state=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["state("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.state_set=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["state_set("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.state_foreign=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"kread_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"aread_ptr",Blockly.xrplhook.ORDER_ATOMIC);return["state_foreign("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.serialization={};Blockly.xrplhook.sto_subfield=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);return["sto_subfield("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.sto_subarray=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"array_id",Blockly.xrplhook.ORDER_ATOMIC);return["sto_subarray("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.sto_emplace=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"sread_ptr",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"sread_len",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"fread_ptr",Blockly.xrplhook.ORDER_ATOMIC),g=Blockly.xrplhook.valueToCode(a,"fread_len",Blockly.xrplhook.ORDER_ATOMIC);
  a=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);return["sto_emplace("+b+","+c+","+d+","+e+","+f+","+g+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.sto_erase=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);return["sto_erase("+b+","+c+","+d+","+e+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.sto_validate=function(a){var b=Blockly.xrplhook.valueToCode(a,"read_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"read_len",Blockly.xrplhook.ORDER_ATOMIC);return["sto_validate("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.macro={};Blockly.xrplhook.TRACEVAR=function(a){return"TRACEVAR("+Blockly.xrplhook.valueToCode(a,"TRACEVAR",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.TRACESTR=function(a){return"TRACESTR("+Blockly.xrplhook.valueToCode(a,"TRACESTR",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.TRACEHEX=function(a){return"TRACEHEX("+Blockly.xrplhook.valueToCode(a,"TRACEHEX",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.TRACEXFL=function(a){return"TRACEXFL("+Blockly.xrplhook.valueToCode(a,"TRACEXFL",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.sfcodes=function(a){return[a.getFieldValue("VALUE"),Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.amount_to_drops=function(a){return["AMOUNT_TO_DROPS("+Blockly.xrplhook.valueToCode(a,"AMOUNT",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.prepare_payment_simple=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf_out",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"drops_amount",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"drops_fee",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"to_address",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"dest_tag",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"src_tag",Blockly.xrplhook.ORDER_ATOMIC);
  return"PREPARE_PAYMENT_SIMPLE("+b+","+c+","+d+","+e+","+f+","+a+");\n"};Blockly.xrplhook.return_val=function(a){return"retrun("+Blockly.xrplhook.valueToCode(a,"VAR",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.guard=function(a){return"GUARD("+Blockly.xrplhook.valueToCode(a,"arg1",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.require=function(a){var b=Blockly.xrplhook.valueToCode(a,"condtion",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"msg",Blockly.xrplhook.ORDER_ATOMIC);return"REQUIRE("+b+","+a+");\n"};Blockly.xrplhook.sbuf=function(a){return["SBUF("+Blockly.xrplhook.valueToCode(a,"SBUF",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.buffer_equal=function(a){var b=Blockly.xrplhook.valueToCode(a,"equal",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"hook_accid",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"account_field",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"length",Blockly.xrplhook.ORDER_ATOMIC);return"BUFFER_EQUAL("+b+","+c+","+d+","+a+");\n"};
  Blockly.xrplhook.clearbuf=function(a){return"CLEARBUF("+Blockly.xrplhook.valueToCode(a,"buffer",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.sub_offset=function(a){return["SUB_OFFSET("+Blockly.xrplhook.valueToCode(a,"SUB_OFFSET",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.uint32_from_buf=function(a){return["UINT32_FROM_BUF("+Blockly.xrplhook.valueToCode(a,"buffer_input",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.rbuf=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"out_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"str",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"num",Blockly.xrplhook.ORDER_ATOMIC);return"RBUF("+b+", "+c+", "+d+", "+a+");\n"};
  Blockly.xrplhook.rbuf2=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"out_len",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"str",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"num",Blockly.xrplhook.ORDER_ATOMIC),f=Blockly.xrplhook.valueToCode(a,"str2",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"num2",Blockly.xrplhook.ORDER_ATOMIC);return"RBUF2("+b+", "+c+", "+d+", "+
  e+","+f+","+a+");\n"};Blockly.xrplhook.buffer_swap=function(a){var b=Blockly.xrplhook.valueToCode(a,"x",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"y",Blockly.xrplhook.ORDER_ATOMIC);return"BUFFER_SWAP("+b+","+a+");\n"};
  Blockly.xrplhook.buffer_equal_str_guard=function(a){var b=Blockly.xrplhook.valueToCode(a,"output",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"buf1",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"buf1len",Blockly.xrplhook.ORDER_ATOMIC),e=Blockly.xrplhook.valueToCode(a,"str",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"n",Blockly.xrplhook.ORDER_ATOMIC);return"BUFFER_EQUAL_STR_GUARD("+b+","+c+","+d+","+e+","+a+");\n"};
  Blockly.xrplhook.buffer_equal_str=function(a){var b=Blockly.xrplhook.valueToCode(a,"output",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"buf1",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"buf1len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"str",Blockly.xrplhook.ORDER_ATOMIC);return"BUFFER_EQUAL_STR("+b+","+c+","+d+","+a+");\n"};
  Blockly.xrplhook.uint16_to_buf=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf_raw",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"i",Blockly.xrplhook.ORDER_ATOMIC);return"UINT16_TO_BUF("+b+","+a+");\n"};Blockly.xrplhook.uint16_from_buf=function(a){return"UINT16_FROM_BUF("+Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.uint32_to_buf=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf_raw",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"i",Blockly.xrplhook.ORDER_ATOMIC);return"UINT32_TO_BUF("+b+","+a+");\n"};Blockly.xrplhook.uint32_from_buf=function(a){return"UINT32_FROM_BUF("+Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.uint64_to_buf=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf_raw",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"i",Blockly.xrplhook.ORDER_ATOMIC);return"UINT64_TO_BUF("+b+","+a+");\n"};Blockly.xrplhook.uint64_from_buf=function(a){return"UINT64_FROM_BUF("+Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};
  Blockly.xrplhook.int64_to_buf=function(a){var b=Blockly.xrplhook.valueToCode(a,"buf_raw",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"i",Blockly.xrplhook.ORDER_ATOMIC);return"INT64_TO_BUF("+b+","+a+");\n"};Blockly.xrplhook.int64_from_buf=function(a){return"INT64_FROM_BUF("+Blockly.xrplhook.valueToCode(a,"buf",Blockly.xrplhook.ORDER_ATOMIC)+");\n"};Blockly.xrplhook.macro_define=function(a){return[a.getFieldValue("NAME"),Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.colour={};Blockly.xrplhook.colour_picker=Blockly.xrplhook.noGeneratorCodeInline;Blockly.xrplhook.colour_random=Blockly.xrplhook.noGeneratorCodeInline;Blockly.xrplhook.colour_rgb=Blockly.xrplhook.noGeneratorCodeInline;Blockly.xrplhook.colour_blend=Blockly.xrplhook.noGeneratorCodeInline;Blockly.xrplhook.otxn={};Blockly.xrplhook.otxn_burden=function(a){return["otxn_burden()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.otxn_field=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);return["otxn_field("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.otxn_field_txt=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC),c=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"field_id",Blockly.xrplhook.ORDER_ATOMIC);return["otxn_field_txt("+b+","+c+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.otxn_generation=function(a){return["otxn_generation()",Blockly.xrplhook.ORDER_NONE]};
  Blockly.xrplhook.otxn_type=function(a){return["otxn_type()",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.otxn_id=function(a){var b=Blockly.xrplhook.valueToCode(a,"write_ptr",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"write_len",Blockly.xrplhook.ORDER_ATOMIC);return["otxn_id("+b+","+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.otxn_slot=function(a){return["otxn_slot("+Blockly.xrplhook.valueToCode(a,"slot_no",Blockly.xrplhook.ORDER_ATOMIC)+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.loops={};Blockly.xrplhook.controls_repeat=function(a){var b=Number(a.getFieldValue("TIMES")),c=Blockly.xrplhook.statementToCode(a,"DO");c=Blockly.xrplhook.addLoopTrap(c,a.id);a=Blockly.xrplhook.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE);return"for (int "+a+" = 0; "+a+" < "+b+"; "+a+"++) {\n"+c+"}\n"};
  Blockly.xrplhook.controls_repeat_ext=function(a){var b=Blockly.xrplhook.valueToCode(a,"TIMES",Blockly.xrplhook.ORDER_ADDITIVE)||"0",c=Blockly.xrplhook.statementToCode(a,"DO");c=Blockly.xrplhook.addLoopTrap(c,a.id);a="";var d=Blockly.xrplhook.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.xrplhook.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),a+="int "+e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+
  " < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.xrplhook.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.xrplhook.valueToCode(a,"BOOL",b?Blockly.xrplhook.ORDER_LOGICAL_OR:Blockly.xrplhook.ORDER_NONE)||"false",d=Blockly.xrplhook.statementToCode(a,"DO");d=Blockly.xrplhook.addLoopTrap(d,a.id);b&&(c.match(/^\w+$/)||(c="("+c+")"),c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
  Blockly.xrplhook.controls_for=function(a){var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.xrplhook.valueToCode(a,"FROM",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0",d=Blockly.xrplhook.valueToCode(a,"TO",Blockly.xrplhook.ORDER_ASSIGNMENT)||"0";Blockly.xrplhook.valueToCode(a,"BY",Blockly.xrplhook.ORDER_ASSIGNMENT);var e=Blockly.xrplhook.statementToCode(a,"DO");e=Blockly.xrplhook.addLoopTrap(e,a.id);a=parseFloat(c)<=parseFloat(d);return"for ("+b+" = "+
  c+"; GUARD("+d+"),"+b+(a?" <= ":" >= ")+d+"; ++"+b+(") {\n"+e+"}\n")};Blockly.xrplhook.controls_forEach=Blockly.xrplhook.noGeneratorCodeLine;Blockly.xrplhook.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw"Unknown flow statement.";};
  Blockly.xrplhook.loops_for=function(a){var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("var0"),Blockly.Variables.NAME_TYPE),c=Blockly.xrplhook.valueToCode(a,"arg0",Blockly.xrplhook.ORDER_ATOMIC),d=Blockly.xrplhook.valueToCode(a,"arg1",Blockly.xrplhook.ORDER_ATOMIC);Blockly.xrplhook.valueToCode(a,"arg2",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.statementToCode(a,"NAME");return"for (int "+b+" = "+c+"; GUARD("+d+"),"+b+" <"+d+"; ++"+b+(") {\n"+a+"}\n")};Blockly.xrplhook.map={};Blockly.xrplhook.base_map=function(a){var b=Blockly.xrplhook.valueToCode(a,"NUM",Blockly.xrplhook.ORDER_NONE)||"0";a=Blockly.xrplhook.valueToCode(a,"DMAX",Blockly.xrplhook.ORDER_ATOMIC)||"0";return["map("+b+", 0, 1024, 0, "+a+")",Blockly.xrplhook.ORDER_NONE]};Blockly.xrplhook.essential={};Blockly.xrplhook._g_function=function(a){var b=Blockly.xrplhook.valueToCode(a,"arg1",Blockly.xrplhook.ORDER_ATOMIC);a=Blockly.xrplhook.valueToCode(a,"arg2",Blockly.xrplhook.ORDER_ATOMIC);return"_g("+b+","+a+");\n"};Blockly.xrplhook.comment=function(a){return"// "+a.getTitleValue("TEXT")+"\n"};
  Blockly.xrplhook.hook_template=function(a){var b=Blockly.xrplhook.statementToCode(a,"SETUP_FUNC");b&&Blockly.xrplhook.addSetup("userSetupCode",b,!0);a=a.getInputTargetBlock("LOOP_FUNC");b=Blockly.xrplhook.blockToCode(a);if(!goog.isString(b))throw'Expecting code from statement block "'+a.type+'".';return b};Blockly.xrplhook.text={};Blockly.xrplhook.text=function(a){return[Blockly.xrplhook.quote_(a.getFieldValue("TEXT")),Blockly.xrplhook.ORDER_ATOMIC]};
  Blockly.xrplhook.text_join=function(a){if(0==a.itemCount_)return['""',Blockly.xrplhook.ORDER_ATOMIC];if(1==a.itemCount_)return["String("+(Blockly.xrplhook.valueToCode(a,"ADD0",Blockly.xrplhook.ORDER_UNARY_POSTFIX)||'""')+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX];var b=[];for(var c=0;c<a.itemCount_;c++){var d=Blockly.xrplhook.valueToCode(a,"ADD"+c,Blockly.xrplhook.ORDER_NONE);b[c]=""==d?'""':"String("+d+")"}b=b.join(" + ");return[b,Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.text_append=function(a){var b=Blockly.xrplhook.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=Blockly.xrplhook.valueToCode(a,"TEXT",Blockly.xrplhook.ORDER_UNARY_POSTFIX);return b+" += "+(""==a?'""':"String("+a+")")+";\n"};Blockly.xrplhook.text_length=function(a){return["String("+(Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_UNARY_POSTFIX)||'""')+").length()",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.text_isEmpty=function(a){var b=[];b.push("boolean "+Blockly.xrplhook.DEF_FUNC_NAME+"(String msg) {");b.push("  if (msg.length() == 0) {");b.push("    return true;");b.push("  } else {");b.push("    return false;");b.push("  }");b.push("}");b=Blockly.xrplhook.addFunction("isStringEmpty",b.join("\n"));a=Blockly.xrplhook.valueToCode(a,"VALUE",Blockly.xrplhook.ORDER_UNARY_POSTFIX);return[b+"("+(""==a?'""':"String("+a+")")+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.text_trim=function(a){Blockly.xrplhook.text_trim.OPERATORS={LEFT:".trim()",RIGHT:".trim()",BOTH:".trim()"};var b=a.getFieldValue("MODE");b=Blockly.xrplhook.text_trim.OPERATORS[b];a=Blockly.xrplhook.valueToCode(a,"TEXT",Blockly.xrplhook.ORDER_UNARY_POSTFIX);return[(""==a?'""':"String("+a+")")+b,Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.text_print=function(a){var b=Blockly.xrplhook.Boards.selected.serial[0][1];Blockly.xrplhook.addSetup("serial_"+b,b+".begin(9600);",!1);a=Blockly.xrplhook.valueToCode(a,"TEXT",Blockly.xrplhook.ORDER_NONE);return b+".print("+(""==a?'""':"String("+a+")")+");\n"};
  Blockly.xrplhook.text_prompt_ext=function(a){var b=Blockly.xrplhook.Boards.selected.serial[0][1],c=a.getFieldValue("TYPE"),d=[],e=c==Blockly.Types.NUMBER.output;e?d.push("int "+Blockly.xrplhook.DEF_FUNC_NAME+"(String msg) {"):d.push("String "+Blockly.xrplhook.DEF_FUNC_NAME+"(String msg) {");d.push("  "+b+".println(msg);");d.push("  boolean stringComplete = false;");e?d.push("  int content = 0;"):d.push('  String content = "";');d.push("  while (stringComplete == false) {");d.push("    if ("+b+".available()) {");
  e?(d.push("      content = "+b+".parseInt();"),d.push("      stringComplete = true;")):(d.push("      char readChar = (char)"+b+".read();"),d.push("      if (readChar == '\\n' || readChar == '\\r') {"),d.push("        stringComplete = true;"),d.push("      } else {"),d.push("        content += readChar;"),d.push("      }"));d.push("    }");d.push("  }");d.push("  // Empty incoming serial buffer");d.push("  while(Serial.available()) { Serial.read(); };");d.push("  return content;");d.push("}");c=Blockly.xrplhook.addFunction("getUserInputPrompt"+
  c,d.join("\n"));Blockly.xrplhook.addSetup("serial_"+b,b+".begin(9600);",!1);a=Blockly.xrplhook.valueToCode(a,"TEXT",Blockly.xrplhook.ORDER_NONE)||'""';return[c+"("+a+")",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.text_endString=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.text_indexOf=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.text_charAt=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};
  Blockly.xrplhook.text_getSubstring=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.text_changeCase=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};Blockly.xrplhook.text_prompt=function(a){return["",Blockly.xrplhook.ORDER_UNARY_POSTFIX]};