vue-blockly
Version:
Blockly wrapped in a vue component
18 lines • 673 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["VBlockly"]=e(require("vue")):t["VBlockly"]=e(t["Vue"])})("undefined"!==typeof self?self:this,(function(__WEBPACK_EXTERNAL_MODULE__8bbf__){return function(t){var e={};function o(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(i,n,function(e){return t[e]}.bind(null,n));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s="fb15")}({"046a":function(t,e,o){},"06c8":function(t,e){t.exports=function(t){return"object"===typeof t?null!==t:"function"===typeof t}},"08bb":function(t,e,o){var i=o("3f9e").document;t.exports=i&&i.documentElement},"0dbc":function(t,e,o){"use strict";var i,n,s,r,a=o("c04b"),l=o("3f9e"),c=o("f658"),u=o("3855"),h=o("5fa5"),p=o("06c8"),_=o("6fc4"),d=o("12eb"),g=o("1ea5"),T=o("e45b"),E=o("e413").set,f=o("5c3c")(),v=o("82d3"),m=o("62fb"),b=o("44e0"),S=o("9212"),y="Promise",C=l.TypeError,R=l.process,k=R&&R.versions,I=k&&k.v8||"",O=l[y],A="process"==u(R),D=function(){},N=n=v.f,M=!!function(){try{var t=O.resolve(1),e=(t.constructor={})[o("f5dc")("species")]=function(t){t(D,D)};return(A||"function"==typeof PromiseRejectionEvent)&&t.then(D)instanceof e&&0!==I.indexOf("6.6")&&-1===b.indexOf("Chrome/66")}catch(i){}}(),L=function(t){var e;return!(!p(t)||"function"!=typeof(e=t.then))&&e},w=function(t,e){if(!t._n){t._n=!0;var o=t._c;f((function(){var i=t._v,n=1==t._s,s=0,r=function(e){var o,s,r,a=n?e.ok:e.fail,l=e.resolve,c=e.reject,u=e.domain;try{a?(n||(2==t._h&&x(t),t._h=1),!0===a?o=i:(u&&u.enter(),o=a(i),u&&(u.exit(),r=!0)),o===e.promise?c(C("Promise-chain cycle")):(s=L(o))?s.call(o,l,c):l(o)):c(i)}catch(h){u&&!r&&u.exit(),c(h)}};while(o.length>s)r(o[s++]);t._c=[],t._n=!1,e&&!t._h&&B(t)}))}},B=function(t){E.call(l,(function(){var e,o,i,n=t._v,s=P(t);if(s&&(e=m((function(){A?R.emit("unhandledRejection",n,t):(o=l.onunhandledrejection)?o({promise:t,reason:n}):(i=l.console)&&i.error&&i.error("Unhandled promise rejection",n)})),t._h=A||P(t)?2:1),t._a=void 0,s&&e.e)throw e.v}))},P=function(t){return 1!==t._h&&0===(t._a||t._c).length},x=function(t){E.call(l,(function(){var e;A?R.emit("rejectionHandled",t):(e=l.onrejectionhandled)&&e({promise:t,reason:t._v})}))},F=function(t){var e=this;e._d||(e._d=!0,e=e._w||e,e._v=t,e._s=2,e._a||(e._a=e._c.slice()),w(e,!0))},U=function(t){var e,o=this;if(!o._d){o._d=!0,o=o._w||o;try{if(o===t)throw C("Promise can't be resolved itself");(e=L(t))?f((function(){var i={_w:o,_d:!1};try{e.call(t,c(U,i,1),c(F,i,1))}catch(n){F.call(i,n)}})):(o._v=t,o._s=1,w(o,!1))}catch(i){F.call({_w:o,_d:!1},i)}}};M||(O=function(t){d(this,O,y,"_h"),_(t),i.call(this);try{t(c(U,this,1),c(F,this,1))}catch(e){F.call(this,e)}},i=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=o("f9e7")(O.prototype,{then:function(t,e){var o=N(T(this,O));return o.ok="function"!=typeof t||t,o.fail="function"==typeof e&&e,o.domain=A?R.domain:void 0,this._c.push(o),this._a&&this._a.push(o),this._s&&w(this,!1),o.promise},catch:function(t){return this.then(void 0,t)}}),s=function(){var t=new i;this.promise=t,this.resolve=c(U,t,1),this.reject=c(F,t,1)},v.f=N=function(t){return t===O||t===r?new s(t):n(t)}),h(h.G+h.W+h.F*!M,{Promise:O}),o("8cf1")(O,y),o("13ca")(y),r=o("4794")[y],h(h.S+h.F*!M,y,{reject:function(t){var e=N(this),o=e.reject;return o(t),e.promise}}),h(h.S+h.F*(a||!M),y,{resolve:function(t){return S(a&&this===r?O:this,t)}}),h(h.S+h.F*!(M&&o("ce5a")((function(t){O.all(t)["catch"](D)}))),y,{all:function(t){var e=this,o=N(e),i=o.resolve,n=o.reject,s=m((function(){var o=[],s=0,r=1;g(t,!1,(function(t){var a=s++,l=!1;o.push(void 0),r++,e.resolve(t).then((function(t){l||(l=!0,o[a]=t,--r||i(o))}),n)})),--r||i(o)}));return s.e&&n(s.v),o.promise},race:function(t){var e=this,o=N(e),i=o.reject,n=m((function(){g(t,!1,(function(t){e.resolve(t).then(o.resolve,i)}))}));return n.e&&i(n.v),o.promise}})},"12eb":function(t,e){t.exports=function(t,e,o,i){if(!(t instanceof e)||void 0!==i&&i in t)throw TypeError(o+": incorrect invocation!");return t}},"13b5":function(t,e){t.exports=function(t){try{return!!t()}catch(e){return!0}}},"13ca":function(t,e,o){"use strict";var i=o("3f9e"),n=o("5352"),s=o("186a"),r=o("f5dc")("species");t.exports=function(t){var e=i[t];s&&e&&!e[r]&&n.f(e,r,{configurable:!0,get:function(){return this}})}},"186a":function(t,e,o){t.exports=!o("13b5")((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},"1d6b":function(t,e,o){t.exports=!o("186a")&&!o("13b5")((function(){return 7!=Object.defineProperty(o("9a08")("div"),"a",{get:function(){return 7}}).a}))},"1ea5":function(t,e,o){var i=o("f658"),n=o("8899"),s=o("d8b3"),r=o("3c01"),a=o("4a9e"),l=o("a41d"),c={},u={};e=t.exports=function(t,e,o,h,p){var _,d,g,T,E=p?function(){return t}:l(t),f=i(o,h,e?2:1),v=0;if("function"!=typeof E)throw TypeError(t+" is not iterable!");if(s(E)){for(_=a(t.length);_>v;v++)if(T=e?f(r(d=t[v])[0],d[1]):f(t[v]),T===c||T===u)return T}else for(g=E.call(t);!(d=g.next()).done;)if(T=n(g,f,d.value,e),T===c||T===u)return T};e.BREAK=c,e.RETURN=u},"21b8":function(t,e){t.exports={}},2467:function(t,e,o){t.exports=o("6552")("native-function-to-string",Function.toString)},2854:function(t,e){t.exports=function(t,e,o){var i=void 0===o;switch(e.length){case 0:return i?t():t.call(o);case 1:return i?t(e[0]):t.call(o,e[0]);case 2:return i?t(e[0],e[1]):t.call(o,e[0],e[1]);case 3:return i?t(e[0],e[1],e[2]):t.call(o,e[0],e[1],e[2]);case 4:return i?t(e[0],e[1],e[2],e[3]):t.call(o,e[0],e[1],e[2],e[3])}return t.apply(o,e)}},"2ddc":function(t,e,o){var i,n,s;(function(r,a){n=[o("b7fd"),o("a884"),o("49d2"),o("fc06")],i=a,s="function"===typeof i?i.apply(e,n):i,void 0===s||(t.exports=s)})(0,(function(t,e,o,i){
/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";return t.setLocale(e),t.Blocks=t.Blocks||{},Object.keys(o).forEach((function(e){t.Blocks[e]=o[e]})),t.JavaScript=i,t}))},3855:function(t,e,o){var i=o("9fe5"),n=o("f5dc")("toStringTag"),s="Arguments"==i(function(){return arguments}()),r=function(t,e){try{return t[e]}catch(o){}};t.exports=function(t){var e,o,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(o=r(e=Object(t),n))?o:s?i(e):"Object"==(a=i(e))&&"function"==typeof e.callee?"Arguments":a}},"3c01":function(t,e,o){var i=o("06c8");t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},"3f9e":function(t,e){var o=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=o)},"44e0":function(t,e,o){var i=o("3f9e"),n=i.navigator;t.exports=n&&n.userAgent||""},4794:function(t,e){var o=t.exports={version:"2.6.9"};"number"==typeof __e&&(__e=o)},"49d2":function(t,e,o){var i,n,s;(function(r,a){n=[o("b7fd")],i=a,s="function"===typeof i?i.apply(e,n):i,void 0===s||(t.exports=s)})(0,(function(t){return t.Blocks={},t.Blocks.colour={},t.Constants={},t.Constants.Colour={},t.Constants.Colour.HUE=20,t.defineBlocksWithJsonArray([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]),t.Blocks.lists={},t.Constants.Lists={},t.Constants.Lists.HUE=260,t.defineBlocksWithJsonArray([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),t.Blocks.lists_create_with={init:function(){this.setHelpUrl(t.Msg.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new t.Mutator(["lists_create_with_item"])),this.setTooltip(t.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var e=t.utils.xml.createElement("mutation");return e.setAttribute("items",this.itemCount_),e},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_create_with_container");e.initSvg();for(var o=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var n=t.newBlock("lists_create_with_item");n.initSvg(),o.connect(n.previousConnection),o=n.nextConnection}return e},compose:function(e){var o=e.getInputTargetBlock("STACK");for(e=[];o;)e.push(o.valueConnection_),o=o.nextConnection&&o.nextConnection.targetBlock();for(o=0;o<this.itemCount_;o++){var i=this.getInput("ADD"+o).connection.targetConnection;i&&-1==e.indexOf(i)&&i.disconnect()}for(this.itemCount_=e.length,this.updateShape_(),o=0;o<this.itemCount_;o++)t.Mutator.reconnect(e[o],this,"ADD"+o)},saveConnections:function(t){t=t.getInputTargetBlock("STACK");for(var e=0;t;){var o=this.getInput("ADD"+e);t.valueConnection_=o&&o.connection.targetConnection,e++,t=t.nextConnection&&t.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(t.Msg.LISTS_CREATE_EMPTY_TITLE);for(var e=0;e<this.itemCount_;e++)if(!this.getInput("ADD"+e)){var o=this.appendValueInput("ADD"+e);0==e&&o.appendField(t.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(;this.getInput("ADD"+e);)this.removeInput("ADD"+e),e++}},t.Blocks.lists_create_with_container={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(t.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(t.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},t.Blocks.lists_create_with_item={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(t.Msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(t.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},t.Blocks.lists_indexOf={init:function(){var e=[[t.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[t.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(t.Msg.LISTS_INDEX_OF_HELPURL),this.setStyle("list_blocks"),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("Array").appendField(t.Msg.LISTS_INDEX_OF_INPUT_IN_LIST),this.appendValueInput("FIND").appendField(new t.FieldDropdown(e),"END"),this.setInputsInline(!0);var o=this;this.setTooltip((function(){return t.Msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",o.workspace.options.oneBasedIndex?"0":"-1")}))}},t.Blocks.lists_getIndex={init:function(){var e=[[t.Msg.LISTS_GET_INDEX_GET,"GET"],[t.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[t.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[t.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[t.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[t.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[t.Msg.LISTS_GET_INDEX_LAST,"LAST"],[t.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(t.Msg.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),e=new t.FieldDropdown(e,(function(t){t="REMOVE"==t,this.getSourceBlock().updateStatement_(t)})),this.appendValueInput("VALUE").setCheck("Array").appendField(t.Msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(e,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),t.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(t.Msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0);var o=this;this.setTooltip((function(){var e=o.getFieldValue("MODE"),i=o.getFieldValue("WHERE"),n="";switch(e+" "+i){case"GET FROM_START":case"GET FROM_END":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":n=t.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return"FROM_START"!=i&&"FROM_END"!=i||(n+=" "+("FROM_START"==i?t.Msg.LISTS_INDEX_FROM_START_TOOLTIP:t.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",o.workspace.options.oneBasedIndex?"#1":"#0")),n}))},mutationToDom:function(){var e=t.utils.xml.createElement("mutation");e.setAttribute("statement",!this.outputConnection);var o=this.getInput("AT").type==t.INPUT_VALUE;return e.setAttribute("at",o),e},domToMutation:function(t){var e="true"==t.getAttribute("statement");this.updateStatement_(e),t="false"!=t.getAttribute("at"),this.updateAt_(t)},updateStatement_:function(t){t!=!this.outputConnection&&(this.unplug(!0,!0),t?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck("Number"),t.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(t.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var o=new t.FieldDropdown(this.WHERE_OPTIONS,(function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var i=this.getSourceBlock();return i.updateAt_(o),i.setFieldValue(t,"WHERE"),null}}));this.getInput("AT").appendField(o,"WHERE"),t.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},t.Blocks.lists_setIndex={init:function(){var e=[[t.Msg.LISTS_SET_INDEX_SET,"SET"],[t.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[t.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[t.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[t.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[t.Msg.LISTS_GET_INDEX_LAST,"LAST"],[t.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(t.Msg.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(t.Msg.LISTS_SET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(new t.FieldDropdown(e),"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(t.Msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(t.Msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0);var o=this;this.setTooltip((function(){var e=o.getFieldValue("MODE"),i=o.getFieldValue("WHERE"),n="";switch(e+" "+i){case"SET FROM_START":case"SET FROM_END":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":n=t.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return"FROM_START"!=i&&"FROM_END"!=i||(n+=" "+t.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",o.workspace.options.oneBasedIndex?"#1":"#0")),n}))},mutationToDom:function(){var e=t.utils.xml.createElement("mutation"),o=this.getInput("AT").type==t.INPUT_VALUE;return e.setAttribute("at",o),e},domToMutation:function(t){t="false"!=t.getAttribute("at"),this.updateAt_(t)},updateAt_:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck("Number"),t.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(t.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var o=new t.FieldDropdown(this.WHERE_OPTIONS,(function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var i=this.getSourceBlock();return i.updateAt_(o),i.setFieldValue(t,"WHERE"),null}}));this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendField(o,"WHERE")}},t.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[t.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[t.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[t.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[t.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[t.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[t.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(t.Msg.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(t.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),t.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(t.Msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(t.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var e=t.utils.xml.createElement("mutation"),o=this.getInput("AT1").type==t.INPUT_VALUE;return e.setAttribute("at1",o),o=this.getInput("AT2").type==t.INPUT_VALUE,e.setAttribute("at2",o),e},domToMutation:function(t){var e="true"==t.getAttribute("at1");t="true"==t.getAttribute("at2"),this.updateAt_(1,e),this.updateAt_(2,t)},updateAt_:function(e,o){this.removeInput("AT"+e),this.removeInput("ORDINAL"+e,!0),o?(this.appendValueInput("AT"+e).setCheck("Number"),t.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+e).appendField(t.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+e);var i=new t.FieldDropdown(this["WHERE_OPTIONS_"+e],(function(t){var i="FROM_START"==t||"FROM_END"==t;if(i!=o){var n=this.getSourceBlock();return n.updateAt_(e,i),n.setFieldValue(t,"WHERE"+e),null}}));this.getInput("AT"+e).appendField(i,"WHERE"+e),1==e&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),t.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}},t.Blocks.lists_sort={init:function(){this.jsonInit({message0:t.Msg.LISTS_SORT_TITLE,args0:[{type:"field_dropdown",name:"TYPE",options:[[t.Msg.LISTS_SORT_TYPE_NUMERIC,"NUMERIC"],[t.Msg.LISTS_SORT_TYPE_TEXT,"TEXT"],[t.Msg.LISTS_SORT_TYPE_IGNORECASE,"IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[[t.Msg.LISTS_SORT_ORDER_ASCENDING,"1"],[t.Msg.LISTS_SORT_ORDER_DESCENDING,"-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:t.Msg.LISTS_SORT_TOOLTIP,helpUrl:t.Msg.LISTS_SORT_HELPURL})}},t.Blocks.lists_split={init:function(){var e=this,o=new t.FieldDropdown([[t.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[t.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],(function(t){e.updateType_(t)}));this.setHelpUrl(t.Msg.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(o,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(t.Msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip((function(){var o=e.getFieldValue("MODE");if("SPLIT"==o)return t.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"==o)return t.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+o)}))},updateType_:function(t){if(this.getFieldValue("MODE")!=t){var e=this.getInput("INPUT").connection;e.setShadowDom(null);var o=e.targetBlock();o&&(e.disconnect(),o.isShadow()?o.dispose():this.bumpNeighbours())}"SPLIT"==t?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){var e=t.utils.xml.createElement("mutation");return e.setAttribute("mode",this.getFieldValue("MODE")),e},domToMutation:function(t){this.updateType_(t.getAttribute("mode"))}},t.Blocks.logic={},t.Constants.Logic={},t.Constants.Logic.HUE=210,t.defineBlocksWithJsonArray([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]}]),t.defineBlocksWithJsonArray([{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]),t.Constants.Logic.TOOLTIPS_BY_OP={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"},t.Extensions.register("logic_op_tooltip",t.Extensions.buildTooltipForDropdown("OP",t.Constants.Logic.TOOLTIPS_BY_OP)),t.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,suppressPrefixSuffix:!0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var e=t.utils.xml.createElement("mutation");return this.elseifCount_&&e.setAttribute("elseif",this.elseifCount_),this.elseCount_&&e.setAttribute("else",1),e},domToMutation:function(t){this.elseifCount_=parseInt(t.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(t.getAttribute("else"),10)||0,this.rebuildShape_()},decompose:function(t){var e=t.newBlock("controls_if_if");e.initSvg();for(var o=e.nextConnection,i=1;i<=this.elseifCount_;i++){var n=t.newBlock("controls_if_elseif");n.initSvg(),o.connect(n.previousConnection),o=n.nextConnection}return this.elseCount_&&(t=t.newBlock("controls_if_else"),t.initSvg(),o.connect(t.previousConnection)),e},compose:function(t){t=t.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;for(var e=[null],o=[null],i=null;t;){switch(t.type){case"controls_if_elseif":this.elseifCount_++,e.push(t.valueConnection_),o.push(t.statementConnection_);break;case"controls_if_else":this.elseCount_++,i=t.statementConnection_;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.nextConnection&&t.nextConnection.targetBlock()}this.updateShape_(),this.reconnectChildBlocks_(e,o,i)},saveConnections:function(t){t=t.nextConnection.targetBlock();for(var e=1;t;){switch(t.type){case"controls_if_elseif":var o=this.getInput("IF"+e),i=this.getInput("DO"+e);t.valueConnection_=o&&o.connection.targetConnection,t.statementConnection_=i&&i.connection.targetConnection,e++;break;case"controls_if_else":i=this.getInput("ELSE"),t.statementConnection_=i&&i.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.nextConnection&&t.nextConnection.targetBlock()}},rebuildShape_:function(){var t=[null],e=[null],o=null;this.getInput("ELSE")&&(o=this.getInput("ELSE").connection.targetConnection);for(var i=1;this.getInput("IF"+i);){var n=this.getInput("IF"+i),s=this.getInput("DO"+i);t.push(n.connection.targetConnection),e.push(s.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(t,e,o)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var e=1;this.getInput("IF"+e);)this.removeInput("IF"+e),this.removeInput("DO"+e),e++;for(e=1;e<=this.elseifCount_;e++)this.appendValueInput("IF"+e).setCheck("Boolean").appendField(t.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+e).appendField(t.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(t.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(e,o,i){for(var n=1;n<=this.elseifCount_;n++)t.Mutator.reconnect(e[n],this,"IF"+n),t.Mutator.reconnect(o[n],this,"DO"+n);t.Mutator.reconnect(i,this,"ELSE")}},t.Extensions.registerMutator("controls_if_mutator",t.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]),t.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION=function(){this.setTooltip(function(){return this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?t.Msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?t.Msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?t.Msg.CONTROLS_IF_TOOLTIP_4:"":t.Msg.CONTROLS_IF_TOOLTIP_1}.bind(this))},t.Extensions.register("controls_if_tooltip",t.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION),t.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN={onchange:function(e){this.prevBlocks_||(this.prevBlocks_=[null,null]);var o=this.getInputTargetBlock("A"),i=this.getInputTargetBlock("B");o&&i&&!o.outputConnection.checkType_(i.outputConnection)&&(t.Events.setGroup(e.group),e=this.prevBlocks_[0],e!==o&&(o.unplug(),e&&!e.isShadow()&&this.getInput("A").connection.connect(e.outputConnection)),o=this.prevBlocks_[1],o!==i&&(i.unplug(),o&&!o.isShadow()&&this.getInput("B").connection.connect(o.outputConnection)),this.bumpNeighbours(),t.Events.setGroup(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},t.Constants.Logic.LOGIC_COMPARE_EXTENSION=function(){this.mixin(t.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN)},t.Extensions.register("logic_compare",t.Constants.Logic.LOGIC_COMPARE_EXTENSION),t.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN={prevParentConnection_:null,onchange:function(e){var o=this.getInputTargetBlock("THEN"),i=this.getInputTargetBlock("ELSE"),n=this.outputConnection.targetConnection;if((o||i)&&n)for(var s=0;2>s;s++){var r=1==s?o:i;r&&!r.outputConnection.checkType_(n)&&(t.Events.setGroup(e.group),n===this.prevParentConnection_?(this.unplug(),n.getSourceBlock().bumpNeighbours()):(r.unplug(),r.bumpNeighbours()),t.Events.setGroup(!1))}this.prevParentConnection_=n}},t.Extensions.registerMixin("logic_ternary",t.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN),t.Blocks.loops={},t.Constants.Loops={},t.Constants.Loops.HUE=120,t.defineBlocksWithJsonArray([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}","UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_forEach",message0:"%{BKY_CONTROLS_FOREACH_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]),t.Constants.Loops.WHILE_UNTIL_TOOLTIPS={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"},t.Extensions.register("controls_whileUntil_tooltip",t.Extensions.buildTooltipForDropdown("MODE",t.Constants.Loops.WHILE_UNTIL_TOOLTIPS)),t.Constants.Loops.BREAK_CONTINUE_TOOLTIPS={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"},t.Extensions.register("controls_flow_tooltip",t.Extensions.buildTooltipForDropdown("FLOW",t.Constants.Loops.BREAK_CONTINUE_TOOLTIPS)),t.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(e){if(!this.isInFlyout){var o=this.getField("VAR").getVariable(),i=o.name;if(!this.isCollapsed()&&null!=i){var n={enabled:!0};n.text=t.Msg.VARIABLES_SET_CREATE_GET.replace("%1",i),o=t.Variables.generateVariableFieldDom(o),i=t.utils.xml.createElement("block"),i.setAttribute("type","variables_get"),i.appendChild(o),n.callback=t.ContextMenu.callbackFactory(this,i),e.push(n)}}}},t.Extensions.registerMixin("contextMenu_newGetVariableBlock",t.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN),t.Extensions.register("controls_for_tooltip",t.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),t.Extensions.register("controls_forEach_tooltip",t.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR")),t.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"],suppressPrefixSuffix:!0,getSurroundLoop:function(e){do{if(-1!=t.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.indexOf(e.type))return e;e=e.getSurroundParent()}while(e);return null},onchange:function(e){this.workspace.isDragging&&!this.workspace.isDragging()&&(t.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(this)?(this.setWarningText(null),this.isInFlyout||this.setEnabled(!0)):(this.setWarningText(t.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),this.isInFlyout||this.getInheritedDisabled()||this.setEnabled(!1)))}},t.Extensions.registerMixin("controls_flow_in_loop_check",t.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN),t.Blocks.math={},t.Constants.Math={},t.Constants.Math.HUE=230,t.defineBlocksWithJsonArray([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_TRIG_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_constant",message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]}],output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTANT_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTANT_HELPURL}"},{type:"math_number_property",message0:"%1 %2",args0:[{type:"input_value",name:"NUMBER_TO_CHECK",check:"Number"},{type:"field_dropdown",name:"PROPERTY",options:[["%{BKY_MATH_IS_EVEN}","EVEN"],["%{BKY_MATH_IS_ODD}","ODD"],["%{BKY_MATH_IS_PRIME}","PRIME"],["%{BKY_MATH_IS_WHOLE}","WHOLE"],["%{BKY_MATH_IS_POSITIVE}","POSITIVE"],["%{BKY_MATH_IS_NEGATIVE}","NEGATIVE"],["%{BKY_MATH_IS_DIVISIBLE_BY}","DIVISIBLE_BY"]]}],inputsInline:!0,output:"Boolean",style:"math_blocks",tooltip:"%{BKY_MATH_IS_TOOLTIP}",mutator:"math_is_divisibleby_mutator"},{type:"math_change",message0:"%{BKY_MATH_CHANGE_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_MATH_CHANGE_TITLE_ITEM}"},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,style:"variable_blocks",helpUrl:"%{BKY_MATH_CHANGE_HELPURL}",extensions:["math_change_tooltip"]},{type:"math_round",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ROUND_OPERATOR_ROUND}","ROUND"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}","ROUNDUP"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}","ROUNDDOWN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ROUND_HELPURL}",tooltip:"%{BKY_MATH_ROUND_TOOLTIP}"},{type:"math_on_list",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ONLIST_OPERATOR_SUM}","SUM"],["%{BKY_MATH_ONLIST_OPERATOR_MIN}","MIN"],["%{BKY_MATH_ONLIST_OPERATOR_MAX}","MAX"],["%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}","AVERAGE"],["%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}","MEDIAN"],["%{BKY_MATH_ONLIST_OPERATOR_MODE}","MODE"],["%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}","STD_DEV"],["%{BKY_MATH_ONLIST_OPERATOR_RANDOM}","RANDOM"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ONLIST_HELPURL}",mutator:"math_modes_of_list_mutator",extensions:["math_op_tooltip"]},{type:"math_modulo",message0:"%{BKY_MATH_MODULO_TITLE}",args0:[{type:"input_value",name:"DIVIDEND",check:"Number"},{type:"input_value",name:"DIVISOR",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_MODULO_TOOLTIP}",helpUrl:"%{BKY_MATH_MODULO_HELPURL}"},{type:"math_constrain",message0:"%{BKY_MATH_CONSTRAIN_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"Number"},{type:"input_value",name:"LOW",check:"Number"},{type:"input_value",name:"HIGH",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTRAIN_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTRAIN_HELPURL}"},{type:"math_random_int",message0:"%{BKY_MATH_RANDOM_INT_TITLE}",args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:"TO",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_INT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_INT_HELPURL}"},{type:"math_random_float",message0:"%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}",output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_FLOAT_HELPURL}"},{type:"math_atan2",message0:"%{BKY_MATH_ATAN2_TITLE}",args0:[{type:"input_value",name:"X",check:"Number"},{type:"input_value",name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_ATAN2_TOOLTIP}",helpUrl:"%{BKY_MATH_ATAN2_HELPURL}"}]),t.Constants.Math.TOOLTIPS_BY_OP={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}",SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"},t.Extensions.register("math_op_tooltip",t.Extensions.buildTooltipForDropdown("OP",t.Constants.Math.TOOLTIPS_BY_OP)),t.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN={mutationToDom:function(){var e=t.utils.xml.createElement("mutation"),o="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");return e.setAttribute("divisor_input",o),e},domToMutation:function(t){t="true"==t.getAttribute("divisor_input"),this.updateShape_(t)},updateShape_:function(t){var e=this.getInput("DIVISOR");t?e||this.appendValueInput("DIVISOR").setCheck("Number"):e&&this.removeInput("DIVISOR")}},t.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION=function(){this.getField("PROPERTY").setValidator((function(t){t="DIVISIBLE_BY"==t,this.getSourceBlock().updateShape_(t)}))},t.Extensions.registerMutator("math_is_divisibleby_mutator",t.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN,t.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION),t.Extensions.register("math_change_tooltip",t.Extensions.buildTooltipWithFieldText("%{BKY_MATH_CHANGE_TOOLTIP}","VAR")),t.Constants.Math.LIST_MODES_MUTATOR_MIXIN={updateType_:function(t){"MODE"==t?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var e=t.utils.xml.createElement("mutation");return e.setAttribute("op",this.getFieldValue("OP")),e},domToMutation:function(t){this.updateType_(t.getAttribute("op"))}},t.Constants.Math.LIST_MODES_MUTATOR_EXTENSION=function(){this.getField("OP").setValidator(function(t){this.updateType_(t)}.bind(this))},t.Extensions.registerMutator("math_modes_of_list_mutator",t.Constants.Math.LIST_MODES_MUTATOR_MIXIN,t.Constants.Math.LIST_MODES_MUTATOR_EXTENSION),t.Blocks.procedures={},t.Blocks.procedures_defnoreturn={init:function(){var e=new t.FieldTextInput("",t.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(t.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(e,"NAME").appendField("","PARAMS"),this.setMutator(new t.Mutator(["procedures_mutatorarg"])),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&t.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(t.Msg.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(t.Msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(t.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:function(e){this.hasStatements_!==e&&(e?(this.appendStatementInput("STACK").appendField(t.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=e)},updateParams_:function(){var e="";this.arguments_.length&&(e=t.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),t.Events.disable();try{this.setFieldValue(e,"PARAMS")}finally{t.Events.enable()}},mutationToDom:function(e){var o=t.utils.xml.createElement("mutation");e&&o.setAttribute("name",this.getFieldValue("NAME"));for(var i=0;i<this.argumentVarModels_.length;i++){var n=t.utils.xml.createElement("arg"),s=this.argumentVarModels_[i];n.setAttribute("name",s.name),n.setAttribute("varid",s.getId()),e&&this.paramIds_&&n.setAttribute("paramId",this.paramIds_[i]),o.appendChild(n)}return this.hasStatements_||o.setAttribute("statements","false"),o},domToMutation:function(e){this.arguments_=[],this.argumentVarModels_=[];for(var o,i=0;o=e.childNodes[i];i++)if("arg"==o.nodeName.toLowerCase()){var n=o.getAttribute("name");o=o.getAttribute("varid")||o.getAttribute("varId"),this.arguments_.push(n),o=t.Variables.getOrCreateVariablePackage(this.workspace,o,n,""),null!=o?this.argumentVarModels_.push(o):console.log("Failed to create a variable with name "+n+", ignoring.")}this.updateParams_(),t.Procedures.mutateCallers(this),this.setStatements_("false"!==e.getAttribute("statements"))},decompose:function(e){var o=t.utils.xml.createElement("block");o.setAttribute("type","procedures_mutatorcontainer");var i=t.utils.xml.createElement("statement");i.setAttribute("name","STACK"),o.appendChild(i);for(var n=0;n<this.arguments_.length;n++){var s=t.utils.xml.createElement("block");s.setAttribute("type","procedures_mutatorarg");var r=t.utils.xml.createElement("field");r.setAttribute("name","NAME");var a=t.utils.xml.createTextNode(this.arguments_[n]);r.appendChild(a),s.appendChild(r),r=t.utils.xml.createElement("next"),s.appendChild(r),i.appendChild(s),i=r}return e=t.Xml.domToBlock(o,e),"procedures_defreturn"==this.type?e.setFieldValue(this.hasStatements_,"STATEMENTS"):e.removeInput("STATEMENT_INPUT"),t.Procedures.mutateCallers(this),e},compose:function(e){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];for(var o=e.getInputTargetBlock("STACK");o;){var i=o.getFieldValue("NAME");this.arguments_.push(i),i=this.workspace.getVariable(i,""),this.argumentVarModels_.push(i),this.paramIds_.push(o.id),o=o.nextConnection&&o.nextConnection.targetBlock()}this.updateParams_(),t.Procedures.mutateCallers(this),e=e.getFieldValue("STATEMENTS"),null!==e&&(e="TRUE"==e,this.hasStatements_!=e)&&(e?(this.setStatements_(!0),t.Mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null):(e=this.getInput("STACK").connection,(this.statementConnection_=e.targetConnection)&&(e=e.targetBlock(),e.unplug(),e.bumpNeighbours()),this.setStatements_(!1)))},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(e,o){var i=this.workspace.getVariableById(e);if(""==i.type){i=i.name;for(var n=this.workspace.getVariableById(o),s=!1,r=0;r<this.argumentVarModels_.length;r++)this.argumentVarModels_[r].getId()==e&&(this.arguments_[r]=n.name,this.argumentVarModels_[r]=n,s=!0);s&&(this.displayRenamedVar_(i,n.name),t.Procedures.mutateCallers(this))}},updateVarName:function(e){for(var o=e.name,i=!1,n=0;n<this.argumentVarModels_.length;n++)if(this.argumentVarModels_[n].getId()==e.getId()){var s=this.arguments_[n];this.arguments_[n]=o,i=!0}i&&(this.displayRenamedVar_(s,o),t.Procedures.mutateCallers(this))},displayRenamedVar_:function(e,o){if(this.updateParams_(),this.mutator&&this.mutator.isVisible())for(var i,n=this.mutator.workspace_.getAllBlocks(!1),s=0;i=n[s];s++)"procedures_mutatorarg"==i.type&&t.Names.equals(e,i.getFieldValue("NAME"))&&i.setFieldValue(o,"NAME")},customContextMenu:function(e){if(!this.isInFlyout){var o={enabled:!0},i=this.getF