@blockly/block-test
Advanced tools
Comparing version 6.0.1 to 6.0.2
/*! For license information please see index.js.LICENSE.txt */ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var n="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},n={};function o(t){var l=n[t];if(void 0!==l)return l.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{o.r(l),o.d(l,{toolboxTestBlocks:()=>b,toolboxTestBlocksInit:()=>f});var t=o(370);t.defineBlocksWithJsonArray([{type:"test_align_dummy_right",message0:"text right %1 long text right %2",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_all",message0:"text %1 long text left %2 text centre %3 much longer text right %4",args0:[{type:"input_dummy"},{type:"input_dummy",align:"LEFT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_with_external_input",message0:"text right %1 long text centre %2 text left %3 much longer text %4",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"LEFT"},{type:"input_value",name:"VALUE"}],inputsInline:!1,style:"math_blocks"}]),t.defineBlocksWithJsonArray([{type:"test_basic_empty",message0:"",args0:[]},{type:"test_basic_stack",message0:"stack block",previousStatement:null,nextStatement:null,colour:"120"},{type:"test_basic_dummy",message0:"dummy input %1",args0:[{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_multiple_dummy",message0:"first dummy %1 second dummy %2",args0:[{type:"input_dummy"},{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_row",message0:"row block %1",args0:[{type:"input_value",name:"INPUT"}],output:null,style:"math_blocks"},{type:"test_basic_value_to_stack",message0:"value to stack",nextStatement:null,output:null,style:"math_blocks"},{type:"test_basic_value_to_statement",message0:"value to statement %1",args0:[{type:"input_statement",name:"STATEMENT"}],output:null,style:"math_blocks"},{type:"test_basic_limit_instances",message0:"limit 3 instances %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,style:"math_blocks"},{type:"test_basic_tooltips",message0:"%1 %2 %3",args0:[{type:"field_label",name:"NAME",text:"field tooltip",tooltip:"This is a JSON tooltip for the *field*."},{type:"input_dummy"},{type:"field_label",name:"NAME",text:"block tooltip"}],tooltip:"This is a JSON tooltip for the *block*.",style:"math_blocks"},{type:"test_basic_javascript",message0:"function %1(%2) { %3 %4 return %5 }",args0:["foo","args",{type:"input_dummy"},{type:"input_statement",name:"STACK"},{type:"input_value",check:"number",align:"right",name:"RETURN"}],inputsInline:!0,colour:200,tooltip:"Hello world."}]),t.Blocks.test_basic_empty_with_mutator={init:function(){this.setMutator(new t.icons.MutatorIcon(["math_number"],this))},decompose:function(t){const e=t.newBlock("math_number");return e.initSvg(),e},compose:function(){}},t.Blocks.test_chameleon={hasOutput:!0,hasPrevious:!0,init:function(){this.appendDummyInput().appendField("chameleon"),this.setColour(120),this.updateShape()},onchange:function(e){e.type===t.Events.BLOCK_DRAG&&(console.log("got drag event"),this.hasPrevious=!this.outputConnection||!this.outputConnection.targetBlock(),this.hasOutput=!this.getPreviousBlock(),this.updateShape())},updateShape:function(){this.setPreviousStatement(this.hasPrevious),this.setOutput(this.hasOutput)}},t.defineBlocksWithJsonArray([{type:"test_connections_row_input",message0:"%1",args0:[{type:"input_value",name:"NAME"}],colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any output connection."},{type:"test_connections_row_blue",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"greenRel"}],output:"noneOut",colour:230,tooltip:"Output: noneOut\nInput: greenRel\nInput connection can accept yellow blocks but not red blocks."},{type:"test_connections_row_yellow",message0:"%1",args0:[{type:"input_value",name:"NAME",check:["orangeRel","yellowRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nInput can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_row_red",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"noneIn"}],output:"orangeRel",colour:0,tooltip:"Output: orangeRel\nInput: noneIn\nOutput can connect to yellow blocks, but not blue blocks."},{type:"test_connections_row_output",message0:"",output:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."},{type:"test_connections_multivalue_1valid",message0:"none %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:"noneIn"},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: noneIn\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to nothing, except grey blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_multivalue_2valid",message0:"both %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:["yellowRel","orangeRel"]},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: yellowRel, orangeRel\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to yellow blocks and red blocks, but not blue blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."}]);const e=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_row_input">\n <value name="NAME">\n <block type="test_connections_row_blue">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_red">\n <value name="NAME">\n <block type="test_connections_row_output"/>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_stack_next",message0:"",nextStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any previous connection."},{type:"test_connections_stack_blue",message0:"",previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nNext connection can accept yellow blocks but not red blocks."},{type:"test_connections_stack_yellow",message0:"",previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_stack_red",message0:"",previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nPrev can connect to yellow blocks, but not blue blocks."},{type:"test_connections_stack_prev",message0:"",previousStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."}]);const n=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_stack_next">\n <next>\n <block type="test_connections_stack_blue">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_red">\n <next>\n <block type="test_connections_stack_prev"/>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_statement_blue",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"greenRel"}],previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nStatement: greenRel\nNext connection can accept yellow blocks but not red blocks.\nStatement connection can accept yellow blocks but not red blocks."},{type:"test_connections_statement_yellow",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_statement_red",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"noneNext"}],previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nStatement: noneNext\nPrev connection can accept yellow blocks but not blue blocks.\nStatement connection accepts none."},{type:"test_connections_statement_nonext",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_1valid",message0:"none %1 both %2",args0:[{type:"input_statement",name:"NAME",check:"noneNext"},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement cannot connect to anything, except grey blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_2valid",message0:"both %1 both %2",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement connection can accept yellow blocks and red blocks but not blue blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"}]);const s=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_statement_blue">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_red"/>\n </statement>\n </block>\n </statement>\n </block>\n </statement>\n </block>\n</xml>'),n)},i={kind:"CATEGORY",name:"Connections",expanded:"true",contents:[{kind:"CATEGORY",name:"Row",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionRows"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_input"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_output"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow" movable="false">\n </block>\n </value>\n</block>'},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_2valid"}]},{kind:"CATEGORY",name:"Stack",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStacks"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_next"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_prev"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow" movable="false"></block>\n </next>\n</block>'}]},{kind:"CATEGORY",name:"Statement",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStatements"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_red"},{kind:"BLOCK",type:"test_connections_statement_nonext"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_2valid"}]}]};t.defineBlocksWithJsonArray([{type:"test_fields_text_input",message0:"text input %1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_only_text_input",message0:"%1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"textInput",tooltip:"",helpUrl:"",output:"String"},{type:"test_fields_checkbox",message0:"checkbox %1",args0:[{type:"field_checkbox",name:"CHECKBOX",checked:!0}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_variable",message0:"variable %1",args0:[{type:"field_variable",name:"VARIABLE",variable:"item"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_label_serializable",message0:"label serializable %1",args0:[{type:"field_label_serializable",name:"LABEL",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_image",message0:"image %1",args0:[{type:"field_image",name:"IMAGE",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"}],colour:230}]),t.defineBlocksWithJsonArray([{type:"test_numbers_float",message0:"float %1",args0:[{type:"field_number",name:"NUM",text:"0"}],style:"math_blocks",output:"Number",tooltip:"A number."},{type:"test_numbers_whole",message0:"precision 1 %1",args0:[{type:"field_number",name:"NUM",precision:1,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1"},{type:"test_numbers_hundredths",message0:"precision 0.01 %1",args0:[{type:"field_number",name:"NUM",precision:.01,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.01"},{type:"test_numbers_halves",message0:"precision 0.5 %1",args0:[{type:"field_number",name:"NUM",precision:.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.5"},{type:"test_numbers_three_halves",message0:"precision 1.5 %1",args0:[{type:"field_number",name:"NUM",precision:1.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1.5"},{type:"test_numbers_whole_bounded",message0:"midi note %1",args0:[{type:"field_number",name:"NOTE",precision:1,min:1,max:127,text:"0"}],style:"math_blocks",output:"Note",tooltip:"A midi note."}]);t.defineBlocksWithJsonArray([{type:"test_dropdowns_long",message0:"long: %1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["first item","ITEM1"],["second item","ITEM2"],["third item","ITEM3"],["fourth item","ITEM4"],["fifth item","ITEM5"],["sixth item","ITEM6"],["seventh item","ITEM7"],["eighth item","ITEM8"],["ninth item","ITEM9"],["tenth item","ITEM10"],["eleventh item","ITEM11"],["twelfth item","ITEM12"],["thirteenth item","ITEM13"],["fourteenth item","ITEM14"],["fifteenth item","ITEM15"],["sixteenth item","ITEM16"],["seventeenth item","ITEM17"],["eighteenth item","ITEM18"],["nineteenth item","ITEM19"],["twentieth item","ITEM20"],["twenty-first item","ITEM21"],["twenty-second item","ITEM22"],["twenty-third item","ITEM23"],["twenty-fourth item","ITEM24"],["twenty-fifth item","ITEM25"],["twenty-sixth item","ITEM26"],["twenty-seventh item","ITEM27"],["twenty-eighth item","ITEM28"],["twenty-ninth item","ITEM29"],["thirtieth item","ITEM30"],["thirty-first item","ITEM31"],["thirty-second item","ITEM32"]]}]},{type:"test_dropdowns_images",message0:"%1",args0:[{NOTE:"The following paths are relative to playground.html",type:"field_dropdown",name:"FIELDNAME",options:[[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_images_and_text",message0:"%1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["images and text","IMAGES AND TEXT"],[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],["xyz","LMNOP"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_in_mutator",message0:"dropdown mutator",mutator:"test_dropdown_mutator"},{type:"test_dropdowns_in_mutator_block",message0:"dropdown %1",args0:[{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]}]}]);const a=[],c=function(){t.dialog.prompt("Add an option?","option "+a.length,(function(t){t&&(console.log("Adding option: "+t),a.push([t,"OPTION"+a.length]))}))},d=function(){const e=a[0]?a[0][0]:"";t.dialog.prompt("Remove an option?",e,(function(t){for(let e,n=0;e=a[n];n++)e[0]==t&&(console.log("Removing option: "+t),a.splice(n,1))}))};t.Blocks.test_dropdowns_dynamic_random={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic random").appendField(e,"OPTIONS")},dynamicOptions:function(){const t=Math.floor(10*Math.random())+1,e=[];for(let n=0;n<t;n++)e.push([String(n),String(n)]);return e}},t.Blocks.test_dropdowns_dynamic_connect_dependant={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic connect-dependant").appendField(e,"OPTIONS"),this.setNextStatement(!0),this.setPreviousStatement(!0)},dynamicOptions:function(){if(this.sourceBlock_&&this.sourceBlock_.getSurroundParent()){const t=this.sourceBlock_.getSurroundParent(),e=[["connected","CONNECTED_KEY"],[`surroundParent: ${t.type}`,`${t.id}_type_key`],[`surroundParent: ${t.id}`,`${t.id}_key`]],n=this.sourceBlock_.getTopStackBlock();return n.id!==t.id&&(e.push([`topStack: ${n.type}`,`${n.id}_type_key`]),e.push([`topStack: ${n.id}`,`${n.id}_key`])),e}return[["unconnected","UNCONNECTED_KEY"]]}};const p={mutationToDom:function(){return t.utils.xml.createElement("mutation")},domToMutation:function(t){},saveExtraState:function(){return{}},loadExtraState:function(t){},decompose:function(t){const e=t.newBlock("test_dropdowns_in_mutator_block");return e.initSvg(),e},compose:function(t){}};t.Extensions.registerMutator("test_dropdown_mutator",p,null,["test_dropdowns_in_mutator_block"]),t.Blocks.test_dropdowns_dynamic={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic").appendField(e,"OPTIONS")},dynamicOptions:function(){return a.length?a:[["","OPTION0"]]}},t.defineBlocksWithJsonArray([{type:"test_images_datauri",message0:"Image data: URI %1",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAABHZJREFUaAXtmEuPDFEUx8cwJIx4jQjxSGYt4pWQiGSIz4A1O2FtLyx8B4+MxIKEtQkRsZBIEF/AAgki3gzjNfx/Xfc/rkpVd1dXdU13OMm/z73ndc+5r6rqgYHu01wNAfqa5kTZx+1I3PtNJ35Aqe4P6VrW+9mnEl6o/g/hu0Ab6koxg0nsjn+dVF6c+Yr8SZgUaGeRfR0ry6alzEFaGuYY/AryafFODjQ++EKOlfRq+nXSxzTeY2FHGHcocM/uIvXZWoA2ZJ1td0pGjKMoRY6d9Nr8ndemXdrMyayVYr1wQ9gn3BVIhNklNluKg06fNslTFDacG4q4LgwLxIIcO+nV+HtOY5HoF2FbgXG3y3ZKwPdsAb/KTeOZIxESOhRG2SB+SrgvfBDeC/cEZKwgdFjA5wydQHFMy2rh8WWxOYx4UJybiiTBR+Fzqu/nin2kHohj0a+dmEWfNYpwAefV3iSMCiMC5+GSYD0PSgjfWVkJDmoaJLRO8EocUXulMC68EW4KpuNqUAy2+EDpePRnjdj/JMhKUASH37N/S+0FgrePV+akZLWTl3+jRt4j7BbGhCUC9EAgcbbThdC+KL5aMA2Fxi5xbLkMoKXCmEBMYjMG5DGTXgW/XuqtiuVZNr8S4nM7cbBHBbYTehcxqDZJOTGv2DvJoKuC45lvaWiSbRea+cyHNN8i0UwHgyfilwUS+SYsFkiCmSYWD7tXwkOB5J8H7uRcCL48EPEDTMYqgYngneyl8FSAPHbSq+DXSWSFYmuwIhzg4WDgSYr93GY7kjQ++OaR7fP0M3IPNiNo0mBWCcxMm+izCtbBHRM5emR5FOvxi21ZibifF6Mh96BNjSIlgX9GfRJJkwen4CLbgrj2Tcds2Y9nt6VxQYOOkyo4TsO86IrkjRGvjNvmsQ8yCox1cTu2LdQuW4gT4wYyuZ21rbxKtsHHbcdynEK8TCEM7GS5jp3k8pAB16plQdRYCRLHxjp8JwVilSpG/h0TA08IXwUSAyTFNdwM2Nge32sCsTqmTp09c8zsM4H3KB6EJMcqW5+Oj946X88jklHMGoE3AuvVbJ/KbC1G4crkW4Ptsld4KzimZ1yiGSJJF0chy4Q7Av7xta5uMfKgxbz+WPMOxv9VrMhtwcmTJDqADKIAkgVeNWS8CbAi2M4akciEMCXwusFrB0WQPJy+z0qWDh98S58RxeiYvEXgnJUVIdIJcQqBQ8ib6fCNY+FTmMpsLZIlATiH1MQHFWT+Oun+JcvSOVZk3n5zsH3TTEuKgEjCf4k6pjnyZjqvhmMRrzCVWZF4MJLwwzGW086TW1eqAA/mWXO/b/n/Qnpt6f6vyL++Ir6hzCubj7q3lscz79tC/DVoXlkhVT0QWyXkV/TxYGhueSv/lvq6CuFM8CryQjgdsqJf2VmpfK+GJLOYi+FbvtIiGKwbK+JZNo+LQlb5+WCAbqyIY5rHhXSt3Y3BPOPmXUs+Dlzld7K30iMNwD8q3Ex85lquZv8QhzimdD/W9Xyb5H0z1Zbsb+OT/8HoqhrfAAAAAElFTkSuQmCC",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_small",message0:"Image too small %1",args0:[{type:"field_image",src:"media/30px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_large",message0:"Image too large %1",args0:[{type:"field_image",src:"media/200px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_fliprtl",message0:"Image flipped RTL %1",args0:[{type:"field_image",src:"media/arrow.png",width:50,height:50,alt:"*",flipRtl:!0}],colour:160},{type:"test_images_missing",message0:"Image missing %1",args0:[{type:"field_image",src:"missing.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_many_icons",message0:"Lots of network icons: %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18",args0:[{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"}],style:"text_blocks"}]),t.Blocks.test_images_clickhandler={init:function(){this.appendDummyInput().appendField("Image click handler").appendField(new t.FieldImage("https://blockly-demo.appspot.com/static/tests/media/a.png",32,32,"image with click handler",this.onClick_),"IMAGE"),this.setStyle("text_blocks")},onClick_:function(){alert("Image clicked")}};t.Blocks.test_validators_dispose_block={init:function(){this.appendDummyInput().appendField("dispose block").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Any changes to the text cause the block to be disposed")},validate:function(t){"default"!=t&&this.getSourceBlock().dispose(!0)}},t.Blocks.test_validators_text_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The display text will remain the input text, but the value should be the default text. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_text_A={init:function(){this.appendDummyInput().appendField("remove 'a'").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All 'a' characters are removed from field value. The display text will include invalid 'a' characters while the field is being edited, but the value will not.")},validate:function(t){return t.replace(/a/g,"")}},t.Blocks.test_validators_text_B={init:function(){this.appendDummyInput().appendField("'b' -> null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Upon detecting a 'b' character the input will validated to null (invalid). Upon removal it should revert to being valid. The display text will remain the input text, but if the input text is invalid the value should be the default text.")},validate:function(t){return-1!==t.indexOf("b")?null:t}},t.Blocks.test_validators_checkbox_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The new input always validates to null (invalid). This means that the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_checkbox_match={init:function(){this.appendDummyInput().appendField("force match").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. The validator will always return the value of the start-most checkbox. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")}},t.Blocks.test_validators_checkbox_not_match_null={init:function(){this.appendDummyInput().appendField("not match -> null").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. If the new value does not match the value of the start-most checkbox, it will return null (invalid), which means the field value should not change. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")!=t?null:t}},t.Blocks.test_validators_dropdown_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). This means the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_dropdown_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input's value will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_dropdown_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input does not start with 1, the input will validate to null (invalid). Otherwise it will return the input value.")},validate:function(t){return"1"!=t.charAt(0)?null:t}},t.Blocks.test_validators_number_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The field will display the input while the field is being edited, but the value should be the default value. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_number_mult10_force={init:function(){this.appendDummyInput().appendField("force mult of 10").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input value will be rounded to the nearest multiple of 10. The field will display the input while the field is being edited, but the value should be the validated (rounded) value. Note: If you want to do rounding this is not the proper way, use the precision option of the number field constructor instead.")},validate:function(t){return 10*Math.round(t/10)}},t.Blocks.test_validators_number_mult10_null={init:function(){this.appendDummyInput().appendField("not mult of 10 -> null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input value is not a multiple of 10, the input will validate to null (invalid). The field will display the input while the field is being edited, but if the input value is invalid the value should be the default value.")},validate:function(t){return t%10!=0?null:t}},t.Blocks.test_validators_variable_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All ids validate to null (invalid). This means the variable should not change.")},validate:function(t){return null}},t.Blocks.test_validators_variable_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("The id will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_variable_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the id does not start with 1, the id will validate to null (invalid). Otherwise it will return the id.")},validate:function(t){return"1"!=t.charAt(0)?null:t}};const r={kind:"CATEGORY",name:"Fields",expanded:"true",contents:[{kind:"CATEGORY",name:"Defaults",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set random style",callbackkey:"setRandomStyle"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle enabled",callbackkey:"toggleEnabled"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle shadow",callbackkey:"toggleShadow"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle collapsed",callbackkey:"toggleCollapsed"},{kind:"BLOCK",type:"test_fields_checkbox"},{kind:"BLOCK",type:"test_fields_text_input"},{kind:"BLOCK",type:"test_fields_only_text_input"},{kind:"BLOCK",type:"test_fields_variable"},{kind:"BUTTON",text:"randomize label text",callbackkey:"randomizeLabelText"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_label_serializable"},{kind:"BUTTON",text:"change image",callbackkey:"changeImage"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_image"}]},{kind:"CATEGORY",name:"Numbers",contents:[{kind:"BLOCK",blockxml:'\n<block type="test_numbers_float">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_hundredths">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_three_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole_bounded">\n <field name="NOTE">60</field>\n</block>'}]},{kind:"CATEGORY",name:"Drop-downs",contents:[{kind:"LABEL",text:"Dynamic"},{kind:"BLOCK",type:"test_dropdowns_dynamic"},{kind:"BUTTON",text:"Add option",callbackkey:"addDynamicOption"},{kind:"BUTTON",text:"Remove option",callbackkey:"removeDynamicOption"},{kind:"BLOCK",type:"test_dropdowns_dynamic_random"},{kind:"BLOCK",type:"test_dropdowns_dynamic_connect_dependant"},{kind:"LABEL",text:"Other"},{kind:"BLOCK",type:"test_dropdowns_long"},{kind:"BLOCK",type:"test_dropdowns_images"},{kind:"BLOCK",type:"test_dropdowns_images_and_text"}]},{kind:"CATEGORY",name:"Images",contents:[{kind:"BLOCK",type:"test_images_datauri"},{kind:"BLOCK",type:"test_images_small"},{kind:"BLOCK",type:"test_images_large"},{kind:"BLOCK",type:"test_images_fliprtl"},{kind:"BLOCK",type:"test_images_missing"},{kind:"BLOCK",type:"test_images_many_icons"},{kind:"BLOCK",type:"test_images_clickhandler"}]},{kind:"CATEGORY",name:"Emoji! o((*^ᴗ^*))o",contents:[{kind:"LABEL",text:"Unicode & Emojis"},{kind:"BLOCK",type:"test_style_emoji"},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Robot face in text field:🤖</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Zalgo in text field:B̛̻̦̬̘̰͎̥̈̔͊͞ͅl̡͖̫̺̬̖̣̳̃̀́͑͑̕͟͠͝o̢̹͙̮̫͔͋̉̊̑̿̽̚c̸̹̹̜͙̹̠͋̒͑̊̇͝k̡͉̫͇̖̳͖̊͒́̆̄̎̂̔̕͜͞l̰̙̞̳̩̠͖̯̀̆̈́̿̈̓͗y̨̡̟͇̮͈̬̙̲̏̅̀͘͠</field>\n</block>'}]},{kind:"CATEGORY",name:"Validators",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set input",callbackkey:"setInput"},{kind:"LABEL",text:"Dispose block"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dispose_block"},{kind:"LABEL",text:"Checkboxes"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_match"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_not_match_null"},{kind:"LABEL",text:"Dropdowns"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_1s_null"},{kind:"LABEL",text:"Numbers"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_force"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_null"},{kind:"LABEL",text:"Text"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_A"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_B"},{kind:"LABEL",text:"Variables"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"add test variables",callbackkey:"addVariables","web-class":"modifiesWorkspace"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_1s_null"}]}]};t.defineBlocksWithJsonArray([{type:"test_mutator_textChange",message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"}]);const u={mutationToDom:function(){const e=t.utils.xml.createElement("mutation");return e.setAttribute("arbitrary",this.getFieldValue("LABEL")),e},domToMutation:function(t){this.setFieldValue(t.getAttribute("arbitrary"),"LABEL")},saveExtraState:function(){return{arbitrary:this.getFieldValue("LABEL")}},loadExtraState:function(t){this.setFieldValue(t.arbitrary,"LABEL")},decompose:function(e){const n=t.serialization.blocks.append({type:"test_mutator_textChange"},e);return n.getField("MUTATOR_TEXT").setValue(this.getFieldValue("LABEL")),n},compose:function(t){this.setFieldValue(t.getFieldValue("MUTATOR_TEXT"),"LABEL")}},m=[];for(let t=0;t<20;t++)m.push(`test_mutator_category_${t}`);const _=m.map((t=>({type:t,message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"})));t.defineBlocksWithJsonArray([{type:"test_mutators_many",message0:"test many blocks mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_many_blocks_mutator",colour:"#000000"},..._]),t.Extensions.registerMutator("test_many_blocks_mutator",u,null,[...m]),t.defineBlocksWithJsonArray([{type:"test_mutators_noflyout",message0:"noflyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_noflyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_noflyout_mutator",u,null,[]),t.defineBlocksWithJsonArray([{type:"test_mutators_changeableFlyout",message0:"changeable flyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_changeableFlyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_changeableFlyout_mutator",u,null,["text"]),t.defineBlocksWithJsonArray([{type:"test_style_hat",message0:"Hat block (event)",nextStatement:null,style:"hat_blocks"},{type:"test_style_hex1",message0:"Block color: Bright purple %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#992aff"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#992aff"},{type:"test_style_hex2",message0:"Block color: White %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#fefefe"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#fefefe"},{type:"test_style_hex3",message0:"Block color: Black %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#010101"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#010101"},{type:"test_style_no_colour",message0:"Block color: unset"},{type:"test_style_hex4",message0:"Block color: #RRGGBBAA (invalid)",colour:"#992aff99"},{type:"test_style_hex5",message0:"Block color: #RRGGBB (invalid)",colour:"#NotHex"},{type:"test_style_emoji",message0:"Robot Face: 🤖",colour:"#AAAAAA"}]);class h extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}}h.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_no_overrides",h);class k extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}}k.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_xml",k);class y extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}y.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_jso",y);class g extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}g.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_both",g),t.defineBlocksWithJsonArray([{type:"test_field_serialization_no_overrides",message0:"no overrides: %1",args0:[{type:"field_no_overrides",name:"LABEL",text:"test"}],colour:0,output:null},{type:"test_field_serialization_xml",message0:"xml: %1",args0:[{type:"field_xml",name:"LABEL",text:"test"}],colour:30,output:null},{type:"test_field_serialization_jso",message0:"jso: %1",args0:[{type:"field_jso",name:"LABEL",text:"test"}],colour:90,output:null},{type:"test_field_serialization_both",message0:"both: %1",args0:[{type:"field_both",name:"LABEL",text:"test"}],colour:150,output:null}]),t.Blocks.test_extra_state_xml=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_xml.saveExtraState,delete t.Blocks.test_extra_state_xml.loadExtraState,t.Blocks.test_extra_state_xml.init=function(){this.setColour(30),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_jso=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_jso.mutationToDom,delete t.Blocks.test_extra_state_jso.domToMutation,t.Blocks.test_extra_state_jso.init=function(){this.setColour(90),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_both=Object.assign({},t.Blocks.lists_create_with),t.Blocks.test_extra_state_both.init=function(){this.setColour(150),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))};const b={contents:[{kind:"CATEGORY",name:"Align",contents:[{kind:"BLOCK",type:"test_align_dummy_right"},{kind:"BLOCK",type:"test_align_all"},{kind:"BLOCK",type:"test_align_with_external_input"}]},{kind:"CATEGORY",name:"Basic",contents:[{kind:"BLOCK",type:"test_basic_empty"},{kind:"BLOCK",type:"test_basic_empty_with_mutator"},{kind:"BLOCK",type:"test_basic_dummy"},{kind:"BLOCK",type:"test_basic_multiple_dummy"},{kind:"BLOCK",type:"test_basic_stack"},{kind:"BLOCK",type:"test_basic_row"},{kind:"BLOCK",type:"test_basic_value_to_stack"},{kind:"BLOCK",type:"test_basic_value_to_statement"},{kind:"BLOCK",type:"test_basic_limit_instances"},{kind:"BLOCK",type:"test_basic_tooltips"},{kind:"BLOCK",type:"test_basic_javascript"}]},{kind:"CATEGORY",name:"Chameleon",contents:[{kind:"BLOCK",type:"test_chameleon"}]},i,{kind:"CATEGORY",name:"Drag",contents:[{kind:"LABEL",text:"Drag each to the workspace"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="text">\n <field name="TEXT">Drag me by this child</field>\n </block>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Drag me by this shadow</field>\n </shadow>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow value</field>\n </shadow>\n </value>\n <next>\n <shadow type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow statement</field>\n </shadow>\n </value>\n </shadow>\n </next>\n</block>'},{kind:"LABEL",text:"Multiple Variable Refs"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n <next>\n <block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n </block>\n </next>\n</block>'},{kind:"LABEL",text:"Procedure Definitions"},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <field name="NAME">without arguments</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">No argument reference.</field>\n </shadow>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <mutation><arg name="fnArgument"></arg></mutation>\n <field name="NAME">with one argument</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Expected an argument reference here.</field>\n </shadow>\n <block type="variables_get">\n <field name="VAR">fnArgument</field>\n </block>\n </value>\n </block>\n </statement>\n</block>'}]},r,{kind:"CATEGORY",name:"Mutators",contents:[{kind:"LABEL",text:"logic_compare"},{kind:"BLOCK",type:"logic_compare",inputs:{A:{shadow:{type:"math_number",fields:{NUM:10}}},B:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"logic_compare",inputs:{A:{block:{type:"math_number",fields:{NUM:10}}},B:{block:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"test_mutators_noflyout"},{kind:"BLOCK",type:"test_mutators_many"},{kind:"BLOCK",type:"test_mutators_changeableFlyout"}]},{kind:"CATEGORY",name:"Style",contents:[{kind:"LABEL",text:"Hats"},{kind:"BLOCK",type:"test_style_hat"},{kind:"LABEL",text:"Colour"},{kind:"BLOCK",type:"test_style_hex1"},{kind:"BLOCK",type:"test_style_hex2"},{kind:"BLOCK",type:"test_style_hex3"},{kind:"BLOCK",type:"test_style_no_colour"},{kind:"BLOCK",type:"test_style_hex4"},{kind:"BLOCK",type:"test_style_hex5",gap:"40"},{kind:"BLOCK",type:"test_style_hex5",disabled:"true"}]},{kind:"CATEGORY",name:"Serialization",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"randomize text",callbackkey:"randomizeText"},{kind:"BLOCK",type:"test_field_serialization_no_overrides"},{kind:"BLOCK",type:"test_field_serialization_xml"},{kind:"BLOCK",type:"test_field_serialization_jso"},{kind:"BLOCK",type:"test_field_serialization_both"},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="test_extra_state_xml"><mutation items="2"></mutation></block>'},{kind:"BLOCK",type:"test_extra_state_jso",extraState:{itemCount:2}},{kind:"BLOCK",type:"test_extra_state_both",extraState:{itemCount:2}},{kind:"SEP",gap:30},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_no_overrides"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_xml"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_jso"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_both"}}}},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="text_print"><value name="TEXT"><shadow type="test_extra_state_xml"><mutation items="2"></mutation></shadow></value></block>'},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_jso",extraState:{itemCount:2}}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_both",extraState:{itemCount:2}}}}}]}]};function f(o){(function(t){!function(t){t.registerButtonCallback("insertConnectionRows",e)}(t),function(t){t.registerButtonCallback("insertConnectionStacks",n)}(t),function(t){t.registerButtonCallback("insertConnectionStatements",s)}(t)})(o),function(e){!function(t){t.registerButtonCallback("randomizeLabelText",(function(t){const e=t.getTargetWorkspace().getBlocksByType("test_fields_label_serializable");for(let t,n=0;t=e[n];n++){let e="";for(let t=0;t<4;t++)e+="AB".charAt(Math.floor(2*Math.random()));t.setFieldValue(e,"LABEL")}})),t.registerButtonCallback("setRandomStyle",(function(e){const n=e.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1),o=Object.keys(t.getRenderer().getConstants().blockStyles);o.splice(o.indexOf(n[0].getStyleName()),1);const l=o[Math.floor(Math.random()*o.length)];for(let t,e=0;t=n[e];e++)t.setStyle(l)})),t.registerButtonCallback("toggleEnabled",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setEnabled(!t.isEnabled())})),t.registerButtonCallback("toggleShadow",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setShadow(!t.isShadow())})),t.registerButtonCallback("toggleCollapsed",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setCollapsed(!t.isCollapsed())})),t.registerButtonCallback("changeImage",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getBlocksByType("test_fields_image"),n="https://blockly-demo.appspot.com/static/tests/media/"+"abcdefghijklm".charAt(Math.floor(13*Math.random()))+".png";for(let t,o=0;t=e[o];o++)t.getField("IMAGE").setValue(n)}))}(e),function(t){t.registerButtonCallback("addDynamicOption",c),t.registerButtonCallback("removeDynamicOption",d)}(e),function(e){e.registerButtonCallback("addVariables",(function(t){e.createVariable("1b","","1B"),e.createVariable("1c","","1C"),e.createVariable("2a","","2A"),e.createVariable("2b","","2B"),e.createVariable("2c","","2C")})),e.registerButtonCallback("setInput",(function(e){t.dialog.prompt("Input text to set.","ab",(function(t){const n=e.getTargetWorkspace().getAllBlocks(!1);for(let e,o=0;e=n[o];o++)e.getField("INPUT")&&e.setFieldValue(t,"INPUT")}))}))}(e)}(o),function(t){t.registerButtonCallback("randomizeText",(function(t){const e=t.getTargetWorkspace(),n=[...e.getBlocksByType("test_field_serialization_no_overrides"),...e.getBlocksByType("test_field_serialization_xml"),...e.getBlocksByType("test_field_serialization_jso"),...e.getBlocksByType("test_field_serialization_both")];for(let t,e=0;t=n[e];e++){let e="";for(let t=0;t<4;t++)e+="ABCDEF".charAt(Math.floor(6*Math.random()));t.setFieldValue(e,"LABEL")}}))}(o),o.registerButtonCallback("addAllBlocksToWorkspace",(function(e){const n=e.getTargetWorkspace(),o=n.getFlyout().getWorkspace().getTopBlocks();for(let e,l=0;e=o[l];l++){const o=t.serialization.blocks.save(e,{addCoordinates:!0});t.serialization.blocks.append(o,n)}}))}})(),l})())); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var n="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},n={};function o(t){var l=n[t];if(void 0!==l)return l.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{o.r(l),o.d(l,{toolboxTestBlocks:()=>f,toolboxTestBlocksInit:()=>x});var t=o(370);t.defineBlocksWithJsonArray([{type:"test_align_dummy_right",message0:"text right %1 long text right %2",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_all",message0:"text %1 long text left %2 text centre %3 much longer text right %4",args0:[{type:"input_dummy"},{type:"input_dummy",align:"LEFT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_with_external_input",message0:"text right %1 long text centre %2 text left %3 much longer text %4",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"LEFT"},{type:"input_value",name:"VALUE"}],inputsInline:!1,style:"math_blocks"}]),t.defineBlocksWithJsonArray([{type:"test_basic_empty",message0:"",args0:[]},{type:"test_basic_stack",message0:"stack block",previousStatement:null,nextStatement:null,colour:"120"},{type:"test_basic_dummy",message0:"dummy input %1",args0:[{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_multiple_dummy",message0:"first dummy %1 second dummy %2",args0:[{type:"input_dummy"},{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_row",message0:"row block %1",args0:[{type:"input_value",name:"INPUT"}],output:null,style:"math_blocks"},{type:"test_basic_value_to_stack",message0:"value to stack",nextStatement:null,output:null,style:"math_blocks"},{type:"test_basic_value_to_statement",message0:"value to statement %1",args0:[{type:"input_statement",name:"STATEMENT"}],output:null,style:"math_blocks"},{type:"test_basic_limit_instances",message0:"limit 3 instances %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,style:"math_blocks"},{type:"test_basic_tooltips",message0:"%1 %2 %3",args0:[{type:"field_label",name:"NAME",text:"field tooltip",tooltip:"This is a JSON tooltip for the *field*."},{type:"input_dummy"},{type:"field_label",name:"NAME",text:"block tooltip"}],tooltip:"This is a JSON tooltip for the *block*.",style:"math_blocks"},{type:"test_basic_javascript",message0:"function %1(%2) { %3 %4 return %5 }",args0:["foo","args",{type:"input_dummy"},{type:"input_statement",name:"STACK"},{type:"input_value",check:"number",align:"right",name:"RETURN"}],inputsInline:!0,colour:200,tooltip:"Hello world."}]),t.Blocks.test_basic_empty_with_mutator={init:function(){this.setMutator(new t.icons.MutatorIcon(["math_number"],this))},decompose:function(t){const e=t.newBlock("math_number");return e.initSvg(),e},compose:function(){}},t.Blocks.test_chameleon={hasOutput:!0,hasPrevious:!0,init:function(){this.appendDummyInput().appendField("chameleon"),this.setColour(120),this.updateShape()},onchange:function(e){e.type===t.Events.BLOCK_DRAG&&(console.log("got drag event"),this.hasPrevious=!this.outputConnection||!this.outputConnection.targetBlock(),this.hasOutput=!this.getPreviousBlock(),this.updateShape())},updateShape:function(){this.setPreviousStatement(this.hasPrevious),this.setOutput(this.hasOutput)}},t.defineBlocksWithJsonArray([{type:"test_connections_row_input",message0:"%1",args0:[{type:"input_value",name:"NAME"}],colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any output connection."},{type:"test_connections_row_blue",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"greenRel"}],output:"noneOut",colour:230,tooltip:"Output: noneOut\nInput: greenRel\nInput connection can accept yellow blocks but not red blocks."},{type:"test_connections_row_yellow",message0:"%1",args0:[{type:"input_value",name:"NAME",check:["orangeRel","yellowRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nInput can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_row_red",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"noneIn"}],output:"orangeRel",colour:0,tooltip:"Output: orangeRel\nInput: noneIn\nOutput can connect to yellow blocks, but not blue blocks."},{type:"test_connections_row_output",message0:"",output:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."},{type:"test_connections_multivalue_1valid",message0:"none %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:"noneIn"},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: noneIn\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to nothing, except grey blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_multivalue_2valid",message0:"both %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:["yellowRel","orangeRel"]},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: yellowRel, orangeRel\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to yellow blocks and red blocks, but not blue blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."}]);const e=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_row_input">\n <value name="NAME">\n <block type="test_connections_row_blue">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_red">\n <value name="NAME">\n <block type="test_connections_row_output"/>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_stack_next",message0:"",nextStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any previous connection."},{type:"test_connections_stack_blue",message0:"",previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nNext connection can accept yellow blocks but not red blocks."},{type:"test_connections_stack_yellow",message0:"",previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_stack_red",message0:"",previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nPrev can connect to yellow blocks, but not blue blocks."},{type:"test_connections_stack_prev",message0:"",previousStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."}]);const n=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_stack_next">\n <next>\n <block type="test_connections_stack_blue">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_red">\n <next>\n <block type="test_connections_stack_prev"/>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_statement_blue",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"greenRel"}],previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nStatement: greenRel\nNext connection can accept yellow blocks but not red blocks.\nStatement connection can accept yellow blocks but not red blocks."},{type:"test_connections_statement_yellow",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_statement_red",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"noneNext"}],previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nStatement: noneNext\nPrev connection can accept yellow blocks but not blue blocks.\nStatement connection accepts none."},{type:"test_connections_statement_nonext",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_1valid",message0:"none %1 both %2",args0:[{type:"input_statement",name:"NAME",check:"noneNext"},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement cannot connect to anything, except grey blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_2valid",message0:"both %1 both %2",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement connection can accept yellow blocks and red blocks but not blue blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"}]);const s=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_statement_blue">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_red"/>\n </statement>\n </block>\n </statement>\n </block>\n </statement>\n </block>\n</xml>'),n)},i={kind:"CATEGORY",name:"Connections",expanded:"true",contents:[{kind:"CATEGORY",name:"Row",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionRows"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_input"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_output"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow" movable="false">\n </block>\n </value>\n</block>'},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_2valid"}]},{kind:"CATEGORY",name:"Stack",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStacks"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_next"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_prev"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow" movable="false"></block>\n </next>\n</block>'}]},{kind:"CATEGORY",name:"Statement",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStatements"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_red"},{kind:"BLOCK",type:"test_connections_statement_nonext"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_2valid"}]}]};t.Blocks.drag_to_dupe={init:function(){this.setOutput(!0,null),this.appendDummyInput().appendField("drag to dupe"),this.setDragStrategy(new a(this))}};class a{constructor(t){this.block=t}isMovable(){return!0}startDrag(e){const n=this.block.toCopyData();this.copy=t.clipboard.paste(n,this.block.workspace),this.baseStrat=new t.dragging.BlockDragStrategy(this.copy),this.baseStrat.startDrag(e)}drag(t){this.baseStrat.drag(t)}endDrag(t){this.baseStrat.endDrag(t)}revertDrag(t){this.copy.dispose()}}t.defineBlocksWithJsonArray([{type:"test_fields_text_input",message0:"text input %1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_only_text_input",message0:"%1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"textInput",tooltip:"",helpUrl:"",output:"String"},{type:"test_fields_checkbox",message0:"checkbox %1",args0:[{type:"field_checkbox",name:"CHECKBOX",checked:!0}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_variable",message0:"variable %1",args0:[{type:"field_variable",name:"VARIABLE",variable:"item"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_label_serializable",message0:"label serializable %1",args0:[{type:"field_label_serializable",name:"LABEL",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_image",message0:"image %1",args0:[{type:"field_image",name:"IMAGE",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"}],colour:230}]),t.defineBlocksWithJsonArray([{type:"test_numbers_float",message0:"float %1",args0:[{type:"field_number",name:"NUM",text:"0"}],style:"math_blocks",output:"Number",tooltip:"A number."},{type:"test_numbers_whole",message0:"precision 1 %1",args0:[{type:"field_number",name:"NUM",precision:1,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1"},{type:"test_numbers_hundredths",message0:"precision 0.01 %1",args0:[{type:"field_number",name:"NUM",precision:.01,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.01"},{type:"test_numbers_halves",message0:"precision 0.5 %1",args0:[{type:"field_number",name:"NUM",precision:.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.5"},{type:"test_numbers_three_halves",message0:"precision 1.5 %1",args0:[{type:"field_number",name:"NUM",precision:1.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1.5"},{type:"test_numbers_whole_bounded",message0:"midi note %1",args0:[{type:"field_number",name:"NOTE",precision:1,min:1,max:127,text:"0"}],style:"math_blocks",output:"Note",tooltip:"A midi note."}]);t.defineBlocksWithJsonArray([{type:"test_dropdowns_long",message0:"long: %1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["first item","ITEM1"],["second item","ITEM2"],["third item","ITEM3"],["fourth item","ITEM4"],["fifth item","ITEM5"],["sixth item","ITEM6"],["seventh item","ITEM7"],["eighth item","ITEM8"],["ninth item","ITEM9"],["tenth item","ITEM10"],["eleventh item","ITEM11"],["twelfth item","ITEM12"],["thirteenth item","ITEM13"],["fourteenth item","ITEM14"],["fifteenth item","ITEM15"],["sixteenth item","ITEM16"],["seventeenth item","ITEM17"],["eighteenth item","ITEM18"],["nineteenth item","ITEM19"],["twentieth item","ITEM20"],["twenty-first item","ITEM21"],["twenty-second item","ITEM22"],["twenty-third item","ITEM23"],["twenty-fourth item","ITEM24"],["twenty-fifth item","ITEM25"],["twenty-sixth item","ITEM26"],["twenty-seventh item","ITEM27"],["twenty-eighth item","ITEM28"],["twenty-ninth item","ITEM29"],["thirtieth item","ITEM30"],["thirty-first item","ITEM31"],["thirty-second item","ITEM32"]]}]},{type:"test_dropdowns_images",message0:"%1",args0:[{NOTE:"The following paths are relative to playground.html",type:"field_dropdown",name:"FIELDNAME",options:[[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_images_and_text",message0:"%1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["images and text","IMAGES AND TEXT"],[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],["xyz","LMNOP"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_in_mutator",message0:"dropdown mutator",mutator:"test_dropdown_mutator"},{type:"test_dropdowns_in_mutator_block",message0:"dropdown %1",args0:[{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]}]}]);const c=[],d=function(){t.dialog.prompt("Add an option?","option "+c.length,(function(t){t&&(console.log("Adding option: "+t),c.push([t,"OPTION"+c.length]))}))},p=function(){const e=c[0]?c[0][0]:"";t.dialog.prompt("Remove an option?",e,(function(t){for(let e,n=0;e=c[n];n++)e[0]==t&&(console.log("Removing option: "+t),c.splice(n,1))}))};t.Blocks.test_dropdowns_dynamic_random={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic random").appendField(e,"OPTIONS")},dynamicOptions:function(){const t=Math.floor(10*Math.random())+1,e=[];for(let n=0;n<t;n++)e.push([String(n),String(n)]);return e}},t.Blocks.test_dropdowns_dynamic_connect_dependant={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic connect-dependant").appendField(e,"OPTIONS"),this.setNextStatement(!0),this.setPreviousStatement(!0)},dynamicOptions:function(){if(this.sourceBlock_&&this.sourceBlock_.getSurroundParent()){const t=this.sourceBlock_.getSurroundParent(),e=[["connected","CONNECTED_KEY"],[`surroundParent: ${t.type}`,`${t.id}_type_key`],[`surroundParent: ${t.id}`,`${t.id}_key`]],n=this.sourceBlock_.getTopStackBlock();return n.id!==t.id&&(e.push([`topStack: ${n.type}`,`${n.id}_type_key`]),e.push([`topStack: ${n.id}`,`${n.id}_key`])),e}return[["unconnected","UNCONNECTED_KEY"]]}};const r={mutationToDom:function(){return t.utils.xml.createElement("mutation")},domToMutation:function(t){},saveExtraState:function(){return{}},loadExtraState:function(t){},decompose:function(t){const e=t.newBlock("test_dropdowns_in_mutator_block");return e.initSvg(),e},compose:function(t){}};t.Extensions.registerMutator("test_dropdown_mutator",r,null,["test_dropdowns_in_mutator_block"]),t.Blocks.test_dropdowns_dynamic={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic").appendField(e,"OPTIONS")},dynamicOptions:function(){return c.length?c:[["","OPTION0"]]}},t.defineBlocksWithJsonArray([{type:"test_images_datauri",message0:"Image data: URI %1",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAABHZJREFUaAXtmEuPDFEUx8cwJIx4jQjxSGYt4pWQiGSIz4A1O2FtLyx8B4+MxIKEtQkRsZBIEF/AAgki3gzjNfx/Xfc/rkpVd1dXdU13OMm/z73ndc+5r6rqgYHu01wNAfqa5kTZx+1I3PtNJ35Aqe4P6VrW+9mnEl6o/g/hu0Ab6koxg0nsjn+dVF6c+Yr8SZgUaGeRfR0ry6alzEFaGuYY/AryafFODjQ++EKOlfRq+nXSxzTeY2FHGHcocM/uIvXZWoA2ZJ1td0pGjKMoRY6d9Nr8ndemXdrMyayVYr1wQ9gn3BVIhNklNluKg06fNslTFDacG4q4LgwLxIIcO+nV+HtOY5HoF2FbgXG3y3ZKwPdsAb/KTeOZIxESOhRG2SB+SrgvfBDeC/cEZKwgdFjA5wydQHFMy2rh8WWxOYx4UJybiiTBR+Fzqu/nin2kHohj0a+dmEWfNYpwAefV3iSMCiMC5+GSYD0PSgjfWVkJDmoaJLRO8EocUXulMC68EW4KpuNqUAy2+EDpePRnjdj/JMhKUASH37N/S+0FgrePV+akZLWTl3+jRt4j7BbGhCUC9EAgcbbThdC+KL5aMA2Fxi5xbLkMoKXCmEBMYjMG5DGTXgW/XuqtiuVZNr8S4nM7cbBHBbYTehcxqDZJOTGv2DvJoKuC45lvaWiSbRea+cyHNN8i0UwHgyfilwUS+SYsFkiCmSYWD7tXwkOB5J8H7uRcCL48EPEDTMYqgYngneyl8FSAPHbSq+DXSWSFYmuwIhzg4WDgSYr93GY7kjQ++OaR7fP0M3IPNiNo0mBWCcxMm+izCtbBHRM5emR5FOvxi21ZibifF6Mh96BNjSIlgX9GfRJJkwen4CLbgrj2Tcds2Y9nt6VxQYOOkyo4TsO86IrkjRGvjNvmsQ8yCox1cTu2LdQuW4gT4wYyuZ21rbxKtsHHbcdynEK8TCEM7GS5jp3k8pAB16plQdRYCRLHxjp8JwVilSpG/h0TA08IXwUSAyTFNdwM2Nge32sCsTqmTp09c8zsM4H3KB6EJMcqW5+Oj946X88jklHMGoE3AuvVbJ/KbC1G4crkW4Ptsld4KzimZ1yiGSJJF0chy4Q7Av7xta5uMfKgxbz+WPMOxv9VrMhtwcmTJDqADKIAkgVeNWS8CbAi2M4akciEMCXwusFrB0WQPJy+z0qWDh98S58RxeiYvEXgnJUVIdIJcQqBQ8ib6fCNY+FTmMpsLZIlATiH1MQHFWT+Oun+JcvSOVZk3n5zsH3TTEuKgEjCf4k6pjnyZjqvhmMRrzCVWZF4MJLwwzGW086TW1eqAA/mWXO/b/n/Qnpt6f6vyL++Ir6hzCubj7q3lscz79tC/DVoXlkhVT0QWyXkV/TxYGhueSv/lvq6CuFM8CryQjgdsqJf2VmpfK+GJLOYi+FbvtIiGKwbK+JZNo+LQlb5+WCAbqyIY5rHhXSt3Y3BPOPmXUs+Dlzld7K30iMNwD8q3Ex85lquZv8QhzimdD/W9Xyb5H0z1Zbsb+OT/8HoqhrfAAAAAElFTkSuQmCC",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_small",message0:"Image too small %1",args0:[{type:"field_image",src:"media/30px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_large",message0:"Image too large %1",args0:[{type:"field_image",src:"media/200px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_fliprtl",message0:"Image flipped RTL %1",args0:[{type:"field_image",src:"media/arrow.png",width:50,height:50,alt:"*",flipRtl:!0}],colour:160},{type:"test_images_missing",message0:"Image missing %1",args0:[{type:"field_image",src:"missing.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_many_icons",message0:"Lots of network icons: %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18",args0:[{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"}],style:"text_blocks"}]),t.Blocks.test_images_clickhandler={init:function(){this.appendDummyInput().appendField("Image click handler").appendField(new t.FieldImage("https://blockly-demo.appspot.com/static/tests/media/a.png",32,32,"image with click handler",this.onClick_),"IMAGE"),this.setStyle("text_blocks")},onClick_:function(){alert("Image clicked")}};t.Blocks.test_validators_dispose_block={init:function(){this.appendDummyInput().appendField("dispose block").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Any changes to the text cause the block to be disposed")},validate:function(t){"default"!=t&&this.getSourceBlock().dispose(!0)}},t.Blocks.test_validators_text_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The display text will remain the input text, but the value should be the default text. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_text_A={init:function(){this.appendDummyInput().appendField("remove 'a'").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All 'a' characters are removed from field value. The display text will include invalid 'a' characters while the field is being edited, but the value will not.")},validate:function(t){return t.replace(/a/g,"")}},t.Blocks.test_validators_text_B={init:function(){this.appendDummyInput().appendField("'b' -> null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Upon detecting a 'b' character the input will validated to null (invalid). Upon removal it should revert to being valid. The display text will remain the input text, but if the input text is invalid the value should be the default text.")},validate:function(t){return-1!==t.indexOf("b")?null:t}},t.Blocks.test_validators_checkbox_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The new input always validates to null (invalid). This means that the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_checkbox_match={init:function(){this.appendDummyInput().appendField("force match").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. The validator will always return the value of the start-most checkbox. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")}},t.Blocks.test_validators_checkbox_not_match_null={init:function(){this.appendDummyInput().appendField("not match -> null").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. If the new value does not match the value of the start-most checkbox, it will return null (invalid), which means the field value should not change. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")!=t?null:t}},t.Blocks.test_validators_dropdown_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). This means the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_dropdown_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input's value will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_dropdown_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input does not start with 1, the input will validate to null (invalid). Otherwise it will return the input value.")},validate:function(t){return"1"!=t.charAt(0)?null:t}},t.Blocks.test_validators_number_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The field will display the input while the field is being edited, but the value should be the default value. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_number_mult10_force={init:function(){this.appendDummyInput().appendField("force mult of 10").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input value will be rounded to the nearest multiple of 10. The field will display the input while the field is being edited, but the value should be the validated (rounded) value. Note: If you want to do rounding this is not the proper way, use the precision option of the number field constructor instead.")},validate:function(t){return 10*Math.round(t/10)}},t.Blocks.test_validators_number_mult10_null={init:function(){this.appendDummyInput().appendField("not mult of 10 -> null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input value is not a multiple of 10, the input will validate to null (invalid). The field will display the input while the field is being edited, but if the input value is invalid the value should be the default value.")},validate:function(t){return t%10!=0?null:t}},t.Blocks.test_validators_variable_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All ids validate to null (invalid). This means the variable should not change.")},validate:function(t){return null}},t.Blocks.test_validators_variable_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("The id will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_variable_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the id does not start with 1, the id will validate to null (invalid). Otherwise it will return the id.")},validate:function(t){return"1"!=t.charAt(0)?null:t}};const u={kind:"CATEGORY",name:"Fields",expanded:"true",contents:[{kind:"CATEGORY",name:"Defaults",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set random style",callbackkey:"setRandomStyle"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle enabled",callbackkey:"toggleEnabled"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle shadow",callbackkey:"toggleShadow"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle collapsed",callbackkey:"toggleCollapsed"},{kind:"BLOCK",type:"test_fields_checkbox"},{kind:"BLOCK",type:"test_fields_text_input"},{kind:"BLOCK",type:"test_fields_only_text_input"},{kind:"BLOCK",type:"test_fields_variable"},{kind:"BUTTON",text:"randomize label text",callbackkey:"randomizeLabelText"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_label_serializable"},{kind:"BUTTON",text:"change image",callbackkey:"changeImage"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_image"}]},{kind:"CATEGORY",name:"Numbers",contents:[{kind:"BLOCK",blockxml:'\n<block type="test_numbers_float">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_hundredths">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_three_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole_bounded">\n <field name="NOTE">60</field>\n</block>'}]},{kind:"CATEGORY",name:"Drop-downs",contents:[{kind:"LABEL",text:"Dynamic"},{kind:"BLOCK",type:"test_dropdowns_dynamic"},{kind:"BUTTON",text:"Add option",callbackkey:"addDynamicOption"},{kind:"BUTTON",text:"Remove option",callbackkey:"removeDynamicOption"},{kind:"BLOCK",type:"test_dropdowns_dynamic_random"},{kind:"BLOCK",type:"test_dropdowns_dynamic_connect_dependant"},{kind:"LABEL",text:"Other"},{kind:"BLOCK",type:"test_dropdowns_long"},{kind:"BLOCK",type:"test_dropdowns_images"},{kind:"BLOCK",type:"test_dropdowns_images_and_text"}]},{kind:"CATEGORY",name:"Images",contents:[{kind:"BLOCK",type:"test_images_datauri"},{kind:"BLOCK",type:"test_images_small"},{kind:"BLOCK",type:"test_images_large"},{kind:"BLOCK",type:"test_images_fliprtl"},{kind:"BLOCK",type:"test_images_missing"},{kind:"BLOCK",type:"test_images_many_icons"},{kind:"BLOCK",type:"test_images_clickhandler"}]},{kind:"CATEGORY",name:"Emoji! o((*^ᴗ^*))o",contents:[{kind:"LABEL",text:"Unicode & Emojis"},{kind:"BLOCK",type:"test_style_emoji"},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Robot face in text field:🤖</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Zalgo in text field:B̛̻̦̬̘̰͎̥̈̔͊͞ͅl̡͖̫̺̬̖̣̳̃̀́͑͑̕͟͠͝o̢̹͙̮̫͔͋̉̊̑̿̽̚c̸̹̹̜͙̹̠͋̒͑̊̇͝k̡͉̫͇̖̳͖̊͒́̆̄̎̂̔̕͜͞l̰̙̞̳̩̠͖̯̀̆̈́̿̈̓͗y̨̡̟͇̮͈̬̙̲̏̅̀͘͠</field>\n</block>'}]},{kind:"CATEGORY",name:"Validators",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set input",callbackkey:"setInput"},{kind:"LABEL",text:"Dispose block"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dispose_block"},{kind:"LABEL",text:"Checkboxes"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_match"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_not_match_null"},{kind:"LABEL",text:"Dropdowns"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_1s_null"},{kind:"LABEL",text:"Numbers"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_force"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_null"},{kind:"LABEL",text:"Text"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_A"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_B"},{kind:"LABEL",text:"Variables"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"add test variables",callbackkey:"addVariables","web-class":"modifiesWorkspace"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_1s_null"}]}]};t.defineBlocksWithJsonArray([{type:"test_mutator_textChange",message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"}]);const m={mutationToDom:function(){const e=t.utils.xml.createElement("mutation");return e.setAttribute("arbitrary",this.getFieldValue("LABEL")),e},domToMutation:function(t){this.setFieldValue(t.getAttribute("arbitrary"),"LABEL")},saveExtraState:function(){return{arbitrary:this.getFieldValue("LABEL")}},loadExtraState:function(t){this.setFieldValue(t.arbitrary,"LABEL")},decompose:function(e){const n=t.serialization.blocks.append({type:"test_mutator_textChange"},e);return n.getField("MUTATOR_TEXT").setValue(this.getFieldValue("LABEL")),n},compose:function(t){this.setFieldValue(t.getFieldValue("MUTATOR_TEXT"),"LABEL")}},_=[];for(let t=0;t<20;t++)_.push(`test_mutator_category_${t}`);const h=_.map((t=>({type:t,message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"})));t.defineBlocksWithJsonArray([{type:"test_mutators_many",message0:"test many blocks mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_many_blocks_mutator",colour:"#000000"},...h]),t.Extensions.registerMutator("test_many_blocks_mutator",m,null,[..._]),t.defineBlocksWithJsonArray([{type:"test_mutators_noflyout",message0:"noflyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_noflyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_noflyout_mutator",m,null,[]),t.defineBlocksWithJsonArray([{type:"test_mutators_changeableFlyout",message0:"changeable flyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_changeableFlyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_changeableFlyout_mutator",m,null,["text"]),t.defineBlocksWithJsonArray([{type:"test_style_hat",message0:"Hat block (event)",nextStatement:null,style:"hat_blocks"},{type:"test_style_hex1",message0:"Block color: Bright purple %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#992aff"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#992aff"},{type:"test_style_hex2",message0:"Block color: White %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#fefefe"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#fefefe"},{type:"test_style_hex3",message0:"Block color: Black %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#010101"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#010101"},{type:"test_style_no_colour",message0:"Block color: unset"},{type:"test_style_hex4",message0:"Block color: #RRGGBBAA (invalid)",colour:"#992aff99"},{type:"test_style_hex5",message0:"Block color: #RRGGBB (invalid)",colour:"#NotHex"},{type:"test_style_emoji",message0:"Robot Face: 🤖",colour:"#AAAAAA"}]);class k extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}}k.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_no_overrides",k);class y extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}}y.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_xml",y);class g extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}g.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_jso",g);class b extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}b.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_both",b),t.defineBlocksWithJsonArray([{type:"test_field_serialization_no_overrides",message0:"no overrides: %1",args0:[{type:"field_no_overrides",name:"LABEL",text:"test"}],colour:0,output:null},{type:"test_field_serialization_xml",message0:"xml: %1",args0:[{type:"field_xml",name:"LABEL",text:"test"}],colour:30,output:null},{type:"test_field_serialization_jso",message0:"jso: %1",args0:[{type:"field_jso",name:"LABEL",text:"test"}],colour:90,output:null},{type:"test_field_serialization_both",message0:"both: %1",args0:[{type:"field_both",name:"LABEL",text:"test"}],colour:150,output:null}]),t.Blocks.test_extra_state_xml=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_xml.saveExtraState,delete t.Blocks.test_extra_state_xml.loadExtraState,t.Blocks.test_extra_state_xml.init=function(){this.setColour(30),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_jso=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_jso.mutationToDom,delete t.Blocks.test_extra_state_jso.domToMutation,t.Blocks.test_extra_state_jso.init=function(){this.setColour(90),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_both=Object.assign({},t.Blocks.lists_create_with),t.Blocks.test_extra_state_both.init=function(){this.setColour(150),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))};const f={contents:[{kind:"CATEGORY",name:"Align",contents:[{kind:"BLOCK",type:"test_align_dummy_right"},{kind:"BLOCK",type:"test_align_all"},{kind:"BLOCK",type:"test_align_with_external_input"}]},{kind:"CATEGORY",name:"Basic",contents:[{kind:"BLOCK",type:"test_basic_empty"},{kind:"BLOCK",type:"test_basic_empty_with_mutator"},{kind:"BLOCK",type:"test_basic_dummy"},{kind:"BLOCK",type:"test_basic_multiple_dummy"},{kind:"BLOCK",type:"test_basic_stack"},{kind:"BLOCK",type:"test_basic_row"},{kind:"BLOCK",type:"test_basic_value_to_stack"},{kind:"BLOCK",type:"test_basic_value_to_statement"},{kind:"BLOCK",type:"test_basic_limit_instances"},{kind:"BLOCK",type:"test_basic_tooltips"},{kind:"BLOCK",type:"test_basic_javascript"}]},{kind:"CATEGORY",name:"Chameleon",contents:[{kind:"BLOCK",type:"test_chameleon"}]},i,{kind:"CATEGORY",name:"Drag",contents:[{kind:"LABEL",text:"Drag each to the workspace"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="text">\n <field name="TEXT">Drag me by this child</field>\n </block>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Drag me by this shadow</field>\n </shadow>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow value</field>\n </shadow>\n </value>\n <next>\n <shadow type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow statement</field>\n </shadow>\n </value>\n </shadow>\n </next>\n</block>'},{kind:"LABEL",text:"Multiple Variable Refs"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n <next>\n <block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n </block>\n </next>\n</block>'},{kind:"LABEL",text:"Procedure Definitions"},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <field name="NAME">without arguments</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">No argument reference.</field>\n </shadow>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <mutation><arg name="fnArgument"></arg></mutation>\n <field name="NAME">with one argument</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Expected an argument reference here.</field>\n </shadow>\n <block type="variables_get">\n <field name="VAR">fnArgument</field>\n </block>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",type:"drag_to_dupe"},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"drag_to_dupe"}}}}]},u,{kind:"CATEGORY",name:"Mutators",contents:[{kind:"LABEL",text:"logic_compare"},{kind:"BLOCK",type:"logic_compare",inputs:{A:{shadow:{type:"math_number",fields:{NUM:10}}},B:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"logic_compare",inputs:{A:{block:{type:"math_number",fields:{NUM:10}}},B:{block:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"test_mutators_noflyout"},{kind:"BLOCK",type:"test_mutators_many"},{kind:"BLOCK",type:"test_mutators_changeableFlyout"}]},{kind:"CATEGORY",name:"Style",contents:[{kind:"LABEL",text:"Hats"},{kind:"BLOCK",type:"test_style_hat"},{kind:"LABEL",text:"Colour"},{kind:"BLOCK",type:"test_style_hex1"},{kind:"BLOCK",type:"test_style_hex2"},{kind:"BLOCK",type:"test_style_hex3"},{kind:"BLOCK",type:"test_style_no_colour"},{kind:"BLOCK",type:"test_style_hex4"},{kind:"BLOCK",type:"test_style_hex5",gap:"40"},{kind:"BLOCK",type:"test_style_hex5",disabled:"true"}]},{kind:"CATEGORY",name:"Serialization",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"randomize text",callbackkey:"randomizeText"},{kind:"BLOCK",type:"test_field_serialization_no_overrides"},{kind:"BLOCK",type:"test_field_serialization_xml"},{kind:"BLOCK",type:"test_field_serialization_jso"},{kind:"BLOCK",type:"test_field_serialization_both"},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="test_extra_state_xml"><mutation items="2"></mutation></block>'},{kind:"BLOCK",type:"test_extra_state_jso",extraState:{itemCount:2}},{kind:"BLOCK",type:"test_extra_state_both",extraState:{itemCount:2}},{kind:"SEP",gap:30},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_no_overrides"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_xml"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_jso"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_both"}}}},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="text_print"><value name="TEXT"><shadow type="test_extra_state_xml"><mutation items="2"></mutation></shadow></value></block>'},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_jso",extraState:{itemCount:2}}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_both",extraState:{itemCount:2}}}}}]}]};function x(o){(function(t){!function(t){t.registerButtonCallback("insertConnectionRows",e)}(t),function(t){t.registerButtonCallback("insertConnectionStacks",n)}(t),function(t){t.registerButtonCallback("insertConnectionStatements",s)}(t)})(o),function(e){!function(t){t.registerButtonCallback("randomizeLabelText",(function(t){const e=t.getTargetWorkspace().getBlocksByType("test_fields_label_serializable");for(let t,n=0;t=e[n];n++){let e="";for(let t=0;t<4;t++)e+="AB".charAt(Math.floor(2*Math.random()));t.setFieldValue(e,"LABEL")}})),t.registerButtonCallback("setRandomStyle",(function(e){const n=e.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1),o=Object.keys(t.getRenderer().getConstants().blockStyles);o.splice(o.indexOf(n[0].getStyleName()),1);const l=o[Math.floor(Math.random()*o.length)];for(let t,e=0;t=n[e];e++)t.setStyle(l)})),t.registerButtonCallback("toggleEnabled",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setEnabled(!t.isEnabled())})),t.registerButtonCallback("toggleShadow",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setShadow(!t.isShadow())})),t.registerButtonCallback("toggleCollapsed",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setCollapsed(!t.isCollapsed())})),t.registerButtonCallback("changeImage",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getBlocksByType("test_fields_image"),n="https://blockly-demo.appspot.com/static/tests/media/"+"abcdefghijklm".charAt(Math.floor(13*Math.random()))+".png";for(let t,o=0;t=e[o];o++)t.getField("IMAGE").setValue(n)}))}(e),function(t){t.registerButtonCallback("addDynamicOption",d),t.registerButtonCallback("removeDynamicOption",p)}(e),function(e){e.registerButtonCallback("addVariables",(function(t){e.createVariable("1b","","1B"),e.createVariable("1c","","1C"),e.createVariable("2a","","2A"),e.createVariable("2b","","2B"),e.createVariable("2c","","2C")})),e.registerButtonCallback("setInput",(function(e){t.dialog.prompt("Input text to set.","ab",(function(t){const n=e.getTargetWorkspace().getAllBlocks(!1);for(let e,o=0;e=n[o];o++)e.getField("INPUT")&&e.setFieldValue(t,"INPUT")}))}))}(e)}(o),function(t){t.registerButtonCallback("randomizeText",(function(t){const e=t.getTargetWorkspace(),n=[...e.getBlocksByType("test_field_serialization_no_overrides"),...e.getBlocksByType("test_field_serialization_xml"),...e.getBlocksByType("test_field_serialization_jso"),...e.getBlocksByType("test_field_serialization_both")];for(let t,e=0;t=n[e];e++){let e="";for(let t=0;t<4;t++)e+="ABCDEF".charAt(Math.floor(6*Math.random()));t.setFieldValue(e,"LABEL")}}))}(o),o.registerButtonCallback("addAllBlocksToWorkspace",(function(e){const n=e.getTargetWorkspace(),o=n.getFlyout().getWorkspace().getTopBlocks();for(let e,l=0;e=o[l];l++){const o=t.serialization.blocks.save(e,{addCoordinates:!0});t.serialization.blocks.append(o,n)}}))}})(),l})())); | ||
//# sourceMappingURL=index.js.map |
/*! For license information please see index.js.LICENSE.txt */ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var n="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},n={};function o(t){var l=n[t];if(void 0!==l)return l.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{o.r(l),o.d(l,{toolboxTestBlocks:()=>b,toolboxTestBlocksInit:()=>f});var t=o(370);t.defineBlocksWithJsonArray([{type:"test_align_dummy_right",message0:"text right %1 long text right %2",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_all",message0:"text %1 long text left %2 text centre %3 much longer text right %4",args0:[{type:"input_dummy"},{type:"input_dummy",align:"LEFT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_with_external_input",message0:"text right %1 long text centre %2 text left %3 much longer text %4",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"LEFT"},{type:"input_value",name:"VALUE"}],inputsInline:!1,style:"math_blocks"}]),t.defineBlocksWithJsonArray([{type:"test_basic_empty",message0:"",args0:[]},{type:"test_basic_stack",message0:"stack block",previousStatement:null,nextStatement:null,colour:"120"},{type:"test_basic_dummy",message0:"dummy input %1",args0:[{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_multiple_dummy",message0:"first dummy %1 second dummy %2",args0:[{type:"input_dummy"},{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_row",message0:"row block %1",args0:[{type:"input_value",name:"INPUT"}],output:null,style:"math_blocks"},{type:"test_basic_value_to_stack",message0:"value to stack",nextStatement:null,output:null,style:"math_blocks"},{type:"test_basic_value_to_statement",message0:"value to statement %1",args0:[{type:"input_statement",name:"STATEMENT"}],output:null,style:"math_blocks"},{type:"test_basic_limit_instances",message0:"limit 3 instances %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,style:"math_blocks"},{type:"test_basic_tooltips",message0:"%1 %2 %3",args0:[{type:"field_label",name:"NAME",text:"field tooltip",tooltip:"This is a JSON tooltip for the *field*."},{type:"input_dummy"},{type:"field_label",name:"NAME",text:"block tooltip"}],tooltip:"This is a JSON tooltip for the *block*.",style:"math_blocks"},{type:"test_basic_javascript",message0:"function %1(%2) { %3 %4 return %5 }",args0:["foo","args",{type:"input_dummy"},{type:"input_statement",name:"STACK"},{type:"input_value",check:"number",align:"right",name:"RETURN"}],inputsInline:!0,colour:200,tooltip:"Hello world."}]),t.Blocks.test_basic_empty_with_mutator={init:function(){this.setMutator(new t.icons.MutatorIcon(["math_number"],this))},decompose:function(t){const e=t.newBlock("math_number");return e.initSvg(),e},compose:function(){}},t.Blocks.test_chameleon={hasOutput:!0,hasPrevious:!0,init:function(){this.appendDummyInput().appendField("chameleon"),this.setColour(120),this.updateShape()},onchange:function(e){e.type===t.Events.BLOCK_DRAG&&(console.log("got drag event"),this.hasPrevious=!this.outputConnection||!this.outputConnection.targetBlock(),this.hasOutput=!this.getPreviousBlock(),this.updateShape())},updateShape:function(){this.setPreviousStatement(this.hasPrevious),this.setOutput(this.hasOutput)}},t.defineBlocksWithJsonArray([{type:"test_connections_row_input",message0:"%1",args0:[{type:"input_value",name:"NAME"}],colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any output connection."},{type:"test_connections_row_blue",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"greenRel"}],output:"noneOut",colour:230,tooltip:"Output: noneOut\nInput: greenRel\nInput connection can accept yellow blocks but not red blocks."},{type:"test_connections_row_yellow",message0:"%1",args0:[{type:"input_value",name:"NAME",check:["orangeRel","yellowRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nInput can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_row_red",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"noneIn"}],output:"orangeRel",colour:0,tooltip:"Output: orangeRel\nInput: noneIn\nOutput can connect to yellow blocks, but not blue blocks."},{type:"test_connections_row_output",message0:"",output:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."},{type:"test_connections_multivalue_1valid",message0:"none %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:"noneIn"},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: noneIn\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to nothing, except grey blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_multivalue_2valid",message0:"both %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:["yellowRel","orangeRel"]},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: yellowRel, orangeRel\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to yellow blocks and red blocks, but not blue blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."}]);const e=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_row_input">\n <value name="NAME">\n <block type="test_connections_row_blue">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_red">\n <value name="NAME">\n <block type="test_connections_row_output"/>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_stack_next",message0:"",nextStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any previous connection."},{type:"test_connections_stack_blue",message0:"",previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nNext connection can accept yellow blocks but not red blocks."},{type:"test_connections_stack_yellow",message0:"",previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_stack_red",message0:"",previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nPrev can connect to yellow blocks, but not blue blocks."},{type:"test_connections_stack_prev",message0:"",previousStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."}]);const n=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_stack_next">\n <next>\n <block type="test_connections_stack_blue">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_red">\n <next>\n <block type="test_connections_stack_prev"/>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_statement_blue",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"greenRel"}],previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nStatement: greenRel\nNext connection can accept yellow blocks but not red blocks.\nStatement connection can accept yellow blocks but not red blocks."},{type:"test_connections_statement_yellow",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_statement_red",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"noneNext"}],previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nStatement: noneNext\nPrev connection can accept yellow blocks but not blue blocks.\nStatement connection accepts none."},{type:"test_connections_statement_nonext",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_1valid",message0:"none %1 both %2",args0:[{type:"input_statement",name:"NAME",check:"noneNext"},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement cannot connect to anything, except grey blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_2valid",message0:"both %1 both %2",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement connection can accept yellow blocks and red blocks but not blue blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"}]);const s=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_statement_blue">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_red"/>\n </statement>\n </block>\n </statement>\n </block>\n </statement>\n </block>\n</xml>'),n)},i={kind:"CATEGORY",name:"Connections",expanded:"true",contents:[{kind:"CATEGORY",name:"Row",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionRows"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_input"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_output"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow" movable="false">\n </block>\n </value>\n</block>'},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_2valid"}]},{kind:"CATEGORY",name:"Stack",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStacks"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_next"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_prev"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow" movable="false"></block>\n </next>\n</block>'}]},{kind:"CATEGORY",name:"Statement",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStatements"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_red"},{kind:"BLOCK",type:"test_connections_statement_nonext"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_2valid"}]}]};t.defineBlocksWithJsonArray([{type:"test_fields_text_input",message0:"text input %1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_only_text_input",message0:"%1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"textInput",tooltip:"",helpUrl:"",output:"String"},{type:"test_fields_checkbox",message0:"checkbox %1",args0:[{type:"field_checkbox",name:"CHECKBOX",checked:!0}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_variable",message0:"variable %1",args0:[{type:"field_variable",name:"VARIABLE",variable:"item"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_label_serializable",message0:"label serializable %1",args0:[{type:"field_label_serializable",name:"LABEL",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_image",message0:"image %1",args0:[{type:"field_image",name:"IMAGE",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"}],colour:230}]),t.defineBlocksWithJsonArray([{type:"test_numbers_float",message0:"float %1",args0:[{type:"field_number",name:"NUM",text:"0"}],style:"math_blocks",output:"Number",tooltip:"A number."},{type:"test_numbers_whole",message0:"precision 1 %1",args0:[{type:"field_number",name:"NUM",precision:1,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1"},{type:"test_numbers_hundredths",message0:"precision 0.01 %1",args0:[{type:"field_number",name:"NUM",precision:.01,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.01"},{type:"test_numbers_halves",message0:"precision 0.5 %1",args0:[{type:"field_number",name:"NUM",precision:.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.5"},{type:"test_numbers_three_halves",message0:"precision 1.5 %1",args0:[{type:"field_number",name:"NUM",precision:1.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1.5"},{type:"test_numbers_whole_bounded",message0:"midi note %1",args0:[{type:"field_number",name:"NOTE",precision:1,min:1,max:127,text:"0"}],style:"math_blocks",output:"Note",tooltip:"A midi note."}]);t.defineBlocksWithJsonArray([{type:"test_dropdowns_long",message0:"long: %1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["first item","ITEM1"],["second item","ITEM2"],["third item","ITEM3"],["fourth item","ITEM4"],["fifth item","ITEM5"],["sixth item","ITEM6"],["seventh item","ITEM7"],["eighth item","ITEM8"],["ninth item","ITEM9"],["tenth item","ITEM10"],["eleventh item","ITEM11"],["twelfth item","ITEM12"],["thirteenth item","ITEM13"],["fourteenth item","ITEM14"],["fifteenth item","ITEM15"],["sixteenth item","ITEM16"],["seventeenth item","ITEM17"],["eighteenth item","ITEM18"],["nineteenth item","ITEM19"],["twentieth item","ITEM20"],["twenty-first item","ITEM21"],["twenty-second item","ITEM22"],["twenty-third item","ITEM23"],["twenty-fourth item","ITEM24"],["twenty-fifth item","ITEM25"],["twenty-sixth item","ITEM26"],["twenty-seventh item","ITEM27"],["twenty-eighth item","ITEM28"],["twenty-ninth item","ITEM29"],["thirtieth item","ITEM30"],["thirty-first item","ITEM31"],["thirty-second item","ITEM32"]]}]},{type:"test_dropdowns_images",message0:"%1",args0:[{NOTE:"The following paths are relative to playground.html",type:"field_dropdown",name:"FIELDNAME",options:[[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_images_and_text",message0:"%1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["images and text","IMAGES AND TEXT"],[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],["xyz","LMNOP"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_in_mutator",message0:"dropdown mutator",mutator:"test_dropdown_mutator"},{type:"test_dropdowns_in_mutator_block",message0:"dropdown %1",args0:[{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]}]}]);const a=[],c=function(){t.dialog.prompt("Add an option?","option "+a.length,(function(t){t&&(console.log("Adding option: "+t),a.push([t,"OPTION"+a.length]))}))},d=function(){const e=a[0]?a[0][0]:"";t.dialog.prompt("Remove an option?",e,(function(t){for(let e,n=0;e=a[n];n++)e[0]==t&&(console.log("Removing option: "+t),a.splice(n,1))}))};t.Blocks.test_dropdowns_dynamic_random={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic random").appendField(e,"OPTIONS")},dynamicOptions:function(){const t=Math.floor(10*Math.random())+1,e=[];for(let n=0;n<t;n++)e.push([String(n),String(n)]);return e}},t.Blocks.test_dropdowns_dynamic_connect_dependant={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic connect-dependant").appendField(e,"OPTIONS"),this.setNextStatement(!0),this.setPreviousStatement(!0)},dynamicOptions:function(){if(this.sourceBlock_&&this.sourceBlock_.getSurroundParent()){const t=this.sourceBlock_.getSurroundParent(),e=[["connected","CONNECTED_KEY"],[`surroundParent: ${t.type}`,`${t.id}_type_key`],[`surroundParent: ${t.id}`,`${t.id}_key`]],n=this.sourceBlock_.getTopStackBlock();return n.id!==t.id&&(e.push([`topStack: ${n.type}`,`${n.id}_type_key`]),e.push([`topStack: ${n.id}`,`${n.id}_key`])),e}return[["unconnected","UNCONNECTED_KEY"]]}};const p={mutationToDom:function(){return t.utils.xml.createElement("mutation")},domToMutation:function(t){},saveExtraState:function(){return{}},loadExtraState:function(t){},decompose:function(t){const e=t.newBlock("test_dropdowns_in_mutator_block");return e.initSvg(),e},compose:function(t){}};t.Extensions.registerMutator("test_dropdown_mutator",p,null,["test_dropdowns_in_mutator_block"]),t.Blocks.test_dropdowns_dynamic={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic").appendField(e,"OPTIONS")},dynamicOptions:function(){return a.length?a:[["","OPTION0"]]}},t.defineBlocksWithJsonArray([{type:"test_images_datauri",message0:"Image data: URI %1",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAABHZJREFUaAXtmEuPDFEUx8cwJIx4jQjxSGYt4pWQiGSIz4A1O2FtLyx8B4+MxIKEtQkRsZBIEF/AAgki3gzjNfx/Xfc/rkpVd1dXdU13OMm/z73ndc+5r6rqgYHu01wNAfqa5kTZx+1I3PtNJ35Aqe4P6VrW+9mnEl6o/g/hu0Ab6koxg0nsjn+dVF6c+Yr8SZgUaGeRfR0ry6alzEFaGuYY/AryafFODjQ++EKOlfRq+nXSxzTeY2FHGHcocM/uIvXZWoA2ZJ1td0pGjKMoRY6d9Nr8ndemXdrMyayVYr1wQ9gn3BVIhNklNluKg06fNslTFDacG4q4LgwLxIIcO+nV+HtOY5HoF2FbgXG3y3ZKwPdsAb/KTeOZIxESOhRG2SB+SrgvfBDeC/cEZKwgdFjA5wydQHFMy2rh8WWxOYx4UJybiiTBR+Fzqu/nin2kHohj0a+dmEWfNYpwAefV3iSMCiMC5+GSYD0PSgjfWVkJDmoaJLRO8EocUXulMC68EW4KpuNqUAy2+EDpePRnjdj/JMhKUASH37N/S+0FgrePV+akZLWTl3+jRt4j7BbGhCUC9EAgcbbThdC+KL5aMA2Fxi5xbLkMoKXCmEBMYjMG5DGTXgW/XuqtiuVZNr8S4nM7cbBHBbYTehcxqDZJOTGv2DvJoKuC45lvaWiSbRea+cyHNN8i0UwHgyfilwUS+SYsFkiCmSYWD7tXwkOB5J8H7uRcCL48EPEDTMYqgYngneyl8FSAPHbSq+DXSWSFYmuwIhzg4WDgSYr93GY7kjQ++OaR7fP0M3IPNiNo0mBWCcxMm+izCtbBHRM5emR5FOvxi21ZibifF6Mh96BNjSIlgX9GfRJJkwen4CLbgrj2Tcds2Y9nt6VxQYOOkyo4TsO86IrkjRGvjNvmsQ8yCox1cTu2LdQuW4gT4wYyuZ21rbxKtsHHbcdynEK8TCEM7GS5jp3k8pAB16plQdRYCRLHxjp8JwVilSpG/h0TA08IXwUSAyTFNdwM2Nge32sCsTqmTp09c8zsM4H3KB6EJMcqW5+Oj946X88jklHMGoE3AuvVbJ/KbC1G4crkW4Ptsld4KzimZ1yiGSJJF0chy4Q7Av7xta5uMfKgxbz+WPMOxv9VrMhtwcmTJDqADKIAkgVeNWS8CbAi2M4akciEMCXwusFrB0WQPJy+z0qWDh98S58RxeiYvEXgnJUVIdIJcQqBQ8ib6fCNY+FTmMpsLZIlATiH1MQHFWT+Oun+JcvSOVZk3n5zsH3TTEuKgEjCf4k6pjnyZjqvhmMRrzCVWZF4MJLwwzGW086TW1eqAA/mWXO/b/n/Qnpt6f6vyL++Ir6hzCubj7q3lscz79tC/DVoXlkhVT0QWyXkV/TxYGhueSv/lvq6CuFM8CryQjgdsqJf2VmpfK+GJLOYi+FbvtIiGKwbK+JZNo+LQlb5+WCAbqyIY5rHhXSt3Y3BPOPmXUs+Dlzld7K30iMNwD8q3Ex85lquZv8QhzimdD/W9Xyb5H0z1Zbsb+OT/8HoqhrfAAAAAElFTkSuQmCC",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_small",message0:"Image too small %1",args0:[{type:"field_image",src:"media/30px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_large",message0:"Image too large %1",args0:[{type:"field_image",src:"media/200px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_fliprtl",message0:"Image flipped RTL %1",args0:[{type:"field_image",src:"media/arrow.png",width:50,height:50,alt:"*",flipRtl:!0}],colour:160},{type:"test_images_missing",message0:"Image missing %1",args0:[{type:"field_image",src:"missing.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_many_icons",message0:"Lots of network icons: %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18",args0:[{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"}],style:"text_blocks"}]),t.Blocks.test_images_clickhandler={init:function(){this.appendDummyInput().appendField("Image click handler").appendField(new t.FieldImage("https://blockly-demo.appspot.com/static/tests/media/a.png",32,32,"image with click handler",this.onClick_),"IMAGE"),this.setStyle("text_blocks")},onClick_:function(){alert("Image clicked")}};t.Blocks.test_validators_dispose_block={init:function(){this.appendDummyInput().appendField("dispose block").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Any changes to the text cause the block to be disposed")},validate:function(t){"default"!=t&&this.getSourceBlock().dispose(!0)}},t.Blocks.test_validators_text_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The display text will remain the input text, but the value should be the default text. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_text_A={init:function(){this.appendDummyInput().appendField("remove 'a'").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All 'a' characters are removed from field value. The display text will include invalid 'a' characters while the field is being edited, but the value will not.")},validate:function(t){return t.replace(/a/g,"")}},t.Blocks.test_validators_text_B={init:function(){this.appendDummyInput().appendField("'b' -> null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Upon detecting a 'b' character the input will validated to null (invalid). Upon removal it should revert to being valid. The display text will remain the input text, but if the input text is invalid the value should be the default text.")},validate:function(t){return-1!==t.indexOf("b")?null:t}},t.Blocks.test_validators_checkbox_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The new input always validates to null (invalid). This means that the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_checkbox_match={init:function(){this.appendDummyInput().appendField("force match").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. The validator will always return the value of the start-most checkbox. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")}},t.Blocks.test_validators_checkbox_not_match_null={init:function(){this.appendDummyInput().appendField("not match -> null").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. If the new value does not match the value of the start-most checkbox, it will return null (invalid), which means the field value should not change. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")!=t?null:t}},t.Blocks.test_validators_dropdown_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). This means the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_dropdown_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input's value will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_dropdown_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input does not start with 1, the input will validate to null (invalid). Otherwise it will return the input value.")},validate:function(t){return"1"!=t.charAt(0)?null:t}},t.Blocks.test_validators_number_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The field will display the input while the field is being edited, but the value should be the default value. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_number_mult10_force={init:function(){this.appendDummyInput().appendField("force mult of 10").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input value will be rounded to the nearest multiple of 10. The field will display the input while the field is being edited, but the value should be the validated (rounded) value. Note: If you want to do rounding this is not the proper way, use the precision option of the number field constructor instead.")},validate:function(t){return 10*Math.round(t/10)}},t.Blocks.test_validators_number_mult10_null={init:function(){this.appendDummyInput().appendField("not mult of 10 -> null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input value is not a multiple of 10, the input will validate to null (invalid). The field will display the input while the field is being edited, but if the input value is invalid the value should be the default value.")},validate:function(t){return t%10!=0?null:t}},t.Blocks.test_validators_variable_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All ids validate to null (invalid). This means the variable should not change.")},validate:function(t){return null}},t.Blocks.test_validators_variable_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("The id will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_variable_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the id does not start with 1, the id will validate to null (invalid). Otherwise it will return the id.")},validate:function(t){return"1"!=t.charAt(0)?null:t}};const r={kind:"CATEGORY",name:"Fields",expanded:"true",contents:[{kind:"CATEGORY",name:"Defaults",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set random style",callbackkey:"setRandomStyle"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle enabled",callbackkey:"toggleEnabled"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle shadow",callbackkey:"toggleShadow"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle collapsed",callbackkey:"toggleCollapsed"},{kind:"BLOCK",type:"test_fields_checkbox"},{kind:"BLOCK",type:"test_fields_text_input"},{kind:"BLOCK",type:"test_fields_only_text_input"},{kind:"BLOCK",type:"test_fields_variable"},{kind:"BUTTON",text:"randomize label text",callbackkey:"randomizeLabelText"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_label_serializable"},{kind:"BUTTON",text:"change image",callbackkey:"changeImage"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_image"}]},{kind:"CATEGORY",name:"Numbers",contents:[{kind:"BLOCK",blockxml:'\n<block type="test_numbers_float">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_hundredths">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_three_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole_bounded">\n <field name="NOTE">60</field>\n</block>'}]},{kind:"CATEGORY",name:"Drop-downs",contents:[{kind:"LABEL",text:"Dynamic"},{kind:"BLOCK",type:"test_dropdowns_dynamic"},{kind:"BUTTON",text:"Add option",callbackkey:"addDynamicOption"},{kind:"BUTTON",text:"Remove option",callbackkey:"removeDynamicOption"},{kind:"BLOCK",type:"test_dropdowns_dynamic_random"},{kind:"BLOCK",type:"test_dropdowns_dynamic_connect_dependant"},{kind:"LABEL",text:"Other"},{kind:"BLOCK",type:"test_dropdowns_long"},{kind:"BLOCK",type:"test_dropdowns_images"},{kind:"BLOCK",type:"test_dropdowns_images_and_text"}]},{kind:"CATEGORY",name:"Images",contents:[{kind:"BLOCK",type:"test_images_datauri"},{kind:"BLOCK",type:"test_images_small"},{kind:"BLOCK",type:"test_images_large"},{kind:"BLOCK",type:"test_images_fliprtl"},{kind:"BLOCK",type:"test_images_missing"},{kind:"BLOCK",type:"test_images_many_icons"},{kind:"BLOCK",type:"test_images_clickhandler"}]},{kind:"CATEGORY",name:"Emoji! o((*^ᴗ^*))o",contents:[{kind:"LABEL",text:"Unicode & Emojis"},{kind:"BLOCK",type:"test_style_emoji"},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Robot face in text field:🤖</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Zalgo in text field:B̛̻̦̬̘̰͎̥̈̔͊͞ͅl̡͖̫̺̬̖̣̳̃̀́͑͑̕͟͠͝o̢̹͙̮̫͔͋̉̊̑̿̽̚c̸̹̹̜͙̹̠͋̒͑̊̇͝k̡͉̫͇̖̳͖̊͒́̆̄̎̂̔̕͜͞l̰̙̞̳̩̠͖̯̀̆̈́̿̈̓͗y̨̡̟͇̮͈̬̙̲̏̅̀͘͠</field>\n</block>'}]},{kind:"CATEGORY",name:"Validators",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set input",callbackkey:"setInput"},{kind:"LABEL",text:"Dispose block"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dispose_block"},{kind:"LABEL",text:"Checkboxes"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_match"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_not_match_null"},{kind:"LABEL",text:"Dropdowns"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_1s_null"},{kind:"LABEL",text:"Numbers"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_force"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_null"},{kind:"LABEL",text:"Text"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_A"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_B"},{kind:"LABEL",text:"Variables"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"add test variables",callbackkey:"addVariables","web-class":"modifiesWorkspace"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_1s_null"}]}]};t.defineBlocksWithJsonArray([{type:"test_mutator_textChange",message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"}]);const u={mutationToDom:function(){const e=t.utils.xml.createElement("mutation");return e.setAttribute("arbitrary",this.getFieldValue("LABEL")),e},domToMutation:function(t){this.setFieldValue(t.getAttribute("arbitrary"),"LABEL")},saveExtraState:function(){return{arbitrary:this.getFieldValue("LABEL")}},loadExtraState:function(t){this.setFieldValue(t.arbitrary,"LABEL")},decompose:function(e){const n=t.serialization.blocks.append({type:"test_mutator_textChange"},e);return n.getField("MUTATOR_TEXT").setValue(this.getFieldValue("LABEL")),n},compose:function(t){this.setFieldValue(t.getFieldValue("MUTATOR_TEXT"),"LABEL")}},m=[];for(let t=0;t<20;t++)m.push(`test_mutator_category_${t}`);const _=m.map((t=>({type:t,message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"})));t.defineBlocksWithJsonArray([{type:"test_mutators_many",message0:"test many blocks mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_many_blocks_mutator",colour:"#000000"},..._]),t.Extensions.registerMutator("test_many_blocks_mutator",u,null,[...m]),t.defineBlocksWithJsonArray([{type:"test_mutators_noflyout",message0:"noflyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_noflyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_noflyout_mutator",u,null,[]),t.defineBlocksWithJsonArray([{type:"test_mutators_changeableFlyout",message0:"changeable flyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_changeableFlyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_changeableFlyout_mutator",u,null,["text"]),t.defineBlocksWithJsonArray([{type:"test_style_hat",message0:"Hat block (event)",nextStatement:null,style:"hat_blocks"},{type:"test_style_hex1",message0:"Block color: Bright purple %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#992aff"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#992aff"},{type:"test_style_hex2",message0:"Block color: White %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#fefefe"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#fefefe"},{type:"test_style_hex3",message0:"Block color: Black %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#010101"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#010101"},{type:"test_style_no_colour",message0:"Block color: unset"},{type:"test_style_hex4",message0:"Block color: #RRGGBBAA (invalid)",colour:"#992aff99"},{type:"test_style_hex5",message0:"Block color: #RRGGBB (invalid)",colour:"#NotHex"},{type:"test_style_emoji",message0:"Robot Face: 🤖",colour:"#AAAAAA"}]);class h extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}}h.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_no_overrides",h);class k extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}}k.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_xml",k);class y extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}y.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_jso",y);class g extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}g.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_both",g),t.defineBlocksWithJsonArray([{type:"test_field_serialization_no_overrides",message0:"no overrides: %1",args0:[{type:"field_no_overrides",name:"LABEL",text:"test"}],colour:0,output:null},{type:"test_field_serialization_xml",message0:"xml: %1",args0:[{type:"field_xml",name:"LABEL",text:"test"}],colour:30,output:null},{type:"test_field_serialization_jso",message0:"jso: %1",args0:[{type:"field_jso",name:"LABEL",text:"test"}],colour:90,output:null},{type:"test_field_serialization_both",message0:"both: %1",args0:[{type:"field_both",name:"LABEL",text:"test"}],colour:150,output:null}]),t.Blocks.test_extra_state_xml=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_xml.saveExtraState,delete t.Blocks.test_extra_state_xml.loadExtraState,t.Blocks.test_extra_state_xml.init=function(){this.setColour(30),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_jso=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_jso.mutationToDom,delete t.Blocks.test_extra_state_jso.domToMutation,t.Blocks.test_extra_state_jso.init=function(){this.setColour(90),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_both=Object.assign({},t.Blocks.lists_create_with),t.Blocks.test_extra_state_both.init=function(){this.setColour(150),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))};const b={contents:[{kind:"CATEGORY",name:"Align",contents:[{kind:"BLOCK",type:"test_align_dummy_right"},{kind:"BLOCK",type:"test_align_all"},{kind:"BLOCK",type:"test_align_with_external_input"}]},{kind:"CATEGORY",name:"Basic",contents:[{kind:"BLOCK",type:"test_basic_empty"},{kind:"BLOCK",type:"test_basic_empty_with_mutator"},{kind:"BLOCK",type:"test_basic_dummy"},{kind:"BLOCK",type:"test_basic_multiple_dummy"},{kind:"BLOCK",type:"test_basic_stack"},{kind:"BLOCK",type:"test_basic_row"},{kind:"BLOCK",type:"test_basic_value_to_stack"},{kind:"BLOCK",type:"test_basic_value_to_statement"},{kind:"BLOCK",type:"test_basic_limit_instances"},{kind:"BLOCK",type:"test_basic_tooltips"},{kind:"BLOCK",type:"test_basic_javascript"}]},{kind:"CATEGORY",name:"Chameleon",contents:[{kind:"BLOCK",type:"test_chameleon"}]},i,{kind:"CATEGORY",name:"Drag",contents:[{kind:"LABEL",text:"Drag each to the workspace"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="text">\n <field name="TEXT">Drag me by this child</field>\n </block>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Drag me by this shadow</field>\n </shadow>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow value</field>\n </shadow>\n </value>\n <next>\n <shadow type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow statement</field>\n </shadow>\n </value>\n </shadow>\n </next>\n</block>'},{kind:"LABEL",text:"Multiple Variable Refs"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n <next>\n <block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n </block>\n </next>\n</block>'},{kind:"LABEL",text:"Procedure Definitions"},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <field name="NAME">without arguments</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">No argument reference.</field>\n </shadow>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <mutation><arg name="fnArgument"></arg></mutation>\n <field name="NAME">with one argument</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Expected an argument reference here.</field>\n </shadow>\n <block type="variables_get">\n <field name="VAR">fnArgument</field>\n </block>\n </value>\n </block>\n </statement>\n</block>'}]},r,{kind:"CATEGORY",name:"Mutators",contents:[{kind:"LABEL",text:"logic_compare"},{kind:"BLOCK",type:"logic_compare",inputs:{A:{shadow:{type:"math_number",fields:{NUM:10}}},B:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"logic_compare",inputs:{A:{block:{type:"math_number",fields:{NUM:10}}},B:{block:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"test_mutators_noflyout"},{kind:"BLOCK",type:"test_mutators_many"},{kind:"BLOCK",type:"test_mutators_changeableFlyout"}]},{kind:"CATEGORY",name:"Style",contents:[{kind:"LABEL",text:"Hats"},{kind:"BLOCK",type:"test_style_hat"},{kind:"LABEL",text:"Colour"},{kind:"BLOCK",type:"test_style_hex1"},{kind:"BLOCK",type:"test_style_hex2"},{kind:"BLOCK",type:"test_style_hex3"},{kind:"BLOCK",type:"test_style_no_colour"},{kind:"BLOCK",type:"test_style_hex4"},{kind:"BLOCK",type:"test_style_hex5",gap:"40"},{kind:"BLOCK",type:"test_style_hex5",disabled:"true"}]},{kind:"CATEGORY",name:"Serialization",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"randomize text",callbackkey:"randomizeText"},{kind:"BLOCK",type:"test_field_serialization_no_overrides"},{kind:"BLOCK",type:"test_field_serialization_xml"},{kind:"BLOCK",type:"test_field_serialization_jso"},{kind:"BLOCK",type:"test_field_serialization_both"},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="test_extra_state_xml"><mutation items="2"></mutation></block>'},{kind:"BLOCK",type:"test_extra_state_jso",extraState:{itemCount:2}},{kind:"BLOCK",type:"test_extra_state_both",extraState:{itemCount:2}},{kind:"SEP",gap:30},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_no_overrides"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_xml"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_jso"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_both"}}}},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="text_print"><value name="TEXT"><shadow type="test_extra_state_xml"><mutation items="2"></mutation></shadow></value></block>'},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_jso",extraState:{itemCount:2}}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_both",extraState:{itemCount:2}}}}}]}]};function f(o){(function(t){!function(t){t.registerButtonCallback("insertConnectionRows",e)}(t),function(t){t.registerButtonCallback("insertConnectionStacks",n)}(t),function(t){t.registerButtonCallback("insertConnectionStatements",s)}(t)})(o),function(e){!function(t){t.registerButtonCallback("randomizeLabelText",(function(t){const e=t.getTargetWorkspace().getBlocksByType("test_fields_label_serializable");for(let t,n=0;t=e[n];n++){let e="";for(let t=0;t<4;t++)e+="AB".charAt(Math.floor(2*Math.random()));t.setFieldValue(e,"LABEL")}})),t.registerButtonCallback("setRandomStyle",(function(e){const n=e.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1),o=Object.keys(t.getRenderer().getConstants().blockStyles);o.splice(o.indexOf(n[0].getStyleName()),1);const l=o[Math.floor(Math.random()*o.length)];for(let t,e=0;t=n[e];e++)t.setStyle(l)})),t.registerButtonCallback("toggleEnabled",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setEnabled(!t.isEnabled())})),t.registerButtonCallback("toggleShadow",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setShadow(!t.isShadow())})),t.registerButtonCallback("toggleCollapsed",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setCollapsed(!t.isCollapsed())})),t.registerButtonCallback("changeImage",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getBlocksByType("test_fields_image"),n="https://blockly-demo.appspot.com/static/tests/media/"+"abcdefghijklm".charAt(Math.floor(13*Math.random()))+".png";for(let t,o=0;t=e[o];o++)t.getField("IMAGE").setValue(n)}))}(e),function(t){t.registerButtonCallback("addDynamicOption",c),t.registerButtonCallback("removeDynamicOption",d)}(e),function(e){e.registerButtonCallback("addVariables",(function(t){e.createVariable("1b","","1B"),e.createVariable("1c","","1C"),e.createVariable("2a","","2A"),e.createVariable("2b","","2B"),e.createVariable("2c","","2C")})),e.registerButtonCallback("setInput",(function(e){t.dialog.prompt("Input text to set.","ab",(function(t){const n=e.getTargetWorkspace().getAllBlocks(!1);for(let e,o=0;e=n[o];o++)e.getField("INPUT")&&e.setFieldValue(t,"INPUT")}))}))}(e)}(o),function(t){t.registerButtonCallback("randomizeText",(function(t){const e=t.getTargetWorkspace(),n=[...e.getBlocksByType("test_field_serialization_no_overrides"),...e.getBlocksByType("test_field_serialization_xml"),...e.getBlocksByType("test_field_serialization_jso"),...e.getBlocksByType("test_field_serialization_both")];for(let t,e=0;t=n[e];e++){let e="";for(let t=0;t<4;t++)e+="ABCDEF".charAt(Math.floor(6*Math.random()));t.setFieldValue(e,"LABEL")}}))}(o),o.registerButtonCallback("addAllBlocksToWorkspace",(function(e){const n=e.getTargetWorkspace(),o=n.getFlyout().getWorkspace().getTopBlocks();for(let e,l=0;e=o[l];l++){const o=t.serialization.blocks.save(e,{addCoordinates:!0});t.serialization.blocks.append(o,n)}}))}})(),l})())); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var n="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},n={};function o(t){var l=n[t];if(void 0!==l)return l.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{o.r(l),o.d(l,{toolboxTestBlocks:()=>f,toolboxTestBlocksInit:()=>x});var t=o(370);t.defineBlocksWithJsonArray([{type:"test_align_dummy_right",message0:"text right %1 long text right %2",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_all",message0:"text %1 long text left %2 text centre %3 much longer text right %4",args0:[{type:"input_dummy"},{type:"input_dummy",align:"LEFT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"RIGHT"}],style:"math_blocks"},{type:"test_align_with_external_input",message0:"text right %1 long text centre %2 text left %3 much longer text %4",args0:[{type:"input_dummy",align:"RIGHT"},{type:"input_dummy",align:"CENTRE"},{type:"input_dummy",align:"LEFT"},{type:"input_value",name:"VALUE"}],inputsInline:!1,style:"math_blocks"}]),t.defineBlocksWithJsonArray([{type:"test_basic_empty",message0:"",args0:[]},{type:"test_basic_stack",message0:"stack block",previousStatement:null,nextStatement:null,colour:"120"},{type:"test_basic_dummy",message0:"dummy input %1",args0:[{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_multiple_dummy",message0:"first dummy %1 second dummy %2",args0:[{type:"input_dummy"},{type:"input_dummy"}],style:"math_blocks"},{type:"test_basic_row",message0:"row block %1",args0:[{type:"input_value",name:"INPUT"}],output:null,style:"math_blocks"},{type:"test_basic_value_to_stack",message0:"value to stack",nextStatement:null,output:null,style:"math_blocks"},{type:"test_basic_value_to_statement",message0:"value to statement %1",args0:[{type:"input_statement",name:"STATEMENT"}],output:null,style:"math_blocks"},{type:"test_basic_limit_instances",message0:"limit 3 instances %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,style:"math_blocks"},{type:"test_basic_tooltips",message0:"%1 %2 %3",args0:[{type:"field_label",name:"NAME",text:"field tooltip",tooltip:"This is a JSON tooltip for the *field*."},{type:"input_dummy"},{type:"field_label",name:"NAME",text:"block tooltip"}],tooltip:"This is a JSON tooltip for the *block*.",style:"math_blocks"},{type:"test_basic_javascript",message0:"function %1(%2) { %3 %4 return %5 }",args0:["foo","args",{type:"input_dummy"},{type:"input_statement",name:"STACK"},{type:"input_value",check:"number",align:"right",name:"RETURN"}],inputsInline:!0,colour:200,tooltip:"Hello world."}]),t.Blocks.test_basic_empty_with_mutator={init:function(){this.setMutator(new t.icons.MutatorIcon(["math_number"],this))},decompose:function(t){const e=t.newBlock("math_number");return e.initSvg(),e},compose:function(){}},t.Blocks.test_chameleon={hasOutput:!0,hasPrevious:!0,init:function(){this.appendDummyInput().appendField("chameleon"),this.setColour(120),this.updateShape()},onchange:function(e){e.type===t.Events.BLOCK_DRAG&&(console.log("got drag event"),this.hasPrevious=!this.outputConnection||!this.outputConnection.targetBlock(),this.hasOutput=!this.getPreviousBlock(),this.updateShape())},updateShape:function(){this.setPreviousStatement(this.hasPrevious),this.setOutput(this.hasOutput)}},t.defineBlocksWithJsonArray([{type:"test_connections_row_input",message0:"%1",args0:[{type:"input_value",name:"NAME"}],colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any output connection."},{type:"test_connections_row_blue",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"greenRel"}],output:"noneOut",colour:230,tooltip:"Output: noneOut\nInput: greenRel\nInput connection can accept yellow blocks but not red blocks."},{type:"test_connections_row_yellow",message0:"%1",args0:[{type:"input_value",name:"NAME",check:["orangeRel","yellowRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nInput can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_row_red",message0:"%1",args0:[{type:"input_value",name:"NAME",check:"noneIn"}],output:"orangeRel",colour:0,tooltip:"Output: orangeRel\nInput: noneIn\nOutput can connect to yellow blocks, but not blue blocks."},{type:"test_connections_row_output",message0:"",output:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."},{type:"test_connections_multivalue_1valid",message0:"none %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:"noneIn"},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: noneIn\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to nothing, except grey blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_multivalue_2valid",message0:"both %1 both %2",args0:[{type:"input_value",name:"NAME1",align:"RIGHT",check:["yellowRel","orangeRel"]},{type:"input_value",name:"NAME2",align:"RIGHT",check:["yellowRel","orangeRel"]}],output:["yellowRel","greenRel"],colour:60,tooltip:"Output: yellowRel, greenRel\nInput Top: yellowRel, orangeRel\nInput Bottom: yellowRel, orangeRel\nOutput can connect to yellow blocks and blue blocks, but not red blocks.\nTop Input can connect to yellow blocks and red blocks, but not blue blocks.\nBottom Input can connect to yellow blocks and red blocks, but not blue blocks."}]);const e=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_row_input">\n <value name="NAME">\n <block type="test_connections_row_blue">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_red">\n <value name="NAME">\n <block type="test_connections_row_output"/>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n </value>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_stack_next",message0:"",nextStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any previous connection."},{type:"test_connections_stack_blue",message0:"",previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nNext connection can accept yellow blocks but not red blocks."},{type:"test_connections_stack_yellow",message0:"",previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks."},{type:"test_connections_stack_red",message0:"",previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nPrev can connect to yellow blocks, but not blue blocks."},{type:"test_connections_stack_prev",message0:"",previousStatement:null,colour:"#aaaaaa",tooltip:"No Checks\nCan connect to any input connection."}]);const n=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_stack_next">\n <next>\n <block type="test_connections_stack_blue">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_red">\n <next>\n <block type="test_connections_stack_prev"/>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n</xml>'),n)};t.defineBlocksWithJsonArray([{type:"test_connections_statement_blue",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"greenRel"}],previousStatement:"nonePrev",nextStatement:"greenRel",colour:230,tooltip:"Prev: nonePrev\nNext: greenRel\nStatement: greenRel\nNext connection can accept yellow blocks but not red blocks.\nStatement connection can accept yellow blocks but not red blocks."},{type:"test_connections_statement_yellow",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],nextStatement:["yellowRel","orangeRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nNext can connect to yellow blocks and red blocks, but not blue blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_statement_red",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:"noneNext"}],previousStatement:"orangeRel",nextStatement:"noneNext",colour:0,tooltip:"Prev: orangeRel\nNext: noneNext\nStatement: noneNext\nPrev connection can accept yellow blocks but not blue blocks.\nStatement connection accepts none."},{type:"test_connections_statement_nonext",message0:"%1",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nStatement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_1valid",message0:"none %1 both %2",args0:[{type:"input_statement",name:"NAME",check:"noneNext"},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement cannot connect to anything, except grey blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"},{type:"test_connections_multistatement_2valid",message0:"both %1 both %2",args0:[{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]},{type:"input_statement",name:"NAME",check:["yellowRel","orangeRel"]}],previousStatement:["greenRel","yellowRel"],colour:60,tooltip:"Prev: yellowRel, greenRel\nNext: yellowRel, orangeRel\nStatement: orangeRel\nPrev can connect to yellow blocks and blue blocks, but not red blocks.\nTop Statement connection can accept yellow blocks and red blocks but not blue blocks.\nBottom Statement connection can accept yellow blocks and red blocks but not blue blocks.\n"}]);const s=function(e){const n=e.getTargetWorkspace();t.Xml.domToWorkspace(t.utils.xml.textToDom('<xml xmlns="https://developers.google.com/blockly/xml">\n <block type="test_connections_statement_blue">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_yellow">\n <statement name="NAME">\n <block type="test_connections_statement_red"/>\n </statement>\n </block>\n </statement>\n </block>\n </statement>\n </block>\n</xml>'),n)},i={kind:"CATEGORY",name:"Connections",expanded:"true",contents:[{kind:"CATEGORY",name:"Row",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionRows"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_input"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_row_output"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_row_yellow">\n <value name="NAME">\n <block type="test_connections_row_yellow" movable="false">\n </block>\n </value>\n</block>'},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multivalue_2valid"}]},{kind:"CATEGORY",name:"Stack",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStacks"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_next"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_red"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_stack_prev"},{kind:"BLOCK",blockxml:'\n<block type="test_connections_stack_yellow">\n <next>\n <block type="test_connections_stack_yellow" movable="false"></block>\n </next>\n</block>'}]},{kind:"CATEGORY",name:"Statement",contents:[{kind:"LABEL",text:"blocks have"},{kind:"SEP",gap:"-1"},{kind:"LABEL",text:"tooltips"},{kind:"BUTTON",text:"insert",callbackkey:"insertConnectionStatements"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_blue"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_yellow"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_statement_red"},{kind:"BLOCK",type:"test_connections_statement_nonext"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_1valid"},{kind:"SEP",gap:"7"},{kind:"BLOCK",type:"test_connections_multistatement_2valid"}]}]};t.Blocks.drag_to_dupe={init:function(){this.setOutput(!0,null),this.appendDummyInput().appendField("drag to dupe"),this.setDragStrategy(new a(this))}};class a{constructor(t){this.block=t}isMovable(){return!0}startDrag(e){const n=this.block.toCopyData();this.copy=t.clipboard.paste(n,this.block.workspace),this.baseStrat=new t.dragging.BlockDragStrategy(this.copy),this.baseStrat.startDrag(e)}drag(t){this.baseStrat.drag(t)}endDrag(t){this.baseStrat.endDrag(t)}revertDrag(t){this.copy.dispose()}}t.defineBlocksWithJsonArray([{type:"test_fields_text_input",message0:"text input %1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_only_text_input",message0:"%1",args0:[{type:"field_input",name:"TEXT_INPUT",text:"default"}],style:"textInput",tooltip:"",helpUrl:"",output:"String"},{type:"test_fields_checkbox",message0:"checkbox %1",args0:[{type:"field_checkbox",name:"CHECKBOX",checked:!0}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_variable",message0:"variable %1",args0:[{type:"field_variable",name:"VARIABLE",variable:"item"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_label_serializable",message0:"label serializable %1",args0:[{type:"field_label_serializable",name:"LABEL",text:"default"}],style:"math_blocks",tooltip:"",helpUrl:""},{type:"test_fields_image",message0:"image %1",args0:[{type:"field_image",name:"IMAGE",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"}],colour:230}]),t.defineBlocksWithJsonArray([{type:"test_numbers_float",message0:"float %1",args0:[{type:"field_number",name:"NUM",text:"0"}],style:"math_blocks",output:"Number",tooltip:"A number."},{type:"test_numbers_whole",message0:"precision 1 %1",args0:[{type:"field_number",name:"NUM",precision:1,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1"},{type:"test_numbers_hundredths",message0:"precision 0.01 %1",args0:[{type:"field_number",name:"NUM",precision:.01,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.01"},{type:"test_numbers_halves",message0:"precision 0.5 %1",args0:[{type:"field_number",name:"NUM",precision:.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 0.5"},{type:"test_numbers_three_halves",message0:"precision 1.5 %1",args0:[{type:"field_number",name:"NUM",precision:1.5,text:"0"}],style:"math_blocks",output:"Number",tooltip:"The number should be rounded to multiples of 1.5"},{type:"test_numbers_whole_bounded",message0:"midi note %1",args0:[{type:"field_number",name:"NOTE",precision:1,min:1,max:127,text:"0"}],style:"math_blocks",output:"Note",tooltip:"A midi note."}]);t.defineBlocksWithJsonArray([{type:"test_dropdowns_long",message0:"long: %1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["first item","ITEM1"],["second item","ITEM2"],["third item","ITEM3"],["fourth item","ITEM4"],["fifth item","ITEM5"],["sixth item","ITEM6"],["seventh item","ITEM7"],["eighth item","ITEM8"],["ninth item","ITEM9"],["tenth item","ITEM10"],["eleventh item","ITEM11"],["twelfth item","ITEM12"],["thirteenth item","ITEM13"],["fourteenth item","ITEM14"],["fifteenth item","ITEM15"],["sixteenth item","ITEM16"],["seventeenth item","ITEM17"],["eighteenth item","ITEM18"],["nineteenth item","ITEM19"],["twentieth item","ITEM20"],["twenty-first item","ITEM21"],["twenty-second item","ITEM22"],["twenty-third item","ITEM23"],["twenty-fourth item","ITEM24"],["twenty-fifth item","ITEM25"],["twenty-sixth item","ITEM26"],["twenty-seventh item","ITEM27"],["twenty-eighth item","ITEM28"],["twenty-ninth item","ITEM29"],["thirtieth item","ITEM30"],["thirty-first item","ITEM31"],["thirty-second item","ITEM32"]]}]},{type:"test_dropdowns_images",message0:"%1",args0:[{NOTE:"The following paths are relative to playground.html",type:"field_dropdown",name:"FIELDNAME",options:[[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_images_and_text",message0:"%1",args0:[{type:"field_dropdown",name:"FIELDNAME",options:[["images and text","IMAGES AND TEXT"],[{src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},"A"],[{src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},"B"],[{src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},"C"],[{src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},"D"],[{src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},"E"],[{src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},"F"],[{src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},"G"],[{src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},"H"],["xyz","LMNOP"],[{src:"https://blockly-demo.appspot.com/static/tests/media/i.png",width:32,height:32,alt:"I"},"I"],[{src:"https://blockly-demo.appspot.com/static/tests/media/j.png",width:32,height:32,alt:"J"},"J"],[{src:"https://blockly-demo.appspot.com/static/tests/media/k.png",width:32,height:32,alt:"K"},"K"],[{src:"https://blockly-demo.appspot.com/static/tests/media/l.png",width:32,height:32,alt:"L"},"L"],[{src:"https://blockly-demo.appspot.com/static/tests/media/m.png",width:32,height:32,alt:"M"},"M"]]}]},{type:"test_dropdowns_in_mutator",message0:"dropdown mutator",mutator:"test_dropdown_mutator"},{type:"test_dropdowns_in_mutator_block",message0:"dropdown %1",args0:[{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]}]}]);const c=[],d=function(){t.dialog.prompt("Add an option?","option "+c.length,(function(t){t&&(console.log("Adding option: "+t),c.push([t,"OPTION"+c.length]))}))},p=function(){const e=c[0]?c[0][0]:"";t.dialog.prompt("Remove an option?",e,(function(t){for(let e,n=0;e=c[n];n++)e[0]==t&&(console.log("Removing option: "+t),c.splice(n,1))}))};t.Blocks.test_dropdowns_dynamic_random={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic random").appendField(e,"OPTIONS")},dynamicOptions:function(){const t=Math.floor(10*Math.random())+1,e=[];for(let n=0;n<t;n++)e.push([String(n),String(n)]);return e}},t.Blocks.test_dropdowns_dynamic_connect_dependant={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic connect-dependant").appendField(e,"OPTIONS"),this.setNextStatement(!0),this.setPreviousStatement(!0)},dynamicOptions:function(){if(this.sourceBlock_&&this.sourceBlock_.getSurroundParent()){const t=this.sourceBlock_.getSurroundParent(),e=[["connected","CONNECTED_KEY"],[`surroundParent: ${t.type}`,`${t.id}_type_key`],[`surroundParent: ${t.id}`,`${t.id}_key`]],n=this.sourceBlock_.getTopStackBlock();return n.id!==t.id&&(e.push([`topStack: ${n.type}`,`${n.id}_type_key`]),e.push([`topStack: ${n.id}`,`${n.id}_key`])),e}return[["unconnected","UNCONNECTED_KEY"]]}};const r={mutationToDom:function(){return t.utils.xml.createElement("mutation")},domToMutation:function(t){},saveExtraState:function(){return{}},loadExtraState:function(t){},decompose:function(t){const e=t.newBlock("test_dropdowns_in_mutator_block");return e.initSvg(),e},compose:function(t){}};t.Extensions.registerMutator("test_dropdown_mutator",r,null,["test_dropdowns_in_mutator_block"]),t.Blocks.test_dropdowns_dynamic={init:function(){const e=new t.FieldDropdown(this.dynamicOptions);this.appendDummyInput().appendField("dynamic").appendField(e,"OPTIONS")},dynamicOptions:function(){return c.length?c:[["","OPTION0"]]}},t.defineBlocksWithJsonArray([{type:"test_images_datauri",message0:"Image data: URI %1",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAABHZJREFUaAXtmEuPDFEUx8cwJIx4jQjxSGYt4pWQiGSIz4A1O2FtLyx8B4+MxIKEtQkRsZBIEF/AAgki3gzjNfx/Xfc/rkpVd1dXdU13OMm/z73ndc+5r6rqgYHu01wNAfqa5kTZx+1I3PtNJ35Aqe4P6VrW+9mnEl6o/g/hu0Ab6koxg0nsjn+dVF6c+Yr8SZgUaGeRfR0ry6alzEFaGuYY/AryafFODjQ++EKOlfRq+nXSxzTeY2FHGHcocM/uIvXZWoA2ZJ1td0pGjKMoRY6d9Nr8ndemXdrMyayVYr1wQ9gn3BVIhNklNluKg06fNslTFDacG4q4LgwLxIIcO+nV+HtOY5HoF2FbgXG3y3ZKwPdsAb/KTeOZIxESOhRG2SB+SrgvfBDeC/cEZKwgdFjA5wydQHFMy2rh8WWxOYx4UJybiiTBR+Fzqu/nin2kHohj0a+dmEWfNYpwAefV3iSMCiMC5+GSYD0PSgjfWVkJDmoaJLRO8EocUXulMC68EW4KpuNqUAy2+EDpePRnjdj/JMhKUASH37N/S+0FgrePV+akZLWTl3+jRt4j7BbGhCUC9EAgcbbThdC+KL5aMA2Fxi5xbLkMoKXCmEBMYjMG5DGTXgW/XuqtiuVZNr8S4nM7cbBHBbYTehcxqDZJOTGv2DvJoKuC45lvaWiSbRea+cyHNN8i0UwHgyfilwUS+SYsFkiCmSYWD7tXwkOB5J8H7uRcCL48EPEDTMYqgYngneyl8FSAPHbSq+DXSWSFYmuwIhzg4WDgSYr93GY7kjQ++OaR7fP0M3IPNiNo0mBWCcxMm+izCtbBHRM5emR5FOvxi21ZibifF6Mh96BNjSIlgX9GfRJJkwen4CLbgrj2Tcds2Y9nt6VxQYOOkyo4TsO86IrkjRGvjNvmsQ8yCox1cTu2LdQuW4gT4wYyuZ21rbxKtsHHbcdynEK8TCEM7GS5jp3k8pAB16plQdRYCRLHxjp8JwVilSpG/h0TA08IXwUSAyTFNdwM2Nge32sCsTqmTp09c8zsM4H3KB6EJMcqW5+Oj946X88jklHMGoE3AuvVbJ/KbC1G4crkW4Ptsld4KzimZ1yiGSJJF0chy4Q7Av7xta5uMfKgxbz+WPMOxv9VrMhtwcmTJDqADKIAkgVeNWS8CbAi2M4akciEMCXwusFrB0WQPJy+z0qWDh98S58RxeiYvEXgnJUVIdIJcQqBQ8ib6fCNY+FTmMpsLZIlATiH1MQHFWT+Oun+JcvSOVZk3n5zsH3TTEuKgEjCf4k6pjnyZjqvhmMRrzCVWZF4MJLwwzGW086TW1eqAA/mWXO/b/n/Qnpt6f6vyL++Ir6hzCubj7q3lscz79tC/DVoXlkhVT0QWyXkV/TxYGhueSv/lvq6CuFM8CryQjgdsqJf2VmpfK+GJLOYi+FbvtIiGKwbK+JZNo+LQlb5+WCAbqyIY5rHhXSt3Y3BPOPmXUs+Dlzld7K30iMNwD8q3Ex85lquZv8QhzimdD/W9Xyb5H0z1Zbsb+OT/8HoqhrfAAAAAElFTkSuQmCC",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_small",message0:"Image too small %1",args0:[{type:"field_image",src:"media/30px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_large",message0:"Image too large %1",args0:[{type:"field_image",src:"media/200px.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_fliprtl",message0:"Image flipped RTL %1",args0:[{type:"field_image",src:"media/arrow.png",width:50,height:50,alt:"*",flipRtl:!0}],colour:160},{type:"test_images_missing",message0:"Image missing %1",args0:[{type:"field_image",src:"missing.png",width:50,height:50,alt:"*"}],style:"text_blocks"},{type:"test_images_many_icons",message0:"Lots of network icons: %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18",args0:[{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"},{type:"input_dummy"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/a.png",width:32,height:32,alt:"A"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/b.png",width:32,height:32,alt:"B"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/c.png",width:32,height:32,alt:"C"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/d.png",width:32,height:32,alt:"D"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/e.png",width:32,height:32,alt:"E"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/f.png",width:32,height:32,alt:"F"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/g.png",width:32,height:32,alt:"G"},{type:"field_image",src:"https://blockly-demo.appspot.com/static/tests/media/h.png",width:32,height:32,alt:"H"}],style:"text_blocks"}]),t.Blocks.test_images_clickhandler={init:function(){this.appendDummyInput().appendField("Image click handler").appendField(new t.FieldImage("https://blockly-demo.appspot.com/static/tests/media/a.png",32,32,"image with click handler",this.onClick_),"IMAGE"),this.setStyle("text_blocks")},onClick_:function(){alert("Image clicked")}};t.Blocks.test_validators_dispose_block={init:function(){this.appendDummyInput().appendField("dispose block").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Any changes to the text cause the block to be disposed")},validate:function(t){"default"!=t&&this.getSourceBlock().dispose(!0)}},t.Blocks.test_validators_text_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The display text will remain the input text, but the value should be the default text. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_text_A={init:function(){this.appendDummyInput().appendField("remove 'a'").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All 'a' characters are removed from field value. The display text will include invalid 'a' characters while the field is being edited, but the value will not.")},validate:function(t){return t.replace(/a/g,"")}},t.Blocks.test_validators_text_B={init:function(){this.appendDummyInput().appendField("'b' -> null").appendField(new t.FieldTextInput("default",this.validate),"INPUT"),this.setColour(230),this.setCommentText("Upon detecting a 'b' character the input will validated to null (invalid). Upon removal it should revert to being valid. The display text will remain the input text, but if the input text is invalid the value should be the default text.")},validate:function(t){return-1!==t.indexOf("b")?null:t}},t.Blocks.test_validators_checkbox_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The new input always validates to null (invalid). This means that the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_checkbox_match={init:function(){this.appendDummyInput().appendField("force match").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. The validator will always return the value of the start-most checkbox. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")}},t.Blocks.test_validators_checkbox_not_match_null={init:function(){this.appendDummyInput().appendField("not match -> null").appendField(new t.FieldCheckbox(!0),"MATCH").appendField(new t.FieldCheckbox(!0,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The validator for this block only works on the end-most checkbox. If the new value does not match the value of the start-most checkbox, it will return null (invalid), which means the field value should not change. Therefore they should always match.")},validate:function(t){return this.sourceBlock_.getFieldValue("MATCH")!=t?null:t}},t.Blocks.test_validators_dropdown_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). This means the field value should not change.")},validate:function(t){return null}},t.Blocks.test_validators_dropdown_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input's value will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_dropdown_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldDropdown([["1a","1A"],["1b","1B"],["1c","1C"],["2a","2A"],["2b","2B"],["2c","2C"]],this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input does not start with 1, the input will validate to null (invalid). Otherwise it will return the input value.")},validate:function(t){return"1"!=t.charAt(0)?null:t}},t.Blocks.test_validators_number_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("All input validates to null (invalid). The field will display the input while the field is being edited, but the value should be the default value. The input should be red after the first keystroke.")},validate:function(t){return null}},t.Blocks.test_validators_number_mult10_force={init:function(){this.appendDummyInput().appendField("force mult of 10").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("The input value will be rounded to the nearest multiple of 10. The field will display the input while the field is being edited, but the value should be the validated (rounded) value. Note: If you want to do rounding this is not the proper way, use the precision option of the number field constructor instead.")},validate:function(t){return 10*Math.round(t/10)}},t.Blocks.test_validators_number_mult10_null={init:function(){this.appendDummyInput().appendField("not mult of 10 -> null").appendField(new t.FieldNumber(123,null,null,null,this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the input value is not a multiple of 10, the input will validate to null (invalid). The field will display the input while the field is being edited, but if the input value is invalid the value should be the default value.")},validate:function(t){return t%10!=0?null:t}},t.Blocks.test_validators_variable_null={init:function(){this.appendDummyInput().appendField("always null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("All ids validate to null (invalid). This means the variable should not change.")},validate:function(t){return null}},t.Blocks.test_validators_variable_force_1s={init:function(){this.appendDummyInput().appendField("force 1s").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("The id will always change to start with 1.")},validate:function(t){return"1"+t.charAt(1)}},t.Blocks.test_validators_variable_1s_null={init:function(){this.appendDummyInput().appendField("not 1s -> null").appendField(new t.FieldVariable("1a",this.validate),"INPUT"),this.setColour(230),this.setCommentText("If the id does not start with 1, the id will validate to null (invalid). Otherwise it will return the id.")},validate:function(t){return"1"!=t.charAt(0)?null:t}};const u={kind:"CATEGORY",name:"Fields",expanded:"true",contents:[{kind:"CATEGORY",name:"Defaults",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set random style",callbackkey:"setRandomStyle"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle enabled",callbackkey:"toggleEnabled"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle shadow",callbackkey:"toggleShadow"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"toggle collapsed",callbackkey:"toggleCollapsed"},{kind:"BLOCK",type:"test_fields_checkbox"},{kind:"BLOCK",type:"test_fields_text_input"},{kind:"BLOCK",type:"test_fields_only_text_input"},{kind:"BLOCK",type:"test_fields_variable"},{kind:"BUTTON",text:"randomize label text",callbackkey:"randomizeLabelText"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_label_serializable"},{kind:"BUTTON",text:"change image",callbackkey:"changeImage"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_fields_image"}]},{kind:"CATEGORY",name:"Numbers",contents:[{kind:"BLOCK",blockxml:'\n<block type="test_numbers_float">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_hundredths">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_three_halves">\n <field name="NUM">123.456</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="test_numbers_whole_bounded">\n <field name="NOTE">60</field>\n</block>'}]},{kind:"CATEGORY",name:"Drop-downs",contents:[{kind:"LABEL",text:"Dynamic"},{kind:"BLOCK",type:"test_dropdowns_dynamic"},{kind:"BUTTON",text:"Add option",callbackkey:"addDynamicOption"},{kind:"BUTTON",text:"Remove option",callbackkey:"removeDynamicOption"},{kind:"BLOCK",type:"test_dropdowns_dynamic_random"},{kind:"BLOCK",type:"test_dropdowns_dynamic_connect_dependant"},{kind:"LABEL",text:"Other"},{kind:"BLOCK",type:"test_dropdowns_long"},{kind:"BLOCK",type:"test_dropdowns_images"},{kind:"BLOCK",type:"test_dropdowns_images_and_text"}]},{kind:"CATEGORY",name:"Images",contents:[{kind:"BLOCK",type:"test_images_datauri"},{kind:"BLOCK",type:"test_images_small"},{kind:"BLOCK",type:"test_images_large"},{kind:"BLOCK",type:"test_images_fliprtl"},{kind:"BLOCK",type:"test_images_missing"},{kind:"BLOCK",type:"test_images_many_icons"},{kind:"BLOCK",type:"test_images_clickhandler"}]},{kind:"CATEGORY",name:"Emoji! o((*^ᴗ^*))o",contents:[{kind:"LABEL",text:"Unicode & Emojis"},{kind:"BLOCK",type:"test_style_emoji"},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Robot face in text field:🤖</field>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text">\n <field name="TEXT">Zalgo in text field:B̛̻̦̬̘̰͎̥̈̔͊͞ͅl̡͖̫̺̬̖̣̳̃̀́͑͑̕͟͠͝o̢̹͙̮̫͔͋̉̊̑̿̽̚c̸̹̹̜͙̹̠͋̒͑̊̇͝k̡͉̫͇̖̳͖̊͒́̆̄̎̂̔̕͜͞l̰̙̞̳̩̠͖̯̀̆̈́̿̈̓͗y̨̡̟͇̮͈̬̙̲̏̅̀͘͠</field>\n</block>'}]},{kind:"CATEGORY",name:"Validators",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"set input",callbackkey:"setInput"},{kind:"LABEL",text:"Dispose block"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dispose_block"},{kind:"LABEL",text:"Checkboxes"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_match"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_checkbox_not_match_null"},{kind:"LABEL",text:"Dropdowns"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_dropdown_1s_null"},{kind:"LABEL",text:"Numbers"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_force"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_number_mult10_null"},{kind:"LABEL",text:"Text"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_A"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_text_B"},{kind:"LABEL",text:"Variables"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"add test variables",callbackkey:"addVariables","web-class":"modifiesWorkspace"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_null"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_force_1s"},{kind:"SEP",gap:"12"},{kind:"BLOCK",type:"test_validators_variable_1s_null"}]}]};t.defineBlocksWithJsonArray([{type:"test_mutator_textChange",message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"}]);const m={mutationToDom:function(){const e=t.utils.xml.createElement("mutation");return e.setAttribute("arbitrary",this.getFieldValue("LABEL")),e},domToMutation:function(t){this.setFieldValue(t.getAttribute("arbitrary"),"LABEL")},saveExtraState:function(){return{arbitrary:this.getFieldValue("LABEL")}},loadExtraState:function(t){this.setFieldValue(t.arbitrary,"LABEL")},decompose:function(e){const n=t.serialization.blocks.append({type:"test_mutator_textChange"},e);return n.getField("MUTATOR_TEXT").setValue(this.getFieldValue("LABEL")),n},compose:function(t){this.setFieldValue(t.getFieldValue("MUTATOR_TEXT"),"LABEL")}},_=[];for(let t=0;t<20;t++)_.push(`test_mutator_category_${t}`);const h=_.map((t=>({type:t,message0:"mutator text: %1",args0:[{type:"field_input",name:"MUTATOR_TEXT",text:"a label"}],style:"colour_blocks"})));t.defineBlocksWithJsonArray([{type:"test_mutators_many",message0:"test many blocks mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_many_blocks_mutator",colour:"#000000"},...h]),t.Extensions.registerMutator("test_many_blocks_mutator",m,null,[..._]),t.defineBlocksWithJsonArray([{type:"test_mutators_noflyout",message0:"noflyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_noflyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_noflyout_mutator",m,null,[]),t.defineBlocksWithJsonArray([{type:"test_mutators_changeableFlyout",message0:"changeable flyout mutator %1",args0:[{type:"field_label",name:"LABEL",text:"changeable label"}],mutator:"test_changeableFlyout_mutator",colour:"#000000"}]),t.Extensions.registerMutator("test_changeableFlyout_mutator",m,null,["text"]),t.defineBlocksWithJsonArray([{type:"test_style_hat",message0:"Hat block (event)",nextStatement:null,style:"hat_blocks"},{type:"test_style_hex1",message0:"Block color: Bright purple %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#992aff"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#992aff"},{type:"test_style_hex2",message0:"Block color: White %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#fefefe"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#fefefe"},{type:"test_style_hex3",message0:"Block color: Black %1 %2 %3 %4",args0:[{type:"field_input",name:"TEXT",text:"#010101"},{type:"field_dropdown",name:"DROPDOWN",options:[["option","ONE"],["option","TWO"]]},{type:"field_checkbox",name:"NAME",checked:!0},{type:"input_value",name:"NAME"}],previousStatement:null,nextStatement:null,colour:"#010101"},{type:"test_style_no_colour",message0:"Block color: unset"},{type:"test_style_hex4",message0:"Block color: #RRGGBBAA (invalid)",colour:"#992aff99"},{type:"test_style_hex5",message0:"Block color: #RRGGBB (invalid)",colour:"#NotHex"},{type:"test_style_emoji",message0:"Robot Face: 🤖",colour:"#AAAAAA"}]);class k extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}}k.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_no_overrides",k);class y extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}}y.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_xml",y);class g extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}g.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_jso",g);class b extends t.FieldLabel{constructor(t,e,n){super(t,e,n),this.EDITABLE=!1,this.SERIALIZABLE=!0}toXml(t){return t.setAttribute("value",this.getValue()),t}fromXml(t){this.setValue(t.getAttribute("value"))}saveState(){return{value:this.getValue()}}loadState(t){this.setValue(t.value)}}b.fromJson=function(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)},t.fieldRegistry.register("field_both",b),t.defineBlocksWithJsonArray([{type:"test_field_serialization_no_overrides",message0:"no overrides: %1",args0:[{type:"field_no_overrides",name:"LABEL",text:"test"}],colour:0,output:null},{type:"test_field_serialization_xml",message0:"xml: %1",args0:[{type:"field_xml",name:"LABEL",text:"test"}],colour:30,output:null},{type:"test_field_serialization_jso",message0:"jso: %1",args0:[{type:"field_jso",name:"LABEL",text:"test"}],colour:90,output:null},{type:"test_field_serialization_both",message0:"both: %1",args0:[{type:"field_both",name:"LABEL",text:"test"}],colour:150,output:null}]),t.Blocks.test_extra_state_xml=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_xml.saveExtraState,delete t.Blocks.test_extra_state_xml.loadExtraState,t.Blocks.test_extra_state_xml.init=function(){this.setColour(30),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_jso=Object.assign({},t.Blocks.lists_create_with),delete t.Blocks.test_extra_state_jso.mutationToDom,delete t.Blocks.test_extra_state_jso.domToMutation,t.Blocks.test_extra_state_jso.init=function(){this.setColour(90),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))},t.Blocks.test_extra_state_both=Object.assign({},t.Blocks.lists_create_with),t.Blocks.test_extra_state_both.init=function(){this.setColour(150),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.icons.MutatorIcon(["lists_create_with_item"],this))};const f={contents:[{kind:"CATEGORY",name:"Align",contents:[{kind:"BLOCK",type:"test_align_dummy_right"},{kind:"BLOCK",type:"test_align_all"},{kind:"BLOCK",type:"test_align_with_external_input"}]},{kind:"CATEGORY",name:"Basic",contents:[{kind:"BLOCK",type:"test_basic_empty"},{kind:"BLOCK",type:"test_basic_empty_with_mutator"},{kind:"BLOCK",type:"test_basic_dummy"},{kind:"BLOCK",type:"test_basic_multiple_dummy"},{kind:"BLOCK",type:"test_basic_stack"},{kind:"BLOCK",type:"test_basic_row"},{kind:"BLOCK",type:"test_basic_value_to_stack"},{kind:"BLOCK",type:"test_basic_value_to_statement"},{kind:"BLOCK",type:"test_basic_limit_instances"},{kind:"BLOCK",type:"test_basic_tooltips"},{kind:"BLOCK",type:"test_basic_javascript"}]},{kind:"CATEGORY",name:"Chameleon",contents:[{kind:"BLOCK",type:"test_chameleon"}]},i,{kind:"CATEGORY",name:"Drag",contents:[{kind:"LABEL",text:"Drag each to the workspace"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="text">\n <field name="TEXT">Drag me by this child</field>\n </block>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Drag me by this shadow</field>\n </shadow>\n </value>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow value</field>\n </shadow>\n </value>\n <next>\n <shadow type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Shadow statement</field>\n </shadow>\n </value>\n </shadow>\n </next>\n</block>'},{kind:"LABEL",text:"Multiple Variable Refs"},{kind:"BLOCK",blockxml:'\n<block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n <next>\n <block type="text_print">\n <value name="TEXT">\n <block type="variables_get">\n <field name="VAR" id="item">item</field>\n </block>\n </value>\n </block>\n </next>\n</block>'},{kind:"LABEL",text:"Procedure Definitions"},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <field name="NAME">without arguments</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">No argument reference.</field>\n </shadow>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",blockxml:'\n<block type="procedures_defnoreturn">\n <mutation><arg name="fnArgument"></arg></mutation>\n <field name="NAME">with one argument</field>\n <statement name="STACK">\n <block type="text_print">\n <value name="TEXT">\n <shadow type="text">\n <field name="TEXT">Expected an argument reference here.</field>\n </shadow>\n <block type="variables_get">\n <field name="VAR">fnArgument</field>\n </block>\n </value>\n </block>\n </statement>\n</block>'},{kind:"BLOCK",type:"drag_to_dupe"},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"drag_to_dupe"}}}}]},u,{kind:"CATEGORY",name:"Mutators",contents:[{kind:"LABEL",text:"logic_compare"},{kind:"BLOCK",type:"logic_compare",inputs:{A:{shadow:{type:"math_number",fields:{NUM:10}}},B:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"logic_compare",inputs:{A:{block:{type:"math_number",fields:{NUM:10}}},B:{block:{type:"math_number",fields:{NUM:10}}}}},{kind:"BLOCK",type:"test_mutators_noflyout"},{kind:"BLOCK",type:"test_mutators_many"},{kind:"BLOCK",type:"test_mutators_changeableFlyout"}]},{kind:"CATEGORY",name:"Style",contents:[{kind:"LABEL",text:"Hats"},{kind:"BLOCK",type:"test_style_hat"},{kind:"LABEL",text:"Colour"},{kind:"BLOCK",type:"test_style_hex1"},{kind:"BLOCK",type:"test_style_hex2"},{kind:"BLOCK",type:"test_style_hex3"},{kind:"BLOCK",type:"test_style_no_colour"},{kind:"BLOCK",type:"test_style_hex4"},{kind:"BLOCK",type:"test_style_hex5",gap:"40"},{kind:"BLOCK",type:"test_style_hex5",disabled:"true"}]},{kind:"CATEGORY",name:"Serialization",contents:[{kind:"BUTTON",text:"add blocks to workspace",callbackkey:"addAllBlocksToWorkspace"},{kind:"SEP",gap:"8"},{kind:"BUTTON",text:"randomize text",callbackkey:"randomizeText"},{kind:"BLOCK",type:"test_field_serialization_no_overrides"},{kind:"BLOCK",type:"test_field_serialization_xml"},{kind:"BLOCK",type:"test_field_serialization_jso"},{kind:"BLOCK",type:"test_field_serialization_both"},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="test_extra_state_xml"><mutation items="2"></mutation></block>'},{kind:"BLOCK",type:"test_extra_state_jso",extraState:{itemCount:2}},{kind:"BLOCK",type:"test_extra_state_both",extraState:{itemCount:2}},{kind:"SEP",gap:30},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_no_overrides"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_xml"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_jso"}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_field_serialization_both"}}}},{kind:"SEP",gap:30},{kind:"BLOCK",blockxml:'<block type="text_print"><value name="TEXT"><shadow type="test_extra_state_xml"><mutation items="2"></mutation></shadow></value></block>'},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_jso",extraState:{itemCount:2}}}}},{kind:"BLOCK",type:"text_print",inputs:{TEXT:{shadow:{type:"test_extra_state_both",extraState:{itemCount:2}}}}}]}]};function x(o){(function(t){!function(t){t.registerButtonCallback("insertConnectionRows",e)}(t),function(t){t.registerButtonCallback("insertConnectionStacks",n)}(t),function(t){t.registerButtonCallback("insertConnectionStatements",s)}(t)})(o),function(e){!function(t){t.registerButtonCallback("randomizeLabelText",(function(t){const e=t.getTargetWorkspace().getBlocksByType("test_fields_label_serializable");for(let t,n=0;t=e[n];n++){let e="";for(let t=0;t<4;t++)e+="AB".charAt(Math.floor(2*Math.random()));t.setFieldValue(e,"LABEL")}})),t.registerButtonCallback("setRandomStyle",(function(e){const n=e.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1),o=Object.keys(t.getRenderer().getConstants().blockStyles);o.splice(o.indexOf(n[0].getStyleName()),1);const l=o[Math.floor(Math.random()*o.length)];for(let t,e=0;t=n[e];e++)t.setStyle(l)})),t.registerButtonCallback("toggleEnabled",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setEnabled(!t.isEnabled())})),t.registerButtonCallback("toggleShadow",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setShadow(!t.isShadow())})),t.registerButtonCallback("toggleCollapsed",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getAllBlocks(!1);for(let t,n=0;t=e[n];n++)t.setCollapsed(!t.isCollapsed())})),t.registerButtonCallback("changeImage",(function(t){const e=t.getTargetWorkspace().getFlyout().getWorkspace().getBlocksByType("test_fields_image"),n="https://blockly-demo.appspot.com/static/tests/media/"+"abcdefghijklm".charAt(Math.floor(13*Math.random()))+".png";for(let t,o=0;t=e[o];o++)t.getField("IMAGE").setValue(n)}))}(e),function(t){t.registerButtonCallback("addDynamicOption",d),t.registerButtonCallback("removeDynamicOption",p)}(e),function(e){e.registerButtonCallback("addVariables",(function(t){e.createVariable("1b","","1B"),e.createVariable("1c","","1C"),e.createVariable("2a","","2A"),e.createVariable("2b","","2B"),e.createVariable("2c","","2C")})),e.registerButtonCallback("setInput",(function(e){t.dialog.prompt("Input text to set.","ab",(function(t){const n=e.getTargetWorkspace().getAllBlocks(!1);for(let e,o=0;e=n[o];o++)e.getField("INPUT")&&e.setFieldValue(t,"INPUT")}))}))}(e)}(o),function(t){t.registerButtonCallback("randomizeText",(function(t){const e=t.getTargetWorkspace(),n=[...e.getBlocksByType("test_field_serialization_no_overrides"),...e.getBlocksByType("test_field_serialization_xml"),...e.getBlocksByType("test_field_serialization_jso"),...e.getBlocksByType("test_field_serialization_both")];for(let t,e=0;t=n[e];e++){let e="";for(let t=0;t<4;t++)e+="ABCDEF".charAt(Math.floor(6*Math.random()));t.setFieldValue(e,"LABEL")}}))}(o),o.registerButtonCallback("addAllBlocksToWorkspace",(function(e){const n=e.getTargetWorkspace(),o=n.getFlyout().getWorkspace().getTopBlocks();for(let e,l=0;e=o[l];l++){const o=t.serialization.blocks.save(e,{addCoordinates:!0});t.serialization.blocks.append(o,n)}}))}})(),l})())); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@blockly/block-test", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "A group of Blockly test blocks.", | ||
@@ -54,3 +54,3 @@ "scripts": { | ||
}, | ||
"gitHead": "6bf755b9387d694329ad0dc2f44ce62190a249b9" | ||
"gitHead": "1cf3e19b9ae3072d559504e071ca4b64133d31e6" | ||
} |
@@ -13,2 +13,43 @@ /** | ||
import * as Blockly from 'blockly/core'; | ||
/** Block that duplicates itself on drag. */ | ||
Blockly.Blocks['drag_to_dupe'] = { | ||
init: function () { | ||
this.setOutput(true, null); | ||
this.appendDummyInput().appendField('drag to dupe'); | ||
this.setDragStrategy(new DragToDupe(this)); | ||
}, | ||
}; | ||
/** Drag strategy that duplicates the block on drag. */ | ||
class DragToDupe { | ||
constructor(block) { | ||
this.block = block; | ||
} | ||
isMovable() { | ||
return true; | ||
} | ||
startDrag(e) { | ||
const data = this.block.toCopyData(); | ||
this.copy = Blockly.clipboard.paste(data, this.block.workspace); | ||
this.baseStrat = new Blockly.dragging.BlockDragStrategy(this.copy); | ||
this.baseStrat.startDrag(e); | ||
} | ||
drag(e) { | ||
this.baseStrat.drag(e); | ||
} | ||
endDrag(e) { | ||
this.baseStrat.endDrag(e); | ||
} | ||
revertDrag(e) { | ||
this.copy.dispose(); | ||
} | ||
} | ||
/** | ||
@@ -131,2 +172,17 @@ * The Drag category. | ||
}, | ||
{ | ||
kind: 'BLOCK', | ||
type: 'drag_to_dupe', | ||
}, | ||
{ | ||
kind: 'BLOCK', | ||
type: 'text_print', | ||
inputs: { | ||
TEXT: { | ||
shadow: { | ||
type: 'drag_to_dupe', | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
@@ -133,0 +189,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375224
4654