pxt-core 13.1.2 → 13.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/cli.js +37 -0
- package/built/pxt.js +37 -0
- package/built/target.js +1 -1
- package/built/targetlight.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtembed.js +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/runnerembed.js +1 -1
- package/built/web/semantic.css +1 -1
- package/localtypings/pxteditor.d.ts +4 -1
- package/package.json +1 -1
- package/theme/home.less +1 -3
package/built/web/pxtembed.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
* Copyright 2024 Google LLC
|
|
19
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
20
20
|
*/
|
|
21
|
-
Object.defineProperty(n,"__esModule",{value:!0}),n.setDuplicateOnDragStrategy=n.DuplicateOnDragStrategy=void 0;const i=e("blockly"),r=e("./duplicateOnDrag");class o extends i.dragging.BlockDragStrategy{getTargetBlock(){const e=this;return e.block.isShadow()&&(0,r.isAllowlistedShadow)(e.block)?e.block:super.getTargetBlock()}drag(e,t){if(super.drag(e,t),!t||t instanceof PointerEvent){this.block.moveDuringDrag(e)}}disconnectBlock(e){var t;const n=this;let o,s,a;const l=n.block.isShadow();if(l&&n.block.setShadow(!1),(0,r.shouldDuplicateOnDrag)(n.block)){const e=n.block.outputConnection;if(!(null==e?void 0:e.targetConnection))return;a=i.Xml.blockToDom(n.block,!0),l||(o=i.Xml.domToBlock(a,n.block.workspace)),s=e.targetConnection}e&&(n.startChildConn=null===(t=n.block.nextConnection)||void 0===t?void 0:t.targetConnection),s&&l&&s.setShadowDom(a),n.block.unplug(e),i.blockAnimations.disconnectUiEffect(n.block),(0,r.updateDuplicateOnDragState)(n.block),s&&o&&s.connect(o.outputConnection)}}n.DuplicateOnDragStrategy=o,n.setDuplicateOnDragStrategy=function(e){var t,n;null===(n=(t=e).setDragStrategy)||void 0===n||n.call(t,new o(e))}},{"./duplicateOnDrag":106,blockly:192}],106:[function(e,t,n){let i,r;function o(e){return!(!i||-1===i.indexOf(e.type))}function s(e){var t,n;if(e.isShadow()&&o(e))return!0;if(r){const i=null===(t=e.outputConnection)||void 0===t?void 0:t.targetBlock();if(i){const t=r.filter(e=>e.parentBlockType===i.type);for(const i of t)if(i&&(!i.childBlockType||i.childBlockType===e.type)){if(!i.inputName)return!0;if((null===(n=e.outputConnection.targetConnection.getParentInput())||void 0===n?void 0:n.name)===i.inputName)return!0}}}return!1}Object.defineProperty(n,"__esModule",{value:!0}),n.updateDuplicateOnDragState=n.shouldDuplicateOnDrag=n.isAllowlistedShadow=n.setDuplicateOnDrag=n.setDraggableShadowBlocks=void 0,n.setDraggableShadowBlocks=function(e){i=e},n.setDuplicateOnDrag=function(e,t,n){r||(r=[]),r.some(i=>i.parentBlockType===e&&i.inputName===t&&i.childBlockType===n)||r.push({parentBlockType:e,inputName:t,childBlockType:n})},n.isAllowlistedShadow=o,n.shouldDuplicateOnDrag=s,n.updateDuplicateOnDragState=function(e){setTimeout(()=>{const t=s(e);e.pathObject&&e.pathObject.setHasDottedOutlineOnHover(t),e.setDeletable(!t)})}},{}],107:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./duplicateOnDrag"),n),r(e("./variablesGetReporter"),n),r(e("./connectionChecker"),n),r(e("./dragStrategy"),n)},{"./connectionChecker":104,"./dragStrategy":105,"./duplicateOnDrag":106,"./variablesGetReporter":108}],108:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("./duplicateOnDrag");i.Blocks.variables_get_reporter={init:function(){this.jsonInit({type:"variables_get_reporter",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}",variableTypes:[""]}],output:null,colour:"%{BKY_VARIABLES_HUE}",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableReporter"]}),(0,r.updateDuplicateOnDragState)(this)}}},{"./duplicateOnDrag":106,blockly:192}],109:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MultiFlyoutRecyclableBlockInflater=n.HIDDEN_CLASS_NAME=void 0;const i=e("blockly");n.HIDDEN_CLASS_NAME="pxtFlyoutHidden";class r extends i.BlockFlyoutInflater{constructor(){super(...arguments),this.keyToBlock=new Map,this.blockToKey=new Map}static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,"block",r,!0)}isBlockRecycleable(e){switch(e.type){case"variables_get":case"variables_set":case"variables_change":return!1}return!0}createBlock(e,t){const r=function(e){if(e.blockxml)return"string"==typeof e.blockxml?e.blockxml:i.Xml.domToText(e.blockxml);return e.type}(e);if(!r)return super.createBlock(e,t);let o;return this.keyToBlock.has(r)&&(o=this.keyToBlock.get(r),this.keyToBlock.delete(r),t.getCanvas().appendChild(o.getSvgRoot())),o=null!=o?o:super.createBlock(e,t),this.blockToKey.set(o,r),o.removeClass(n.HIDDEN_CLASS_NAME),o.getFocusableElement().ariaHidden="false",o.setDisabledReason(!1,n.HIDDEN_CLASS_NAME),o}disposeItem(e){const t=e.getElement();if(t instanceof i.BlockSvg&&this.blockToKey.has(t)){if(this.isBlockRecycleable(t))return void this.recycleBlock(t);this.blockToKey.delete(t)}super.disposeItem(e)}clearCache(){this.blockToKey=new Map,this.keyToBlock=new Map}recycleBlock(e){const t=e.getRelativeToSurfaceXY();e.moveBy(-t.x,-t.y),e.addClass(n.HIDDEN_CLASS_NAME),e.getFocusableElement().ariaHidden="true",e.setDisabledReason(!0,n.HIDDEN_CLASS_NAME),e.getSvgRoot().remove();const i=this.blockToKey.get(e);this.keyToBlock.set(i,e),this.removeListeners(e.id)}}n.MultiFlyoutRecyclableBlockInflater=r,i.Css.register(`\n.${n.HIDDEN_CLASS_NAME} {\n display: none;\n}\n`)},{blockly:192}],110:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ButtonFlyoutInflater=void 0;const i=e("blockly"),r=e("./flyoutButton"),o="button";class s extends i.ButtonFlyoutInflater{static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,o,s,!0)}load(e,t){const n=new r.FlyoutButton(t.getWorkspace(),t.targetWorkspace,e,!1);return n.show(),new i.FlyoutItem(n,o)}}n.ButtonFlyoutInflater=s},{"./flyoutButton":112,blockly:192}],111:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.CachingFlyout=void 0;const i=e("blockly"),r=e("./blockInflater");class o extends i.VerticalFlyout{constructor(){super(...arguments),this.forceOpen=!1}clearBlockCache(){const e=this.getInflaterForType("block");e instanceof r.MultiFlyoutRecyclableBlockInflater&&e.clearCache()}getFlyoutElement(){return this.svgGroup_}setForceOpen(e){this.forceOpen=e}}n.CachingFlyout=o},{"./blockInflater":109,blockly:192}],112:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FlyoutButton=void 0;const i=e("blockly"),r={"":"usb","":"accessible-icon","":"adn","":"pied-piper-pp","":"steam","":"bluetooth-b","":"rebel","":"maxcdn","":"joomla","":"sellsy","":"connectdevelop","":"github-alt"};class o extends i.FlyoutButton{constructor(e,t,n,o){super(e,t,n,o);const s=this.getSvgRoot();if(!o){const e=17.5,t=14,n=this.height;this.width+=2*(e-i.FlyoutButton.TEXT_MARGIN_X),this.height+=2*(t-i.FlyoutButton.TEXT_MARGIN_Y);const r=s.getElementsByClassName("blocklyFlyoutButtonShadow").item(0),o=s.getElementsByClassName("blocklyFlyoutButtonBackground").item(0),a=s.getElementsByTagName("text").item(0);return r.setAttribute("width",String(this.width)),r.setAttribute("height",String(this.height)),o.setAttribute("width",String(this.width)),o.setAttribute("height",String(this.height)),a.setAttribute("x",String(this.width/2)),void a.setAttribute("y",String(parseFloat(a.getAttribute("y"))-n/2+this.height/2))}const a=n;a["web-class"]&&s.classList.add(a["web-class"]);const l=a["web-icon"],c=a["web-icon-class"],u=a["web-icon-color"],d=a["web-icon-image"];if(d){const e=20,t=this.getTargetWorkspace(),n=i.utils.dom.createSvgElement("image",{height:String(e),width:String(e),x:String(t.RTL?this.width+i.FlyoutButton.TEXT_MARGIN_X:i.FlyoutButton.TEXT_MARGIN_X),y:String(this.height/2+i.FlyoutButton.TEXT_MARGIN_Y-e/2)},s);n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);const r=e+2*i.FlyoutButton.TEXT_MARGIN_X;this.width+=r;const o=s.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);o.setAttribute("width",String(this.width));for(let e=0;e<s.children.length;e++){const t=s.children.item(e);if(t!==n&&t!==o){const e=Number(t.getAttribute("x"));t.setAttribute("x",e+r+"")}}}else if(l||c){const e=Object.keys(r).includes(l)?"brandIcon":"",t=i.utils.dom.createSvgElement("text",{class:`blocklyFlyoutLabelIcon${c?" "+c:""}${e?" "+e:""}`,x:0,y:0,"text-anchor":"start"},s);l&&(t.textContent=l),u&&t.setAttribute("style","fill: "+u);const n=this.getTargetWorkspace();t.setAttribute("dominant-baseline","central"),t.setAttribute("dy","0"),t.setAttribute("x",(n.RTL?this.width+i.FlyoutButton.TEXT_MARGIN_X:0)+""),t.setAttribute("y",this.height/2+i.FlyoutButton.TEXT_MARGIN_Y+"");const o=i.utils.dom.getTextWidth(t)+2*i.FlyoutButton.TEXT_MARGIN_X;this.width+=o;const a=s.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);a.setAttribute("width",String(this.width));for(let e=0;e<s.children.length;e++){const n=s.children.item(e);if(n!==t&&n!==a){const e=Number(n.getAttribute("x"));n.setAttribute("x",e+o+"")}}}const p=a["web-line"],h=a["web-line-width"];if(p){const e=i.utils.dom.createSvgElement("line",{class:"blocklyFlyoutLine","stroke-dasharray":p,"text-anchor":"middle"},s);e.setAttribute("x1","0"),e.setAttribute("x2",null!=h?h:this.width+""),e.setAttribute("y1",this.height+10+""),e.setAttribute("y2",this.height+10+"")}}isDisposed(){return null===this.getSvgRoot().parentNode}}n.FlyoutButton=o},{blockly:192}],113:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.registerFlyoutInflaters=n.MultiFlyoutRecyclableBlockInflater=n.LabelFlyoutInflater=n.ButtonFlyoutInflater=void 0;const o=e("./buttonFlyoutInflater");Object.defineProperty(n,"ButtonFlyoutInflater",{enumerable:!0,get:function(){return o.ButtonFlyoutInflater}});const s=e("./labelFlyoutInflater");Object.defineProperty(n,"LabelFlyoutInflater",{enumerable:!0,get:function(){return s.LabelFlyoutInflater}});const a=e("./blockInflater");Object.defineProperty(n,"MultiFlyoutRecyclableBlockInflater",{enumerable:!0,get:function(){return a.MultiFlyoutRecyclableBlockInflater}}),r(e("./cachingFlyout"),n),n.registerFlyoutInflaters=function(){o.ButtonFlyoutInflater.register(),s.LabelFlyoutInflater.register(),a.MultiFlyoutRecyclableBlockInflater.register()}},{"./blockInflater":109,"./buttonFlyoutInflater":110,"./cachingFlyout":111,"./labelFlyoutInflater":114}],114:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.LabelFlyoutInflater=void 0;const i=e("blockly"),r=e("./flyoutButton"),o="label";class s extends i.LabelFlyoutInflater{static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,o,s,!0)}load(e,t){const n=new r.FlyoutButton(t.getWorkspace(),t.targetWorkspace,e,!0);return n.show(),new i.FlyoutItem(n,o)}}n.LabelFlyoutInflater=s},{"./flyoutButton":112,blockly:192}],115:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../constants"),o={typeName_:"",getTypeName(){return this.typeName_},removeFieldCallback(e){const t=this.getParent();(null==t?void 0:t.removeFieldCallback)&&t.removeFieldCallback(e)}};i.Blocks[r.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"bool"}],extensions:["output_boolean","text_field_color"]}),this.typeName_="boolean"}}),i.Blocks[r.ARGUMENT_EDITOR_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"text"}],extensions:["output_string","text_field_color"]}),this.typeName_="string"}}),i.Blocks[r.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"num"}],extensions:["output_number","text_field_color"]}),this.typeName_="number"}}),i.Blocks[r.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"list"}],extensions:["output_array","text_field_color"]}),this.typeName_="Array"}}),i.Blocks[r.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"arg"}],outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,extensions:["text_field_color"]}),this.typeName_="any"},mutationToDom(){const e=i.utils.xml.createElement("mutation");return e.setAttribute("typename",this.typeName_),e},domToMutation(e){this.typeName_=e.getAttribute("typename"),this.setOutput(!0,this.typeName_)}})},{"../constants":121,blockly:192}],116:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.LOCALIZATION_NAME_MUTATION_KEY=void 0;const i=e("blockly"),r=e("../constants"),o=e("../msg"),s=e("../../duplicateOnDrag");n.LOCALIZATION_NAME_MUTATION_KEY="localizationname";const a={typeName_:"",localizationName_:"",getTypeName(){return this.typeName_},getLocalizationName(){return this.localizationName_||this.getFieldValue("VALUE")},mutationToDom(){const e=i.utils.xml.createElement("mutation");return this.localizationName_&&e.setAttribute(n.LOCALIZATION_NAME_MUTATION_KEY,this.localizationName_),e},domToMutation(e){e.hasAttribute(n.LOCALIZATION_NAME_MUTATION_KEY)&&(this.localizationName_=e.getAttribute(n.LOCALIZATION_NAME_MUTATION_KEY))}};function l(e){(0,s.setDuplicateOnDragStrategy)(e),(0,s.updateDuplicateOnDragState)(e)}i.Blocks[r.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_boolean"]}),this.typeName_="boolean",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_string"]}),this.typeName_="string",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_number"]}),this.typeName_="number",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_array"]}),this.typeName_="Array",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],inputsInline:!0,outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,output:null}),this.typeName_="",l(this)},mutationToDom(){const e=a.mutationToDom.call(this);return e.setAttribute("typename",this.typeName_),e},domToMutation(e){this.typeName_=e.getAttribute("typename"),this.setOutput(!0,this.typeName_),a.domToMutation.call(this,e)}})},{"../../duplicateOnDrag":107,"../constants":121,"../msg":128,blockly:192}],117:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../msg"),l=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){let r=null,o=null;if(t&&e.id in t){const n=t[e.id];r=n.block,o=n.shadow}const s=null==r?void 0:r.workspace.connectionChecker;i.Events.disable();try{if(r&&!r.isDisposed()&&t&&(null==s?void 0:s.canConnectWithReason(null==r?void 0:r.outputConnection,n.connection,!1))===i.Connection.CAN_CONNECT){let s;r.outputConnection.connect(n.connection),s=r.isShadow()?i.Xml.blockToDom(r):o||this.buildShadowDom_(e.type),"variables_get"!==s.getAttribute("type")&&n.connection.setShadowDom(s),delete t[n.name]}else this.attachShadow_(n,e.type)}finally{i.Events.enable()}},afterWorkspaceLoad:function(){var e;for(const t of this.inputList){if(t.type!==i.inputs.inputTypes.VALUE)continue;const n=null===(e=t.connection)||void 0===e?void 0:e.targetBlock();n&&n.isShadow()&&n.getVarModels().length&&n.setShadow(!1);const r=t.connection&&t.getShadowDom();(0,s.isVariableBlockType)(null==r?void 0:r.getAttribute("type"))&&t.setShadowDom(null)}},addFunctionLabel_:function(e){this.appendDummyInput("function_name").appendField(new i.FieldLabel(e,"functionNameText"),"function_name")},updateFunctionLabel_:function(e){this.getField("function_name").setValue(e)},attachShadow_(e,t){const n=(0,s.getShadowBlockInfoFromType_)(t,this.workspace),r=n[0],o=n[1],a=n[2];i.Events.disable();let l=null;try{l=this.workspace.newBlock(r),l.setFieldValue(a,o),l.setShadow("variables_get"!==r),!this.isInsertionMarker()&&l instanceof i.BlockSvg&&(l.initSvg(),l.queueRender())}finally{i.Events.enable()}l&&(l.setShadow(!0),l.outputConnection.connect(e.connection))},buildShadowDom_(e){const t=i.utils.xml.createElement("shadow"),n=(0,s.getShadowBlockInfoFromType_)(e,this.workspace),r=n[0],o=n[1],a=n[2],l="variables_get"===r;t.setAttribute("type",r);const c=i.utils.xml.createElement("field");if(c.textContent=a,l){c.setAttribute("id",a);const e=this.workspace.getVariableMap().getVariableById(a);c.textContent=e?e.getName():""}return c.setAttribute("name",o),t.appendChild(c),t},onchange(e){var t;if(this.workspace&&!this.workspace.isFlyout)if(e.type==i.Events.BLOCK_CREATE&&-1!=(null===(t=e.ids)||void 0===t?void 0:t.indexOf(this.id))){const t=this.getName(),n=(0,s.getDefinition)(t,this.workspace);if(n){const e=n.getArguments().slice(),t=this.arguments_.slice();JSON.stringify(t)!==JSON.stringify(e)&&(0,s.mutateCallersAndDefinition)(n.getName(),this.workspace,n.mutationToDom()),this.functionId_=n.functionId_}else{i.Events.setGroup(e.group);const t=i.utils.xml.createElement("xml"),n=i.utils.xml.createElement("block");n.setAttribute("type",o.FUNCTION_DEFINITION_BLOCK_TYPE);const r=this.getRelativeToSurfaceXY(),s=r.x+i.config.snapRadius*(this.RTL?-1:1),a=r.y+2*i.config.snapRadius;n.setAttribute("x",s+""),n.setAttribute("y",a+"");const l=this.mutationToDom();n.appendChild(l),t.appendChild(n),i.Xml.domToWorkspace(t,this.workspace),i.Events.setGroup(!1)}}else if(e.type==i.Events.BLOCK_DELETE){const t=this.getName();(0,s.getDefinition)(t,this.workspace)||(i.Events.setGroup(e.group),this.dispose(!0),i.Events.setGroup(!1))}},serializeChangedInputs(e){const t=[],n=(0,s.getArgMap)(e,!0);for(const e of this.arguments_){if(n[e.id])continue;const i=this.getInput(e.id).connection,r=i.targetBlock();r.isShadow()?t.push({inputName:e.id,connectedShadow:i.getShadowState(!0)}):t.push({inputName:e.id,connectedBlock:r.id})}return t}});i.Blocks[o.FUNCTION_CALL_BLOCK_TYPE]=Object.assign(Object.assign({},l),{init:function(){this.jsonInit({extensions:["function_contextmenu_edit"]}),this.name_="",this.arguments_=[],this.functionId_="",this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(i.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(i.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(i.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}}),i.Blocks[o.FUNCTION_CALL_OUTPUT_BLOCK_TYPE]=Object.assign(Object.assign({},l),{init:function(){this.jsonInit({extensions:["function_contextmenu_edit"]}),this.name_="",this.arguments_=[],this.functionId_="",this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,null),this.setOutputShape((new i.zelos.ConstantProvider).SHAPES.ROUND),this.setColour(i.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(i.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(i.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../msg":128,"../utils":130,blockly:192}],118:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.newFunctionMutation=void 0;const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../fields/fieldAutocapitalizeTextInput"),l=e("../functionManager"),c=e("../msg"),u=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){const i=this.createArgumentEditor_(e.type,e.name);n.connection.connect(i.outputConnection)},addFunctionLabel_:function(e){const t=new a.FieldAutocapitalizeTextInput(e||"",void 0,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(t,"function_name")},updateFunctionLabel_:function(e){i.Events.disable(),this.getField("function_name").setValue(e),i.Events.enable()},createArgumentEditor_:function(e,t){let n;i.Events.disable();try{let r="";switch(e){case"boolean":r=o.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE;break;case"number":r=o.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE;break;case"string":r=o.ARGUMENT_EDITOR_STRING_BLOCK_TYPE;break;case"Array":r=o.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE;break;default:r=o.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE}n=r==o.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE?(0,s.createCustomArgumentEditor)(e,this.workspace):this.workspace.newBlock(r),n.setFieldValue(t,"TEXT"),n.setShadow(!0),!this.isInsertionMarker()&&n instanceof i.BlockSvg&&(n.initSvg(),n.queueRender())}finally{i.Events.enable()}return n},async focusLastEditorAsync_(){if(await i.renderManagement.finishQueuedRenders(),this.inputList.length>0){let e=this.inputList[this.inputList.length-2];if(e.type==i.inputs.inputTypes.DUMMY){const t=this.workspace;t instanceof i.WorkspaceSvg&&t.centerOnBlock(this.id,!0),e.fieldRow[0].showEditor()}else if(e.type==i.inputs.inputTypes.VALUE){const t=e.connection.targetBlock(),n=t.workspace;n instanceof i.WorkspaceSvg&&n.centerOnBlock(t.id,!0),t.getField("TEXT").showEditor()}}},removeFieldCallback(e){let t=null;for(let n=0;n<this.inputList.length&&!t;n++){let i=this.inputList[n];if(i.connection){let n=i.connection.targetBlock();if(!n)continue;n.getField(e.name)===e&&(t=i.name)}else for(let n=0;n<i.fieldRow.length;n++)i.fieldRow[n]==e&&(t=i.name)}t&&(i.WidgetDiv.hide(),this.removeInput(t),this.updateFunctionSignature(),this.updateDisplay_())},addParam_(e,t){i.WidgetDiv.hide();const n=(0,s.findUniqueParamName)(t,this.arguments_.map(e=>e.name));this.arguments_.push({id:i.utils.idGenerator.genUid(),name:n,type:e}),this.updateDisplay_(),this.focusLastEditorAsync_()},addBooleanExternal(){this.addParam_("boolean",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME])},addStringExternal(){this.addParam_("string",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_STRING_ARG_NAME])},addNumberExternal(){this.addParam_("number",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME])},addArrayExternal(){this.addParam_("Array",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME])},addCustomExternal(e){this.addParam_(e,l.FunctionManager.getInstance().getArgumentNameForType(e))},updateFunctionSignature(){this.arguments_=[];for(let e=1;e<this.inputList.length;e++){const t=this.inputList[e];switch(t.type){case i.inputs.inputTypes.STATEMENT:break;case i.inputs.inputTypes.DUMMY:this.name_=t.fieldRow[0].getValue()||t.fieldRow[0].getText();break;case i.inputs.inputTypes.VALUE:const e=t.connection.targetBlock();this.arguments_.push({id:t.name,name:e.getFieldValue("TEXT"),type:e.getTypeName()});break;default:pxt.warn("Unexpected input type on a function mutator root: "+t.type)}}}});n.newFunctionMutation=function(e){const t=(0,s.findLegalName)(i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_FUNCTION_NAME],e),n=i.utils.xml.createElement("mutation");return n.setAttribute("name",t),n.setAttribute("functionid",i.utils.idGenerator.genUid()),n},i.Blocks[o.FUNCTION_DECLARATION_BLOCK_TYPE]=Object.assign(Object.assign({},u),{init:function(){this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(i.Msg[c.MsgKey.PROCEDURES_HUE]),this.setStatements_(!0),this.setDeletable(!1),this.setMovable(!1),this.contextMenu=!1,this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../fields/fieldAutocapitalizeTextInput":125,"../functionManager":126,"../msg":128,"../utils":130,blockly:192}],119:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../fields/fieldAutocapitalizeTextInput"),l=e("../msg"),c=e("../functionManager"),u=e("../svgs"),d=e("../../duplicateOnDrag"),p=e("../../../fields/field_imagenotext"),h=e("../../../utils"),f=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){let i,r=null;if(null==t?void 0:t[e.id]){r=t[e.id].block}t&&r&&!r.isDisposed()?(i=r,i.setFieldValue(e.name,"VALUE"),delete t[n.name]):i=this.createArgumentReporter_(e),n.connection.connect(i.outputConnection)},afterWorkspaceLoad:function(){for(const e of this.inputList){if(e.type!==i.inputs.inputTypes.VALUE)continue;const t=this.arguments_.find(t=>t.id===e.name);if(!t)continue;let n=e.connection.targetBlock();n||(this.populateArgument_(t,null,e),n=e.connection.targetBlock()),n.setFieldValue(t.name,"VALUE"),n.isShadow()&&n.setShadow(!1),e.setShadowDom(null)}},addFunctionLabel_:function(e){const t=new a.FieldAutocapitalizeTextInput(e||"",s.rename,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(t,"function_name")},updateFunctionLabel_:function(e){i.Events.disable(),this.getField("function_name").setValue(e),i.Events.enable()},createArgumentReporter_:function(e){let t,n="";switch(e.type){case"boolean":n=o.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE;break;case"number":n=o.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE;break;case"string":n=o.ARGUMENT_REPORTER_STRING_BLOCK_TYPE;break;case"Array":n=o.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE;break;default:n=o.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}i.Events.disable();try{t=n==o.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE?(0,s.createCustomArgumentReporter)(e.type,this.workspace):this.workspace.newBlock(n),t.setFieldValue(e.name,"VALUE"),t.setShadow(!0),!this.isInsertionMarker()&&t instanceof i.BlockSvg&&(t.initSvg(),t.queueRender())}finally{i.Events.enable()}return t},customContextMenu:function(e){var t,n;this.isInFlyout||(null===(n=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===n?void 0:n.readOnly)||(e.push(this.makeEditOption()),e.push(this.makeCallOption()))},makeEditOption:function(){var e,t;return{enabled:!(null===(t=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===t?void 0:t.readOnly),text:i.Msg.FUNCTIONS_EDIT_OPTION,callback:()=>{!function(e){if(e.type==o.FUNCTION_CALL_BLOCK_TYPE||e.type==o.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const t=e.workspace;e=(0,s.getDefinition)(e.getName(),t)}i.hideChaff(),i.getSelected()&&i.getSelected().unselect();c.FunctionManager.getInstance().editFunctionExternal(e.mutationToDom(),t=>{t&&((0,s.mutateCallersAndDefinition)(e.getName(),e.workspace,t),e.updateDisplay_()),setTimeout(()=>{e.afterWorkspaceLoad&&e.afterWorkspaceLoad()})})}(this)}}},makeCallOption:function(){var e,t;const n=this.getName(),r=i.utils.xml.createElement("mutation");r.setAttribute("name",n);const s=i.utils.xml.createElement("block");return s.appendChild(r),s.setAttribute("type",o.FUNCTION_CALL_BLOCK_TYPE),{enabled:this.workspace.remainingCapacity()>0&&!(null===(t=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===t?void 0:t.readOnly),text:i.Msg.FUNCTIONS_CREATE_CALL_OPTION.replace("%1",n),callback:i.ContextMenu.callbackFactory(this,s)}}});i.Blocks[o.FUNCTION_DEFINITION_BLOCK_TYPE]=Object.assign(Object.assign({},f),{init:function(){if(this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(i.Msg[l.MsgKey.PROCEDURES_HUE]),this.setTooltip(i.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_TOOLTIP]),this.setHelpUrl(i.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_HELPURL]),this.setStatements_(!0),this.setInputsInline(!0),this.workspace.options.collapse){const e=u.COLLAPSE_IMAGE_DATAURI;this.appendDummyInput("function_collapse").appendField(new p.FieldImageNoText(e,24,24,lf("Collapse block"),()=>{var e;this.setCollapsed(!0);const t=null===(e=this.inputList.find(e=>e.name===i.constants.COLLAPSED_INPUT_NAME))||void 0===e?void 0:e.fieldRow[1];(0,h.maybeMoveFocusFromButton)(t)},!1))}}}),(0,d.setDuplicateOnDrag)(o.FUNCTION_DEFINITION_BLOCK_TYPE)},{"../../../fields/field_imagenotext":38,"../../../utils":155,"../../duplicateOnDrag":107,"../commonFunctionMixin":120,"../constants":121,"../fields/fieldAutocapitalizeTextInput":125,"../functionManager":126,"../msg":128,"../svgs":129,"../utils":130,blockly:192}],120:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.COMMON_FUNCTION_MIXIN=void 0;const i=e("blockly"),r=e("./constants"),o=e("./utils"),s=e("./msg");n.COMMON_FUNCTION_MIXIN={name_:"",functionId_:"",arguments_:[],mutationToDom:function(){this.ensureIds_();const e=i.utils.xml.createElement("mutation");return e.setAttribute("name",this.name_),e.setAttribute("functionid",this.functionId_),this.arguments_.forEach(function(t){const n=i.utils.xml.createElement("arg");n.setAttribute("name",t.name),n.setAttribute("id",t.id),n.setAttribute("type",t.type),e.appendChild(n)}),e},domToMutation:function(e){const t=[];for(let n=0;n<e.childNodes.length;++n){const i=e.childNodes[n];"arg"==i.nodeName.toLowerCase()&&t.push({id:i.getAttribute("id"),name:i.getAttribute("name"),type:i.getAttribute("type")})}this.arguments_=t,this.name_=e.getAttribute("name"),this.restoreSavedFunctionId(e.getAttribute("functionid"))},saveExtraState:function(){return{name:this.name_,functionid:this.functionId_,arguments:this.arguments_.slice()}},loadExtraState:function(e){this.arguments_=e.arguments.slice(),this.name_=e.name,this.restoreSavedFunctionId(e.functionid)},restoreSavedFunctionId:function(e){(0,o.idsInUse)(this.workspace).indexOf(e)<0&&(this.functionId_=e),this.ensureIds_();let t=null;this instanceof i.BlockSvg&&(t=this.getHeightWidth()),this.type!==r.FUNCTION_DEFINITION_BLOCK_TYPE||t&&!t.height&&!t.width?this.updateDisplay_():!this.getFieldValue("function_name")&&this.name_&&(this.setFieldValue(this.name_,"function_name"),this.updateDisplay_())},getName:function(){return this.name_},getFunctionId:function(){return this.functionId_},getArguments:function(){return this.arguments_},removeValueInputs_:function(){const e=[];for(let t,n=0;t=this.inputList[n];n++)t.type==i.inputs.inputTypes.VALUE?t.dispose():e.push(t);this.inputList=e},createAllInputs_:function(){let e=!1,t=!1;if(this.inputList.forEach(function(n){"function_title"==n.name?e=!0:"function_name"==n.name&&(t=!0)}),!e){let e="";switch(this.type){case r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case r.FUNCTION_CALL_BLOCK_TYPE:e=i.Msg[s.MsgKey.FUNCTIONS_CALL_TITLE];break;case r.FUNCTION_DEFINITION_BLOCK_TYPE:case r.FUNCTION_DECLARATION_BLOCK_TYPE:e=i.Msg[s.MsgKey.FUNCTIONS_DEFNORETURN_TITLE]}this.appendDummyInput("function_title").appendField(e,"function_title")}t?this.updateFunctionLabel_(this.getName()):this.addFunctionLabel_(this.getName()),this.updateArgumentInputs_()},updateArgumentInputs_(){var e;for(const e of this.inputList)if(e.type===i.inputs.inputTypes.VALUE&&!this.arguments_.some(t=>t.id===e.name)){if(this.type===r.FUNCTION_DEFINITION_BLOCK_TYPE){const t=e.connection.targetBlock();t&&t.dispose()}this.removeInput(e.name)}let t=this.inputList.findIndex(e=>e.type===i.inputs.inputTypes.VALUE);-1===t&&(t=this.inputList.length);for(const n of this.arguments_){let i=this.inputList.find(e=>e.name===n.id);const r=!i;r&&(i=this.appendValueInput(n.id)),this.inputList.indexOf(i)!==t&&this.moveInputBefore(i.name,null===(e=this.inputList[t+1])||void 0===e?void 0:e.name),(0,o.isCustomType)(n.type)?i.setCheck(n.type):i.setCheck(n.type.charAt(0).toUpperCase()+n.type.slice(1)),!this.isInsertionMarker()&&r&&this.populateArgument_(n,void 0,i),t++}this.inputList.some(e=>"function_collapse"===e.name)&&this.moveInputBefore("function_collapse",null),this.hasStatements_&&this.moveInputBefore("STACK",null)},updateDisplay_:function(){let e=this.rendered;this.createAllInputs_(),e&&!this.isInsertionMarker()&&this instanceof i.BlockSvg&&(this.initSvg(),this.queueRender())},setStatements_:function(e){this.hasStatements_!==e&&(e?this.appendStatementInput("STACK"):this.removeInput("STACK",!0),this.hasStatements_=e)},ensureIds_:function(){switch(this.type){case r.FUNCTION_DEFINITION_BLOCK_TYPE:this.functionId_&&"null"!=this.functionId_||(this.functionId_=i.utils.idGenerator.genUid());for(let e=0;e<this.arguments_.length;++e)this.arguments_[e].id||(this.arguments_[e].id=i.utils.idGenerator.genUid());break;case r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case r.FUNCTION_CALL_BLOCK_TYPE:const e=(0,o.getDefinition)(this.name_,this.workspace);if(e){this.functionId_=e.getFunctionId();const t=e.getArguments();for(let e=0;e<this.arguments_.length;++e)for(let n=0;n<t.length;++n)if(t[n].name==this.arguments_[e].name){this.arguments_[e].id=t[n].id;break}}}}}},{"./constants":121,"./msg":128,"./utils":130,blockly:192}],121:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE=n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE=n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE=n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE=n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE=n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE=n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE=n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE=n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE=n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE=n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE=n.FUNCTION_CALL_BLOCK_TYPE=n.FUNCTION_DECLARATION_BLOCK_TYPE=n.FUNCTION_DEFINITION_BLOCK_TYPE=void 0,n.FUNCTION_DEFINITION_BLOCK_TYPE="function_definition",n.FUNCTION_DECLARATION_BLOCK_TYPE="function_declaration",n.FUNCTION_CALL_BLOCK_TYPE="function_call",n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE="function_call_output",n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE="argument_reporter_boolean",n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE="argument_reporter_number",n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE="argument_reporter_string",n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE="argument_reporter_array",n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE="argument_reporter_custom",n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE="argument_editor_boolean",n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE="argument_editor_number",n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE="argument_editor_string",n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE="argument_editor_array",n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE="argument_editor_custom"},{}],122:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("./utils"),o=e("./msg"),s=e("./svgs"),a=new i.zelos.ConstantProvider;const l={customContextMenu:function(e){var t,n;const s={enabled:!(null===(n=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===n?void 0:n.readOnly),text:i.Msg[o.MsgKey.FUNCTIONS_GO_TO_DEFINITION_OPTION],callback:()=>{const e=this.getField("function_name").getText(),t=(0,r.getDefinition)(e,this.workspace);t&&this.workspace instanceof i.WorkspaceSvg&&this.workspace.centerOnBlock(t.id,!0)}};e.push(s)}},c={customContextMenu:function(e){if(this.isCollapsed())return;const t={text:i.Msg.RENAME_VARIABLE,enabled:!this.workspace.options.readOnly,callback:()=>{const e=this.workspace,t=this.getField("VAR").getVariable();i.Variables.renameVariable(e,t)}};if(e.unshift(t),!this.isInFlyout){const t=this.workspace.getVariableMap().getVariablesOfType("");for(const n of t){const t={enabled:!this.workspace.options.readOnly,text:n.getName(),callback:()=>{let e=this.getField("VAR");e||pxt.log("Tried to get a variable field on the wrong type of block."),e.setValue(n.getId())}};e.unshift(t)}}}};i.Extensions.registerMixin("function_contextmenu_edit",l),i.Extensions.registerMixin("contextMenu_variableReporter",c),i.Extensions.register("output_number",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Number")}),i.Extensions.register("output_string",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"String")}),i.Extensions.register("output_boolean",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.HEXAGONAL),this.setOutput(!0,"Boolean")}),i.Extensions.register("output_array",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Array")}),i.Extensions.register("text_field_color",function(){if(this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer().getConstants();this.setColour(e.FIELD_BORDER_RECT_COLOUR)}else this.setColour("#fff")}),i.Extensions.register("inline-svgs",function(){this.ADD_IMAGE_DATAURI=s.ADD_IMAGE_DATAURI,this.REMOVE_IMAGE_DATAURI=s.REMOVE_IMAGE_DATAURI})},{"./msg":128,"./svgs":129,"./utils":130,blockly:192}],123:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldArgumentEditor=void 0;const i=e("blockly"),r=e("../functionManager"),o=e("../../../external"),s=e("../msg");class a extends i.FieldTextInput{constructor(e,t,n){super(e,t,n)}showEditor(e){var t,n;super.showEditor(e);const o=i.WidgetDiv.getDiv();o.className+=" argumentEditorInput";const s=document.createElement("img");s.setAttribute("class","argumentEditorRemoveIcon"),s.setAttribute("src",a.REMOVE_ARG_URI),this.removeButtonMouseWrapper_=i.browserEvents.conditionalBind(s,"mousedown",this,this.removeCallback),o.appendChild(s);const l=null===(t=this.sourceBlock_)||void 0===t?void 0:t.getTypeName();if(l&&(null===(n=this.sourceBlock_)||void 0===n?void 0:n.workspace)){const e=r.FunctionManager.getInstance().getIconForType(l);if(e){const t=e+" icon argumentEditorTypeIcon",n=document.createElement("i");n.className=t,o.appendChild(n)}}}showEditor_(e,t=!1,n=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(i.utils.userAgent.MOBILE||i.utils.userAgent.ANDROID||i.utils.userAgent.IPAD)?this.showPromptEditorModal():super.showEditor_(e,t,n)}showPromptEditorModal(){(0,o.prompt)(i.Msg.CHANGE_VALUE_TITLE,this.getText(),e=>{null!==e&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)},{placeholder:void 0,buttons:[{label:i.Msg[s.MsgKey.FUNCTIONS_DELETE_PARAMETER_BUTTON],className:"red",icon:"trash",onclick:()=>{this.removeCallback()}}]})}removeCallback(){var e,t;const n=null===(e=this.sourceBlock_)||void 0===e?void 0:e.getParent();if(!n)return;let r;for(const e of n.inputList){if((null===(t=e.connection)||void 0===t?void 0:t.targetBlock())===this.sourceBlock_){r=e.name;break}}r&&(i.WidgetDiv.hide(),n.removeInput(r))}}n.FieldArgumentEditor=a,a.REMOVE_ARG_URI="data:image/svg+xml;charset=UTF-8,%3c?xml version='1.0' encoding='UTF-8' standalone='no'?%3e%3csvg width='20px' height='20px' viewBox='0 0 20 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch --%3e%3ctitle%3edelete-argument v2%3c/title%3e%3cdesc%3eCreated with Sketch.%3c/desc%3e%3cdefs%3e%3c/defs%3e%3cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3e%3cg id='delete-argument-v2' stroke='%23FF661A'%3e%3cg id='Group' transform='translate(3.000000, 2.500000)'%3e%3cpath d='M1,3 L13,3 L11.8900496,14.0995037 C11.8389294,14.6107055 11.4087639,15 10.8950124,15 L3.10498756,15 C2.59123611,15 2.16107055,14.6107055 2.10995037,14.0995037 L1,3 Z' id='Rectangle' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M7,11 L7,6' id='Line' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M9.5,11 L9.5,6' id='Line-Copy' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M4.5,11 L4.5,6' id='Line-Copy-2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3crect id='Rectangle-2' fill='%23FF661A' x='0' y='2.5' width='14' height='1' rx='0.5'%3e%3c/rect%3e%3cpath d='M6,0 L8,0 C8.55228475,-1.01453063e-16 9,0.44771525 9,1 L9,3 L5,3 L5,1 C5,0.44771525 5.44771525,1.01453063e-16 6,0 Z' id='Rectangle-3' stroke-width='1.5'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",i.fieldRegistry.register("field_argument_editor",a),i.Css.register("\n\n.argumentEditorInput {\n overflow: visible;\n}\n\n.functioneditor i.argumentEditorTypeIcon {\n color: var(--pxt-target-foreground1);\n position: absolute;\n width: 24px;\n height: 24px;\n top: 40px;\n left: 50%;\n margin-left: -12px;\n}\n\n.argumentEditorRemoveIcon {\n position: absolute;\n width: 24px;\n height: 24px;\n top: -40px;\n left: 50%;\n margin-left: -12px;\n cursor: pointer;\n}\n\n")},{"../../../external":25,"../functionManager":126,"../msg":128,blockly:192}],124:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.setArgumentReporterLocalizeFunction=n.FieldArgumentReporter=void 0;const i=e("blockly"),r=e("../utils");let o;class s extends i.FieldLabelSerializable{getDisplayText_(){const e=this.getSourceBlock();if(e&&(0,r.isFunctionArgumentReporter)(e)&&o){const t=o(this,e);if(t)return t}return super.getDisplayText_()}}n.FieldArgumentReporter=s,n.setArgumentReporterLocalizeFunction=function(e){o=e},i.registry.register(i.registry.Type.FIELD,"field_argument_reporter",s)},{"../utils":130,blockly:192}],125:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldAutocapitalizeTextInput=void 0;const i=e("blockly");class r extends i.FieldTextInput{constructor(e,t,n){super(e,t,n),this.disableAutocapitalize=!1}setAutocapitalize(e){this.disableAutocapitalize=!e,this.htmlInput_&&(this.disableAutocapitalize?this.htmlInput_.setAttribute("autocapitalize","none"):this.htmlInput_.removeAttribute("autocapitalize"))}configure_(e){super.configure_(e),void 0!==e.disableAutocapitalize&&(this.disableAutocapitalize=e.disableAutocapitalize)}widgetCreate_(){const e=super.widgetCreate_();return this.disableAutocapitalize&&e.setAttribute("autocapitalize","none"),e}}n.FieldAutocapitalizeTextInput=r,i.fieldRegistry.register("field_autocapitalize_text_input",r)},{blockly:192}],126:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FunctionManager=void 0;const i=e("blockly"),r=e("./msg");class o{constructor(){this.typeIcons={},this.typeArgumentNames={}}static getInstance(){return o.instance}getIconForType(e){return this.typeIcons[e]}setIconForType(e,t){this.typeIcons[e]=t}setArgumentNameForType(e,t){this.typeArgumentNames[e]=t}getArgumentNameForType(e){return this.typeArgumentNames[e]?this.typeArgumentNames[e]:i.Msg[r.MsgKey.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME]}setEditFunctionExternal(e){this._editFunctionExternal=e}editFunctionExternal(e,t){this._editFunctionExternal?this._editFunctionExternal(e,t):pxt.warn("External function editor must be overriden: Blockly.Functions.editFunctionExternalHandler",e,t)}}n.FunctionManager=o,o.instance=new o},{"./msg":128,blockly:192}],127:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.validateFunctionExternal=n.getAllFunctionDefinitionBlocks=n.getDefinition=n.flyoutCategory=void 0,r(e("./msg"),n),r(e("./extensions"),n),r(e("./fields/fieldArgumentEditor"),n),r(e("./fields/fieldArgumentReporter"),n),r(e("./fields/fieldAutocapitalizeTextInput"),n),r(e("./blocks/argumentEditorBlocks"),n),r(e("./blocks/argumentReporterBlocks"),n),r(e("./blocks/functionDeclarationBlock"),n),r(e("./blocks/functionDefinitionBlock"),n),r(e("./blocks/functionCallBlocks"),n),r(e("./functionManager"),n);var o=e("./utils");Object.defineProperty(n,"flyoutCategory",{enumerable:!0,get:function(){return o.flyoutCategory}}),Object.defineProperty(n,"getDefinition",{enumerable:!0,get:function(){return o.getDefinition}}),Object.defineProperty(n,"getAllFunctionDefinitionBlocks",{enumerable:!0,get:function(){return o.getAllFunctionDefinitionBlocks}}),Object.defineProperty(n,"validateFunctionExternal",{enumerable:!0,get:function(){return o.validateFunctionExternal}})},{"./blocks/argumentEditorBlocks":115,"./blocks/argumentReporterBlocks":116,"./blocks/functionCallBlocks":117,"./blocks/functionDeclarationBlock":118,"./blocks/functionDefinitionBlock":119,"./extensions":122,"./fields/fieldArgumentEditor":123,"./fields/fieldArgumentReporter":124,"./fields/fieldAutocapitalizeTextInput":125,"./functionManager":126,"./msg":128,"./utils":130}],128:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MsgKey=void 0;const i=e("blockly");var r;function o(e,t){i.Msg[e]||(i.Msg[e]=t)}!function(e){e.REPORTERS_HUE="REPORTERS_HUE",e.FUNCTIONS_CALL_TITLE="FUNCTIONS_CALL_TITLE",e.FUNCTIONS_DEFNORETURN_TITLE="FUNCTIONS_DEFNORETURN_TITLE",e.FUNCTIONS_GO_TO_DEFINITION_OPTION="FUNCTIONS_GO_TO_DEFINITION_OPTION",e.FUNCTION_CALL_TOOLTIP="FUNCTION_CALL_TOOLTIP",e.PROCEDURES_HUE="PROCEDURES_HUE",e.PROCEDURES_CALLNORETURN_HELPURL="PROCEDURES_CALLNORETURN_HELPURL",e.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME="FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME",e.FUNCTIONS_DEFAULT_STRING_ARG_NAME="FUNCTIONS_DEFAULT_STRING_ARG_NAME",e.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME="FUNCTIONS_DEFAULT_NUMBER_ARG_NAME",e.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME="FUNCTIONS_DEFAULT_ARRAY_ARG_NAME",e.PROCEDURES_DEFNORETURN_TOOLTIP="PROCEDURES_DEFNORETURN_TOOLTIP",e.PROCEDURES_DEFNORETURN_HELPURL="PROCEDURES_DEFNORETURN_HELPURL",e.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME="FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME",e.FUNCTIONS_DEFAULT_FUNCTION_NAME="FUNCTIONS_DEFAULT_FUNCTION_NAME",e.FUNCTION_CREATE_NEW="FUNCTION_CREATE_NEW",e.FUNCTION_FLYOUT_LABEL="FUNCTION_FLYOUT_LABEL",e.FUNCTIONS_EDIT_OPTION="FUNCTIONS_EDIT_OPTION",e.FUNCTIONS_CREATE_CALL_OPTION="FUNCTIONS_CREATE_CALL_OPTION",e.FUNCTIONS_DELETE_PARAMETER_BUTTON="FUNCTIONS_DELETE_PARAMETER_BUTTON"}(r=n.MsgKey||(n.MsgKey={})),o(r.REPORTERS_HUE,"#A80000"),o(r.FUNCTIONS_CALL_TITLE,"call"),o(r.FUNCTIONS_DEFNORETURN_TITLE,"function"),o(r.FUNCTIONS_GO_TO_DEFINITION_OPTION,"Go to Definition"),o(r.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME,"bool"),o(r.FUNCTIONS_DEFAULT_STRING_ARG_NAME,"text"),o(r.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME,"num"),o(r.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME,"array"),o(r.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME,"value"),o(r.FUNCTIONS_DEFAULT_FUNCTION_NAME,"doSomething"),o(r.FUNCTION_CREATE_NEW,"Make a Function"),o(r.FUNCTION_FLYOUT_LABEL,"Your Functions"),o(r.FUNCTIONS_EDIT_OPTION,"Edit Function"),o(r.FUNCTIONS_CREATE_CALL_OPTION,"Create 'call %1'"),o(r.FUNCTIONS_DELETE_PARAMETER_BUTTON,"Delete")},{blockly:192}],129:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.REMOVE_IMAGE_DATAURI=n.ADD_IMAGE_DATAURI=n.COLLAPSE_IMAGE_DATAURI=void 0,n.COLLAPSE_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.354)'%3E%3Cpath d='m1611 367.42q0 53-37 90l-651 651q-38 38-91 38-54 0-90-38l-651-651q-38-36-38-90 0-53 38-91l74-75q39-37 91-37 53 0 90 37l486 486 486-486q37-37 90-37 52 0 91 37l75 75q37 39 37 91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A",n.ADD_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJhZGQuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjQ4MjEiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NjkiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjEyLjkxNTI1NCIKICAgICBpbmtzY2FwZTpjeT0iMTYuMDY3Nzk2IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0icmVwZWF0IiAvPjxzdHlsZQogICAgIHR5cGU9InRleHQvY3NzIgogICAgIGlkPSJzdHlsZTMiPgoJLnN0MHtmaWxsOiNDRjhCMTc7fQoJLnN0MXtmaWxsOiNGRkZGRkY7fQo8L3N0eWxlPjx0aXRsZQogICAgIGlkPSJ0aXRsZTUiPnJlcGVhdDwvdGl0bGU+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMiCiAgICAgd2lkdGg9IjQuMDUwMDAwMiIKICAgICBoZWlnaHQ9IjEyLjM5NzA1IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSItMTguMTk4NTI2IgogICAgIHJ4PSIwLjgxIgogICAgIHJ5PSIwLjgxIgogICAgIHRyYW5zZm9ybT0ic2NhbGUoMSwtMSkiIC8+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMtMSIKICAgICB3aWR0aD0iNC4wNTAwMDAyIgogICAgIGhlaWdodD0iMTIuMzk3MTE5IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSI1LjgwMTQ0MDciCiAgICAgcng9IjAuODEiCiAgICAgcnk9IjAuODEiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMCwxLDEsMCwwLDApIiAvPjxjaXJjbGUKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6I2ZmZmZmZjtzdHJva2Utd2lkdGg6MjtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MSIKICAgICBpZD0icGF0aDQxMzYiCiAgICAgY3g9IjEyIgogICAgIGN5PSIxMiIKICAgICByPSIxMC41MDMxOTEiIC8+PC9zdmc+",n.REMOVE_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJyZW1vdmUuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjFhZmYiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NTAiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjAuMDUwODQ3NTIxIgogICAgIGlua3NjYXBlOmN5PSI5Ljk2NjEwMTciCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJyZXBlYXQiIC8+PHN0eWxlCiAgICAgdHlwZT0idGV4dC9jc3MiCiAgICAgaWQ9InN0eWxlMyI+Cgkuc3Qwe2ZpbGw6I0NGOEIxNzt9Cgkuc3Qxe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU+PHRpdGxlCiAgICAgaWQ9InRpdGxlNSI+cmVwZWF0PC90aXRsZT48cmVjdAogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eTowLjA3ODQzMTM3IgogICAgIGlkPSJyZWN0NDE0My0xIgogICAgIHdpZHRoPSI0LjA1MDAwMDIiCiAgICAgaGVpZ2h0PSIxMi4zOTcxMTkiCiAgICAgeD0iOS45NzUwMDA0IgogICAgIHk9IjUuODAxNDQwNyIKICAgICByeD0iMC44MSIKICAgICByeT0iMC44MSIKICAgICB0cmFuc2Zvcm09Im1hdHJpeCgwLDEsMSwwLDAsMCkiIC8+PGNpcmNsZQogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojZmZmZmZmO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eToxIgogICAgIGlkPSJwYXRoNDEzNiIKICAgICBjeD0iMTIiCiAgICAgY3k9IjEyIgogICAgIHI9IjEwLjUwMzE5MSIgLz48L3N2Zz4="},{}],130:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isVariableBlockType=n.validateFunctionExternal=n.flyoutCategory=n.getShadowBlockInfoFromType_=n.findUniqueParamName=n.getArgumentReporterParent=n.doArgumentReporterDragChecks=n.isFunctionArgumentReporter=n.getArgMap=n.mutateCallersAndDefinition=n.idsInUse=n.findLegalName=n.createCustomArgumentEditor=n.createCustomArgumentReporter=n.isCustomType=n.getAllFunctionDefinitionBlocks=n.getDefinition=n.rename=void 0;const i=e("blockly"),r=e("./constants"),o=e("./functionManager"),s=e("./msg"),a=e("./blocks/functionDeclarationBlock"),l=e("../../compiler/util"),c=e("../../loader");function u(e,t){for(const n of t.getTopBlocks(!1))if(n.type===r.FUNCTION_DEFINITION_BLOCK_TYPE){const t=n;if(t.getName()===e)return t}return null}function d(e){return e.getTopBlocks(!1).filter(e=>e.type===r.FUNCTION_DEFINITION_BLOCK_TYPE)}function p(e,t,n){const r=n.newBlock(e),o=i.utils.xml.createElement("mutation");return o.setAttribute("typename",t),r.domToMutation(o),r}function h(e,t,n){if(null==n?void 0:n.isInFlyout)return e;const i=f(t,n);for(;i[e];)e=g(e);return e}function f(e,t,n){const i={};return e.getVariableMap().getAllVariables().forEach(function(e){i[e.getName()]=!0}),e.getAllBlocks(!1).forEach(function(e){const o=e;o==t||n&&o.getFunctionId&&o.getFunctionId()==n||(o.type==r.FUNCTION_DEFINITION_BLOCK_TYPE?i[o.getName()]=!0:"procedures_defreturn"==e.type||e.type)}),i}function g(e){const t=e.match(/^(.*?)(\d+)$/);return t?e=t[1]+(parseInt(t[2],10)+1):e+="2",e}function m(e,t,n){const o=u(e,t);if(o){const s=o.mutationToDom(),a=_(s,!1),l=_(n,!0),c=[];for(const e of o.getDescendants(!1)){if(!y(e))continue;const t=b(e,e);if(t&&t!==o)continue;const n=e.getFieldValue("VALUE"),i=l[a[n]];if(n===i)continue;const r=e.outputConnection.targetBlock().id,s=e.outputConnection.targetConnection.getParentInput().name;c.push({id:e.id,type:e.type,oldName:n,newName:i,targetBlockId:r,targetInputName:s})}const u=function(e,t){const n=[];for(const i of t.getAllBlocks(!1))if(i.type===r.FUNCTION_CALL_BLOCK_TYPE||i.type===r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const t=i;t.getName()===e&&n.push(t)}return n}(e,o.workspace).map(e=>({id:e.id,oldMutation:i.utils.xml.domToText(e.mutationToDom()),shadows:e.serializeChangedInputs(n)})),d=new T(o.id,u,i.Xml.domToText(s),i.Xml.domToText(n),c);d.workspaceId=t.id,d.run(!0),i.Events.fire(d)}else pxt.warn("Attempted to change function "+e+", but no definition block was found on the workspace")}function _(e,t){const n={};for(let i=0;i<e.childNodes.length;++i){const r=e.childNodes[i],o=t?r.getAttribute("id"):r.getAttribute("name"),s=t?r.getAttribute("name"):r.getAttribute("id");n[o]=s}return n}function y(e){return e.type==r.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_STRING_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}function b(e,t){pxt.U.assert(y(e));const n=e.getFieldValue("VALUE"),i=e.getTypeName();for(;t.getSurroundParent();){t=t.getSurroundParent();for(const e of t.inputList){if(!e.connection||!e.name.startsWith(c.DRAGGABLE_PARAM_INPUT_PREFIX))continue;if(e.name.slice(c.DRAGGABLE_PARAM_INPUT_PREFIX.length)!==n)continue;let r=i;return"string"!==r&&"number"!==r&&"boolean"!==r||(r=r.charAt(0).toUpperCase()+r.slice(1)),-1!==e.connection.getCheck().indexOf(r)?t:void 0}}if(!t.isEnabled())return t;if((0,l.isFunctionDefinition)(t)){if(t.getArguments().some(e=>e.name===n&&e.type===i))return t}}function v(e,t){return!t||-1==t.indexOf(e)}n.rename=function(e){e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");const t=this.sourceBlock_,n=h(e,t.workspace,t),i=this.getValue();if(!e)return i;if(!n)return e;if(!i)return t.name_=n,n;if(i!=e&&i!=n){t.name_=n;const e=t.mutationToDom();t.name_=i,m(i,t.workspace,e)}return n},n.getDefinition=u,n.getAllFunctionDefinitionBlocks=d,n.isCustomType=function(e){return!("boolean"==e||"string"==e||"number"==e)},n.createCustomArgumentReporter=function(e,t){return p(r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE,e,t)},n.createCustomArgumentEditor=function(e,t){return p(r.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE,e,t)},n.findLegalName=h,n.idsInUse=function(e){const t=[];return e.getAllBlocks(!1).forEach(function(e){e.type==r.FUNCTION_DEFINITION_BLOCK_TYPE&&t.push(e.getFunctionId())}),t},n.mutateCallersAndDefinition=m,n.getArgMap=_,n.isFunctionArgumentReporter=y,n.doArgumentReporterDragChecks=function(e,t,n){const i=e.getSourceBlock();if(!y(i))return!0;const r=t.getSourceBlock();return!r||!!b(i,r)},n.getArgumentReporterParent=b,n.findUniqueParamName=function(e,t){for(;!v(e,t);)e=g(e);return e},n.getShadowBlockInfoFromType_=function(e,t){let n="",r="",s="";switch(e){case"boolean":n="logic_boolean",r="BOOL",s="TRUE";break;case"number":n="math_number",r="NUM",s="1";break;case"string":n="text",r="TEXT",s="abc";break;case"Array":n="variables_get",r="VAR",s=i.Variables.getOrCreateVariablePackage(t,null,"list","").getId();break;default:n="variables_get",r="VAR",s=i.Variables.getOrCreateVariablePackage(t,null,o.FunctionManager.getInstance().getArgumentNameForType(e),"").getId()}return[n,r,s]},n.flyoutCategory=function(e){const t=[],n=document.createElement("button"),l=i.Msg[s.MsgKey.FUNCTION_CREATE_NEW],c="CREATE_FUNCTION";n.setAttribute("text",l),n.setAttribute("callbackKey",c),e.registerButtonCallback(c,()=>{!function(e){i.hideChaff(),i.getSelected()&&i.getSelected().unselect();o.FunctionManager.getInstance().editFunctionExternal((0,a.newFunctionMutation)(e),function(e){return function(t){if(t){const n='<xml><block type="'+r.FUNCTION_DEFINITION_BLOCK_TYPE+'">'+i.Xml.domToText(t)+"</block></xml>",o=i.utils.xml.textToDom(n);i.Events.setGroup(!0);const s=i.Xml.domToBlock(o.firstChild,e);if(s.updateDisplay_(),e.getMetrics){const t=e.getMetrics(),n=s.getHeightWidth();s.moveBy(t.viewLeft+t.viewWidth/2-n.width/2,t.viewTop+t.viewHeight/2-n.height/2),s.scheduleSnapAndBump()}e.centerOnBlock(s.id,!0),i.Events.setGroup(!1),setTimeout(()=>{s.afterWorkspaceLoad&&s.afterWorkspaceLoad(),i.getFocusManager().focusNode(s)})}}}(e))}(e)}),t.push(n);for(const n of d(e)){const e=n.getName(),r=n.getArguments(),o=i.utils.xml.createElement("block");o.setAttribute("type","function_call"),o.setAttribute("gap","16");const s=i.utils.xml.createElement("mutation");s.setAttribute("name",e),o.appendChild(s);for(let e=0;e<r.length;e++){const t=i.utils.xml.createElement("arg");t.setAttribute("name",r[e].name),t.setAttribute("type",r[e].type),t.setAttribute("id",r[e].id),s.appendChild(t)}t.push(o)}return t},n.validateFunctionExternal=function(e,t){const n=e.getAttribute("name");if(!n)return i.dialog.alert(i.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;const r={};for(let t=0;t<e.childNodes.length;++t){const n=e.childNodes[t].getAttribute("name");if(!n)return i.dialog.alert(i.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;if(r[n])return i.dialog.alert(i.Msg.FUNCTION_WARNING_DUPLICATE_ARG),!1;r[n]=!0}return r[n]?(i.dialog.alert(i.Msg.FUNCTION_WARNING_ARG_NAME_IS_FUNCTION_NAME),!1):!f(t,null,e.getAttribute("functionid"))[n]||(i.dialog.alert(i.Msg.VARIABLE_ALREADY_EXISTS.replace("%1",n)),!1)},n.isVariableBlockType=function(e){switch(e){case"argument_reporter_boolean":case"argument_reporter_number":case"argument_reporter_string":case"argument_reporter_array":case"argument_reporter_custom":case"variables_get_reporter":case"variables_get":return!0}return!1};class T extends i.Events.Abstract{constructor(e,t,n,i,r){super(),this.definition=e,this.callers=t,this.oldMutation=n,this.newMutation=i,this.descendantChanges=r,this.type="pxt_mutate_function"}static fromJson(e,t,n){const i=n=super.fromJson(e,t,n||new T(e.definition,e.callers,e.oldMutation,e.newMutation,e.descendantChanges));return i.definition=e.definition,i.callers=e.callers,i.oldMutation=e.oldMutation,i.newMutation=e.newMutation,i.descendantChanges=e.descendantChanges,n}toJson(){return{type:this.type,group:this.group,definition:this.definition,callers:this.callers,oldMutation:this.oldMutation,newMutation:this.newMutation,descendantChanges:this.descendantChanges}}run(e){const t=this.getEventWorkspace_(),n=i.utils.xml.textToDom(e?this.newMutation:this.oldMutation),r=t.getBlockById(this.definition);i.Events.disable(),r.domToMutation(n),r.updateArgumentInputs_(),r.afterWorkspaceLoad();for(const r of this.callers){const o=t.getBlockById(r.id);if(e)o.domToMutation(n);else{o.domToMutation(i.utils.xml.textToDom(r.oldMutation));for(const e of r.shadows)if(e.connectedBlock){const n=t.getBlockById(e.connectedBlock);o.getInput(e.inputName).connection.connect(n.outputConnection)}else o.getInput(e.inputName).connection.setShadowState(e.connectedShadow)}}for(const n of this.descendantChanges)if(n.newName){t.getBlockById(n.id).setFieldValue(e?n.newName:n.oldName,"VALUE")}else if(e){const e=t.getBlockById(n.id);e&&e.dispose()}else{const e=t.newBlock(n.type,n.id);e.setFieldValue(n.oldName,"VALUE"),e.initSvg();const i=t.getBlockById(n.targetBlockId).getInput(n.targetInputName).connection,r=i.targetBlock();r&&(r.isShadow()||r.dispose()),i.connect(e.outputConnection)}i.Events.enable()}}},{"../../compiler/util":15,"../../loader":79,"./blocks/functionDeclarationBlock":118,"./constants":121,"./functionManager":126,"./msg":128,blockly:192}],131:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly");i.Extensions.unregister("logic_compare"),i.Extensions.register("logic_compare",function(){})},{blockly:192}],132:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../../fields/field_imagenotext"),o=e("../../utils"),s={elseifCount_:0,elseCount_:0,valueConnections_:[],statementConnections_:[],elseStatementConnection_:null,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const e=i.utils.xml.createElement("mutation");return this.elseifCount_&&e.setAttribute("elseif",this.elseifCount_+""),this.elseCount_&&e.setAttribute("else","1"),e},domToMutation:function(e){e&&(this.elseifCount_=parseInt(e.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(e.getAttribute("else"),10)||0,this.rebuildShape_())},storeConnections_:function(e){e||(e=0),this.valueConnections_=[null],this.statementConnections_=[null],this.elseStatementConnection_=null;for(let t=1;t<=this.elseifCount_;t++)e!=t&&(this.valueConnections_.push(this.getInput("IF"+t).connection.targetConnection),this.statementConnections_.push(this.getInput("DO"+t).connection.targetConnection));this.getInput("ELSE")&&(this.elseStatementConnection_=this.getInput("ELSE").connection.targetConnection)},restoreConnections_:function(){var e,t;for(let t=1;t<=this.elseifCount_;t++)this.reconnectValueConnection_(t,this.valueConnections_),null===(e=this.statementConnections_[t])||void 0===e||e.reconnect(this,"DO"+t);this.getInput("ELSE")&&(null===(t=this.elseStatementConnection_)||void 0===t||t.reconnect(this,"ELSE"))},addElse_:function(){i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch added."));this.update_(()=>{this.elseCount_++})},removeElse_:function(){var e,t;i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch removed."));this.update_(()=>{this.elseCount_--});const n="IF"+this.elseifCount_;(0,o.maybeMoveFocusFromButton)(null===(t=null===(e=this.getInput(n))||void 0===e?void 0:e.connection)||void 0===t?void 0:t.targetBlock())},addElseIf_:function(){i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch added."));this.update_(()=>{this.elseifCount_++})},removeElseIf_:function(e){var t,n;i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch removed."));this.update_(()=>{this.elseifCount_--},e);const r="IF"+(e-1);(0,o.maybeMoveFocusFromButton)(null===(n=null===(t=this.getInput(r))||void 0===t?void 0:t.connection)||void 0===n?void 0:n.targetBlock())},update_:function(e,t){i.Events.setGroup(!0),this.storeConnections_(t);const n=this,r=n.mutationToDom(),o=r&&i.Xml.domToText(r);e&&e.call(this),this.updateShape_(),n instanceof i.BlockSvg&&n.initSvg();const s=i.Events.getGroup(),a=n.mutationToDom(),l=a&&i.Xml.domToText(a);o!=l&&(i.Events.fire(new i.Events.BlockChange(n,"mutation",null,o,l)),setTimeout(function(){i.Events.setGroup(s),n.bumpNeighbours(),i.Events.setGroup(!1)},i.config.bumpDelay)),n.rendered&&n instanceof i.BlockSvg&&n.queueRender(),this.restoreConnections_(),i.Events.setGroup(!1)},updateShape_:function(){this.getInput("ELSE")&&(this.removeInput("ELSE"),this.removeInput("ELSETITLE"),this.removeInput("ELSEBUTTONS"));let e=1;for(;this.getInput("IF"+e);)this.removeInput("IF"+e),this.removeInput("IFTITLE"+e),this.removeInput("IFBUTTONS"+e),this.removeInput("DO"+e),e++;for(let e=1;e<=this.elseifCount_;e++){const n=function(e){return function(){t.removeElseIf_(e)}}(e);this.appendValueInput("IF"+e).setCheck("Boolean").appendField(i.Msg.CONTROLS_IF_MSG_ELSEIF).setShadowDom(a()),this.appendDummyInput("IFTITLE"+e).appendField(i.Msg.CONTROLS_IF_MSG_THEN),this.appendDummyInput("IFBUTTONS"+e).appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else if branch"),n,!1)).setAlign(i.inputs.Align.RIGHT),this.appendStatementInput("DO"+e)}this.elseCount_&&(this.appendDummyInput("ELSETITLE").appendField(i.Msg.CONTROLS_IF_MSG_ELSE),this.appendDummyInput("ELSEBUTTONS").setAlign(i.inputs.Align.RIGHT).appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else branch"),this.removeElse_.bind(this),!1)),this.appendStatementInput("ELSE")),this.getInput("ADDBUTTON")&&this.removeInput("ADDBUTTON");const t=this,n=function(){var e,n,r;if(0==t.elseCount_)t.addElse_(),(0,o.maybeMoveFocusFromButton)(null===(e=t.getInput("ELSEBUTTONS"))||void 0===e?void 0:e.fieldRow[0]);else{t.elseifCount_||(t.elseifCount_=0),t.addElseIf_();const e=i.getFocusManager(),o=null===(r=null===(n=t.getInput("IF"+t.elseifCount_))||void 0===n?void 0:n.connection)||void 0===r?void 0:r.targetBlock();e.focusNode(o)}};this.appendDummyInput("ADDBUTTON").appendField(new r.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,this.elseCount_?pxt.Util.lf("add else if branch"):pxt.Util.lf("add else branch"),n,!1))},rebuildShape_:function(){const e=[null],t=[null];let n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);let i=1;for(;this.getInput("IF"+i);){const n=this.getInput("IF"+i),r=this.getInput("DO"+i);e.push(n.connection.targetConnection),t.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},reconnectChildBlocks_:function(e,t,n){var i;for(let n=1;n<=this.elseifCount_;n++)this.reconnectValueConnection_(n,e),null===(i=t[n])||void 0===i||i.reconnect(this,"DO"+n);null==n||n.reconnect(this,"ELSE")},reconnectValueConnection_:function(e,t){var n;const i=null===(n=this.getInput("IF"+e))||void 0===n?void 0:n.connection.targetBlock();t[e]&&(t[e].reconnect(this,"IF"+e),i&&!i.getParent()&&i.dispose())}};function a(){const e=document.createElement("shadow");e.setAttribute("type","logic_boolean");const t=document.createElement("field");return t.setAttribute("name","BOOL"),t.textContent="FALSE",e.appendChild(t),e}i.Blocks.controls_if=Object.assign(Object.assign({},s),{init(){if(i.Extensions.apply("inline-svgs",this,!1),this.elseifCount_=0,this.elseCount_=0,this.setHelpUrl(i.Msg.CONTROLS_IF_HELPURL),this.appendValueInput("IF0").setCheck("Boolean").appendField(i.Msg.CONTROLS_IF_MSG_IF),this.appendDummyInput("THEN0").appendField(i.Msg.CONTROLS_IF_MSG_THEN),this.appendStatementInput("DO0"),this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer();this.setOutputShape(e.getConstants().SHAPES.HEXAGONAL)}this.updateShape_(),this.setInputsInline(!0),this.setColour(i.Msg.LOGIC_HUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(()=>this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_4:"":i.Msg.CONTROLS_IF_TOOLTIP_1)}})},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],133:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./extensions"),n),r(e("./ifElse"),n)},{"./extensions":131,"./ifElse":132}],134:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldSlider=void 0;const i=e("blockly");class r extends i.FieldNumber{constructor(e,t,n,i,r,o,s,a){super(e,t,n,i,s,a),this.keyboardControlActive=!1,"string"==typeof r?this.step_=parseFloat(r):"number"==typeof r&&(this.step_=r),this.labelText_=o}hasMin(){return this.getMin()>-1/0}hasMax(){return this.getMax()<1/0}getStep(){return this.step_}getLabel(){return this.labelText_}setLabel(e){this.labelText_=e}setOptions(e,t,n,i){this.setConstraints(e,t,i),this.step_=parseFloat(n)||void 0}getFieldDescription(){return this.getValue()+""}doClassValidation_(e){if(null===e)return null;e=(e=(e=(e=`${e}`).replace(/O/gi,"0")).replace(/,/g,"")).replace(/infinity/i,"Infinity");let t=Number(e||0);if(isNaN(t))return null;this.precision_&&isFinite(t)&&(t=Math.round(t/this.precision_)*this.precision_);let n=String(this.precision_);-1!==n.indexOf("e")&&(n=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const i=n.indexOf(".");let r;return r=-1===i?this.precision_?0:null:n.length-i-1,null!==r&&(t=Number(t.toFixed(r))),t}widgetDispose_(){this.removeEventListeners(),super.widgetDispose_()}addEventListeners(){this.inputKeydownHandler=this.inputKeydownListener.bind(this),this.htmlInput_.addEventListener("keydown",this.inputKeydownHandler),this.sliderKeydownHandler=this.sliderKeydownListener.bind(this),this.slider_.addEventListener("keydown",this.sliderKeydownHandler),this.sliderBlurHandler=this.sliderBlurListener.bind(this),this.slider_.addEventListener("blur",this.sliderBlurHandler),this.sliderPointerdownHandler=this.sliderPointerdownListener.bind(this),this.slider_.addEventListener("pointerdown",this.sliderPointerdownHandler)}removeEventListeners(){this.htmlInput_.removeEventListener("keydown",this.inputKeydownHandler),this.slider_.removeEventListener("keydown",this.sliderKeydownHandler),this.slider_.removeEventListener("blur",this.sliderBlurHandler),this.slider_.removeEventListener("pointerdown",this.sliderPointerdownHandler)}inputKeydownListener(e){"ArrowDown"===e.key&&(e.preventDefault(),this.keyboardControlActive=!0,this.slider_.focus())}sliderPointerdownListener(e){this.keyboardControlActive=!1}sliderKeydownListener(e){switch(e.key){case"ArrowUp":e.preventDefault(),this.htmlInput_.focus();break;case"Enter":case" ":e.preventDefault(),e.stopPropagation(),i.hideChaff();break;case"ArrowDown":e.preventDefault(),e.stopPropagation()}}sliderBlurListener(e){this.keyboardControlActive=!1}showEditor_(e,t){super.showEditor_(e,!0),"number"==typeof this.min_&&"number"==typeof this.max_&&(this.htmlInput_.ariaLabel=lf("Enter a value between {0} and {1}",this.min_,this.max_)),i.DropDownDiv.hideWithoutAnimation(),i.DropDownDiv.clearContent();const n=i.DropDownDiv.getContentDiv();n.style.height="",n.parentElement.classList.add("blocklyFieldSliderDropdown"),this.addSlider_(n),i.DropDownDiv.setColour("#ffffff","#dddddd"),i.DropDownDiv.showPositionedByBlock(this,this.sourceBlock_,void 0,void 0,!1),this.addEventListeners(),t||(this.htmlInput_.focus(),this.htmlInput_.select())}addSlider_(e){if(this.labelText_){let t=this.createLabelDom_(this.labelText_);e.appendChild(t[0]),this.readout_=t[1],this.setReadout(this.value_)}this.slider_=this.createSlider(),e.appendChild(this.slider_);const t=()=>{pxt.BrowserUtils.isFirefox()||this.keyboardControlActive||this.htmlInput_.focus()};i.browserEvents.bind(this.slider_,"input",this,e=>{const n=parseFloat(this.slider_.value)||0;if(null!==n){this.setValue(n);const e=this.htmlInput_;e&&(e.value=n+"",t())}}),i.browserEvents.bind(this.slider_,"focus",this,e=>{t()})}setValue(e,t){super.setValue(e,t),this.updateDom(),this.slider_&&(this.slider_.value=this.getValue()+"")}createSlider(){const e=document.createElement("input");let t;return e.setAttribute("class","blocklyFieldSlider"),e.type="range",e.min=this.getMin()+"",e.max=this.getMax()+"",e.value=this.getValue()+"",this.sourceBlock_ instanceof i.BlockSvg&&("#ffffff"===this.sourceBlock_.getColour()?this.sourceBlock_.getParent()&&(t=this.sourceBlock_.getParent().getColourTertiary()):t=this.sourceBlock_.getColourTertiary()),t&&e.setAttribute("style",`--blocklyFieldSliderBackgroundColor: ${t}`),Number.isNaN(this.step_)||(e.step=this.step_+""),e}updateDom(){this.setReadout(this.getValue())}setReadout(e){this.readout_&&(this.readout_.innerText=e+"")}createLabelDom_(e){const t=document.createElement("div");t.setAttribute("class","blocklyFieldSliderLabel");const n=document.createElement("span");n.setAttribute("class","blocklyFieldSliderReadout");const i=document.createElement("span");return i.setAttribute("class","blocklyFieldSliderLabelText"),i.innerText=e,t.appendChild(i),t.appendChild(n),[t,n]}}n.FieldSlider=r,i.fieldRegistry.register("field_slider",r),i.Css.register('\n:root {\n --blocklyFieldSliderBackgroundColor: #547AB2;\n --blocklyFieldSliderThumbColor: #ffffff;\n --blocklyFieldSliderThumbBorderColor: rgba(0, 0, 0, 0.15);\n}\n.blocklyFieldSliderLabel {\n font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;\n font-size: 0.65rem;\n color: #000000;\n margin: 8px;\n}\n.blocklyFieldSliderLabelText {\n font-weight: bold;\n}\n.blocklyFieldSliderReadout {\n margin-left: 10px;\n}\n\ninput[type=range].blocklyFieldSlider {\n -webkit-appearance: none;\n width: 100%;\n}\ninput[type=range].blocklyFieldSlider:focus {\n outline: none;\n}\ninput[type=range].blocklyFieldSlider::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n margin: 8px;\n height: 22px;\n width: 150px;\n outline: none;\n border-radius: 11px;\n margin-bottom: 20px;\n background: var(--blocklyFieldSliderBackgroundColor);\n}\ninput[type=range].blocklyFieldSlider::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 26px;\n height: 26px;\n margin-top: -1px;\n background-color: var(--blocklyFieldSliderThumbColor);\n border-radius: 100%;\n -webkit-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n -moz-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n cursor: pointer;\n}\ninput[type=range].blocklyFieldSlider:focus-visible::-webkit-slider-thumb {\n outline: 2px solid white;\n outline-offset: 3px;\n -webkit-box-shadow: 0 0 0 3px var(--pxt-focus-border);\n -moz-box-shadow: 0 0 0 3px var(--pxt-focus-border);\n box-shadow: 0 0 0 3px var(--pxt-focus-border);\n}\ninput[type=range].blocklyFieldSlider::-moz-range-track {\n margin: 8px;\n height: 22px;\n width: 95%;\n outline: none;\n border-radius: 11px;\n margin-bottom: 20px;\n background: var(--blocklyFieldSliderBackgroundColor);\n}\ninput[type=range].blocklyFieldSlider::-moz-range-thumb {\n width: 26px;\n height: 26px;\n margin-top: -1px;\n background-color: var(--blocklyFieldSliderThumbColor);\n border-radius: 100%;\n -webkit-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n -moz-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n cursor: pointer;\n}\n')},{blockly:192}],135:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldSlider"),n),r(e("./numberBlocks"),n)},{"./fieldSlider":134,"./numberBlocks":136}],136:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=new i.zelos.ConstantProvider;i.defineBlocksWithJsonArray([{type:"math_integer",message0:"%1",args0:[{type:"field_number",name:"NUM",precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_whole_number",message0:"%1",args0:[{type:"field_number",name:"NUM",min:0,precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_positive_number",message0:"%1",args0:[{type:"field_number",name:"NUM",min:0,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_number_minmax",message0:"%1",args0:[{type:"field_slider",name:"SLIDER",value:0,step:1,labelText:"Number"}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",mutator:"math_number_minmax_mutator",extensions:["parent_tooltip_when_inline"]}]);const o={mutationToDom:function(){const e=this.inputList[0].fieldRow[0];let t=i.utils.xml.createElement("mutation");return e.hasMin()&&t.setAttribute("min",e.getMin()+""),e.hasMax()&&t.setAttribute("max",e.getMax()+""),null!=e.getLabel()&&t.setAttribute("label",e.getLabel()),null!=e.getStep()&&t.setAttribute("step",e.getStep()+""),null!=e.getPrecision()&&t.setAttribute("precision",e.getPrecision()+""),t},domToMutation:function(e){const t=this.inputList[0].fieldRow[0],n=e.getAttribute("min"),i=e.getAttribute("max"),r=e.getAttribute("step"),o=e.getAttribute("label"),s=e.getAttribute("precision");t.setLabel(o),t.setOptions(n,i,r,s)}};i.Extensions.registerMutator("math_number_minmax_mutator",o)},{blockly:192}],137:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldVariable=void 0;const i=e("blockly");class r extends i.FieldVariable{constructor(e,t,n,i,o){super(e,t,n,i,o),this.svgRootBinding=null,this.fieldRootBinding=null,this.menuGenerator_=r.dropdownCreate}static dropdownCreate(){const e=i.FieldVariable.dropdownCreate.call(this),t=e.findIndex(e=>"RENAME_VARIABLE_ID"===e[1]);return e.splice(t,0,[i.Msg.NEW_VARIABLE_DROPDOWN,r.CREATE_VARIABLE_ID],i.FieldDropdown.SEPARATOR),e}onItemSelected_(e,t){if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(t.getValue()===r.CREATE_VARIABLE_ID)return void i.Variables.createVariableButtonHandler(this.sourceBlock_.workspace,e=>{const t=this.sourceBlock_.workspace.getVariableMap().getVariable(e);t&&this.setValue(t.getId())})}super.onItemSelected_(e,t)}initView(){super.initView(),this.shouldAddBorderRect_()||(this.createBorderRect_(),this.clickTargetRect=this.borderRect_,this.clickTargetRect.setAttribute("stroke-opacity","0"),this.clickTargetRect.setAttribute("fill-opacity","0"),this.borderRect_=void 0)}shouldAddBorderRect_(){if("variables_get"===this.sourceBlock_.type)return!1;for(const e of this.sourceBlock_.inputList)for(const t of e.fieldRow)if(t!==this&&t.EDITABLE)return!0;return!this.sourceBlock_.getInputsInline()||super.shouldAddBorderRect_()}bindEvents_(){this.shouldAddBorderRect_()?super.bindEvents_():(this.svgRootBinding=i.browserEvents.conditionalBind(this.sourceBlock_.getSvgRoot(),"pointerdown",this,e=>{this.sourceBlock_.icons.length||this.onMouseDown_(e)},!1),this.fieldRootBinding=i.browserEvents.conditionalBind(this.getSvgRoot(),"pointerdown",this,e=>{this.sourceBlock_.icons.length&&this.onMouseDown_(e)},!1))}dispose(){super.dispose(),this.svgRootBinding&&(i.browserEvents.unbind(this.svgRootBinding),i.browserEvents.unbind(this.fieldRootBinding))}positionBorderRect_(){super.positionBorderRect_(),this.clickTargetRect&&(this.clickTargetRect.setAttribute("width",String(this.size_.width)),this.clickTargetRect.setAttribute("height",String(this.size_.height)),this.clickTargetRect.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.clickTargetRect.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getValue(){var e,t;const n=super.getValue();if(null===(e=this.sourceBlock_)||void 0===e?void 0:e.isInFlyout){if((null===(t=this.sourceBlock_.workspace)||void 0===t?void 0:t.getPotentialVariableMap()).getVariableById(n))return"potential_"+n}return n}}n.FieldVariable=r,r.CREATE_VARIABLE_ID="CREATE_VARIABLE",i.fieldRegistry.unregister("field_variable"),i.fieldRegistry.register("field_variable",r)},{blockly:192}],138:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldVariable"),n)},{"./fieldVariable":137}],139:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isCollapsedInputRow=n.CollapsedInputRow=void 0;const i=e("blockly");class r extends i.blockRendering.InputRow{constructor(e){super(e),this.type|=i.blockRendering.Types.INPUT_ROW|i.blockRendering.Types.getType("COLLAPSED_INPUT_ROW")}measure(){this.width=this.minWidth,this.height=this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT}}n.CollapsedInputRow=r,n.isCollapsedInputRow=function(e){return!!(e.type&i.blockRendering.Types.getType("COLLAPSED_INPUT_ROW"))}},{blockly:192}],140:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectionPreviewer=void 0;const i=e("blockly");class r extends i.InsertionMarkerPreviewer{previewConnection(e,t){super.previewConnection(e,t),t.type!==i.ConnectionType.INPUT_VALUE&&t.type!==i.ConnectionType.OUTPUT_VALUE||this.showDraggedIndicatorWithLine(e,t)}previewReplacement(e,t,n){super.previewReplacement(e,t,n),this.showDraggedIndicatorWithLine(e,t)}showDraggedIndicatorWithLine(e,t){if(!this.connectionLine){this.connectionLine=i.utils.dom.createSvgElement("line",{class:"blocklyConnectionLine",x1:0,y1:0,x2:0,y2:0},e.sourceBlock_.getSvgRoot()),this.draggedConnectionIndicator=this.createConnectionIndicator(e.sourceBlock_.getSvgRoot(),e);const n=t.sourceBlock_.getSvgRoot().querySelector(":scope>.blocklyConnectionIndicatorParent");this.staticConnectionIndicator=this.createConnectionIndicator(n,t)}this.raiseIndicators(),this.updateLineCoords(e,t),i.renderManagement.finishQueuedRenders().then(()=>{this.connectionLine&&(this.raiseIndicators(),this.updateLineCoords(e,t))})}raiseIndicators(){var e,t;null===(e=this.draggedConnectionIndicator.parentElement)||void 0===e||e.appendChild(this.draggedConnectionIndicator);const n=this.staticConnectionIndicator.parentElement;n.appendChild(this.staticConnectionIndicator),null===(t=n.parentElement)||void 0===t||t.appendChild(n)}updateLineCoords(e,t){const n=r.CONNECTION_INDICATOR_RADIUS,o=e.getOffsetInBlock(),s=t.getOffsetInBlock();this.draggedConnectionIndicator.setAttribute("transform",`translate(${o.x}, ${o.y})`),this.staticConnectionIndicator.setAttribute("transform",`translate(${s.x}, ${s.y})`);const a=i.utils.Coordinate.sum(e.sourceBlock_.getRelativeToSurfaceXY(),o),l=i.utils.Coordinate.sum(t.sourceBlock_.getRelativeToSurfaceXY(),s),c=l.x-a.x,u=l.y-a.y;if(Math.sqrt(c*c+u*u)<2*n+1)return void i.utils.dom.addClass(this.connectionLine,"hidden");i.utils.dom.removeClass(this.connectionLine,"hidden");const d=Math.atan2(u,c);this.connectionLine.setAttribute("x1",String(o.x+Math.cos(d)*n)),this.connectionLine.setAttribute("y1",String(o.y+Math.sin(d)*n)),this.connectionLine.setAttribute("x2",String(o.x+c-Math.cos(d)*n)),this.connectionLine.setAttribute("y2",String(o.y+u-Math.sin(d)*n))}hidePreview(){super.hidePreview(),this.connectionLine&&(this.connectionLine.remove(),this.connectionLine=null,this.draggedConnectionIndicator.remove(),this.draggedConnectionIndicator=null,this.staticConnectionIndicator.remove(),this.staticConnectionIndicator=null,this.staticConnection=null)}createConnectionIndicator(e,t){const n=i.utils.dom.createSvgElement("g",{class:"blocklyInputConnectionIndicator"},e);i.utils.dom.createSvgElement("circle",{r:r.CONNECTION_INDICATOR_RADIUS},n);const o=t.getOffsetInBlock();return n.setAttribute("transform","translate("+o.x+","+o.y+")"),n}}n.ConnectionPreviewer=r,r.CONNECTION_INDICATOR_RADIUS=9},{blockly:192}],141:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConstantProvider=void 0;const i=e("blockly");class r extends i.zelos.ConstantProvider{constructor(){super(...arguments),this.FIELD_TEXT_FONTFAMILY='"Consolas", "Monaco", "Menlo", "Ubuntu Mono", "source-code-pro", monospace',this.FIELD_TEXT_FONTWEIGHT="600",this.HIGHLIGHT_GLOW_COLOUR="#FFF200",this.ERROR_HIGHLIGHT_GLOW_COLOR="#FF0000",this.HIGHLIGHT_GLOW_SIZE=1.1,this.ELLIPSES_RADIUS=6,this.ELLIPSES_SPACING=8,this.ellipses=this.makeEllipses()}createDom(e,t,n){super.createDom(e,t,n);const r=i.utils.dom.createSvgElement(i.utils.Svg.DEFS,{},e);this.highlightOutlineFilter=this.createHighlight(r,"blocklyHighlightedGlowFilter",this.HIGHLIGHT_GLOW_COLOUR),this.highlightOutlineFilterId=this.highlightOutlineFilter.id,this.errorOutlineFilter=this.createHighlight(r,"blocklyErrorHighlightedGlowFilter",this.ERROR_HIGHLIGHT_GLOW_COLOR),this.errorOutlineFilterId=this.errorOutlineFilter.id,this.embossFilterOverride=this.createOutline(r,"blocklyBubbleEmbossGlowFilter"),this.embossFilterId=this.embossFilterOverride.id}dispose(){super.dispose(),this.highlightOutlineFilter&&i.utils.dom.removeNode(this.highlightOutlineFilter)}makeEllipses(){const e=this.ELLIPSES_RADIUS,t=this.ELLIPSES_SPACING;let n="";for(let r=0;r<3;r++)n+=i.utils.svgPaths.moveBy(t,0)+i.utils.svgPaths.arc("a","180 1,1",e,i.utils.svgPaths.point(2*e,0));for(let r=0;r<3;r++)n+=i.utils.svgPaths.arc("a","180 1,1",e,i.utils.svgPaths.point(2*-e,0))+i.utils.svgPaths.moveBy(-t,0);return n}getCSS_(e){return super.getCSS_(e).concat([e+" .blocklyConnectionIndicator, "+e+" .blocklyInputConnectionIndicator {","fill: #ff0000;","stroke: #ffff00;","stroke-width: 3px;","}",e+" .blocklyConnectionIndicator {","display: none;","}",e+" .blocklyBlockDragSurface > g > .blocklyDraggable > .blocklyConnectionIndicator {","display: block;","}",e+" .blocklyConnectionLine {","stroke: #ffff00;","stroke-width: 4px;","}",e+" .blocklyConnectionLine.hidden {","display: none;","}",e+" .blocklyFlyoutHeading .blocklyFlyoutLabelText {font-size: 1.5rem;","}",`${e} .blocklyText::selection {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>text::selection,`,`${e} .blocklyEditableField>text::selection,`,`${e} .blocklyNonEditableField>g>text::selection,`,`${e} .blocklyEditableField>g>text::selection {`,"fill: #575E75;","}",`${e} .blocklyDropdownText::selection {`,"fill: #fff !important;","}"])}createHighlight(e,t,n){const r=i.utils.dom.createSvgElement(i.utils.Svg.FILTER,{id:t+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e);i.utils.dom.createSvgElement(i.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.HIGHLIGHT_GLOW_SIZE},r);const o=i.utils.dom.createSvgElement(i.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},r);return i.utils.dom.createSvgElement(i.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),i.utils.dom.createSvgElement(i.utils.Svg.FEFLOOD,{"flood-color":n,"flood-opacity":1,result:"outColor"},r),i.utils.dom.createSvgElement(i.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},r),r}createOutline(e,t){const n=i.utils.dom.createSvgElement(i.utils.Svg.FILTER,{id:t+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e);i.utils.dom.createSvgElement(i.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:.92},n);const r=i.utils.dom.createSvgElement(i.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},n);i.utils.dom.createSvgElement(i.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},r),i.utils.dom.createSvgElement(i.utils.Svg.FEFLOOD,{"flood-color":"#000000","flood-opacity":.5,result:"outColor"},n),i.utils.dom.createSvgElement(i.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},n);const o=i.utils.dom.createSvgElement("feMerge",{},n);return i.utils.dom.createSvgElement("feMergeNode",{in:"outBlur"},o),i.utils.dom.createSvgElement("feMergeNode",{in:"outGlow"},o),i.utils.dom.createSvgElement("feMergeNode",{in:"SourceGraphic"},o),n}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case i.ConnectionType.INPUT_VALUE:case i.ConnectionType.OUTPUT_VALUE:return t&&t.includes("Boolean")?this.HEXAGONAL:(t&&t.includes("Number")||t&&t.includes("String"),this.ROUNDED);case i.ConnectionType.PREVIOUS_STATEMENT:case i.ConnectionType.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}}n.ConstantProvider=r,r.COLLAPSE_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.354)'%3E%3Cpath d='m1611 367.42q0 53-37 90l-651 651q-38 38-91 38-54 0-90-38l-651-651q-38-36-38-90 0-53 38-91l74-75q39-37 91-37 53 0 90 37l486 486 486-486q37-37 90-37 52 0 91 37l75 75q37 39 37 91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A",r.EXPAND_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.654)'%3E%3Cpath d='m1611 832q0-53-37-90l-651-651q-38-38-91-38-54 0-90 38l-651 651q-38 36-38 90 0 53 38 91l74 75q39 37 91 37 53 0 90-37l486-486 486 486q37 37 90 37 52 0 91-37l75-75q37-39 37-91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A"},{blockly:192}],142:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});e("blockly").Css.register("\n.blocklyDropdownMenu .blocklyMenuItemCheckbox {\n filter: contrast(0) brightness(100);\n}\n\n.blocklyVerticalMarker {\n fill: none;\n}\n")},{blockly:192}],143:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.Drawer=void 0;const i=e("blockly"),r=e("./collapsedInputRow");class o extends i.zelos.Drawer{drawCollapsedStack_(e){const t=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.constants_.INSIDE_CORNERS.width,n=this.constants_.STATEMENT_INPUT_PADDING_LEFT+2*this.constants_.INSIDE_CORNERS.width+i.utils.svgPaths.lineOnAxis("h",-this.constants_.INSIDE_CORNERS.width)+this.constants_.INSIDE_CORNERS.pathTop,r=e.height-2*this.constants_.INSIDE_CORNERS.height,o=this.constants_.INSIDE_CORNERS.pathBottom+i.utils.svgPaths.lineOnAxis("h",this.constants_.INSIDE_CORNERS.width),s=this.constants_.ellipses;this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.bottomRight+i.utils.svgPaths.lineOnAxis("H",t)+n+i.utils.svgPaths.lineOnAxis("v",r/2)+s+i.utils.svgPaths.lineOnAxis("v",r/2)+o+i.utils.svgPaths.lineOnAxis("H",e.xPos+e.width-this.constants_.OUTSIDE_CORNERS.rightHeight)+this.constants_.OUTSIDE_CORNERS.topRight}drawOutline_(){if(this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection)this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_();else{this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){const t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):(0,r.isCollapsedInputRow)(t)?this.drawCollapsedStack_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}}drawLeft_(){super.drawLeft_();if(this.info_.rows.find(function(e){return(0,r.isCollapsedInputRow)(e)})){let e=this.info_.startY;i.blockRendering.Types.isLeftRoundedCorner(this.info_.topRow.elements[0])&&(e+=this.constants_.OUTSIDE_CORNERS.rightHeight),this.outlinePath_=this.outlinePath_.slice(0,-1),this.outlinePath_+=i.utils.svgPaths.lineOnAxis("V",e)}}}n.Drawer=o},{"./collapsedInputRow":139,blockly:192}],144:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./renderer"),n),r(e("./connectionPreviewer"),n),r(e("./css"),n)},{"./connectionPreviewer":140,"./css":142,"./renderer":147}],145:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.RenderInfo=void 0;const i=e("blockly"),r=e("./collapsedInputRow");class o extends i.zelos.RenderInfo{measure(){if(this.block_)for(const e of this.block_.inputList)e.init();super.measure()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let e=new i.blockRendering.InputRow(this.constants_);this.inputRows.push(e);const t=this.block_.getIcons();for(let n,r=0;n=t[r];r++){const t=new i.blockRendering.Icon(this.constants_,n);this.isCollapsed&&!n.isShownWhenCollapsed()||e.elements.push(t)}let n;for(let t,r=0;t=this.block_.inputList[r];r++)if(t.isVisible()){this.shouldStartNewRow_(t,n)&&(this.rows.push(e),e=new i.blockRendering.InputRow(this.constants_),this.inputRows.push(e));for(let n,r=0;n=t.fieldRow[r];r++)e.elements.push(new i.blockRendering.Field(this.constants_,n,t));this.addInput_(t,e),n=t}if(this.isCollapsed){this.block_.inputList.find(function(e){return e.type==i.inputs.inputTypes.STATEMENT})?e=this.addCollapsedRow_(e):(e.hasJaggedEdge=!0,e.elements.push(new i.blockRendering.JaggedEdge(this.constants_)))}(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;const e=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof i.inputs.StatementInput||this.rows.some(e=>(0,r.isCollapsedInputRow)(e));this.bottomRow.minHeight=e?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new i.blockRendering.SquareCorner(this.constants_)):this.bottomRow.elements.push(new i.blockRendering.RoundCorner(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new i.blockRendering.NextConnection(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new i.blockRendering.SquareCorner(this.constants_,"right")):this.bottomRow.elements.push(new i.blockRendering.RoundCorner(this.constants_,"right"))}addCollapsedRow_(e){this.rows.push(e);const t=new r.CollapsedInputRow(this.constants_);return t.hasDummyInput=!0,t}}n.RenderInfo=o},{"./collapsedInputRow":139,blockly:192}],146:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.PathObject=void 0;const i=e("blockly"),r="blockly-dotted-outline-on-hover",o="hover";class s extends i.zelos.PathObject{constructor(){super(...arguments),this.connectionPointIndicators=new WeakMap}setPath(e){super.setPath(e),this.svgPathHighlighted&&this.svgPathHighlighted.setAttribute("d",e)}updateHighlighted(e){if(e){if(!this.svgPathHighlighted){const e=this.constants,t=this.hasError?e.errorOutlineFilterId:e.highlightOutlineFilterId;this.svgPathHighlighted=this.svgPath.cloneNode(!0),this.svgPathHighlighted.classList.add("pxtRendererHighlight"),this.svgPathHighlighted.setAttribute("fill","none"),this.svgPathHighlighted.setAttribute("filter","url(#"+t+")"),this.svgRoot.appendChild(this.svgPathHighlighted)}}else this.svgPathHighlighted&&(this.svgRoot.removeChild(this.svgPathHighlighted),this.svgPathHighlighted=null)}updateSelected(e){e&&this.svgPath.classList.remove(o),super.updateSelected(e)}addConnectionHighlight(e,t,n,r){const o=super.addConnectionHighlight(e,t,n,r);return this.staticConnectionIndicatorParentGroup?this.svgRoot.appendChild(this.staticConnectionIndicatorParentGroup):this.staticConnectionIndicatorParentGroup=i.utils.dom.createSvgElement("g",{class:"blocklyConnectionIndicatorParent"},this.svgRoot),o}removeConnectionHighlight(e){var t;null===(t=this.staticConnectionIndicatorParentGroup)||void 0===t||t.remove(),super.removeConnectionHighlight(e)}applyColour(e){if(super.applyColour(e),e.outputConnection){let t=!1;const n=e.getParent();if(n)if(e.isShadow()){const e=n.style.colourTertiary,r=function(e){return(.2126*e[0]+.7152*e[1]+.0722*e[2])/255}(i.utils.colour.hexToRgb(e));r<.15&&(this.svgPath.setAttribute("stroke",i.utils.colour.blend("#ffffff",e,.3)),t=!0)}else{const r=n.style.colourPrimary,o=e.style.colourPrimary;if(r===o){const e=.6,n=i.utils.colour.blend("#0000000",o,e),s=i.utils.colour.blend("#ffffff",o,e);pxt.contrastRatio(n,r)>pxt.contrastRatio(s,r)?this.svgPath.setAttribute("stroke",n):this.svgPath.setAttribute("stroke",s),t=!0}}t||this.svgPath.setAttribute("stroke",e.style.colourTertiary)}}setHasDottedOutlineOnHover(e){this.hasDottedOutlineOnHover=e,e?(this.svgPath.classList.add(r),this.mouseOverData||(this.mouseOverData=i.browserEvents.bind(this.svgRoot,"mouseover",this,()=>{this.svgPath.classList.add(o)}),this.mouseLeaveData=i.browserEvents.bind(this.svgRoot,"mouseleave",this,()=>{this.svgPath.classList.remove(o)}))):(this.svgPath.classList.remove(r),this.mouseOverData&&(i.browserEvents.unbind(this.mouseOverData),i.browserEvents.unbind(this.mouseLeaveData),this.mouseOverData=void 0,this.mouseLeaveData=void 0),this.svgPath.classList.remove(r))}setHasError(e){this.hasError=e}isHighlighted(){return!!this.svgPathHighlighted}}n.PathObject=s,s.CONNECTION_INDICATOR_RADIUS=9,i.Css.register("\n.blockly-dotted-outline-on-hover {\n transition: stroke .4s;\n}\n.blockly-dotted-outline-on-hover.hover {\n stroke-dasharray: 2;\n stroke: white;\n stroke-width: 2;\n}\n.blocklyDisabledPattern>.blocklyPath.pxtRendererHighlight {\n fill: none;\n}\n")},{blockly:192}],147:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.Renderer=void 0;const i=e("blockly"),r=e("./pathObject"),o=e("./constants"),s=e("./info"),a=e("./drawer");class l extends i.zelos.Renderer{makePathObject(e,t){return new r.PathObject(e,t,this.getConstants())}makeConstants_(){return new o.ConstantProvider}makeRenderInfo_(e){return new s.RenderInfo(this,e)}makeDrawer_(e,t){return new a.Drawer(e,t)}render(e){e.updateBeforeRender&&e.updateBeforeRender(),super.render(e)}}n.Renderer=l,i.blockRendering.register("pxt",l)},{"./constants":141,"./drawer":143,"./info":145,"./pathObject":146,blockly:192}],148:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldString=void 0;const i=e("blockly");class r extends i.FieldTextInput{initView(){this.quoteSize_=16,this.quoteWidth_=8,this.quoteLeftX_=0,this.quoteRightX_=0,this.quoteY_=10,this.quoteLeft_&&this.quoteLeft_.parentNode.removeChild(this.quoteLeft_),this.quoteLeft_=i.utils.dom.createSvgElement("text",{"font-size":this.quoteSize_+"px",class:"field-text-quote","aria-hidden":"true"},this.fieldGroup_),super.initView(),this.quoteRight_&&this.quoteRight_.parentNode.removeChild(this.quoteRight_),this.quoteRight_=i.utils.dom.createSvgElement("text",{"font-size":this.quoteSize_+"px",class:"field-text-quote","aria-hidden":"true"},this.fieldGroup_),this.quoteLeft_.appendChild(document.createTextNode('"')),this.quoteRight_.appendChild(document.createTextNode('"'))}updateSize_(e){super.updateSize_(e);const t=this.value_?this.size_.width:1;let n=this.positionLeft(t+3);this.textElement_.setAttribute("x",n+""),n+=this.positionRight(n+t+3),this.size_.width=t+n}positionLeft(e){if(!this.quoteLeft_)return 0;let t=0;return this.sourceBlock_.RTL?(this.quoteLeftX_=e+this.quoteWidth_+2*r.quotePadding,t=this.quoteWidth_+r.quotePadding):(this.quoteLeftX_=0,t=this.quoteWidth_+r.quotePadding),this.quoteLeft_.setAttribute("transform","translate("+this.quoteLeftX_+","+this.quoteY_+")"),t}positionRight(e){if(!this.quoteRight_)return 0;let t=0;return this.sourceBlock_.RTL?(this.quoteRightX_=r.quotePadding,t=this.quoteWidth_+r.quotePadding):(this.quoteRightX_=e+r.quotePadding,t=this.quoteWidth_+r.quotePadding),this.quoteRight_.setAttribute("transform","translate("+this.quoteRightX_+","+this.quoteY_+")"),t}}n.FieldString=r,r.quotePadding=0,i.Css.register("\n.field-text-quote {\n fill: #a31515 !important;\n}\n"),i.fieldRegistry.register("field_string",r)},{blockly:192}],149:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldString"),n),r(e("./text"),n),r(e("./join"),n)},{"./fieldString":148,"./join":150,"./text":151}],150:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../../fields/field_imagenotext"),o=e("../../utils"),s={itemCount_:0,valueConnections_:[],buttons:null,delta:0,mutationToDom:function(){const e=i.utils.xml.createElement("mutation");return e.setAttribute("items",this.itemCount_+""),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute("items"),10),this.updateShape_()},storeValueConnections_:function(){this.valueConnections_=[];for(let e=0;e<this.itemCount_;e++)this.valueConnections_.push(this.getInput("ADD"+e).connection.targetConnection)},restoreValueConnections_:function(){var e;for(let t=0;t<this.itemCount_;t++)null===(e=this.valueConnections_[t])||void 0===e||e.reconnect(this,"ADD"+t)},addItem_:function(){this.storeValueConnections_();if(this.delta=1,this.update_(()=>{this.itemCount_++}),this.restoreValueConnections_(),this.itemCount_>1){const e=this.getInput("ADD0");if(e&&e.connection.targetConnection){const t=this.getInput("ADD"+(this.itemCount_-1)),n=e.connection.getShadowDom();if(n){const e=i.utils.xml.createElement("shadow"),r=n.getAttribute("type");e.setAttribute("type",r),e&&(e.setAttribute("id",i.utils.idGenerator.genUid()),t.connection.setShadowDom(e))}}}},removeItem_:function(){this.storeValueConnections_();this.delta=-1,this.update_(()=>{this.itemCount_--}),this.restoreValueConnections_()},update_:function(e){i.Events.setGroup(!0);const t=this,n=t.mutationToDom(),r=n&&i.Xml.domToText(n);e&&e.call(this),this.updateShape_(),t instanceof i.BlockSvg&&t.initSvg();const s=i.Events.getGroup(),a=t.mutationToDom(),l=a&&i.Xml.domToText(a);r!=l&&(i.Events.fire(new i.Events.BlockChange(t,"mutation",null,r,l)),setTimeout(function(){i.Events.setGroup(s),t.bumpNeighbours(),i.Events.setGroup(!1)},i.config.bumpDelay)),t.rendered&&t instanceof i.BlockSvg&&t.queueRender().then(()=>{if(this.buttons){let e=this.buttons.fieldRow[0];this.buttons.fieldRow.length>1&&(e=this.delta<0?e:this.buttons.fieldRow[1]),(0,o.maybeMoveFocusFromButton)(e),this.buttons=null,this.delta=0}}),i.Events.setGroup(!1)},updateShape_:function(){const e=this,t=function(){e.removeItem_()};let n;for(this.getInput("EMPTY")&&this.removeInput("EMPTY"),this.getInput("TITLE")||this.appendDummyInput("TITLE").appendField(i.Msg.TEXT_JOIN_TITLE_CREATEWITH),n=0;n<this.itemCount_;n++)if(!this.getInput("ADD"+n)){this.appendValueInput("ADD"+n).setAlign(i.inputs.Align.LEFT).setAriaLabelProvider(i.Msg.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(n+1).toString()))}for(;this.getInput("ADD"+n);)this.removeInput("ADD"+n),n++;this.getInput("BUTTONS")&&this.removeInput("BUTTONS"),this.buttons=this.appendDummyInput("BUTTONS"),this.itemCount_>1&&this.buttons.appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,lf("remove argument"),t,!1)),this.buttons.appendField(new r.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,lf("add argument"),function(){e.addItem_()},!1));const o=this.itemCount_<=4;if(this.setInputsInline(o),this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer();this.setOutputShape(o?e.getConstants().SHAPES.ROUND:e.getConstants().SHAPES.SQUARE)}}};i.Extensions.registerMutator("pxt_text_join_mutator",s,function(){i.Extensions.apply("inline-svgs",this,!1),this.itemCount_=2,this.updateShape_()}),i.defineBlocksWithJsonArray([{type:"text_join",message0:"",output:"String",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"pxt_text_join_mutator"}])},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],151:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly");i.defineBlocksWithJsonArray([{type:"text",message0:"%1",args0:[{type:"field_string",name:"TEXT",text:""}],output:"String",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]}])},{blockly:192}],152:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.blocksMetrics=n.render=n.renderWorkspace=n.cleanRenderingWorkspace=n.initRenderingWorkspace=void 0;const i=e("blockly"),r=e("./layout"),o=e("./importer");let s,a;function l(){return s||(a=document.createElement("div"),a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="1px",a.style.height="1px",document.body.appendChild(a),s=i.inject(a,{move:{scrollbars:!1},readOnly:!0,sounds:!1,media:pxt.webConfig.commitCdnUrl+"blockly/media/",rtl:pxt.Util.isUserLanguageRtl(),renderer:"pxt"})),(0,o.clearWithoutEvents)(s),s}function c(){s&&s.dispose(),s=void 0}function u(e={emPixels:18,layout:1}){switch(e.splitSvg?1:e.layout||4){case 1:(0,r.verticalAlign)(s,e.emPixels||18);break;case 4:(0,r.flow)(s,{ratio:e.aspectRatio,useViewWidth:e.useViewWidth});break;case 3:s.cleanUp_&&s.cleanUp_()}let t=s.getMetrics();const n=a.querySelectorAll("svg")[0],i=n.cloneNode(!0);return(0,r.cleanUpBlocklySvg)(i,n),pxt.U.toArray(i.querySelectorAll(".blocklyBlockCanvas,.blocklyBubbleCanvas")).forEach(e=>e.setAttribute("transform",`translate(${-t.contentLeft}, ${-t.contentTop}) scale(1)`)),i.setAttribute("viewBox",`0 0 ${t.contentWidth} ${t.contentHeight}`),e.emPixels&&(i.style.width=t.contentWidth/e.emPixels+"em",i.style.height=t.contentHeight/e.emPixels+"em"),e.splitSvg?(0,r.splitSvg)(i,s,e.emPixels):i}n.initRenderingWorkspace=l,n.cleanRenderingWorkspace=c,n.renderWorkspace=u,n.render=function(e,t={emPixels:18,layout:1}){l();try{let n=e||'<xml xmlns="http://www.w3.org/1999/xhtml"></xml>',r=i.utils.xml.textToDom(n);return(0,o.domToWorkspaceNoEvents)(r,s,{applyHideMetaComment:!0}),u(t)}catch(e){return void pxt.reportException(e)}finally{c()}},n.blocksMetrics=function(e){const t=e.getTopBlocks(!1);if(!t.length)return{width:0,height:0};let n;return t.forEach(e=>{const t=e.getBoundingRectangle();n?(n.l=Math.min(n.l,t.left),n.r=Math.max(n.r,t.right),n.t=Math.min(n.t,t.top),n.b=Math.min(n.b,t.bottom)):n={l:t.left,r:t.right,t:t.top,b:t.bottom}}),{width:n.r-n.l,height:n.b-n.t}}},{"./importer":75,"./layout":77,blockly:192}],153:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.findBlockIdByLine=n.findBlockIdByPosition=void 0,n.findBlockIdByPosition=function(e,t){if(!t)return;let n,i;for(let r=0;r<e.length;++r){let o=e[r];o.startPos<=t.start&&o.endPos>=t.start+t.length&&(!n||i>o.endPos-o.startPos)&&(n=o,i=o.endPos-o.startPos)}return n?n.id:void 0},n.findBlockIdByLine=function(e,t){if(!t)return;let n,i;for(let r=0;r<e.length;++r){let o=e[r];o.startLine<=t.start&&o.endLine>t.start+t.length&&(!n||i>o.endLine-o.startLine)&&(n=o,i=o.endLine-o.startLine)}return n?n.id:void 0}},{}],154:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.createFunctionsFlyoutCategory=n.mkReturnStatementBlock=n.mkVariableFieldBlock=n.mkFieldBlock=n.mkPredicateBlock=n.createToolboxBlock=n.createFlyoutGap=n.createFlyoutButton=n.createFlyoutGroupLabel=n.createFlyoutHeadingLabel=n.createShadowValue=n.isArrayType=void 0;const i=e("blockly"),r=e("./plugins/functions"),o=e("./loader"),s=/^(string|number|boolean)$/,a={string:{field:"TEXT",block:"text",defaultValue:""},number:{field:"NUM",block:"math_number",defaultValue:"0"},boolean:{field:"BOOL",block:"logic_boolean",defaultValue:"false"},Array:{field:"VAR",block:"variables_get",defaultValue:"list"}};function l(e){let t=/^(?:Array<(.+)>)|(?:(.+)\[\])|(?:\[.+\])$/.exec(e);return t?t[1]?t[1]:t[2]:void 0}function c(e,t,n,i,r,o=0){let s;if(i=i||t.defaultValue,!(n=n||t.shadowBlockId)&&t.range&&(n="math_number_minmax"),s=i&&'"'==i.slice(0,1)?JSON.parse(i):i,"number"==t.type&&"value"==n){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode("0")),e}if(t.fieldEditor){if(t.defaultValue){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode(t.defaultValue)),e}return}let c=pxt.Util.lookup(e.apis.byQName,t.type),d=6==(null==c?void 0:c.kind),p=c&&!!c.attributes.fixedInstances&&!t.shadowBlockId,h="@combined@"==t.type;if(!n&&(d||p||h)){if(i){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode(i)),e}return}const g="variables_get"==n,m="text"==n,_=document.createElement("value");_.setAttribute("name",t.definitionName);const y="lists_create_with"!==n&&n?void 0:l(t.type),b=document.createElement(!g&&!y||r?"shadow":"block");_.appendChild(b);const v=a[y||t.type];if(b.setAttribute("type",n||(y?"lists_create_with":v&&v.block||t.type)),b.setAttribute("colour","#fff"),y){if(v&&!n){let e;switch(y){case"number":e=["0","1"];break;case"string":e=["a","b","c"];break;case"boolean":e=["FALSE","FALSE","FALSE"]}return u(b,v.block,v.field,e),_}if(n&&s)return u(b,s),_}if(!v||n&&v.block!==n&&"math_number_minmax"!==n){if(s){const i=document.createElement("field");if(i.textContent=s,g)i.setAttribute("name","VAR"),b.appendChild(i);else if(m)i.setAttribute("name","TEXT"),b.appendChild(i);else if(n){const t=e.blocksById[n];if(t&&t.attributes._def&&t.attributes._def.parameters.length){const e=t.attributes._def.parameters[0];i.setAttribute("name",e.name),b.appendChild(i)}}else i.setAttribute("name",t.definitionName),b.appendChild(i)}}else{const e=document.createElement("field");let i,r;switch(b.appendChild(e),n){case"variables_get":i="VAR";break;case"math_number_minmax":i="SLIDER";break;default:i=v.field}e.setAttribute("name",i),r="boolean"==t.type?document.createTextNode((s||v.defaultValue).toUpperCase()):document.createTextNode(s||v.defaultValue),e.appendChild(r)}let T;if(t.range&&(T=document.createElement("mutation"),T.setAttribute("min",t.range.min.toString()),T.setAttribute("max",t.range.max.toString()),T.setAttribute("label",t.actualName.charAt(0).toUpperCase()+t.actualName.slice(1)),t.fieldOptions&&(t.fieldOptions.step&&T.setAttribute("step",t.fieldOptions.step),t.fieldOptions.color&&T.setAttribute("color",t.fieldOptions.color),t.fieldOptions.precision&&T.setAttribute("precision",t.fieldOptions.precision))),t.fieldOptions&&(T||(T=document.createElement("mutation")),T.setAttribute("customfield",JSON.stringify(t.fieldOptions))),T&&b.appendChild(T),o){const t=pxt.Util.toArray(_.getElementsByTagName("shadow"));for(const n of t)if(!n.innerHTML){const t=e.blocks.find(e=>e.attributes.blockId===n.getAttribute("type"));if(t){const i=f(e,t,pxt.blocks.compileInfo(t),!0,o-1);for(;i.firstChild;)n.appendChild(i.firstChild.cloneNode(!0)),i.firstChild.remove()}}}return _}function u(e,t,n,i){const r=i?i.length:2,o=document.createElement("mutation");o.setAttribute("items",""+r),o.setAttribute("horizontalafter",""+r),e.appendChild(o);for(let o=0;o<r;o++){const r=document.createElement("value");r.setAttribute("name","ADD"+o);const s=document.createElement("shadow");if(s.setAttribute("type",t),n){const e=document.createElement("field");e.setAttribute("name",n),i&&e.appendChild(document.createTextNode(i[o])),s.appendChild(e)}r.appendChild(s),e.appendChild(r)}}function d(e,t,n,i){const r=h(e,pxt.toolbox.convertColor(t),n,i);return r.setAttribute("web-class","blocklyFlyoutHeading"),r}function p(e,t,n,i){const r=h(e,void 0,t);return r.setAttribute("web-class","blocklyFlyoutGroup"),r.setAttribute("web-line","1.5"),n&&r.setAttribute("web-line-width",n),i&&(r.setAttribute("web-help-button","true"),r.setAttribute("callbackKey",i)),r}function h(e,t,n,r){let o=i.utils.xml.createElement("label");return o.setAttribute("text",e),t&&o.setAttribute("web-icon-color",pxt.toolbox.convertColor(t)),n&&(1===n.length?(o.setAttribute("web-icon",n),r&&o.setAttribute("web-icon-class",r)):(o.setAttribute("web-icon-class",`blocklyFlyoutIcon${e}`),pxt.toolbox.isImageIcon(n)&&o.setAttribute("web-icon-image",pxt.Util.pathJoin(pxt.webConfig.commitCdnUrl,encodeURI(n))))),o}function f(e,t,n,i=!1,a=0){var u,d;let p,h;if(t.attributes.builtinBlockId)return function(e){const t=e.attributes.builtinBlockId,n=e.attributes.color;if("makecode_color_picker"===t){const e=document.createElement("block");e.setAttribute("type","makecode_color_picker");const t=document.createElement("field");t.setAttribute("name","FORMAT"),t.textContent="rgb",e.appendChild(t);for(let t=0;t<3;t++){const n=document.createElement("value");n.setAttribute("name",`INPUT${t}`);const i=document.createElement("shadow");i.setAttribute("type","makecode_color_picker_number");const r=document.createElement("field");r.setAttribute("name","NUM"),r.textContent="0",i.appendChild(r),n.appendChild(i),e.appendChild(n)}if(n){const t=document.createElement("mutation");t.setAttribute("color",n),e.appendChild(t)}return e}return void pxt.warn(`Unsupported builtin block id: ${t}`)}(t);if(t.attributes.toolboxParent){const n=e.blocksById[t.attributes.toolboxParent];if(n){const r=pxt.blocks.compileInfo(n);if(p=f(e,n,r,i),t.attributes.toolboxParentArgument)h=p.querySelector(`value[name=${t.attributes.toolboxParentArgument}]`),!h&&r.parameters.some(e=>e.definitionName===t.attributes.toolboxParentArgument)&&(h=document.createElement("value"),h.setAttribute("name",t.attributes.toolboxParentArgument),p.appendChild(h));else if(h=p.querySelector("value"),!h)for(const e of r.parameters)if(!p.querySelector(`field[name=${e.definitionName}]`)){h=document.createElement("value"),h.setAttribute("name",e.definitionName),p.appendChild(h);break}if(h)for(;h.firstChild;)h.removeChild(h.firstChild);else p=void 0}}let g=document.createElement(p||i?"shadow":"block");if(g.setAttribute("type",t.attributes.blockId),t.attributes.blockGap?g.setAttribute("gap",t.attributes.blockGap):pxt.appTarget.appTheme&&pxt.appTarget.appTheme.defaultBlockGap&&g.setAttribute("gap",pxt.appTarget.appTheme.defaultBlockGap.toString()),n.thisParameter){const t=n.thisParameter,r=!!(null===(u=e.apis.byQName[t.type])||void 0===u?void 0:u.attributes.fixedInstances);let o=t.shadowBlockId,s=t.defaultValue;r||o&&"variables_get"!==o||(o="variables_get",s=s||t.definitionName);const l=c(e,t,o,s,i,a);l&&g.appendChild(l)}if("ENUM_GET"===t.attributes.shim||"KIND_GET"===t.attributes.shim){if(null===(d=t.parameters)||void 0===d?void 0:d.length){const e=t.parameters[0].default;if(e){const t=document.createElement("field");t.setAttribute("name","MEMBER"),t.textContent=e,g.appendChild(t)}}}else t.parameters&&(n.parameters.filter(e=>s.test(e.type)||s.test(l(e.type))||e.shadowBlockId||e.defaultValue).forEach(t=>{const n=c(e,t,void 0,void 0,i,a);n&&g.appendChild(n)}),t.attributes.draggableParameters?n.handlerArgs.forEach(e=>{const n="reporter"===t.attributes.draggableParameters,i=document.createElement("value");i.setAttribute("name",o.DRAGGABLE_PARAM_INPUT_PREFIX+e.name);const s=n?pxt.blocks.reporterTypeForArgType(e.type):"variables_get_reporter",a=document.createElement("block");a.setAttribute("type",s);const l=document.createElement("mutation");a.appendChild(l),n&&"argument_reporter_custom"===s&&l.setAttribute("typename",e.type),l.setAttribute(r.LOCALIZATION_NAME_MUTATION_KEY,e.localizationKey);const c=document.createElement("field");c.setAttribute("name",n?"VALUE":"VAR"),c.textContent=pxt.Util.htmlEscape(e.name),a.appendChild(c),i.appendChild(a),g.appendChild(i)}):n.handlerArgs.forEach(e=>{const t=document.createElement("field");t.setAttribute("name","HANDLER_"+e.name),t.textContent=e.name,g.appendChild(t)}));if(t.attributes.expandArgumentsInToolbox){let e;for(const t of g.children)if("mutation"===t.tagName){e=t;break}e||(e=document.createElement("mutation"),g.appendChild(e)),e.setAttribute("_expanded",""+t.attributes._expandedDef.parameters.length)}return p?(h.appendChild(g),p):g}function g(e,t,n,i){const r=document.createElement(i?"shadow":"block");r.setAttribute("type",pxt.Util.htmlEscape(e));const o=document.createElement("field");return o.setAttribute("name",pxt.Util.htmlEscape(t)),o.textContent=pxt.Util.htmlEscape(n),r.appendChild(o),r}function m(){const e=document.createElement("block");e.setAttribute("type","function_return");const t=document.createElement("value");t.setAttribute("name","RETURN_VALUE"),e.appendChild(t);const n=g("math_number","NUM","0",!0);return t.appendChild(n),e}n.isArrayType=l,n.createShadowValue=c,n.createFlyoutHeadingLabel=d,n.createFlyoutGroupLabel=p,n.createFlyoutButton=function(e,t){let n=i.utils.xml.createElement("button");return n.setAttribute("text",t),n.setAttribute("callbackKey",e),n},n.createFlyoutGap=function(e){const t=i.utils.xml.createElement("sep");return t.setAttribute("gap",e+""),t},n.createToolboxBlock=f,n.mkPredicateBlock=function(e){const t=document.createElement("block");t.setAttribute("type",e);const n=document.createElement("value");n.setAttribute("name","PREDICATE"),t.appendChild(n);const i=g("logic_boolean","BOOL","TRUE",!0);return n.appendChild(i),t},n.mkFieldBlock=g,n.mkVariableFieldBlock=function(e,t,n,i,r){const o=document.createElement(r?"shadow":"block");o.setAttribute("type",pxt.Util.htmlEscape(e));const s=document.createElement("field");return s.setAttribute("name","VAR"),s.id=t,s.setAttribute("variabletype",pxt.Util.htmlEscape(n)),s.textContent=pxt.Util.htmlEscape(i),o.appendChild(s),o},n.mkReturnStatementBlock=m,n.createFunctionsFlyoutCategory=function(e){const t=(0,r.flyoutCategory)(e);if(t.length>1){let e=m();t.splice(1,0,p(lf("Your Functions"))),t.splice(1,0,e)}const n=(0,r.getAllFunctionDefinitionBlocks)(e).filter(e=>e.getDescendants(!1).some(e=>"function_return"===e.type&&e.getInputTargetBlock("RETURN_VALUE"))).map(e=>e.getField("function_name").getText()),i=d(lf("Functions"),pxt.toolbox.getNamespaceColor("functions"),pxt.toolbox.getNamespaceIcon("functions"),"blocklyFlyoutIconfunctions");t.unshift(i);const o=[];for(const e of t)if(o.push(e),"function_call"===e.getAttribute("type")){const t=e.children.item(0);if(t){const i=t.getAttribute("name");if(n.some(e=>e===i)){const t=e.cloneNode(!0);t.setAttribute("type","function_call_output"),o.push(t)}}}return o}},{"./loader":79,"./plugins/functions":127,blockly:192}],155:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.maybeMoveFocusFromButton=void 0;const i=e("blockly"),r=e("./fields/field_imagenotext");n.maybeMoveFocusFromButton=e=>{const t=i.getFocusManager(),n=t.getFocusedNode();e&&(n instanceof r.FieldImageNoText||!n)&&t.focusNode(e)}},{"./fields/field_imagenotext":38,blockly:192}],156:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.PxtWorkspaceSearch=void 0;const i=e("blockly"),r=e("@blockly/plugin-workspace-search");class o extends r.WorkspaceSearch{constructor(e){super(e),this.injectionDiv=e.getInjectionDiv()}highlightSearchGroup(e){e.forEach(e=>{const t=e.pathObject.svgPath;i.utils.dom.addClass(t,"blockly-ws-search-highlight-pxt")})}unhighlightSearchGroup(e){e.forEach(e=>{const t=e.pathObject.svgPath;i.utils.dom.removeClass(t,"blockly-ws-search-highlight-pxt")})}open(){super.open(),i.utils.dom.addClass(this.injectionDiv,"blockly-ws-searching")}close(){super.close(),i.utils.dom.removeClass(this.injectionDiv,"blockly-ws-searching")}}n.PxtWorkspaceSearch=o,i.Css.register("\n.blockly-ws-search {\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n border: solid var(--pxt-neutral-alpha50) 1px;\n border-top: none;\n border-right: none;\n box-shadow: 0px 2px 15px var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input {\n -webkit-tap-highlight-color: transparent;\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n border: none;\n}\n\n.blockly-ws-search input::-webkit-input-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input::-moz-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input::-ms-input-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input:active,\n.blockly-ws-search input:focus {\n border-color: var(--pxt-neutral-alpha50);\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n}\n\n.blockly-ws-search input::selection {\n color: var(--pxt-neutral-foreground1);\n}\n\n.blockly-ws-search button {\n padding-left: 6px;\n padding-right: 6px;\n color: var(--pxt-neutral-foreground1);\n}")},{"@blockly/plugin-workspace-search":187,blockly:192}],157:[function(e,t,n){function i(e,t,n,i){return pxt.Util.toArray(e.getElementsByTagName(t)).filter(e=>e.getAttribute(n)===i)}Object.defineProperty(n,"__esModule",{value:!0}),n.cleanOuterHTML=n.getDirectChildren=n.getFirstChildWithAttr=n.getChildrenWithAttr=n.getBlocksWithType=void 0,n.getBlocksWithType=function(e,t){return i(e,"block","type",t).concat(i(e,"shadow","type",t))},n.getChildrenWithAttr=i,n.getFirstChildWithAttr=function(e,t,n,r){const o=i(e,t,n,r);return o.length?o[0]:void 0},n.getDirectChildren=function(e,t){const n=[];for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes.item(i);r.tagName===t&&n.push(r)}return n},n.cleanOuterHTML=function(e){return e.outerHTML.replace(/^<\?[^>]*>/,"")}},{}],158:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.getNestedChildBlocks=void 0,n.getNestedChildBlocks=function(e){return e.getDescendants(!0).filter(t=>t.isEnabled()&&t.getSurroundParent()===e)}},{}],159:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./runValidatorPlan"),n),r(e("./validateBlocksExist"),n),r(e("./validateBlocksInSetExist"),n),r(e("./validateCommentsExist"),n),r(e("./validateSpecificBlockCommentsExist"),n)},{"./runValidatorPlan":160,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165}],160:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.runValidatorPlan=void 0;const i=e("./validateBlockFieldValueExists"),r=e("./validateBlocksExist"),o=e("./validateBlocksInSetExist"),s=e("./validateCommentsExist"),a=e("./validateSpecificBlockCommentsExist"),l=e("./getNestedChildBlocks"),c=e("./validateVariableUsage");function u(e,t){const n=t.blockCounts.reduce((e,t)=>(e[t.blockId]=t.count,e),{}),i=(0,r.validateBlocksExist)({usedBlocks:e,requiredBlockCounts:n});let o=[];if(i.passed)for(const e of t.blockCounts){const t=e.blockId;o.push(...i.successfulBlocks[t])}return[o,i.passed]}function d(e,t){return(0,s.validateBlockCommentsExist)({usedBlocks:e,numRequired:t.count}).passed}function p(e,t){return(0,s.validateCommentsExist)({usedBlocks:e,numRequired:t.count}).passed}function h(e,t){return(0,a.validateSpecificBlockCommentsExist)({usedBlocks:e,blockType:t.blockType}).passed}function f(e,t){const n=(0,o.validateBlocksInSetExist)({usedBlocks:e,blockIdsToCheck:t.blocks,count:t.count});return[n.successfulBlocks,n.passed]}function g(e,t){const n=(0,i.validateBlockFieldValueExists)({usedBlocks:e,fieldType:t.fieldType,fieldValue:t.fieldValue,specifiedBlock:t.blockType});return[n.successfulBlocks,n.passed]}function m(e,t){const n=(0,c.validateVariableUsage)({usedBlocks:e,count:t.count,name:t.name}),i=[];for(const e of n.passingVarDefinitions.values())i.push(...e);return[i,n.passed]}n.runValidatorPlan=function e(t,n,i){const r=Date.now();let o=0,s=[];for(const r of n.checks){let n=!1;switch(r.validator){case"blocksExist":[s,n]=[...u(t,r)];break;case"commentsExist":n=p(t,r);break;case"blockCommentsExist":n=d(t,r);break;case"specificBlockCommentsExist":n=h(t,r);break;case"blocksInSetExist":[s,n]=[...f(t,r)];break;case"blockFieldValueExists":[s,n]=[...g(t,r)];break;case"variableUsage":[s,n]=[...m(t,r)];break;default:return pxt.debug(`Unrecognized validator: ${r.validator}`),pxt.tickEvent("validation.unrecognized_validator",{validator:r.validator}),{executionSuccess:!1,executionErrorMsg:lf("Unrecognized evaluation rule")}}if(n&&r.childValidatorPlans)for(const t of r.childValidatorPlans){let r=0;for(const n of s){const o=(0,l.getNestedChildBlocks)(n),s=i.find(e=>e.name===t);r+=e(o,s,i)?1:0}n=n&&r>0}o+=n?1:0}const a=o>=n.threshold;return pxt.tickEvent("validation.evaluation_complete",{plan:n.name,durationMs:Date.now()-r,passed:`${a}`}),{result:a,executionSuccess:!0}}},{"./getNestedChildBlocks":158,"./validateBlockFieldValueExists":161,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165,"./validateVariableUsage":166}],161:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlockFieldValueExists=void 0,n.validateBlockFieldValueExists=function({usedBlocks:e,fieldType:t,fieldValue:n,specifiedBlock:i}){const r=e.filter(e=>e.isEnabled()&&e.type===i).filter(e=>{var i;return"VAR"===t?(null===(i=e.getVarModels())||void 0===i?void 0:i[0].getName())===n:e.getFieldValue(t)===n});return{successfulBlocks:r,passed:r.length>0}}},{}],162:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlocksExist=void 0,n.validateBlocksExist=function({usedBlocks:e,requiredBlockCounts:t}){let n=[],i=[],r=[],o={};const s=null==e?void 0:e.reduce((e,t)=>(e[t.type]=(e[t.type]||0)+(t.isEnabled()?1:0),e),{});for(const[a,l]of Object.entries(t||{})){const t=s[a],c=e.filter(e=>e.isEnabled()&&e.type===a);c.length>0&&(o[a]=c),void 0===t?n.push(a):t?t<l&&r.push(a):i.push(a)}return{missingBlocks:n,disabledBlocks:i,insufficientBlocks:r,successfulBlocks:o,passed:0===n.length&&0===i.length&&0===r.length}}},{}],163:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlocksInSetExist=void 0,n.validateBlocksInSetExist=function({usedBlocks:e,blockIdsToCheck:t,count:n,requireUnique:i}){const r=[],o=e.filter(e=>e.isEnabled());for(const e of t){const t=o.filter(t=>t.type===e);i&&t.length>=1?r.push(t[0]):r.push(...t)}return{successfulBlocks:r,passed:r.length>=n}}},{}],164:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateCommentsExist=n.validateWorkspaceCommentsExist=n.validateBlockCommentsExist=void 0;const i=e("blockly");function r(e){return e.filter(e=>!!e.getCommentText())}function o(e){var t,n,r;const o=null!==(n=null===(t=e[0])||void 0===t?void 0:t.workspace)&&void 0!==n?n:i.getMainWorkspace();return(null!==(r=null==o?void 0:o.getTopComments())&&void 0!==r?r:[]).filter(e=>!!e.getText())}n.validateBlockCommentsExist=function({usedBlocks:e,numRequired:t}){const n=r(e);return{commentedBlocks:n,passed:n.length>=t}},n.validateWorkspaceCommentsExist=function({usedBlocks:e,numRequired:t}){const n=o(e);return{workspaceComments:n,passed:n.length>=t}},n.validateCommentsExist=function({usedBlocks:e,numRequired:t}){const n=[...r(e),...o(e)];return{comments:n,passed:n.length>=t}}},{blockly:192}],165:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSpecificBlockCommentsExist=void 0,n.validateSpecificBlockCommentsExist=function({usedBlocks:e,blockType:t}){const n=e.filter(e=>e.type===t),i=n.filter(e=>!e.getCommentText());return{uncommentedBlocks:i,passed:0!==n.length&&0===i.length}}},{}],166:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateVariableUsage=void 0,n.validateVariableUsage=function({usedBlocks:e,count:t,name:n}){const i=new Map,r=new Set;for(const t of e){if(!t.isEnabled())continue;const e=t.getVarModels();for(const o of null!=e?e:[]){const e=o.getName();n&&e!==n||("variables_set"===t.type||"variables_change"===t.type?(i.has(e)||i.set(e,[]),i.get(e).push(t)):r.add(e))}}const o=new Map;for(const[e,t]of i)r.has(e)&&o.set(e,t);return{passingVarDefinitions:o,passed:o.size>=t}}},{}],167:[function(e,t,n){let i;Object.defineProperty(n,"__esModule",{value:!0}),n.isBlocks=n.initEditorExtensionsAsync=n.HELP_IMAGE_URI=void 0,n.HELP_IMAGE_URI="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIHZpZXdCb3g9IjAgMCAyNiAyNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTMiIGN5PSIxMyIgcj0iMTMiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xNy45NTIgOS4xODQwMkMxNy45NTIgMTAuMjU2IDE3LjgxNiAxMS4wNzIgMTcuNTQ0IDExLjYzMkMxNy4yODggMTIuMTkyIDE2Ljc1MiAxMi43OTIgMTUuOTM2IDEzLjQzMkMxNS4xMiAxNC4wNzIgMTQuNTc2IDE0LjU4NCAxNC4zMDQgMTQuOTY4QzE0LjA0OCAxNS4zMzYgMTMuOTIgMTUuNzM2IDEzLjkyIDE2LjE2OFYxNi45NkgxMS44MDhDMTEuNDI0IDE2LjQ2NCAxMS4yMzIgMTUuODQgMTEuMjMyIDE1LjA4OEMxMS4yMzIgMTQuNjg4IDExLjM4NCAxNC4yODggMTEuNjg4IDEzLjg4OEMxMS45OTIgMTMuNDg4IDEyLjUzNiAxMi45NjggMTMuMzIgMTIuMzI4QzE0LjEwNCAxMS42NzIgMTQuNjI0IDExLjE2OCAxNC44OCAxMC44MTZDMTUuMTM2IDEwLjQ0OCAxNS4yNjQgOS45NjgwMiAxNS4yNjQgOS4zNzYwMkMxNS4yNjQgOC4yMDgwMiAxNC40MTYgNy42MjQwMiAxMi43MiA3LjYyNDAyQzExLjc2IDcuNjI0MDIgMTAuNzUyIDcuNzM2MDIgOS42OTYgNy45NjAwMkw5LjE0NCA4LjA4MDAyTDkgNi4wODgwMkMxMC40ODggNS41NjAwMiAxMS44NCA1LjI5NjAyIDEzLjA1NiA1LjI5NjAyQzE0LjczNiA1LjI5NjAyIDE1Ljk2OCA1LjYwODAyIDE2Ljc1MiA2LjIzMjAyQzE3LjU1MiA2Ljg0MDAyIDE3Ljk1MiA3LjgyNDAyIDE3Ljk1MiA5LjE4NDAyWk0xMS40IDIyVjE4LjY0SDE0LjE4NFYyMkgxMS40WiIgZmlsbD0iIzU5NUU3NCIvPgo8L3N2Zz4K",n.initEditorExtensionsAsync=function(){if(!i&&(i=Promise.resolve(),pxt.appTarget&&pxt.appTarget.appTheme&&pxt.appTarget.appTheme.extendFieldEditors)){const e={};i=i.then(()=>pxt.BrowserUtils.loadBlocklyAsync()).then(()=>pxt.BrowserUtils.loadScriptAsync("fieldeditors.js")).then(()=>pxt.editor.initFieldExtensionsAsync(e)).then(e=>{e.fieldEditors&&e.fieldEditors.forEach(e=>{pxt.blocks.registerFieldEditor(e.selector,e.editor,e.validator)})})}return i},n.isBlocks=function(e){return pxt.U.endsWith(e.name,".blocks")}},{}],168:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.postHostMessageAsync=n.shouldPostHostMessages=n.enableControllerAnalytics=n.bindEditorMessages=void 0;const i=e("./code-validation/runValidatorPlan"),r=e("../pxtservices/iframeEmbeddedClient"),o=e("./projectImport"),s={};let a;n.bindEditorMessages=function(e){const t=pxt.appTarget.appTheme.allowParentController||pxt.shell.isControllerMode(),n=pxt.appTarget.appTheme.allowPackageExtensions,l=pxt.appTarget.appTheme.allowSimulatorTelemetry;if(!t&&!n&&!l)return;a=new r.IFrameEmbeddedClient(r=>{const a=r.data;if(!a||!/^pxt(host|editor|pkgext|sim)$/.test(a.type))return!1;if("pxtpkgext"===a.type&&n)e().then(e=>{e.handleExtensionRequest(a)});else if("pxtsim"===a.type&&l){const e=a;"event"===e.action&&(e.category||e.message?pxt.reportError(e.category,e.message,e.data):pxt.tickEvent(e.tick,e.data))}else if(t){let t,n=Promise.resolve();if("pxthost"==a.type){const e=s[a.id];e?n=n.then(()=>e.resolve(a)):pxt.debug(`pxthost: unknown request ${a.id}`)}else"pxteditor"==a.type&&(n=n.then(()=>e().then(e=>{const n=a;switch(pxt.debug(`pxteditor: ${n.action}`),n.action.toLowerCase()){case"switchjavascript":return Promise.resolve().then(()=>e.openJavaScript());case"switchpython":return Promise.resolve().then(()=>e.openPython());case"switchblocks":return Promise.resolve().then(()=>e.openBlocks());case"startsimulator":return Promise.resolve().then(()=>e.startSimulator());case"restartsimulator":return Promise.resolve().then(()=>e.restartSimulator());case"hidesimulator":return Promise.resolve().then(()=>e.collapseSimulator());case"showsimulator":return Promise.resolve().then(()=>e.expandSimulator());case"closeflyout":return Promise.resolve().then(()=>e.closeFlyout());case"unloadproject":return Promise.resolve().then(()=>e.unloadProjectAsync());case"saveproject":return e.saveProjectAsync();case"compile":return e.compile();case"redo":return Promise.resolve().then(()=>{const t=e.editor;t&&t.hasRedo()&&t.redo()});case"undo":return Promise.resolve().then(()=>{const t=e.editor;t&&t.hasUndo()&&t.undo()});case"setscale":{const t=a;return Promise.resolve().then(()=>e.editor.setScale(t.scale))}case"stopsimulator":{const t=a;return Promise.resolve().then(()=>e.stopSimulator(t.unload))}case"newproject":{const t=a;return Promise.resolve().then(()=>e.newProject(t.options))}case"importproject":{const t=a;return Promise.resolve().then(()=>e.importProjectAsync(t.project,{filters:t.filters,searchBar:t.searchBar}))}case"importexternalproject":{const e=a;return(0,o.saveProjectAsync)(e.project).then(e=>{const n=location.origin+location.pathname+`#embedimport:${e}`;t={importUrl:n}})}case"openheader":{const t=a;return e.openProjectByHeaderIdAsync(t.headerId)}case"startactivity":{const t=a;let n,i=t.path;return/^([jt]s|py|blocks?):/i.test(i)&&(n=/^py:/i.test(i)?pxt.PYTHON_PROJECT_NAME:/^[jt]s:/i.test(i)?pxt.JAVASCRIPT_PROJECT_NAME:pxt.BLOCKS_PROJECT_NAME,i=i.substr(i.indexOf(":")+1)),Promise.resolve().then(()=>e.startActivity({activity:t.activityType,path:i,title:t.title,editor:n,previousProjectHeaderId:t.previousProjectHeaderId,carryoverPreviousCode:t.carryoverPreviousCode}))}case"importtutorial":{const t=a;return Promise.resolve().then(()=>e.importTutorialAsync(t.markdown))}case"proxytosim":{const t=a;return Promise.resolve().then(()=>e.proxySimulatorMessage(t.content))}case"renderblocks":{const n=a;return Promise.resolve().then(()=>e.renderBlocksAsync(n)).then(e=>e.xml.then(e=>{t=e.xml}))}case"renderxml":{const n=a;return Promise.resolve().then(()=>e.renderXml(n).resultXml.then(e=>{t=e.xml}))}case"renderbyblockid":{const n=a;return Promise.resolve().then(()=>e.renderByBlockIdAsync(n)).then(e=>e.resultXml.then(e=>{t=e.xml}))}case"runeval":{const n=a,r=n.validatorPlan,o=n.planLib;return Promise.resolve().then(()=>{const t=e.getBlocks();return(0,i.runValidatorPlan)(t,r,o)}).then(e=>{t=e})}case"gettoolboxcategories":{const n=a;return Promise.resolve().then(()=>{t=e.getToolboxCategories(n.advanced)})}case"getblockastext":{const n=a;return Promise.resolve().then(()=>{const i=e.getBlockAsText(n.blockId);t={blockAsText:i}})}case"renderpython":{const n=a;return Promise.resolve().then(()=>e.renderPythonAsync(n)).then(e=>{t=e.python})}case"toggletrace":{const t=a;return Promise.resolve().then(()=>e.toggleTrace(t.intervalSpeed))}case"settracestate":{const t=a;return Promise.resolve().then(()=>e.setTrace(t.enabled,t.intervalSpeed))}case"setsimulatorfullscreen":{const t=a;return Promise.resolve().then(()=>e.setSimulatorFullScreen(t.enabled))}case"showthemepicker":return Promise.resolve().then(()=>e.showThemePicker());case"togglehighcontrast":return Promise.resolve().then(()=>e.toggleHighContrast());case"sethighcontrast":{const t=a;return Promise.resolve().then(()=>e.setHighContrast(t.on))}case"togglegreenscreen":return Promise.resolve().then(()=>e.toggleGreenScreen());case"togglekeyboardcontrols":return Promise.resolve();case"print":return Promise.resolve().then(()=>e.printCode());case"pair":return e.pairAsync().then(()=>{});case"info":return Promise.resolve().then(()=>{t={versions:pxt.appTarget.versions,locale:ts.pxtc.Util.userLanguage(),availableLocales:pxt.appTarget.appTheme.availableLocales,keyboardControls:!0}});case"shareproject":{const n=a;return e.anonymousPublishHeaderByIdAsync(n.headerId,n.projectName).then(e=>{t=e})}case"savelocalprojectstocloud":{const n=a;return e.saveLocalProjectsToCloudAsync(n.headerIds).then(e=>{t={headerIdMap:e}})}case"requestprojectcloudstatus":{const t=a;return e.requestProjectCloudStatus(t.headerIds)}case"convertcloudprojectstolocal":{const t=a;return e.convertCloudProjectsToLocal(t.userId)}case"setlanguagerestriction":{const t=a;if("no-blocks"===t.restriction)throw pxt.warn("no-blocks language restriction is not supported"),new Error("no-blocks language restriction is not supported");return e.setLanguageRestrictionAsync(t.restriction)}case"precachetutorial":{const e=a,t=e.data,n=e.lang||pxt.Util.userLanguage();return pxt.github.db.cacheReposAsync(t).then(async()=>{if("string"==typeof t.markdown){const e=await pxt.BrowserUtils.translationDbAsync();await e.setAsync(n,t.path,void 0,void 0,t.markdown)}})}case"setcolorthemebyid":{const t=a;return e.setColorThemeById(t.colorThemeId,!!t.savePreference),Promise.resolve()}}return Promise.resolve()})));n.then(()=>c(a,t,!0,void 0),e=>c(a,t,!1,e))}return!0})};let l=!1;function c(e,t,n,i){if(e.response){const r={type:e.type,id:e.id,resp:t,success:n,error:i};a?a.postMessage(r):window.parent.postMessage(r,"*")}}function u(e){return new Promise((t,n)=>{const i=pxt.Util.clone(e);if(i.id=ts.pxtc.Util.guidGen(),e.response&&(s[i.id]={resolve:t,reject:n}),a?a.postMessage(i):window.parent.postMessage(i,"*"),pxt.commands.onPostHostMessage)try{pxt.commands.onPostHostMessage(i)}catch(e){pxt.reportException(e)}e.response||t(void 0)})}n.enableControllerAnalytics=function(){if(l)return;const e=!!pxt.commands.onPostHostMessage,t=pxt.appTarget.appTheme.allowParentController,n=pxt.BrowserUtils.isIFrame();if(!(e||t&&n))return;const i=pxt.tickEvent;pxt.tickEvent=function(e,t,n){i&&i(e,t,n),u({type:"pxthost",action:"event",tick:e,response:!1,data:t})};const r=pxt.reportException;pxt.reportException=function(e,t){r&&r(e,t);try{u({type:"pxthost",action:"event",tick:"error",message:e.message,response:!1,data:t})}catch(e){}};const o=pxt.reportError;pxt.reportError=function(e,t,n){o&&o(e,t,n),u({type:"pxthost",action:"event",tick:"error",category:e,message:t,data:n})},l=!0},n.shouldPostHostMessages=function(){return pxt.appTarget.appTheme.allowParentController&&pxt.BrowserUtils.isIFrame()},n.postHostMessageAsync=u},{"../pxtservices/iframeEmbeddedClient":185,"./code-validation/runValidatorPlan":160,"./projectImport":180}],169:[function(e,t,n){function i(e){return`experiments-${"object"==typeof e?e.id:e}`}let r;function o(){const e=pxt.savedAppTheme(),t={},n=s();return n.forEach(n=>{const i=a(n);e[n.id]=!!i,i&&(t[n.id]=i?1:0)}),n.length&&Object.keys(t).length&&(pxt.tickEvent("experiments.loaded",t),pxt.reloadAppTargetVariant()),pxt.appTarget.appTheme}function s(){const e=pxt.appTarget.appTheme.experiments;if(!e)return[];return[{id:"print",name:lf("Print Code"),description:lf("Print the code from the current project"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4740"},{id:"greenScreen",name:lf("Green screen"),description:lf("Display a webcam video stream or a green background behind the code."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4738"},{id:"allowPackageExtensions",name:lf("Editor Extensions"),description:lf("Allow Extensions to add buttons in the editor."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4741"},{id:"instructions",name:lf("Wiring Instructions"),description:lf("Generate step-by-step assembly instructions for breadboard wiring."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4739"},{id:"debugger",name:lf("Debugger"),description:lf("Step through code and inspect variables in the debugger"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4729"},{id:"bluetoothUartConsole",name:"Bluetooth Console",description:lf("Receives UART message through Web Bluetooth"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4796"},{id:"bluetoothPartialFlashing",name:"Bluetooth Download",description:lf("Download code via Web Bluetooth"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4807"},{id:"simScreenshot",name:lf("Simulator Screenshots"),description:lf("Download screenshots of the simulator"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5232"},{id:"python",name:lf("Static Python"),description:lf("Use Static Python to code your device"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5390"},{id:"simGif",name:lf("Simulator Gifs"),description:lf("Download gifs of the simulator"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5297"},{id:"qrCode",name:lf("Shared QR Code"),description:lf("Generate a QR Code form the shared project url"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5456"},{id:"importExtensionFiles",name:lf("Import Extension Files"),description:lf("Import Extensions from compiled project files")},{id:"debugExtensionCode",name:lf("Debug Extension Code"),description:lf("Use the JavaScript debugger to debug extension code")},{id:"advancedBlockDebugger",name:lf("Advanced Blocks Debugger"),description:lf("Enables extra options and variables in the Blocks debugger")},{id:"snippetBuilder",name:lf("Snippet Builder"),description:lf("Try out the new snippet dialogs.")},{id:"experimentalHw",name:lf("Experimental Hardware"),description:lf("Enable support for hardware marked 'experimental' in the hardware seletion dialog")},{id:"checkForHwVariantWebUSB",name:lf("Detect Hardware with WebUSB"),description:lf("When compiling, use WebUSB to detect hardware configuration.")},{id:"githubEditor",name:lf("GitHub editor"),description:lf("Review, commit and push to GitHub."),feedbackUrl:"https://github.com/microsoft/pxt/issues/6419",enableOnline:!0},{id:"githubCompiledJs",name:lf("GitHub Pages JavaScript"),description:lf("Commit compiled javascript when creating a release"),enableOnline:!0},{id:"blocksCollapsing",name:lf("Collapse blocks"),description:lf("Collapse and expand functions or event blocks")},{id:"tutorialBlocksDiff",name:lf("Tutorial Block Diffs"),description:lf("Automatially render blocks diff in tutorials")},{id:"openProjectNewTab",name:lf("Open in New Tab"),description:lf("Open an editor in a new tab.")},{id:"openProjectNewDependentTab",name:lf("Open in New Connected Tab"),description:lf("Open connected editors in different browser tabs.")},{id:"errorList",name:lf("Error List"),description:lf("Show an error list panel for JavaScript and Python.")},{id:"timeMachine",name:lf("Time Machine"),description:lf("Save and restore past versions of a project")},{id:"forceEnableAiErrorHelp",name:lf("AI Error Explainer"),description:lf("Get AI's help explaining errors in your code"),feedbackUrl:"https://github.com/microsoft/pxt/issues/10694",enableOnline:!0}].filter(t=>e.indexOf(t.id)>-1).concat(r||[]).filter(e=>!(pxt.BrowserUtils.isPxtElectron()&&e.enableOnline))}function a(e){return!!pxt.storage.getLocal(i(e))}function l(e,t){t!=a(e)&&(t?pxt.storage.setLocal(i(e),"1"):pxt.storage.removeLocal(i(e)),o())}Object.defineProperty(n,"__esModule",{value:!0}),n.setState=n.state=n.toggle=n.isEnabled=n.someEnabled=n.clear=n.all=n.syncTheme=n.setEditorExtensionExperiments=void 0,n.setEditorExtensionExperiments=function(e){r=e},n.syncTheme=o,n.all=s,n.clear=function(){s().forEach(e=>pxt.storage.removeLocal(i(e))),o()},n.someEnabled=function(){return s().some(e=>a(e))},n.isEnabled=a,n.toggle=function(e){e.onClick?e.onClick():l(e,!a(e))},n.state=function(){const e={};return s().forEach(t=>e[t.id]=a(t)),JSON.stringify(e)},n.setState=l},{}],170:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.patchConfigEditorVersion=n.getTextAtTime=n.updateShareHistory=n.pushSnapshotOnHistory=n.updateHistory=n.parseHistoryFile=n.applySnapshot=n.createSnapshot=n.applyDiff=n.diffScriptText=n.collapseHistory=void 0;const i=18e5,r=864e5;function o(e,t,n,i,r){const o=[],l=e.entries.slice();let c=Object.assign({},t),{interval:u,minTime:d,maxTime:p}=n;void 0===d&&(d=0),void 0===p&&(p=e.lastSaveTime);let h=Object.assign({},c),f=e.lastSaveTime;for(;l.length;){const e=l.pop();c=a(c,e,r),e.timestamp>p?(o.unshift(e),h=Object.assign({},c),f=e.timestamp):e.timestamp<d?h?(o.unshift({timestamp:e.timestamp,editorVersion:e.editorVersion,changes:s(c,h,e.timestamp,i).changes}),h=void 0):o.unshift(e):f-e.timestamp>=u&&(o.unshift({timestamp:e.timestamp,editorVersion:e.editorVersion,changes:s(c,h,e.timestamp,i).changes}),h=Object.assign({},c),f=e.timestamp)}return h&&f>e.entries[0].timestamp&&o.unshift({timestamp:e.entries[0].timestamp,editorVersion:e.entries[0].editorVersion,changes:s(c,h,e.entries[0].timestamp,i).changes}),Object.assign(Object.assign({},e),{entries:o})}function s(e,t,n,i){var r,o;const s=[];for(const n of Object.keys(e))(n.endsWith(".ts")||n.endsWith(".jres")||n.endsWith(".py")||n.endsWith(".blocks")||"pxt.json"===n)&&(null==t[n]?s.push({type:"removed",filename:n,value:e[n]}):e[n]!==t[n]&&s.push({type:"edited",filename:n,patch:i(t[n],e[n])}));for(const n of Object.keys(t))(n.endsWith(".ts")||n.endsWith(".jres")||n.endsWith(".py")||n.endsWith(".blocks")||"pxt.json"===n)&&null==e[n]&&s.push({type:"added",filename:n,value:t[n]});if(s.length)return{timestamp:n,editorVersion:null===(o=null===(r=pxt.appTarget)||void 0===r?void 0:r.versions)||void 0===o?void 0:o.target,changes:s}}function a(e,t,n){const i=Object.assign({},e);for(const r of t.changes)"added"===r.type?delete i[r.filename]:"removed"===r.type?i[r.filename]=r.value:i[r.filename]=n(r.patch,e[r.filename]);return i}function l(e){let t;try{t={};const n=JSON.parse(e[pxt.CONFIG_NAME]);for(const i of n.files)i===pxt.IMAGES_CODE||i===pxt.TILEMAP_CODE?t[i]="":t[i]=e[i];if(t[pxt.CONFIG_NAME]=e[pxt.CONFIG_NAME],n.preferredEditor===pxt.BLOCKS_PROJECT_NAME?t[pxt.MAIN_BLOCKS]&&(t[pxt.MAIN_TS]=""):n.preferredEditor===pxt.PYTHON_PROJECT_NAME&&t[pxt.MAIN_PY]&&(t[pxt.MAIN_TS]=""),n.testFiles)for(const i of n.testFiles)t[i]=e[i]}catch(n){t=Object.assign({},e)}return t[pxt.HISTORY_FILE]&&delete t[pxt.HISTORY_FILE],t}function c(e){const t=JSON.parse(e);return t.entries||(t.entries=[]),t.shares||(t.shares=[]),t.snapshots||(t.snapshots=[]),t}function u(e,t){e=Object.assign({},e);try{const n=JSON.parse(e[pxt.CONFIG_NAME]);n.targetVersions&&(n.targetVersions.target=t),e[pxt.CONFIG_NAME]=JSON.stringify(n,null,4)}catch(e){}return{files:e,editorVersion:t}}function d(e,t){return{timestamp:t,editorVersion:pxt.appTarget.versions.target,text:l(e)}}function p(){var e,t;return null!=(null===(t=null===(e=pxt.appTarget)||void 0===e?void 0:e.appTheme)||void 0===t?void 0:t.timeMachineDiffInterval)?pxt.appTarget.appTheme.timeMachineDiffInterval:3e5}n.collapseHistory=function(e,t,n,i){if(!e[pxt.HISTORY_FILE])return;const r=o(c(e[pxt.HISTORY_FILE]),e,t,n,i);e[pxt.HISTORY_FILE]=JSON.stringify(r)},n.diffScriptText=s,n.applyDiff=a,n.createSnapshot=l,n.applySnapshot=function(e,t){var n;try{const i=Object.assign({},t),r=JSON.parse(e[pxt.CONFIG_NAME]);for(const t of Object.keys(e))t!==pxt.HISTORY_FILE&&(-1!==r.files.indexOf(t)||-1!==(null===(n=r.testFiles)||void 0===n?void 0:n.indexOf(t))||i[t]||(i[t]=e[t]));return i}catch(n){const i=Object.assign({},e);for(const e of Object.keys(t))i[e]=t[e];return i}},n.parseHistoryFile=c,n.updateHistory=function(e,t,n,l,u,h,f=!1){let g;e[pxt.HISTORY_FILE]?(g=c(e[pxt.HISTORY_FILE]),void 0===g.lastSaveTime&&(g.lastSaveTime=n)):g={entries:[],snapshots:[d(e,n-1)],shares:[],lastSaveTime:n};const m=g.lastSaveTime;for(const e of l)g.shares.some(t=>t.id===e.id)||g.shares.push({id:e.id,timestamp:n});if(function(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n){if(-1===i.indexOf(r))return!1;if(e[r]!==t[r])return!1}return!0}(e,t))return void(t[pxt.HISTORY_FILE]=JSON.stringify(g));let _=!1;if(1===g.entries.length){n-g.entries[g.entries.length-1].timestamp<p()&&(_=!0)}else if(g.entries.length>1){const e=g.entries[g.entries.length-1].timestamp,t=g.entries[g.entries.length-2].timestamp;n-e<p()&&e-t<p()&&(_=!0)}if(_){const n=g.entries.pop(),i=s(a(e,n,h),t,n.timestamp,u);i&&g.entries.push(i)}else{const n=s(e,t,g.lastSaveTime,u);n&&g.entries.push(n)}if(f&&Math.floor(m/r)!==Math.floor(n/r)&&(g=o(g,t,{interval:72e5,maxTime:n-r},u,h)),g.lastSaveTime=n,0==g.snapshots.length)g.snapshots.push(d(e,n-1));else if(n-g.snapshots[g.snapshots.length-1].timestamp>=function(){var e,t;if(null!=(null===(t=null===(e=pxt.appTarget)||void 0===e?void 0:e.appTheme)||void 0===t?void 0:t.timeMachineSnapshotInterval))return pxt.appTarget.appTheme.timeMachineSnapshotInterval;return i}()){g.snapshots.push(d(e,n));const t=[];let i=Math.floor(n/r)*r;for(let e=0;e<g.snapshots.length;e++){const o=g.snapshots[g.snapshots.length-1-e];n-o.timestamp<r||e===g.snapshots.length-1?t.unshift(o):o.timestamp<i&&(t.unshift(o),i=Math.floor(o.timestamp/r)*r)}g.snapshots=t}for(const e of g.snapshots)e.text[pxt.HISTORY_FILE]&&delete e.text[pxt.HISTORY_FILE];t[pxt.HISTORY_FILE]=JSON.stringify(g)},n.pushSnapshotOnHistory=function(e,t){let n;n=e[pxt.HISTORY_FILE]?c(e[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:t},n.snapshots.push(d(e,t)),e[pxt.HISTORY_FILE]=JSON.stringify(n)},n.updateShareHistory=function(e,t,n){let i;i=e[pxt.HISTORY_FILE]?c(e[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:t};for(const e of n)i.shares.some(t=>t.id===e.id)||i.shares.push({id:e.id,timestamp:t});e[pxt.HISTORY_FILE]=JSON.stringify(i)},n.getTextAtTime=function(e,t,n,i){let r=Object.assign({},e);for(let e=0;e<t.entries.length;e++){const o=t.entries.length-1-e,s=t.entries[o];if(r=a(r,s,i),s.timestamp===n){return u(r,o>0?t.entries[o-1].editorVersion:s.editorVersion)}}return{files:r,editorVersion:pxt.appTarget.versions.target}},n.patchConfigEditorVersion=u},{}],171:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.importDb=n.validation=n.experiments=n.workspace=n.monaco=n.history=void 0;const o=e("./history");n.history=o;const s=e("./monaco");n.monaco=s;const a=e("./workspace");n.workspace=a;const l=e("./experiments");n.experiments=l;const c=e("./code-validation");n.validation=c;const u=e("./projectImport");n.importDb=u,r(e("./editor"),n),r(e("./editorcontroller"),n),r(e("./monaco-fields/monacoFieldEditor"),n),r(e("./monaco-fields/field_tilemap"),n),r(e("./monaco-fields/field_musiceditor"),n),r(e("./monaco-fields/field_soundEffect"),n),r(e("./monaco-fields/field_sprite"),n),r(e("./monaco-fields/field_animation"),n),r(e("./monaco-fields/field_react"),n)},{"./code-validation":159,"./editor":167,"./editorcontroller":168,"./experiments":169,"./history":170,"./monaco":179,"./monaco-fields/field_animation":172,"./monaco-fields/field_musiceditor":173,"./monaco-fields/field_react":174,"./monaco-fields/field_soundEffect":175,"./monaco-fields/field_sprite":176,"./monaco-fields/field_tilemap":177,"./monaco-fields/monacoFieldEditor":178,"./projectImport":180,"./workspace":181}],172:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.animationEditorDefinition=n.MonacoAnimationEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="animation-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`");const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject(),r=i.lookupAssetByName("animation",n);if(r)return this.editing=r,r;{const e=i.createNewAnimation();return n&&!i.isNameTaken("animation",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("animation"),this.editing=e,e}}}resultToText(e){const t=pxt.react.getTilemapProject();return t.pushUndo(),e=pxt.patchTemporaryAsset(this.editing,e,t),e=t.updateAsset(e),pxt.getTSReferenceForAsset(e,this.isPython)}getFieldEditorId(){return o}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}n.MonacoAnimationEditor=s;const a=["assets\\s*\\.\\s*animation\\s*`[^`]*`",'assets\\s*\\.\\s*animation\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.animationEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.animationEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],173:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.songEditorDefinition=n.MonacoSongEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="music-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`"),this.text=e;const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject();this.isAsset=!0;const r=i.lookupAssetByName("song",n);if(r)return this.editing=r,r;{const e=i.createNewSong(pxt.assets.music.getEmptySong(2));return n&&!i.isNameTaken("song",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("song"),this.editing=e,e}}const n=/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m.exec(e);if(n){const e=n[1].trim();return this.editing=a(e?pxt.assets.music.decodeSongFromHex(e):pxt.assets.music.getEmptySong(2)),this.editing}}resultToText(e){var t;const n=pxt.react.getTilemapProject();if(n.pushUndo(),null===(t=(e=pxt.patchTemporaryAsset(this.editing,e,n)).meta)||void 0===t?void 0:t.displayName){e=this.isAsset||n.lookupAsset(e.type,e.id)?n.updateAsset(e):n.createNewSong(e.song,e.meta.displayName);let t=pxt.getTSReferenceForAsset(e,this.isPython);return this.isAsset||(t=this.isPython?`music.create_song(${t})`:`music.createSong(${t})`),t}let i=pxt.assets.music.encodeSongToHex(e.song);return i=this.isPython?`hex("""${i}""")`:"hex`"+i+"`",this.text.replace(/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m,i)}getFieldEditorId(){return o}getOptions(){return{blocksInfo:this.host.blocksInfo()}}}function a(e){return{type:"song",id:"",internalID:0,meta:{},song:e}}n.MonacoSongEditor=s;const l=["music\\s*\\.\\s*createSong\\s*\\(\\s*hex`[a-fA-F0-9\\s\\n]*`\\s*\\)","assets\\s*\\.\\s*song\\s*`[^`]*`",'music\\s*\\.\\s*create_song\\s*\\(\\s*hex\\s*\\(\\s*"""[a-fA-F0-9\\s\\n]*"""\\s*\\)\\s*\\)','music\\s*\\.\\s*createSong\\s*\\(\\s*hex\\s*\\(\\s*"""[a-fA-F0-9\\s\\n]*"""\\s*\\)\\s*\\)','assets\\s*\\.\\s*song\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.songEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:l,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.songEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],174:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MonacoReactFieldEditor=void 0;n.MonacoReactFieldEditor=class{getId(){return"image-editor"}showEditorAsync(e,t,n){return this.fileType=e,this.editrange=t,this.host=n,this.initAsync().then(()=>{const e=this.textToValue(n.getText(t));return e?(this.fv=pxt.react.getFieldEditorView(this.getFieldEditorId(),e,this.getOptions()),this.fv.onHide(()=>{this.onClosed()}),this.fv.show(),new Promise((e,t)=>{this.resolver=e,this.rejecter=t})):Promise.resolve(null)})}onClosed(){this.resolver&&(this.resolver({range:this.editrange,replacement:this.resultToText(this.fv.getResult())}),this.editrange=void 0,this.resolver=void 0,this.rejecter=void 0)}dispose(){this.onClosed()}initAsync(){return Promise.resolve()}textToValue(e){return null}resultToText(e){return e+""}getFieldEditorId(){return""}getOptions(){return null}}},{}],175:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.soundEditorDefinition=n.MonacoSoundEffectEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="soundeffect-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){const t={wave:"sine",startFrequency:5e3,endFrequency:0,startVolume:255,endVolume:0,duration:500,effect:"none",interpolation:"linear"};this.value=t;const n=/\(([^)]*)\)/.exec(e)[1].split(",").map(e=>e.replace(/\s/g,""));if(8!==n.length)return t;switch(n[0]){case"WaveShape.Sawtooth":t.wave="sawtooth";break;case"WaveShape.Square":t.wave="square";break;case"WaveShape.Noise":t.wave="noise";break;case"WaveShape.Triangle":t.wave="triangle";break;default:t.wave="sine"}const i=(e,t)=>isNaN(e)?t:e;switch(t.startFrequency=i(parseInt(n[1]),t.startFrequency),t.endFrequency=i(parseInt(n[2]),t.endFrequency),t.startVolume=i(parseInt(n[3]),t.startVolume),t.endVolume=i(parseInt(n[4]),t.endVolume),t.duration=i(parseInt(n[5]),t.duration),n[6]){case"SoundExpressionEffect.Vibrato":t.effect="vibrato";break;case"SoundExpressionEffect.Tremolo":t.effect="tremolo";break;case"SoundExpressionEffect.Warble":t.effect="warble";break;default:t.effect="none"}switch(n[7]){case"InterpolationCurve.Logarithmic":t.interpolation="logarithmic";break;case"InterpolationCurve.Curve":t.interpolation="curve";break;default:t.interpolation="linear"}return t}resultToText(e){let t,n,i;switch((e=this.value).wave){case"sine":t="WaveShape.Sine";break;case"square":t="WaveShape.Square";break;case"triangle":t="WaveShape.Triangle";break;case"noise":t="WaveShape.Noise";break;case"sawtooth":t="WaveShape.Sawtooth"}switch(e.effect){case"vibrato":n="SoundExpressionEffect.Vibrato";break;case"tremolo":n="SoundExpressionEffect.Tremolo";break;case"warble":n="SoundExpressionEffect.Warble";break;case"none":n="SoundExpressionEffect.None"}switch(e.interpolation){case"curve":i="InterpolationCurve.Curve";break;case"linear":i="InterpolationCurve.Linear";break;case"logarithmic":i="InterpolationCurve.Logarithmic"}return`music.createSoundEffect(${t}, ${Math.round(e.startFrequency)}, ${Math.round(e.endFrequency)}, ${Math.round(e.startVolume)}, ${Math.round(e.endVolume)}, ${Math.round(e.duration)}, ${n}, ${i})`}getFieldEditorId(){return o}getOptions(){return{onClose:()=>this.fv.hide(),onSoundChange:e=>this.value=e,initialSound:this.value,useFlex:!0,useMixerSynthesizer:"microbit"!==pxt.appTarget.id}}}n.MonacoSoundEffectEditor=s,n.soundEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:"music\\s*\\.\\s*createSoundEffect\\s*\\(",isRegex:!0,matchCase:!0,matchWholeWord:!1,validateRange:function(e,t){let n=e.startLineNumber,i=0,r=!1,o=0;const s="createSoundEffect",a=t.getLineCount();for(;n<a;){const a=t.getLineContent(n),l=a.indexOf(s);if(-1!==l&&(r=!0,i=l+17),r)for(;i<a.length;){const r=a.charAt(i);if("("===r)o++;else if(")"===r&&(o--,0===o))return new monaco.Range(e.startLineNumber,e.startColumn,n,i+t.getLineMinColumn(n)+1);i++}i=0,n++}}},proto:s},(0,r.registerMonacoFieldEditor)(o,n.soundEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],176:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.spriteEditorDefinition=n.MonacoSpriteEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="image-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`"),this.template=e.startsWith("bmp")?"bmp":"img";const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject();this.isAsset=!0;const r=i.lookupAssetByName("image",n);if(r)return this.editing=r,r;{const e=i.createNewImage();return n&&!i.isNameTaken("image",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("image"),this.editing=e,e}}return this.editing={type:"image",id:"",internalID:0,bitmap:pxt.sprite.imageLiteralToBitmap(e,this.template).data(),meta:{},jresData:""},this.editing}resultToText(e){var t;const n=pxt.react.getTilemapProject();return n.pushUndo(),(null===(t=(e=pxt.patchTemporaryAsset(this.editing,e,n)).meta)||void 0===t?void 0:t.displayName)?(e=this.isAsset||n.lookupAsset(e.type,e.id)?n.updateAsset(e):n.createNewProjectImage(e.bitmap,e.meta.displayName),this.isAsset=!0,pxt.getTSReferenceForAsset(e,this.isPython)):pxt.sprite.bitmapToImageLiteral(pxt.sprite.Bitmap.fromData(e.bitmap),this.isPython?"python":"typescript",this.template)}getFieldEditorId(){return"image-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}n.MonacoSpriteEditor=s;const a=["img\\s*`[\\.a-zA-Z0-9#\\n\\s]*`","bmp\\s*`[\\.a-zA-Z0-9#\\n\\s]*`","assets\\s*\\.\\s*image\\s*`[^`]*`",'img\\s*\\(\\s*"""[\\.a-zA-Z0-9#\\n\\s]*"""\\s*\\)','bmp\\s*\\(\\s*"""[\\.a-zA-Z0-9#\\n\\s]*"""\\s*\\)','assets\\s*\\.\\s*image\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.spriteEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.spriteEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],177:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.tilemapEditorDefinition=n.MonacoTilemapEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="tilemap-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){const t=this.readTilemap(e),n=pxt.react.getTilemapProject();return pxt.sprite.addMissingTilemapTilesAndReferences(n,t),this.editing=t,t}readTilemap(e){const t=pxt.react.getTilemapProject();if(/^\s*tiles\s*\./.test(e)&&(this.isTilemapLiteral=!1,e)){try{return function(e){return{type:"tilemap",id:"",internalID:0,meta:{},data:e}}(pxt.sprite.decodeTilemap(e,"typescript",t))}catch(e){}return null}this.isTilemapLiteral=!0;const n=/^\s*(tilemap(?:4|8|16|32)?)\s*(?:`([^`]*)`)|(?:\(\s*"""([^"]*)"""\s*\))\s*$/.exec(e),i=(n[2]||n[3]||"").trim();let r,o;if(this.tilemapLiteral=n[1],i&&(o=ts.pxtc.escapeIdentifier(i),r=t.getTilemap(o)||t.lookupAssetByName("tilemap",i)),!r){let e=16;"tilemap8"===this.tilemapLiteral?e=8:"tilemap32"===this.tilemapLiteral?e=32:"tilemap4"===this.tilemapLiteral&&(e=4);const[n]=t.createNewTilemap(o,e,16,16);r=t.getTilemap(n),o=n}return r}resultToText(e){const t=pxt.react.getTilemapProject();return t.pushUndo(),e=pxt.patchTemporaryAsset(this.editing,e,t),pxt.sprite.updateTilemapReferencesFromResult(t,e),this.isTilemapLiteral?(t.updateAsset(e),pxt.getTSReferenceForAsset(e,"python"===this.fileType)):pxt.sprite.encodeTilemap(e.data,"typescript"===this.fileType?"typescript":"python")}getFieldEditorId(){return"tilemap-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}getCreateTilemapRange(){const e=this.editrange.getStartPosition();let t,n=this.editrange.getEndPosition(),i=1;for(;;){t=new monaco.Range(n.lineNumber,n.column,n.lineNumber+1,0);const r=this.host.getText(t);for(let t=0;t<r.length;t++)if("("===r.charAt(t))i++;else if(")"===r.charAt(t)&&(i--,0===i)){const i=new monaco.Position(n.lineNumber,n.column+t+2);return monaco.Range.fromPositions(e,i)}if(n=t.getEndPosition(),n.lineNumber>e.lineNumber+20)return null}}}n.MonacoTilemapEditor=s,n.tilemapEditorDefinition={id:o,foldMatches:!0,alwaysBuildOnClose:!0,glyphCssClass:"sprite-focus-hover ms-Icon ms-Icon--Nav2DMapView",heightInPixels:510,weight:5,matcher:{searchString:'(?:tilemap(?:8|16|32)?\\s*(?:`|\\(""")(?:[^`"]|\\n)*\\s*(?:`|"""\\)))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))',isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.tilemapEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],178:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.getMonacoFieldEditor=n.registerMonacoFieldEditor=void 0;const i={};n.registerMonacoFieldEditor=function(e,t){i[e]=t},n.getMonacoFieldEditor=function(e){return i[e]}},{}],179:[function(e,t,n){function i(e){const t=pxt.appTarget.appTheme.invertedMonaco,n=!(!pxt.appTarget.appTheme.monacoFieldEditors||!pxt.appTarget.appTheme.monacoFieldEditors.length);let i=monaco.editor.create(e,{model:null,ariaLabel:pxt.Util.lf("JavaScript editor"),fontFamily:"'Consolas', 'Monaco', 'Menlo', 'Ubuntu Mono', 'source-code-pro', 'monospace'",scrollBeyondLastLine:!0,language:"typescript",mouseWheelZoom:!1,wordBasedSuggestions:!0,lineNumbersMinChars:3,formatOnPaste:!0,folding:n,glyphMargin:n||pxt.appTarget.appTheme.debugger,minimap:{enabled:!1},fixedOverflowWidgets:!0,autoIndent:"full",useTabStops:!0,dragAndDrop:!0,matchBrackets:"always",occurrencesHighlight:!1,quickSuggestionsDelay:200,theme:t?"vs-dark":"vs",renderIndentGuides:!0,accessibilityHelpUrl:"",quickSuggestions:{other:!0,comments:!0,strings:!0},acceptSuggestionOnCommitCharacter:!0,acceptSuggestionOnEnter:"on",accessibilitySupport:"on"});return i.layout(),i}Object.defineProperty(n,"__esModule",{value:!0}),n.createEditor=n.initMonacoAsync=n.syncModels=void 0,n.syncModels=function(e,t,n,i){if(i)return;let r=monaco.languages.typescript.typescriptDefaults.getExtraLibs(),o={};e.sortedDeps().forEach(e=>{e.getFiles().forEach(i=>{let r=e.id+"/"+i;if(/\.(ts)$/.test(i)&&r!=n){if(!monaco.languages.typescript.typescriptDefaults.getExtraLibs()[r]){let n=e.readFile(i)||"\n";t[r]=monaco.languages.typescript.typescriptDefaults.addExtraLib(n,r)}o[r]="1"}})}),Object.keys(r).filter(e=>/\.(ts)$/.test(e)&&!o[e]).forEach(e=>{t[e].dispose()})},n.initMonacoAsync=function(e){return new Promise((t,n)=>{if("object"==typeof window.monaco)return void t(i(e));let r=window.MonacoPaths,o=()=>{let n=window.require;n.config({paths:r}),n(["vs/editor/editor.main"],()=>{monaco.languages.register({id:"asm",extensions:[".asm"]}),monaco.languages.setMonarchTokensProvider("asm",{tokenPostfix:"",keywords:["movs","mov","adds","add","adcs","adr","subs","sbcs","sub","rsbs","muls","cmp","cmn","ands","eors","orrs","bics","mvns","tst","lsls","lsrs","asrs","rors","ldr","ldrh","ldrb","ldrsh","ldrsb","ldm","str","strh","strb","stm","push","pop","cbz","cbnz","b","bl","bx","blx","sxth","sxtb","uxth","uxtb","rev","rev16","revsh","svc","cpsid","cpsie","setend","bkpt","nop","sev","wfe","wfi","yield","beq","bne","bcs","bhs","bcc","blo","bmi","bpl","bvs","bvc","bhi","bls","bge","blt","bgt","ble","bal","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11","r12","r13","r14","r15","pc","sp","lr"],typeKeywords:[".startaddr",".hex",".short",".space",".section",".string",".byte"],operators:[],symbols:/[:\*]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/(\.)?[a-z_$\.][\w$]*/,{cases:{"@typeKeywords":"keyword","@keywords":"keyword","@default":"identifier"}}],{include:"@whitespace"},[/[{}()\[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/@\s*[a-zA-Z_\$][\w\$]*/,{token:"annotation"}],[/(#|(0[xX]))?[0-9a-fA-F]+/,"number"],[/[;,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/'[^\\']'/,"string"],[/(')(@escapes)(')/,["string","string.escape","string"]],[/'/,"string.invalid"]],comment:[],string:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/;.*$/,"comment"]]}}),monaco.languages.typescript&&(monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSyntaxValidation:!0,noSemanticValidation:!0}),monaco.languages.typescript.typescriptDefaults.setWorkerOptions({customWorkerPath:pxt.webConfig.typeScriptWorkerJs}),monaco.languages.typescript.typescriptDefaults.setCompilerOptions({allowUnreachableCode:!0,noImplicitAny:!0,allowJs:!1,allowUnusedLabels:!0,target:monaco.languages.typescript.ScriptTarget.ES5,outDir:"built",rootDir:".",noLib:!0,mouseWheelZoom:!1})),t(i(e))})};if(window.require)o();else{let e=document.createElement("script");e.type="text/javascript",e.src=r["vs/loader"],e.addEventListener("load",o),document.body.appendChild(e)}})},n.createEditor=i},{}],180:[function(e,t,n){let i;Object.defineProperty(n,"__esModule",{value:!0}),n.removeProjectAsync=n.saveProjectAsync=void 0;const r="projects";async function o(){if(i)return i;const e=pxt.appTarget.id+"-import";return i=new pxt.BrowserUtils.IDBWrapper(e,1,(e,t)=>{t.result.createObjectStore(r,{keyPath:"importId"})}),await i.openAsync(),i}n.saveProjectAsync=async function(e){const t={importId:pxt.U.guidGen(),project:e},n=await o();return await n.deleteAllAsync(r),await n.setAsync(r,t),t.importId},n.removeProjectAsync=async function(e){const t=await o(),n=await t.getAsync(r,e);return await t.deleteAllAsync(r),null==n?void 0:n.project}},{}],181:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.freshHeader=void 0,n.freshHeader=function(e,t){return{target:pxt.appTarget.id,targetVersion:pxt.appTarget.versions.target,name:e,meta:{},editor:pxt.JAVASCRIPT_PROJECT_NAME,pubId:"",pubCurrent:!1,_rev:null,id:pxt.U.guidGen(),recentUse:t,modificationTime:t,cloudUserId:null,cloudCurrent:!1,cloudVersion:null,cloudLastSyncTime:0,isDeleted:!1}}},{}],182:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("./runner"),r=e("./renderer"),o=e("../pxteditor");window.pxt||(window.pxt={}),window.pxt.runner=Object.assign(Object.assign({},i),r),window.pxt.editor=Object.assign({},o),function(){let e=window.ksRunnerWhenLoaded;e&&e()}()},{"../pxteditor":171,"./renderer":183,"./runner":184}],183:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.renderAsync=n.fireClickOnEnter=n.defaultClientRenderOptions=void 0;const i=e("./runner"),r=e("blockly"),o=e("../pxtblocks"),s=e("../pxtblocks/codecardRenderer");function a(){return{blocksAspectRatio:window.innerHeight<window.innerWidth?1.62:1/1.62,snippetClass:"lang-blocks",signatureClass:"lang-sig",blocksClass:"lang-block",blocksXmlClass:"lang-blocksxml",diffBlocksXmlClass:"lang-diffblocksxml",diffClass:"lang-diff",diffStaticPythonClass:"lang-diffspy",diffBlocksClass:"lang-diffblocks",staticPythonClass:"lang-spy",simulatorClass:"lang-sim",linksClass:"lang-cards",namespacesClass:"lang-namespaces",apisClass:"lang-apis",codeCardClass:"lang-codecard",packageClass:"lang-package",jresClass:"lang-jres",assetJSONClass:"lang-assetsjson",projectClass:"lang-project",snippetReplaceParent:!0,simulator:!0,showEdit:!0,hex:!0,tutorial:!1,showJavaScript:!1,hexName:pxt.appTarget.id}}function l(e){"undefined"!=typeof hljs&&(e.hasClass("highlight")?hljs.highlightBlock(e[0]):e.find("code.highlight").each(function(e,t){hljs.highlightBlock(t)}),c(e))}function c(e){e.find("span.hljs-comment:contains(@highlight)").each((e,t)=>{try{!function(e){const t=$(e),n=document.createElement("span");n.className="highlight-line";let i=e.nextSibling;if(!i||i.nodeType!=Node.TEXT_NODE)return;let r=i.textContent,o=r.indexOf("\n");if(o<0)return;i.textContent=r.substring(0,o+1),$(document.createTextNode(r.substring(o+1).replace(/^\s+/,""))).insertAfter($(i)),i=i.nextSibling;for(;i;){let e=i.nextSibling;if(i.nodeType==Node.TEXT_NODE){r=i.textContent;const t=r.indexOf("\n");if(!(t<0)){n.appendChild(document.createTextNode(r.substring(0,t))),i.textContent=r.substring(t+1);break}n.appendChild(i),i=e}else n.appendChild(i),i=e}$(n).insertAfter(t),t.remove()}(t)}catch(e){pxt.reportException(e)}})}function u(e,t){e.append($('<div class="ui content blocks"/>').append(t))}function d(e,t,n){e.append($('<div class="ui content js"><div class="subheading"><i class="ui icon xicon js"></i>JavaScript</div></div>').append(t)),l(t)}function p(e,t,n){e.append($('<div class="ui content py"><div class="subheading"><i class="ui icon xicon python"></i>Python</div></div>').append(t)),l(t)}function h(e,t){const n=$('<a class="item" role="button" tabindex="0"><i role="presentation" aria-hidden="true"></i><span class="ui desktop only"></span></a>');return n.attr("aria-label",e),n.attr("title",e),n.find("i").attr("class",t),n.find("span").text(e),n.keypress(f),n}function f(e){const t="number"==typeof e.which?e.which:e.keyCode;13!==t&&32!==t||(e.preventDefault(),e.currentTarget.click())}n.defaultClientRenderOptions=a,n.fireClickOnEnter=f;let g=!1;function m(e,t,n,i,r,o,s={}){let a=$('<div class="ui bottom attached tabular icon small compact menu hideprint"> <div class="right icon menu"></div></div>'),l=$('<div class="ui top attached segment codewidget"></div>'),c=a.find(".right.menu");const f=pxt.appTarget.appTheme||{};if(s.showEdit&&!f.hideDocsEdit&&o){const t=h(lf("Edit"),"edit icon"),{package:n,compileBlocks:s,compilePython:a}=o,l=n.host();if(r&&s?(n.setPreferredEditor(pxt.BLOCKS_PROJECT_NAME),l.writeFile(n,pxt.MAIN_BLOCKS,s.outfiles[pxt.MAIN_BLOCKS])):i&&a?(n.setPreferredEditor(pxt.PYTHON_PROJECT_NAME),l.writeFile(n,pxt.MAIN_PY,s.outfiles[pxt.MAIN_PY])):n.setPreferredEditor(pxt.JAVASCRIPT_PROJECT_NAME),e.assetJSON)for(const t of Object.keys(e.assetJSON))n.config.files.indexOf(t)<0&&n.config.files.push(t),l.writeFile(n,t,e.assetJSON[t]);const u=n.compressToFileAsync();t.click(()=>{pxt.tickEvent("docs.btn",{button:"edit"}),u.then(t=>{window.open(`${function(e){const t=e.pxtUrl||pxt.appTarget.appTheme.homeUrl;return(t||"").replace(/\/$/,"")}(e)}/#project:${ts.pxtc.encodeBase64(pxt.Util.uint8ArrayToString(t))}`,"pxt")})}),c.append(t)}if(e.showJavaScript||!r&&!i?(l.append(n),_(),b()):r?(l.append(r),y(),b()):i&&(l.append(i),_(),y()),s.run&&!f.hideDocsSimulator){let t=h(lf("Run"),"play icon").click(()=>{if(pxt.tickEvent("docs.btn",{button:"sim"}),l.find(".sim")[0])l.find(".sim").remove(),v(l);else{g||(g=!0,window.addEventListener("message",e=>{const t=e.data;if("aspectratio"!==t.type)return;const n=t.frameid,i=t.value,r=document.querySelector(`iframe[data-frameid="${n}"]`);(null==r?void 0:r.parentElement)&&(r.parentElement.style.paddingBottom=100/i+"%")}));let t="81.97%";pxt.appTarget.simulator&&(t=100/pxt.appTarget.simulator.aspectRatio+"%");const i=e.package?"&deps="+encodeURIComponent(e.package):"",r=C(e)+"#nofooter=1"+i,o=e.assetJSON?`data-assets="${encodeURIComponent(JSON.stringify(e.assetJSON))}"`:"",s=encodeURIComponent(n.text()),a=`sim-${pxt.Util.guidGen()}`;let c=$(`<div class="ui card sim"><div class="ui content"><div style="position:relative;height:0;padding-bottom:${t};overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="${r}" data-code="${s}" data-frameid="${a}" ${o} allowfullscreen="allowfullscreen" sandbox="allow-popups allow-forms allow-scripts allow-same-origin" frameborder="0"></iframe></div></div></div>`);l.append(c),v(c)}});c.append(t)}if(s.hexname&&s.hex){let e=h(lf("Download"),"download icon").click(()=>{pxt.tickEvent("docs.btn",{button:"hex"}),pxt.BrowserUtils.browserDownloadBinText(s.hex,s.hexname,{contentType:pxt.appTarget.compile.hexMimeType})});c.append(e)}let m=$("<div class=codesnippet></div>");function _(){if(!r)return;const e=h(lf("Blocks"),"icon xicon blocks").click(()=>{pxt.tickEvent("docs.btn",{button:"blocks"}),l.find(".blocks")[0]?(l.find(".blocks").remove(),v(l)):(u(n?n.parent():l,r),v(r))});c.append(e)}function y(){if(n)if(s.showJs)d(l,n);else{const e=h("JavaScript","icon xicon js").click(()=>{pxt.tickEvent("docs.btn",{button:"js"}),l.find(".js")[0]?(l.find(".js").remove(),v(l)):(d(r?r.parent():l,n),v(n))});c.append(e)}}function b(){if(i)if(s.showPy)p(l,i);else{const e=h("Python","icon xicon python").click(()=>{pxt.tickEvent("docs.btn",{button:"py"}),l.find(".py")[0]?(l.find(".py").remove(),v(l)):(p(r?r.parent():l,i),v(i))});c.append(e)}}function v(e){var t;null===(t=e[0])||void 0===t||t.scrollIntoView({behavior:"smooth",block:"center"})}c.children().length&&m.append(a),m.append(l),t.replaceWith(m)}let _,y=[];function b(e,t,n){if(!e)return Promise.resolve();let i=$("."+e).first();return i[0]?(n.emPixels||(n.emPixels=18),n.layout||(n.layout=1),n.splitSvg=!0,y.push({el:i,source:i.text(),options:n,render:t}),i.addClass("lang-shadow"),i.removeClass(e),b(e,t,n)):Promise.resolve()}function v(e){if(!e||e.kind!=ts.SyntaxKind.ExpressionStatement)return null;let t=e;if(!t.expression||t.expression.kind!=ts.SyntaxKind.CallExpression)return null;let n=t.expression;return pxtc.pxtInfo(n).callInfo}function T(e){return _||(_=(0,i.decompileSnippetAsync)("",e)),_}function k(e,t){if(!t)return;const n=/^\/(v\d+)/.exec(t.url),i=/^\/(v\d+)/.exec(window.location.pathname),r=/#doc/i.test(window.location.href);t.url&&!n&&i&&!r&&(t.url=`/${i[1]}/${t.url}`);const o=document.createElement("div");o.setAttribute("role","listitem"),o.append((0,s.renderCodeCard)(t,{hideHeader:!0,shortName:!0})),e.append(o)}function E(e,t,n){const i=t.attributes,o=!i.blockHidden&&r.Blocks[i.blockId];if(null==o?void 0:o.codeCard){const t=pxt.U.clone(o.codeCard);n&&(t.style=n),k(e,t)}else k(e,{name:t.qName,description:i.jsDoc,url:i.help||void 0,style:n})}function x(e,t,n,i){return b(t,(e,t)=>{const o=t.compileProgram;if(!o)return;const s=o.getSourceFile(pxt.MAIN_TS).statements.slice(0),a=document.createElement("div");a.setAttribute("role","list"),a.className="card-list",s.forEach(e=>{const n=e.kind,o=v(e);if(o&&t.apiInfo&&t.apiInfo.byQName[o.qName]){const e=t.apiInfo.byQName[o.qName],n=e.attributes,s=r.Blocks[n.blockId];if(i){const i=e,r=t.compileBlocks.blocksInfo.apis.byQName[i.namespace];k(a,{name:r.attributes.blockNamespace||r.name,url:r.attributes.help||"reference/"+(r.attributes.blockNamespace||r.name).toLowerCase(),description:r.attributes.jsDoc,blocksXml:s&&s.codeCard?s.codeCard.blocksXml:n.blockId?`<xml xmlns="http://www.w3.org/1999/xhtml"><block type="${n.blockId}"></block></xml>`:void 0})}else E(a,e)}else switch(n){case ts.SyntaxKind.ExpressionStatement:{const t=e;switch(t.expression.kind){case ts.SyntaxKind.TrueKeyword:case ts.SyntaxKind.FalseKeyword:k(a,{name:"Boolean",url:"blocks/logic/boolean",description:lf("True or false values"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></xml>'});break;default:pxt.debug(`card expr kind: ${t.expression.kind}`)}break}case ts.SyntaxKind.IfStatement:k(a,{name:i?"Logic":"if",url:"blocks/logic"+(i?"":"/if"),description:lf(i?"Logic operators and constants":"Conditional statement"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_if"></block></xml>'});break;case ts.SyntaxKind.WhileStatement:k(a,{name:i?"Loops":"while",url:"blocks/loops"+(i?"":"/while"),description:lf(i?"Loops and repetition":"Repeat code while a condition is true."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="device_while"></block></xml>'});break;case ts.SyntaxKind.ForOfStatement:k(a,{name:i?"Loops":"for of",url:"blocks/loops"+(i?"":"/for-of"),description:lf(i?"Loops and repetition":"Repeat code for each item in a list."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_for_of"></block></xml>'});break;case ts.SyntaxKind.BreakStatement:k(a,{name:i?"Loops":"break",url:"blocks/loops"+(i?"":"/break"),description:lf(i?"Loops and repetition":"Break out of the current loop."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="break_keyword"></block></xml>'});break;case ts.SyntaxKind.ContinueStatement:k(a,{name:i?"Loops":"continue",url:"blocks/loops"+(i?"":"/continue"),description:lf(i?"Loops and repetition":"Skip iteration and continue the current loop."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="continue_keyboard"></block></xml>'});break;case ts.SyntaxKind.ForStatement:{let t=e,n=!0;3==t.condition.getChildCount()&&(n=!("0"==t.condition.getChildAt(0).getText()||t.condition.getChildAt(1).kind==ts.SyntaxKind.LessThanToken)),k(a,n?{name:i?"Loops":"for",url:"blocks/loops"+(i?"":"/for"),description:lf(i?"Loops and repetition":"Repeat code for a given number of times using an index."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_simple_for"></block></xml>'}:{name:i?"Loops":"repeat",url:"blocks/loops"+(i?"":"/repeat"),description:lf(i?"Loops and repetition":"Repeat code for a given number of times."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_repeat_ext"></block></xml>'});break}case ts.SyntaxKind.VariableStatement:k(a,{name:i?"Variables":"variable declaration",url:"blocks/variables"+(i?"":"/assign"),description:lf(i?"Variables":"Assign a value to a named variable."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="variables_set"></block></xml>'});break;default:pxt.debug(`card kind: ${n}`)}}),n&&(e=e.parent()),e.replaceWith(a)},{package:e.package,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}function S(e,t){if(!e)return Promise.resolve();let n=$("."+e).first();if(!n[0])return Promise.resolve();n.removeClass(e);const i=pxt.gallery.parseCodeCardsHtml(n[0]);return i||n.append($("<div/>").addClass("ui segment warning").text("invalid codecard format")),t.snippetReplaceParent&&(n=n.parent()),function(e,t,n){if(!t||0==t.length)return Promise.resolve();if(0==t.length){let i=(0,s.renderCodeCard)(t[0],n);e.replaceWith(i)}else{let i=document.createElement("div");i.className="card-list",i.setAttribute("role","list"),i.setAttribute("aria-label",n.cardCategory||lf("Content cards")),t.forEach(e=>{const t=/^\/(v\d+)/.exec(e.url),r=/^\/(v\d+)/.exec(window.location.pathname),o=/#doc/i.test(window.location.href);e.url&&!t&&r&&!o&&(e.url=`/${r[1]}${e.url}`);const a=(0,s.renderCodeCard)(e,n),l=document.createElement("div");if(l.setAttribute("role","listitem"),l.appendChild(a),i.appendChild(l),"package"==e.cardType){const t=pxt.github.parseRepoId((e.url||"").replace(/^\/pkg\//,""));t&&pxt.packagesConfigAsync().then(i=>{switch(pxt.github.repoStatus(t,i)){case pxt.github.GitRepoStatus.Banned:a.remove();break;case pxt.github.GitRepoStatus.Approved:e.imageUrl=pxt.github.mkRepoIconUrl(t),l.insertBefore((0,s.renderCodeCard)(e,n),a),a.remove()}}).catch(t=>{pxt.reportException(t),pxt.debug(`failed to load repo ${e.url}`)})}}),e.replaceWith(i)}return Promise.resolve()}(n,i,{hideHeader:!0,cardCategory:t.hexName}).then(()=>pxt.U.delay(1,S(e,t)))}function C(e){return e.pxtUrl?e.pxtUrl+"/--run":pxt.webConfig&&pxt.webConfig.runUrl?pxt.webConfig.runUrl:"/--run"}function A(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};$("code.lang-python").each((n,i)=>{!function(n,i){"undefined"!=typeof hljs&&($(n).text($(n).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(n),c($(n)));const r=pxt.U.clone(t);i&&(r.run=!1,r.showEdit=!1),m(e,$(n).parent(),$(n),void 0,void 0,void 0,r)}(i,!1),$(i).removeClass("lang-python")})}function I(e,t){t.snippetReplaceParent&&(e=e.parent()),e.remove()}function w(e,t,n){$(`code.lang-${e}\\.${t}`).each((e,t)=>{I($(t),n)})}n.renderAsync=function(e){return pxt.analytics.enable(pxt.Util.userLanguage()),e||(e=a()),e.pxtUrl&&(e.pxtUrl=e.pxtUrl.replace(/\/$/,"")),e.showEdit&&(e.showEdit=!pxt.BrowserUtils.isIFrame()),pxt.docs.hydrateYouTubeEmbeds(document.body,!1),function(e){e.packageClass&&($("."+e.packageClass).each((t,n)=>{let i=$(n),r=i.text().split("\n").map(e=>e.replace(/\s*/g,"")).filter(e=>!!e).join(",");e.package=e.package?`${e.package},${r}`:r,e.snippetReplaceParent&&(i=i.parent()),i.remove()}),$(".lang-config").each((t,n)=>{let i=$(n);e.snippetReplaceParent&&(i=i.parent()),i.remove()}))}(e),function(e){let t,n;e.jresClass&&$(`.${e.jresClass}`).each((e,t)=>{const i=$(t);n=i.text(),t.parentElement.remove()}),e.assetJSONClass&&$(`.${e.assetJSONClass}`).each((e,n)=>{const i=$(n);t=i.text(),n.parentElement.remove()}),e.assetJSON=function(e,t){if(!e&&!t)return;const n=pxt.tutorial.parseAssetJson(e)||{};if(t){const e=JSON.parse(t);n[pxt.TILEMAP_JRES]=JSON.stringify(e),n[pxt.TILEMAP_CODE]=pxt.emitTilemapsFromJRes(e)}return n}(t,n)}(e),y=[],function(e){I($("code.lang-ghost"),e)}(e),function(e){w("blockconfig","local",e),w("blockconfig","global",e)}(e),function(e){I($("code.lang-template"),e)}(e),function(e){w("validation","local",e),w("validation","global",e)}(e),function(e){e.simulatorClass&&$("."+e.simulatorClass).each((t,n)=>{var i;let r=$(n),o="81.97%";pxt.appTarget.simulator&&(o=100/pxt.appTarget.simulator.aspectRatio+"%");const s=lf("MakeCode {0} Simulator",(null===(i=pxt.appTarget.appTheme)||void 0===i?void 0:i.boardName)||pxt.appTarget.name);let a=$(`\n <div class="ui card">\n <div class="ui content">\n <div style="position:relative;height:0;padding-bottom:${o};overflow:hidden;">\n <iframe\n style="position:absolute;top:0;left:0;width:100%;height:100%;"\n allowfullscreen="allowfullscreen"\n frameborder="0"\n sandbox="allow-popups allow-forms allow-scripts allow-same-origin"\n title="${pxt.U.htmlEscape(s)}"\n ></iframe>\n </div>\n </div>\n </div>\n `);const l=e.package?"&deps="+encodeURIComponent(e.package):"",c=C(e)+"#nofooter=1"+l,u=encodeURIComponent(r.text().trim()),d=a.find("iframe");d.attr("src",c),d.attr("data-code",u),e.assetJSON&&d.attr("data-assets",JSON.stringify(e.assetJSON)),e.snippetReplaceParent&&(r=r.parent()),r.replaceWith(a)})}(e),function(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};function n(n,i){"undefined"!=typeof hljs&&($(n).text($(n).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(n),c($(n)));const r=pxt.U.clone(t);i&&(r.run=!1,r.showEdit=!1),m(e,$(n).parent(),$(n),void 0,void 0,void 0,r)}$("code.lang-typescript").each((e,t)=>{n(t,!1),$(t).removeClass("lang-typescript")}),$("code.lang-typescript-ignore").each((e,t)=>{$(t).removeClass("lang-typescript-ignore"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript")}),$("code.lang-typescript-invalid").each((e,t)=>{$(t).removeClass("lang-typescript-invalid"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript"),$(t).parent("div").addClass("invalid"),$(t).parent("div").prepend($("<i>",{class:"icon ban"})),$(t).addClass("invalid")}),$("code.lang-typescript-valid").each((e,t)=>{$(t).removeClass("lang-typescript-valid"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript"),$(t).parent("div").addClass("valid"),$(t).parent("div").prepend($("<i>",{class:"icon check"})),$(t).addClass("valid")})}(e),A(e),Promise.resolve().then(()=>S(e.codeCardClass,e)).then(()=>async function(e){if("core"==pxt.appTarget.id)return;const t=(await T(e)).compileBlocks.blocksInfo;let n={};for(const e of t.blocks){const i=(e.attributes.blockNamespace||e.namespace).split(".")[0];if(!n[i]){const e=t.apis.byQName[i];e&&e.attributes.color&&(n[i]=e.attributes.color)}}let i="";for(const e of Object.keys(n)){const t=n[e];i+=`\n span.docs.${e.toLowerCase()} {\n --inline-namespace-color: ${t};\n }\n `}for(const e of Object.keys(pxt.toolbox.blockColors)){const t=pxt.toolbox.getNamespaceColor(e);i+=`\n span.docs.${e.toLowerCase()} {\n --inline-namespace-color: ${t};\n }\n `}let r=document.createElement("style");r.id="namespaceColors",r.type="text/css",(document.head||document.getElementsByTagName("head")[0]).appendChild(r),r.appendChild(document.createTextNode(i))}(e)).then(()=>function(e){(e=pxt.Util.clone(e)).emPixels=18,e.snippetMode=!0;const t=$(":not(pre) > code");let n=0;return function r(){if(n>=t.length)return Promise.resolve();const o=$(t[n++]),s=o.text(),a=/^(\|+)([^\|]+)\|+$/.exec(s);if(a){const e=/^(([^\:\.]*?)[\:\.])?(.*)$/.exec(a[2]),t=(e[2]?e[2].trim().toLowerCase():"").replace(/\(.*?\)/g,""),n=1==a[1].length?`docs inlinebutton ${t}`:`docs inlineblock ${t}`,i=e[3].trim();return o.replaceWith($(`<span class="${n}"/>`).text(pxt.U.rlf(i))),r()}const l=/^\[(.+)\]$/.exec(s);if(!l)return r();const c=l[1];return(0,i.decompileSnippetAsync)(c,e).then(e=>{if(e.blocksSvg){let t=$('<span class="block"/>').append(e.blocksSvg);const n=v(e.compileProgram.getSourceFile(pxt.MAIN_TS).statements[0]);if(n&&e.apiInfo){const i=e.apiInfo.byQName[n.qName];if(i&&i.attributes.help){const e=i.name||i.qName,n=lf("Documentation for {0} block",e);t=$('<a class="ui link"/>').attr("href",`/reference/${i.attributes.help}`).attr("aria-label",n).append(t)}}o.replaceWith(t)}return pxt.U.delay(1,r())})}()}(e)).then(()=>x(e,e.linksClass,e.snippetReplaceParent,!1)).then(()=>x(e,e.namespacesClass,e.snippetReplaceParent,!0)).then(()=>function(e,t){const n=e.apisClass;if(!n)return Promise.resolve();const i=$("."+n);return i.length?T(e).then(e=>{const n=e.compileBlocks.blocksInfo,o=pxt.Util.values(n.apis.byQName).filter(e=>!(e.attributes.hidden||e.attributes.deprecated||e.attributes.blockAliasFor||!e.attributes.jsDoc||!e.attributes.block||/^__/.test(e.name)));i.each((e,n)=>{let i=$(n);const s=pxt.Util.toDictionary(i.text().split("\n"),e=>e),a=o.filter(e=>!!s[e.attributes.blockNamespace||e.namespace]);if(!a.length)return;a.sort((e,t)=>{const n=!e.attributes.blockHidden&&r.Blocks[e.attributes.blockId],i=!t.attributes.blockHidden&&r.Blocks[t.attributes.blockId];return!!n!=!!i?(i?1:0)-(n?1:0):e.name.localeCompare(t.name)});const l=document.createElement("div");l.className="ui divided items",l.setAttribute("role","list"),a.forEach(e=>E(l,e,"item")),t&&(i=i.parent()),i.replaceWith(l)})}):Promise.resolve()}(e,e.snippetReplaceParent)).then(()=>function(e){return b(e.signatureClass,(t,n)=>{var i,s,a,l;let c=n.compileProgram;if(!c)return;let u=v(c.getSourceFile(pxt.MAIN_TS).statements[0]);if(!u||!n.apiInfo)return;const d=n.apiInfo.byQName[u.qName];if(!d)return;let p=r.Blocks[d.attributes.blockId],h=(null===(i=null==p?void 0:p.codeCard)||void 0===i?void 0:i.blocksXml)||void 0;const f=h?(0,o.render)(h):(null===(s=n.compileBlocks)||void 0===s?void 0:s.success)?n.blocksSvg:void 0,g=f?$(f):void 0;let _=ts.pxtc.service.displayStringForSymbol(d,!1,n.apiInfo).split("\n")[1]+";";const y=$('<code class="lang-typescript highlight"/>').text(_),b=(null===(l=null===(a=pxt.appTarget)||void 0===a?void 0:a.appTheme)||void 0===l?void 0:l.python)&&ts.pxtc.service.displayStringForSymbol(d,!0,n.apiInfo).split("\n")[1],T=b&&$('<code class="lang-python highlight"/>').text(b);if(e.snippetReplaceParent&&(t=t.parent()),pxt.Util.isTranslationMode()){const e=$('<div class="ui segment" />');e.append($('<div class="ui header"><i class="ui xicon globe"></i></div>')),d.attributes.translationId&&e.append($('<div class="ui message">').text(d.attributes.translationId)),d.attributes.jsDoc&&e.append($('<div class="ui message">').text(d.attributes.jsDoc)),e.insertAfter(t)}m(e,t,y,T,g,n,{showJs:!0,showPy:!0,hideGutter:!0})},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>function(e){if(e.tutorial)return b(e.snippetClass,(t,n)=>{const i=n.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const r=$('<div class="ui segment codewidget"/>').append(i);t.replaceWith(r)},{package:e.package,snippetMode:!1,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON});let t=0;return b(e.snippetClass,(n,i)=>{const r=i.compileBlocks&&i.compileBlocks.success?$(i.blocksSvg):void 0,o=i.compilePython&&i.compilePython.success&&i.compilePython.outfiles[pxt.MAIN_PY],s=$('<code class="lang-typescript highlight"/>').text(n.text().trim()),a=o?$('<code class="lang-python highlight"/>').text(o.trim()):void 0;e.snippetReplaceParent&&(n=n.parent());const l=i.compileJS&&i.compileJS.success,c=e.hex&&l&&i.compileJS.outfiles[pxtc.BINARY_HEX]?i.compileJS.outfiles[pxtc.BINARY_HEX]:void 0,u=`${pxt.appTarget.nickname||pxt.appTarget.id}-${e.hexName||""}-${t++}.hex`;m(e,n,s,a,r,i,{showEdit:e.showEdit,run:e.simulator,hexname:u,hex:c})},{package:e.package,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>function(e){return b(e.blocksClass,(t,n)=>{const i=n.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const r=$('<div class="ui segment codewidget"/>').append(i);t.replaceWith(r)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>{return(t=e).blocksXmlClass?function e(t,n,r){let o=$("."+t).first();return o[0]?(r.emPixels||(r.emPixels=18),r.splitSvg=!0,(0,i.compileBlocksAsync)(o.text(),r).then(i=>{try{n(o,i)}catch(e){pxt.reportException(e),o.append($("<div/>").addClass("ui segment warning").text(e.message))}return o.removeClass(t),pxt.U.delay(1,e(t,n,r))})):Promise.resolve()}(t.blocksXmlClass,(e,n)=>{const i=n.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const r=$('<div class="ui segment codewidget"/>').append(i);e.replaceWith(r)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON}):Promise.resolve();var t}).then(()=>{return(t=e).diffBlocksXmlClass?function e(t,n,r){let s=$("."+t).first();if(!s[0])return Promise.resolve();r.emPixels||(r.emPixels=18),r.splitSvg=!0;const a=s.text().split(/-{10,}/),l=a[0],c=a[1];return(0,i.compileBlocksAsync)("",r).then(i=>{s.removeClass(t);try{const e=(0,o.diffXml)(l,c);e?(i.blocksSvg=e.svg,n(s,i)):s.text("no changes")}catch(e){pxt.reportException(e),s.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(t,n,r))})}(t.diffBlocksXmlClass,(e,n)=>{const i=n.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const r=$('<div class="ui segment codewidget"/>').append(i);e.replaceWith(r)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON}):Promise.resolve();var t}).then(()=>{return(t=e).diffBlocksClass?function e(n){let r=$("."+n).first();if(!r[0])return Promise.resolve();const{fileA:s,fileB:a}=pxt.diff.split(r.text(),{removeTrailingSemiColumns:!0});return pxt.U.promiseMapAllSeries([s,a],e=>(0,i.decompileSnippetAsync)(e,{generateSourceMap:!0})).then(i=>{try{const e=(0,o.decompiledDiffAsync)(s,i[0].compileBlocks,a,i[1].compileBlocks,{hideDeletedTopBlocks:!0,hideDeletedBlocks:!0}),n=pxt.diff.render(s,a,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});let l;const[c,u]=i.map(e=>e.compilePython&&e.compilePython.outfiles&&e.compilePython.outfiles[pxt.MAIN_PY]);c&&u&&(l=pxt.diff.render(c,u,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0})),m(t,r.parent(),$(n),l&&$(l),$(e.svg),void 0,{showEdit:!1,run:!1,hexname:void 0,hex:void 0})}catch(e){pxt.reportException(e),r.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(n))})}(t.diffBlocksClass):Promise.resolve();var t}).then(()=>{return(t=e).diffClass?function e(n){let i=$("."+n).first();if(!i[0])return Promise.resolve();const{fileA:r,fileB:o}=pxt.diff.split(i.text());try{const e=pxt.diff.render(r,o,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});t.snippetReplaceParent&&(i=i.parent());const s=$('<div class="ui segment codewidget"/>').append(e);i.removeClass(n),i.replaceWith(s)}catch(e){pxt.reportException(e),i.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(n))}(t.diffClass):Promise.resolve();var t}).then(()=>function(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};return b(e.staticPythonClass,(n,i)=>{const r=i.compilePython;if(r&&r.success){const o=n.clone().removeClass("lang-shadow").addClass("highlight"),s=o.clone().addClass("lang-python").text(r.outfiles[pxt.MAIN_PY]);o.addClass("lang-typescript"),l(s),m(e,n.parent(),o,s,void 0,i,t)}},{package:e.package,snippetMode:!0,assets:e.assetJSON})}(e)).then(()=>function(e){return e.projectClass?function t(){let n=$("."+e.projectClass).first(),r=n[0];if(!r)return Promise.resolve();n.removeClass(e.projectClass);let o=pxt.Cloud.parseScriptId(r.innerText);if(o){if(e.snippetReplaceParent){r=r.parentElement;let e=document.createElement("div");r.parentElement.insertBefore(e,r),r.parentElement.removeChild(r),r=e}return(0,i.renderProjectAsync)(r,o).then(()=>t())}return t()}():Promise.resolve()}(e)).then(()=>function(){const e={};return function t(){const n=y.shift();if(!n)return Promise.resolve();const{el:r,options:o,render:s}=n;return(0,i.decompileSnippetAsync)(r.text(),o).then(t=>{const n=t.compileJS&&t.compileJS.diagnostics&&t.compileJS.diagnostics.filter(e=>e.category==pxtc.DiagnosticCategory.Error);n&&n.length&&n.forEach(e=>pxt.reportError("docs.decompile",""+e.messageText,{code:e.code+""})),t.blocksSvg.querySelectorAll("defs *").forEach(t=>{e[t.id]?t.remove():e[t.id]=!0}),s(r,t)},e=>{pxt.reportException(e),r.append($("<div/>").addClass("ui segment warning").text(e.message))}).finally(()=>(r.removeClass("lang-shadow"),t()))}().then(()=>{r.Workspace.getAll().forEach(e=>e.dispose()),(0,o.cleanRenderingWorkspace)()})}())}},{"../pxtblocks":76,"../pxtblocks/codecardRenderer":11,"./runner":184,blockly:192}],184:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.init=n.setInitCallbacks=n.compileBlocksAsync=n.decompileSnippetAsync=n.renderMarkdownAsync=n.renderProjectFilesAsync=n.renderProjectAsync=n.startDocsServer=n.startRenderServer=n.setEditorContextAsync=n.editorLanguageMode=n.LanguageMode=n.buildSimJsInfo=n.fetchSimJsInfo=n.postSimMessage=n.currentDriver=n.preloadSim=n.simulateAsync=n.generateVMFileAsync=n.generateHexFileAsync=n.showError=n.initFooter=n.initHost=n.mainPkg=void 0;const i=e("../pxtblocks"),r=e("../pxteditor/editor"),o=e("./renderer"),s=e("../pxtblocks"),a=e("blockly");pxt.blocks.requirePxtBlockly=()=>s,pxt.blocks.requireBlockly=()=>a,pxt.blocks.registerFieldEditor=(e,t,n)=>s.registerFieldEditor(e,t,n);class l{constructor(e,t){this.ksPkg=e,this.topPkg=t,this.files={}}getKsPkg(){return this.ksPkg}getPkgId(){return this.ksPkg?this.ksPkg.id:this.id}isTopLevel(){return this.ksPkg&&0==this.ksPkg.level}setFiles(e){this.files=e}getAllFiles(){return pxt.Util.mapMap(this.files,(e,t)=>t)}}class c{constructor(){this.githubPackageCache={}}readFile(e,t){let n=g(e);return pxt.U.lookup(n.files,t)}writeFile(e,t,n){g(e).files[t]=n}getHexInfoAsync(e){return pxt.hexloader.getHexInfoAsync(this,e)}cacheStoreAsync(e,t){return Promise.resolve()}cacheGetAsync(e){return Promise.resolve(null)}patchDependencies(e,t,n){if(!n)return!1;const i=pxt.github.parseRepoId(n);if(!i)return!1;for(const t of Object.keys(e.dependencies)){const r=e.dependencies[t],o=pxt.github.parseRepoId(r);if(o&&i.fullName==o.fullName)return pxt.semver.strcmp(i.tag,o.tag)<0&&(e.dependencies[t]=n),!0}return!1}downloadPackageAsync(e,t){let n,i=e.verProtocol();"github"==i&&(n=this.githubPackageCache[e._verspec]);let r=g(e);return(n?Promise.resolve(n):e.commonDownloadAsync()).then(o=>{if(o)return"github"!=i||n||(this.githubPackageCache[e._verspec]=pxt.Util.clone(o)),r.setFiles(o),Promise.resolve();if("empty"==i){if(0==Object.keys(r.files).length&&r.setFiles(m()),t&&t.length){const n=g(e).files,i=JSON.parse(n[pxt.CONFIG_NAME]);t.forEach(e=>{f(i,e)}),n[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i)}return Promise.resolve()}if("docs"==i){let t=m(),n=JSON.parse(t[pxt.CONFIG_NAME]);return e.verArgument().split(",").forEach(e=>{f(n,e)}),n.yotta||(n.yotta={}),n.yotta.ignoreConflicts=!0,t[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(n),r.setFiles(t),Promise.resolve()}return"invalid"==i?(pxt.log(`skipping invalid pkg ${e.id}`),Promise.resolve()):Promise.reject(`Cannot download ${e.version()}; unknown protocol`)})}}let u,d,p,h;function f(e,t){let n=/^([a-zA-Z0-9_-]+)(=(.+))?$/.exec(t);return n?e.dependencies[n[1]]=n[3]||"*":pxt.warn(`unknown package syntax ${t}`),!0}function g(e){let t=e._editorPkg;if(t)return t;let i=null;e!=n.mainPkg&&(i=g(n.mainPkg));let r=new l(e,i);return e==n.mainPkg&&(r.topPkg=r),e._editorPkg=r,r}function m(){let e=pxt.appTarget.tsprj,t=pxt.U.clone(e.files);return t[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(e.config),t[pxt.MAIN_BLOCKS]="",t}function _(){pxt.setAppTarget(window.pxtTargetBundle),pxt.analytics.enable(pxt.Util.userLanguage()),pxt.Util.assert(!!pxt.appTarget);const e=window.location.href;let t,n=!1;if(/[&?]translate=1/.test(e)&&!pxt.BrowserUtils.isIE())t=ts.pxtc.Util.TRANSLATION_LOCALE,n=!0,pxt.Util.enableLiveLocalizationUpdates();else{const i=/PXT_LANG=(.*?)(?:;|$)/.exec(document.cookie),r=/(live)?(force)?lang=([a-z]{2,}(-[A-Z]+)?)/i.exec(e);t=r?r[3]:i&&i[1]||pxt.appTarget.appTheme.defaultLocale||navigator.userLanguage||navigator.language;const o=pxt.appTarget.appTheme.defaultLocale,s=null==t?void 0:t.toLocaleLowerCase(),a=pxt.BrowserUtils.isLocalHostDev()&&(!s||(o?o.toLocaleLowerCase()===s:"en"===s||"en-us"===s));(pxt.BrowserUtils.isPxtElectron()||a||pxt.appTarget.appTheme.disableLiveTranslations)&&!(null==r?void 0:r[1])||pxt.Util.enableLiveLocalizationUpdates(),n=!!r&&!!r[2]}pxt.appTarget.versions;$&&$.fn&&$.fn.embed&&$.fn.embed.settings&&$.fn.embed.settings.sources&&$.fn.embed.settings.sources.youtube&&($.fn.embed.settings.sources.youtube.url="//www.youtube.com/embed/{id}?rel=0");const i=pxt.webConfig;return pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:i.commitCdnUrl,code:t,force:n}).then(()=>y())}function y(){n.mainPkg=new pxt.MainPackage(new c)}function b(e){pxt.error(e)}function v(e,t,i){const r=e?/\w+:\w+/.test(e)?e:"pub:"+e:"empty:tsprj";let o,s,a;return d&&d._verspec==r?(n.mainPkg=d,o=n.mainPkg.host(),s=Promise.resolve(),a=Promise.resolve()):(o=n.mainPkg.host(),n.mainPkg=new pxt.MainPackage(o),n.mainPkg._verspec=e?/\w+:\w+/.test(e)?e:"pub:"+e:"empty:tsprj",s=o.downloadPackageAsync(n.mainPkg,i),a=n.mainPkg.installAllAsync(),d=n.mainPkg),s.then(()=>o.readFile(n.mainPkg,pxt.CONFIG_NAME)).then(e=>e?a.then(()=>{if(t){let e=g(n.mainPkg);e.files[pxt.MAIN_TS]=t;let i=JSON.parse(e.files[pxt.CONFIG_NAME]);i.name=window.location.href.split("/").pop().split(/[?#]/)[0],e.files[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i),n.mainPkg.config.name=i.name,-1==n.mainPkg.config.files.indexOf(pxt.MAIN_BLOCKS)&&n.mainPkg.config.files.push(pxt.MAIN_BLOCKS)}}).catch(e=>{b(lf("Cannot load extension: {0}",e.message))}):Promise.resolve())}function T(e){let t=n.mainPkg.getTargetOptions();return t.isNative=!!e,t.hasHex=!!e,n.mainPkg.getCompileOptionsAsync(t)}function k(e,t){return T(e).then(e=>{t&&t(e);let n=pxtc.compile(e);return n.diagnostics&&n.diagnostics.length>0&&n.diagnostics.forEach(e=>{pxt.error(e.messageText)}),n})}function E(e,t,i){var r,o;p&&t.embedId&&h===t.embedId?p.container=e:(p=new pxsim.SimulatorDriver(e),h=t.embedId);const{fnArgs:s,parts:a,usedBuiltinParts:l}=i||{};let c=pxt.appTarget.simulator.boardDefinition,u=C(t.id),d={debug:t.debug,mute:t.mute,boardDefinition:c,parts:a,builtinParts:l,fnArgs:s,cdnUrl:pxt.webConfig.commitCdnUrl,localizedStrings:pxt.Util.getLocalizedStrings(),partDefinitions:null===n.mainPkg||void 0===n.mainPkg?void 0:n.mainPkg.computePartDefinitions(a),highContrast:t.highContrast,storedState:u,light:t.light,single:t.single,hideSimButtons:t.hideSimButtons,autofocus:t.autofocus,queryParameters:t.additionalQueryParameters,mpRole:t.mpRole,theme:null===(r=n.mainPkg.config)||void 0===r?void 0:r.theme};if(pxt.appTarget.simulator&&!t.fullScreen&&(d.aspectRatio=a.length&&pxt.appTarget.simulator.partsAspectRatio?pxt.appTarget.simulator.partsAspectRatio:pxt.appTarget.simulator.aspectRatio),window.parent&&d.aspectRatio&&d.aspectRatio!==pxt.appTarget.simulator.aspectRatio){const e=null===(o=window.frameElement)||void 0===o?void 0:o.getAttribute("data-frameid");e&&window.parent.postMessage({type:"aspectratio",frameid:e,value:d.aspectRatio},"*")}return p.setRunOptions(d),d}async function x(e){try{const t=Date.now(),n=await pxt.Cloud.downloadBuiltSimJsInfoAsync(e.id);return pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-t,operation:"fetchSimJsInfo"}),n}catch(e){return void pxt.debug(e.toString())}}async function S(e){var t,i,r;const o=Date.now();await v(e.id,e.code,e.dependencies);let s=!1;const a=pxt.appTarget.versions.target;let l=await k(!1,t=>{var i;if(t.computeUsedParts=!0,t.computeUsedSymbols=!0,e.debug&&(t.breakpoints=!0),e.assets){const n=JSON.parse(e.assets);for(const e of Object.keys(n)){const i=n[e];if(t.fileSystem[e]=i,t.sourceFiles.indexOf(e)<0&&t.sourceFiles.push(e),/\.jres$/.test(e)){const e=JSON.parse(i);t.jres=pxt.inflateJRes(e,t.jres)}}}if(e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code),t.target.preferredEditor===pxt.PYTHON_PROJECT_NAME){t.target.preferredEditor=pxt.JAVASCRIPT_PROJECT_NAME,t.ast=!0;const e=F(pxtc.compile(t).ast,t);t.apisInfo=e,t.target.preferredEditor=pxt.PYTHON_PROJECT_NAME}const r=null===(i=n.mainPkg.config.targetVersions)||void 0===i?void 0:i.target;if(r&&a&&pxt.semver.cmp(pxt.semver.parse(r),pxt.semver.parse(a))<0)for(const e of Object.keys(t.fileSystem))!pxt.Util.startsWith(e,"pxt_modules")&&pxt.Util.endsWith(e,".ts")&&(s=!0,t.fileSystem[e]=pxt.patching.patchJavaScript(r,t.fileSystem[e]))});(null===(t=l.diagnostics)||void 0===t?void 0:t.length)>0&&s&&(pxt.log("Compile with upgrade rules failed, trying again with original code"),l=await k(!1,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})),l.diagnostics&&l.diagnostics.length>0&&pxt.error("Diagnostics",l.diagnostics);const c=pxtc.buildSimJsInfo(l),u=(null===(r=null===(i=pxt.appTarget.simulator)||void 0===i?void 0:i.boardDefinition)||void 0===r?void 0:r.onboardComponents)||[];return c.allParts=l.usedParts||[],c.usedBuiltinParts=l.usedParts.filter(e=>-1!==u.indexOf(e)),c.parts=l.usedParts.filter(e=>-1===u.indexOf(e)),pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-o,operation:"buildSimJsInfo"}),c}function C(e){let t={};try{let n=window.localStorage.getItem(e);n&&(t=JSON.parse(n))}catch(e){}return t}var A;function I(e,t){if(n.editorLanguageMode=e,t!=pxt.Util.localeInfo()){const e=/^live-/;return e.test(t)&&pxt.Util.enableLiveLocalizationUpdates(),pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:pxt.webConfig.commitCdnUrl,code:t.replace(e,"")})}return Promise.resolve()}function w(e){let t=e.data;if(t)switch(t.type){case"fileloaded":let e=t,n=e.name,i=A.Blocks;/\.ts$/i.test(n)?i=A.TypeScript:/\.py$/i.test(n)&&(i=A.Python),I(i,e.locale);break;case"popout":let r=/((\/v[0-9+])\/)?[^\/]*#(doc|md):([^&?:]+)/i.exec(window.location.href);if(r){const e=pxt.webConfig.docsUrl||"/--docs";let t=r[2]||"",n="doc"==r[3]?pxt.webConfig.isStatic?`/docs${r[4]}.html`:`${r[4]}`:`${e}?md=${r[4]}`;window.parent&&window.parent.postMessage({type:"opendoc",url:pxt.BrowserUtils.urlJoin(t,n)},"*")}break;case"localtoken":let o=t;o&&o.localToken&&(pxt.Cloud.localToken=o.localToken,U.forEach(e=>e()),U=[])}}function N(e,t){return pxt.Cloud.privateGetTextAsync(t+"/text").then(e=>JSON.parse(e)).then(n=>D(e,n,t))}function D(e,t,i=null,r=!1){const o=JSON.parse(t[pxt.CONFIG_NAME])||{};let s=`# ${o.name} ${o.version?o.version:""}\n\n`;const a="README.md";t[a]&&(s+=t[a].replace(/^#+/,"$0#")+"\n"),o.files.filter(e=>e!=pxt.CONFIG_NAME&&e!=a).filter(e=>function(e,t){switch(t){case A.Blocks:return/\.blocks?$/.test(e);case A.TypeScript:return/\.ts?$/.test(e);case A.Python:return/\.py?$/.test(e)}}(e,n.editorLanguageMode)).forEach(e=>{/^main\.(ts|blocks)$/.test(e)||(s+=`\n## ${e}\n`),/\.ts$/.test(e)?s+=`\`\`\`typescript\n${t[e]}\n\`\`\`\n`:/\.blocks?$/.test(e)?s+=`\`\`\`blocksxml\n${t[e]}\n\`\`\`\n`:s+=`\`\`\`${e.substr(e.indexOf("."))}\n${t[e]}\n\`\`\`\n`});const l=o&&o.dependencies&&Object.keys(o.dependencies).filter(e=>e!=pxt.appTarget.corepkg);if(l&&l.length&&(s+=`\n## ${lf("Extensions")} #extensions\n\n${l.map(e=>`* ${e}, ${o.dependencies[e]}`).join("\n")}\n\n\`\`\`package\n${l.map(e=>`${e}=${o.dependencies[e]}`).join("\n")}\n\`\`\`\n`),i){let e=(pxt.appTarget.appTheme.shareUrl||"https://makecode.com/")+i;r&&(e="`"+e+"`"),s+=`\n${e}\n\n`}pxt.debug(`print md: ${s}`);return R(e,s,{print:!0})}pxt.react.getTilemapProject||(pxt.react.getTilemapProject=()=>(u||(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg)),u)),n.initHost=y,n.initFooter=function(e,t){if(!e)return;let n=pxt.appTarget.appTheme,i=$("body"),r=$(e),o=$("<a/>").attr("href",n.homeUrl).attr("target","_blank");r.append(o),n.organizationLogo?o.append($("<img/>").attr("src",pxt.Util.toDataUri(n.organizationLogo))):o.append(lf("powered by {0}",n.title)),i.mouseenter(e=>r.fadeOut()),i.mouseleave(e=>r.fadeIn())},n.showError=b,n.generateHexFileAsync=function(e){return v(e.id).then(()=>k(!0,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})).then(e=>(e.diagnostics&&e.diagnostics.length>0&&pxt.error("Diagnostics",e.diagnostics),e.outfiles[pxtc.BINARY_HEX]))},n.generateVMFileAsync=function(e){return pxt.setHwVariant("vm"),v(e.id).then(()=>k(!0,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})).then(e=>(pxt.log(e),e))},n.simulateAsync=async function(e,t){var n,i;const r=t.builtJsInfo||await x(t)||await S(t),{js:o}=r;if(!o)return void pxt.error("Program failed to compile");const s=E(e,t,r);return p.options.messageSimulators=null===(i=null===(n=pxt.appTarget)||void 0===n?void 0:n.simulator)||void 0===i?void 0:i.messageSimulators,p.options.onSimulatorCommand=e=>{"restart"===e.command?(s.storedState=C(t.id),p.run(o,s)):"setstate"===e.command?e.stateKey&&function(e,t,n){let i=C(e);if(!e)return;null!=n?i[t]=n:delete i[t];try{window.localStorage.setItem(e,JSON.stringify(i))}catch(e){}}(t.id,e.stateKey,e.stateValue):"single"===e.command&&p.setSingleSimulator()},r.breakpoints&&t.debug&&p.setBreakpoints(r.breakpoints),p.run(o,s),r},n.preloadSim=function(e,t){var n,i;E(e,t),p.preload((null===(i=null===(n=pxt.appTarget)||void 0===n?void 0:n.simulator)||void 0===i?void 0:i.aspectRatio)||1,!0)},n.currentDriver=function(){return p},n.postSimMessage=function(e){null==p||p.postMessage(e)},n.fetchSimJsInfo=x,n.buildSimJsInfo=S,function(e){e[e.Blocks=0]="Blocks",e[e.TypeScript=1]="TypeScript",e[e.Python=2]="Python"}(A=n.LanguageMode||(n.LanguageMode={})),n.editorLanguageMode=A.Blocks,n.setEditorContextAsync=I,n.startRenderServer=function(){pxt.tickEvent("renderer.ready");const e=[];let t;function n(){if(t)return;const r=e.shift();if(!r)return;const o=r.options||{};o.splitSvg=!1,pxt.tickEvent("renderer.job");const s=/^\s*<xml/.test(r.code);t=(async()=>{const e=(s?await B(r.code,o):await M(r.code,r.options)).blocksSvg;if(!e)throw new Error("Failed to generate blocks SVG");const t=e.viewBox.baseVal.width,n=e.viewBox.baseVal.height;let a,l;try{a=await(0,i.blocklyToSvgAsync)(e,0,0,t,n)}catch(e){throw pxt.reportException(e),e}try{l=a?await pxt.BrowserUtils.encodeToPngAsync(a.xml,{width:t,height:n}):void 0}catch(e){pxt.warn(e)}window.parent.postMessage({source:"makecode",type:"renderblocks",id:r.id,width:null==a?void 0:a.width,height:null==a?void 0:a.height,svg:null==a?void 0:a.svg,uri:l||(null==a?void 0:a.xml),css:null==a?void 0:a.css},"*")})().catch(e=>{window.parent.postMessage({source:"makecode",type:"renderblocks",id:r.id,error:e.message},"*")}).finally(()=>{t=void 0,n()})}(0,r.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",function(t){const i=t.data;"renderblocks"==i.type&&(e.push(i),n())},!1),window.parent.postMessage({source:"makecode",type:"renderready",versions:pxt.appTarget.versions},"*")})},n.startDocsServer=function(e,t,n){pxt.tickEvent("docrenderer.ready");const i=[];function s(i,r){pxt.debug(`rendering ${i}`),n&&$(n).hide(),$(t).hide(),$(e).show(),pxt.U.delay(100).then(()=>{switch(i){case"print":const e=window.localStorage.printjob;return delete window.localStorage.printjob,D(t,JSON.parse(e),void 0,!0).then(()=>pxsim.print(1e3));case"project":return D(t,JSON.parse(r)).then(()=>pxsim.print(1e3));case"projectid":return N(t,JSON.parse(r)).then(()=>pxsim.print(1e3));case"doc":return async function(e,t){t=t.replace(/^\//,"");const n=await pxt.Cloud.markdownAsync(t,void 0,!0);try{await R(e,n,{path:t})}catch(e){pxt.warn(e)}}(t,r);case"book":return function(e,t){t=t.replace(/^\//,""),pxt.tickEvent("book",{id:t}),pxt.log(`rendering book from ${t}`);let n;return $("#loading").find(".loader").addClass("text").text(lf("Compiling your book (this may take a minute)")),pxt.U.delay(100).then(()=>pxt.Cloud.markdownAsync(t,void 0,!0)).then(e=>{n=pxt.docs.buildTOC(e),pxt.log(`TOC: ${JSON.stringify(n,null,2)}`);const t=[];return pxt.docs.visitTOC(n,e=>{/^\//.test(e.path)&&!/^\/pkg\//.test(e.path)&&t.push(e)}),pxt.U.promisePoolAsync(4,t,async e=>{try{const t=await pxt.Cloud.markdownAsync(e.path,void 0,!0);e.markdown=t}catch(t){e.markdown=`_${e.path} failed to load._`}})}).then(t=>{let i=n[0].name;return pxt.docs.visitTOC(n,e=>{e.markdown&&(i+="\n\n"+e.markdown)}),R(e,i)})}(t,r);default:return R(t,r)}}).catch(e=>{$(t).html(`\n <img style="height:4em;" src="${pxt.appTarget.appTheme.docsLogo}" />\n <h1>${lf("Oops")}</h1>\n <h3>${lf("We could not load the documentation, please check your internet connection.")}</h3>\n <button class="ui button primary" id="tryagain">${lf("Try Again")}</button>`),$(t).find("#tryagain").click(()=>{s(i,r)}),window.parent&&window.parent.postMessage({type:"docfailed",docType:i,src:r},"*")}).finally(()=>{$(e).hide(),n&&$(n).show(),$(t).show()}).then(()=>{})}function a(e,t){t?(pxsim.U.addClass(e,"disabled"),e.setAttribute("aria-disabled","true")):(pxsim.U.removeClass(e,"disabled"),e.setAttribute("aria-disabled","false"))}async function l(){let e=/^#(doc|md|tutorial|book|project|projectid|print):([^&?:]+)(:([^&?:]+):([^&?:]+))?/i.exec(window.location.hash);if(e){if(n&&(i.push(window.location.hash),i.length>10&&i.shift(),i.length>1&&a(n,!1)),e[4]){let t=A.TypeScript;/^blocks$/i.test(e[4])?t=A.Blocks:/^python$/i.test(e[4])&&(t=A.Python),await I(t,e[5])}s(e[1],decodeURIComponent(e[2]))}}n&&(n.addEventListener("click",()=>{!function(){if(!n)return;i.length>1&&(i.pop(),window.location.hash=i.pop());i.length<=1&&a(n,!0)}()}),n.addEventListener("keydown",o.fireClickOnEnter),a(n,!0)),(0,r.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",w,!1),window.addEventListener("hashchange",()=>{l()},!1),parent.postMessage({type:"sidedocready"},"*"),setTimeout(()=>l(),1)})},n.renderProjectAsync=N,n.renderProjectFilesAsync=D;const O='\n<aside id=button class=box>\n<a class="ui primary button" href="@ARGS@">@BODY@</a>\n</aside>\n\n<aside id=vimeo>\n<div class="ui two column stackable grid container">\n<div class="column">\n<div class="ui embed mdvid" data-source="vimeo" data-id="@ARGS@" data-placeholder="/thumbnail/1024/vimeo/@ARGS@" data-icon="video play">\n</div>\n</div></div>\n</aside>\n\n<aside id=youtube>\n<div class="ui two column stackable grid container">\n<div class="column">\n<div class="ui embed mdvid" data-source="youtube" data-id="@ARGS@" data-placeholder="https://img.youtube.com/vi/@ARGS@/0.jpg">\n</div>\n</div></div>\n</aside>\n\n<aside id=section>\n\x3c!-- section @ARGS@ --\x3e\n</aside>\n\n<aside id=hide class=box>\n<div style=\'display:none\'>\n @BODY@\n</div>\n</aside>\n\n<aside id=avatar class=box>\n<div class=\'avatar @ARGS@\'>\n <div class=\'avatar-image\'></div>\n <div class=\'ui compact message\'>\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=hint class=box>\n<div class="ui info message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=codecard class=box>\n<pre><code class="lang-codecard">@BODY@</code></pre>\n</aside>\n\n<aside id=tutorialhint class=box>\n<div class="ui hint message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=reminder class=box>\n<div class="ui warning message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=alert class=box>\n<div class="ui negative message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=tip class=box>\n<div class="ui positive message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n\x3c!-- wrapped around ordinary content --\x3e\n<aside id=main-container class=box>\n<div class="ui text">\n @BODY@\n</div>\n</aside>\n\n\x3c!-- used for \'column\' box - they are collected and wrapped in \'column-container\' --\x3e\n<aside id=column class=aside>\n<div class=\'column\'>\n @BODY@\n</div>\n</aside>\n<aside id=column-container class=box>\n<div class="ui three column stackable grid text">\n @BODY@\n</div>\n</aside>\n@breadcrumb@\n@body@';function R(e,t,i={}){const r=pxt.docs.renderMarkdown({template:O,markdown:t,theme:pxt.appTarget.appTheme});let s=i.blocksAspectRatio||window.innerHeight<window.innerWidth?1.62:1/1.62;$(e).html(r),$(e).find("a").attr("target","_blank");const a=(0,o.defaultClientRenderOptions)();return a.tutorial=!!i.tutorial,a.blocksAspectRatio=s||a.blocksAspectRatio,a.showJavaScript=n.editorLanguageMode==A.TypeScript,i.print&&(a.showEdit=!1,a.simulator=!1),(0,o.renderAsync)(a).then(()=>{$(e).find('a[href^="/"]').removeAttr("target").each((e,t)=>{$(t).attr("href","#doc:"+$(t).attr("href").replace(/^\//,""))}),$(e).find(".ui.embed").embed()})}let L,P;function M(e,t){const{assets:r,forceCompilation:o,snippetMode:s,generateSourceMap:a}=t||{};return v(t&&t.packageId?"pub:"+t.packageId:t&&t.package?"docs:"+t.package:null,e).then(()=>T(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(l=>{if(e&&(l.fileSystem[pxt.MAIN_TS]=e),l.ast=!0,r)for(const e of Object.keys(r))l.sourceFiles.indexOf(e)<0&&l.sourceFiles.push(e),l.fileSystem[e]=r[e];let c,d,p;o?(c=pxtc.compile(l),d=c&&c.ast):d=pxtc.getTSProgram(l,L),L=d,pxt.appTarget.appTheme.python&&(p=ts.pxtc.transpile.tsToPy(d,pxt.MAIN_TS));let h=F(d,l);return ts.pxtc.localizeApisAsync(h,n.mainPkg).then(()=>{let e=pxtc.getBlocksInfo(h);(0,i.initializeAndInject)(e);const o=null==r?void 0:r[pxt.TILEMAP_JRES],l=null==r?void 0:r[pxt.IMAGES_JRES];(o||l)&&(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg),o&&u.loadTilemapJRes(JSON.parse(o),!0),l&&u.loadAssetsJRes(JSON.parse(l)));let f=pxtc.decompiler.decompileToBlocks(e,d.getSourceFile(pxt.MAIN_TS),{snippetMode:s,generateSourceMap:a});if(f.diagnostics&&f.diagnostics.length>0&&f.diagnostics.forEach(e=>pxt.error(e.messageText)),!f.success)return{package:n.mainPkg,compileProgram:d,compileJS:c,compileBlocks:f,apiInfo:h};pxt.debug(f.outfiles[pxt.MAIN_BLOCKS]);const g=(0,i.render)(f.outfiles[pxt.MAIN_BLOCKS],t);return(o||l)&&(u=null),{package:n.mainPkg,compileProgram:d,compileJS:c,compileBlocks:f,compilePython:p,apiInfo:h,blocksSvg:g}})})}function F(e,t){P||(P={});const n=Object.keys(t.fileSystem).sort().join(";");return P[n]||(P[n]=pxtc.getApiInfo(e,t.jres)),P[n]}function B(e,t){const{assets:r}=t||{};return v(t&&t.packageId?"pub:"+t.packageId:t&&t.package?"docs:"+t.package:null,"").then(()=>T(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(o=>{if(o.ast=!0,r)for(const e of Object.keys(r))o.sourceFiles.indexOf(e)<0&&o.sourceFiles.push(e),o.fileSystem[e]=r[e];const s=F(pxtc.compile(o).ast,o);return ts.pxtc.localizeApisAsync(s,n.mainPkg).then(()=>{const o=pxtc.getBlocksInfo(s);(0,i.initializeAndInject)(o);const a=null==r?void 0:r[pxt.TILEMAP_JRES],l=null==r?void 0:r[pxt.IMAGES_JRES];(a||l)&&(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg),a&&u.loadTilemapJRes(JSON.parse(a),!0),l&&u.loadAssetsJRes(JSON.parse(l)));const c=(0,i.render)(e,t);return(a||l)&&(u=null),{package:n.mainPkg,blocksSvg:c,apiInfo:s}})})}n.renderMarkdownAsync=R,n.decompileSnippetAsync=M,n.compileBlocksAsync=B;let U=[];let H=[];n.setInitCallbacks=function(e){H=e},n.init=function(){_().then(()=>{for(let e=0;e<H.length;++e)H[e]()})}},{"../pxtblocks":76,"../pxteditor/editor":167,"./renderer":183,blockly:192}],185:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.IFrameEmbeddedClient=void 0;n.IFrameEmbeddedClient=class{constructor(e){this.messageHandler=e,this.onMessageReceived=e=>{const t=e.data;if(t){if("iframeclientsetmessageport"===t.type)return this.port=e.ports[0],this.port.onmessage=this.onMessageReceived,void this.postMessage({type:"iframeclientsetmessageport"});if("iframeclientready"===t.type)return void this.sendReadyMessage()}this.messageHandler(e)},this.frameId=function(){const e=/frameid=([a-zA-Z0-9\-]+)/i.exec(window.location.href);if(e)return e[1];return}(),window.addEventListener("message",this.onMessageReceived),this.sendReadyMessage()}dispose(){window.removeEventListener("message",this.onMessageReceived),this.port&&this.port.close()}postMessage(e){this.postMessageCore(e)}postMessageCore(e){this.frameId&&(e.frameId=this.frameId),this.port?this.port.postMessage(e):window.acquireVsCodeApi?window.acquireVsCodeApi().postMessage(e):window.parent&&window.parent!==window&&window.parent.postMessage(e,"*")}sendReadyMessage(){this.postMessage({type:"iframeclientready"})}}},{}],186:[function(e,t,n){
|
|
21
|
+
Object.defineProperty(n,"__esModule",{value:!0}),n.setDuplicateOnDragStrategy=n.DuplicateOnDragStrategy=void 0;const i=e("blockly"),r=e("./duplicateOnDrag");class o extends i.dragging.BlockDragStrategy{getTargetBlock(){const e=this;return e.block.isShadow()&&(0,r.isAllowlistedShadow)(e.block)?e.block:super.getTargetBlock()}drag(e,t){if(super.drag(e,t),!t||t instanceof PointerEvent){this.block.moveDuringDrag(e)}}disconnectBlock(e){var t;const n=this;let o,s,a;const l=n.block.isShadow();if(l&&n.block.setShadow(!1),(0,r.shouldDuplicateOnDrag)(n.block)){const e=n.block.outputConnection;if(!(null==e?void 0:e.targetConnection))return;a=i.Xml.blockToDom(n.block,!0),l||(o=i.Xml.domToBlock(a,n.block.workspace)),s=e.targetConnection}e&&(n.startChildConn=null===(t=n.block.nextConnection)||void 0===t?void 0:t.targetConnection),s&&l&&s.setShadowDom(a),n.block.unplug(e),i.blockAnimations.disconnectUiEffect(n.block),(0,r.updateDuplicateOnDragState)(n.block),s&&o&&s.connect(o.outputConnection)}}n.DuplicateOnDragStrategy=o,n.setDuplicateOnDragStrategy=function(e){var t,n;null===(n=(t=e).setDragStrategy)||void 0===n||n.call(t,new o(e))}},{"./duplicateOnDrag":106,blockly:192}],106:[function(e,t,n){let i,r;function o(e){return!(!i||-1===i.indexOf(e.type))}function s(e){var t,n;if(e.isShadow()&&o(e))return!0;if(r){const i=null===(t=e.outputConnection)||void 0===t?void 0:t.targetBlock();if(i){const t=r.filter(e=>e.parentBlockType===i.type);for(const i of t)if(i&&(!i.childBlockType||i.childBlockType===e.type)){if(!i.inputName)return!0;if((null===(n=e.outputConnection.targetConnection.getParentInput())||void 0===n?void 0:n.name)===i.inputName)return!0}}}return!1}Object.defineProperty(n,"__esModule",{value:!0}),n.updateDuplicateOnDragState=n.shouldDuplicateOnDrag=n.isAllowlistedShadow=n.setDuplicateOnDrag=n.setDraggableShadowBlocks=void 0,n.setDraggableShadowBlocks=function(e){i=e},n.setDuplicateOnDrag=function(e,t,n){r||(r=[]),r.some(i=>i.parentBlockType===e&&i.inputName===t&&i.childBlockType===n)||r.push({parentBlockType:e,inputName:t,childBlockType:n})},n.isAllowlistedShadow=o,n.shouldDuplicateOnDrag=s,n.updateDuplicateOnDragState=function(e){setTimeout(()=>{const t=s(e);e.pathObject&&e.pathObject.setHasDottedOutlineOnHover(t),e.setDeletable(!t)})}},{}],107:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./duplicateOnDrag"),n),r(e("./variablesGetReporter"),n),r(e("./connectionChecker"),n),r(e("./dragStrategy"),n)},{"./connectionChecker":104,"./dragStrategy":105,"./duplicateOnDrag":106,"./variablesGetReporter":108}],108:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("./duplicateOnDrag");i.Blocks.variables_get_reporter={init:function(){this.jsonInit({type:"variables_get_reporter",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}",variableTypes:[""]}],output:null,colour:"%{BKY_VARIABLES_HUE}",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableReporter"]}),(0,r.updateDuplicateOnDragState)(this)}}},{"./duplicateOnDrag":106,blockly:192}],109:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MultiFlyoutRecyclableBlockInflater=n.HIDDEN_CLASS_NAME=void 0;const i=e("blockly");n.HIDDEN_CLASS_NAME="pxtFlyoutHidden";class r extends i.BlockFlyoutInflater{constructor(){super(...arguments),this.keyToBlock=new Map,this.blockToKey=new Map}static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,"block",r,!0)}isBlockRecycleable(e){switch(e.type){case"variables_get":case"variables_set":case"variables_change":return!1}return!0}createBlock(e,t){const r=function(e){if(e.blockxml)return"string"==typeof e.blockxml?e.blockxml:i.Xml.domToText(e.blockxml);return e.type}(e);if(!r)return super.createBlock(e,t);let o;return this.keyToBlock.has(r)&&(o=this.keyToBlock.get(r),this.keyToBlock.delete(r),t.getCanvas().appendChild(o.getSvgRoot())),o=null!=o?o:super.createBlock(e,t),this.blockToKey.set(o,r),o.removeClass(n.HIDDEN_CLASS_NAME),o.getFocusableElement().ariaHidden="false",o.setDisabledReason(!1,n.HIDDEN_CLASS_NAME),o}disposeItem(e){const t=e.getElement();if(t instanceof i.BlockSvg&&this.blockToKey.has(t)){if(this.isBlockRecycleable(t))return void this.recycleBlock(t);this.blockToKey.delete(t)}super.disposeItem(e)}clearCache(){this.blockToKey=new Map,this.keyToBlock=new Map}recycleBlock(e){const t=e.getRelativeToSurfaceXY();e.moveBy(-t.x,-t.y),e.addClass(n.HIDDEN_CLASS_NAME),e.getFocusableElement().ariaHidden="true",e.setDisabledReason(!0,n.HIDDEN_CLASS_NAME),e.getSvgRoot().remove();const i=this.blockToKey.get(e);this.keyToBlock.set(i,e),this.removeListeners(e.id)}}n.MultiFlyoutRecyclableBlockInflater=r,i.Css.register(`\n.${n.HIDDEN_CLASS_NAME} {\n display: none;\n}\n`)},{blockly:192}],110:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ButtonFlyoutInflater=void 0;const i=e("blockly"),r=e("./flyoutButton"),o="button";class s extends i.ButtonFlyoutInflater{static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,o,s,!0)}load(e,t){const n=new r.FlyoutButton(t.getWorkspace(),t.targetWorkspace,e,!1);return n.show(),new i.FlyoutItem(n,o)}}n.ButtonFlyoutInflater=s},{"./flyoutButton":112,blockly:192}],111:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.CachingFlyout=void 0;const i=e("blockly"),r=e("./blockInflater");class o extends i.VerticalFlyout{constructor(){super(...arguments),this.forceOpen=!1}clearBlockCache(){const e=this.getInflaterForType("block");e instanceof r.MultiFlyoutRecyclableBlockInflater&&e.clearCache()}getFlyoutElement(){return this.svgGroup_}setForceOpen(e){this.forceOpen=e}}n.CachingFlyout=o},{"./blockInflater":109,blockly:192}],112:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FlyoutButton=void 0;const i=e("blockly"),r={"":"usb","":"accessible-icon","":"adn","":"pied-piper-pp","":"steam","":"bluetooth-b","":"rebel","":"maxcdn","":"joomla","":"sellsy","":"connectdevelop","":"github-alt"};class o extends i.FlyoutButton{constructor(e,t,n,o){super(e,t,n,o);const s=this.getSvgRoot();if(!o){const e=17.5,t=14,n=this.height;this.width+=2*(e-i.FlyoutButton.TEXT_MARGIN_X),this.height+=2*(t-i.FlyoutButton.TEXT_MARGIN_Y);const r=s.getElementsByClassName("blocklyFlyoutButtonShadow").item(0),o=s.getElementsByClassName("blocklyFlyoutButtonBackground").item(0),a=s.getElementsByTagName("text").item(0);return r.setAttribute("width",String(this.width)),r.setAttribute("height",String(this.height)),o.setAttribute("width",String(this.width)),o.setAttribute("height",String(this.height)),a.setAttribute("x",String(this.width/2)),void a.setAttribute("y",String(parseFloat(a.getAttribute("y"))-n/2+this.height/2))}const a=n;a["web-class"]&&s.classList.add(a["web-class"]);const l=a["web-icon"],c=a["web-icon-class"],u=a["web-icon-color"],d=a["web-icon-image"];if(d){const e=20,t=this.getTargetWorkspace(),n=i.utils.dom.createSvgElement("image",{height:String(e),width:String(e),x:String(t.RTL?this.width+i.FlyoutButton.TEXT_MARGIN_X:i.FlyoutButton.TEXT_MARGIN_X),y:String(this.height/2+i.FlyoutButton.TEXT_MARGIN_Y-e/2)},s);n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);const r=e+2*i.FlyoutButton.TEXT_MARGIN_X;this.width+=r;const o=s.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);o.setAttribute("width",String(this.width));for(let e=0;e<s.children.length;e++){const t=s.children.item(e);if(t!==n&&t!==o){const e=Number(t.getAttribute("x"));t.setAttribute("x",e+r+"")}}}else if(l||c){const e=Object.keys(r).includes(l)?"brandIcon":"",t=i.utils.dom.createSvgElement("text",{class:`blocklyFlyoutLabelIcon${c?" "+c:""}${e?" "+e:""}`,x:0,y:0,"text-anchor":"start"},s);l&&(t.textContent=l),u&&t.setAttribute("style","fill: "+u);const n=this.getTargetWorkspace();t.setAttribute("dominant-baseline","central"),t.setAttribute("dy","0"),t.setAttribute("x",(n.RTL?this.width+i.FlyoutButton.TEXT_MARGIN_X:0)+""),t.setAttribute("y",this.height/2+i.FlyoutButton.TEXT_MARGIN_Y+"");const o=i.utils.dom.getTextWidth(t)+2*i.FlyoutButton.TEXT_MARGIN_X;this.width+=o;const a=s.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);a.setAttribute("width",String(this.width));for(let e=0;e<s.children.length;e++){const n=s.children.item(e);if(n!==t&&n!==a){const e=Number(n.getAttribute("x"));n.setAttribute("x",e+o+"")}}}const p=a["web-line"],h=a["web-line-width"];if(p){const e=i.utils.dom.createSvgElement("line",{class:"blocklyFlyoutLine","stroke-dasharray":p,"text-anchor":"middle"},s);e.setAttribute("x1","0"),e.setAttribute("x2",null!=h?h:this.width+""),e.setAttribute("y1",this.height+10+""),e.setAttribute("y2",this.height+10+"")}}isDisposed(){return null===this.getSvgRoot().parentNode}}n.FlyoutButton=o},{blockly:192}],113:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.registerFlyoutInflaters=n.MultiFlyoutRecyclableBlockInflater=n.LabelFlyoutInflater=n.ButtonFlyoutInflater=void 0;const o=e("./buttonFlyoutInflater");Object.defineProperty(n,"ButtonFlyoutInflater",{enumerable:!0,get:function(){return o.ButtonFlyoutInflater}});const s=e("./labelFlyoutInflater");Object.defineProperty(n,"LabelFlyoutInflater",{enumerable:!0,get:function(){return s.LabelFlyoutInflater}});const a=e("./blockInflater");Object.defineProperty(n,"MultiFlyoutRecyclableBlockInflater",{enumerable:!0,get:function(){return a.MultiFlyoutRecyclableBlockInflater}}),r(e("./cachingFlyout"),n),n.registerFlyoutInflaters=function(){o.ButtonFlyoutInflater.register(),s.LabelFlyoutInflater.register(),a.MultiFlyoutRecyclableBlockInflater.register()}},{"./blockInflater":109,"./buttonFlyoutInflater":110,"./cachingFlyout":111,"./labelFlyoutInflater":114}],114:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.LabelFlyoutInflater=void 0;const i=e("blockly"),r=e("./flyoutButton"),o="label";class s extends i.LabelFlyoutInflater{static register(){i.registry.register(i.registry.Type.FLYOUT_INFLATER,o,s,!0)}load(e,t){const n=new r.FlyoutButton(t.getWorkspace(),t.targetWorkspace,e,!0);return n.show(),new i.FlyoutItem(n,o)}}n.LabelFlyoutInflater=s},{"./flyoutButton":112,blockly:192}],115:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../constants"),o={typeName_:"",getTypeName(){return this.typeName_},removeFieldCallback(e){const t=this.getParent();(null==t?void 0:t.removeFieldCallback)&&t.removeFieldCallback(e)}};i.Blocks[r.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"bool"}],extensions:["output_boolean","text_field_color"]}),this.typeName_="boolean"}}),i.Blocks[r.ARGUMENT_EDITOR_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"text"}],extensions:["output_string","text_field_color"]}),this.typeName_="string"}}),i.Blocks[r.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"num"}],extensions:["output_number","text_field_color"]}),this.typeName_="number"}}),i.Blocks[r.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"list"}],extensions:["output_array","text_field_color"]}),this.typeName_="Array"}}),i.Blocks[r.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},o),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"arg"}],outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,extensions:["text_field_color"]}),this.typeName_="any"},mutationToDom(){const e=i.utils.xml.createElement("mutation");return e.setAttribute("typename",this.typeName_),e},domToMutation(e){this.typeName_=e.getAttribute("typename"),this.setOutput(!0,this.typeName_)}})},{"../constants":121,blockly:192}],116:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.LOCALIZATION_NAME_MUTATION_KEY=void 0;const i=e("blockly"),r=e("../constants"),o=e("../msg"),s=e("../../duplicateOnDrag");n.LOCALIZATION_NAME_MUTATION_KEY="localizationname";const a={typeName_:"",localizationName_:"",getTypeName(){return this.typeName_},getLocalizationName(){return this.localizationName_||this.getFieldValue("VALUE")},mutationToDom(){const e=i.utils.xml.createElement("mutation");return this.localizationName_&&e.setAttribute(n.LOCALIZATION_NAME_MUTATION_KEY,this.localizationName_),e},domToMutation(e){e.hasAttribute(n.LOCALIZATION_NAME_MUTATION_KEY)&&(this.localizationName_=e.getAttribute(n.LOCALIZATION_NAME_MUTATION_KEY))}};function l(e){(0,s.setDuplicateOnDragStrategy)(e),(0,s.updateDuplicateOnDragState)(e)}i.Blocks[r.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_boolean"]}),this.typeName_="boolean",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_string"]}),this.typeName_="string",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_number"]}),this.typeName_="number",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],extensions:["output_array"]}),this.typeName_="Array",l(this)}}),i.Blocks[r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},a),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_reporter",name:"VALUE",text:""}],colour:i.Msg[o.MsgKey.REPORTERS_HUE],inputsInline:!0,outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,output:null}),this.typeName_="",l(this)},mutationToDom(){const e=a.mutationToDom.call(this);return e.setAttribute("typename",this.typeName_),e},domToMutation(e){this.typeName_=e.getAttribute("typename"),this.setOutput(!0,this.typeName_),a.domToMutation.call(this,e)}})},{"../../duplicateOnDrag":107,"../constants":121,"../msg":128,blockly:192}],117:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../msg"),l=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){let r=null,o=null;if(t&&e.id in t){const n=t[e.id];r=n.block,o=n.shadow}const s=null==r?void 0:r.workspace.connectionChecker;i.Events.disable();try{if(r&&!r.isDisposed()&&t&&(null==s?void 0:s.canConnectWithReason(null==r?void 0:r.outputConnection,n.connection,!1))===i.Connection.CAN_CONNECT){let s;r.outputConnection.connect(n.connection),s=r.isShadow()?i.Xml.blockToDom(r):o||this.buildShadowDom_(e.type),"variables_get"!==s.getAttribute("type")&&n.connection.setShadowDom(s),delete t[n.name]}else this.attachShadow_(n,e.type)}finally{i.Events.enable()}},afterWorkspaceLoad:function(){var e;for(const t of this.inputList){if(t.type!==i.inputs.inputTypes.VALUE)continue;const n=null===(e=t.connection)||void 0===e?void 0:e.targetBlock();n&&n.isShadow()&&n.getVarModels().length&&n.setShadow(!1);const r=t.connection&&t.getShadowDom();(0,s.isVariableBlockType)(null==r?void 0:r.getAttribute("type"))&&t.setShadowDom(null)}},addFunctionLabel_:function(e){this.appendDummyInput("function_name").appendField(new i.FieldLabel(e,"functionNameText"),"function_name")},updateFunctionLabel_:function(e){this.getField("function_name").setValue(e)},attachShadow_(e,t){const n=(0,s.getShadowBlockInfoFromType_)(t,this.workspace),r=n[0],o=n[1],a=n[2];i.Events.disable();let l=null;try{l=this.workspace.newBlock(r),l.setFieldValue(a,o),l.setShadow("variables_get"!==r),!this.isInsertionMarker()&&l instanceof i.BlockSvg&&(l.initSvg(),l.queueRender())}finally{i.Events.enable()}l&&(l.setShadow(!0),l.outputConnection.connect(e.connection))},buildShadowDom_(e){const t=i.utils.xml.createElement("shadow"),n=(0,s.getShadowBlockInfoFromType_)(e,this.workspace),r=n[0],o=n[1],a=n[2],l="variables_get"===r;t.setAttribute("type",r);const c=i.utils.xml.createElement("field");if(c.textContent=a,l){c.setAttribute("id",a);const e=this.workspace.getVariableMap().getVariableById(a);c.textContent=e?e.getName():""}return c.setAttribute("name",o),t.appendChild(c),t},onchange(e){var t;if(this.workspace&&!this.workspace.isFlyout)if(e.type==i.Events.BLOCK_CREATE&&-1!=(null===(t=e.ids)||void 0===t?void 0:t.indexOf(this.id))){const t=this.getName(),n=(0,s.getDefinition)(t,this.workspace);if(n){const e=n.getArguments().slice(),t=this.arguments_.slice();JSON.stringify(t)!==JSON.stringify(e)&&(0,s.mutateCallersAndDefinition)(n.getName(),this.workspace,n.mutationToDom()),this.functionId_=n.functionId_}else{i.Events.setGroup(e.group);const t=i.utils.xml.createElement("xml"),n=i.utils.xml.createElement("block");n.setAttribute("type",o.FUNCTION_DEFINITION_BLOCK_TYPE);const r=this.getRelativeToSurfaceXY(),s=r.x+i.config.snapRadius*(this.RTL?-1:1),a=r.y+2*i.config.snapRadius;n.setAttribute("x",s+""),n.setAttribute("y",a+"");const l=this.mutationToDom();n.appendChild(l),t.appendChild(n),i.Xml.domToWorkspace(t,this.workspace),i.Events.setGroup(!1)}}else if(e.type==i.Events.BLOCK_DELETE){const t=this.getName();(0,s.getDefinition)(t,this.workspace)||(i.Events.setGroup(e.group),this.dispose(!0),i.Events.setGroup(!1))}},serializeChangedInputs(e){const t=[],n=(0,s.getArgMap)(e,!0);for(const e of this.arguments_){if(n[e.id])continue;const i=this.getInput(e.id).connection,r=i.targetBlock();r.isShadow()?t.push({inputName:e.id,connectedShadow:i.getShadowState(!0)}):t.push({inputName:e.id,connectedBlock:r.id})}return t}});i.Blocks[o.FUNCTION_CALL_BLOCK_TYPE]=Object.assign(Object.assign({},l),{init:function(){this.jsonInit({extensions:["function_contextmenu_edit"]}),this.name_="",this.arguments_=[],this.functionId_="",this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(i.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(i.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(i.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}}),i.Blocks[o.FUNCTION_CALL_OUTPUT_BLOCK_TYPE]=Object.assign(Object.assign({},l),{init:function(){this.jsonInit({extensions:["function_contextmenu_edit"]}),this.name_="",this.arguments_=[],this.functionId_="",this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,null),this.setOutputShape((new i.zelos.ConstantProvider).SHAPES.ROUND),this.setColour(i.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(i.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(i.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../msg":128,"../utils":130,blockly:192}],118:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.newFunctionMutation=void 0;const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../fields/fieldAutocapitalizeTextInput"),l=e("../functionManager"),c=e("../msg"),u=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){const i=this.createArgumentEditor_(e.type,e.name);n.connection.connect(i.outputConnection)},addFunctionLabel_:function(e){const t=new a.FieldAutocapitalizeTextInput(e||"",void 0,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(t,"function_name")},updateFunctionLabel_:function(e){i.Events.disable(),this.getField("function_name").setValue(e),i.Events.enable()},createArgumentEditor_:function(e,t){let n;i.Events.disable();try{let r="";switch(e){case"boolean":r=o.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE;break;case"number":r=o.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE;break;case"string":r=o.ARGUMENT_EDITOR_STRING_BLOCK_TYPE;break;case"Array":r=o.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE;break;default:r=o.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE}n=r==o.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE?(0,s.createCustomArgumentEditor)(e,this.workspace):this.workspace.newBlock(r),n.setFieldValue(t,"TEXT"),n.setShadow(!0),!this.isInsertionMarker()&&n instanceof i.BlockSvg&&(n.initSvg(),n.queueRender())}finally{i.Events.enable()}return n},async focusLastEditorAsync_(){if(await i.renderManagement.finishQueuedRenders(),this.inputList.length>0){let e=this.inputList[this.inputList.length-2];if(e.type==i.inputs.inputTypes.DUMMY){const t=this.workspace;t instanceof i.WorkspaceSvg&&t.centerOnBlock(this.id,!0),e.fieldRow[0].showEditor()}else if(e.type==i.inputs.inputTypes.VALUE){const t=e.connection.targetBlock(),n=t.workspace;n instanceof i.WorkspaceSvg&&n.centerOnBlock(t.id,!0),t.getField("TEXT").showEditor()}}},removeFieldCallback(e){let t=null;for(let n=0;n<this.inputList.length&&!t;n++){let i=this.inputList[n];if(i.connection){let n=i.connection.targetBlock();if(!n)continue;n.getField(e.name)===e&&(t=i.name)}else for(let n=0;n<i.fieldRow.length;n++)i.fieldRow[n]==e&&(t=i.name)}t&&(i.WidgetDiv.hide(),this.removeInput(t),this.updateFunctionSignature(),this.updateDisplay_())},addParam_(e,t){i.WidgetDiv.hide();const n=(0,s.findUniqueParamName)(t,this.arguments_.map(e=>e.name));this.arguments_.push({id:i.utils.idGenerator.genUid(),name:n,type:e}),this.updateDisplay_(),this.focusLastEditorAsync_()},addBooleanExternal(){this.addParam_("boolean",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME])},addStringExternal(){this.addParam_("string",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_STRING_ARG_NAME])},addNumberExternal(){this.addParam_("number",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME])},addArrayExternal(){this.addParam_("Array",i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME])},addCustomExternal(e){this.addParam_(e,l.FunctionManager.getInstance().getArgumentNameForType(e))},updateFunctionSignature(){this.arguments_=[];for(let e=1;e<this.inputList.length;e++){const t=this.inputList[e];switch(t.type){case i.inputs.inputTypes.STATEMENT:break;case i.inputs.inputTypes.DUMMY:this.name_=t.fieldRow[0].getValue()||t.fieldRow[0].getText();break;case i.inputs.inputTypes.VALUE:const e=t.connection.targetBlock();this.arguments_.push({id:t.name,name:e.getFieldValue("TEXT"),type:e.getTypeName()});break;default:pxt.warn("Unexpected input type on a function mutator root: "+t.type)}}}});n.newFunctionMutation=function(e){const t=(0,s.findLegalName)(i.Msg[c.MsgKey.FUNCTIONS_DEFAULT_FUNCTION_NAME],e),n=i.utils.xml.createElement("mutation");return n.setAttribute("name",t),n.setAttribute("functionid",i.utils.idGenerator.genUid()),n},i.Blocks[o.FUNCTION_DECLARATION_BLOCK_TYPE]=Object.assign(Object.assign({},u),{init:function(){this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(i.Msg[c.MsgKey.PROCEDURES_HUE]),this.setStatements_(!0),this.setDeletable(!1),this.setMovable(!1),this.contextMenu=!1,this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../fields/fieldAutocapitalizeTextInput":125,"../functionManager":126,"../msg":128,"../utils":130,blockly:192}],119:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../commonFunctionMixin"),o=e("../constants"),s=e("../utils"),a=e("../fields/fieldAutocapitalizeTextInput"),l=e("../msg"),c=e("../functionManager"),u=e("../svgs"),d=e("../../duplicateOnDrag"),p=e("../../../fields/field_imagenotext"),h=e("../../../utils"),f=Object.assign(Object.assign({},r.COMMON_FUNCTION_MIXIN),{populateArgument_:function(e,t,n){let i,r=null;if(null==t?void 0:t[e.id]){r=t[e.id].block}t&&r&&!r.isDisposed()?(i=r,i.setFieldValue(e.name,"VALUE"),delete t[n.name]):i=this.createArgumentReporter_(e),n.connection.connect(i.outputConnection)},afterWorkspaceLoad:function(){for(const e of this.inputList){if(e.type!==i.inputs.inputTypes.VALUE)continue;const t=this.arguments_.find(t=>t.id===e.name);if(!t)continue;let n=e.connection.targetBlock();n||(this.populateArgument_(t,null,e),n=e.connection.targetBlock()),n.setFieldValue(t.name,"VALUE"),n.isShadow()&&n.setShadow(!1),e.setShadowDom(null)}},addFunctionLabel_:function(e){const t=new a.FieldAutocapitalizeTextInput(e||"",s.rename,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(t,"function_name")},updateFunctionLabel_:function(e){i.Events.disable(),this.getField("function_name").setValue(e),i.Events.enable()},createArgumentReporter_:function(e){let t,n="";switch(e.type){case"boolean":n=o.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE;break;case"number":n=o.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE;break;case"string":n=o.ARGUMENT_REPORTER_STRING_BLOCK_TYPE;break;case"Array":n=o.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE;break;default:n=o.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}i.Events.disable();try{t=n==o.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE?(0,s.createCustomArgumentReporter)(e.type,this.workspace):this.workspace.newBlock(n),t.setFieldValue(e.name,"VALUE"),t.setShadow(!0),!this.isInsertionMarker()&&t instanceof i.BlockSvg&&(t.initSvg(),t.queueRender())}finally{i.Events.enable()}return t},customContextMenu:function(e){var t,n;this.isInFlyout||(null===(n=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===n?void 0:n.readOnly)||(e.push(this.makeEditOption()),e.push(this.makeCallOption()))},makeEditOption:function(){var e,t;return{enabled:!(null===(t=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===t?void 0:t.readOnly),text:i.Msg.FUNCTIONS_EDIT_OPTION,callback:()=>{!function(e){if(e.type==o.FUNCTION_CALL_BLOCK_TYPE||e.type==o.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const t=e.workspace;e=(0,s.getDefinition)(e.getName(),t)}i.hideChaff(),i.getSelected()&&i.getSelected().unselect();c.FunctionManager.getInstance().editFunctionExternal(e.mutationToDom(),t=>{t&&((0,s.mutateCallersAndDefinition)(e.getName(),e.workspace,t),e.updateDisplay_()),setTimeout(()=>{e.afterWorkspaceLoad&&e.afterWorkspaceLoad()})})}(this)}}},makeCallOption:function(){var e,t;const n=this.getName(),r=i.utils.xml.createElement("mutation");r.setAttribute("name",n);const s=i.utils.xml.createElement("block");return s.appendChild(r),s.setAttribute("type",o.FUNCTION_CALL_BLOCK_TYPE),{enabled:this.workspace.remainingCapacity()>0&&!(null===(t=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===t?void 0:t.readOnly),text:i.Msg.FUNCTIONS_CREATE_CALL_OPTION.replace("%1",n),callback:i.ContextMenu.callbackFactory(this,s)}}});i.Blocks[o.FUNCTION_DEFINITION_BLOCK_TYPE]=Object.assign(Object.assign({},f),{init:function(){if(this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(i.Msg[l.MsgKey.PROCEDURES_HUE]),this.setTooltip(i.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_TOOLTIP]),this.setHelpUrl(i.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_HELPURL]),this.setStatements_(!0),this.setInputsInline(!0),this.workspace.options.collapse){const e=u.COLLAPSE_IMAGE_DATAURI;this.appendDummyInput("function_collapse").appendField(new p.FieldImageNoText(e,24,24,lf("Collapse block"),()=>{var e;this.setCollapsed(!0);const t=null===(e=this.inputList.find(e=>e.name===i.constants.COLLAPSED_INPUT_NAME))||void 0===e?void 0:e.fieldRow[1];(0,h.maybeMoveFocusFromButton)(t)},!1))}}}),(0,d.setDuplicateOnDrag)(o.FUNCTION_DEFINITION_BLOCK_TYPE)},{"../../../fields/field_imagenotext":38,"../../../utils":155,"../../duplicateOnDrag":107,"../commonFunctionMixin":120,"../constants":121,"../fields/fieldAutocapitalizeTextInput":125,"../functionManager":126,"../msg":128,"../svgs":129,"../utils":130,blockly:192}],120:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.COMMON_FUNCTION_MIXIN=void 0;const i=e("blockly"),r=e("./constants"),o=e("./utils"),s=e("./msg");n.COMMON_FUNCTION_MIXIN={name_:"",functionId_:"",arguments_:[],mutationToDom:function(){this.ensureIds_();const e=i.utils.xml.createElement("mutation");return e.setAttribute("name",this.name_),e.setAttribute("functionid",this.functionId_),this.arguments_.forEach(function(t){const n=i.utils.xml.createElement("arg");n.setAttribute("name",t.name),n.setAttribute("id",t.id),n.setAttribute("type",t.type),e.appendChild(n)}),e},domToMutation:function(e){const t=[];for(let n=0;n<e.childNodes.length;++n){const i=e.childNodes[n];"arg"==i.nodeName.toLowerCase()&&t.push({id:i.getAttribute("id"),name:i.getAttribute("name"),type:i.getAttribute("type")})}this.arguments_=t,this.name_=e.getAttribute("name"),this.restoreSavedFunctionId(e.getAttribute("functionid"))},saveExtraState:function(){return{name:this.name_,functionid:this.functionId_,arguments:this.arguments_.slice()}},loadExtraState:function(e){this.arguments_=e.arguments.slice(),this.name_=e.name,this.restoreSavedFunctionId(e.functionid)},restoreSavedFunctionId:function(e){(0,o.idsInUse)(this.workspace).indexOf(e)<0&&(this.functionId_=e),this.ensureIds_();let t=null;this instanceof i.BlockSvg&&(t=this.getHeightWidth()),this.type!==r.FUNCTION_DEFINITION_BLOCK_TYPE||t&&!t.height&&!t.width?this.updateDisplay_():!this.getFieldValue("function_name")&&this.name_&&(this.setFieldValue(this.name_,"function_name"),this.updateDisplay_())},getName:function(){return this.name_},getFunctionId:function(){return this.functionId_},getArguments:function(){return this.arguments_},removeValueInputs_:function(){const e=[];for(let t,n=0;t=this.inputList[n];n++)t.type==i.inputs.inputTypes.VALUE?t.dispose():e.push(t);this.inputList=e},createAllInputs_:function(){let e=!1,t=!1;if(this.inputList.forEach(function(n){"function_title"==n.name?e=!0:"function_name"==n.name&&(t=!0)}),!e){let e="";switch(this.type){case r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case r.FUNCTION_CALL_BLOCK_TYPE:e=i.Msg[s.MsgKey.FUNCTIONS_CALL_TITLE];break;case r.FUNCTION_DEFINITION_BLOCK_TYPE:case r.FUNCTION_DECLARATION_BLOCK_TYPE:e=i.Msg[s.MsgKey.FUNCTIONS_DEFNORETURN_TITLE]}this.appendDummyInput("function_title").appendField(e,"function_title")}t?this.updateFunctionLabel_(this.getName()):this.addFunctionLabel_(this.getName()),this.updateArgumentInputs_()},updateArgumentInputs_(){var e;for(const e of this.inputList)if(e.type===i.inputs.inputTypes.VALUE&&!this.arguments_.some(t=>t.id===e.name)){if(this.type===r.FUNCTION_DEFINITION_BLOCK_TYPE){const t=e.connection.targetBlock();t&&t.dispose()}this.removeInput(e.name)}let t=this.inputList.findIndex(e=>e.type===i.inputs.inputTypes.VALUE);-1===t&&(t=this.inputList.length);for(const n of this.arguments_){let i=this.inputList.find(e=>e.name===n.id);const r=!i;r&&(i=this.appendValueInput(n.id)),this.inputList.indexOf(i)!==t&&this.moveInputBefore(i.name,null===(e=this.inputList[t+1])||void 0===e?void 0:e.name),(0,o.isCustomType)(n.type)?i.setCheck(n.type):i.setCheck(n.type.charAt(0).toUpperCase()+n.type.slice(1)),!this.isInsertionMarker()&&r&&this.populateArgument_(n,void 0,i),t++}this.inputList.some(e=>"function_collapse"===e.name)&&this.moveInputBefore("function_collapse",null),this.hasStatements_&&this.moveInputBefore("STACK",null)},updateDisplay_:function(){let e=this.rendered;this.createAllInputs_(),e&&!this.isInsertionMarker()&&this instanceof i.BlockSvg&&(this.initSvg(),this.queueRender())},setStatements_:function(e){this.hasStatements_!==e&&(e?this.appendStatementInput("STACK"):this.removeInput("STACK",!0),this.hasStatements_=e)},ensureIds_:function(){switch(this.type){case r.FUNCTION_DEFINITION_BLOCK_TYPE:this.functionId_&&"null"!=this.functionId_||(this.functionId_=i.utils.idGenerator.genUid());for(let e=0;e<this.arguments_.length;++e)this.arguments_[e].id||(this.arguments_[e].id=i.utils.idGenerator.genUid());break;case r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case r.FUNCTION_CALL_BLOCK_TYPE:const e=(0,o.getDefinition)(this.name_,this.workspace);if(e){this.functionId_=e.getFunctionId();const t=e.getArguments();for(let e=0;e<this.arguments_.length;++e)for(let n=0;n<t.length;++n)if(t[n].name==this.arguments_[e].name){this.arguments_[e].id=t[n].id;break}}}}}},{"./constants":121,"./msg":128,"./utils":130,blockly:192}],121:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE=n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE=n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE=n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE=n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE=n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE=n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE=n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE=n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE=n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE=n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE=n.FUNCTION_CALL_BLOCK_TYPE=n.FUNCTION_DECLARATION_BLOCK_TYPE=n.FUNCTION_DEFINITION_BLOCK_TYPE=void 0,n.FUNCTION_DEFINITION_BLOCK_TYPE="function_definition",n.FUNCTION_DECLARATION_BLOCK_TYPE="function_declaration",n.FUNCTION_CALL_BLOCK_TYPE="function_call",n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE="function_call_output",n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE="argument_reporter_boolean",n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE="argument_reporter_number",n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE="argument_reporter_string",n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE="argument_reporter_array",n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE="argument_reporter_custom",n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE="argument_editor_boolean",n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE="argument_editor_number",n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE="argument_editor_string",n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE="argument_editor_array",n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE="argument_editor_custom"},{}],122:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("./utils"),o=e("./msg"),s=e("./svgs"),a=new i.zelos.ConstantProvider;const l={customContextMenu:function(e){var t,n;const s={enabled:!(null===(n=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===n?void 0:n.readOnly),text:i.Msg[o.MsgKey.FUNCTIONS_GO_TO_DEFINITION_OPTION],callback:()=>{const e=this.getField("function_name").getText(),t=(0,r.getDefinition)(e,this.workspace);t&&this.workspace instanceof i.WorkspaceSvg&&this.workspace.centerOnBlock(t.id,!0)}};e.push(s)}},c={customContextMenu:function(e){if(this.isCollapsed())return;const t={text:i.Msg.RENAME_VARIABLE,enabled:!this.workspace.options.readOnly,callback:()=>{const e=this.workspace,t=this.getField("VAR").getVariable();i.Variables.renameVariable(e,t)}};if(e.unshift(t),!this.isInFlyout){const t=this.workspace.getVariableMap().getVariablesOfType("");for(const n of t){const t={enabled:!this.workspace.options.readOnly,text:n.getName(),callback:()=>{let e=this.getField("VAR");e||pxt.log("Tried to get a variable field on the wrong type of block."),e.setValue(n.getId())}};e.unshift(t)}}}};i.Extensions.registerMixin("function_contextmenu_edit",l),i.Extensions.registerMixin("contextMenu_variableReporter",c),i.Extensions.register("output_number",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Number")}),i.Extensions.register("output_string",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"String")}),i.Extensions.register("output_boolean",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.HEXAGONAL),this.setOutput(!0,"Boolean")}),i.Extensions.register("output_array",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Array")}),i.Extensions.register("text_field_color",function(){if(this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer().getConstants();this.setColour(e.FIELD_BORDER_RECT_COLOUR)}else this.setColour("#fff")}),i.Extensions.register("inline-svgs",function(){this.ADD_IMAGE_DATAURI=s.ADD_IMAGE_DATAURI,this.REMOVE_IMAGE_DATAURI=s.REMOVE_IMAGE_DATAURI})},{"./msg":128,"./svgs":129,"./utils":130,blockly:192}],123:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldArgumentEditor=void 0;const i=e("blockly"),r=e("../functionManager"),o=e("../../../external"),s=e("../msg");class a extends i.FieldTextInput{constructor(e,t,n){super(e,t,n)}showEditor(e){var t,n;super.showEditor(e);const o=i.WidgetDiv.getDiv();o.className+=" argumentEditorInput";const s=document.createElement("img");s.setAttribute("class","argumentEditorRemoveIcon"),s.setAttribute("src",a.REMOVE_ARG_URI),this.removeButtonMouseWrapper_=i.browserEvents.conditionalBind(s,"mousedown",this,this.removeCallback),o.appendChild(s);const l=null===(t=this.sourceBlock_)||void 0===t?void 0:t.getTypeName();if(l&&(null===(n=this.sourceBlock_)||void 0===n?void 0:n.workspace)){const e=r.FunctionManager.getInstance().getIconForType(l);if(e){const t=e+" icon argumentEditorTypeIcon",n=document.createElement("i");n.className=t,o.appendChild(n)}}}showEditor_(e,t=!1,n=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(i.utils.userAgent.MOBILE||i.utils.userAgent.ANDROID||i.utils.userAgent.IPAD)?this.showPromptEditorModal():super.showEditor_(e,t,n)}showPromptEditorModal(){(0,o.prompt)(i.Msg.CHANGE_VALUE_TITLE,this.getText(),e=>{null!==e&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)},{placeholder:void 0,buttons:[{label:i.Msg[s.MsgKey.FUNCTIONS_DELETE_PARAMETER_BUTTON],className:"red",icon:"trash",onclick:()=>{this.removeCallback()}}]})}removeCallback(){var e,t;const n=null===(e=this.sourceBlock_)||void 0===e?void 0:e.getParent();if(!n)return;let r;for(const e of n.inputList){if((null===(t=e.connection)||void 0===t?void 0:t.targetBlock())===this.sourceBlock_){r=e.name;break}}r&&(i.WidgetDiv.hide(),n.removeInput(r))}}n.FieldArgumentEditor=a,a.REMOVE_ARG_URI="data:image/svg+xml;charset=UTF-8,%3c?xml version='1.0' encoding='UTF-8' standalone='no'?%3e%3csvg width='20px' height='20px' viewBox='0 0 20 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch --%3e%3ctitle%3edelete-argument v2%3c/title%3e%3cdesc%3eCreated with Sketch.%3c/desc%3e%3cdefs%3e%3c/defs%3e%3cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3e%3cg id='delete-argument-v2' stroke='%23FF661A'%3e%3cg id='Group' transform='translate(3.000000, 2.500000)'%3e%3cpath d='M1,3 L13,3 L11.8900496,14.0995037 C11.8389294,14.6107055 11.4087639,15 10.8950124,15 L3.10498756,15 C2.59123611,15 2.16107055,14.6107055 2.10995037,14.0995037 L1,3 Z' id='Rectangle' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M7,11 L7,6' id='Line' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M9.5,11 L9.5,6' id='Line-Copy' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3cpath d='M4.5,11 L4.5,6' id='Line-Copy-2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3c/path%3e%3crect id='Rectangle-2' fill='%23FF661A' x='0' y='2.5' width='14' height='1' rx='0.5'%3e%3c/rect%3e%3cpath d='M6,0 L8,0 C8.55228475,-1.01453063e-16 9,0.44771525 9,1 L9,3 L5,3 L5,1 C5,0.44771525 5.44771525,1.01453063e-16 6,0 Z' id='Rectangle-3' stroke-width='1.5'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",i.fieldRegistry.register("field_argument_editor",a),i.Css.register("\n\n.argumentEditorInput {\n overflow: visible;\n}\n\n.functioneditor i.argumentEditorTypeIcon {\n color: var(--pxt-target-foreground1);\n position: absolute;\n width: 24px;\n height: 24px;\n top: 40px;\n left: 50%;\n margin-left: -12px;\n}\n\n.argumentEditorRemoveIcon {\n position: absolute;\n width: 24px;\n height: 24px;\n top: -40px;\n left: 50%;\n margin-left: -12px;\n cursor: pointer;\n}\n\n")},{"../../../external":25,"../functionManager":126,"../msg":128,blockly:192}],124:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.setArgumentReporterLocalizeFunction=n.FieldArgumentReporter=void 0;const i=e("blockly"),r=e("../utils");let o;class s extends i.FieldLabelSerializable{getDisplayText_(){const e=this.getSourceBlock();if(e&&(0,r.isFunctionArgumentReporter)(e)&&o){const t=o(this,e);if(t)return t}return super.getDisplayText_()}}n.FieldArgumentReporter=s,n.setArgumentReporterLocalizeFunction=function(e){o=e},i.registry.register(i.registry.Type.FIELD,"field_argument_reporter",s)},{"../utils":130,blockly:192}],125:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldAutocapitalizeTextInput=void 0;const i=e("blockly");class r extends i.FieldTextInput{constructor(e,t,n){super(e,t,n),this.disableAutocapitalize=!1}setAutocapitalize(e){this.disableAutocapitalize=!e,this.htmlInput_&&(this.disableAutocapitalize?this.htmlInput_.setAttribute("autocapitalize","none"):this.htmlInput_.removeAttribute("autocapitalize"))}configure_(e){super.configure_(e),void 0!==e.disableAutocapitalize&&(this.disableAutocapitalize=e.disableAutocapitalize)}widgetCreate_(){const e=super.widgetCreate_();return this.disableAutocapitalize&&e.setAttribute("autocapitalize","none"),e}}n.FieldAutocapitalizeTextInput=r,i.fieldRegistry.register("field_autocapitalize_text_input",r)},{blockly:192}],126:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FunctionManager=void 0;const i=e("blockly"),r=e("./msg");class o{constructor(){this.typeIcons={},this.typeArgumentNames={}}static getInstance(){return o.instance}getIconForType(e){return this.typeIcons[e]}setIconForType(e,t){this.typeIcons[e]=t}setArgumentNameForType(e,t){this.typeArgumentNames[e]=t}getArgumentNameForType(e){return this.typeArgumentNames[e]?this.typeArgumentNames[e]:i.Msg[r.MsgKey.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME]}setEditFunctionExternal(e){this._editFunctionExternal=e}editFunctionExternal(e,t){this._editFunctionExternal?this._editFunctionExternal(e,t):pxt.warn("External function editor must be overriden: Blockly.Functions.editFunctionExternalHandler",e,t)}}n.FunctionManager=o,o.instance=new o},{"./msg":128,blockly:192}],127:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.validateFunctionExternal=n.getAllFunctionDefinitionBlocks=n.getDefinition=n.flyoutCategory=void 0,r(e("./msg"),n),r(e("./extensions"),n),r(e("./fields/fieldArgumentEditor"),n),r(e("./fields/fieldArgumentReporter"),n),r(e("./fields/fieldAutocapitalizeTextInput"),n),r(e("./blocks/argumentEditorBlocks"),n),r(e("./blocks/argumentReporterBlocks"),n),r(e("./blocks/functionDeclarationBlock"),n),r(e("./blocks/functionDefinitionBlock"),n),r(e("./blocks/functionCallBlocks"),n),r(e("./functionManager"),n);var o=e("./utils");Object.defineProperty(n,"flyoutCategory",{enumerable:!0,get:function(){return o.flyoutCategory}}),Object.defineProperty(n,"getDefinition",{enumerable:!0,get:function(){return o.getDefinition}}),Object.defineProperty(n,"getAllFunctionDefinitionBlocks",{enumerable:!0,get:function(){return o.getAllFunctionDefinitionBlocks}}),Object.defineProperty(n,"validateFunctionExternal",{enumerable:!0,get:function(){return o.validateFunctionExternal}})},{"./blocks/argumentEditorBlocks":115,"./blocks/argumentReporterBlocks":116,"./blocks/functionCallBlocks":117,"./blocks/functionDeclarationBlock":118,"./blocks/functionDefinitionBlock":119,"./extensions":122,"./fields/fieldArgumentEditor":123,"./fields/fieldArgumentReporter":124,"./fields/fieldAutocapitalizeTextInput":125,"./functionManager":126,"./msg":128,"./utils":130}],128:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MsgKey=void 0;const i=e("blockly");var r;function o(e,t){i.Msg[e]||(i.Msg[e]=t)}!function(e){e.REPORTERS_HUE="REPORTERS_HUE",e.FUNCTIONS_CALL_TITLE="FUNCTIONS_CALL_TITLE",e.FUNCTIONS_DEFNORETURN_TITLE="FUNCTIONS_DEFNORETURN_TITLE",e.FUNCTIONS_GO_TO_DEFINITION_OPTION="FUNCTIONS_GO_TO_DEFINITION_OPTION",e.FUNCTION_CALL_TOOLTIP="FUNCTION_CALL_TOOLTIP",e.PROCEDURES_HUE="PROCEDURES_HUE",e.PROCEDURES_CALLNORETURN_HELPURL="PROCEDURES_CALLNORETURN_HELPURL",e.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME="FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME",e.FUNCTIONS_DEFAULT_STRING_ARG_NAME="FUNCTIONS_DEFAULT_STRING_ARG_NAME",e.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME="FUNCTIONS_DEFAULT_NUMBER_ARG_NAME",e.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME="FUNCTIONS_DEFAULT_ARRAY_ARG_NAME",e.PROCEDURES_DEFNORETURN_TOOLTIP="PROCEDURES_DEFNORETURN_TOOLTIP",e.PROCEDURES_DEFNORETURN_HELPURL="PROCEDURES_DEFNORETURN_HELPURL",e.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME="FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME",e.FUNCTIONS_DEFAULT_FUNCTION_NAME="FUNCTIONS_DEFAULT_FUNCTION_NAME",e.FUNCTION_CREATE_NEW="FUNCTION_CREATE_NEW",e.FUNCTION_FLYOUT_LABEL="FUNCTION_FLYOUT_LABEL",e.FUNCTIONS_EDIT_OPTION="FUNCTIONS_EDIT_OPTION",e.FUNCTIONS_CREATE_CALL_OPTION="FUNCTIONS_CREATE_CALL_OPTION",e.FUNCTIONS_DELETE_PARAMETER_BUTTON="FUNCTIONS_DELETE_PARAMETER_BUTTON"}(r=n.MsgKey||(n.MsgKey={})),o(r.REPORTERS_HUE,"#A80000"),o(r.FUNCTIONS_CALL_TITLE,"call"),o(r.FUNCTIONS_DEFNORETURN_TITLE,"function"),o(r.FUNCTIONS_GO_TO_DEFINITION_OPTION,"Go to Definition"),o(r.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME,"bool"),o(r.FUNCTIONS_DEFAULT_STRING_ARG_NAME,"text"),o(r.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME,"num"),o(r.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME,"array"),o(r.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME,"value"),o(r.FUNCTIONS_DEFAULT_FUNCTION_NAME,"doSomething"),o(r.FUNCTION_CREATE_NEW,"Make a Function"),o(r.FUNCTION_FLYOUT_LABEL,"Your Functions"),o(r.FUNCTIONS_EDIT_OPTION,"Edit Function"),o(r.FUNCTIONS_CREATE_CALL_OPTION,"Create 'call %1'"),o(r.FUNCTIONS_DELETE_PARAMETER_BUTTON,"Delete")},{blockly:192}],129:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.REMOVE_IMAGE_DATAURI=n.ADD_IMAGE_DATAURI=n.COLLAPSE_IMAGE_DATAURI=void 0,n.COLLAPSE_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.354)'%3E%3Cpath d='m1611 367.42q0 53-37 90l-651 651q-38 38-91 38-54 0-90-38l-651-651q-38-36-38-90 0-53 38-91l74-75q39-37 91-37 53 0 90 37l486 486 486-486q37-37 90-37 52 0 91 37l75 75q37 39 37 91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A",n.ADD_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJhZGQuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjQ4MjEiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NjkiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjEyLjkxNTI1NCIKICAgICBpbmtzY2FwZTpjeT0iMTYuMDY3Nzk2IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0icmVwZWF0IiAvPjxzdHlsZQogICAgIHR5cGU9InRleHQvY3NzIgogICAgIGlkPSJzdHlsZTMiPgoJLnN0MHtmaWxsOiNDRjhCMTc7fQoJLnN0MXtmaWxsOiNGRkZGRkY7fQo8L3N0eWxlPjx0aXRsZQogICAgIGlkPSJ0aXRsZTUiPnJlcGVhdDwvdGl0bGU+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMiCiAgICAgd2lkdGg9IjQuMDUwMDAwMiIKICAgICBoZWlnaHQ9IjEyLjM5NzA1IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSItMTguMTk4NTI2IgogICAgIHJ4PSIwLjgxIgogICAgIHJ5PSIwLjgxIgogICAgIHRyYW5zZm9ybT0ic2NhbGUoMSwtMSkiIC8+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMtMSIKICAgICB3aWR0aD0iNC4wNTAwMDAyIgogICAgIGhlaWdodD0iMTIuMzk3MTE5IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSI1LjgwMTQ0MDciCiAgICAgcng9IjAuODEiCiAgICAgcnk9IjAuODEiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMCwxLDEsMCwwLDApIiAvPjxjaXJjbGUKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6I2ZmZmZmZjtzdHJva2Utd2lkdGg6MjtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MSIKICAgICBpZD0icGF0aDQxMzYiCiAgICAgY3g9IjEyIgogICAgIGN5PSIxMiIKICAgICByPSIxMC41MDMxOTEiIC8+PC9zdmc+",n.REMOVE_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJyZW1vdmUuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjFhZmYiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NTAiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjAuMDUwODQ3NTIxIgogICAgIGlua3NjYXBlOmN5PSI5Ljk2NjEwMTciCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJyZXBlYXQiIC8+PHN0eWxlCiAgICAgdHlwZT0idGV4dC9jc3MiCiAgICAgaWQ9InN0eWxlMyI+Cgkuc3Qwe2ZpbGw6I0NGOEIxNzt9Cgkuc3Qxe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU+PHRpdGxlCiAgICAgaWQ9InRpdGxlNSI+cmVwZWF0PC90aXRsZT48cmVjdAogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eTowLjA3ODQzMTM3IgogICAgIGlkPSJyZWN0NDE0My0xIgogICAgIHdpZHRoPSI0LjA1MDAwMDIiCiAgICAgaGVpZ2h0PSIxMi4zOTcxMTkiCiAgICAgeD0iOS45NzUwMDA0IgogICAgIHk9IjUuODAxNDQwNyIKICAgICByeD0iMC44MSIKICAgICByeT0iMC44MSIKICAgICB0cmFuc2Zvcm09Im1hdHJpeCgwLDEsMSwwLDAsMCkiIC8+PGNpcmNsZQogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojZmZmZmZmO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eToxIgogICAgIGlkPSJwYXRoNDEzNiIKICAgICBjeD0iMTIiCiAgICAgY3k9IjEyIgogICAgIHI9IjEwLjUwMzE5MSIgLz48L3N2Zz4="},{}],130:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isVariableBlockType=n.validateFunctionExternal=n.flyoutCategory=n.getShadowBlockInfoFromType_=n.findUniqueParamName=n.getArgumentReporterParent=n.doArgumentReporterDragChecks=n.isFunctionArgumentReporter=n.getArgMap=n.mutateCallersAndDefinition=n.idsInUse=n.findLegalName=n.createCustomArgumentEditor=n.createCustomArgumentReporter=n.isCustomType=n.getAllFunctionDefinitionBlocks=n.getDefinition=n.rename=void 0;const i=e("blockly"),r=e("./constants"),o=e("./functionManager"),s=e("./msg"),a=e("./blocks/functionDeclarationBlock"),l=e("../../compiler/util"),c=e("../../loader");function u(e,t){for(const n of t.getTopBlocks(!1))if(n.type===r.FUNCTION_DEFINITION_BLOCK_TYPE){const t=n;if(t.getName()===e)return t}return null}function d(e){return e.getTopBlocks(!1).filter(e=>e.type===r.FUNCTION_DEFINITION_BLOCK_TYPE)}function p(e,t,n){const r=n.newBlock(e),o=i.utils.xml.createElement("mutation");return o.setAttribute("typename",t),r.domToMutation(o),r}function h(e,t,n){if(null==n?void 0:n.isInFlyout)return e;const i=f(t,n);for(;i[e];)e=g(e);return e}function f(e,t,n){const i={};return e.getVariableMap().getAllVariables().forEach(function(e){i[e.getName()]=!0}),e.getAllBlocks(!1).forEach(function(e){const o=e;o==t||n&&o.getFunctionId&&o.getFunctionId()==n||(o.type==r.FUNCTION_DEFINITION_BLOCK_TYPE?i[o.getName()]=!0:"procedures_defreturn"==e.type||e.type)}),i}function g(e){const t=e.match(/^(.*?)(\d+)$/);return t?e=t[1]+(parseInt(t[2],10)+1):e+="2",e}function m(e,t,n){const o=u(e,t);if(o){const s=o.mutationToDom(),a=_(s,!1),l=_(n,!0),c=[];for(const e of o.getDescendants(!1)){if(!y(e))continue;const t=b(e,e);if(t&&t!==o)continue;const n=e.getFieldValue("VALUE"),i=l[a[n]];if(n===i)continue;const r=e.outputConnection.targetBlock().id,s=e.outputConnection.targetConnection.getParentInput().name;c.push({id:e.id,type:e.type,oldName:n,newName:i,targetBlockId:r,targetInputName:s})}const u=function(e,t){const n=[];for(const i of t.getAllBlocks(!1))if(i.type===r.FUNCTION_CALL_BLOCK_TYPE||i.type===r.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const t=i;t.getName()===e&&n.push(t)}return n}(e,o.workspace).map(e=>({id:e.id,oldMutation:i.utils.xml.domToText(e.mutationToDom()),shadows:e.serializeChangedInputs(n)})),d=new T(o.id,u,i.Xml.domToText(s),i.Xml.domToText(n),c);d.workspaceId=t.id,d.run(!0),i.Events.fire(d)}else pxt.warn("Attempted to change function "+e+", but no definition block was found on the workspace")}function _(e,t){const n={};for(let i=0;i<e.childNodes.length;++i){const r=e.childNodes[i],o=t?r.getAttribute("id"):r.getAttribute("name"),s=t?r.getAttribute("name"):r.getAttribute("id");n[o]=s}return n}function y(e){return e.type==r.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_STRING_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE||e.type==r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}function b(e,t){pxt.U.assert(y(e));const n=e.getFieldValue("VALUE"),i=e.getTypeName();for(;t.getSurroundParent();){t=t.getSurroundParent();for(const e of t.inputList){if(!e.connection||!e.name.startsWith(c.DRAGGABLE_PARAM_INPUT_PREFIX))continue;if(e.name.slice(c.DRAGGABLE_PARAM_INPUT_PREFIX.length)!==n)continue;let r=i;return"string"!==r&&"number"!==r&&"boolean"!==r||(r=r.charAt(0).toUpperCase()+r.slice(1)),-1!==e.connection.getCheck().indexOf(r)?t:void 0}}if(!t.isEnabled())return t;if((0,l.isFunctionDefinition)(t)){if(t.getArguments().some(e=>e.name===n&&e.type===i))return t}}function v(e,t){return!t||-1==t.indexOf(e)}n.rename=function(e){e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");const t=this.sourceBlock_,n=h(e,t.workspace,t),i=this.getValue();if(!e)return i;if(!n)return e;if(!i)return t.name_=n,n;if(i!=e&&i!=n){t.name_=n;const e=t.mutationToDom();t.name_=i,m(i,t.workspace,e)}return n},n.getDefinition=u,n.getAllFunctionDefinitionBlocks=d,n.isCustomType=function(e){return!("boolean"==e||"string"==e||"number"==e)},n.createCustomArgumentReporter=function(e,t){return p(r.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE,e,t)},n.createCustomArgumentEditor=function(e,t){return p(r.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE,e,t)},n.findLegalName=h,n.idsInUse=function(e){const t=[];return e.getAllBlocks(!1).forEach(function(e){e.type==r.FUNCTION_DEFINITION_BLOCK_TYPE&&t.push(e.getFunctionId())}),t},n.mutateCallersAndDefinition=m,n.getArgMap=_,n.isFunctionArgumentReporter=y,n.doArgumentReporterDragChecks=function(e,t,n){const i=e.getSourceBlock();if(!y(i))return!0;const r=t.getSourceBlock();return!r||!!b(i,r)},n.getArgumentReporterParent=b,n.findUniqueParamName=function(e,t){for(;!v(e,t);)e=g(e);return e},n.getShadowBlockInfoFromType_=function(e,t){let n="",r="",s="";switch(e){case"boolean":n="logic_boolean",r="BOOL",s="TRUE";break;case"number":n="math_number",r="NUM",s="1";break;case"string":n="text",r="TEXT",s="abc";break;case"Array":n="variables_get",r="VAR",s=i.Variables.getOrCreateVariablePackage(t,null,"list","").getId();break;default:n="variables_get",r="VAR",s=i.Variables.getOrCreateVariablePackage(t,null,o.FunctionManager.getInstance().getArgumentNameForType(e),"").getId()}return[n,r,s]},n.flyoutCategory=function(e){const t=[],n=document.createElement("button"),l=i.Msg[s.MsgKey.FUNCTION_CREATE_NEW],c="CREATE_FUNCTION";n.setAttribute("text",l),n.setAttribute("callbackKey",c),e.registerButtonCallback(c,()=>{!function(e){i.hideChaff(),i.getSelected()&&i.getSelected().unselect();o.FunctionManager.getInstance().editFunctionExternal((0,a.newFunctionMutation)(e),function(e){return function(t){if(t){const n='<xml><block type="'+r.FUNCTION_DEFINITION_BLOCK_TYPE+'">'+i.Xml.domToText(t)+"</block></xml>",o=i.utils.xml.textToDom(n);i.Events.setGroup(!0);const s=i.Xml.domToBlock(o.firstChild,e);if(s.updateDisplay_(),e.getMetrics){const t=e.getMetrics(),n=s.getHeightWidth();s.moveBy(t.viewLeft+t.viewWidth/2-n.width/2,t.viewTop+t.viewHeight/2-n.height/2),s.scheduleSnapAndBump()}e.centerOnBlock(s.id,!0),i.Events.setGroup(!1),setTimeout(()=>{s.afterWorkspaceLoad&&s.afterWorkspaceLoad(),i.getFocusManager().focusNode(s)})}}}(e))}(e)}),t.push(n);for(const n of d(e)){const e=n.getName(),r=n.getArguments(),o=i.utils.xml.createElement("block");o.setAttribute("type","function_call"),o.setAttribute("gap","16");const s=i.utils.xml.createElement("mutation");s.setAttribute("name",e),o.appendChild(s);for(let e=0;e<r.length;e++){const t=i.utils.xml.createElement("arg");t.setAttribute("name",r[e].name),t.setAttribute("type",r[e].type),t.setAttribute("id",r[e].id),s.appendChild(t)}t.push(o)}return t},n.validateFunctionExternal=function(e,t){const n=e.getAttribute("name");if(!n)return i.dialog.alert(i.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;const r={};for(let t=0;t<e.childNodes.length;++t){const n=e.childNodes[t].getAttribute("name");if(!n)return i.dialog.alert(i.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;if(r[n])return i.dialog.alert(i.Msg.FUNCTION_WARNING_DUPLICATE_ARG),!1;r[n]=!0}return r[n]?(i.dialog.alert(i.Msg.FUNCTION_WARNING_ARG_NAME_IS_FUNCTION_NAME),!1):!f(t,null,e.getAttribute("functionid"))[n]||(i.dialog.alert(i.Msg.VARIABLE_ALREADY_EXISTS.replace("%1",n)),!1)},n.isVariableBlockType=function(e){switch(e){case"argument_reporter_boolean":case"argument_reporter_number":case"argument_reporter_string":case"argument_reporter_array":case"argument_reporter_custom":case"variables_get_reporter":case"variables_get":return!0}return!1};class T extends i.Events.Abstract{constructor(e,t,n,i,r){super(),this.definition=e,this.callers=t,this.oldMutation=n,this.newMutation=i,this.descendantChanges=r,this.type="pxt_mutate_function"}static fromJson(e,t,n){const i=n=super.fromJson(e,t,n||new T(e.definition,e.callers,e.oldMutation,e.newMutation,e.descendantChanges));return i.definition=e.definition,i.callers=e.callers,i.oldMutation=e.oldMutation,i.newMutation=e.newMutation,i.descendantChanges=e.descendantChanges,n}toJson(){return{type:this.type,group:this.group,definition:this.definition,callers:this.callers,oldMutation:this.oldMutation,newMutation:this.newMutation,descendantChanges:this.descendantChanges}}run(e){const t=this.getEventWorkspace_(),n=i.utils.xml.textToDom(e?this.newMutation:this.oldMutation),r=t.getBlockById(this.definition);i.Events.disable(),r.domToMutation(n),r.updateArgumentInputs_(),r.afterWorkspaceLoad();for(const r of this.callers){const o=t.getBlockById(r.id);if(e)o.domToMutation(n);else{o.domToMutation(i.utils.xml.textToDom(r.oldMutation));for(const e of r.shadows)if(e.connectedBlock){const n=t.getBlockById(e.connectedBlock);o.getInput(e.inputName).connection.connect(n.outputConnection)}else o.getInput(e.inputName).connection.setShadowState(e.connectedShadow)}}for(const n of this.descendantChanges)if(n.newName){t.getBlockById(n.id).setFieldValue(e?n.newName:n.oldName,"VALUE")}else if(e){const e=t.getBlockById(n.id);e&&e.dispose()}else{const e=t.newBlock(n.type,n.id);e.setFieldValue(n.oldName,"VALUE"),e.initSvg();const i=t.getBlockById(n.targetBlockId).getInput(n.targetInputName).connection,r=i.targetBlock();r&&(r.isShadow()||r.dispose()),i.connect(e.outputConnection)}i.Events.enable()}}},{"../../compiler/util":15,"../../loader":79,"./blocks/functionDeclarationBlock":118,"./constants":121,"./functionManager":126,"./msg":128,blockly:192}],131:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly");i.Extensions.unregister("logic_compare"),i.Extensions.register("logic_compare",function(){})},{blockly:192}],132:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../../fields/field_imagenotext"),o=e("../../utils"),s={elseifCount_:0,elseCount_:0,valueConnections_:[],statementConnections_:[],elseStatementConnection_:null,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const e=i.utils.xml.createElement("mutation");return this.elseifCount_&&e.setAttribute("elseif",this.elseifCount_+""),this.elseCount_&&e.setAttribute("else","1"),e},domToMutation:function(e){e&&(this.elseifCount_=parseInt(e.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(e.getAttribute("else"),10)||0,this.rebuildShape_())},storeConnections_:function(e){e||(e=0),this.valueConnections_=[null],this.statementConnections_=[null],this.elseStatementConnection_=null;for(let t=1;t<=this.elseifCount_;t++)e!=t&&(this.valueConnections_.push(this.getInput("IF"+t).connection.targetConnection),this.statementConnections_.push(this.getInput("DO"+t).connection.targetConnection));this.getInput("ELSE")&&(this.elseStatementConnection_=this.getInput("ELSE").connection.targetConnection)},restoreConnections_:function(){var e,t;for(let t=1;t<=this.elseifCount_;t++)this.reconnectValueConnection_(t,this.valueConnections_),null===(e=this.statementConnections_[t])||void 0===e||e.reconnect(this,"DO"+t);this.getInput("ELSE")&&(null===(t=this.elseStatementConnection_)||void 0===t||t.reconnect(this,"ELSE"))},addElse_:function(){i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch added."));this.update_(()=>{this.elseCount_++})},removeElse_:function(){var e,t;i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch removed."));this.update_(()=>{this.elseCount_--});const n="IF"+this.elseifCount_;(0,o.maybeMoveFocusFromButton)(null===(t=null===(e=this.getInput(n))||void 0===e?void 0:e.connection)||void 0===t?void 0:t.targetBlock())},addElseIf_:function(){i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch added."));this.update_(()=>{this.elseifCount_++})},removeElseIf_:function(e){var t,n;i.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch removed."));this.update_(()=>{this.elseifCount_--},e);const r="IF"+(e-1);(0,o.maybeMoveFocusFromButton)(null===(n=null===(t=this.getInput(r))||void 0===t?void 0:t.connection)||void 0===n?void 0:n.targetBlock())},update_:function(e,t){i.Events.setGroup(!0),this.storeConnections_(t);const n=this,r=n.mutationToDom(),o=r&&i.Xml.domToText(r);e&&e.call(this),this.updateShape_(),n instanceof i.BlockSvg&&n.initSvg();const s=i.Events.getGroup(),a=n.mutationToDom(),l=a&&i.Xml.domToText(a);o!=l&&(i.Events.fire(new i.Events.BlockChange(n,"mutation",null,o,l)),setTimeout(function(){i.Events.setGroup(s),n.bumpNeighbours(),i.Events.setGroup(!1)},i.config.bumpDelay)),n.rendered&&n instanceof i.BlockSvg&&n.queueRender(),this.restoreConnections_(),i.Events.setGroup(!1)},updateShape_:function(){this.getInput("ELSE")&&(this.removeInput("ELSE"),this.removeInput("ELSETITLE"),this.removeInput("ELSEBUTTONS"));let e=1;for(;this.getInput("IF"+e);)this.removeInput("IF"+e),this.removeInput("IFTITLE"+e),this.removeInput("IFBUTTONS"+e),this.removeInput("DO"+e),e++;for(let e=1;e<=this.elseifCount_;e++){const n=function(e){return function(){t.removeElseIf_(e)}}(e);this.appendValueInput("IF"+e).setCheck("Boolean").appendField(i.Msg.CONTROLS_IF_MSG_ELSEIF).setShadowDom(a()),this.appendDummyInput("IFTITLE"+e).appendField(i.Msg.CONTROLS_IF_MSG_THEN),this.appendDummyInput("IFBUTTONS"+e).appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else if branch"),n,!1)).setAlign(i.inputs.Align.RIGHT),this.appendStatementInput("DO"+e)}this.elseCount_&&(this.appendDummyInput("ELSETITLE").appendField(i.Msg.CONTROLS_IF_MSG_ELSE),this.appendDummyInput("ELSEBUTTONS").setAlign(i.inputs.Align.RIGHT).appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else branch"),this.removeElse_.bind(this),!1)),this.appendStatementInput("ELSE")),this.getInput("ADDBUTTON")&&this.removeInput("ADDBUTTON");const t=this,n=function(){var e,n,r;if(0==t.elseCount_)t.addElse_(),(0,o.maybeMoveFocusFromButton)(null===(e=t.getInput("ELSEBUTTONS"))||void 0===e?void 0:e.fieldRow[0]);else{t.elseifCount_||(t.elseifCount_=0),t.addElseIf_();const e=i.getFocusManager(),o=null===(r=null===(n=t.getInput("IF"+t.elseifCount_))||void 0===n?void 0:n.connection)||void 0===r?void 0:r.targetBlock();e.focusNode(o)}};this.appendDummyInput("ADDBUTTON").appendField(new r.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,this.elseCount_?pxt.Util.lf("add else if branch"):pxt.Util.lf("add else branch"),n,!1))},rebuildShape_:function(){const e=[null],t=[null];let n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);let i=1;for(;this.getInput("IF"+i);){const n=this.getInput("IF"+i),r=this.getInput("DO"+i);e.push(n.connection.targetConnection),t.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},reconnectChildBlocks_:function(e,t,n){var i;for(let n=1;n<=this.elseifCount_;n++)this.reconnectValueConnection_(n,e),null===(i=t[n])||void 0===i||i.reconnect(this,"DO"+n);null==n||n.reconnect(this,"ELSE")},reconnectValueConnection_:function(e,t){var n;const i=null===(n=this.getInput("IF"+e))||void 0===n?void 0:n.connection.targetBlock();t[e]&&(t[e].reconnect(this,"IF"+e),i&&!i.getParent()&&i.dispose())}};function a(){const e=document.createElement("shadow");e.setAttribute("type","logic_boolean");const t=document.createElement("field");return t.setAttribute("name","BOOL"),t.textContent="FALSE",e.appendChild(t),e}i.Blocks.controls_if=Object.assign(Object.assign({},s),{init(){if(i.Extensions.apply("inline-svgs",this,!1),this.elseifCount_=0,this.elseCount_=0,this.setHelpUrl(i.Msg.CONTROLS_IF_HELPURL),this.appendValueInput("IF0").setCheck("Boolean").appendField(i.Msg.CONTROLS_IF_MSG_IF),this.appendDummyInput("THEN0").appendField(i.Msg.CONTROLS_IF_MSG_THEN),this.appendStatementInput("DO0"),this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer();this.setOutputShape(e.getConstants().SHAPES.HEXAGONAL)}this.updateShape_(),this.setInputsInline(!0),this.setColour(i.Msg.LOGIC_HUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(()=>this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?i.Msg.CONTROLS_IF_TOOLTIP_4:"":i.Msg.CONTROLS_IF_TOOLTIP_1)}})},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],133:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./extensions"),n),r(e("./ifElse"),n)},{"./extensions":131,"./ifElse":132}],134:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldSlider=void 0;const i=e("blockly");class r extends i.FieldNumber{constructor(e,t,n,i,r,o,s,a){super(e,t,n,i,s,a),this.keyboardControlActive=!1,"string"==typeof r?this.step_=parseFloat(r):"number"==typeof r&&(this.step_=r),this.labelText_=o}hasMin(){return this.getMin()>-1/0}hasMax(){return this.getMax()<1/0}getStep(){return this.step_}getLabel(){return this.labelText_}setLabel(e){this.labelText_=e}setOptions(e,t,n,i){this.setConstraints(e,t,i),this.step_=parseFloat(n)||void 0}getFieldDescription(){return this.getValue()+""}doClassValidation_(e){if(null===e)return null;e=(e=(e=(e=`${e}`).replace(/O/gi,"0")).replace(/,/g,"")).replace(/infinity/i,"Infinity");let t=Number(e||0);if(isNaN(t))return null;this.precision_&&isFinite(t)&&(t=Math.round(t/this.precision_)*this.precision_);let n=String(this.precision_);-1!==n.indexOf("e")&&(n=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const i=n.indexOf(".");let r;return r=-1===i?this.precision_?0:null:n.length-i-1,null!==r&&(t=Number(t.toFixed(r))),t}widgetDispose_(){this.removeEventListeners(),super.widgetDispose_()}addEventListeners(){this.inputKeydownHandler=this.inputKeydownListener.bind(this),this.htmlInput_.addEventListener("keydown",this.inputKeydownHandler),this.sliderKeydownHandler=this.sliderKeydownListener.bind(this),this.slider_.addEventListener("keydown",this.sliderKeydownHandler),this.sliderBlurHandler=this.sliderBlurListener.bind(this),this.slider_.addEventListener("blur",this.sliderBlurHandler),this.sliderPointerdownHandler=this.sliderPointerdownListener.bind(this),this.slider_.addEventListener("pointerdown",this.sliderPointerdownHandler)}removeEventListeners(){this.htmlInput_.removeEventListener("keydown",this.inputKeydownHandler),this.slider_.removeEventListener("keydown",this.sliderKeydownHandler),this.slider_.removeEventListener("blur",this.sliderBlurHandler),this.slider_.removeEventListener("pointerdown",this.sliderPointerdownHandler)}inputKeydownListener(e){"ArrowDown"===e.key&&(e.preventDefault(),this.keyboardControlActive=!0,this.slider_.focus())}sliderPointerdownListener(e){this.keyboardControlActive=!1}sliderKeydownListener(e){switch(e.key){case"ArrowUp":e.preventDefault(),this.htmlInput_.focus();break;case"Enter":case" ":e.preventDefault(),e.stopPropagation(),i.hideChaff();break;case"ArrowDown":e.preventDefault(),e.stopPropagation()}}sliderBlurListener(e){this.keyboardControlActive=!1}showEditor_(e,t){super.showEditor_(e,!0),"number"==typeof this.min_&&"number"==typeof this.max_&&(this.htmlInput_.ariaLabel=lf("Enter a value between {0} and {1}",this.min_,this.max_)),i.DropDownDiv.hideWithoutAnimation(),i.DropDownDiv.clearContent();const n=i.DropDownDiv.getContentDiv();n.style.height="",n.parentElement.classList.add("blocklyFieldSliderDropdown"),this.addSlider_(n),i.DropDownDiv.setColour("#ffffff","#dddddd"),i.DropDownDiv.showPositionedByBlock(this,this.sourceBlock_,void 0,void 0,!1),this.addEventListeners(),t||(this.htmlInput_.focus(),this.htmlInput_.select())}addSlider_(e){if(this.labelText_){let t=this.createLabelDom_(this.labelText_);e.appendChild(t[0]),this.readout_=t[1],this.setReadout(this.value_)}this.slider_=this.createSlider(),e.appendChild(this.slider_);const t=()=>{pxt.BrowserUtils.isFirefox()||this.keyboardControlActive||this.htmlInput_.focus()};i.browserEvents.bind(this.slider_,"input",this,e=>{const n=parseFloat(this.slider_.value)||0;if(null!==n){this.setValue(n);const e=this.htmlInput_;e&&(e.value=n+"",t())}}),i.browserEvents.bind(this.slider_,"focus",this,e=>{t()})}setValue(e,t){super.setValue(e,t),this.updateDom(),this.slider_&&(this.slider_.value=this.getValue()+"")}createSlider(){const e=document.createElement("input");let t;return e.setAttribute("class","blocklyFieldSlider"),e.type="range",e.min=this.getMin()+"",e.max=this.getMax()+"",e.value=this.getValue()+"",this.sourceBlock_ instanceof i.BlockSvg&&("#ffffff"===this.sourceBlock_.getColour()?this.sourceBlock_.getParent()&&(t=this.sourceBlock_.getParent().getColourTertiary()):t=this.sourceBlock_.getColourTertiary()),t&&e.setAttribute("style",`--blocklyFieldSliderBackgroundColor: ${t}`),Number.isNaN(this.step_)||(e.step=this.step_+""),e}updateDom(){this.setReadout(this.getValue())}setReadout(e){this.readout_&&(this.readout_.innerText=e+"")}createLabelDom_(e){const t=document.createElement("div");t.setAttribute("class","blocklyFieldSliderLabel");const n=document.createElement("span");n.setAttribute("class","blocklyFieldSliderReadout");const i=document.createElement("span");return i.setAttribute("class","blocklyFieldSliderLabelText"),i.innerText=e,t.appendChild(i),t.appendChild(n),[t,n]}}n.FieldSlider=r,i.fieldRegistry.register("field_slider",r),i.Css.register('\n:root {\n --blocklyFieldSliderBackgroundColor: #547AB2;\n --blocklyFieldSliderThumbColor: #ffffff;\n --blocklyFieldSliderThumbBorderColor: rgba(0, 0, 0, 0.15);\n}\n.blocklyFieldSliderLabel {\n font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;\n font-size: 0.65rem;\n color: #000000;\n margin: 8px;\n}\n.blocklyFieldSliderLabelText {\n font-weight: bold;\n}\n.blocklyFieldSliderReadout {\n margin-left: 10px;\n}\n\ninput[type=range].blocklyFieldSlider {\n -webkit-appearance: none;\n width: 100%;\n}\ninput[type=range].blocklyFieldSlider:focus {\n outline: none;\n}\ninput[type=range].blocklyFieldSlider::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n margin: 8px;\n height: 22px;\n width: 150px;\n outline: none;\n border-radius: 11px;\n margin-bottom: 20px;\n background: var(--blocklyFieldSliderBackgroundColor);\n}\ninput[type=range].blocklyFieldSlider::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 26px;\n height: 26px;\n margin-top: -1px;\n background-color: var(--blocklyFieldSliderThumbColor);\n border-radius: 100%;\n -webkit-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n -moz-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n cursor: pointer;\n}\ninput[type=range].blocklyFieldSlider:focus-visible::-webkit-slider-thumb {\n outline: 2px solid white;\n outline-offset: 3px;\n -webkit-box-shadow: 0 0 0 3px var(--pxt-focus-border);\n -moz-box-shadow: 0 0 0 3px var(--pxt-focus-border);\n box-shadow: 0 0 0 3px var(--pxt-focus-border);\n}\ninput[type=range].blocklyFieldSlider::-moz-range-track {\n margin: 8px;\n height: 22px;\n width: 95%;\n outline: none;\n border-radius: 11px;\n margin-bottom: 20px;\n background: var(--blocklyFieldSliderBackgroundColor);\n}\ninput[type=range].blocklyFieldSlider::-moz-range-thumb {\n width: 26px;\n height: 26px;\n margin-top: -1px;\n background-color: var(--blocklyFieldSliderThumbColor);\n border-radius: 100%;\n -webkit-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n -moz-box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n box-shadow: 0 0 0 4px var(--blocklyFieldSliderThumbBorderColor);\n cursor: pointer;\n}\n')},{blockly:192}],135:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldSlider"),n),r(e("./numberBlocks"),n)},{"./fieldSlider":134,"./numberBlocks":136}],136:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=new i.zelos.ConstantProvider;i.defineBlocksWithJsonArray([{type:"math_integer",message0:"%1",args0:[{type:"field_number",name:"NUM",precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_whole_number",message0:"%1",args0:[{type:"field_number",name:"NUM",min:0,precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_positive_number",message0:"%1",args0:[{type:"field_number",name:"NUM",min:0,ariaTypeName:lf("value")}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_number_minmax",message0:"%1",args0:[{type:"field_slider",name:"SLIDER",value:0,step:1,labelText:"Number"}],output:"Number",outputShape:r.SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",mutator:"math_number_minmax_mutator",extensions:["parent_tooltip_when_inline"]}]);const o={mutationToDom:function(){const e=this.inputList[0].fieldRow[0];let t=i.utils.xml.createElement("mutation");return e.hasMin()&&t.setAttribute("min",e.getMin()+""),e.hasMax()&&t.setAttribute("max",e.getMax()+""),null!=e.getLabel()&&t.setAttribute("label",e.getLabel()),null!=e.getStep()&&t.setAttribute("step",e.getStep()+""),null!=e.getPrecision()&&t.setAttribute("precision",e.getPrecision()+""),t},domToMutation:function(e){const t=this.inputList[0].fieldRow[0],n=e.getAttribute("min"),i=e.getAttribute("max"),r=e.getAttribute("step"),o=e.getAttribute("label"),s=e.getAttribute("precision");t.setLabel(o),t.setOptions(n,i,r,s)}};i.Extensions.registerMutator("math_number_minmax_mutator",o)},{blockly:192}],137:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldVariable=void 0;const i=e("blockly");class r extends i.FieldVariable{constructor(e,t,n,i,o){super(e,t,n,i,o),this.svgRootBinding=null,this.fieldRootBinding=null,this.menuGenerator_=r.dropdownCreate}static dropdownCreate(){const e=i.FieldVariable.dropdownCreate.call(this),t=e.findIndex(e=>"RENAME_VARIABLE_ID"===e[1]);return e.splice(t,0,[i.Msg.NEW_VARIABLE_DROPDOWN,r.CREATE_VARIABLE_ID],i.FieldDropdown.SEPARATOR),e}onItemSelected_(e,t){if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(t.getValue()===r.CREATE_VARIABLE_ID)return void i.Variables.createVariableButtonHandler(this.sourceBlock_.workspace,e=>{const t=this.sourceBlock_.workspace.getVariableMap().getVariable(e);t&&this.setValue(t.getId())})}super.onItemSelected_(e,t)}initView(){super.initView(),this.shouldAddBorderRect_()||(this.createBorderRect_(),this.clickTargetRect=this.borderRect_,this.clickTargetRect.setAttribute("stroke-opacity","0"),this.clickTargetRect.setAttribute("fill-opacity","0"),this.borderRect_=void 0)}shouldAddBorderRect_(){if("variables_get"===this.sourceBlock_.type)return!1;for(const e of this.sourceBlock_.inputList)for(const t of e.fieldRow)if(t!==this&&t.EDITABLE)return!0;return!this.sourceBlock_.getInputsInline()||super.shouldAddBorderRect_()}bindEvents_(){this.shouldAddBorderRect_()?super.bindEvents_():(this.svgRootBinding=i.browserEvents.conditionalBind(this.sourceBlock_.getSvgRoot(),"pointerdown",this,e=>{this.sourceBlock_.icons.length||this.onMouseDown_(e)},!1),this.fieldRootBinding=i.browserEvents.conditionalBind(this.getSvgRoot(),"pointerdown",this,e=>{this.sourceBlock_.icons.length&&this.onMouseDown_(e)},!1))}dispose(){super.dispose(),this.svgRootBinding&&(i.browserEvents.unbind(this.svgRootBinding),i.browserEvents.unbind(this.fieldRootBinding))}positionBorderRect_(){super.positionBorderRect_(),this.clickTargetRect&&(this.clickTargetRect.setAttribute("width",String(this.size_.width)),this.clickTargetRect.setAttribute("height",String(this.size_.height)),this.clickTargetRect.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.clickTargetRect.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getValue(){var e,t;const n=super.getValue();if(null===(e=this.sourceBlock_)||void 0===e?void 0:e.isInFlyout){if((null===(t=this.sourceBlock_.workspace)||void 0===t?void 0:t.getPotentialVariableMap()).getVariableById(n))return"potential_"+n}return n}}n.FieldVariable=r,r.CREATE_VARIABLE_ID="CREATE_VARIABLE",i.fieldRegistry.unregister("field_variable"),i.fieldRegistry.register("field_variable",r)},{blockly:192}],138:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldVariable"),n)},{"./fieldVariable":137}],139:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.isCollapsedInputRow=n.CollapsedInputRow=void 0;const i=e("blockly");class r extends i.blockRendering.InputRow{constructor(e){super(e),this.type|=i.blockRendering.Types.INPUT_ROW|i.blockRendering.Types.getType("COLLAPSED_INPUT_ROW")}measure(){this.width=this.minWidth,this.height=this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT}}n.CollapsedInputRow=r,n.isCollapsedInputRow=function(e){return!!(e.type&i.blockRendering.Types.getType("COLLAPSED_INPUT_ROW"))}},{blockly:192}],140:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConnectionPreviewer=void 0;const i=e("blockly");class r extends i.InsertionMarkerPreviewer{previewConnection(e,t){super.previewConnection(e,t),t.type!==i.ConnectionType.INPUT_VALUE&&t.type!==i.ConnectionType.OUTPUT_VALUE||this.showDraggedIndicatorWithLine(e,t)}previewReplacement(e,t,n){super.previewReplacement(e,t,n),this.showDraggedIndicatorWithLine(e,t)}showDraggedIndicatorWithLine(e,t){if(!this.connectionLine){this.connectionLine=i.utils.dom.createSvgElement("line",{class:"blocklyConnectionLine",x1:0,y1:0,x2:0,y2:0},e.sourceBlock_.getSvgRoot()),this.draggedConnectionIndicator=this.createConnectionIndicator(e.sourceBlock_.getSvgRoot(),e);const n=t.sourceBlock_.getSvgRoot().querySelector(":scope>.blocklyConnectionIndicatorParent");this.staticConnectionIndicator=this.createConnectionIndicator(n,t)}this.raiseIndicators(),this.updateLineCoords(e,t),i.renderManagement.finishQueuedRenders().then(()=>{this.connectionLine&&(this.raiseIndicators(),this.updateLineCoords(e,t))})}raiseIndicators(){var e,t;null===(e=this.draggedConnectionIndicator.parentElement)||void 0===e||e.appendChild(this.draggedConnectionIndicator);const n=this.staticConnectionIndicator.parentElement;n.appendChild(this.staticConnectionIndicator),null===(t=n.parentElement)||void 0===t||t.appendChild(n)}updateLineCoords(e,t){const n=r.CONNECTION_INDICATOR_RADIUS,o=e.getOffsetInBlock(),s=t.getOffsetInBlock();this.draggedConnectionIndicator.setAttribute("transform",`translate(${o.x}, ${o.y})`),this.staticConnectionIndicator.setAttribute("transform",`translate(${s.x}, ${s.y})`);const a=i.utils.Coordinate.sum(e.sourceBlock_.getRelativeToSurfaceXY(),o),l=i.utils.Coordinate.sum(t.sourceBlock_.getRelativeToSurfaceXY(),s),c=l.x-a.x,u=l.y-a.y;if(Math.sqrt(c*c+u*u)<2*n+1)return void i.utils.dom.addClass(this.connectionLine,"hidden");i.utils.dom.removeClass(this.connectionLine,"hidden");const d=Math.atan2(u,c);this.connectionLine.setAttribute("x1",String(o.x+Math.cos(d)*n)),this.connectionLine.setAttribute("y1",String(o.y+Math.sin(d)*n)),this.connectionLine.setAttribute("x2",String(o.x+c-Math.cos(d)*n)),this.connectionLine.setAttribute("y2",String(o.y+u-Math.sin(d)*n))}hidePreview(){super.hidePreview(),this.connectionLine&&(this.connectionLine.remove(),this.connectionLine=null,this.draggedConnectionIndicator.remove(),this.draggedConnectionIndicator=null,this.staticConnectionIndicator.remove(),this.staticConnectionIndicator=null,this.staticConnection=null)}createConnectionIndicator(e,t){const n=i.utils.dom.createSvgElement("g",{class:"blocklyInputConnectionIndicator"},e);i.utils.dom.createSvgElement("circle",{r:r.CONNECTION_INDICATOR_RADIUS},n);const o=t.getOffsetInBlock();return n.setAttribute("transform","translate("+o.x+","+o.y+")"),n}}n.ConnectionPreviewer=r,r.CONNECTION_INDICATOR_RADIUS=9},{blockly:192}],141:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConstantProvider=void 0;const i=e("blockly");class r extends i.zelos.ConstantProvider{constructor(){super(...arguments),this.FIELD_TEXT_FONTFAMILY='"Consolas", "Monaco", "Menlo", "Ubuntu Mono", "source-code-pro", monospace',this.FIELD_TEXT_FONTWEIGHT="600",this.HIGHLIGHT_GLOW_COLOUR="#FFF200",this.ERROR_HIGHLIGHT_GLOW_COLOR="#FF0000",this.HIGHLIGHT_GLOW_SIZE=1.1,this.ELLIPSES_RADIUS=6,this.ELLIPSES_SPACING=8,this.ellipses=this.makeEllipses()}createDom(e,t,n){super.createDom(e,t,n);const r=i.utils.dom.createSvgElement(i.utils.Svg.DEFS,{},e);this.highlightOutlineFilter=this.createHighlight(r,"blocklyHighlightedGlowFilter",this.HIGHLIGHT_GLOW_COLOUR),this.highlightOutlineFilterId=this.highlightOutlineFilter.id,this.errorOutlineFilter=this.createHighlight(r,"blocklyErrorHighlightedGlowFilter",this.ERROR_HIGHLIGHT_GLOW_COLOR),this.errorOutlineFilterId=this.errorOutlineFilter.id,this.embossFilterOverride=this.createOutline(r,"blocklyBubbleEmbossGlowFilter"),this.embossFilterId=this.embossFilterOverride.id}dispose(){super.dispose(),this.highlightOutlineFilter&&i.utils.dom.removeNode(this.highlightOutlineFilter)}makeEllipses(){const e=this.ELLIPSES_RADIUS,t=this.ELLIPSES_SPACING;let n="";for(let r=0;r<3;r++)n+=i.utils.svgPaths.moveBy(t,0)+i.utils.svgPaths.arc("a","180 1,1",e,i.utils.svgPaths.point(2*e,0));for(let r=0;r<3;r++)n+=i.utils.svgPaths.arc("a","180 1,1",e,i.utils.svgPaths.point(2*-e,0))+i.utils.svgPaths.moveBy(-t,0);return n}getCSS_(e){return super.getCSS_(e).concat([e+" .blocklyConnectionIndicator, "+e+" .blocklyInputConnectionIndicator {","fill: #ff0000;","stroke: #ffff00;","stroke-width: 3px;","}",e+" .blocklyConnectionIndicator {","display: none;","}",e+" .blocklyBlockDragSurface > g > .blocklyDraggable > .blocklyConnectionIndicator {","display: block;","}",e+" .blocklyConnectionLine {","stroke: #ffff00;","stroke-width: 4px;","}",e+" .blocklyConnectionLine.hidden {","display: none;","}",e+" .blocklyFlyoutHeading .blocklyFlyoutLabelText {font-size: 1.5rem;","}",`${e} .blocklyText::selection {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>text::selection,`,`${e} .blocklyEditableField>text::selection,`,`${e} .blocklyNonEditableField>g>text::selection,`,`${e} .blocklyEditableField>g>text::selection {`,"fill: #575E75;","}",`${e} .blocklyDropdownText::selection {`,"fill: #fff !important;","}"])}createHighlight(e,t,n){const r=i.utils.dom.createSvgElement(i.utils.Svg.FILTER,{id:t+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e);i.utils.dom.createSvgElement(i.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.HIGHLIGHT_GLOW_SIZE},r);const o=i.utils.dom.createSvgElement(i.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},r);return i.utils.dom.createSvgElement(i.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),i.utils.dom.createSvgElement(i.utils.Svg.FEFLOOD,{"flood-color":n,"flood-opacity":1,result:"outColor"},r),i.utils.dom.createSvgElement(i.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},r),r}createOutline(e,t){const n=i.utils.dom.createSvgElement(i.utils.Svg.FILTER,{id:t+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e);i.utils.dom.createSvgElement(i.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:.92},n);const r=i.utils.dom.createSvgElement(i.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},n);i.utils.dom.createSvgElement(i.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},r),i.utils.dom.createSvgElement(i.utils.Svg.FEFLOOD,{"flood-color":"#000000","flood-opacity":.5,result:"outColor"},n),i.utils.dom.createSvgElement(i.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},n);const o=i.utils.dom.createSvgElement("feMerge",{},n);return i.utils.dom.createSvgElement("feMergeNode",{in:"outBlur"},o),i.utils.dom.createSvgElement("feMergeNode",{in:"outGlow"},o),i.utils.dom.createSvgElement("feMergeNode",{in:"SourceGraphic"},o),n}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case i.ConnectionType.INPUT_VALUE:case i.ConnectionType.OUTPUT_VALUE:return t&&t.includes("Boolean")?this.HEXAGONAL:(t&&t.includes("Number")||t&&t.includes("String"),this.ROUNDED);case i.ConnectionType.PREVIOUS_STATEMENT:case i.ConnectionType.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}}n.ConstantProvider=r,r.COLLAPSE_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.354)'%3E%3Cpath d='m1611 367.42q0 53-37 90l-651 651q-38 38-91 38-54 0-90-38l-651-651q-38-36-38-90 0-53 38-91l74-75q39-37 91-37 53 0 90 37l486 486 486-486q37-37 90-37 52 0 91 37l75 75q37 39 37 91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A",r.EXPAND_IMAGE_DATAURI="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg enable-background='new 0 0 24 24' version='1.1' viewBox='0 0 24 24' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23CF8B17;%7D .st1%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Ctitle%3Erepeat%3C/title%3E%3Ccircle cx='12' cy='12' r='10.503' fill='none' stroke='%23fff' stroke-linecap='square' stroke-linejoin='round' stroke-width='2'/%3E%3Cg transform='matrix(.0086269 0 0 -.0086269 4.8224 17.654)'%3E%3Cpath d='m1611 832q0-53-37-90l-651-651q-38-38-91-38-54 0-90 38l-651 651q-38 36-38 90 0 53 38 91l74 75q39 37 91 37 53 0 90-37l486-486 486 486q37 37 90 37 52 0 91-37l75-75q37-39 37-91z' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E%0A"},{blockly:192}],142:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});e("blockly").Css.register("\n.blocklyDropdownMenu .blocklyMenuItemCheckbox {\n filter: contrast(0) brightness(100);\n}\n\n.blocklyVerticalMarker {\n fill: none;\n}\n")},{blockly:192}],143:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.Drawer=void 0;const i=e("blockly"),r=e("./collapsedInputRow");class o extends i.zelos.Drawer{drawCollapsedStack_(e){const t=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.constants_.INSIDE_CORNERS.width,n=this.constants_.STATEMENT_INPUT_PADDING_LEFT+2*this.constants_.INSIDE_CORNERS.width+i.utils.svgPaths.lineOnAxis("h",-this.constants_.INSIDE_CORNERS.width)+this.constants_.INSIDE_CORNERS.pathTop,r=e.height-2*this.constants_.INSIDE_CORNERS.height,o=this.constants_.INSIDE_CORNERS.pathBottom+i.utils.svgPaths.lineOnAxis("h",this.constants_.INSIDE_CORNERS.width),s=this.constants_.ellipses;this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.bottomRight+i.utils.svgPaths.lineOnAxis("H",t)+n+i.utils.svgPaths.lineOnAxis("v",r/2)+s+i.utils.svgPaths.lineOnAxis("v",r/2)+o+i.utils.svgPaths.lineOnAxis("H",e.xPos+e.width-this.constants_.OUTSIDE_CORNERS.rightHeight)+this.constants_.OUTSIDE_CORNERS.topRight}drawOutline_(){if(this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection)this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_();else{this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){const t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):(0,r.isCollapsedInputRow)(t)?this.drawCollapsedStack_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}}drawLeft_(){super.drawLeft_();if(this.info_.rows.find(function(e){return(0,r.isCollapsedInputRow)(e)})){let e=this.info_.startY;i.blockRendering.Types.isLeftRoundedCorner(this.info_.topRow.elements[0])&&(e+=this.constants_.OUTSIDE_CORNERS.rightHeight),this.outlinePath_=this.outlinePath_.slice(0,-1),this.outlinePath_+=i.utils.svgPaths.lineOnAxis("V",e)}}}n.Drawer=o},{"./collapsedInputRow":139,blockly:192}],144:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./renderer"),n),r(e("./connectionPreviewer"),n),r(e("./css"),n)},{"./connectionPreviewer":140,"./css":142,"./renderer":147}],145:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.RenderInfo=void 0;const i=e("blockly"),r=e("./collapsedInputRow");class o extends i.zelos.RenderInfo{measure(){if(this.block_)for(const e of this.block_.inputList)e.init();super.measure()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let e=new i.blockRendering.InputRow(this.constants_);this.inputRows.push(e);const t=this.block_.getIcons();for(let n,r=0;n=t[r];r++){const t=new i.blockRendering.Icon(this.constants_,n);this.isCollapsed&&!n.isShownWhenCollapsed()||e.elements.push(t)}let n;for(let t,r=0;t=this.block_.inputList[r];r++)if(t.isVisible()){this.shouldStartNewRow_(t,n)&&(this.rows.push(e),e=new i.blockRendering.InputRow(this.constants_),this.inputRows.push(e));for(let n,r=0;n=t.fieldRow[r];r++)e.elements.push(new i.blockRendering.Field(this.constants_,n,t));this.addInput_(t,e),n=t}if(this.isCollapsed){this.block_.inputList.find(function(e){return e.type==i.inputs.inputTypes.STATEMENT})?e=this.addCollapsedRow_(e):(e.hasJaggedEdge=!0,e.elements.push(new i.blockRendering.JaggedEdge(this.constants_)))}(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;const e=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof i.inputs.StatementInput||this.rows.some(e=>(0,r.isCollapsedInputRow)(e));this.bottomRow.minHeight=e?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new i.blockRendering.SquareCorner(this.constants_)):this.bottomRow.elements.push(new i.blockRendering.RoundCorner(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new i.blockRendering.NextConnection(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new i.blockRendering.SquareCorner(this.constants_,"right")):this.bottomRow.elements.push(new i.blockRendering.RoundCorner(this.constants_,"right"))}addCollapsedRow_(e){this.rows.push(e);const t=new r.CollapsedInputRow(this.constants_);return t.hasDummyInput=!0,t}}n.RenderInfo=o},{"./collapsedInputRow":139,blockly:192}],146:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.PathObject=void 0;const i=e("blockly"),r="blockly-dotted-outline-on-hover",o="hover";class s extends i.zelos.PathObject{constructor(){super(...arguments),this.connectionPointIndicators=new WeakMap}setPath(e){super.setPath(e),this.svgPathHighlighted&&this.svgPathHighlighted.setAttribute("d",e)}updateHighlighted(e){if(e){if(!this.svgPathHighlighted){const e=this.constants,t=this.hasError?e.errorOutlineFilterId:e.highlightOutlineFilterId;this.svgPathHighlighted=this.svgPath.cloneNode(!0),this.svgPathHighlighted.classList.add("pxtRendererHighlight"),this.svgPathHighlighted.setAttribute("fill","none"),this.svgPathHighlighted.setAttribute("filter","url(#"+t+")"),this.svgRoot.appendChild(this.svgPathHighlighted)}}else this.svgPathHighlighted&&(this.svgRoot.removeChild(this.svgPathHighlighted),this.svgPathHighlighted=null)}updateSelected(e){e&&this.svgPath.classList.remove(o),super.updateSelected(e)}addConnectionHighlight(e,t,n,r){const o=super.addConnectionHighlight(e,t,n,r);return this.staticConnectionIndicatorParentGroup?this.svgRoot.appendChild(this.staticConnectionIndicatorParentGroup):this.staticConnectionIndicatorParentGroup=i.utils.dom.createSvgElement("g",{class:"blocklyConnectionIndicatorParent"},this.svgRoot),o}removeConnectionHighlight(e){var t;null===(t=this.staticConnectionIndicatorParentGroup)||void 0===t||t.remove(),super.removeConnectionHighlight(e)}applyColour(e){if(super.applyColour(e),e.outputConnection){let t=!1;const n=e.getParent();if(n)if(e.isShadow()){const e=n.style.colourTertiary,r=function(e){return(.2126*e[0]+.7152*e[1]+.0722*e[2])/255}(i.utils.colour.hexToRgb(e));r<.15&&(this.svgPath.setAttribute("stroke",i.utils.colour.blend("#ffffff",e,.3)),t=!0)}else{const r=n.style.colourPrimary,o=e.style.colourPrimary;if(r===o){const e=.6,n=i.utils.colour.blend("#0000000",o,e),s=i.utils.colour.blend("#ffffff",o,e);pxt.contrastRatio(n,r)>pxt.contrastRatio(s,r)?this.svgPath.setAttribute("stroke",n):this.svgPath.setAttribute("stroke",s),t=!0}}t||this.svgPath.setAttribute("stroke",e.style.colourTertiary)}}setHasDottedOutlineOnHover(e){this.hasDottedOutlineOnHover=e,e?(this.svgPath.classList.add(r),this.mouseOverData||(this.mouseOverData=i.browserEvents.bind(this.svgRoot,"mouseover",this,()=>{this.svgPath.classList.add(o)}),this.mouseLeaveData=i.browserEvents.bind(this.svgRoot,"mouseleave",this,()=>{this.svgPath.classList.remove(o)}))):(this.svgPath.classList.remove(r),this.mouseOverData&&(i.browserEvents.unbind(this.mouseOverData),i.browserEvents.unbind(this.mouseLeaveData),this.mouseOverData=void 0,this.mouseLeaveData=void 0),this.svgPath.classList.remove(r))}setHasError(e){this.hasError=e}isHighlighted(){return!!this.svgPathHighlighted}}n.PathObject=s,s.CONNECTION_INDICATOR_RADIUS=9,i.Css.register("\n.blockly-dotted-outline-on-hover {\n transition: stroke .4s;\n}\n.blockly-dotted-outline-on-hover.hover {\n stroke-dasharray: 2;\n stroke: white;\n stroke-width: 2;\n}\n.blocklyDisabledPattern>.blocklyPath.pxtRendererHighlight {\n fill: none;\n}\n")},{blockly:192}],147:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.Renderer=void 0;const i=e("blockly"),r=e("./pathObject"),o=e("./constants"),s=e("./info"),a=e("./drawer");class l extends i.zelos.Renderer{makePathObject(e,t){return new r.PathObject(e,t,this.getConstants())}makeConstants_(){return new o.ConstantProvider}makeRenderInfo_(e){return new s.RenderInfo(this,e)}makeDrawer_(e,t){return new a.Drawer(e,t)}render(e){e.updateBeforeRender&&e.updateBeforeRender(),super.render(e)}}n.Renderer=l,i.blockRendering.register("pxt",l)},{"./constants":141,"./drawer":143,"./info":145,"./pathObject":146,blockly:192}],148:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.FieldString=void 0;const i=e("blockly");class r extends i.FieldTextInput{initView(){this.quoteSize_=16,this.quoteWidth_=8,this.quoteLeftX_=0,this.quoteRightX_=0,this.quoteY_=10,this.quoteLeft_&&this.quoteLeft_.parentNode.removeChild(this.quoteLeft_),this.quoteLeft_=i.utils.dom.createSvgElement("text",{"font-size":this.quoteSize_+"px",class:"field-text-quote","aria-hidden":"true"},this.fieldGroup_),super.initView(),this.quoteRight_&&this.quoteRight_.parentNode.removeChild(this.quoteRight_),this.quoteRight_=i.utils.dom.createSvgElement("text",{"font-size":this.quoteSize_+"px",class:"field-text-quote","aria-hidden":"true"},this.fieldGroup_),this.quoteLeft_.appendChild(document.createTextNode('"')),this.quoteRight_.appendChild(document.createTextNode('"'))}updateSize_(e){super.updateSize_(e);const t=this.value_?this.size_.width:1;let n=this.positionLeft(t+3);this.textElement_.setAttribute("x",n+""),n+=this.positionRight(n+t+3),this.size_.width=t+n}positionLeft(e){if(!this.quoteLeft_)return 0;let t=0;return this.sourceBlock_.RTL?(this.quoteLeftX_=e+this.quoteWidth_+2*r.quotePadding,t=this.quoteWidth_+r.quotePadding):(this.quoteLeftX_=0,t=this.quoteWidth_+r.quotePadding),this.quoteLeft_.setAttribute("transform","translate("+this.quoteLeftX_+","+this.quoteY_+")"),t}positionRight(e){if(!this.quoteRight_)return 0;let t=0;return this.sourceBlock_.RTL?(this.quoteRightX_=r.quotePadding,t=this.quoteWidth_+r.quotePadding):(this.quoteRightX_=e+r.quotePadding,t=this.quoteWidth_+r.quotePadding),this.quoteRight_.setAttribute("transform","translate("+this.quoteRightX_+","+this.quoteY_+")"),t}}n.FieldString=r,r.quotePadding=0,i.Css.register("\n.field-text-quote {\n fill: #a31515 !important;\n}\n"),i.fieldRegistry.register("field_string",r)},{blockly:192}],149:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./fieldString"),n),r(e("./text"),n),r(e("./join"),n)},{"./fieldString":148,"./join":150,"./text":151}],150:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly"),r=e("../../fields/field_imagenotext"),o=e("../../utils"),s={itemCount_:0,valueConnections_:[],buttons:null,delta:0,mutationToDom:function(){const e=i.utils.xml.createElement("mutation");return e.setAttribute("items",this.itemCount_+""),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute("items"),10),this.updateShape_()},storeValueConnections_:function(){this.valueConnections_=[];for(let e=0;e<this.itemCount_;e++)this.valueConnections_.push(this.getInput("ADD"+e).connection.targetConnection)},restoreValueConnections_:function(){var e;for(let t=0;t<this.itemCount_;t++)null===(e=this.valueConnections_[t])||void 0===e||e.reconnect(this,"ADD"+t)},addItem_:function(){this.storeValueConnections_();if(this.delta=1,this.update_(()=>{this.itemCount_++}),this.restoreValueConnections_(),this.itemCount_>1){const e=this.getInput("ADD0");if(e&&e.connection.targetConnection){const t=this.getInput("ADD"+(this.itemCount_-1)),n=e.connection.getShadowDom();if(n){const e=i.utils.xml.createElement("shadow"),r=n.getAttribute("type");e.setAttribute("type",r),e&&(e.setAttribute("id",i.utils.idGenerator.genUid()),t.connection.setShadowDom(e))}}}},removeItem_:function(){this.storeValueConnections_();this.delta=-1,this.update_(()=>{this.itemCount_--}),this.restoreValueConnections_()},update_:function(e){i.Events.setGroup(!0);const t=this,n=t.mutationToDom(),r=n&&i.Xml.domToText(n);e&&e.call(this),this.updateShape_(),t instanceof i.BlockSvg&&t.initSvg();const s=i.Events.getGroup(),a=t.mutationToDom(),l=a&&i.Xml.domToText(a);r!=l&&(i.Events.fire(new i.Events.BlockChange(t,"mutation",null,r,l)),setTimeout(function(){i.Events.setGroup(s),t.bumpNeighbours(),i.Events.setGroup(!1)},i.config.bumpDelay)),t.rendered&&t instanceof i.BlockSvg&&t.queueRender().then(()=>{if(this.buttons){let e=this.buttons.fieldRow[0];this.buttons.fieldRow.length>1&&(e=this.delta<0?e:this.buttons.fieldRow[1]),(0,o.maybeMoveFocusFromButton)(e),this.buttons=null,this.delta=0}}),i.Events.setGroup(!1)},updateShape_:function(){const e=this,t=function(){e.removeItem_()};let n;for(this.getInput("EMPTY")&&this.removeInput("EMPTY"),this.getInput("TITLE")||this.appendDummyInput("TITLE").appendField(i.Msg.TEXT_JOIN_TITLE_CREATEWITH),n=0;n<this.itemCount_;n++)if(!this.getInput("ADD"+n)){this.appendValueInput("ADD"+n).setAlign(i.inputs.Align.LEFT).setAriaLabelProvider(i.Msg.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(n+1).toString()))}for(;this.getInput("ADD"+n);)this.removeInput("ADD"+n),n++;this.getInput("BUTTONS")&&this.removeInput("BUTTONS"),this.buttons=this.appendDummyInput("BUTTONS"),this.itemCount_>1&&this.buttons.appendField(new r.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,lf("remove argument"),t,!1)),this.buttons.appendField(new r.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,lf("add argument"),function(){e.addItem_()},!1));const o=this.itemCount_<=4;if(this.setInputsInline(o),this.workspace instanceof i.WorkspaceSvg){const e=this.workspace.getRenderer();this.setOutputShape(o?e.getConstants().SHAPES.ROUND:e.getConstants().SHAPES.SQUARE)}}};i.Extensions.registerMutator("pxt_text_join_mutator",s,function(){i.Extensions.apply("inline-svgs",this,!1),this.itemCount_=2,this.updateShape_()}),i.defineBlocksWithJsonArray([{type:"text_join",message0:"",output:"String",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"pxt_text_join_mutator"}])},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],151:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("blockly");i.defineBlocksWithJsonArray([{type:"text",message0:"%1",args0:[{type:"field_string",name:"TEXT",text:""}],output:"String",outputShape:(new i.zelos.ConstantProvider).SHAPES.ROUND,style:"field_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]}])},{blockly:192}],152:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.blocksMetrics=n.render=n.renderWorkspace=n.cleanRenderingWorkspace=n.initRenderingWorkspace=void 0;const i=e("blockly"),r=e("./layout"),o=e("./importer");let s,a;function l(){return s||(a=document.createElement("div"),a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="1px",a.style.height="1px",document.body.appendChild(a),s=i.inject(a,{move:{scrollbars:!1},readOnly:!0,sounds:!1,media:pxt.webConfig.commitCdnUrl+"blockly/media/",rtl:pxt.Util.isUserLanguageRtl(),renderer:"pxt"})),(0,o.clearWithoutEvents)(s),s}function c(){s&&s.dispose(),s=void 0}function u(e={emPixels:18,layout:1}){switch(e.splitSvg?1:e.layout||4){case 1:(0,r.verticalAlign)(s,e.emPixels||18);break;case 4:(0,r.flow)(s,{ratio:e.aspectRatio,useViewWidth:e.useViewWidth});break;case 3:s.cleanUp_&&s.cleanUp_()}let t=s.getMetrics();const n=a.querySelectorAll("svg")[0],i=n.cloneNode(!0);return(0,r.cleanUpBlocklySvg)(i,n),pxt.U.toArray(i.querySelectorAll(".blocklyBlockCanvas,.blocklyBubbleCanvas")).forEach(e=>e.setAttribute("transform",`translate(${-t.contentLeft}, ${-t.contentTop}) scale(1)`)),i.setAttribute("viewBox",`0 0 ${t.contentWidth} ${t.contentHeight}`),e.emPixels&&(i.style.width=t.contentWidth/e.emPixels+"em",i.style.height=t.contentHeight/e.emPixels+"em"),e.splitSvg?(0,r.splitSvg)(i,s,e.emPixels):i}n.initRenderingWorkspace=l,n.cleanRenderingWorkspace=c,n.renderWorkspace=u,n.render=function(e,t={emPixels:18,layout:1}){l();try{let n=e||'<xml xmlns="http://www.w3.org/1999/xhtml"></xml>',r=i.utils.xml.textToDom(n);return(0,o.domToWorkspaceNoEvents)(r,s,{applyHideMetaComment:!0}),u(t)}catch(e){return void pxt.reportException(e)}finally{c()}},n.blocksMetrics=function(e){const t=e.getTopBlocks(!1);if(!t.length)return{width:0,height:0};let n;return t.forEach(e=>{const t=e.getBoundingRectangle();n?(n.l=Math.min(n.l,t.left),n.r=Math.max(n.r,t.right),n.t=Math.min(n.t,t.top),n.b=Math.min(n.b,t.bottom)):n={l:t.left,r:t.right,t:t.top,b:t.bottom}}),{width:n.r-n.l,height:n.b-n.t}}},{"./importer":75,"./layout":77,blockly:192}],153:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.findBlockIdByLine=n.findBlockIdByPosition=void 0,n.findBlockIdByPosition=function(e,t){if(!t)return;let n,i;for(let r=0;r<e.length;++r){let o=e[r];o.startPos<=t.start&&o.endPos>=t.start+t.length&&(!n||i>o.endPos-o.startPos)&&(n=o,i=o.endPos-o.startPos)}return n?n.id:void 0},n.findBlockIdByLine=function(e,t){if(!t)return;let n,i;for(let r=0;r<e.length;++r){let o=e[r];o.startLine<=t.start&&o.endLine>t.start+t.length&&(!n||i>o.endLine-o.startLine)&&(n=o,i=o.endLine-o.startLine)}return n?n.id:void 0}},{}],154:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.createFunctionsFlyoutCategory=n.mkReturnStatementBlock=n.mkVariableFieldBlock=n.mkFieldBlock=n.mkPredicateBlock=n.createToolboxBlock=n.createFlyoutGap=n.createFlyoutButton=n.createFlyoutGroupLabel=n.createFlyoutHeadingLabel=n.createShadowValue=n.isArrayType=void 0;const i=e("blockly"),r=e("./plugins/functions"),o=e("./loader"),s=/^(string|number|boolean)$/,a={string:{field:"TEXT",block:"text",defaultValue:""},number:{field:"NUM",block:"math_number",defaultValue:"0"},boolean:{field:"BOOL",block:"logic_boolean",defaultValue:"false"},Array:{field:"VAR",block:"variables_get",defaultValue:"list"}};function l(e){let t=/^(?:Array<(.+)>)|(?:(.+)\[\])|(?:\[.+\])$/.exec(e);return t?t[1]?t[1]:t[2]:void 0}function c(e,t,n,i,r,o=0){let s;if(i=i||t.defaultValue,!(n=n||t.shadowBlockId)&&t.range&&(n="math_number_minmax"),s=i&&'"'==i.slice(0,1)?JSON.parse(i):i,"number"==t.type&&"value"==n){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode("0")),e}if(t.fieldEditor){if(t.defaultValue){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode(t.defaultValue)),e}return}let c=pxt.Util.lookup(e.apis.byQName,t.type),d=6==(null==c?void 0:c.kind),p=c&&!!c.attributes.fixedInstances&&!t.shadowBlockId,h="@combined@"==t.type;if(!n&&(d||p||h)){if(i){const e=document.createElement("field");return e.setAttribute("name",t.definitionName),e.appendChild(document.createTextNode(i)),e}return}const g="variables_get"==n,m="text"==n,_=document.createElement("value");_.setAttribute("name",t.definitionName);const y="lists_create_with"!==n&&n?void 0:l(t.type),b=document.createElement(!g&&!y||r?"shadow":"block");_.appendChild(b);const v=a[y||t.type];if(b.setAttribute("type",n||(y?"lists_create_with":v&&v.block||t.type)),b.setAttribute("colour","#fff"),y){if(v&&!n){let e;switch(y){case"number":e=["0","1"];break;case"string":e=["a","b","c"];break;case"boolean":e=["FALSE","FALSE","FALSE"]}return u(b,v.block,v.field,e),_}if(n&&s)return u(b,s),_}if(!v||n&&v.block!==n&&"math_number_minmax"!==n){if(s){const i=document.createElement("field");if(i.textContent=s,g)i.setAttribute("name","VAR"),b.appendChild(i);else if(m)i.setAttribute("name","TEXT"),b.appendChild(i);else if(n){const t=e.blocksById[n];if(t&&t.attributes._def&&t.attributes._def.parameters.length){const e=t.attributes._def.parameters[0];i.setAttribute("name",e.name),b.appendChild(i)}}else i.setAttribute("name",t.definitionName),b.appendChild(i)}}else{const e=document.createElement("field");let i,r;switch(b.appendChild(e),n){case"variables_get":i="VAR";break;case"math_number_minmax":i="SLIDER";break;default:i=v.field}e.setAttribute("name",i),r="boolean"==t.type?document.createTextNode((s||v.defaultValue).toUpperCase()):document.createTextNode(s||v.defaultValue),e.appendChild(r)}let T;if(t.range&&(T=document.createElement("mutation"),T.setAttribute("min",t.range.min.toString()),T.setAttribute("max",t.range.max.toString()),T.setAttribute("label",t.actualName.charAt(0).toUpperCase()+t.actualName.slice(1)),t.fieldOptions&&(t.fieldOptions.step&&T.setAttribute("step",t.fieldOptions.step),t.fieldOptions.color&&T.setAttribute("color",t.fieldOptions.color),t.fieldOptions.precision&&T.setAttribute("precision",t.fieldOptions.precision))),t.fieldOptions&&(T||(T=document.createElement("mutation")),T.setAttribute("customfield",JSON.stringify(t.fieldOptions))),T&&b.appendChild(T),o){const t=pxt.Util.toArray(_.getElementsByTagName("shadow"));for(const n of t)if(!n.innerHTML){const t=e.blocks.find(e=>e.attributes.blockId===n.getAttribute("type"));if(t){const i=f(e,t,pxt.blocks.compileInfo(t),!0,o-1);for(;i.firstChild;)n.appendChild(i.firstChild.cloneNode(!0)),i.firstChild.remove()}}}return _}function u(e,t,n,i){const r=i?i.length:2,o=document.createElement("mutation");o.setAttribute("items",""+r),o.setAttribute("horizontalafter",""+r),e.appendChild(o);for(let o=0;o<r;o++){const r=document.createElement("value");r.setAttribute("name","ADD"+o);const s=document.createElement("shadow");if(s.setAttribute("type",t),n){const e=document.createElement("field");e.setAttribute("name",n),i&&e.appendChild(document.createTextNode(i[o])),s.appendChild(e)}r.appendChild(s),e.appendChild(r)}}function d(e,t,n,i){const r=h(e,pxt.toolbox.convertColor(t),n,i);return r.setAttribute("web-class","blocklyFlyoutHeading"),r}function p(e,t,n,i){const r=h(e,void 0,t);return r.setAttribute("web-class","blocklyFlyoutGroup"),r.setAttribute("web-line","1.5"),n&&r.setAttribute("web-line-width",n),i&&(r.setAttribute("web-help-button","true"),r.setAttribute("callbackKey",i)),r}function h(e,t,n,r){let o=i.utils.xml.createElement("label");return o.setAttribute("text",e),t&&o.setAttribute("web-icon-color",pxt.toolbox.convertColor(t)),n&&(1===n.length?(o.setAttribute("web-icon",n),r&&o.setAttribute("web-icon-class",r)):(o.setAttribute("web-icon-class",`blocklyFlyoutIcon${e}`),pxt.toolbox.isImageIcon(n)&&o.setAttribute("web-icon-image",pxt.Util.pathJoin(pxt.webConfig.commitCdnUrl,encodeURI(n))))),o}function f(e,t,n,i=!1,a=0){var u,d;let p,h;if(t.attributes.builtinBlockId)return function(e){const t=e.attributes.builtinBlockId,n=e.attributes.color;if("makecode_color_picker"===t){const e=document.createElement("block");e.setAttribute("type","makecode_color_picker");const t=document.createElement("field");t.setAttribute("name","FORMAT"),t.textContent="rgb",e.appendChild(t);for(let t=0;t<3;t++){const n=document.createElement("value");n.setAttribute("name",`INPUT${t}`);const i=document.createElement("shadow");i.setAttribute("type","makecode_color_picker_number");const r=document.createElement("field");r.setAttribute("name","NUM"),r.textContent="0",i.appendChild(r),n.appendChild(i),e.appendChild(n)}if(n){const t=document.createElement("mutation");t.setAttribute("color",n),e.appendChild(t)}return e}return void pxt.warn(`Unsupported builtin block id: ${t}`)}(t);if(t.attributes.toolboxParent){const n=e.blocksById[t.attributes.toolboxParent];if(n){const r=pxt.blocks.compileInfo(n);if(p=f(e,n,r,i),t.attributes.toolboxParentArgument)h=p.querySelector(`value[name=${t.attributes.toolboxParentArgument}]`),!h&&r.parameters.some(e=>e.definitionName===t.attributes.toolboxParentArgument)&&(h=document.createElement("value"),h.setAttribute("name",t.attributes.toolboxParentArgument),p.appendChild(h));else if(h=p.querySelector("value"),!h)for(const e of r.parameters)if(!p.querySelector(`field[name=${e.definitionName}]`)){h=document.createElement("value"),h.setAttribute("name",e.definitionName),p.appendChild(h);break}if(h)for(;h.firstChild;)h.removeChild(h.firstChild);else p=void 0}}let g=document.createElement(p||i?"shadow":"block");if(g.setAttribute("type",t.attributes.blockId),t.attributes.blockGap?g.setAttribute("gap",t.attributes.blockGap):pxt.appTarget.appTheme&&pxt.appTarget.appTheme.defaultBlockGap&&g.setAttribute("gap",pxt.appTarget.appTheme.defaultBlockGap.toString()),n.thisParameter){const t=n.thisParameter,r=!!(null===(u=e.apis.byQName[t.type])||void 0===u?void 0:u.attributes.fixedInstances);let o=t.shadowBlockId,s=t.defaultValue;r||o&&"variables_get"!==o||(o="variables_get",s=s||t.definitionName);const l=c(e,t,o,s,i,a);l&&g.appendChild(l)}if("ENUM_GET"===t.attributes.shim||"KIND_GET"===t.attributes.shim){if(null===(d=t.parameters)||void 0===d?void 0:d.length){const e=t.parameters[0].default;if(e){const t=document.createElement("field");t.setAttribute("name","MEMBER"),t.textContent=e,g.appendChild(t)}}}else t.parameters&&(n.parameters.filter(e=>s.test(e.type)||s.test(l(e.type))||e.shadowBlockId||e.defaultValue).forEach(t=>{const n=c(e,t,void 0,void 0,i,a);n&&g.appendChild(n)}),t.attributes.draggableParameters?n.handlerArgs.forEach(e=>{const n="reporter"===t.attributes.draggableParameters,i=document.createElement("value");i.setAttribute("name",o.DRAGGABLE_PARAM_INPUT_PREFIX+e.name);const s=n?pxt.blocks.reporterTypeForArgType(e.type):"variables_get_reporter",a=document.createElement("block");a.setAttribute("type",s);const l=document.createElement("mutation");a.appendChild(l),n&&"argument_reporter_custom"===s&&l.setAttribute("typename",e.type),l.setAttribute(r.LOCALIZATION_NAME_MUTATION_KEY,e.localizationKey);const c=document.createElement("field");c.setAttribute("name",n?"VALUE":"VAR"),c.textContent=pxt.Util.htmlEscape(e.name),a.appendChild(c),i.appendChild(a),g.appendChild(i)}):n.handlerArgs.forEach(e=>{const t=document.createElement("field");t.setAttribute("name","HANDLER_"+e.name),t.textContent=e.name,g.appendChild(t)}));if(t.attributes.expandArgumentsInToolbox){let e;for(const t of g.children)if("mutation"===t.tagName){e=t;break}e||(e=document.createElement("mutation"),g.appendChild(e)),e.setAttribute("_expanded",""+t.attributes._expandedDef.parameters.length)}return p?(h.appendChild(g),p):g}function g(e,t,n,i){const r=document.createElement(i?"shadow":"block");r.setAttribute("type",pxt.Util.htmlEscape(e));const o=document.createElement("field");return o.setAttribute("name",pxt.Util.htmlEscape(t)),o.textContent=pxt.Util.htmlEscape(n),r.appendChild(o),r}function m(){const e=document.createElement("block");e.setAttribute("type","function_return");const t=document.createElement("value");t.setAttribute("name","RETURN_VALUE"),e.appendChild(t);const n=g("math_number","NUM","0",!0);return t.appendChild(n),e}n.isArrayType=l,n.createShadowValue=c,n.createFlyoutHeadingLabel=d,n.createFlyoutGroupLabel=p,n.createFlyoutButton=function(e,t){let n=i.utils.xml.createElement("button");return n.setAttribute("text",t),n.setAttribute("callbackKey",e),n},n.createFlyoutGap=function(e){const t=i.utils.xml.createElement("sep");return t.setAttribute("gap",e+""),t},n.createToolboxBlock=f,n.mkPredicateBlock=function(e){const t=document.createElement("block");t.setAttribute("type",e);const n=document.createElement("value");n.setAttribute("name","PREDICATE"),t.appendChild(n);const i=g("logic_boolean","BOOL","TRUE",!0);return n.appendChild(i),t},n.mkFieldBlock=g,n.mkVariableFieldBlock=function(e,t,n,i,r){const o=document.createElement(r?"shadow":"block");o.setAttribute("type",pxt.Util.htmlEscape(e));const s=document.createElement("field");return s.setAttribute("name","VAR"),s.id=t,s.setAttribute("variabletype",pxt.Util.htmlEscape(n)),s.textContent=pxt.Util.htmlEscape(i),o.appendChild(s),o},n.mkReturnStatementBlock=m,n.createFunctionsFlyoutCategory=function(e){const t=(0,r.flyoutCategory)(e);if(t.length>1){let e=m();t.splice(1,0,p(lf("Your Functions"))),t.splice(1,0,e)}const n=(0,r.getAllFunctionDefinitionBlocks)(e).filter(e=>e.getDescendants(!1).some(e=>"function_return"===e.type&&e.getInputTargetBlock("RETURN_VALUE"))).map(e=>e.getField("function_name").getText()),i=d(lf("Functions"),pxt.toolbox.getNamespaceColor("functions"),pxt.toolbox.getNamespaceIcon("functions"),"blocklyFlyoutIconfunctions");t.unshift(i);const o=[];for(const e of t)if(o.push(e),"function_call"===e.getAttribute("type")){const t=e.children.item(0);if(t){const i=t.getAttribute("name");if(n.some(e=>e===i)){const t=e.cloneNode(!0);t.setAttribute("type","function_call_output"),o.push(t)}}}return o}},{"./loader":79,"./plugins/functions":127,blockly:192}],155:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.maybeMoveFocusFromButton=void 0;const i=e("blockly"),r=e("./fields/field_imagenotext");n.maybeMoveFocusFromButton=e=>{const t=i.getFocusManager(),n=t.getFocusedNode();e&&(n instanceof r.FieldImageNoText||!n)&&t.focusNode(e)}},{"./fields/field_imagenotext":38,blockly:192}],156:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.PxtWorkspaceSearch=void 0;const i=e("blockly"),r=e("@blockly/plugin-workspace-search");class o extends r.WorkspaceSearch{constructor(e){super(e),this.injectionDiv=e.getInjectionDiv()}highlightSearchGroup(e){e.forEach(e=>{const t=e.pathObject.svgPath;i.utils.dom.addClass(t,"blockly-ws-search-highlight-pxt")})}unhighlightSearchGroup(e){e.forEach(e=>{const t=e.pathObject.svgPath;i.utils.dom.removeClass(t,"blockly-ws-search-highlight-pxt")})}open(){super.open(),i.utils.dom.addClass(this.injectionDiv,"blockly-ws-searching")}close(){super.close(),i.utils.dom.removeClass(this.injectionDiv,"blockly-ws-searching")}}n.PxtWorkspaceSearch=o,i.Css.register("\n.blockly-ws-search {\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n border: solid var(--pxt-neutral-alpha50) 1px;\n border-top: none;\n border-right: none;\n box-shadow: 0px 2px 15px var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input {\n -webkit-tap-highlight-color: transparent;\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n border: none;\n}\n\n.blockly-ws-search input::-webkit-input-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input::-moz-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input::-ms-input-placeholder {\n color: var(--pxt-neutral-alpha50);\n}\n\n.blockly-ws-search input:active,\n.blockly-ws-search input:focus {\n border-color: var(--pxt-neutral-alpha50);\n background: var(--pxt-neutral-background1);\n color: var(--pxt-neutral-foreground1);\n}\n\n.blockly-ws-search input::selection {\n color: var(--pxt-neutral-foreground1);\n}\n\n.blockly-ws-search button {\n padding-left: 6px;\n padding-right: 6px;\n color: var(--pxt-neutral-foreground1);\n}")},{"@blockly/plugin-workspace-search":187,blockly:192}],157:[function(e,t,n){function i(e,t,n,i){return pxt.Util.toArray(e.getElementsByTagName(t)).filter(e=>e.getAttribute(n)===i)}Object.defineProperty(n,"__esModule",{value:!0}),n.cleanOuterHTML=n.getDirectChildren=n.getFirstChildWithAttr=n.getChildrenWithAttr=n.getBlocksWithType=void 0,n.getBlocksWithType=function(e,t){return i(e,"block","type",t).concat(i(e,"shadow","type",t))},n.getChildrenWithAttr=i,n.getFirstChildWithAttr=function(e,t,n,r){const o=i(e,t,n,r);return o.length?o[0]:void 0},n.getDirectChildren=function(e,t){const n=[];for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes.item(i);r.tagName===t&&n.push(r)}return n},n.cleanOuterHTML=function(e){return e.outerHTML.replace(/^<\?[^>]*>/,"")}},{}],158:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.getNestedChildBlocks=void 0,n.getNestedChildBlocks=function(e){return e.getDescendants(!0).filter(t=>t.isEnabled()&&t.getSurroundParent()===e)}},{}],159:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),r(e("./runValidatorPlan"),n),r(e("./validateBlocksExist"),n),r(e("./validateBlocksInSetExist"),n),r(e("./validateCommentsExist"),n),r(e("./validateSpecificBlockCommentsExist"),n)},{"./runValidatorPlan":160,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165}],160:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.runValidatorPlan=void 0;const i=e("./validateBlockFieldValueExists"),r=e("./validateBlocksExist"),o=e("./validateBlocksInSetExist"),s=e("./validateCommentsExist"),a=e("./validateSpecificBlockCommentsExist"),l=e("./getNestedChildBlocks"),c=e("./validateVariableUsage");function u(e,t){const n=t.blockCounts.reduce((e,t)=>(e[t.blockId]=t.count,e),{}),i=(0,r.validateBlocksExist)({usedBlocks:e,requiredBlockCounts:n});let o=[];if(i.passed)for(const e of t.blockCounts){const t=e.blockId;o.push(...i.successfulBlocks[t])}return[o,i.passed]}function d(e,t){return(0,s.validateBlockCommentsExist)({usedBlocks:e,numRequired:t.count}).passed}function p(e,t){return(0,s.validateCommentsExist)({usedBlocks:e,numRequired:t.count}).passed}function h(e,t){return(0,a.validateSpecificBlockCommentsExist)({usedBlocks:e,blockType:t.blockType}).passed}function f(e,t){const n=(0,o.validateBlocksInSetExist)({usedBlocks:e,blockIdsToCheck:t.blocks,count:t.count});return[n.successfulBlocks,n.passed]}function g(e,t){const n=(0,i.validateBlockFieldValueExists)({usedBlocks:e,fieldType:t.fieldType,fieldValue:t.fieldValue,specifiedBlock:t.blockType});return[n.successfulBlocks,n.passed]}function m(e,t){const n=(0,c.validateVariableUsage)({usedBlocks:e,count:t.count,name:t.name}),i=[];for(const e of n.passingVarDefinitions.values())i.push(...e);return[i,n.passed]}n.runValidatorPlan=function e(t,n,i){const r=Date.now();let o=0,s=[];for(const r of n.checks){let n=!1;switch(r.validator){case"blocksExist":[s,n]=[...u(t,r)];break;case"commentsExist":n=p(t,r);break;case"blockCommentsExist":n=d(t,r);break;case"specificBlockCommentsExist":n=h(t,r);break;case"blocksInSetExist":[s,n]=[...f(t,r)];break;case"blockFieldValueExists":[s,n]=[...g(t,r)];break;case"variableUsage":[s,n]=[...m(t,r)];break;default:return pxt.debug(`Unrecognized validator: ${r.validator}`),pxt.tickEvent("validation.unrecognized_validator",{validator:r.validator}),{executionSuccess:!1,executionErrorMsg:lf("Unrecognized evaluation rule")}}if(n&&r.childValidatorPlans)for(const t of r.childValidatorPlans){let r=0;for(const n of s){const o=(0,l.getNestedChildBlocks)(n),s=i.find(e=>e.name===t);r+=e(o,s,i)?1:0}n=n&&r>0}o+=n?1:0}const a=o>=n.threshold;return pxt.tickEvent("validation.evaluation_complete",{plan:n.name,durationMs:Date.now()-r,passed:`${a}`}),{result:a,executionSuccess:!0}}},{"./getNestedChildBlocks":158,"./validateBlockFieldValueExists":161,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165,"./validateVariableUsage":166}],161:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlockFieldValueExists=void 0,n.validateBlockFieldValueExists=function({usedBlocks:e,fieldType:t,fieldValue:n,specifiedBlock:i}){const r=e.filter(e=>e.isEnabled()&&e.type===i).filter(e=>{var i;return"VAR"===t?(null===(i=e.getVarModels())||void 0===i?void 0:i[0].getName())===n:e.getFieldValue(t)===n});return{successfulBlocks:r,passed:r.length>0}}},{}],162:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlocksExist=void 0,n.validateBlocksExist=function({usedBlocks:e,requiredBlockCounts:t}){let n=[],i=[],r=[],o={};const s=null==e?void 0:e.reduce((e,t)=>(e[t.type]=(e[t.type]||0)+(t.isEnabled()?1:0),e),{});for(const[a,l]of Object.entries(t||{})){const t=s[a],c=e.filter(e=>e.isEnabled()&&e.type===a);c.length>0&&(o[a]=c),void 0===t?n.push(a):t?t<l&&r.push(a):i.push(a)}return{missingBlocks:n,disabledBlocks:i,insufficientBlocks:r,successfulBlocks:o,passed:0===n.length&&0===i.length&&0===r.length}}},{}],163:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateBlocksInSetExist=void 0,n.validateBlocksInSetExist=function({usedBlocks:e,blockIdsToCheck:t,count:n,requireUnique:i}){const r=[],o=e.filter(e=>e.isEnabled());for(const e of t){const t=o.filter(t=>t.type===e);i&&t.length>=1?r.push(t[0]):r.push(...t)}return{successfulBlocks:r,passed:r.length>=n}}},{}],164:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateCommentsExist=n.validateWorkspaceCommentsExist=n.validateBlockCommentsExist=void 0;const i=e("blockly");function r(e){return e.filter(e=>!!e.getCommentText())}function o(e){var t,n,r;const o=null!==(n=null===(t=e[0])||void 0===t?void 0:t.workspace)&&void 0!==n?n:i.getMainWorkspace();return(null!==(r=null==o?void 0:o.getTopComments())&&void 0!==r?r:[]).filter(e=>!!e.getText())}n.validateBlockCommentsExist=function({usedBlocks:e,numRequired:t}){const n=r(e);return{commentedBlocks:n,passed:n.length>=t}},n.validateWorkspaceCommentsExist=function({usedBlocks:e,numRequired:t}){const n=o(e);return{workspaceComments:n,passed:n.length>=t}},n.validateCommentsExist=function({usedBlocks:e,numRequired:t}){const n=[...r(e),...o(e)];return{comments:n,passed:n.length>=t}}},{blockly:192}],165:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateSpecificBlockCommentsExist=void 0,n.validateSpecificBlockCommentsExist=function({usedBlocks:e,blockType:t}){const n=e.filter(e=>e.type===t),i=n.filter(e=>!e.getCommentText());return{uncommentedBlocks:i,passed:0!==n.length&&0===i.length}}},{}],166:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.validateVariableUsage=void 0,n.validateVariableUsage=function({usedBlocks:e,count:t,name:n}){const i=new Map,r=new Set;for(const t of e){if(!t.isEnabled())continue;const e=t.getVarModels();for(const o of null!=e?e:[]){const e=o.getName();n&&e!==n||("variables_set"===t.type||"variables_change"===t.type?(i.has(e)||i.set(e,[]),i.get(e).push(t)):r.add(e))}}const o=new Map;for(const[e,t]of i)r.has(e)&&o.set(e,t);return{passingVarDefinitions:o,passed:o.size>=t}}},{}],167:[function(e,t,n){let i;Object.defineProperty(n,"__esModule",{value:!0}),n.isBlocks=n.initEditorExtensionsAsync=n.HELP_IMAGE_URI=void 0,n.HELP_IMAGE_URI="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIHZpZXdCb3g9IjAgMCAyNiAyNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTMiIGN5PSIxMyIgcj0iMTMiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xNy45NTIgOS4xODQwMkMxNy45NTIgMTAuMjU2IDE3LjgxNiAxMS4wNzIgMTcuNTQ0IDExLjYzMkMxNy4yODggMTIuMTkyIDE2Ljc1MiAxMi43OTIgMTUuOTM2IDEzLjQzMkMxNS4xMiAxNC4wNzIgMTQuNTc2IDE0LjU4NCAxNC4zMDQgMTQuOTY4QzE0LjA0OCAxNS4zMzYgMTMuOTIgMTUuNzM2IDEzLjkyIDE2LjE2OFYxNi45NkgxMS44MDhDMTEuNDI0IDE2LjQ2NCAxMS4yMzIgMTUuODQgMTEuMjMyIDE1LjA4OEMxMS4yMzIgMTQuNjg4IDExLjM4NCAxNC4yODggMTEuNjg4IDEzLjg4OEMxMS45OTIgMTMuNDg4IDEyLjUzNiAxMi45NjggMTMuMzIgMTIuMzI4QzE0LjEwNCAxMS42NzIgMTQuNjI0IDExLjE2OCAxNC44OCAxMC44MTZDMTUuMTM2IDEwLjQ0OCAxNS4yNjQgOS45NjgwMiAxNS4yNjQgOS4zNzYwMkMxNS4yNjQgOC4yMDgwMiAxNC40MTYgNy42MjQwMiAxMi43MiA3LjYyNDAyQzExLjc2IDcuNjI0MDIgMTAuNzUyIDcuNzM2MDIgOS42OTYgNy45NjAwMkw5LjE0NCA4LjA4MDAyTDkgNi4wODgwMkMxMC40ODggNS41NjAwMiAxMS44NCA1LjI5NjAyIDEzLjA1NiA1LjI5NjAyQzE0LjczNiA1LjI5NjAyIDE1Ljk2OCA1LjYwODAyIDE2Ljc1MiA2LjIzMjAyQzE3LjU1MiA2Ljg0MDAyIDE3Ljk1MiA3LjgyNDAyIDE3Ljk1MiA5LjE4NDAyWk0xMS40IDIyVjE4LjY0SDE0LjE4NFYyMkgxMS40WiIgZmlsbD0iIzU5NUU3NCIvPgo8L3N2Zz4K",n.initEditorExtensionsAsync=function(){if(!i&&(i=Promise.resolve(),pxt.appTarget&&pxt.appTarget.appTheme&&pxt.appTarget.appTheme.extendFieldEditors)){const e={};i=i.then(()=>pxt.BrowserUtils.loadBlocklyAsync()).then(()=>pxt.BrowserUtils.loadScriptAsync("fieldeditors.js")).then(()=>pxt.editor.initFieldExtensionsAsync(e)).then(e=>{e.fieldEditors&&e.fieldEditors.forEach(e=>{pxt.blocks.registerFieldEditor(e.selector,e.editor,e.validator)})})}return i},n.isBlocks=function(e){return pxt.U.endsWith(e.name,".blocks")}},{}],168:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.postHostMessageAsync=n.shouldPostHostMessages=n.enableControllerAnalytics=n.bindEditorMessages=void 0;const i=e("./code-validation/runValidatorPlan"),r=e("../pxtservices/iframeEmbeddedClient"),o=e("./projectImport"),s={};let a;n.bindEditorMessages=function(e){const t=pxt.appTarget.appTheme.allowParentController||pxt.shell.isControllerMode(),n=pxt.appTarget.appTheme.allowPackageExtensions,l=pxt.appTarget.appTheme.allowSimulatorTelemetry;if(!t&&!n&&!l)return;a=new r.IFrameEmbeddedClient(r=>{const a=r.data;if(!a||!/^pxt(host|editor|pkgext|sim)$/.test(a.type))return!1;if("pxtpkgext"===a.type&&n)e().then(e=>{e.handleExtensionRequest(a)});else if("pxtsim"===a.type&&l){const e=a;"event"===e.action&&(e.category||e.message?pxt.reportError(e.category,e.message,e.data):pxt.tickEvent(e.tick,e.data))}else if(t){let t,n=Promise.resolve();if("pxthost"==a.type){const e=s[a.id];e?n=n.then(()=>e.resolve(a)):pxt.debug(`pxthost: unknown request ${a.id}`)}else"pxteditor"==a.type&&(n=n.then(()=>e().then(e=>{const n=a;switch(pxt.debug(`pxteditor: ${n.action}`),n.action.toLowerCase()){case"switchjavascript":return Promise.resolve().then(()=>e.openJavaScript());case"switchpython":return Promise.resolve().then(()=>e.openPython());case"switchblocks":return Promise.resolve().then(()=>e.openBlocks());case"startsimulator":return Promise.resolve().then(()=>e.startSimulator());case"restartsimulator":return Promise.resolve().then(()=>e.restartSimulator());case"hidesimulator":return Promise.resolve().then(()=>e.collapseSimulator());case"showsimulator":return Promise.resolve().then(()=>e.expandSimulator());case"closeflyout":return Promise.resolve().then(()=>e.closeFlyout());case"unloadproject":return Promise.resolve().then(()=>e.unloadProjectAsync());case"saveproject":return e.saveProjectAsync();case"compile":return e.compile();case"redo":return Promise.resolve().then(()=>{const t=e.editor;t&&t.hasRedo()&&t.redo()});case"undo":return Promise.resolve().then(()=>{const t=e.editor;t&&t.hasUndo()&&t.undo()});case"setscale":{const t=a;return Promise.resolve().then(()=>e.editor.setScale(t.scale))}case"stopsimulator":{const t=a;return Promise.resolve().then(()=>e.stopSimulator(t.unload))}case"newproject":{const t=a;return Promise.resolve().then(()=>e.newProject(t.options))}case"importproject":{const t=a;return Promise.resolve().then(()=>e.importProjectAsync(t.project,{filters:t.filters,searchBar:t.searchBar}))}case"importexternalproject":{const e=a;return(0,o.saveProjectAsync)(e.project).then(e=>{const n=location.origin+location.pathname+`#embedimport:${e}`;t={importUrl:n}})}case"openheader":{const t=a;return e.openProjectByHeaderIdAsync(t.headerId)}case"startactivity":{const t=a;let n,i=t.path;return/^([jt]s|py|blocks?):/i.test(i)&&(n=/^py:/i.test(i)?pxt.PYTHON_PROJECT_NAME:/^[jt]s:/i.test(i)?pxt.JAVASCRIPT_PROJECT_NAME:pxt.BLOCKS_PROJECT_NAME,i=i.substr(i.indexOf(":")+1)),Promise.resolve().then(()=>e.startActivity({activity:t.activityType,path:i,title:t.title,editor:n,previousProjectHeaderId:t.previousProjectHeaderId,carryoverPreviousCode:t.carryoverPreviousCode}))}case"importtutorial":{const t=a;return Promise.resolve().then(()=>e.importTutorialAsync(t.markdown))}case"proxytosim":{const t=a;return Promise.resolve().then(()=>e.proxySimulatorMessage(t.content))}case"renderblocks":{const n=a;return Promise.resolve().then(()=>e.renderBlocksAsync(n)).then(e=>e.xml.then(e=>{t=e.xml}))}case"renderxml":{const n=a;return Promise.resolve().then(()=>e.renderXml(n).resultXml.then(e=>{t=e.xml}))}case"renderbyblockid":{const n=a;return Promise.resolve().then(()=>e.renderByBlockIdAsync(n)).then(e=>e.resultXml.then(e=>{t=e.xml}))}case"runeval":{const n=a,r=n.validatorPlan,o=n.planLib;return Promise.resolve().then(()=>{const t=e.getBlocks();return(0,i.runValidatorPlan)(t,r,o)}).then(e=>{t=e})}case"gettoolboxcategories":{const n=a;return Promise.resolve().then(()=>{t=e.getToolboxCategories(n.advanced)})}case"getblockastext":{const n=a;return Promise.resolve().then(()=>{const i=e.getBlockAsText(n.blockId);t={blockAsText:i}})}case"renderpython":{const n=a;return Promise.resolve().then(()=>e.renderPythonAsync(n)).then(e=>{t=e.python})}case"toggletrace":{const t=a;return Promise.resolve().then(()=>e.toggleTrace(t.intervalSpeed))}case"settracestate":{const t=a;return Promise.resolve().then(()=>e.setTrace(t.enabled,t.intervalSpeed))}case"setsimulatorfullscreen":{const t=a;return Promise.resolve().then(()=>e.setSimulatorFullScreen(t.enabled))}case"showthemepicker":return Promise.resolve().then(()=>e.showThemePicker());case"togglehighcontrast":return Promise.resolve().then(()=>e.toggleHighContrast());case"sethighcontrast":{const t=a;return Promise.resolve().then(()=>e.setHighContrast(t.on))}case"togglegreenscreen":return Promise.resolve().then(()=>e.toggleGreenScreen());case"togglekeyboardcontrols":return Promise.resolve();case"togglescreenreadermode":return e.toggleScreenReaderModeAsync("settings");case"print":return Promise.resolve().then(()=>e.printCode());case"pair":return e.pairAsync().then(()=>{});case"info":return Promise.resolve().then(()=>{t={versions:pxt.appTarget.versions,locale:ts.pxtc.Util.userLanguage(),availableLocales:pxt.appTarget.appTheme.availableLocales,keyboardControls:!0,screenReaderMode:e.isScreenReaderModeEnabled()}});case"shareproject":{const n=a;return e.anonymousPublishHeaderByIdAsync(n.headerId,n.projectName).then(e=>{t=e})}case"savelocalprojectstocloud":{const n=a;return e.saveLocalProjectsToCloudAsync(n.headerIds).then(e=>{t={headerIdMap:e}})}case"requestprojectcloudstatus":{const t=a;return e.requestProjectCloudStatus(t.headerIds)}case"convertcloudprojectstolocal":{const t=a;return e.convertCloudProjectsToLocal(t.userId)}case"setlanguagerestriction":{const t=a;if("no-blocks"===t.restriction)throw pxt.warn("no-blocks language restriction is not supported"),new Error("no-blocks language restriction is not supported");return e.setLanguageRestrictionAsync(t.restriction)}case"precachetutorial":{const e=a,t=e.data,n=e.lang||pxt.Util.userLanguage();return pxt.github.db.cacheReposAsync(t).then(async()=>{if("string"==typeof t.markdown){const e=await pxt.BrowserUtils.translationDbAsync();await e.setAsync(n,t.path,void 0,void 0,t.markdown)}})}case"setcolorthemebyid":{const t=a;return e.setColorThemeById(t.colorThemeId,!!t.savePreference),Promise.resolve()}}return Promise.resolve()})));n.then(()=>c(a,t,!0,void 0),e=>c(a,t,!1,e))}return!0})};let l=!1;function c(e,t,n,i){if(e.response){const r={type:e.type,id:e.id,resp:t,success:n,error:i};a?a.postMessage(r):window.parent.postMessage(r,"*")}}function u(e){return new Promise((t,n)=>{const i=pxt.Util.clone(e);if(i.id=ts.pxtc.Util.guidGen(),e.response&&(s[i.id]={resolve:t,reject:n}),a?a.postMessage(i):window.parent.postMessage(i,"*"),pxt.commands.onPostHostMessage)try{pxt.commands.onPostHostMessage(i)}catch(e){pxt.reportException(e)}e.response||t(void 0)})}n.enableControllerAnalytics=function(){if(l)return;const e=!!pxt.commands.onPostHostMessage,t=pxt.appTarget.appTheme.allowParentController,n=pxt.BrowserUtils.isIFrame();if(!(e||t&&n))return;const i=pxt.tickEvent;pxt.tickEvent=function(e,t,n){i&&i(e,t,n),u({type:"pxthost",action:"event",tick:e,response:!1,data:t})};const r=pxt.reportException;pxt.reportException=function(e,t){r&&r(e,t);try{u({type:"pxthost",action:"event",tick:"error",message:e.message,response:!1,data:t})}catch(e){}};const o=pxt.reportError;pxt.reportError=function(e,t,n){o&&o(e,t,n),u({type:"pxthost",action:"event",tick:"error",category:e,message:t,data:n})},l=!0},n.shouldPostHostMessages=function(){return pxt.appTarget.appTheme.allowParentController&&pxt.BrowserUtils.isIFrame()},n.postHostMessageAsync=u},{"../pxtservices/iframeEmbeddedClient":185,"./code-validation/runValidatorPlan":160,"./projectImport":180}],169:[function(e,t,n){function i(e){return`experiments-${"object"==typeof e?e.id:e}`}let r;function o(){const e=pxt.savedAppTheme(),t={},n=s();return n.forEach(n=>{const i=a(n);e[n.id]=!!i,i&&(t[n.id]=i?1:0)}),n.length&&Object.keys(t).length&&(pxt.tickEvent("experiments.loaded",t),pxt.reloadAppTargetVariant()),pxt.appTarget.appTheme}function s(){const e=pxt.appTarget.appTheme.experiments;if(!e)return[];return[{id:"print",name:lf("Print Code"),description:lf("Print the code from the current project"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4740"},{id:"greenScreen",name:lf("Green screen"),description:lf("Display a webcam video stream or a green background behind the code."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4738"},{id:"allowPackageExtensions",name:lf("Editor Extensions"),description:lf("Allow Extensions to add buttons in the editor."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4741"},{id:"instructions",name:lf("Wiring Instructions"),description:lf("Generate step-by-step assembly instructions for breadboard wiring."),feedbackUrl:"https://github.com/microsoft/pxt/issues/4739"},{id:"debugger",name:lf("Debugger"),description:lf("Step through code and inspect variables in the debugger"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4729"},{id:"bluetoothUartConsole",name:"Bluetooth Console",description:lf("Receives UART message through Web Bluetooth"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4796"},{id:"bluetoothPartialFlashing",name:"Bluetooth Download",description:lf("Download code via Web Bluetooth"),feedbackUrl:"https://github.com/microsoft/pxt/issues/4807"},{id:"simScreenshot",name:lf("Simulator Screenshots"),description:lf("Download screenshots of the simulator"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5232"},{id:"python",name:lf("Static Python"),description:lf("Use Static Python to code your device"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5390"},{id:"simGif",name:lf("Simulator Gifs"),description:lf("Download gifs of the simulator"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5297"},{id:"qrCode",name:lf("Shared QR Code"),description:lf("Generate a QR Code form the shared project url"),feedbackUrl:"https://github.com/microsoft/pxt/issues/5456"},{id:"importExtensionFiles",name:lf("Import Extension Files"),description:lf("Import Extensions from compiled project files")},{id:"debugExtensionCode",name:lf("Debug Extension Code"),description:lf("Use the JavaScript debugger to debug extension code")},{id:"advancedBlockDebugger",name:lf("Advanced Blocks Debugger"),description:lf("Enables extra options and variables in the Blocks debugger")},{id:"snippetBuilder",name:lf("Snippet Builder"),description:lf("Try out the new snippet dialogs.")},{id:"experimentalHw",name:lf("Experimental Hardware"),description:lf("Enable support for hardware marked 'experimental' in the hardware seletion dialog")},{id:"checkForHwVariantWebUSB",name:lf("Detect Hardware with WebUSB"),description:lf("When compiling, use WebUSB to detect hardware configuration.")},{id:"githubEditor",name:lf("GitHub editor"),description:lf("Review, commit and push to GitHub."),feedbackUrl:"https://github.com/microsoft/pxt/issues/6419",enableOnline:!0},{id:"githubCompiledJs",name:lf("GitHub Pages JavaScript"),description:lf("Commit compiled javascript when creating a release"),enableOnline:!0},{id:"blocksCollapsing",name:lf("Collapse blocks"),description:lf("Collapse and expand functions or event blocks")},{id:"tutorialBlocksDiff",name:lf("Tutorial Block Diffs"),description:lf("Automatially render blocks diff in tutorials")},{id:"openProjectNewTab",name:lf("Open in New Tab"),description:lf("Open an editor in a new tab.")},{id:"openProjectNewDependentTab",name:lf("Open in New Connected Tab"),description:lf("Open connected editors in different browser tabs.")},{id:"errorList",name:lf("Error List"),description:lf("Show an error list panel for JavaScript and Python.")},{id:"timeMachine",name:lf("Time Machine"),description:lf("Save and restore past versions of a project")},{id:"forceEnableAiErrorHelp",name:lf("AI Error Explainer"),description:lf("Get AI's help explaining errors in your code"),feedbackUrl:"https://github.com/microsoft/pxt/issues/10694",enableOnline:!0}].filter(t=>e.indexOf(t.id)>-1).concat(r||[]).filter(e=>!(pxt.BrowserUtils.isPxtElectron()&&e.enableOnline))}function a(e){return!!pxt.storage.getLocal(i(e))}function l(e,t){t!=a(e)&&(t?pxt.storage.setLocal(i(e),"1"):pxt.storage.removeLocal(i(e)),o())}Object.defineProperty(n,"__esModule",{value:!0}),n.setState=n.state=n.toggle=n.isEnabled=n.someEnabled=n.clear=n.all=n.syncTheme=n.setEditorExtensionExperiments=void 0,n.setEditorExtensionExperiments=function(e){r=e},n.syncTheme=o,n.all=s,n.clear=function(){s().forEach(e=>pxt.storage.removeLocal(i(e))),o()},n.someEnabled=function(){return s().some(e=>a(e))},n.isEnabled=a,n.toggle=function(e){e.onClick?e.onClick():l(e,!a(e))},n.state=function(){const e={};return s().forEach(t=>e[t.id]=a(t)),JSON.stringify(e)},n.setState=l},{}],170:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.patchConfigEditorVersion=n.getTextAtTime=n.updateShareHistory=n.pushSnapshotOnHistory=n.updateHistory=n.parseHistoryFile=n.applySnapshot=n.createSnapshot=n.applyDiff=n.diffScriptText=n.collapseHistory=void 0;const i=18e5,r=864e5;function o(e,t,n,i,r){const o=[],l=e.entries.slice();let c=Object.assign({},t),{interval:u,minTime:d,maxTime:p}=n;void 0===d&&(d=0),void 0===p&&(p=e.lastSaveTime);let h=Object.assign({},c),f=e.lastSaveTime;for(;l.length;){const e=l.pop();c=a(c,e,r),e.timestamp>p?(o.unshift(e),h=Object.assign({},c),f=e.timestamp):e.timestamp<d?h?(o.unshift({timestamp:e.timestamp,editorVersion:e.editorVersion,changes:s(c,h,e.timestamp,i).changes}),h=void 0):o.unshift(e):f-e.timestamp>=u&&(o.unshift({timestamp:e.timestamp,editorVersion:e.editorVersion,changes:s(c,h,e.timestamp,i).changes}),h=Object.assign({},c),f=e.timestamp)}return h&&f>e.entries[0].timestamp&&o.unshift({timestamp:e.entries[0].timestamp,editorVersion:e.entries[0].editorVersion,changes:s(c,h,e.entries[0].timestamp,i).changes}),Object.assign(Object.assign({},e),{entries:o})}function s(e,t,n,i){var r,o;const s=[];for(const n of Object.keys(e))(n.endsWith(".ts")||n.endsWith(".jres")||n.endsWith(".py")||n.endsWith(".blocks")||"pxt.json"===n)&&(null==t[n]?s.push({type:"removed",filename:n,value:e[n]}):e[n]!==t[n]&&s.push({type:"edited",filename:n,patch:i(t[n],e[n])}));for(const n of Object.keys(t))(n.endsWith(".ts")||n.endsWith(".jres")||n.endsWith(".py")||n.endsWith(".blocks")||"pxt.json"===n)&&null==e[n]&&s.push({type:"added",filename:n,value:t[n]});if(s.length)return{timestamp:n,editorVersion:null===(o=null===(r=pxt.appTarget)||void 0===r?void 0:r.versions)||void 0===o?void 0:o.target,changes:s}}function a(e,t,n){const i=Object.assign({},e);for(const r of t.changes)"added"===r.type?delete i[r.filename]:"removed"===r.type?i[r.filename]=r.value:i[r.filename]=n(r.patch,e[r.filename]);return i}function l(e){let t;try{t={};const n=JSON.parse(e[pxt.CONFIG_NAME]);for(const i of n.files)i===pxt.IMAGES_CODE||i===pxt.TILEMAP_CODE?t[i]="":t[i]=e[i];if(t[pxt.CONFIG_NAME]=e[pxt.CONFIG_NAME],n.preferredEditor===pxt.BLOCKS_PROJECT_NAME?t[pxt.MAIN_BLOCKS]&&(t[pxt.MAIN_TS]=""):n.preferredEditor===pxt.PYTHON_PROJECT_NAME&&t[pxt.MAIN_PY]&&(t[pxt.MAIN_TS]=""),n.testFiles)for(const i of n.testFiles)t[i]=e[i]}catch(n){t=Object.assign({},e)}return t[pxt.HISTORY_FILE]&&delete t[pxt.HISTORY_FILE],t}function c(e){const t=JSON.parse(e);return t.entries||(t.entries=[]),t.shares||(t.shares=[]),t.snapshots||(t.snapshots=[]),t}function u(e,t){e=Object.assign({},e);try{const n=JSON.parse(e[pxt.CONFIG_NAME]);n.targetVersions&&(n.targetVersions.target=t),e[pxt.CONFIG_NAME]=JSON.stringify(n,null,4)}catch(e){}return{files:e,editorVersion:t}}function d(e,t){return{timestamp:t,editorVersion:pxt.appTarget.versions.target,text:l(e)}}function p(){var e,t;return null!=(null===(t=null===(e=pxt.appTarget)||void 0===e?void 0:e.appTheme)||void 0===t?void 0:t.timeMachineDiffInterval)?pxt.appTarget.appTheme.timeMachineDiffInterval:3e5}n.collapseHistory=function(e,t,n,i){if(!e[pxt.HISTORY_FILE])return;const r=o(c(e[pxt.HISTORY_FILE]),e,t,n,i);e[pxt.HISTORY_FILE]=JSON.stringify(r)},n.diffScriptText=s,n.applyDiff=a,n.createSnapshot=l,n.applySnapshot=function(e,t){var n;try{const i=Object.assign({},t),r=JSON.parse(e[pxt.CONFIG_NAME]);for(const t of Object.keys(e))t!==pxt.HISTORY_FILE&&(-1!==r.files.indexOf(t)||-1!==(null===(n=r.testFiles)||void 0===n?void 0:n.indexOf(t))||i[t]||(i[t]=e[t]));return i}catch(n){const i=Object.assign({},e);for(const e of Object.keys(t))i[e]=t[e];return i}},n.parseHistoryFile=c,n.updateHistory=function(e,t,n,l,u,h,f=!1){let g;e[pxt.HISTORY_FILE]?(g=c(e[pxt.HISTORY_FILE]),void 0===g.lastSaveTime&&(g.lastSaveTime=n)):g={entries:[],snapshots:[d(e,n-1)],shares:[],lastSaveTime:n};const m=g.lastSaveTime;for(const e of l)g.shares.some(t=>t.id===e.id)||g.shares.push({id:e.id,timestamp:n});if(function(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n){if(-1===i.indexOf(r))return!1;if(e[r]!==t[r])return!1}return!0}(e,t))return void(t[pxt.HISTORY_FILE]=JSON.stringify(g));let _=!1;if(1===g.entries.length){n-g.entries[g.entries.length-1].timestamp<p()&&(_=!0)}else if(g.entries.length>1){const e=g.entries[g.entries.length-1].timestamp,t=g.entries[g.entries.length-2].timestamp;n-e<p()&&e-t<p()&&(_=!0)}if(_){const n=g.entries.pop(),i=s(a(e,n,h),t,n.timestamp,u);i&&g.entries.push(i)}else{const n=s(e,t,g.lastSaveTime,u);n&&g.entries.push(n)}if(f&&Math.floor(m/r)!==Math.floor(n/r)&&(g=o(g,t,{interval:72e5,maxTime:n-r},u,h)),g.lastSaveTime=n,0==g.snapshots.length)g.snapshots.push(d(e,n-1));else if(n-g.snapshots[g.snapshots.length-1].timestamp>=function(){var e,t;if(null!=(null===(t=null===(e=pxt.appTarget)||void 0===e?void 0:e.appTheme)||void 0===t?void 0:t.timeMachineSnapshotInterval))return pxt.appTarget.appTheme.timeMachineSnapshotInterval;return i}()){g.snapshots.push(d(e,n));const t=[];let i=Math.floor(n/r)*r;for(let e=0;e<g.snapshots.length;e++){const o=g.snapshots[g.snapshots.length-1-e];n-o.timestamp<r||e===g.snapshots.length-1?t.unshift(o):o.timestamp<i&&(t.unshift(o),i=Math.floor(o.timestamp/r)*r)}g.snapshots=t}for(const e of g.snapshots)e.text[pxt.HISTORY_FILE]&&delete e.text[pxt.HISTORY_FILE];t[pxt.HISTORY_FILE]=JSON.stringify(g)},n.pushSnapshotOnHistory=function(e,t){let n;n=e[pxt.HISTORY_FILE]?c(e[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:t},n.snapshots.push(d(e,t)),e[pxt.HISTORY_FILE]=JSON.stringify(n)},n.updateShareHistory=function(e,t,n){let i;i=e[pxt.HISTORY_FILE]?c(e[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:t};for(const e of n)i.shares.some(t=>t.id===e.id)||i.shares.push({id:e.id,timestamp:t});e[pxt.HISTORY_FILE]=JSON.stringify(i)},n.getTextAtTime=function(e,t,n,i){let r=Object.assign({},e);for(let e=0;e<t.entries.length;e++){const o=t.entries.length-1-e,s=t.entries[o];if(r=a(r,s,i),s.timestamp===n){return u(r,o>0?t.entries[o-1].editorVersion:s.editorVersion)}}return{files:r,editorVersion:pxt.appTarget.versions.target}},n.patchConfigEditorVersion=u},{}],171:[function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(n,"__esModule",{value:!0}),n.importDb=n.validation=n.experiments=n.workspace=n.monaco=n.history=void 0;const o=e("./history");n.history=o;const s=e("./monaco");n.monaco=s;const a=e("./workspace");n.workspace=a;const l=e("./experiments");n.experiments=l;const c=e("./code-validation");n.validation=c;const u=e("./projectImport");n.importDb=u,r(e("./editor"),n),r(e("./editorcontroller"),n),r(e("./monaco-fields/monacoFieldEditor"),n),r(e("./monaco-fields/field_tilemap"),n),r(e("./monaco-fields/field_musiceditor"),n),r(e("./monaco-fields/field_soundEffect"),n),r(e("./monaco-fields/field_sprite"),n),r(e("./monaco-fields/field_animation"),n),r(e("./monaco-fields/field_react"),n)},{"./code-validation":159,"./editor":167,"./editorcontroller":168,"./experiments":169,"./history":170,"./monaco":179,"./monaco-fields/field_animation":172,"./monaco-fields/field_musiceditor":173,"./monaco-fields/field_react":174,"./monaco-fields/field_soundEffect":175,"./monaco-fields/field_sprite":176,"./monaco-fields/field_tilemap":177,"./monaco-fields/monacoFieldEditor":178,"./projectImport":180,"./workspace":181}],172:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.animationEditorDefinition=n.MonacoAnimationEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="animation-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`");const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject(),r=i.lookupAssetByName("animation",n);if(r)return this.editing=r,r;{const e=i.createNewAnimation();return n&&!i.isNameTaken("animation",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("animation"),this.editing=e,e}}}resultToText(e){const t=pxt.react.getTilemapProject();return t.pushUndo(),e=pxt.patchTemporaryAsset(this.editing,e,t),e=t.updateAsset(e),pxt.getTSReferenceForAsset(e,this.isPython)}getFieldEditorId(){return o}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}n.MonacoAnimationEditor=s;const a=["assets\\s*\\.\\s*animation\\s*`[^`]*`",'assets\\s*\\.\\s*animation\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.animationEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.animationEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],173:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.songEditorDefinition=n.MonacoSongEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="music-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`"),this.text=e;const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject();this.isAsset=!0;const r=i.lookupAssetByName("song",n);if(r)return this.editing=r,r;{const e=i.createNewSong(pxt.assets.music.getEmptySong(2));return n&&!i.isNameTaken("song",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("song"),this.editing=e,e}}const n=/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m.exec(e);if(n){const e=n[1].trim();return this.editing=a(e?pxt.assets.music.decodeSongFromHex(e):pxt.assets.music.getEmptySong(2)),this.editing}}resultToText(e){var t;const n=pxt.react.getTilemapProject();if(n.pushUndo(),null===(t=(e=pxt.patchTemporaryAsset(this.editing,e,n)).meta)||void 0===t?void 0:t.displayName){e=this.isAsset||n.lookupAsset(e.type,e.id)?n.updateAsset(e):n.createNewSong(e.song,e.meta.displayName);let t=pxt.getTSReferenceForAsset(e,this.isPython);return this.isAsset||(t=this.isPython?`music.create_song(${t})`:`music.createSong(${t})`),t}let i=pxt.assets.music.encodeSongToHex(e.song);return i=this.isPython?`hex("""${i}""")`:"hex`"+i+"`",this.text.replace(/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m,i)}getFieldEditorId(){return o}getOptions(){return{blocksInfo:this.host.blocksInfo()}}}function a(e){return{type:"song",id:"",internalID:0,meta:{},song:e}}n.MonacoSongEditor=s;const l=["music\\s*\\.\\s*createSong\\s*\\(\\s*hex`[a-fA-F0-9\\s\\n]*`\\s*\\)","assets\\s*\\.\\s*song\\s*`[^`]*`",'music\\s*\\.\\s*create_song\\s*\\(\\s*hex\\s*\\(\\s*"""[a-fA-F0-9\\s\\n]*"""\\s*\\)\\s*\\)','music\\s*\\.\\s*createSong\\s*\\(\\s*hex\\s*\\(\\s*"""[a-fA-F0-9\\s\\n]*"""\\s*\\)\\s*\\)','assets\\s*\\.\\s*song\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.songEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:l,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.songEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],174:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.MonacoReactFieldEditor=void 0;n.MonacoReactFieldEditor=class{getId(){return"image-editor"}showEditorAsync(e,t,n){return this.fileType=e,this.editrange=t,this.host=n,this.initAsync().then(()=>{const e=this.textToValue(n.getText(t));return e?(this.fv=pxt.react.getFieldEditorView(this.getFieldEditorId(),e,this.getOptions()),this.fv.onHide(()=>{this.onClosed()}),this.fv.show(),new Promise((e,t)=>{this.resolver=e,this.rejecter=t})):Promise.resolve(null)})}onClosed(){this.resolver&&(this.resolver({range:this.editrange,replacement:this.resultToText(this.fv.getResult())}),this.editrange=void 0,this.resolver=void 0,this.rejecter=void 0)}dispose(){this.onClosed()}initAsync(){return Promise.resolve()}textToValue(e){return null}resultToText(e){return e+""}getFieldEditorId(){return""}getOptions(){return null}}},{}],175:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.soundEditorDefinition=n.MonacoSoundEffectEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="soundeffect-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){const t={wave:"sine",startFrequency:5e3,endFrequency:0,startVolume:255,endVolume:0,duration:500,effect:"none",interpolation:"linear"};this.value=t;const n=/\(([^)]*)\)/.exec(e)[1].split(",").map(e=>e.replace(/\s/g,""));if(8!==n.length)return t;switch(n[0]){case"WaveShape.Sawtooth":t.wave="sawtooth";break;case"WaveShape.Square":t.wave="square";break;case"WaveShape.Noise":t.wave="noise";break;case"WaveShape.Triangle":t.wave="triangle";break;default:t.wave="sine"}const i=(e,t)=>isNaN(e)?t:e;switch(t.startFrequency=i(parseInt(n[1]),t.startFrequency),t.endFrequency=i(parseInt(n[2]),t.endFrequency),t.startVolume=i(parseInt(n[3]),t.startVolume),t.endVolume=i(parseInt(n[4]),t.endVolume),t.duration=i(parseInt(n[5]),t.duration),n[6]){case"SoundExpressionEffect.Vibrato":t.effect="vibrato";break;case"SoundExpressionEffect.Tremolo":t.effect="tremolo";break;case"SoundExpressionEffect.Warble":t.effect="warble";break;default:t.effect="none"}switch(n[7]){case"InterpolationCurve.Logarithmic":t.interpolation="logarithmic";break;case"InterpolationCurve.Curve":t.interpolation="curve";break;default:t.interpolation="linear"}return t}resultToText(e){let t,n,i;switch((e=this.value).wave){case"sine":t="WaveShape.Sine";break;case"square":t="WaveShape.Square";break;case"triangle":t="WaveShape.Triangle";break;case"noise":t="WaveShape.Noise";break;case"sawtooth":t="WaveShape.Sawtooth"}switch(e.effect){case"vibrato":n="SoundExpressionEffect.Vibrato";break;case"tremolo":n="SoundExpressionEffect.Tremolo";break;case"warble":n="SoundExpressionEffect.Warble";break;case"none":n="SoundExpressionEffect.None"}switch(e.interpolation){case"curve":i="InterpolationCurve.Curve";break;case"linear":i="InterpolationCurve.Linear";break;case"logarithmic":i="InterpolationCurve.Logarithmic"}return`music.createSoundEffect(${t}, ${Math.round(e.startFrequency)}, ${Math.round(e.endFrequency)}, ${Math.round(e.startVolume)}, ${Math.round(e.endVolume)}, ${Math.round(e.duration)}, ${n}, ${i})`}getFieldEditorId(){return o}getOptions(){return{onClose:()=>this.fv.hide(),onSoundChange:e=>this.value=e,initialSound:this.value,useFlex:!0,useMixerSynthesizer:"microbit"!==pxt.appTarget.id}}}n.MonacoSoundEffectEditor=s,n.soundEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:"music\\s*\\.\\s*createSoundEffect\\s*\\(",isRegex:!0,matchCase:!0,matchWholeWord:!1,validateRange:function(e,t){let n=e.startLineNumber,i=0,r=!1,o=0;const s="createSoundEffect",a=t.getLineCount();for(;n<a;){const a=t.getLineContent(n),l=a.indexOf(s);if(-1!==l&&(r=!0,i=l+17),r)for(;i<a.length;){const r=a.charAt(i);if("("===r)o++;else if(")"===r&&(o--,0===o))return new monaco.Range(e.startLineNumber,e.startColumn,n,i+t.getLineMinColumn(n)+1);i++}i=0,n++}}},proto:s},(0,r.registerMonacoFieldEditor)(o,n.soundEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],176:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.spriteEditorDefinition=n.MonacoSpriteEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="image-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){this.isPython=-1===e.indexOf("`"),this.template=e.startsWith("bmp")?"bmp":"img";const t=pxt.parseAssetTSReference(e);if(t){const{name:e}=t,n=e.trim(),i=pxt.react.getTilemapProject();this.isAsset=!0;const r=i.lookupAssetByName("image",n);if(r)return this.editing=r,r;{const e=i.createNewImage();return n&&!i.isNameTaken("image",n)&&pxt.validateAssetName(n)?e.meta.displayName=n:e.meta.displayName=i.generateNewName("image"),this.editing=e,e}}return this.editing={type:"image",id:"",internalID:0,bitmap:pxt.sprite.imageLiteralToBitmap(e,this.template).data(),meta:{},jresData:""},this.editing}resultToText(e){var t;const n=pxt.react.getTilemapProject();return n.pushUndo(),(null===(t=(e=pxt.patchTemporaryAsset(this.editing,e,n)).meta)||void 0===t?void 0:t.displayName)?(e=this.isAsset||n.lookupAsset(e.type,e.id)?n.updateAsset(e):n.createNewProjectImage(e.bitmap,e.meta.displayName),this.isAsset=!0,pxt.getTSReferenceForAsset(e,this.isPython)):pxt.sprite.bitmapToImageLiteral(pxt.sprite.Bitmap.fromData(e.bitmap),this.isPython?"python":"typescript",this.template)}getFieldEditorId(){return"image-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}n.MonacoSpriteEditor=s;const a=["img\\s*`[\\.a-zA-Z0-9#\\n\\s]*`","bmp\\s*`[\\.a-zA-Z0-9#\\n\\s]*`","assets\\s*\\.\\s*image\\s*`[^`]*`",'img\\s*\\(\\s*"""[\\.a-zA-Z0-9#\\n\\s]*"""\\s*\\)','bmp\\s*\\(\\s*"""[\\.a-zA-Z0-9#\\n\\s]*"""\\s*\\)','assets\\s*\\.\\s*image\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(e=>`(?:${e})`).join("|");n.spriteEditorDefinition={id:o,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.spriteEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],177:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.tilemapEditorDefinition=n.MonacoTilemapEditor=void 0;const i=e("./field_react"),r=e("./monacoFieldEditor"),o="tilemap-editor";class s extends i.MonacoReactFieldEditor{textToValue(e){const t=this.readTilemap(e),n=pxt.react.getTilemapProject();return pxt.sprite.addMissingTilemapTilesAndReferences(n,t),this.editing=t,t}readTilemap(e){const t=pxt.react.getTilemapProject();if(/^\s*tiles\s*\./.test(e)&&(this.isTilemapLiteral=!1,e)){try{return function(e){return{type:"tilemap",id:"",internalID:0,meta:{},data:e}}(pxt.sprite.decodeTilemap(e,"typescript",t))}catch(e){}return null}this.isTilemapLiteral=!0;const n=/^\s*(tilemap(?:4|8|16|32)?)\s*(?:`([^`]*)`)|(?:\(\s*"""([^"]*)"""\s*\))\s*$/.exec(e),i=(n[2]||n[3]||"").trim();let r,o;if(this.tilemapLiteral=n[1],i&&(o=ts.pxtc.escapeIdentifier(i),r=t.getTilemap(o)||t.lookupAssetByName("tilemap",i)),!r){let e=16;"tilemap8"===this.tilemapLiteral?e=8:"tilemap32"===this.tilemapLiteral?e=32:"tilemap4"===this.tilemapLiteral&&(e=4);const[n]=t.createNewTilemap(o,e,16,16);r=t.getTilemap(n),o=n}return r}resultToText(e){const t=pxt.react.getTilemapProject();return t.pushUndo(),e=pxt.patchTemporaryAsset(this.editing,e,t),pxt.sprite.updateTilemapReferencesFromResult(t,e),this.isTilemapLiteral?(t.updateAsset(e),pxt.getTSReferenceForAsset(e,"python"===this.fileType)):pxt.sprite.encodeTilemap(e.data,"typescript"===this.fileType?"typescript":"python")}getFieldEditorId(){return"tilemap-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}getCreateTilemapRange(){const e=this.editrange.getStartPosition();let t,n=this.editrange.getEndPosition(),i=1;for(;;){t=new monaco.Range(n.lineNumber,n.column,n.lineNumber+1,0);const r=this.host.getText(t);for(let t=0;t<r.length;t++)if("("===r.charAt(t))i++;else if(")"===r.charAt(t)&&(i--,0===i)){const i=new monaco.Position(n.lineNumber,n.column+t+2);return monaco.Range.fromPositions(e,i)}if(n=t.getEndPosition(),n.lineNumber>e.lineNumber+20)return null}}}n.MonacoTilemapEditor=s,n.tilemapEditorDefinition={id:o,foldMatches:!0,alwaysBuildOnClose:!0,glyphCssClass:"sprite-focus-hover ms-Icon ms-Icon--Nav2DMapView",heightInPixels:510,weight:5,matcher:{searchString:'(?:tilemap(?:8|16|32)?\\s*(?:`|\\(""")(?:[^`"]|\\n)*\\s*(?:`|"""\\)))|(?:tiles\\s*\\.\\s*createTilemap\\s*\\([^\\)]+\\))',isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:s},(0,r.registerMonacoFieldEditor)(o,n.tilemapEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],178:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.getMonacoFieldEditor=n.registerMonacoFieldEditor=void 0;const i={};n.registerMonacoFieldEditor=function(e,t){i[e]=t},n.getMonacoFieldEditor=function(e){return i[e]}},{}],179:[function(e,t,n){function i(e){const t=pxt.appTarget.appTheme.invertedMonaco,n=!(!pxt.appTarget.appTheme.monacoFieldEditors||!pxt.appTarget.appTheme.monacoFieldEditors.length);let i=monaco.editor.create(e,{model:null,ariaLabel:pxt.Util.lf("JavaScript editor"),fontFamily:"'Consolas', 'Monaco', 'Menlo', 'Ubuntu Mono', 'source-code-pro', 'monospace'",scrollBeyondLastLine:!0,language:"typescript",mouseWheelZoom:!1,wordBasedSuggestions:!0,lineNumbersMinChars:3,formatOnPaste:!0,folding:n,glyphMargin:n||pxt.appTarget.appTheme.debugger,minimap:{enabled:!1},fixedOverflowWidgets:!0,autoIndent:"full",useTabStops:!0,dragAndDrop:!0,matchBrackets:"always",occurrencesHighlight:!1,quickSuggestionsDelay:200,theme:t?"vs-dark":"vs",renderIndentGuides:!0,accessibilityHelpUrl:"",quickSuggestions:{other:!0,comments:!0,strings:!0},acceptSuggestionOnCommitCharacter:!0,acceptSuggestionOnEnter:"on",accessibilitySupport:"on"});return i.layout(),i}Object.defineProperty(n,"__esModule",{value:!0}),n.createEditor=n.initMonacoAsync=n.syncModels=void 0,n.syncModels=function(e,t,n,i){if(i)return;let r=monaco.languages.typescript.typescriptDefaults.getExtraLibs(),o={};e.sortedDeps().forEach(e=>{e.getFiles().forEach(i=>{let r=e.id+"/"+i;if(/\.(ts)$/.test(i)&&r!=n){if(!monaco.languages.typescript.typescriptDefaults.getExtraLibs()[r]){let n=e.readFile(i)||"\n";t[r]=monaco.languages.typescript.typescriptDefaults.addExtraLib(n,r)}o[r]="1"}})}),Object.keys(r).filter(e=>/\.(ts)$/.test(e)&&!o[e]).forEach(e=>{t[e].dispose()})},n.initMonacoAsync=function(e){return new Promise((t,n)=>{if("object"==typeof window.monaco)return void t(i(e));let r=window.MonacoPaths,o=()=>{let n=window.require;n.config({paths:r}),n(["vs/editor/editor.main"],()=>{monaco.languages.register({id:"asm",extensions:[".asm"]}),monaco.languages.setMonarchTokensProvider("asm",{tokenPostfix:"",keywords:["movs","mov","adds","add","adcs","adr","subs","sbcs","sub","rsbs","muls","cmp","cmn","ands","eors","orrs","bics","mvns","tst","lsls","lsrs","asrs","rors","ldr","ldrh","ldrb","ldrsh","ldrsb","ldm","str","strh","strb","stm","push","pop","cbz","cbnz","b","bl","bx","blx","sxth","sxtb","uxth","uxtb","rev","rev16","revsh","svc","cpsid","cpsie","setend","bkpt","nop","sev","wfe","wfi","yield","beq","bne","bcs","bhs","bcc","blo","bmi","bpl","bvs","bvc","bhi","bls","bge","blt","bgt","ble","bal","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11","r12","r13","r14","r15","pc","sp","lr"],typeKeywords:[".startaddr",".hex",".short",".space",".section",".string",".byte"],operators:[],symbols:/[:\*]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/(\.)?[a-z_$\.][\w$]*/,{cases:{"@typeKeywords":"keyword","@keywords":"keyword","@default":"identifier"}}],{include:"@whitespace"},[/[{}()\[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/@\s*[a-zA-Z_\$][\w\$]*/,{token:"annotation"}],[/(#|(0[xX]))?[0-9a-fA-F]+/,"number"],[/[;,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/'[^\\']'/,"string"],[/(')(@escapes)(')/,["string","string.escape","string"]],[/'/,"string.invalid"]],comment:[],string:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/;.*$/,"comment"]]}}),monaco.languages.typescript&&(monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSyntaxValidation:!0,noSemanticValidation:!0}),monaco.languages.typescript.typescriptDefaults.setWorkerOptions({customWorkerPath:pxt.webConfig.typeScriptWorkerJs}),monaco.languages.typescript.typescriptDefaults.setCompilerOptions({allowUnreachableCode:!0,noImplicitAny:!0,allowJs:!1,allowUnusedLabels:!0,target:monaco.languages.typescript.ScriptTarget.ES5,outDir:"built",rootDir:".",noLib:!0,mouseWheelZoom:!1})),t(i(e))})};if(window.require)o();else{let e=document.createElement("script");e.type="text/javascript",e.src=r["vs/loader"],e.addEventListener("load",o),document.body.appendChild(e)}})},n.createEditor=i},{}],180:[function(e,t,n){let i;Object.defineProperty(n,"__esModule",{value:!0}),n.removeProjectAsync=n.saveProjectAsync=void 0;const r="projects";async function o(){if(i)return i;const e=pxt.appTarget.id+"-import";return i=new pxt.BrowserUtils.IDBWrapper(e,1,(e,t)=>{t.result.createObjectStore(r,{keyPath:"importId"})}),await i.openAsync(),i}n.saveProjectAsync=async function(e){const t={importId:pxt.U.guidGen(),project:e},n=await o();return await n.deleteAllAsync(r),await n.setAsync(r,t),t.importId},n.removeProjectAsync=async function(e){const t=await o(),n=await t.getAsync(r,e);return await t.deleteAllAsync(r),null==n?void 0:n.project}},{}],181:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.freshHeader=void 0,n.freshHeader=function(e,t){return{target:pxt.appTarget.id,targetVersion:pxt.appTarget.versions.target,name:e,meta:{},editor:pxt.JAVASCRIPT_PROJECT_NAME,pubId:"",pubCurrent:!1,_rev:null,id:pxt.U.guidGen(),recentUse:t,modificationTime:t,cloudUserId:null,cloudCurrent:!1,cloudVersion:null,cloudLastSyncTime:0,isDeleted:!1}}},{}],182:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});const i=e("./runner"),r=e("./renderer"),o=e("../pxteditor");window.pxt||(window.pxt={}),window.pxt.runner=Object.assign(Object.assign({},i),r),window.pxt.editor=Object.assign({},o),function(){let e=window.ksRunnerWhenLoaded;e&&e()}()},{"../pxteditor":171,"./renderer":183,"./runner":184}],183:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.renderAsync=n.fireClickOnEnter=n.defaultClientRenderOptions=void 0;const i=e("./runner"),r=e("blockly"),o=e("../pxtblocks"),s=e("../pxtblocks/codecardRenderer");function a(){return{blocksAspectRatio:window.innerHeight<window.innerWidth?1.62:1/1.62,snippetClass:"lang-blocks",signatureClass:"lang-sig",blocksClass:"lang-block",blocksXmlClass:"lang-blocksxml",diffBlocksXmlClass:"lang-diffblocksxml",diffClass:"lang-diff",diffStaticPythonClass:"lang-diffspy",diffBlocksClass:"lang-diffblocks",staticPythonClass:"lang-spy",simulatorClass:"lang-sim",linksClass:"lang-cards",namespacesClass:"lang-namespaces",apisClass:"lang-apis",codeCardClass:"lang-codecard",packageClass:"lang-package",jresClass:"lang-jres",assetJSONClass:"lang-assetsjson",projectClass:"lang-project",snippetReplaceParent:!0,simulator:!0,showEdit:!0,hex:!0,tutorial:!1,showJavaScript:!1,hexName:pxt.appTarget.id}}function l(e){"undefined"!=typeof hljs&&(e.hasClass("highlight")?hljs.highlightBlock(e[0]):e.find("code.highlight").each(function(e,t){hljs.highlightBlock(t)}),c(e))}function c(e){e.find("span.hljs-comment:contains(@highlight)").each((e,t)=>{try{!function(e){const t=$(e),n=document.createElement("span");n.className="highlight-line";let i=e.nextSibling;if(!i||i.nodeType!=Node.TEXT_NODE)return;let r=i.textContent,o=r.indexOf("\n");if(o<0)return;i.textContent=r.substring(0,o+1),$(document.createTextNode(r.substring(o+1).replace(/^\s+/,""))).insertAfter($(i)),i=i.nextSibling;for(;i;){let e=i.nextSibling;if(i.nodeType==Node.TEXT_NODE){r=i.textContent;const t=r.indexOf("\n");if(!(t<0)){n.appendChild(document.createTextNode(r.substring(0,t))),i.textContent=r.substring(t+1);break}n.appendChild(i),i=e}else n.appendChild(i),i=e}$(n).insertAfter(t),t.remove()}(t)}catch(e){pxt.reportException(e)}})}function u(e,t){e.append($('<div class="ui content blocks"/>').append(t))}function d(e,t,n){e.append($('<div class="ui content js"><div class="subheading"><i class="ui icon xicon js"></i>JavaScript</div></div>').append(t)),l(t)}function p(e,t,n){e.append($('<div class="ui content py"><div class="subheading"><i class="ui icon xicon python"></i>Python</div></div>').append(t)),l(t)}function h(e,t){const n=$('<a class="item" role="button" tabindex="0"><i role="presentation" aria-hidden="true"></i><span class="ui desktop only"></span></a>');return n.attr("aria-label",e),n.attr("title",e),n.find("i").attr("class",t),n.find("span").text(e),n.keypress(f),n}function f(e){const t="number"==typeof e.which?e.which:e.keyCode;13!==t&&32!==t||(e.preventDefault(),e.currentTarget.click())}n.defaultClientRenderOptions=a,n.fireClickOnEnter=f;let g=!1;function m(e,t,n,i,r,o,s={}){let a=$('<div class="ui bottom attached tabular icon small compact menu hideprint"> <div class="right icon menu"></div></div>'),l=$('<div class="ui top attached segment codewidget"></div>'),c=a.find(".right.menu");const f=pxt.appTarget.appTheme||{};if(s.showEdit&&!f.hideDocsEdit&&o){const t=h(lf("Edit"),"edit icon"),{package:n,compileBlocks:s,compilePython:a}=o,l=n.host();if(r&&s?(n.setPreferredEditor(pxt.BLOCKS_PROJECT_NAME),l.writeFile(n,pxt.MAIN_BLOCKS,s.outfiles[pxt.MAIN_BLOCKS])):i&&a?(n.setPreferredEditor(pxt.PYTHON_PROJECT_NAME),l.writeFile(n,pxt.MAIN_PY,s.outfiles[pxt.MAIN_PY])):n.setPreferredEditor(pxt.JAVASCRIPT_PROJECT_NAME),e.assetJSON)for(const t of Object.keys(e.assetJSON))n.config.files.indexOf(t)<0&&n.config.files.push(t),l.writeFile(n,t,e.assetJSON[t]);const u=n.compressToFileAsync();t.click(()=>{pxt.tickEvent("docs.btn",{button:"edit"}),u.then(t=>{window.open(`${function(e){const t=e.pxtUrl||pxt.appTarget.appTheme.homeUrl;return(t||"").replace(/\/$/,"")}(e)}/#project:${ts.pxtc.encodeBase64(pxt.Util.uint8ArrayToString(t))}`,"pxt")})}),c.append(t)}if(e.showJavaScript||!r&&!i?(l.append(n),_(),b()):r?(l.append(r),y(),b()):i&&(l.append(i),_(),y()),s.run&&!f.hideDocsSimulator){let t=h(lf("Run"),"play icon").click(()=>{if(pxt.tickEvent("docs.btn",{button:"sim"}),l.find(".sim")[0])l.find(".sim").remove(),v(l);else{g||(g=!0,window.addEventListener("message",e=>{const t=e.data;if("aspectratio"!==t.type)return;const n=t.frameid,i=t.value,r=document.querySelector(`iframe[data-frameid="${n}"]`);(null==r?void 0:r.parentElement)&&(r.parentElement.style.paddingBottom=100/i+"%")}));let t="81.97%";pxt.appTarget.simulator&&(t=100/pxt.appTarget.simulator.aspectRatio+"%");const i=e.package?"&deps="+encodeURIComponent(e.package):"",r=C(e)+"#nofooter=1"+i,o=e.assetJSON?`data-assets="${encodeURIComponent(JSON.stringify(e.assetJSON))}"`:"",s=encodeURIComponent(n.text()),a=`sim-${pxt.Util.guidGen()}`;let c=$(`<div class="ui card sim"><div class="ui content"><div style="position:relative;height:0;padding-bottom:${t};overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="${r}" data-code="${s}" data-frameid="${a}" ${o} allowfullscreen="allowfullscreen" sandbox="allow-popups allow-forms allow-scripts allow-same-origin" frameborder="0"></iframe></div></div></div>`);l.append(c),v(c)}});c.append(t)}if(s.hexname&&s.hex){let e=h(lf("Download"),"download icon").click(()=>{pxt.tickEvent("docs.btn",{button:"hex"}),pxt.BrowserUtils.browserDownloadBinText(s.hex,s.hexname,{contentType:pxt.appTarget.compile.hexMimeType})});c.append(e)}let m=$("<div class=codesnippet></div>");function _(){if(!r)return;const e=h(lf("Blocks"),"icon xicon blocks").click(()=>{pxt.tickEvent("docs.btn",{button:"blocks"}),l.find(".blocks")[0]?(l.find(".blocks").remove(),v(l)):(u(n?n.parent():l,r),v(r))});c.append(e)}function y(){if(n)if(s.showJs)d(l,n);else{const e=h("JavaScript","icon xicon js").click(()=>{pxt.tickEvent("docs.btn",{button:"js"}),l.find(".js")[0]?(l.find(".js").remove(),v(l)):(d(r?r.parent():l,n),v(n))});c.append(e)}}function b(){if(i)if(s.showPy)p(l,i);else{const e=h("Python","icon xicon python").click(()=>{pxt.tickEvent("docs.btn",{button:"py"}),l.find(".py")[0]?(l.find(".py").remove(),v(l)):(p(r?r.parent():l,i),v(i))});c.append(e)}}function v(e){var t;null===(t=e[0])||void 0===t||t.scrollIntoView({behavior:"smooth",block:"center"})}c.children().length&&m.append(a),m.append(l),t.replaceWith(m)}let _,y=[];function b(e,t,n){if(!e)return Promise.resolve();let i=$("."+e).first();return i[0]?(n.emPixels||(n.emPixels=18),n.layout||(n.layout=1),n.splitSvg=!0,y.push({el:i,source:i.text(),options:n,render:t}),i.addClass("lang-shadow"),i.removeClass(e),b(e,t,n)):Promise.resolve()}function v(e){if(!e||e.kind!=ts.SyntaxKind.ExpressionStatement)return null;let t=e;if(!t.expression||t.expression.kind!=ts.SyntaxKind.CallExpression)return null;let n=t.expression;return pxtc.pxtInfo(n).callInfo}function T(e){return _||(_=(0,i.decompileSnippetAsync)("",e)),_}function k(e,t){if(!t)return;const n=/^\/(v\d+)/.exec(t.url),i=/^\/(v\d+)/.exec(window.location.pathname),r=/#doc/i.test(window.location.href);t.url&&!n&&i&&!r&&(t.url=`/${i[1]}/${t.url}`);const o=document.createElement("div");o.setAttribute("role","listitem"),o.append((0,s.renderCodeCard)(t,{hideHeader:!0,shortName:!0})),e.append(o)}function E(e,t,n){const i=t.attributes,o=!i.blockHidden&&r.Blocks[i.blockId];if(null==o?void 0:o.codeCard){const t=pxt.U.clone(o.codeCard);n&&(t.style=n),k(e,t)}else k(e,{name:t.qName,description:i.jsDoc,url:i.help||void 0,style:n})}function x(e,t,n,i){return b(t,(e,t)=>{const o=t.compileProgram;if(!o)return;const s=o.getSourceFile(pxt.MAIN_TS).statements.slice(0),a=document.createElement("div");a.setAttribute("role","list"),a.className="card-list",s.forEach(e=>{const n=e.kind,o=v(e);if(o&&t.apiInfo&&t.apiInfo.byQName[o.qName]){const e=t.apiInfo.byQName[o.qName],n=e.attributes,s=r.Blocks[n.blockId];if(i){const i=e,r=t.compileBlocks.blocksInfo.apis.byQName[i.namespace];k(a,{name:r.attributes.blockNamespace||r.name,url:r.attributes.help||"reference/"+(r.attributes.blockNamespace||r.name).toLowerCase(),description:r.attributes.jsDoc,blocksXml:s&&s.codeCard?s.codeCard.blocksXml:n.blockId?`<xml xmlns="http://www.w3.org/1999/xhtml"><block type="${n.blockId}"></block></xml>`:void 0})}else E(a,e)}else switch(n){case ts.SyntaxKind.ExpressionStatement:{const t=e;switch(t.expression.kind){case ts.SyntaxKind.TrueKeyword:case ts.SyntaxKind.FalseKeyword:k(a,{name:"Boolean",url:"blocks/logic/boolean",description:lf("True or false values"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></xml>'});break;default:pxt.debug(`card expr kind: ${t.expression.kind}`)}break}case ts.SyntaxKind.IfStatement:k(a,{name:i?"Logic":"if",url:"blocks/logic"+(i?"":"/if"),description:lf(i?"Logic operators and constants":"Conditional statement"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_if"></block></xml>'});break;case ts.SyntaxKind.WhileStatement:k(a,{name:i?"Loops":"while",url:"blocks/loops"+(i?"":"/while"),description:lf(i?"Loops and repetition":"Repeat code while a condition is true."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="device_while"></block></xml>'});break;case ts.SyntaxKind.ForOfStatement:k(a,{name:i?"Loops":"for of",url:"blocks/loops"+(i?"":"/for-of"),description:lf(i?"Loops and repetition":"Repeat code for each item in a list."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_for_of"></block></xml>'});break;case ts.SyntaxKind.BreakStatement:k(a,{name:i?"Loops":"break",url:"blocks/loops"+(i?"":"/break"),description:lf(i?"Loops and repetition":"Break out of the current loop."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="break_keyword"></block></xml>'});break;case ts.SyntaxKind.ContinueStatement:k(a,{name:i?"Loops":"continue",url:"blocks/loops"+(i?"":"/continue"),description:lf(i?"Loops and repetition":"Skip iteration and continue the current loop."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="continue_keyboard"></block></xml>'});break;case ts.SyntaxKind.ForStatement:{let t=e,n=!0;3==t.condition.getChildCount()&&(n=!("0"==t.condition.getChildAt(0).getText()||t.condition.getChildAt(1).kind==ts.SyntaxKind.LessThanToken)),k(a,n?{name:i?"Loops":"for",url:"blocks/loops"+(i?"":"/for"),description:lf(i?"Loops and repetition":"Repeat code for a given number of times using an index."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_simple_for"></block></xml>'}:{name:i?"Loops":"repeat",url:"blocks/loops"+(i?"":"/repeat"),description:lf(i?"Loops and repetition":"Repeat code for a given number of times."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_repeat_ext"></block></xml>'});break}case ts.SyntaxKind.VariableStatement:k(a,{name:i?"Variables":"variable declaration",url:"blocks/variables"+(i?"":"/assign"),description:lf(i?"Variables":"Assign a value to a named variable."),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="variables_set"></block></xml>'});break;default:pxt.debug(`card kind: ${n}`)}}),n&&(e=e.parent()),e.replaceWith(a)},{package:e.package,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}function S(e,t){if(!e)return Promise.resolve();let n=$("."+e).first();if(!n[0])return Promise.resolve();n.removeClass(e);const i=pxt.gallery.parseCodeCardsHtml(n[0]);return i||n.append($("<div/>").addClass("ui segment warning").text("invalid codecard format")),t.snippetReplaceParent&&(n=n.parent()),function(e,t,n){if(!t||0==t.length)return Promise.resolve();if(0==t.length){let i=(0,s.renderCodeCard)(t[0],n);e.replaceWith(i)}else{let i=document.createElement("div");i.className="card-list",i.setAttribute("role","list"),i.setAttribute("aria-label",n.cardCategory||lf("Content cards")),t.forEach(e=>{const t=/^\/(v\d+)/.exec(e.url),r=/^\/(v\d+)/.exec(window.location.pathname),o=/#doc/i.test(window.location.href);e.url&&!t&&r&&!o&&(e.url=`/${r[1]}${e.url}`);const a=(0,s.renderCodeCard)(e,n),l=document.createElement("div");if(l.setAttribute("role","listitem"),l.appendChild(a),i.appendChild(l),"package"==e.cardType){const t=pxt.github.parseRepoId((e.url||"").replace(/^\/pkg\//,""));t&&pxt.packagesConfigAsync().then(i=>{switch(pxt.github.repoStatus(t,i)){case pxt.github.GitRepoStatus.Banned:a.remove();break;case pxt.github.GitRepoStatus.Approved:e.imageUrl=pxt.github.mkRepoIconUrl(t),l.insertBefore((0,s.renderCodeCard)(e,n),a),a.remove()}}).catch(t=>{pxt.reportException(t),pxt.debug(`failed to load repo ${e.url}`)})}}),e.replaceWith(i)}return Promise.resolve()}(n,i,{hideHeader:!0,cardCategory:t.hexName}).then(()=>pxt.U.delay(1,S(e,t)))}function C(e){return e.pxtUrl?e.pxtUrl+"/--run":pxt.webConfig&&pxt.webConfig.runUrl?pxt.webConfig.runUrl:"/--run"}function A(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};$("code.lang-python").each((n,i)=>{!function(n,i){"undefined"!=typeof hljs&&($(n).text($(n).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(n),c($(n)));const r=pxt.U.clone(t);i&&(r.run=!1,r.showEdit=!1),m(e,$(n).parent(),$(n),void 0,void 0,void 0,r)}(i,!1),$(i).removeClass("lang-python")})}function I(e,t){t.snippetReplaceParent&&(e=e.parent()),e.remove()}function w(e,t,n){$(`code.lang-${e}\\.${t}`).each((e,t)=>{I($(t),n)})}n.renderAsync=function(e){return pxt.analytics.enable(pxt.Util.userLanguage()),e||(e=a()),e.pxtUrl&&(e.pxtUrl=e.pxtUrl.replace(/\/$/,"")),e.showEdit&&(e.showEdit=!pxt.BrowserUtils.isIFrame()),pxt.docs.hydrateYouTubeEmbeds(document.body,!1),function(e){e.packageClass&&($("."+e.packageClass).each((t,n)=>{let i=$(n),r=i.text().split("\n").map(e=>e.replace(/\s*/g,"")).filter(e=>!!e).join(",");e.package=e.package?`${e.package},${r}`:r,e.snippetReplaceParent&&(i=i.parent()),i.remove()}),$(".lang-config").each((t,n)=>{let i=$(n);e.snippetReplaceParent&&(i=i.parent()),i.remove()}))}(e),function(e){let t,n;e.jresClass&&$(`.${e.jresClass}`).each((e,t)=>{const i=$(t);n=i.text(),t.parentElement.remove()}),e.assetJSONClass&&$(`.${e.assetJSONClass}`).each((e,n)=>{const i=$(n);t=i.text(),n.parentElement.remove()}),e.assetJSON=function(e,t){if(!e&&!t)return;const n=pxt.tutorial.parseAssetJson(e)||{};if(t){const e=JSON.parse(t);n[pxt.TILEMAP_JRES]=JSON.stringify(e),n[pxt.TILEMAP_CODE]=pxt.emitTilemapsFromJRes(e)}return n}(t,n)}(e),y=[],function(e){I($("code.lang-ghost"),e)}(e),function(e){w("blockconfig","local",e),w("blockconfig","global",e)}(e),function(e){I($("code.lang-template"),e)}(e),function(e){w("validation","local",e),w("validation","global",e)}(e),function(e){e.simulatorClass&&$("."+e.simulatorClass).each((t,n)=>{var i;let r=$(n),o="81.97%";pxt.appTarget.simulator&&(o=100/pxt.appTarget.simulator.aspectRatio+"%");const s=lf("MakeCode {0} Simulator",(null===(i=pxt.appTarget.appTheme)||void 0===i?void 0:i.boardName)||pxt.appTarget.name);let a=$(`\n <div class="ui card">\n <div class="ui content">\n <div style="position:relative;height:0;padding-bottom:${o};overflow:hidden;">\n <iframe\n style="position:absolute;top:0;left:0;width:100%;height:100%;"\n allowfullscreen="allowfullscreen"\n frameborder="0"\n sandbox="allow-popups allow-forms allow-scripts allow-same-origin"\n title="${pxt.U.htmlEscape(s)}"\n ></iframe>\n </div>\n </div>\n </div>\n `);const l=e.package?"&deps="+encodeURIComponent(e.package):"",c=C(e)+"#nofooter=1"+l,u=encodeURIComponent(r.text().trim()),d=a.find("iframe");d.attr("src",c),d.attr("data-code",u),e.assetJSON&&d.attr("data-assets",JSON.stringify(e.assetJSON)),e.snippetReplaceParent&&(r=r.parent()),r.replaceWith(a)})}(e),function(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};function n(n,i){"undefined"!=typeof hljs&&($(n).text($(n).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(n),c($(n)));const r=pxt.U.clone(t);i&&(r.run=!1,r.showEdit=!1),m(e,$(n).parent(),$(n),void 0,void 0,void 0,r)}$("code.lang-typescript").each((e,t)=>{n(t,!1),$(t).removeClass("lang-typescript")}),$("code.lang-typescript-ignore").each((e,t)=>{$(t).removeClass("lang-typescript-ignore"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript")}),$("code.lang-typescript-invalid").each((e,t)=>{$(t).removeClass("lang-typescript-invalid"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript"),$(t).parent("div").addClass("invalid"),$(t).parent("div").prepend($("<i>",{class:"icon ban"})),$(t).addClass("invalid")}),$("code.lang-typescript-valid").each((e,t)=>{$(t).removeClass("lang-typescript-valid"),$(t).addClass("lang-typescript"),n(t,!0),$(t).removeClass("lang-typescript"),$(t).parent("div").addClass("valid"),$(t).parent("div").prepend($("<i>",{class:"icon check"})),$(t).addClass("valid")})}(e),A(e),Promise.resolve().then(()=>S(e.codeCardClass,e)).then(()=>async function(e){if("core"==pxt.appTarget.id)return;const t=(await T(e)).compileBlocks.blocksInfo;let n={};for(const e of t.blocks){const i=(e.attributes.blockNamespace||e.namespace).split(".")[0];if(!n[i]){const e=t.apis.byQName[i];e&&e.attributes.color&&(n[i]=e.attributes.color)}}let i="";for(const e of Object.keys(n)){const t=n[e];i+=`\n span.docs.${e.toLowerCase()} {\n --inline-namespace-color: ${t};\n }\n `}for(const e of Object.keys(pxt.toolbox.blockColors)){const t=pxt.toolbox.getNamespaceColor(e);i+=`\n span.docs.${e.toLowerCase()} {\n --inline-namespace-color: ${t};\n }\n `}let r=document.createElement("style");r.id="namespaceColors",r.type="text/css",(document.head||document.getElementsByTagName("head")[0]).appendChild(r),r.appendChild(document.createTextNode(i))}(e)).then(()=>function(e){(e=pxt.Util.clone(e)).emPixels=18,e.snippetMode=!0;const t=$(":not(pre) > code");let n=0;return function r(){if(n>=t.length)return Promise.resolve();const o=$(t[n++]),s=o.text(),a=/^(\|+)([^\|]+)\|+$/.exec(s);if(a){const e=/^(([^\:\.]*?)[\:\.])?(.*)$/.exec(a[2]),t=(e[2]?e[2].trim().toLowerCase():"").replace(/\(.*?\)/g,""),n=1==a[1].length?`docs inlinebutton ${t}`:`docs inlineblock ${t}`,i=e[3].trim();return o.replaceWith($(`<span class="${n}"/>`).text(pxt.U.rlf(i))),r()}const l=/^\[(.+)\]$/.exec(s);if(!l)return r();const c=l[1];return(0,i.decompileSnippetAsync)(c,e).then(e=>{if(e.blocksSvg){let t=$('<span class="block"/>').append(e.blocksSvg);const n=v(e.compileProgram.getSourceFile(pxt.MAIN_TS).statements[0]);if(n&&e.apiInfo){const i=e.apiInfo.byQName[n.qName];if(i&&i.attributes.help){const e=i.name||i.qName,n=lf("Documentation for {0} block",e);t=$('<a class="ui link"/>').attr("href",`/reference/${i.attributes.help}`).attr("aria-label",n).append(t)}}o.replaceWith(t)}return pxt.U.delay(1,r())})}()}(e)).then(()=>x(e,e.linksClass,e.snippetReplaceParent,!1)).then(()=>x(e,e.namespacesClass,e.snippetReplaceParent,!0)).then(()=>function(e,t){const n=e.apisClass;if(!n)return Promise.resolve();const i=$("."+n);return i.length?T(e).then(e=>{const n=e.compileBlocks.blocksInfo,o=pxt.Util.values(n.apis.byQName).filter(e=>!(e.attributes.hidden||e.attributes.deprecated||e.attributes.blockAliasFor||!e.attributes.jsDoc||!e.attributes.block||/^__/.test(e.name)));i.each((e,n)=>{let i=$(n);const s=pxt.Util.toDictionary(i.text().split("\n"),e=>e),a=o.filter(e=>!!s[e.attributes.blockNamespace||e.namespace]);if(!a.length)return;a.sort((e,t)=>{const n=!e.attributes.blockHidden&&r.Blocks[e.attributes.blockId],i=!t.attributes.blockHidden&&r.Blocks[t.attributes.blockId];return!!n!=!!i?(i?1:0)-(n?1:0):e.name.localeCompare(t.name)});const l=document.createElement("div");l.className="ui divided items",l.setAttribute("role","list"),a.forEach(e=>E(l,e,"item")),t&&(i=i.parent()),i.replaceWith(l)})}):Promise.resolve()}(e,e.snippetReplaceParent)).then(()=>function(e){return b(e.signatureClass,(t,n)=>{var i,s,a,l;let c=n.compileProgram;if(!c)return;let u=v(c.getSourceFile(pxt.MAIN_TS).statements[0]);if(!u||!n.apiInfo)return;const d=n.apiInfo.byQName[u.qName];if(!d)return;let p=r.Blocks[d.attributes.blockId],h=(null===(i=null==p?void 0:p.codeCard)||void 0===i?void 0:i.blocksXml)||void 0;const f=h?(0,o.render)(h):(null===(s=n.compileBlocks)||void 0===s?void 0:s.success)?n.blocksSvg:void 0,g=f?$(f):void 0;let _=ts.pxtc.service.displayStringForSymbol(d,!1,n.apiInfo).split("\n")[1]+";";const y=$('<code class="lang-typescript highlight"/>').text(_),b=(null===(l=null===(a=pxt.appTarget)||void 0===a?void 0:a.appTheme)||void 0===l?void 0:l.python)&&ts.pxtc.service.displayStringForSymbol(d,!0,n.apiInfo).split("\n")[1],T=b&&$('<code class="lang-python highlight"/>').text(b);if(e.snippetReplaceParent&&(t=t.parent()),pxt.Util.isTranslationMode()){const e=$('<div class="ui segment" />');e.append($('<div class="ui header"><i class="ui xicon globe"></i></div>')),d.attributes.translationId&&e.append($('<div class="ui message">').text(d.attributes.translationId)),d.attributes.jsDoc&&e.append($('<div class="ui message">').text(d.attributes.jsDoc)),e.insertAfter(t)}m(e,t,y,T,g,n,{showJs:!0,showPy:!0,hideGutter:!0})},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>function(e){if(e.tutorial)return b(e.snippetClass,(t,n)=>{const i=n.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const r=$('<div class="ui segment codewidget"/>').append(i);t.replaceWith(r)},{package:e.package,snippetMode:!1,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON});let t=0;return b(e.snippetClass,(n,i)=>{const r=i.compileBlocks&&i.compileBlocks.success?$(i.blocksSvg):void 0,o=i.compilePython&&i.compilePython.success&&i.compilePython.outfiles[pxt.MAIN_PY],s=$('<code class="lang-typescript highlight"/>').text(n.text().trim()),a=o?$('<code class="lang-python highlight"/>').text(o.trim()):void 0;e.snippetReplaceParent&&(n=n.parent());const l=i.compileJS&&i.compileJS.success,c=e.hex&&l&&i.compileJS.outfiles[pxtc.BINARY_HEX]?i.compileJS.outfiles[pxtc.BINARY_HEX]:void 0,u=`${pxt.appTarget.nickname||pxt.appTarget.id}-${e.hexName||""}-${t++}.hex`;m(e,n,s,a,r,i,{showEdit:e.showEdit,run:e.simulator,hexname:u,hex:c})},{package:e.package,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>function(e){return b(e.blocksClass,(t,n)=>{const i=n.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const r=$('<div class="ui segment codewidget"/>').append(i);t.replaceWith(r)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON})}(e)).then(()=>{return(t=e).blocksXmlClass?function e(t,n,r){let o=$("."+t).first();return o[0]?(r.emPixels||(r.emPixels=18),r.splitSvg=!0,(0,i.compileBlocksAsync)(o.text(),r).then(i=>{try{n(o,i)}catch(e){pxt.reportException(e),o.append($("<div/>").addClass("ui segment warning").text(e.message))}return o.removeClass(t),pxt.U.delay(1,e(t,n,r))})):Promise.resolve()}(t.blocksXmlClass,(e,n)=>{const i=n.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const r=$('<div class="ui segment codewidget"/>').append(i);e.replaceWith(r)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON}):Promise.resolve();var t}).then(()=>{return(t=e).diffBlocksXmlClass?function e(t,n,r){let s=$("."+t).first();if(!s[0])return Promise.resolve();r.emPixels||(r.emPixels=18),r.splitSvg=!0;const a=s.text().split(/-{10,}/),l=a[0],c=a[1];return(0,i.compileBlocksAsync)("",r).then(i=>{s.removeClass(t);try{const e=(0,o.diffXml)(l,c);e?(i.blocksSvg=e.svg,n(s,i)):s.text("no changes")}catch(e){pxt.reportException(e),s.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(t,n,r))})}(t.diffBlocksXmlClass,(e,n)=>{const i=n.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const r=$('<div class="ui segment codewidget"/>').append(i);e.replaceWith(r)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON}):Promise.resolve();var t}).then(()=>{return(t=e).diffBlocksClass?function e(n){let r=$("."+n).first();if(!r[0])return Promise.resolve();const{fileA:s,fileB:a}=pxt.diff.split(r.text(),{removeTrailingSemiColumns:!0});return pxt.U.promiseMapAllSeries([s,a],e=>(0,i.decompileSnippetAsync)(e,{generateSourceMap:!0})).then(i=>{try{const e=(0,o.decompiledDiffAsync)(s,i[0].compileBlocks,a,i[1].compileBlocks,{hideDeletedTopBlocks:!0,hideDeletedBlocks:!0}),n=pxt.diff.render(s,a,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});let l;const[c,u]=i.map(e=>e.compilePython&&e.compilePython.outfiles&&e.compilePython.outfiles[pxt.MAIN_PY]);c&&u&&(l=pxt.diff.render(c,u,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0})),m(t,r.parent(),$(n),l&&$(l),$(e.svg),void 0,{showEdit:!1,run:!1,hexname:void 0,hex:void 0})}catch(e){pxt.reportException(e),r.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(n))})}(t.diffBlocksClass):Promise.resolve();var t}).then(()=>{return(t=e).diffClass?function e(n){let i=$("."+n).first();if(!i[0])return Promise.resolve();const{fileA:r,fileB:o}=pxt.diff.split(i.text());try{const e=pxt.diff.render(r,o,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});t.snippetReplaceParent&&(i=i.parent());const s=$('<div class="ui segment codewidget"/>').append(e);i.removeClass(n),i.replaceWith(s)}catch(e){pxt.reportException(e),i.append($("<div/>").addClass("ui segment warning").text(e.message))}return pxt.U.delay(1,e(n))}(t.diffClass):Promise.resolve();var t}).then(()=>function(e){const t={showEdit:!!e.showEdit,run:!!e.simulator};return b(e.staticPythonClass,(n,i)=>{const r=i.compilePython;if(r&&r.success){const o=n.clone().removeClass("lang-shadow").addClass("highlight"),s=o.clone().addClass("lang-python").text(r.outfiles[pxt.MAIN_PY]);o.addClass("lang-typescript"),l(s),m(e,n.parent(),o,s,void 0,i,t)}},{package:e.package,snippetMode:!0,assets:e.assetJSON})}(e)).then(()=>function(e){return e.projectClass?function t(){let n=$("."+e.projectClass).first(),r=n[0];if(!r)return Promise.resolve();n.removeClass(e.projectClass);let o=pxt.Cloud.parseScriptId(r.innerText);if(o){if(e.snippetReplaceParent){r=r.parentElement;let e=document.createElement("div");r.parentElement.insertBefore(e,r),r.parentElement.removeChild(r),r=e}return(0,i.renderProjectAsync)(r,o).then(()=>t())}return t()}():Promise.resolve()}(e)).then(()=>function(){const e={};return function t(){const n=y.shift();if(!n)return Promise.resolve();const{el:r,options:o,render:s}=n;return(0,i.decompileSnippetAsync)(r.text(),o).then(t=>{const n=t.compileJS&&t.compileJS.diagnostics&&t.compileJS.diagnostics.filter(e=>e.category==pxtc.DiagnosticCategory.Error);n&&n.length&&n.forEach(e=>pxt.reportError("docs.decompile",""+e.messageText,{code:e.code+""})),t.blocksSvg.querySelectorAll("defs *").forEach(t=>{e[t.id]?t.remove():e[t.id]=!0}),s(r,t)},e=>{pxt.reportException(e),r.append($("<div/>").addClass("ui segment warning").text(e.message))}).finally(()=>(r.removeClass("lang-shadow"),t()))}().then(()=>{r.Workspace.getAll().forEach(e=>e.dispose()),(0,o.cleanRenderingWorkspace)()})}())}},{"../pxtblocks":76,"../pxtblocks/codecardRenderer":11,"./runner":184,blockly:192}],184:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.init=n.setInitCallbacks=n.compileBlocksAsync=n.decompileSnippetAsync=n.renderMarkdownAsync=n.renderProjectFilesAsync=n.renderProjectAsync=n.startDocsServer=n.startRenderServer=n.setEditorContextAsync=n.editorLanguageMode=n.LanguageMode=n.buildSimJsInfo=n.fetchSimJsInfo=n.postSimMessage=n.currentDriver=n.preloadSim=n.simulateAsync=n.generateVMFileAsync=n.generateHexFileAsync=n.showError=n.initFooter=n.initHost=n.mainPkg=void 0;const i=e("../pxtblocks"),r=e("../pxteditor/editor"),o=e("./renderer"),s=e("../pxtblocks"),a=e("blockly");pxt.blocks.requirePxtBlockly=()=>s,pxt.blocks.requireBlockly=()=>a,pxt.blocks.registerFieldEditor=(e,t,n)=>s.registerFieldEditor(e,t,n);class l{constructor(e,t){this.ksPkg=e,this.topPkg=t,this.files={}}getKsPkg(){return this.ksPkg}getPkgId(){return this.ksPkg?this.ksPkg.id:this.id}isTopLevel(){return this.ksPkg&&0==this.ksPkg.level}setFiles(e){this.files=e}getAllFiles(){return pxt.Util.mapMap(this.files,(e,t)=>t)}}class c{constructor(){this.githubPackageCache={}}readFile(e,t){let n=g(e);return pxt.U.lookup(n.files,t)}writeFile(e,t,n){g(e).files[t]=n}getHexInfoAsync(e){return pxt.hexloader.getHexInfoAsync(this,e)}cacheStoreAsync(e,t){return Promise.resolve()}cacheGetAsync(e){return Promise.resolve(null)}patchDependencies(e,t,n){if(!n)return!1;const i=pxt.github.parseRepoId(n);if(!i)return!1;for(const t of Object.keys(e.dependencies)){const r=e.dependencies[t],o=pxt.github.parseRepoId(r);if(o&&i.fullName==o.fullName)return pxt.semver.strcmp(i.tag,o.tag)<0&&(e.dependencies[t]=n),!0}return!1}downloadPackageAsync(e,t){let n,i=e.verProtocol();"github"==i&&(n=this.githubPackageCache[e._verspec]);let r=g(e);return(n?Promise.resolve(n):e.commonDownloadAsync()).then(o=>{if(o)return"github"!=i||n||(this.githubPackageCache[e._verspec]=pxt.Util.clone(o)),r.setFiles(o),Promise.resolve();if("empty"==i){if(0==Object.keys(r.files).length&&r.setFiles(m()),t&&t.length){const n=g(e).files,i=JSON.parse(n[pxt.CONFIG_NAME]);t.forEach(e=>{f(i,e)}),n[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i)}return Promise.resolve()}if("docs"==i){let t=m(),n=JSON.parse(t[pxt.CONFIG_NAME]);return e.verArgument().split(",").forEach(e=>{f(n,e)}),n.yotta||(n.yotta={}),n.yotta.ignoreConflicts=!0,t[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(n),r.setFiles(t),Promise.resolve()}return"invalid"==i?(pxt.log(`skipping invalid pkg ${e.id}`),Promise.resolve()):Promise.reject(`Cannot download ${e.version()}; unknown protocol`)})}}let u,d,p,h;function f(e,t){let n=/^([a-zA-Z0-9_-]+)(=(.+))?$/.exec(t);return n?e.dependencies[n[1]]=n[3]||"*":pxt.warn(`unknown package syntax ${t}`),!0}function g(e){let t=e._editorPkg;if(t)return t;let i=null;e!=n.mainPkg&&(i=g(n.mainPkg));let r=new l(e,i);return e==n.mainPkg&&(r.topPkg=r),e._editorPkg=r,r}function m(){let e=pxt.appTarget.tsprj,t=pxt.U.clone(e.files);return t[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(e.config),t[pxt.MAIN_BLOCKS]="",t}function _(){pxt.setAppTarget(window.pxtTargetBundle),pxt.analytics.enable(pxt.Util.userLanguage()),pxt.Util.assert(!!pxt.appTarget);const e=window.location.href;let t,n=!1;if(/[&?]translate=1/.test(e)&&!pxt.BrowserUtils.isIE())t=ts.pxtc.Util.TRANSLATION_LOCALE,n=!0,pxt.Util.enableLiveLocalizationUpdates();else{const i=/PXT_LANG=(.*?)(?:;|$)/.exec(document.cookie),r=/(live)?(force)?lang=([a-z]{2,}(-[A-Z]+)?)/i.exec(e);t=r?r[3]:i&&i[1]||pxt.appTarget.appTheme.defaultLocale||navigator.userLanguage||navigator.language;const o=pxt.appTarget.appTheme.defaultLocale,s=null==t?void 0:t.toLocaleLowerCase(),a=pxt.BrowserUtils.isLocalHostDev()&&(!s||(o?o.toLocaleLowerCase()===s:"en"===s||"en-us"===s));(pxt.BrowserUtils.isPxtElectron()||a||pxt.appTarget.appTheme.disableLiveTranslations)&&!(null==r?void 0:r[1])||pxt.Util.enableLiveLocalizationUpdates(),n=!!r&&!!r[2]}pxt.appTarget.versions;$&&$.fn&&$.fn.embed&&$.fn.embed.settings&&$.fn.embed.settings.sources&&$.fn.embed.settings.sources.youtube&&($.fn.embed.settings.sources.youtube.url="//www.youtube.com/embed/{id}?rel=0");const i=pxt.webConfig;return pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:i.commitCdnUrl,code:t,force:n}).then(()=>y())}function y(){n.mainPkg=new pxt.MainPackage(new c)}function b(e){pxt.error(e)}function v(e,t,i){const r=e?/\w+:\w+/.test(e)?e:"pub:"+e:"empty:tsprj";let o,s,a;return d&&d._verspec==r?(n.mainPkg=d,o=n.mainPkg.host(),s=Promise.resolve(),a=Promise.resolve()):(o=n.mainPkg.host(),n.mainPkg=new pxt.MainPackage(o),n.mainPkg._verspec=e?/\w+:\w+/.test(e)?e:"pub:"+e:"empty:tsprj",s=o.downloadPackageAsync(n.mainPkg,i),a=n.mainPkg.installAllAsync(),d=n.mainPkg),s.then(()=>o.readFile(n.mainPkg,pxt.CONFIG_NAME)).then(e=>e?a.then(()=>{if(t){let e=g(n.mainPkg);e.files[pxt.MAIN_TS]=t;let i=JSON.parse(e.files[pxt.CONFIG_NAME]);i.name=window.location.href.split("/").pop().split(/[?#]/)[0],e.files[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i),n.mainPkg.config.name=i.name,-1==n.mainPkg.config.files.indexOf(pxt.MAIN_BLOCKS)&&n.mainPkg.config.files.push(pxt.MAIN_BLOCKS)}}).catch(e=>{b(lf("Cannot load extension: {0}",e.message))}):Promise.resolve())}function T(e){let t=n.mainPkg.getTargetOptions();return t.isNative=!!e,t.hasHex=!!e,n.mainPkg.getCompileOptionsAsync(t)}function k(e,t){return T(e).then(e=>{t&&t(e);let n=pxtc.compile(e);return n.diagnostics&&n.diagnostics.length>0&&n.diagnostics.forEach(e=>{pxt.error(e.messageText)}),n})}function E(e,t,i){var r,o;p&&t.embedId&&h===t.embedId?p.container=e:(p=new pxsim.SimulatorDriver(e),h=t.embedId);const{fnArgs:s,parts:a,usedBuiltinParts:l}=i||{};let c=pxt.appTarget.simulator.boardDefinition,u=C(t.id),d={debug:t.debug,mute:t.mute,boardDefinition:c,parts:a,builtinParts:l,fnArgs:s,cdnUrl:pxt.webConfig.commitCdnUrl,localizedStrings:pxt.Util.getLocalizedStrings(),partDefinitions:null===n.mainPkg||void 0===n.mainPkg?void 0:n.mainPkg.computePartDefinitions(a),highContrast:t.highContrast,storedState:u,light:t.light,single:t.single,hideSimButtons:t.hideSimButtons,autofocus:t.autofocus,queryParameters:t.additionalQueryParameters,mpRole:t.mpRole,theme:null===(r=n.mainPkg.config)||void 0===r?void 0:r.theme};if(pxt.appTarget.simulator&&!t.fullScreen&&(d.aspectRatio=a.length&&pxt.appTarget.simulator.partsAspectRatio?pxt.appTarget.simulator.partsAspectRatio:pxt.appTarget.simulator.aspectRatio),window.parent&&d.aspectRatio&&d.aspectRatio!==pxt.appTarget.simulator.aspectRatio){const e=null===(o=window.frameElement)||void 0===o?void 0:o.getAttribute("data-frameid");e&&window.parent.postMessage({type:"aspectratio",frameid:e,value:d.aspectRatio},"*")}return p.setRunOptions(d),d}async function x(e){try{const t=Date.now(),n=await pxt.Cloud.downloadBuiltSimJsInfoAsync(e.id);return pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-t,operation:"fetchSimJsInfo"}),n}catch(e){return void pxt.debug(e.toString())}}async function S(e){var t,i,r;const o=Date.now();await v(e.id,e.code,e.dependencies);let s=!1;const a=pxt.appTarget.versions.target;let l=await k(!1,t=>{var i;if(t.computeUsedParts=!0,t.computeUsedSymbols=!0,e.debug&&(t.breakpoints=!0),e.assets){const n=JSON.parse(e.assets);for(const e of Object.keys(n)){const i=n[e];if(t.fileSystem[e]=i,t.sourceFiles.indexOf(e)<0&&t.sourceFiles.push(e),/\.jres$/.test(e)){const e=JSON.parse(i);t.jres=pxt.inflateJRes(e,t.jres)}}}if(e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code),t.target.preferredEditor===pxt.PYTHON_PROJECT_NAME){t.target.preferredEditor=pxt.JAVASCRIPT_PROJECT_NAME,t.ast=!0;const e=F(pxtc.compile(t).ast,t);t.apisInfo=e,t.target.preferredEditor=pxt.PYTHON_PROJECT_NAME}const r=null===(i=n.mainPkg.config.targetVersions)||void 0===i?void 0:i.target;if(r&&a&&pxt.semver.cmp(pxt.semver.parse(r),pxt.semver.parse(a))<0)for(const e of Object.keys(t.fileSystem))!pxt.Util.startsWith(e,"pxt_modules")&&pxt.Util.endsWith(e,".ts")&&(s=!0,t.fileSystem[e]=pxt.patching.patchJavaScript(r,t.fileSystem[e]))});(null===(t=l.diagnostics)||void 0===t?void 0:t.length)>0&&s&&(pxt.log("Compile with upgrade rules failed, trying again with original code"),l=await k(!1,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})),l.diagnostics&&l.diagnostics.length>0&&pxt.error("Diagnostics",l.diagnostics);const c=pxtc.buildSimJsInfo(l),u=(null===(r=null===(i=pxt.appTarget.simulator)||void 0===i?void 0:i.boardDefinition)||void 0===r?void 0:r.onboardComponents)||[];return c.allParts=l.usedParts||[],c.usedBuiltinParts=l.usedParts.filter(e=>-1!==u.indexOf(e)),c.parts=l.usedParts.filter(e=>-1===u.indexOf(e)),pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-o,operation:"buildSimJsInfo"}),c}function C(e){let t={};try{let n=window.localStorage.getItem(e);n&&(t=JSON.parse(n))}catch(e){}return t}var A;function I(e,t){if(n.editorLanguageMode=e,t!=pxt.Util.localeInfo()){const e=/^live-/;return e.test(t)&&pxt.Util.enableLiveLocalizationUpdates(),pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:pxt.webConfig.commitCdnUrl,code:t.replace(e,"")})}return Promise.resolve()}function w(e){let t=e.data;if(t)switch(t.type){case"fileloaded":let e=t,n=e.name,i=A.Blocks;/\.ts$/i.test(n)?i=A.TypeScript:/\.py$/i.test(n)&&(i=A.Python),I(i,e.locale);break;case"popout":let r=/((\/v[0-9+])\/)?[^\/]*#(doc|md):([^&?:]+)/i.exec(window.location.href);if(r){const e=pxt.webConfig.docsUrl||"/--docs";let t=r[2]||"",n="doc"==r[3]?pxt.webConfig.isStatic?`/docs${r[4]}.html`:`${r[4]}`:`${e}?md=${r[4]}`;window.parent&&window.parent.postMessage({type:"opendoc",url:pxt.BrowserUtils.urlJoin(t,n)},"*")}break;case"localtoken":let o=t;o&&o.localToken&&(pxt.Cloud.localToken=o.localToken,U.forEach(e=>e()),U=[])}}function N(e,t){return pxt.Cloud.privateGetTextAsync(t+"/text").then(e=>JSON.parse(e)).then(n=>D(e,n,t))}function D(e,t,i=null,r=!1){const o=JSON.parse(t[pxt.CONFIG_NAME])||{};let s=`# ${o.name} ${o.version?o.version:""}\n\n`;const a="README.md";t[a]&&(s+=t[a].replace(/^#+/,"$0#")+"\n"),o.files.filter(e=>e!=pxt.CONFIG_NAME&&e!=a).filter(e=>function(e,t){switch(t){case A.Blocks:return/\.blocks?$/.test(e);case A.TypeScript:return/\.ts?$/.test(e);case A.Python:return/\.py?$/.test(e)}}(e,n.editorLanguageMode)).forEach(e=>{/^main\.(ts|blocks)$/.test(e)||(s+=`\n## ${e}\n`),/\.ts$/.test(e)?s+=`\`\`\`typescript\n${t[e]}\n\`\`\`\n`:/\.blocks?$/.test(e)?s+=`\`\`\`blocksxml\n${t[e]}\n\`\`\`\n`:s+=`\`\`\`${e.substr(e.indexOf("."))}\n${t[e]}\n\`\`\`\n`});const l=o&&o.dependencies&&Object.keys(o.dependencies).filter(e=>e!=pxt.appTarget.corepkg);if(l&&l.length&&(s+=`\n## ${lf("Extensions")} #extensions\n\n${l.map(e=>`* ${e}, ${o.dependencies[e]}`).join("\n")}\n\n\`\`\`package\n${l.map(e=>`${e}=${o.dependencies[e]}`).join("\n")}\n\`\`\`\n`),i){let e=(pxt.appTarget.appTheme.shareUrl||"https://makecode.com/")+i;r&&(e="`"+e+"`"),s+=`\n${e}\n\n`}pxt.debug(`print md: ${s}`);return R(e,s,{print:!0})}pxt.react.getTilemapProject||(pxt.react.getTilemapProject=()=>(u||(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg)),u)),n.initHost=y,n.initFooter=function(e,t){if(!e)return;let n=pxt.appTarget.appTheme,i=$("body"),r=$(e),o=$("<a/>").attr("href",n.homeUrl).attr("target","_blank");r.append(o),n.organizationLogo?o.append($("<img/>").attr("src",pxt.Util.toDataUri(n.organizationLogo))):o.append(lf("powered by {0}",n.title)),i.mouseenter(e=>r.fadeOut()),i.mouseleave(e=>r.fadeIn())},n.showError=b,n.generateHexFileAsync=function(e){return v(e.id).then(()=>k(!0,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})).then(e=>(e.diagnostics&&e.diagnostics.length>0&&pxt.error("Diagnostics",e.diagnostics),e.outfiles[pxtc.BINARY_HEX]))},n.generateVMFileAsync=function(e){return pxt.setHwVariant("vm"),v(e.id).then(()=>k(!0,t=>{e.code&&(t.fileSystem[pxt.MAIN_TS]=e.code)})).then(e=>(pxt.log(e),e))},n.simulateAsync=async function(e,t){var n,i;const r=t.builtJsInfo||await x(t)||await S(t),{js:o}=r;if(!o)return void pxt.error("Program failed to compile");const s=E(e,t,r);return p.options.messageSimulators=null===(i=null===(n=pxt.appTarget)||void 0===n?void 0:n.simulator)||void 0===i?void 0:i.messageSimulators,p.options.onSimulatorCommand=e=>{"restart"===e.command?(s.storedState=C(t.id),p.run(o,s)):"setstate"===e.command?e.stateKey&&function(e,t,n){let i=C(e);if(!e)return;null!=n?i[t]=n:delete i[t];try{window.localStorage.setItem(e,JSON.stringify(i))}catch(e){}}(t.id,e.stateKey,e.stateValue):"single"===e.command&&p.setSingleSimulator()},r.breakpoints&&t.debug&&p.setBreakpoints(r.breakpoints),p.run(o,s),r},n.preloadSim=function(e,t){var n,i;E(e,t),p.preload((null===(i=null===(n=pxt.appTarget)||void 0===n?void 0:n.simulator)||void 0===i?void 0:i.aspectRatio)||1,!0)},n.currentDriver=function(){return p},n.postSimMessage=function(e){null==p||p.postMessage(e)},n.fetchSimJsInfo=x,n.buildSimJsInfo=S,function(e){e[e.Blocks=0]="Blocks",e[e.TypeScript=1]="TypeScript",e[e.Python=2]="Python"}(A=n.LanguageMode||(n.LanguageMode={})),n.editorLanguageMode=A.Blocks,n.setEditorContextAsync=I,n.startRenderServer=function(){pxt.tickEvent("renderer.ready");const e=[];let t;function n(){if(t)return;const r=e.shift();if(!r)return;const o=r.options||{};o.splitSvg=!1,pxt.tickEvent("renderer.job");const s=/^\s*<xml/.test(r.code);t=(async()=>{const e=(s?await B(r.code,o):await M(r.code,r.options)).blocksSvg;if(!e)throw new Error("Failed to generate blocks SVG");const t=e.viewBox.baseVal.width,n=e.viewBox.baseVal.height;let a,l;try{a=await(0,i.blocklyToSvgAsync)(e,0,0,t,n)}catch(e){throw pxt.reportException(e),e}try{l=a?await pxt.BrowserUtils.encodeToPngAsync(a.xml,{width:t,height:n}):void 0}catch(e){pxt.warn(e)}window.parent.postMessage({source:"makecode",type:"renderblocks",id:r.id,width:null==a?void 0:a.width,height:null==a?void 0:a.height,svg:null==a?void 0:a.svg,uri:l||(null==a?void 0:a.xml),css:null==a?void 0:a.css},"*")})().catch(e=>{window.parent.postMessage({source:"makecode",type:"renderblocks",id:r.id,error:e.message},"*")}).finally(()=>{t=void 0,n()})}(0,r.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",function(t){const i=t.data;"renderblocks"==i.type&&(e.push(i),n())},!1),window.parent.postMessage({source:"makecode",type:"renderready",versions:pxt.appTarget.versions},"*")})},n.startDocsServer=function(e,t,n){pxt.tickEvent("docrenderer.ready");const i=[];function s(i,r){pxt.debug(`rendering ${i}`),n&&$(n).hide(),$(t).hide(),$(e).show(),pxt.U.delay(100).then(()=>{switch(i){case"print":const e=window.localStorage.printjob;return delete window.localStorage.printjob,D(t,JSON.parse(e),void 0,!0).then(()=>pxsim.print(1e3));case"project":return D(t,JSON.parse(r)).then(()=>pxsim.print(1e3));case"projectid":return N(t,JSON.parse(r)).then(()=>pxsim.print(1e3));case"doc":return async function(e,t){t=t.replace(/^\//,"");const n=await pxt.Cloud.markdownAsync(t,void 0,!0);try{await R(e,n,{path:t})}catch(e){pxt.warn(e)}}(t,r);case"book":return function(e,t){t=t.replace(/^\//,""),pxt.tickEvent("book",{id:t}),pxt.log(`rendering book from ${t}`);let n;return $("#loading").find(".loader").addClass("text").text(lf("Compiling your book (this may take a minute)")),pxt.U.delay(100).then(()=>pxt.Cloud.markdownAsync(t,void 0,!0)).then(e=>{n=pxt.docs.buildTOC(e),pxt.log(`TOC: ${JSON.stringify(n,null,2)}`);const t=[];return pxt.docs.visitTOC(n,e=>{/^\//.test(e.path)&&!/^\/pkg\//.test(e.path)&&t.push(e)}),pxt.U.promisePoolAsync(4,t,async e=>{try{const t=await pxt.Cloud.markdownAsync(e.path,void 0,!0);e.markdown=t}catch(t){e.markdown=`_${e.path} failed to load._`}})}).then(t=>{let i=n[0].name;return pxt.docs.visitTOC(n,e=>{e.markdown&&(i+="\n\n"+e.markdown)}),R(e,i)})}(t,r);default:return R(t,r)}}).catch(e=>{$(t).html(`\n <img style="height:4em;" src="${pxt.appTarget.appTheme.docsLogo}" />\n <h1>${lf("Oops")}</h1>\n <h3>${lf("We could not load the documentation, please check your internet connection.")}</h3>\n <button class="ui button primary" id="tryagain">${lf("Try Again")}</button>`),$(t).find("#tryagain").click(()=>{s(i,r)}),window.parent&&window.parent.postMessage({type:"docfailed",docType:i,src:r},"*")}).finally(()=>{$(e).hide(),n&&$(n).show(),$(t).show()}).then(()=>{})}function a(e,t){t?(pxsim.U.addClass(e,"disabled"),e.setAttribute("aria-disabled","true")):(pxsim.U.removeClass(e,"disabled"),e.setAttribute("aria-disabled","false"))}async function l(){let e=/^#(doc|md|tutorial|book|project|projectid|print):([^&?:]+)(:([^&?:]+):([^&?:]+))?/i.exec(window.location.hash);if(e){if(n&&(i.push(window.location.hash),i.length>10&&i.shift(),i.length>1&&a(n,!1)),e[4]){let t=A.TypeScript;/^blocks$/i.test(e[4])?t=A.Blocks:/^python$/i.test(e[4])&&(t=A.Python),await I(t,e[5])}s(e[1],decodeURIComponent(e[2]))}}n&&(n.addEventListener("click",()=>{!function(){if(!n)return;i.length>1&&(i.pop(),window.location.hash=i.pop());i.length<=1&&a(n,!0)}()}),n.addEventListener("keydown",o.fireClickOnEnter),a(n,!0)),(0,r.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",w,!1),window.addEventListener("hashchange",()=>{l()},!1),parent.postMessage({type:"sidedocready"},"*"),setTimeout(()=>l(),1)})},n.renderProjectAsync=N,n.renderProjectFilesAsync=D;const O='\n<aside id=button class=box>\n<a class="ui primary button" href="@ARGS@">@BODY@</a>\n</aside>\n\n<aside id=vimeo>\n<div class="ui two column stackable grid container">\n<div class="column">\n<div class="ui embed mdvid" data-source="vimeo" data-id="@ARGS@" data-placeholder="/thumbnail/1024/vimeo/@ARGS@" data-icon="video play">\n</div>\n</div></div>\n</aside>\n\n<aside id=youtube>\n<div class="ui two column stackable grid container">\n<div class="column">\n<div class="ui embed mdvid" data-source="youtube" data-id="@ARGS@" data-placeholder="https://img.youtube.com/vi/@ARGS@/0.jpg">\n</div>\n</div></div>\n</aside>\n\n<aside id=section>\n\x3c!-- section @ARGS@ --\x3e\n</aside>\n\n<aside id=hide class=box>\n<div style=\'display:none\'>\n @BODY@\n</div>\n</aside>\n\n<aside id=avatar class=box>\n<div class=\'avatar @ARGS@\'>\n <div class=\'avatar-image\'></div>\n <div class=\'ui compact message\'>\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=hint class=box>\n<div class="ui info message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=codecard class=box>\n<pre><code class="lang-codecard">@BODY@</code></pre>\n</aside>\n\n<aside id=tutorialhint class=box>\n<div class="ui hint message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=reminder class=box>\n<div class="ui warning message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=alert class=box>\n<div class="ui negative message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n<aside id=tip class=box>\n<div class="ui positive message">\n <div class="content">\n @BODY@\n </div>\n</div>\n</aside>\n\n\x3c!-- wrapped around ordinary content --\x3e\n<aside id=main-container class=box>\n<div class="ui text">\n @BODY@\n</div>\n</aside>\n\n\x3c!-- used for \'column\' box - they are collected and wrapped in \'column-container\' --\x3e\n<aside id=column class=aside>\n<div class=\'column\'>\n @BODY@\n</div>\n</aside>\n<aside id=column-container class=box>\n<div class="ui three column stackable grid text">\n @BODY@\n</div>\n</aside>\n@breadcrumb@\n@body@';function R(e,t,i={}){const r=pxt.docs.renderMarkdown({template:O,markdown:t,theme:pxt.appTarget.appTheme});let s=i.blocksAspectRatio||window.innerHeight<window.innerWidth?1.62:1/1.62;$(e).html(r),$(e).find("a").attr("target","_blank");const a=(0,o.defaultClientRenderOptions)();return a.tutorial=!!i.tutorial,a.blocksAspectRatio=s||a.blocksAspectRatio,a.showJavaScript=n.editorLanguageMode==A.TypeScript,i.print&&(a.showEdit=!1,a.simulator=!1),(0,o.renderAsync)(a).then(()=>{$(e).find('a[href^="/"]').removeAttr("target").each((e,t)=>{$(t).attr("href","#doc:"+$(t).attr("href").replace(/^\//,""))}),$(e).find(".ui.embed").embed()})}let L,P;function M(e,t){const{assets:r,forceCompilation:o,snippetMode:s,generateSourceMap:a}=t||{};return v(t&&t.packageId?"pub:"+t.packageId:t&&t.package?"docs:"+t.package:null,e).then(()=>T(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(l=>{if(e&&(l.fileSystem[pxt.MAIN_TS]=e),l.ast=!0,r)for(const e of Object.keys(r))l.sourceFiles.indexOf(e)<0&&l.sourceFiles.push(e),l.fileSystem[e]=r[e];let c,d,p;o?(c=pxtc.compile(l),d=c&&c.ast):d=pxtc.getTSProgram(l,L),L=d,pxt.appTarget.appTheme.python&&(p=ts.pxtc.transpile.tsToPy(d,pxt.MAIN_TS));let h=F(d,l);return ts.pxtc.localizeApisAsync(h,n.mainPkg).then(()=>{let e=pxtc.getBlocksInfo(h);(0,i.initializeAndInject)(e);const o=null==r?void 0:r[pxt.TILEMAP_JRES],l=null==r?void 0:r[pxt.IMAGES_JRES];(o||l)&&(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg),o&&u.loadTilemapJRes(JSON.parse(o),!0),l&&u.loadAssetsJRes(JSON.parse(l)));let f=pxtc.decompiler.decompileToBlocks(e,d.getSourceFile(pxt.MAIN_TS),{snippetMode:s,generateSourceMap:a});if(f.diagnostics&&f.diagnostics.length>0&&f.diagnostics.forEach(e=>pxt.error(e.messageText)),!f.success)return{package:n.mainPkg,compileProgram:d,compileJS:c,compileBlocks:f,apiInfo:h};pxt.debug(f.outfiles[pxt.MAIN_BLOCKS]);const g=(0,i.render)(f.outfiles[pxt.MAIN_BLOCKS],t);return(o||l)&&(u=null),{package:n.mainPkg,compileProgram:d,compileJS:c,compileBlocks:f,compilePython:p,apiInfo:h,blocksSvg:g}})})}function F(e,t){P||(P={});const n=Object.keys(t.fileSystem).sort().join(";");return P[n]||(P[n]=pxtc.getApiInfo(e,t.jres)),P[n]}function B(e,t){const{assets:r}=t||{};return v(t&&t.packageId?"pub:"+t.packageId:t&&t.package?"docs:"+t.package:null,"").then(()=>T(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(o=>{if(o.ast=!0,r)for(const e of Object.keys(r))o.sourceFiles.indexOf(e)<0&&o.sourceFiles.push(e),o.fileSystem[e]=r[e];const s=F(pxtc.compile(o).ast,o);return ts.pxtc.localizeApisAsync(s,n.mainPkg).then(()=>{const o=pxtc.getBlocksInfo(s);(0,i.initializeAndInject)(o);const a=null==r?void 0:r[pxt.TILEMAP_JRES],l=null==r?void 0:r[pxt.IMAGES_JRES];(a||l)&&(u=new pxt.TilemapProject,u.loadPackage(n.mainPkg),a&&u.loadTilemapJRes(JSON.parse(a),!0),l&&u.loadAssetsJRes(JSON.parse(l)));const c=(0,i.render)(e,t);return(a||l)&&(u=null),{package:n.mainPkg,blocksSvg:c,apiInfo:s}})})}n.renderMarkdownAsync=R,n.decompileSnippetAsync=M,n.compileBlocksAsync=B;let U=[];let H=[];n.setInitCallbacks=function(e){H=e},n.init=function(){_().then(()=>{for(let e=0;e<H.length;++e)H[e]()})}},{"../pxtblocks":76,"../pxteditor/editor":167,"./renderer":183,blockly:192}],185:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.IFrameEmbeddedClient=void 0;n.IFrameEmbeddedClient=class{constructor(e){this.messageHandler=e,this.onMessageReceived=e=>{const t=e.data;if(t){if("iframeclientsetmessageport"===t.type)return this.port=e.ports[0],this.port.onmessage=this.onMessageReceived,void this.postMessage({type:"iframeclientsetmessageport"});if("iframeclientready"===t.type)return void this.sendReadyMessage()}this.messageHandler(e)},this.frameId=function(){const e=/frameid=([a-zA-Z0-9\-]+)/i.exec(window.location.href);if(e)return e[1];return}(),window.addEventListener("message",this.onMessageReceived),this.sendReadyMessage()}dispose(){window.removeEventListener("message",this.onMessageReceived),this.port&&this.port.close()}postMessage(e){this.postMessageCore(e)}postMessageCore(e){this.frameId&&(e.frameId=this.frameId),this.port?this.port.postMessage(e):window.acquireVsCodeApi?window.acquireVsCodeApi().postMessage(e):window.parent&&window.parent!==window&&window.parent.postMessage(e,"*")}sendReadyMessage(){this.postMessage({type:"iframeclientready"})}}},{}],186:[function(e,t,n){
|
|
22
22
|
/*! For license information please see index.js.LICENSE.txt */
|
|
23
23
|
!function(i,r){if("object"==typeof n&&"object"==typeof t)t.exports=r(e("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],r);else{var o=r("object"==typeof n?e("blockly/core"):i.Blockly);for(var s in o)("object"==typeof n?n:i)[s]=o[s]}}(this,e=>(()=>{var t={370:t=>{t.exports=e}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.r(r),i.d(r,{FieldGridDropdown:()=>l});var o=i(370);class s{constructor(e,t,n,i){this.value=n,this.selected=!1,this.selectionCallback=i,this.element=document.createElement("button"),this.element.id=o.utils.idGenerator.getNextUniqueId(),this.element.className="blocklyFieldGridItem",this.clickHandler=o.browserEvents.conditionalBind(this.element,"click",this,this.onClick,!0),e.appendChild(this.element);const r="string"==typeof t?document.createTextNode(t):t;this.element.appendChild(r),o.utils.aria.setRole(this.element,o.utils.aria.Role.GRIDCELL)}dispose(){this.selectionCallback=null,this.element.remove(),this.clickHandler&&(o.browserEvents.unbind(this.clickHandler),this.clickHandler=null)}getId(){return this.element.id}getValue(){return this.value}isSelected(){return this.selected}setSelected(e){this.selected=e,o.utils.aria.setState(this.element,o.utils.aria.State.SELECTED,this.selected),this.element.classList.toggle("blocklyFieldGridItemSelected",this.selected),this.isSelected()&&this.focus()}onClick(){var e;this.setSelected(!0),null===(e=this.selectionCallback)||void 0===e||e.call(this,this)}focus(){this.element.focus({preventScroll:!0});const e=this.element.offsetParent;if(!e)return;const t=this.element.offsetTop,n=e.scrollTop,i=this.getInterItemSpacing();t<n?e.scrollTo(0,t-i):t+this.element.offsetHeight>n+e.clientHeight&&e.scrollBy(0,t+this.element.clientHeight-(n+e.clientHeight)+i)}getInterItemSpacing(){const e=this.element.closest(".blocklyFieldGrid");if(!e)return 0;const t=[...e.querySelectorAll(".blocklyFieldGridItem")];if(!t.length)return 0;const n=t[0].offsetTop,i=t[0].offsetHeight;for(const e of t)if(e.offsetTop!==n)return e.offsetTop-i-n;return 0}}class a{constructor(e,t,n,i,r){if(this.columns=n,this.rtl=i,this.itemIndices=new Map,this.items=new Array,this.keyDownHandler=null,this.pointerMoveHandler=null,this.selectionCallback=r,this.root=document.createElement("div"),this.root.className="blocklyFieldGrid",this.root.tabIndex=0,o.utils.aria.setRole(this.root,o.utils.aria.Role.GRID),e.appendChild(this.root),this.populateItems(t),this.keyDownHandler=o.browserEvents.conditionalBind(this.root,"keydown",this,this.onKeyDown),this.pointerMoveHandler=o.browserEvents.conditionalBind(this.root,"pointermove",this,this.onPointerMove,!0),!(n>=1))throw new Error(`Number of columns must be >= 1; got ${n}`);this.columns=n,this.root.style.setProperty("--grid-columns",`${this.columns}`)}populateItems(e){let t=document.createElement("div");for(const[n,i]of e.entries()){if(i===o.FieldDropdown.SEPARATOR)continue;n%this.columns===0&&(t=document.createElement("div"),t.className="blocklyFieldGridRow",o.utils.aria.setRole(t,o.utils.aria.Role.ROW),this.root.appendChild(t));const[e,r]=i,a=(()=>{if((t=e)&&"object"==typeof t&&"src"in t&&"string"==typeof t.src&&"alt"in t&&"string"==typeof t.alt&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height){const t=new Image(e.width,e.height);return t.src=e.src,t.alt=e.alt||"",t}var t;return e})(),l=new s(t,a,r,e=>{var t;this.setSelectedValue(e.getValue()),null===(t=this.selectionCallback)||void 0===t||t.call(this,e)});this.itemIndices.set(l.getId(),this.itemIndices.size),this.items.push(l)}}dispose(){this.selectionCallback=void 0;for(const e of this.items)e.dispose();this.itemIndices.clear(),this.items.length=0,this.keyDownHandler&&(o.browserEvents.unbind(this.keyDownHandler),this.keyDownHandler=null),this.pointerMoveHandler&&(o.browserEvents.unbind(this.pointerMoveHandler),this.pointerMoveHandler=null),this.root.remove()}onKeyDown(e){if(!(!this.items.length||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){switch(e.key){case"ArrowUp":this.moveFocus(-1*this.columns,!0);break;case"ArrowDown":this.moveFocus(this.columns,!0);break;case"ArrowLeft":this.moveFocus(-1*(this.rtl?-1:1),!0);break;case"ArrowRight":this.moveFocus(1*(this.rtl?-1:1),!0);break;case"PageUp":case"Home":this.moveFocus(0,!1);break;case"PageDown":case"End":this.moveFocus(this.items.length-1,!1);break;case"Enter":case"Space":return void e.stopPropagation();default:return}e.preventDefault(),e.stopPropagation()}}onPointerMove(e){if(!e.movementX&&!e.movementY||!(e.target instanceof Element))return;const t=e.target.closest(".blocklyFieldGridItem");if(!t)return;const n=t.id,i=this.itemIndices.get(n);void 0!==i&&this.moveFocus(i,!1)}setSelectedValue(e){for(const[t,n]of this.items.entries()){const i=n.getValue()===e;n.setSelected(i),i&&this.moveFocus(t,!1)}}moveFocus(e,t){let n=e;if(t){const e=this.getFocusedItem();if(!e)return;n+=this.indexOfItem(e)}const i=this.itemAtIndex(n);i&&(i.focus(),o.utils.aria.setState(this.root,o.utils.aria.State.ACTIVEDESCENDANT,i.getId()))}indexOfItem(e){var t;return null!==(t=this.itemIndices.get(e.getId()))&&void 0!==t?t:-1}itemAtIndex(e){return this.items[e]}getFocusedItem(){var e;const t=null!==(e=this.root.querySelector(".blocklyFieldGridItem:focus"))&&void 0!==e?e:this.root.querySelector(".blocklyFieldGridItem");if(!t||!t.id)return;const n=this.itemIndices.get(t.id);return void 0!==n?this.itemAtIndex(n):void 0}}class l extends o.FieldDropdown{constructor(e,t,n){super(e,t,n),this.columns=3,(null==n?void 0:n.columns)&&this.setColumns(parseInt(`${n.columns}`)),n&&n.primaryColour&&(this.primaryColour=n.primaryColour),n&&n.borderColour&&(this.borderColour=n.borderColour)}static fromJson(e){if(!e.options)throw new Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples.");return new this(e.options,void 0,e)}setColumns(e){var t;!isNaN(e)&&e>=1&&(this.columns=e,o.DropDownDiv.getOwner()===this&&o.DropDownDiv.isVisible()&&(null===(t=this.grid)||void 0===t||t.dispose(),this.showEditor_()))}showEditor_(e){var t;o.DropDownDiv.clearContent();const n=!!(null===(t=this.getSourceBlock())||void 0===t?void 0:t.workspace.RTL);this.grid=new a(o.DropDownDiv.getContentDiv(),this.getOptions(!1),this.columns,n,e=>{o.DropDownDiv.hideIfOwner(this),this.setValue(e.getValue())}),o.DropDownDiv.getContentDiv().classList.add("blocklyFieldGridContainer");const i=this.getColours();i&&i.border&&o.DropDownDiv.setColour(i.primary,i.border),o.DropDownDiv.showPositionedByField(this,this.dropdownDispose_.bind(this));const r=this.getValue();r&&this.grid.setSelectedValue(r)}doValueUpdate_(e){var t;super.doValueUpdate_(e),null===(t=this.grid)||void 0===t||t.setSelectedValue(e)}getColours(){var e,t;if(this.primaryColour&&this.borderColour)return{primary:this.primaryColour,border:this.borderColour};const n=this.getSourceBlock();if(!(n instanceof o.BlockSvg))return;const i=n.isShadow()?n.getParent():n;return i?{primary:null!==(e=this.primaryColour)&&void 0!==e?e:i.getColour(),border:null!==(t=this.borderColour)&&void 0!==t?t:i.getColourTertiary()}:void 0}}return o.fieldRegistry.register("field_grid_dropdown",l),o.Css.register("\n .blocklyFieldGridContainer {\n padding: 7px;\n overflow: auto;\n }\n \n .blocklyFieldGrid {\n display: grid;\n grid-gap: 7px;\n grid-template-columns: repeat(var(--grid-columns), min-content);\n }\n\n .blocklyFieldGrid .blocklyFieldGridItem {\n border: 1px solid rgba(1, 1, 1, 0.5);\n border-radius: 4px;\n color: white;\n min-width: auto;\n background: none;\n white-space: nowrap;\n cursor: pointer;\n padding: 6px 15px;\n }\n \n .blocklyFieldGrid .blocklyFieldGridRow {\n display: contents;\n }\n \n .blocklyFieldGrid .blocklyFieldGridItem.blocklyFieldGridItemSelected {\n background-color: rgba(1, 1, 1, 0.25);\n }\n\n .blocklyFieldGrid .blocklyFieldGridItem:focus {\n box-shadow: 0 0 0 4px hsla(0, 0%, 100%, .2);\n outline: none;\n }\n "),r})())},{"blockly/core":191}],187:[function(e,t,n){
|
|
24
24
|
/*! For license information please see index.js.LICENSE.txt */
|