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/runnerembed.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2024 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*/Object.defineProperty(i,"__esModule",{value:!0}),i.setDuplicateOnDragStrategy=i.DuplicateOnDragStrategy=void 0;const o=t("blockly"),s=t("./duplicateOnDrag");class n extends o.dragging.BlockDragStrategy{getTargetBlock(){const t=this;return t.block.isShadow()&&(0,s.isAllowlistedShadow)(t.block)?t.block:super.getTargetBlock()}drag(t,e){if(super.drag(t,e),!e||e instanceof PointerEvent){this.block.moveDuringDrag(t)}}disconnectBlock(t){var e;const i=this;let n,r,a;const l=i.block.isShadow();if(l&&i.block.setShadow(!1),(0,s.shouldDuplicateOnDrag)(i.block)){const t=i.block.outputConnection;if(!(null==t?void 0:t.targetConnection))return;a=o.Xml.blockToDom(i.block,!0),l||(n=o.Xml.domToBlock(a,i.block.workspace)),r=t.targetConnection}t&&(i.startChildConn=null===(e=i.block.nextConnection)||void 0===e?void 0:e.targetConnection),r&&l&&r.setShadowDom(a),i.block.unplug(t),o.blockAnimations.disconnectUiEffect(i.block),(0,s.updateDuplicateOnDragState)(i.block),r&&n&&r.connect(n.outputConnection)}}i.DuplicateOnDragStrategy=n,i.setDuplicateOnDragStrategy=function(t){var e,i;null===(i=(e=t).setDragStrategy)||void 0===i||i.call(e,new n(t))}},{"./duplicateOnDrag":106,blockly:192}],106:[function(t,e,i){"use strict";let o,s;function n(t){return!(!o||-1===o.indexOf(t.type))}function r(t){var e,i;if(t.isShadow()&&n(t))return!0;if(s){const o=null===(e=t.outputConnection)||void 0===e?void 0:e.targetBlock();if(o){const e=s.filter(t=>t.parentBlockType===o.type);for(const o of e)if(o&&(!o.childBlockType||o.childBlockType===t.type)){if(!o.inputName)return!0;if((null===(i=t.outputConnection.targetConnection.getParentInput())||void 0===i?void 0:i.name)===o.inputName)return!0}}}return!1}Object.defineProperty(i,"__esModule",{value:!0}),i.updateDuplicateOnDragState=i.shouldDuplicateOnDrag=i.isAllowlistedShadow=i.setDuplicateOnDrag=i.setDraggableShadowBlocks=void 0,i.setDraggableShadowBlocks=function(t){o=t},i.setDuplicateOnDrag=function(t,e,i){s||(s=[]),s.some(o=>o.parentBlockType===t&&o.inputName===e&&o.childBlockType===i)||s.push({parentBlockType:t,inputName:e,childBlockType:i})},i.isAllowlistedShadow=n,i.shouldDuplicateOnDrag=r,i.updateDuplicateOnDragState=function(t){setTimeout(()=>{const e=r(t);t.pathObject&&t.pathObject.setHasDottedOutlineOnHover(e),t.setDeletable(!e)})}},{}],107:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./duplicateOnDrag"),i),s(t("./variablesGetReporter"),i),s(t("./connectionChecker"),i),s(t("./dragStrategy"),i)},{"./connectionChecker":104,"./dragStrategy":105,"./duplicateOnDrag":106,"./variablesGetReporter":108}],108:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("./duplicateOnDrag");o.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 o.zelos.ConstantProvider).SHAPES.ROUND,helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableReporter"]}),(0,s.updateDuplicateOnDragState)(this)}}},{"./duplicateOnDrag":106,blockly:192}],109:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MultiFlyoutRecyclableBlockInflater=i.HIDDEN_CLASS_NAME=void 0;const o=t("blockly");i.HIDDEN_CLASS_NAME="pxtFlyoutHidden";class s extends o.BlockFlyoutInflater{constructor(){super(...arguments),this.keyToBlock=new Map,this.blockToKey=new Map}static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,"block",s,!0)}isBlockRecycleable(t){switch(t.type){case"variables_get":case"variables_set":case"variables_change":return!1}return!0}createBlock(t,e){const s=function(t){if(t.blockxml)return"string"==typeof t.blockxml?t.blockxml:o.Xml.domToText(t.blockxml);return t.type}(t);if(!s)return super.createBlock(t,e);let n;return this.keyToBlock.has(s)&&(n=this.keyToBlock.get(s),this.keyToBlock.delete(s),e.getCanvas().appendChild(n.getSvgRoot())),n=null!=n?n:super.createBlock(t,e),this.blockToKey.set(n,s),n.removeClass(i.HIDDEN_CLASS_NAME),n.getFocusableElement().ariaHidden="false",n.setDisabledReason(!1,i.HIDDEN_CLASS_NAME),n}disposeItem(t){const e=t.getElement();if(e instanceof o.BlockSvg&&this.blockToKey.has(e)){if(this.isBlockRecycleable(e))return void this.recycleBlock(e);this.blockToKey.delete(e)}super.disposeItem(t)}clearCache(){this.blockToKey=new Map,this.keyToBlock=new Map}recycleBlock(t){const e=t.getRelativeToSurfaceXY();t.moveBy(-e.x,-e.y),t.addClass(i.HIDDEN_CLASS_NAME),t.getFocusableElement().ariaHidden="true",t.setDisabledReason(!0,i.HIDDEN_CLASS_NAME),t.getSvgRoot().remove();const o=this.blockToKey.get(t);this.keyToBlock.set(o,t),this.removeListeners(t.id)}}i.MultiFlyoutRecyclableBlockInflater=s,o.Css.register(`\n.${i.HIDDEN_CLASS_NAME} {\n display: none;\n}\n`)},{blockly:192}],110:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ButtonFlyoutInflater=void 0;const o=t("blockly"),s=t("./flyoutButton"),n="button";class r extends o.ButtonFlyoutInflater{static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,n,r,!0)}load(t,e){const i=new s.FlyoutButton(e.getWorkspace(),e.targetWorkspace,t,!1);return i.show(),new o.FlyoutItem(i,n)}}i.ButtonFlyoutInflater=r},{"./flyoutButton":112,blockly:192}],111:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.CachingFlyout=void 0;const o=t("blockly"),s=t("./blockInflater");class n extends o.VerticalFlyout{constructor(){super(...arguments),this.forceOpen=!1}clearBlockCache(){const t=this.getInflaterForType("block");t instanceof s.MultiFlyoutRecyclableBlockInflater&&t.clearCache()}getFlyoutElement(){return this.svgGroup_}setForceOpen(t){this.forceOpen=t}}i.CachingFlyout=n},{"./blockInflater":109,blockly:192}],112:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FlyoutButton=void 0;const o=t("blockly"),s={"":"usb","":"accessible-icon","":"adn","":"pied-piper-pp","":"steam","":"bluetooth-b","":"rebel","":"maxcdn","":"joomla","":"sellsy","":"connectdevelop","":"github-alt"};class n extends o.FlyoutButton{constructor(t,e,i,n){super(t,e,i,n);const r=this.getSvgRoot();if(!n){const t=17.5,e=14,i=this.height;this.width+=2*(t-o.FlyoutButton.TEXT_MARGIN_X),this.height+=2*(e-o.FlyoutButton.TEXT_MARGIN_Y);const s=r.getElementsByClassName("blocklyFlyoutButtonShadow").item(0),n=r.getElementsByClassName("blocklyFlyoutButtonBackground").item(0),a=r.getElementsByTagName("text").item(0);return s.setAttribute("width",String(this.width)),s.setAttribute("height",String(this.height)),n.setAttribute("width",String(this.width)),n.setAttribute("height",String(this.height)),a.setAttribute("x",String(this.width/2)),void a.setAttribute("y",String(parseFloat(a.getAttribute("y"))-i/2+this.height/2))}const a=i;a["web-class"]&&r.classList.add(a["web-class"]);const l=a["web-icon"],c=a["web-icon-class"],h=a["web-icon-color"],u=a["web-icon-image"];if(u){const t=20,e=this.getTargetWorkspace(),i=o.utils.dom.createSvgElement("image",{height:String(t),width:String(t),x:String(e.RTL?this.width+o.FlyoutButton.TEXT_MARGIN_X:o.FlyoutButton.TEXT_MARGIN_X),y:String(this.height/2+o.FlyoutButton.TEXT_MARGIN_Y-t/2)},r);i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);const s=t+2*o.FlyoutButton.TEXT_MARGIN_X;this.width+=s;const n=r.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);n.setAttribute("width",String(this.width));for(let t=0;t<r.children.length;t++){const e=r.children.item(t);if(e!==i&&e!==n){const t=Number(e.getAttribute("x"));e.setAttribute("x",t+s+"")}}}else if(l||c){const t=Object.keys(s).includes(l)?"brandIcon":"",e=o.utils.dom.createSvgElement("text",{class:`blocklyFlyoutLabelIcon${c?" "+c:""}${t?" "+t:""}`,x:0,y:0,"text-anchor":"start"},r);l&&(e.textContent=l),h&&e.setAttribute("style","fill: "+h);const i=this.getTargetWorkspace();e.setAttribute("dominant-baseline","central"),e.setAttribute("dy","0"),e.setAttribute("x",(i.RTL?this.width+o.FlyoutButton.TEXT_MARGIN_X:0)+""),e.setAttribute("y",this.height/2+o.FlyoutButton.TEXT_MARGIN_Y+"");const n=o.utils.dom.getTextWidth(e)+2*o.FlyoutButton.TEXT_MARGIN_X;this.width+=n;const a=r.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);a.setAttribute("width",String(this.width));for(let t=0;t<r.children.length;t++){const i=r.children.item(t);if(i!==e&&i!==a){const t=Number(i.getAttribute("x"));i.setAttribute("x",t+n+"")}}}const d=a["web-line"],p=a["web-line-width"];if(d){const t=o.utils.dom.createSvgElement("line",{class:"blocklyFlyoutLine","stroke-dasharray":d,"text-anchor":"middle"},r);t.setAttribute("x1","0"),t.setAttribute("x2",null!=p?p:this.width+""),t.setAttribute("y1",this.height+10+""),t.setAttribute("y2",this.height+10+"")}}isDisposed(){return null===this.getSvgRoot().parentNode}}i.FlyoutButton=n},{blockly:192}],113:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.registerFlyoutInflaters=i.MultiFlyoutRecyclableBlockInflater=i.LabelFlyoutInflater=i.ButtonFlyoutInflater=void 0;const n=t("./buttonFlyoutInflater");Object.defineProperty(i,"ButtonFlyoutInflater",{enumerable:!0,get:function(){return n.ButtonFlyoutInflater}});const r=t("./labelFlyoutInflater");Object.defineProperty(i,"LabelFlyoutInflater",{enumerable:!0,get:function(){return r.LabelFlyoutInflater}});const a=t("./blockInflater");Object.defineProperty(i,"MultiFlyoutRecyclableBlockInflater",{enumerable:!0,get:function(){return a.MultiFlyoutRecyclableBlockInflater}}),s(t("./cachingFlyout"),i),i.registerFlyoutInflaters=function(){n.ButtonFlyoutInflater.register(),r.LabelFlyoutInflater.register(),a.MultiFlyoutRecyclableBlockInflater.register()}},{"./blockInflater":109,"./buttonFlyoutInflater":110,"./cachingFlyout":111,"./labelFlyoutInflater":114}],114:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LabelFlyoutInflater=void 0;const o=t("blockly"),s=t("./flyoutButton"),n="label";class r extends o.LabelFlyoutInflater{static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,n,r,!0)}load(t,e){const i=new s.FlyoutButton(e.getWorkspace(),e.targetWorkspace,t,!0);return i.show(),new o.FlyoutItem(i,n)}}i.LabelFlyoutInflater=r},{"./flyoutButton":112,blockly:192}],115:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../constants"),n={typeName_:"",getTypeName(){return this.typeName_},removeFieldCallback(t){const e=this.getParent();(null==e?void 0:e.removeFieldCallback)&&e.removeFieldCallback(t)}};o.Blocks[s.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"bool"}],extensions:["output_boolean","text_field_color"]}),this.typeName_="boolean"}}),o.Blocks[s.ARGUMENT_EDITOR_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"text"}],extensions:["output_string","text_field_color"]}),this.typeName_="string"}}),o.Blocks[s.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"num"}],extensions:["output_number","text_field_color"]}),this.typeName_="number"}}),o.Blocks[s.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"list"}],extensions:["output_array","text_field_color"]}),this.typeName_="Array"}}),o.Blocks[s.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"arg"}],outputShape:(new o.zelos.ConstantProvider).SHAPES.ROUND,extensions:["text_field_color"]}),this.typeName_="any"},mutationToDom(){const t=o.utils.xml.createElement("mutation");return t.setAttribute("typename",this.typeName_),t},domToMutation(t){this.typeName_=t.getAttribute("typename"),this.setOutput(!0,this.typeName_)}})},{"../constants":121,blockly:192}],116:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LOCALIZATION_NAME_MUTATION_KEY=void 0;const o=t("blockly"),s=t("../constants"),n=t("../msg"),r=t("../../duplicateOnDrag");i.LOCALIZATION_NAME_MUTATION_KEY="localizationname";const a={typeName_:"",localizationName_:"",getTypeName(){return this.typeName_},getLocalizationName(){return this.localizationName_||this.getFieldValue("VALUE")},mutationToDom(){const t=o.utils.xml.createElement("mutation");return this.localizationName_&&t.setAttribute(i.LOCALIZATION_NAME_MUTATION_KEY,this.localizationName_),t},domToMutation(t){t.hasAttribute(i.LOCALIZATION_NAME_MUTATION_KEY)&&(this.localizationName_=t.getAttribute(i.LOCALIZATION_NAME_MUTATION_KEY))}};function l(t){(0,r.setDuplicateOnDragStrategy)(t),(0,r.updateDuplicateOnDragState)(t)}o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_boolean"]}),this.typeName_="boolean",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_string"]}),this.typeName_="string",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_number"]}),this.typeName_="number",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_array"]}),this.typeName_="Array",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],inputsInline:!0,outputShape:(new o.zelos.ConstantProvider).SHAPES.ROUND,output:null}),this.typeName_="",l(this)},mutationToDom(){const t=a.mutationToDom.call(this);return t.setAttribute("typename",this.typeName_),t},domToMutation(t){this.typeName_=t.getAttribute("typename"),this.setOutput(!0,this.typeName_),a.domToMutation.call(this,t)}})},{"../../duplicateOnDrag":107,"../constants":121,"../msg":128,blockly:192}],117:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../msg"),l=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){let s=null,n=null;if(e&&t.id in e){const i=e[t.id];s=i.block,n=i.shadow}const r=null==s?void 0:s.workspace.connectionChecker;o.Events.disable();try{if(s&&!s.isDisposed()&&e&&(null==r?void 0:r.canConnectWithReason(null==s?void 0:s.outputConnection,i.connection,!1))===o.Connection.CAN_CONNECT){let r;s.outputConnection.connect(i.connection),r=s.isShadow()?o.Xml.blockToDom(s):n||this.buildShadowDom_(t.type),"variables_get"!==r.getAttribute("type")&&i.connection.setShadowDom(r),delete e[i.name]}else this.attachShadow_(i,t.type)}finally{o.Events.enable()}},afterWorkspaceLoad:function(){var t;for(const e of this.inputList){if(e.type!==o.inputs.inputTypes.VALUE)continue;const i=null===(t=e.connection)||void 0===t?void 0:t.targetBlock();i&&i.isShadow()&&i.getVarModels().length&&i.setShadow(!1);const s=e.connection&&e.getShadowDom();(0,r.isVariableBlockType)(null==s?void 0:s.getAttribute("type"))&&e.setShadowDom(null)}},addFunctionLabel_:function(t){this.appendDummyInput("function_name").appendField(new o.FieldLabel(t,"functionNameText"),"function_name")},updateFunctionLabel_:function(t){this.getField("function_name").setValue(t)},attachShadow_(t,e){const i=(0,r.getShadowBlockInfoFromType_)(e,this.workspace),s=i[0],n=i[1],a=i[2];o.Events.disable();let l=null;try{l=this.workspace.newBlock(s),l.setFieldValue(a,n),l.setShadow("variables_get"!==s),!this.isInsertionMarker()&&l instanceof o.BlockSvg&&(l.initSvg(),l.queueRender())}finally{o.Events.enable()}l&&(l.setShadow(!0),l.outputConnection.connect(t.connection))},buildShadowDom_(t){const e=o.utils.xml.createElement("shadow"),i=(0,r.getShadowBlockInfoFromType_)(t,this.workspace),s=i[0],n=i[1],a=i[2],l="variables_get"===s;e.setAttribute("type",s);const c=o.utils.xml.createElement("field");if(c.textContent=a,l){c.setAttribute("id",a);const t=this.workspace.getVariableMap().getVariableById(a);c.textContent=t?t.getName():""}return c.setAttribute("name",n),e.appendChild(c),e},onchange(t){var e;if(this.workspace&&!this.workspace.isFlyout)if(t.type==o.Events.BLOCK_CREATE&&-1!=(null===(e=t.ids)||void 0===e?void 0:e.indexOf(this.id))){const e=this.getName(),i=(0,r.getDefinition)(e,this.workspace);if(i){const t=i.getArguments().slice(),e=this.arguments_.slice();JSON.stringify(e)!==JSON.stringify(t)&&(0,r.mutateCallersAndDefinition)(i.getName(),this.workspace,i.mutationToDom()),this.functionId_=i.functionId_}else{o.Events.setGroup(t.group);const e=o.utils.xml.createElement("xml"),i=o.utils.xml.createElement("block");i.setAttribute("type",n.FUNCTION_DEFINITION_BLOCK_TYPE);const s=this.getRelativeToSurfaceXY(),r=s.x+o.config.snapRadius*(this.RTL?-1:1),a=s.y+2*o.config.snapRadius;i.setAttribute("x",r+""),i.setAttribute("y",a+"");const l=this.mutationToDom();i.appendChild(l),e.appendChild(i),o.Xml.domToWorkspace(e,this.workspace),o.Events.setGroup(!1)}}else if(t.type==o.Events.BLOCK_DELETE){const e=this.getName();(0,r.getDefinition)(e,this.workspace)||(o.Events.setGroup(t.group),this.dispose(!0),o.Events.setGroup(!1))}},serializeChangedInputs(t){const e=[],i=(0,r.getArgMap)(t,!0);for(const t of this.arguments_){if(i[t.id])continue;const o=this.getInput(t.id).connection,s=o.targetBlock();s.isShadow()?e.push({inputName:t.id,connectedShadow:o.getShadowState(!0)}):e.push({inputName:t.id,connectedBlock:s.id})}return e}});o.Blocks[n.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(o.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(o.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(o.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}}),o.Blocks[n.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 o.zelos.ConstantProvider).SHAPES.ROUND),this.setColour(o.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(o.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(o.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../msg":128,"../utils":130,blockly:192}],118:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.newFunctionMutation=void 0;const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../fields/fieldAutocapitalizeTextInput"),l=t("../functionManager"),c=t("../msg"),h=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){const o=this.createArgumentEditor_(t.type,t.name);i.connection.connect(o.outputConnection)},addFunctionLabel_:function(t){const e=new a.FieldAutocapitalizeTextInput(t||"",void 0,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(e,"function_name")},updateFunctionLabel_:function(t){o.Events.disable(),this.getField("function_name").setValue(t),o.Events.enable()},createArgumentEditor_:function(t,e){let i;o.Events.disable();try{let s="";switch(t){case"boolean":s=n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE;break;case"number":s=n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE;break;case"string":s=n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE;break;case"Array":s=n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE;break;default:s=n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE}i=s==n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE?(0,r.createCustomArgumentEditor)(t,this.workspace):this.workspace.newBlock(s),i.setFieldValue(e,"TEXT"),i.setShadow(!0),!this.isInsertionMarker()&&i instanceof o.BlockSvg&&(i.initSvg(),i.queueRender())}finally{o.Events.enable()}return i},async focusLastEditorAsync_(){if(await o.renderManagement.finishQueuedRenders(),this.inputList.length>0){let t=this.inputList[this.inputList.length-2];if(t.type==o.inputs.inputTypes.DUMMY){const e=this.workspace;e instanceof o.WorkspaceSvg&&e.centerOnBlock(this.id,!0),t.fieldRow[0].showEditor()}else if(t.type==o.inputs.inputTypes.VALUE){const e=t.connection.targetBlock(),i=e.workspace;i instanceof o.WorkspaceSvg&&i.centerOnBlock(e.id,!0),e.getField("TEXT").showEditor()}}},removeFieldCallback(t){let e=null;for(let i=0;i<this.inputList.length&&!e;i++){let o=this.inputList[i];if(o.connection){let i=o.connection.targetBlock();if(!i)continue;i.getField(t.name)===t&&(e=o.name)}else for(let i=0;i<o.fieldRow.length;i++)o.fieldRow[i]==t&&(e=o.name)}e&&(o.WidgetDiv.hide(),this.removeInput(e),this.updateFunctionSignature(),this.updateDisplay_())},addParam_(t,e){o.WidgetDiv.hide();const i=(0,r.findUniqueParamName)(e,this.arguments_.map(t=>t.name));this.arguments_.push({id:o.utils.idGenerator.genUid(),name:i,type:t}),this.updateDisplay_(),this.focusLastEditorAsync_()},addBooleanExternal(){this.addParam_("boolean",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME])},addStringExternal(){this.addParam_("string",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_STRING_ARG_NAME])},addNumberExternal(){this.addParam_("number",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME])},addArrayExternal(){this.addParam_("Array",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME])},addCustomExternal(t){this.addParam_(t,l.FunctionManager.getInstance().getArgumentNameForType(t))},updateFunctionSignature(){this.arguments_=[];for(let t=1;t<this.inputList.length;t++){const e=this.inputList[t];switch(e.type){case o.inputs.inputTypes.STATEMENT:break;case o.inputs.inputTypes.DUMMY:this.name_=e.fieldRow[0].getValue()||e.fieldRow[0].getText();break;case o.inputs.inputTypes.VALUE:const t=e.connection.targetBlock();this.arguments_.push({id:e.name,name:t.getFieldValue("TEXT"),type:t.getTypeName()});break;default:pxt.warn("Unexpected input type on a function mutator root: "+e.type)}}}});i.newFunctionMutation=function(t){const e=(0,r.findLegalName)(o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_FUNCTION_NAME],t),i=o.utils.xml.createElement("mutation");return i.setAttribute("name",e),i.setAttribute("functionid",o.utils.idGenerator.genUid()),i},o.Blocks[n.FUNCTION_DECLARATION_BLOCK_TYPE]=Object.assign(Object.assign({},h),{init:function(){this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../fields/fieldAutocapitalizeTextInput"),l=t("../msg"),c=t("../functionManager"),h=t("../svgs"),u=t("../../duplicateOnDrag"),d=t("../../../fields/field_imagenotext"),p=t("../../../utils"),g=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){let o,s=null;if(null==e?void 0:e[t.id]){s=e[t.id].block}e&&s&&!s.isDisposed()?(o=s,o.setFieldValue(t.name,"VALUE"),delete e[i.name]):o=this.createArgumentReporter_(t),i.connection.connect(o.outputConnection)},afterWorkspaceLoad:function(){for(const t of this.inputList){if(t.type!==o.inputs.inputTypes.VALUE)continue;const e=this.arguments_.find(e=>e.id===t.name);if(!e)continue;let i=t.connection.targetBlock();i||(this.populateArgument_(e,null,t),i=t.connection.targetBlock()),i.setFieldValue(e.name,"VALUE"),i.isShadow()&&i.setShadow(!1),t.setShadowDom(null)}},addFunctionLabel_:function(t){const e=new a.FieldAutocapitalizeTextInput(t||"",r.rename,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(e,"function_name")},updateFunctionLabel_:function(t){o.Events.disable(),this.getField("function_name").setValue(t),o.Events.enable()},createArgumentReporter_:function(t){let e,i="";switch(t.type){case"boolean":i=n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE;break;case"number":i=n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE;break;case"string":i=n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE;break;case"Array":i=n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE;break;default:i=n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}o.Events.disable();try{e=i==n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE?(0,r.createCustomArgumentReporter)(t.type,this.workspace):this.workspace.newBlock(i),e.setFieldValue(t.name,"VALUE"),e.setShadow(!0),!this.isInsertionMarker()&&e instanceof o.BlockSvg&&(e.initSvg(),e.queueRender())}finally{o.Events.enable()}return e},customContextMenu:function(t){var e,i;this.isInFlyout||(null===(i=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===i?void 0:i.readOnly)||(t.push(this.makeEditOption()),t.push(this.makeCallOption()))},makeEditOption:function(){var t,e;return{enabled:!(null===(e=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===e?void 0:e.readOnly),text:o.Msg.FUNCTIONS_EDIT_OPTION,callback:()=>{!function(t){if(t.type==n.FUNCTION_CALL_BLOCK_TYPE||t.type==n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const e=t.workspace;t=(0,r.getDefinition)(t.getName(),e)}o.hideChaff(),o.getSelected()&&o.getSelected().unselect();c.FunctionManager.getInstance().editFunctionExternal(t.mutationToDom(),e=>{e&&((0,r.mutateCallersAndDefinition)(t.getName(),t.workspace,e),t.updateDisplay_()),setTimeout(()=>{t.afterWorkspaceLoad&&t.afterWorkspaceLoad()})})}(this)}}},makeCallOption:function(){var t,e;const i=this.getName(),s=o.utils.xml.createElement("mutation");s.setAttribute("name",i);const r=o.utils.xml.createElement("block");return r.appendChild(s),r.setAttribute("type",n.FUNCTION_CALL_BLOCK_TYPE),{enabled:this.workspace.remainingCapacity()>0&&!(null===(e=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===e?void 0:e.readOnly),text:o.Msg.FUNCTIONS_CREATE_CALL_OPTION.replace("%1",i),callback:o.ContextMenu.callbackFactory(this,r)}}});o.Blocks[n.FUNCTION_DEFINITION_BLOCK_TYPE]=Object.assign(Object.assign({},g),{init:function(){if(this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(o.Msg[l.MsgKey.PROCEDURES_HUE]),this.setTooltip(o.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_TOOLTIP]),this.setHelpUrl(o.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_HELPURL]),this.setStatements_(!0),this.setInputsInline(!0),this.workspace.options.collapse){const t=h.COLLAPSE_IMAGE_DATAURI;this.appendDummyInput("function_collapse").appendField(new d.FieldImageNoText(t,24,24,lf("Collapse block"),()=>{var t;this.setCollapsed(!0);const e=null===(t=this.inputList.find(t=>t.name===o.constants.COLLAPSED_INPUT_NAME))||void 0===t?void 0:t.fieldRow[1];(0,p.maybeMoveFocusFromButton)(e)},!1))}}}),(0,u.setDuplicateOnDrag)(n.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.COMMON_FUNCTION_MIXIN=void 0;const o=t("blockly"),s=t("./constants"),n=t("./utils"),r=t("./msg");i.COMMON_FUNCTION_MIXIN={name_:"",functionId_:"",arguments_:[],mutationToDom:function(){this.ensureIds_();const t=o.utils.xml.createElement("mutation");return t.setAttribute("name",this.name_),t.setAttribute("functionid",this.functionId_),this.arguments_.forEach(function(e){const i=o.utils.xml.createElement("arg");i.setAttribute("name",e.name),i.setAttribute("id",e.id),i.setAttribute("type",e.type),t.appendChild(i)}),t},domToMutation:function(t){const e=[];for(let i=0;i<t.childNodes.length;++i){const o=t.childNodes[i];"arg"==o.nodeName.toLowerCase()&&e.push({id:o.getAttribute("id"),name:o.getAttribute("name"),type:o.getAttribute("type")})}this.arguments_=e,this.name_=t.getAttribute("name"),this.restoreSavedFunctionId(t.getAttribute("functionid"))},saveExtraState:function(){return{name:this.name_,functionid:this.functionId_,arguments:this.arguments_.slice()}},loadExtraState:function(t){this.arguments_=t.arguments.slice(),this.name_=t.name,this.restoreSavedFunctionId(t.functionid)},restoreSavedFunctionId:function(t){(0,n.idsInUse)(this.workspace).indexOf(t)<0&&(this.functionId_=t),this.ensureIds_();let e=null;this instanceof o.BlockSvg&&(e=this.getHeightWidth()),this.type!==s.FUNCTION_DEFINITION_BLOCK_TYPE||e&&!e.height&&!e.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 t=[];for(let e,i=0;e=this.inputList[i];i++)e.type==o.inputs.inputTypes.VALUE?e.dispose():t.push(e);this.inputList=t},createAllInputs_:function(){let t=!1,e=!1;if(this.inputList.forEach(function(i){"function_title"==i.name?t=!0:"function_name"==i.name&&(e=!0)}),!t){let t="";switch(this.type){case s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case s.FUNCTION_CALL_BLOCK_TYPE:t=o.Msg[r.MsgKey.FUNCTIONS_CALL_TITLE];break;case s.FUNCTION_DEFINITION_BLOCK_TYPE:case s.FUNCTION_DECLARATION_BLOCK_TYPE:t=o.Msg[r.MsgKey.FUNCTIONS_DEFNORETURN_TITLE]}this.appendDummyInput("function_title").appendField(t,"function_title")}e?this.updateFunctionLabel_(this.getName()):this.addFunctionLabel_(this.getName()),this.updateArgumentInputs_()},updateArgumentInputs_(){var t;for(const t of this.inputList)if(t.type===o.inputs.inputTypes.VALUE&&!this.arguments_.some(e=>e.id===t.name)){if(this.type===s.FUNCTION_DEFINITION_BLOCK_TYPE){const e=t.connection.targetBlock();e&&e.dispose()}this.removeInput(t.name)}let e=this.inputList.findIndex(t=>t.type===o.inputs.inputTypes.VALUE);-1===e&&(e=this.inputList.length);for(const i of this.arguments_){let o=this.inputList.find(t=>t.name===i.id);const s=!o;s&&(o=this.appendValueInput(i.id)),this.inputList.indexOf(o)!==e&&this.moveInputBefore(o.name,null===(t=this.inputList[e+1])||void 0===t?void 0:t.name),(0,n.isCustomType)(i.type)?o.setCheck(i.type):o.setCheck(i.type.charAt(0).toUpperCase()+i.type.slice(1)),!this.isInsertionMarker()&&s&&this.populateArgument_(i,void 0,o),e++}this.inputList.some(t=>"function_collapse"===t.name)&&this.moveInputBefore("function_collapse",null),this.hasStatements_&&this.moveInputBefore("STACK",null)},updateDisplay_:function(){let t=this.rendered;this.createAllInputs_(),t&&!this.isInsertionMarker()&&this instanceof o.BlockSvg&&(this.initSvg(),this.queueRender())},setStatements_:function(t){this.hasStatements_!==t&&(t?this.appendStatementInput("STACK"):this.removeInput("STACK",!0),this.hasStatements_=t)},ensureIds_:function(){switch(this.type){case s.FUNCTION_DEFINITION_BLOCK_TYPE:this.functionId_&&"null"!=this.functionId_||(this.functionId_=o.utils.idGenerator.genUid());for(let t=0;t<this.arguments_.length;++t)this.arguments_[t].id||(this.arguments_[t].id=o.utils.idGenerator.genUid());break;case s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case s.FUNCTION_CALL_BLOCK_TYPE:const t=(0,n.getDefinition)(this.name_,this.workspace);if(t){this.functionId_=t.getFunctionId();const e=t.getArguments();for(let t=0;t<this.arguments_.length;++t)for(let i=0;i<e.length;++i)if(e[i].name==this.arguments_[t].name){this.arguments_[t].id=e[i].id;break}}}}}},{"./constants":121,"./msg":128,"./utils":130,blockly:192}],121:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE=i.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE=i.ARGUMENT_EDITOR_STRING_BLOCK_TYPE=i.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE=i.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE=i.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE=i.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE=i.ARGUMENT_REPORTER_STRING_BLOCK_TYPE=i.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE=i.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE=i.FUNCTION_CALL_OUTPUT_BLOCK_TYPE=i.FUNCTION_CALL_BLOCK_TYPE=i.FUNCTION_DECLARATION_BLOCK_TYPE=i.FUNCTION_DEFINITION_BLOCK_TYPE=void 0,i.FUNCTION_DEFINITION_BLOCK_TYPE="function_definition",i.FUNCTION_DECLARATION_BLOCK_TYPE="function_declaration",i.FUNCTION_CALL_BLOCK_TYPE="function_call",i.FUNCTION_CALL_OUTPUT_BLOCK_TYPE="function_call_output",i.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE="argument_reporter_boolean",i.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE="argument_reporter_number",i.ARGUMENT_REPORTER_STRING_BLOCK_TYPE="argument_reporter_string",i.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE="argument_reporter_array",i.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE="argument_reporter_custom",i.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE="argument_editor_boolean",i.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE="argument_editor_number",i.ARGUMENT_EDITOR_STRING_BLOCK_TYPE="argument_editor_string",i.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE="argument_editor_array",i.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE="argument_editor_custom"},{}],122:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("./utils"),n=t("./msg"),r=t("./svgs"),a=new o.zelos.ConstantProvider;const l={customContextMenu:function(t){var e,i;const r={enabled:!(null===(i=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===i?void 0:i.readOnly),text:o.Msg[n.MsgKey.FUNCTIONS_GO_TO_DEFINITION_OPTION],callback:()=>{const t=this.getField("function_name").getText(),e=(0,s.getDefinition)(t,this.workspace);e&&this.workspace instanceof o.WorkspaceSvg&&this.workspace.centerOnBlock(e.id,!0)}};t.push(r)}},c={customContextMenu:function(t){if(this.isCollapsed())return;const e={text:o.Msg.RENAME_VARIABLE,enabled:!this.workspace.options.readOnly,callback:()=>{const t=this.workspace,e=this.getField("VAR").getVariable();o.Variables.renameVariable(t,e)}};if(t.unshift(e),!this.isInFlyout){const e=this.workspace.getVariableMap().getVariablesOfType("");for(const i of e){const e={enabled:!this.workspace.options.readOnly,text:i.getName(),callback:()=>{let t=this.getField("VAR");t||pxt.log("Tried to get a variable field on the wrong type of block."),t.setValue(i.getId())}};t.unshift(e)}}}};o.Extensions.registerMixin("function_contextmenu_edit",l),o.Extensions.registerMixin("contextMenu_variableReporter",c),o.Extensions.register("output_number",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Number")}),o.Extensions.register("output_string",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"String")}),o.Extensions.register("output_boolean",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.HEXAGONAL),this.setOutput(!0,"Boolean")}),o.Extensions.register("output_array",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Array")}),o.Extensions.register("text_field_color",function(){if(this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer().getConstants();this.setColour(t.FIELD_BORDER_RECT_COLOUR)}else this.setColour("#fff")}),o.Extensions.register("inline-svgs",function(){this.ADD_IMAGE_DATAURI=r.ADD_IMAGE_DATAURI,this.REMOVE_IMAGE_DATAURI=r.REMOVE_IMAGE_DATAURI})},{"./msg":128,"./svgs":129,"./utils":130,blockly:192}],123:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldArgumentEditor=void 0;const o=t("blockly"),s=t("../functionManager"),n=t("../../../external"),r=t("../msg");class a extends o.FieldTextInput{constructor(t,e,i){super(t,e,i)}showEditor(t){var e,i;super.showEditor(t);const n=o.WidgetDiv.getDiv();n.className+=" argumentEditorInput";const r=document.createElement("img");r.setAttribute("class","argumentEditorRemoveIcon"),r.setAttribute("src",a.REMOVE_ARG_URI),this.removeButtonMouseWrapper_=o.browserEvents.conditionalBind(r,"mousedown",this,this.removeCallback),n.appendChild(r);const l=null===(e=this.sourceBlock_)||void 0===e?void 0:e.getTypeName();if(l&&(null===(i=this.sourceBlock_)||void 0===i?void 0:i.workspace)){const t=s.FunctionManager.getInstance().getIconForType(l);if(t){const e=t+" icon argumentEditorTypeIcon",i=document.createElement("i");i.className=e,n.appendChild(i)}}}showEditor_(t,e=!1,i=!0){this.workspace_=this.sourceBlock_.workspace,!e&&this.workspace_.options.modalInputs&&(o.utils.userAgent.MOBILE||o.utils.userAgent.ANDROID||o.utils.userAgent.IPAD)?this.showPromptEditorModal():super.showEditor_(t,e,i)}showPromptEditorModal(){(0,n.prompt)(o.Msg.CHANGE_VALUE_TITLE,this.getText(),t=>{null!==t&&this.setValue(this.getValueFromEditorText_(t)),this.onFinishEditing_(this.value_)},{placeholder:void 0,buttons:[{label:o.Msg[r.MsgKey.FUNCTIONS_DELETE_PARAMETER_BUTTON],className:"red",icon:"trash",onclick:()=>{this.removeCallback()}}]})}removeCallback(){var t,e;const i=null===(t=this.sourceBlock_)||void 0===t?void 0:t.getParent();if(!i)return;let s;for(const t of i.inputList){if((null===(e=t.connection)||void 0===e?void 0:e.targetBlock())===this.sourceBlock_){s=t.name;break}}s&&(o.WidgetDiv.hide(),i.removeInput(s))}}i.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",o.fieldRegistry.register("field_argument_editor",a),o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.setArgumentReporterLocalizeFunction=i.FieldArgumentReporter=void 0;const o=t("blockly"),s=t("../utils");let n;class r extends o.FieldLabelSerializable{getDisplayText_(){const t=this.getSourceBlock();if(t&&(0,s.isFunctionArgumentReporter)(t)&&n){const e=n(this,t);if(e)return e}return super.getDisplayText_()}}i.FieldArgumentReporter=r,i.setArgumentReporterLocalizeFunction=function(t){n=t},o.registry.register(o.registry.Type.FIELD,"field_argument_reporter",r)},{"../utils":130,blockly:192}],125:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldAutocapitalizeTextInput=void 0;const o=t("blockly");class s extends o.FieldTextInput{constructor(t,e,i){super(t,e,i),this.disableAutocapitalize=!1}setAutocapitalize(t){this.disableAutocapitalize=!t,this.htmlInput_&&(this.disableAutocapitalize?this.htmlInput_.setAttribute("autocapitalize","none"):this.htmlInput_.removeAttribute("autocapitalize"))}configure_(t){super.configure_(t),void 0!==t.disableAutocapitalize&&(this.disableAutocapitalize=t.disableAutocapitalize)}widgetCreate_(){const t=super.widgetCreate_();return this.disableAutocapitalize&&t.setAttribute("autocapitalize","none"),t}}i.FieldAutocapitalizeTextInput=s,o.fieldRegistry.register("field_autocapitalize_text_input",s)},{blockly:192}],126:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FunctionManager=void 0;const o=t("blockly"),s=t("./msg");class n{constructor(){this.typeIcons={},this.typeArgumentNames={}}static getInstance(){return n.instance}getIconForType(t){return this.typeIcons[t]}setIconForType(t,e){this.typeIcons[t]=e}setArgumentNameForType(t,e){this.typeArgumentNames[t]=e}getArgumentNameForType(t){return this.typeArgumentNames[t]?this.typeArgumentNames[t]:o.Msg[s.MsgKey.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME]}setEditFunctionExternal(t){this._editFunctionExternal=t}editFunctionExternal(t,e){this._editFunctionExternal?this._editFunctionExternal(t,e):pxt.warn("External function editor must be overriden: Blockly.Functions.editFunctionExternalHandler",t,e)}}i.FunctionManager=n,n.instance=new n},{"./msg":128,blockly:192}],127:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.validateFunctionExternal=i.getAllFunctionDefinitionBlocks=i.getDefinition=i.flyoutCategory=void 0,s(t("./msg"),i),s(t("./extensions"),i),s(t("./fields/fieldArgumentEditor"),i),s(t("./fields/fieldArgumentReporter"),i),s(t("./fields/fieldAutocapitalizeTextInput"),i),s(t("./blocks/argumentEditorBlocks"),i),s(t("./blocks/argumentReporterBlocks"),i),s(t("./blocks/functionDeclarationBlock"),i),s(t("./blocks/functionDefinitionBlock"),i),s(t("./blocks/functionCallBlocks"),i),s(t("./functionManager"),i);var n=t("./utils");Object.defineProperty(i,"flyoutCategory",{enumerable:!0,get:function(){return n.flyoutCategory}}),Object.defineProperty(i,"getDefinition",{enumerable:!0,get:function(){return n.getDefinition}}),Object.defineProperty(i,"getAllFunctionDefinitionBlocks",{enumerable:!0,get:function(){return n.getAllFunctionDefinitionBlocks}}),Object.defineProperty(i,"validateFunctionExternal",{enumerable:!0,get:function(){return n.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MsgKey=void 0;const o=t("blockly");var s;function n(t,e){o.Msg[t]||(o.Msg[t]=e)}!function(t){t.REPORTERS_HUE="REPORTERS_HUE",t.FUNCTIONS_CALL_TITLE="FUNCTIONS_CALL_TITLE",t.FUNCTIONS_DEFNORETURN_TITLE="FUNCTIONS_DEFNORETURN_TITLE",t.FUNCTIONS_GO_TO_DEFINITION_OPTION="FUNCTIONS_GO_TO_DEFINITION_OPTION",t.FUNCTION_CALL_TOOLTIP="FUNCTION_CALL_TOOLTIP",t.PROCEDURES_HUE="PROCEDURES_HUE",t.PROCEDURES_CALLNORETURN_HELPURL="PROCEDURES_CALLNORETURN_HELPURL",t.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME="FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME",t.FUNCTIONS_DEFAULT_STRING_ARG_NAME="FUNCTIONS_DEFAULT_STRING_ARG_NAME",t.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME="FUNCTIONS_DEFAULT_NUMBER_ARG_NAME",t.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME="FUNCTIONS_DEFAULT_ARRAY_ARG_NAME",t.PROCEDURES_DEFNORETURN_TOOLTIP="PROCEDURES_DEFNORETURN_TOOLTIP",t.PROCEDURES_DEFNORETURN_HELPURL="PROCEDURES_DEFNORETURN_HELPURL",t.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME="FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME",t.FUNCTIONS_DEFAULT_FUNCTION_NAME="FUNCTIONS_DEFAULT_FUNCTION_NAME",t.FUNCTION_CREATE_NEW="FUNCTION_CREATE_NEW",t.FUNCTION_FLYOUT_LABEL="FUNCTION_FLYOUT_LABEL",t.FUNCTIONS_EDIT_OPTION="FUNCTIONS_EDIT_OPTION",t.FUNCTIONS_CREATE_CALL_OPTION="FUNCTIONS_CREATE_CALL_OPTION",t.FUNCTIONS_DELETE_PARAMETER_BUTTON="FUNCTIONS_DELETE_PARAMETER_BUTTON"}(s=i.MsgKey||(i.MsgKey={})),n(s.REPORTERS_HUE,"#A80000"),n(s.FUNCTIONS_CALL_TITLE,"call"),n(s.FUNCTIONS_DEFNORETURN_TITLE,"function"),n(s.FUNCTIONS_GO_TO_DEFINITION_OPTION,"Go to Definition"),n(s.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME,"bool"),n(s.FUNCTIONS_DEFAULT_STRING_ARG_NAME,"text"),n(s.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME,"num"),n(s.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME,"array"),n(s.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME,"value"),n(s.FUNCTIONS_DEFAULT_FUNCTION_NAME,"doSomething"),n(s.FUNCTION_CREATE_NEW,"Make a Function"),n(s.FUNCTION_FLYOUT_LABEL,"Your Functions"),n(s.FUNCTIONS_EDIT_OPTION,"Edit Function"),n(s.FUNCTIONS_CREATE_CALL_OPTION,"Create 'call %1'"),n(s.FUNCTIONS_DELETE_PARAMETER_BUTTON,"Delete")},{blockly:192}],129:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.REMOVE_IMAGE_DATAURI=i.ADD_IMAGE_DATAURI=i.COLLAPSE_IMAGE_DATAURI=void 0,i.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",i.ADD_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJhZGQuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjQ4MjEiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NjkiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjEyLjkxNTI1NCIKICAgICBpbmtzY2FwZTpjeT0iMTYuMDY3Nzk2IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0icmVwZWF0IiAvPjxzdHlsZQogICAgIHR5cGU9InRleHQvY3NzIgogICAgIGlkPSJzdHlsZTMiPgoJLnN0MHtmaWxsOiNDRjhCMTc7fQoJLnN0MXtmaWxsOiNGRkZGRkY7fQo8L3N0eWxlPjx0aXRsZQogICAgIGlkPSJ0aXRsZTUiPnJlcGVhdDwvdGl0bGU+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMiCiAgICAgd2lkdGg9IjQuMDUwMDAwMiIKICAgICBoZWlnaHQ9IjEyLjM5NzA1IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSItMTguMTk4NTI2IgogICAgIHJ4PSIwLjgxIgogICAgIHJ5PSIwLjgxIgogICAgIHRyYW5zZm9ybT0ic2NhbGUoMSwtMSkiIC8+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMtMSIKICAgICB3aWR0aD0iNC4wNTAwMDAyIgogICAgIGhlaWdodD0iMTIuMzk3MTE5IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSI1LjgwMTQ0MDciCiAgICAgcng9IjAuODEiCiAgICAgcnk9IjAuODEiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMCwxLDEsMCwwLDApIiAvPjxjaXJjbGUKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6I2ZmZmZmZjtzdHJva2Utd2lkdGg6MjtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MSIKICAgICBpZD0icGF0aDQxMzYiCiAgICAgY3g9IjEyIgogICAgIGN5PSIxMiIKICAgICByPSIxMC41MDMxOTEiIC8+PC9zdmc+",i.REMOVE_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJyZW1vdmUuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjFhZmYiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NTAiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjAuMDUwODQ3NTIxIgogICAgIGlua3NjYXBlOmN5PSI5Ljk2NjEwMTciCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJyZXBlYXQiIC8+PHN0eWxlCiAgICAgdHlwZT0idGV4dC9jc3MiCiAgICAgaWQ9InN0eWxlMyI+Cgkuc3Qwe2ZpbGw6I0NGOEIxNzt9Cgkuc3Qxe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU+PHRpdGxlCiAgICAgaWQ9InRpdGxlNSI+cmVwZWF0PC90aXRsZT48cmVjdAogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eTowLjA3ODQzMTM3IgogICAgIGlkPSJyZWN0NDE0My0xIgogICAgIHdpZHRoPSI0LjA1MDAwMDIiCiAgICAgaGVpZ2h0PSIxMi4zOTcxMTkiCiAgICAgeD0iOS45NzUwMDA0IgogICAgIHk9IjUuODAxNDQwNyIKICAgICByeD0iMC44MSIKICAgICByeT0iMC44MSIKICAgICB0cmFuc2Zvcm09Im1hdHJpeCgwLDEsMSwwLDAsMCkiIC8+PGNpcmNsZQogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojZmZmZmZmO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eToxIgogICAgIGlkPSJwYXRoNDEzNiIKICAgICBjeD0iMTIiCiAgICAgY3k9IjEyIgogICAgIHI9IjEwLjUwMzE5MSIgLz48L3N2Zz4="},{}],130:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isVariableBlockType=i.validateFunctionExternal=i.flyoutCategory=i.getShadowBlockInfoFromType_=i.findUniqueParamName=i.getArgumentReporterParent=i.doArgumentReporterDragChecks=i.isFunctionArgumentReporter=i.getArgMap=i.mutateCallersAndDefinition=i.idsInUse=i.findLegalName=i.createCustomArgumentEditor=i.createCustomArgumentReporter=i.isCustomType=i.getAllFunctionDefinitionBlocks=i.getDefinition=i.rename=void 0;const o=t("blockly"),s=t("./constants"),n=t("./functionManager"),r=t("./msg"),a=t("./blocks/functionDeclarationBlock"),l=t("../../compiler/util"),c=t("../../loader");function h(t,e){for(const i of e.getTopBlocks(!1))if(i.type===s.FUNCTION_DEFINITION_BLOCK_TYPE){const e=i;if(e.getName()===t)return e}return null}function u(t){return t.getTopBlocks(!1).filter(t=>t.type===s.FUNCTION_DEFINITION_BLOCK_TYPE)}function d(t,e,i){const s=i.newBlock(t),n=o.utils.xml.createElement("mutation");return n.setAttribute("typename",e),s.domToMutation(n),s}function p(t,e,i){if(null==i?void 0:i.isInFlyout)return t;const o=g(e,i);for(;o[t];)t=m(t);return t}function g(t,e,i){const o={};return t.getVariableMap().getAllVariables().forEach(function(t){o[t.getName()]=!0}),t.getAllBlocks(!1).forEach(function(t){const n=t;n==e||i&&n.getFunctionId&&n.getFunctionId()==i||(n.type==s.FUNCTION_DEFINITION_BLOCK_TYPE?o[n.getName()]=!0:"procedures_defreturn"==t.type||t.type)}),o}function m(t){const e=t.match(/^(.*?)(\d+)$/);return e?t=e[1]+(parseInt(e[2],10)+1):t+="2",t}function _(t,e,i){const n=h(t,e);if(n){const r=n.mutationToDom(),a=f(r,!1),l=f(i,!0),c=[];for(const t of n.getDescendants(!1)){if(!T(t))continue;const e=b(t,t);if(e&&e!==n)continue;const i=t.getFieldValue("VALUE"),o=l[a[i]];if(i===o)continue;const s=t.outputConnection.targetBlock().id,r=t.outputConnection.targetConnection.getParentInput().name;c.push({id:t.id,type:t.type,oldName:i,newName:o,targetBlockId:s,targetInputName:r})}const h=function(t,e){const i=[];for(const o of e.getAllBlocks(!1))if(o.type===s.FUNCTION_CALL_BLOCK_TYPE||o.type===s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const e=o;e.getName()===t&&i.push(e)}return i}(t,n.workspace).map(t=>({id:t.id,oldMutation:o.utils.xml.domToText(t.mutationToDom()),shadows:t.serializeChangedInputs(i)})),u=new y(n.id,h,o.Xml.domToText(r),o.Xml.domToText(i),c);u.workspaceId=e.id,u.run(!0),o.Events.fire(u)}else pxt.warn("Attempted to change function "+t+", but no definition block was found on the workspace")}function f(t,e){const i={};for(let o=0;o<t.childNodes.length;++o){const s=t.childNodes[o],n=e?s.getAttribute("id"):s.getAttribute("name"),r=e?s.getAttribute("name"):s.getAttribute("id");i[n]=r}return i}function T(t){return t.type==s.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_STRING_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}function b(t,e){pxt.U.assert(T(t));const i=t.getFieldValue("VALUE"),o=t.getTypeName();for(;e.getSurroundParent();){e=e.getSurroundParent();for(const t of e.inputList){if(!t.connection||!t.name.startsWith(c.DRAGGABLE_PARAM_INPUT_PREFIX))continue;if(t.name.slice(c.DRAGGABLE_PARAM_INPUT_PREFIX.length)!==i)continue;let s=o;return"string"!==s&&"number"!==s&&"boolean"!==s||(s=s.charAt(0).toUpperCase()+s.slice(1)),-1!==t.connection.getCheck().indexOf(s)?e:void 0}}if(!e.isEnabled())return e;if((0,l.isFunctionDefinition)(e)){if(e.getArguments().some(t=>t.name===i&&t.type===o))return e}}function E(t,e){return!e||-1==e.indexOf(t)}i.rename=function(t){t=t.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");const e=this.sourceBlock_,i=p(t,e.workspace,e),o=this.getValue();if(!t)return o;if(!i)return t;if(!o)return e.name_=i,i;if(o!=t&&o!=i){e.name_=i;const t=e.mutationToDom();e.name_=o,_(o,e.workspace,t)}return i},i.getDefinition=h,i.getAllFunctionDefinitionBlocks=u,i.isCustomType=function(t){return!("boolean"==t||"string"==t||"number"==t)},i.createCustomArgumentReporter=function(t,e){return d(s.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE,t,e)},i.createCustomArgumentEditor=function(t,e){return d(s.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE,t,e)},i.findLegalName=p,i.idsInUse=function(t){const e=[];return t.getAllBlocks(!1).forEach(function(t){t.type==s.FUNCTION_DEFINITION_BLOCK_TYPE&&e.push(t.getFunctionId())}),e},i.mutateCallersAndDefinition=_,i.getArgMap=f,i.isFunctionArgumentReporter=T,i.doArgumentReporterDragChecks=function(t,e,i){const o=t.getSourceBlock();if(!T(o))return!0;const s=e.getSourceBlock();return!s||!!b(o,s)},i.getArgumentReporterParent=b,i.findUniqueParamName=function(t,e){for(;!E(t,e);)t=m(t);return t},i.getShadowBlockInfoFromType_=function(t,e){let i="",s="",r="";switch(t){case"boolean":i="logic_boolean",s="BOOL",r="TRUE";break;case"number":i="math_number",s="NUM",r="1";break;case"string":i="text",s="TEXT",r="abc";break;case"Array":i="variables_get",s="VAR",r=o.Variables.getOrCreateVariablePackage(e,null,"list","").getId();break;default:i="variables_get",s="VAR",r=o.Variables.getOrCreateVariablePackage(e,null,n.FunctionManager.getInstance().getArgumentNameForType(t),"").getId()}return[i,s,r]},i.flyoutCategory=function(t){const e=[],i=document.createElement("button"),l=o.Msg[r.MsgKey.FUNCTION_CREATE_NEW],c="CREATE_FUNCTION";i.setAttribute("text",l),i.setAttribute("callbackKey",c),t.registerButtonCallback(c,()=>{!function(t){o.hideChaff(),o.getSelected()&&o.getSelected().unselect();n.FunctionManager.getInstance().editFunctionExternal((0,a.newFunctionMutation)(t),function(t){return function(e){if(e){const i='<xml><block type="'+s.FUNCTION_DEFINITION_BLOCK_TYPE+'">'+o.Xml.domToText(e)+"</block></xml>",n=o.utils.xml.textToDom(i);o.Events.setGroup(!0);const r=o.Xml.domToBlock(n.firstChild,t);if(r.updateDisplay_(),t.getMetrics){const e=t.getMetrics(),i=r.getHeightWidth();r.moveBy(e.viewLeft+e.viewWidth/2-i.width/2,e.viewTop+e.viewHeight/2-i.height/2),r.scheduleSnapAndBump()}t.centerOnBlock(r.id,!0),o.Events.setGroup(!1),setTimeout(()=>{r.afterWorkspaceLoad&&r.afterWorkspaceLoad(),o.getFocusManager().focusNode(r)})}}}(t))}(t)}),e.push(i);for(const i of u(t)){const t=i.getName(),s=i.getArguments(),n=o.utils.xml.createElement("block");n.setAttribute("type","function_call"),n.setAttribute("gap","16");const r=o.utils.xml.createElement("mutation");r.setAttribute("name",t),n.appendChild(r);for(let t=0;t<s.length;t++){const e=o.utils.xml.createElement("arg");e.setAttribute("name",s[t].name),e.setAttribute("type",s[t].type),e.setAttribute("id",s[t].id),r.appendChild(e)}e.push(n)}return e},i.validateFunctionExternal=function(t,e){const i=t.getAttribute("name");if(!i)return o.dialog.alert(o.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;const s={};for(let e=0;e<t.childNodes.length;++e){const i=t.childNodes[e].getAttribute("name");if(!i)return o.dialog.alert(o.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;if(s[i])return o.dialog.alert(o.Msg.FUNCTION_WARNING_DUPLICATE_ARG),!1;s[i]=!0}return s[i]?(o.dialog.alert(o.Msg.FUNCTION_WARNING_ARG_NAME_IS_FUNCTION_NAME),!1):!g(e,null,t.getAttribute("functionid"))[i]||(o.dialog.alert(o.Msg.VARIABLE_ALREADY_EXISTS.replace("%1",i)),!1)},i.isVariableBlockType=function(t){switch(t){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 y extends o.Events.Abstract{constructor(t,e,i,o,s){super(),this.definition=t,this.callers=e,this.oldMutation=i,this.newMutation=o,this.descendantChanges=s,this.type="pxt_mutate_function"}static fromJson(t,e,i){const o=i=super.fromJson(t,e,i||new y(t.definition,t.callers,t.oldMutation,t.newMutation,t.descendantChanges));return o.definition=t.definition,o.callers=t.callers,o.oldMutation=t.oldMutation,o.newMutation=t.newMutation,o.descendantChanges=t.descendantChanges,i}toJson(){return{type:this.type,group:this.group,definition:this.definition,callers:this.callers,oldMutation:this.oldMutation,newMutation:this.newMutation,descendantChanges:this.descendantChanges}}run(t){const e=this.getEventWorkspace_(),i=o.utils.xml.textToDom(t?this.newMutation:this.oldMutation),s=e.getBlockById(this.definition);o.Events.disable(),s.domToMutation(i),s.updateArgumentInputs_(),s.afterWorkspaceLoad();for(const s of this.callers){const n=e.getBlockById(s.id);if(t)n.domToMutation(i);else{n.domToMutation(o.utils.xml.textToDom(s.oldMutation));for(const t of s.shadows)if(t.connectedBlock){const i=e.getBlockById(t.connectedBlock);n.getInput(t.inputName).connection.connect(i.outputConnection)}else n.getInput(t.inputName).connection.setShadowState(t.connectedShadow)}}for(const i of this.descendantChanges)if(i.newName){e.getBlockById(i.id).setFieldValue(t?i.newName:i.oldName,"VALUE")}else if(t){const t=e.getBlockById(i.id);t&&t.dispose()}else{const t=e.newBlock(i.type,i.id);t.setFieldValue(i.oldName,"VALUE"),t.initSvg();const o=e.getBlockById(i.targetBlockId).getInput(i.targetInputName).connection,s=o.targetBlock();s&&(s.isShadow()||s.dispose()),o.connect(t.outputConnection)}o.Events.enable()}}},{"../../compiler/util":15,"../../loader":79,"./blocks/functionDeclarationBlock":118,"./constants":121,"./functionManager":126,"./msg":128,blockly:192}],131:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly");o.Extensions.unregister("logic_compare"),o.Extensions.register("logic_compare",function(){})},{blockly:192}],132:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../../fields/field_imagenotext"),n=t("../../utils"),r={elseifCount_:0,elseCount_:0,valueConnections_:[],statementConnections_:[],elseStatementConnection_:null,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=o.utils.xml.createElement("mutation");return this.elseifCount_&&t.setAttribute("elseif",this.elseifCount_+""),this.elseCount_&&t.setAttribute("else","1"),t},domToMutation:function(t){t&&(this.elseifCount_=parseInt(t.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(t.getAttribute("else"),10)||0,this.rebuildShape_())},storeConnections_:function(t){t||(t=0),this.valueConnections_=[null],this.statementConnections_=[null],this.elseStatementConnection_=null;for(let e=1;e<=this.elseifCount_;e++)t!=e&&(this.valueConnections_.push(this.getInput("IF"+e).connection.targetConnection),this.statementConnections_.push(this.getInput("DO"+e).connection.targetConnection));this.getInput("ELSE")&&(this.elseStatementConnection_=this.getInput("ELSE").connection.targetConnection)},restoreConnections_:function(){var t,e;for(let e=1;e<=this.elseifCount_;e++)this.reconnectValueConnection_(e,this.valueConnections_),null===(t=this.statementConnections_[e])||void 0===t||t.reconnect(this,"DO"+e);this.getInput("ELSE")&&(null===(e=this.elseStatementConnection_)||void 0===e||e.reconnect(this,"ELSE"))},addElse_:function(){o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch added."));this.update_(()=>{this.elseCount_++})},removeElse_:function(){var t,e;o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch removed."));this.update_(()=>{this.elseCount_--});const i="IF"+this.elseifCount_;(0,n.maybeMoveFocusFromButton)(null===(e=null===(t=this.getInput(i))||void 0===t?void 0:t.connection)||void 0===e?void 0:e.targetBlock())},addElseIf_:function(){o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch added."));this.update_(()=>{this.elseifCount_++})},removeElseIf_:function(t){var e,i;o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch removed."));this.update_(()=>{this.elseifCount_--},t);const s="IF"+(t-1);(0,n.maybeMoveFocusFromButton)(null===(i=null===(e=this.getInput(s))||void 0===e?void 0:e.connection)||void 0===i?void 0:i.targetBlock())},update_:function(t,e){o.Events.setGroup(!0),this.storeConnections_(e);const i=this,s=i.mutationToDom(),n=s&&o.Xml.domToText(s);t&&t.call(this),this.updateShape_(),i instanceof o.BlockSvg&&i.initSvg();const r=o.Events.getGroup(),a=i.mutationToDom(),l=a&&o.Xml.domToText(a);n!=l&&(o.Events.fire(new o.Events.BlockChange(i,"mutation",null,n,l)),setTimeout(function(){o.Events.setGroup(r),i.bumpNeighbours(),o.Events.setGroup(!1)},o.config.bumpDelay)),i.rendered&&i instanceof o.BlockSvg&&i.queueRender(),this.restoreConnections_(),o.Events.setGroup(!1)},updateShape_:function(){this.getInput("ELSE")&&(this.removeInput("ELSE"),this.removeInput("ELSETITLE"),this.removeInput("ELSEBUTTONS"));let t=1;for(;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("IFTITLE"+t),this.removeInput("IFBUTTONS"+t),this.removeInput("DO"+t),t++;for(let t=1;t<=this.elseifCount_;t++){const i=function(t){return function(){e.removeElseIf_(t)}}(t);this.appendValueInput("IF"+t).setCheck("Boolean").appendField(o.Msg.CONTROLS_IF_MSG_ELSEIF).setShadowDom(a()),this.appendDummyInput("IFTITLE"+t).appendField(o.Msg.CONTROLS_IF_MSG_THEN),this.appendDummyInput("IFBUTTONS"+t).appendField(new s.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else if branch"),i,!1)).setAlign(o.inputs.Align.RIGHT),this.appendStatementInput("DO"+t)}this.elseCount_&&(this.appendDummyInput("ELSETITLE").appendField(o.Msg.CONTROLS_IF_MSG_ELSE),this.appendDummyInput("ELSEBUTTONS").setAlign(o.inputs.Align.RIGHT).appendField(new s.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 e=this,i=function(){var t,i,s;if(0==e.elseCount_)e.addElse_(),(0,n.maybeMoveFocusFromButton)(null===(t=e.getInput("ELSEBUTTONS"))||void 0===t?void 0:t.fieldRow[0]);else{e.elseifCount_||(e.elseifCount_=0),e.addElseIf_();const t=o.getFocusManager(),n=null===(s=null===(i=e.getInput("IF"+e.elseifCount_))||void 0===i?void 0:i.connection)||void 0===s?void 0:s.targetBlock();t.focusNode(n)}};this.appendDummyInput("ADDBUTTON").appendField(new s.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,this.elseCount_?pxt.Util.lf("add else if branch"):pxt.Util.lf("add else branch"),i,!1))},rebuildShape_:function(){const t=[null],e=[null];let i=null;this.getInput("ELSE")&&(i=this.getInput("ELSE").connection.targetConnection);let o=1;for(;this.getInput("IF"+o);){const i=this.getInput("IF"+o),s=this.getInput("DO"+o);t.push(i.connection.targetConnection),e.push(s.connection.targetConnection),o++}this.updateShape_(),this.reconnectChildBlocks_(t,e,i)},reconnectChildBlocks_:function(t,e,i){var o;for(let i=1;i<=this.elseifCount_;i++)this.reconnectValueConnection_(i,t),null===(o=e[i])||void 0===o||o.reconnect(this,"DO"+i);null==i||i.reconnect(this,"ELSE")},reconnectValueConnection_:function(t,e){var i;const o=null===(i=this.getInput("IF"+t))||void 0===i?void 0:i.connection.targetBlock();e[t]&&(e[t].reconnect(this,"IF"+t),o&&!o.getParent()&&o.dispose())}};function a(){const t=document.createElement("shadow");t.setAttribute("type","logic_boolean");const e=document.createElement("field");return e.setAttribute("name","BOOL"),e.textContent="FALSE",t.appendChild(e),t}o.Blocks.controls_if=Object.assign(Object.assign({},r),{init(){if(o.Extensions.apply("inline-svgs",this,!1),this.elseifCount_=0,this.elseCount_=0,this.setHelpUrl(o.Msg.CONTROLS_IF_HELPURL),this.appendValueInput("IF0").setCheck("Boolean").appendField(o.Msg.CONTROLS_IF_MSG_IF),this.appendDummyInput("THEN0").appendField(o.Msg.CONTROLS_IF_MSG_THEN),this.appendStatementInput("DO0"),this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer();this.setOutputShape(t.getConstants().SHAPES.HEXAGONAL)}this.updateShape_(),this.setInputsInline(!0),this.setColour(o.Msg.LOGIC_HUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(()=>this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_4:"":o.Msg.CONTROLS_IF_TOOLTIP_1)}})},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],133:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./extensions"),i),s(t("./ifElse"),i)},{"./extensions":131,"./ifElse":132}],134:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldSlider=void 0;const o=t("blockly");class s extends o.FieldNumber{constructor(t,e,i,o,s,n,r,a){super(t,e,i,o,r,a),this.keyboardControlActive=!1,"string"==typeof s?this.step_=parseFloat(s):"number"==typeof s&&(this.step_=s),this.labelText_=n}hasMin(){return this.getMin()>-1/0}hasMax(){return this.getMax()<1/0}getStep(){return this.step_}getLabel(){return this.labelText_}setLabel(t){this.labelText_=t}setOptions(t,e,i,o){this.setConstraints(t,e,o),this.step_=parseFloat(i)||void 0}getFieldDescription(){return this.getValue()+""}doClassValidation_(t){if(null===t)return null;t=(t=(t=(t=`${t}`).replace(/O/gi,"0")).replace(/,/g,"")).replace(/infinity/i,"Infinity");let e=Number(t||0);if(isNaN(e))return null;this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_);let i=String(this.precision_);-1!==i.indexOf("e")&&(i=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const o=i.indexOf(".");let s;return s=-1===o?this.precision_?0:null:i.length-o-1,null!==s&&(e=Number(e.toFixed(s))),e}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(t){"ArrowDown"===t.key&&(t.preventDefault(),this.keyboardControlActive=!0,this.slider_.focus())}sliderPointerdownListener(t){this.keyboardControlActive=!1}sliderKeydownListener(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.htmlInput_.focus();break;case"Enter":case" ":t.preventDefault(),t.stopPropagation(),o.hideChaff();break;case"ArrowDown":t.preventDefault(),t.stopPropagation()}}sliderBlurListener(t){this.keyboardControlActive=!1}showEditor_(t,e){super.showEditor_(t,!0),"number"==typeof this.min_&&"number"==typeof this.max_&&(this.htmlInput_.ariaLabel=lf("Enter a value between {0} and {1}",this.min_,this.max_)),o.DropDownDiv.hideWithoutAnimation(),o.DropDownDiv.clearContent();const i=o.DropDownDiv.getContentDiv();i.style.height="",i.parentElement.classList.add("blocklyFieldSliderDropdown"),this.addSlider_(i),o.DropDownDiv.setColour("#ffffff","#dddddd"),o.DropDownDiv.showPositionedByBlock(this,this.sourceBlock_,void 0,void 0,!1),this.addEventListeners(),e||(this.htmlInput_.focus(),this.htmlInput_.select())}addSlider_(t){if(this.labelText_){let e=this.createLabelDom_(this.labelText_);t.appendChild(e[0]),this.readout_=e[1],this.setReadout(this.value_)}this.slider_=this.createSlider(),t.appendChild(this.slider_);const e=()=>{pxt.BrowserUtils.isFirefox()||this.keyboardControlActive||this.htmlInput_.focus()};o.browserEvents.bind(this.slider_,"input",this,t=>{const i=parseFloat(this.slider_.value)||0;if(null!==i){this.setValue(i);const t=this.htmlInput_;t&&(t.value=i+"",e())}}),o.browserEvents.bind(this.slider_,"focus",this,t=>{e()})}setValue(t,e){super.setValue(t,e),this.updateDom(),this.slider_&&(this.slider_.value=this.getValue()+"")}createSlider(){const t=document.createElement("input");let e;return t.setAttribute("class","blocklyFieldSlider"),t.type="range",t.min=this.getMin()+"",t.max=this.getMax()+"",t.value=this.getValue()+"",this.sourceBlock_ instanceof o.BlockSvg&&("#ffffff"===this.sourceBlock_.getColour()?this.sourceBlock_.getParent()&&(e=this.sourceBlock_.getParent().getColourTertiary()):e=this.sourceBlock_.getColourTertiary()),e&&t.setAttribute("style",`--blocklyFieldSliderBackgroundColor: ${e}`),Number.isNaN(this.step_)||(t.step=this.step_+""),t}updateDom(){this.setReadout(this.getValue())}setReadout(t){this.readout_&&(this.readout_.innerText=t+"")}createLabelDom_(t){const e=document.createElement("div");e.setAttribute("class","blocklyFieldSliderLabel");const i=document.createElement("span");i.setAttribute("class","blocklyFieldSliderReadout");const o=document.createElement("span");return o.setAttribute("class","blocklyFieldSliderLabelText"),o.innerText=t,e.appendChild(o),e.appendChild(i),[e,i]}}i.FieldSlider=s,o.fieldRegistry.register("field_slider",s),o.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(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldSlider"),i),s(t("./numberBlocks"),i)},{"./fieldSlider":134,"./numberBlocks":136}],136:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=new o.zelos.ConstantProvider;o.defineBlocksWithJsonArray([{type:"math_integer",message0:"%1",args0:[{type:"field_number",name:"NUM",precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:s.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:s.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:s.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:s.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 n={mutationToDom:function(){const t=this.inputList[0].fieldRow[0];let e=o.utils.xml.createElement("mutation");return t.hasMin()&&e.setAttribute("min",t.getMin()+""),t.hasMax()&&e.setAttribute("max",t.getMax()+""),null!=t.getLabel()&&e.setAttribute("label",t.getLabel()),null!=t.getStep()&&e.setAttribute("step",t.getStep()+""),null!=t.getPrecision()&&e.setAttribute("precision",t.getPrecision()+""),e},domToMutation:function(t){const e=this.inputList[0].fieldRow[0],i=t.getAttribute("min"),o=t.getAttribute("max"),s=t.getAttribute("step"),n=t.getAttribute("label"),r=t.getAttribute("precision");e.setLabel(n),e.setOptions(i,o,s,r)}};o.Extensions.registerMutator("math_number_minmax_mutator",n)},{blockly:192}],137:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldVariable=void 0;const o=t("blockly");class s extends o.FieldVariable{constructor(t,e,i,o,n){super(t,e,i,o,n),this.svgRootBinding=null,this.fieldRootBinding=null,this.menuGenerator_=s.dropdownCreate}static dropdownCreate(){const t=o.FieldVariable.dropdownCreate.call(this),e=t.findIndex(t=>"RENAME_VARIABLE_ID"===t[1]);return t.splice(e,0,[o.Msg.NEW_VARIABLE_DROPDOWN,s.CREATE_VARIABLE_ID],o.FieldDropdown.SEPARATOR),t}onItemSelected_(t,e){if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e.getValue()===s.CREATE_VARIABLE_ID)return void o.Variables.createVariableButtonHandler(this.sourceBlock_.workspace,t=>{const e=this.sourceBlock_.workspace.getVariableMap().getVariable(t);e&&this.setValue(e.getId())})}super.onItemSelected_(t,e)}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 t of this.sourceBlock_.inputList)for(const e of t.fieldRow)if(e!==this&&e.EDITABLE)return!0;return!this.sourceBlock_.getInputsInline()||super.shouldAddBorderRect_()}bindEvents_(){this.shouldAddBorderRect_()?super.bindEvents_():(this.svgRootBinding=o.browserEvents.conditionalBind(this.sourceBlock_.getSvgRoot(),"pointerdown",this,t=>{this.sourceBlock_.icons.length||this.onMouseDown_(t)},!1),this.fieldRootBinding=o.browserEvents.conditionalBind(this.getSvgRoot(),"pointerdown",this,t=>{this.sourceBlock_.icons.length&&this.onMouseDown_(t)},!1))}dispose(){super.dispose(),this.svgRootBinding&&(o.browserEvents.unbind(this.svgRootBinding),o.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 t,e;const i=super.getValue();if(null===(t=this.sourceBlock_)||void 0===t?void 0:t.isInFlyout){if((null===(e=this.sourceBlock_.workspace)||void 0===e?void 0:e.getPotentialVariableMap()).getVariableById(i))return"potential_"+i}return i}}i.FieldVariable=s,s.CREATE_VARIABLE_ID="CREATE_VARIABLE",o.fieldRegistry.unregister("field_variable"),o.fieldRegistry.register("field_variable",s)},{blockly:192}],138:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldVariable"),i)},{"./fieldVariable":137}],139:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isCollapsedInputRow=i.CollapsedInputRow=void 0;const o=t("blockly");class s extends o.blockRendering.InputRow{constructor(t){super(t),this.type|=o.blockRendering.Types.INPUT_ROW|o.blockRendering.Types.getType("COLLAPSED_INPUT_ROW")}measure(){this.width=this.minWidth,this.height=this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT}}i.CollapsedInputRow=s,i.isCollapsedInputRow=function(t){return!!(t.type&o.blockRendering.Types.getType("COLLAPSED_INPUT_ROW"))}},{blockly:192}],140:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConnectionPreviewer=void 0;const o=t("blockly");class s extends o.InsertionMarkerPreviewer{previewConnection(t,e){super.previewConnection(t,e),e.type!==o.ConnectionType.INPUT_VALUE&&e.type!==o.ConnectionType.OUTPUT_VALUE||this.showDraggedIndicatorWithLine(t,e)}previewReplacement(t,e,i){super.previewReplacement(t,e,i),this.showDraggedIndicatorWithLine(t,e)}showDraggedIndicatorWithLine(t,e){if(!this.connectionLine){this.connectionLine=o.utils.dom.createSvgElement("line",{class:"blocklyConnectionLine",x1:0,y1:0,x2:0,y2:0},t.sourceBlock_.getSvgRoot()),this.draggedConnectionIndicator=this.createConnectionIndicator(t.sourceBlock_.getSvgRoot(),t);const i=e.sourceBlock_.getSvgRoot().querySelector(":scope>.blocklyConnectionIndicatorParent");this.staticConnectionIndicator=this.createConnectionIndicator(i,e)}this.raiseIndicators(),this.updateLineCoords(t,e),o.renderManagement.finishQueuedRenders().then(()=>{this.connectionLine&&(this.raiseIndicators(),this.updateLineCoords(t,e))})}raiseIndicators(){var t,e;null===(t=this.draggedConnectionIndicator.parentElement)||void 0===t||t.appendChild(this.draggedConnectionIndicator);const i=this.staticConnectionIndicator.parentElement;i.appendChild(this.staticConnectionIndicator),null===(e=i.parentElement)||void 0===e||e.appendChild(i)}updateLineCoords(t,e){const i=s.CONNECTION_INDICATOR_RADIUS,n=t.getOffsetInBlock(),r=e.getOffsetInBlock();this.draggedConnectionIndicator.setAttribute("transform",`translate(${n.x}, ${n.y})`),this.staticConnectionIndicator.setAttribute("transform",`translate(${r.x}, ${r.y})`);const a=o.utils.Coordinate.sum(t.sourceBlock_.getRelativeToSurfaceXY(),n),l=o.utils.Coordinate.sum(e.sourceBlock_.getRelativeToSurfaceXY(),r),c=l.x-a.x,h=l.y-a.y;if(Math.sqrt(c*c+h*h)<2*i+1)return void o.utils.dom.addClass(this.connectionLine,"hidden");o.utils.dom.removeClass(this.connectionLine,"hidden");const u=Math.atan2(h,c);this.connectionLine.setAttribute("x1",String(n.x+Math.cos(u)*i)),this.connectionLine.setAttribute("y1",String(n.y+Math.sin(u)*i)),this.connectionLine.setAttribute("x2",String(n.x+c-Math.cos(u)*i)),this.connectionLine.setAttribute("y2",String(n.y+h-Math.sin(u)*i))}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(t,e){const i=o.utils.dom.createSvgElement("g",{class:"blocklyInputConnectionIndicator"},t);o.utils.dom.createSvgElement("circle",{r:s.CONNECTION_INDICATOR_RADIUS},i);const n=e.getOffsetInBlock();return i.setAttribute("transform","translate("+n.x+","+n.y+")"),i}}i.ConnectionPreviewer=s,s.CONNECTION_INDICATOR_RADIUS=9},{blockly:192}],141:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConstantProvider=void 0;const o=t("blockly");class s extends o.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(t,e,i){super.createDom(t,e,i);const s=o.utils.dom.createSvgElement(o.utils.Svg.DEFS,{},t);this.highlightOutlineFilter=this.createHighlight(s,"blocklyHighlightedGlowFilter",this.HIGHLIGHT_GLOW_COLOUR),this.highlightOutlineFilterId=this.highlightOutlineFilter.id,this.errorOutlineFilter=this.createHighlight(s,"blocklyErrorHighlightedGlowFilter",this.ERROR_HIGHLIGHT_GLOW_COLOR),this.errorOutlineFilterId=this.errorOutlineFilter.id,this.embossFilterOverride=this.createOutline(s,"blocklyBubbleEmbossGlowFilter"),this.embossFilterId=this.embossFilterOverride.id}dispose(){super.dispose(),this.highlightOutlineFilter&&o.utils.dom.removeNode(this.highlightOutlineFilter)}makeEllipses(){const t=this.ELLIPSES_RADIUS,e=this.ELLIPSES_SPACING;let i="";for(let s=0;s<3;s++)i+=o.utils.svgPaths.moveBy(e,0)+o.utils.svgPaths.arc("a","180 1,1",t,o.utils.svgPaths.point(2*t,0));for(let s=0;s<3;s++)i+=o.utils.svgPaths.arc("a","180 1,1",t,o.utils.svgPaths.point(2*-t,0))+o.utils.svgPaths.moveBy(-e,0);return i}getCSS_(t){return super.getCSS_(t).concat([t+" .blocklyConnectionIndicator, "+t+" .blocklyInputConnectionIndicator {","fill: #ff0000;","stroke: #ffff00;","stroke-width: 3px;","}",t+" .blocklyConnectionIndicator {","display: none;","}",t+" .blocklyBlockDragSurface > g > .blocklyDraggable > .blocklyConnectionIndicator {","display: block;","}",t+" .blocklyConnectionLine {","stroke: #ffff00;","stroke-width: 4px;","}",t+" .blocklyConnectionLine.hidden {","display: none;","}",t+" .blocklyFlyoutHeading .blocklyFlyoutLabelText {font-size: 1.5rem;","}",`${t} .blocklyText::selection {`,"fill: #fff;","}",`${t} .blocklyNonEditableField>text::selection,`,`${t} .blocklyEditableField>text::selection,`,`${t} .blocklyNonEditableField>g>text::selection,`,`${t} .blocklyEditableField>g>text::selection {`,"fill: #575E75;","}",`${t} .blocklyDropdownText::selection {`,"fill: #fff !important;","}"])}createHighlight(t,e,i){const s=o.utils.dom.createSvgElement(o.utils.Svg.FILTER,{id:e+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t);o.utils.dom.createSvgElement(o.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.HIGHLIGHT_GLOW_SIZE},s);const n=o.utils.dom.createSvgElement(o.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},s);return o.utils.dom.createSvgElement(o.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},n),o.utils.dom.createSvgElement(o.utils.Svg.FEFLOOD,{"flood-color":i,"flood-opacity":1,result:"outColor"},s),o.utils.dom.createSvgElement(o.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},s),s}createOutline(t,e){const i=o.utils.dom.createSvgElement(o.utils.Svg.FILTER,{id:e+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t);o.utils.dom.createSvgElement(o.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:.92},i);const s=o.utils.dom.createSvgElement(o.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},i);o.utils.dom.createSvgElement(o.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),o.utils.dom.createSvgElement(o.utils.Svg.FEFLOOD,{"flood-color":"#000000","flood-opacity":.5,result:"outColor"},i),o.utils.dom.createSvgElement(o.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},i);const n=o.utils.dom.createSvgElement("feMerge",{},i);return o.utils.dom.createSvgElement("feMergeNode",{in:"outBlur"},n),o.utils.dom.createSvgElement("feMergeNode",{in:"outGlow"},n),o.utils.dom.createSvgElement("feMergeNode",{in:"SourceGraphic"},n),i}shapeFor(t){let e=t.getCheck();switch(!e&&t.targetConnection&&(e=t.targetConnection.getCheck()),t.type){case o.ConnectionType.INPUT_VALUE:case o.ConnectionType.OUTPUT_VALUE:return e&&e.includes("Boolean")?this.HEXAGONAL:(e&&e.includes("Number")||e&&e.includes("String"),this.ROUNDED);case o.ConnectionType.PREVIOUS_STATEMENT:case o.ConnectionType.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}}i.ConstantProvider=s,s.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",s.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});t("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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Drawer=void 0;const o=t("blockly"),s=t("./collapsedInputRow");class n extends o.zelos.Drawer{drawCollapsedStack_(t){const e=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.constants_.INSIDE_CORNERS.width,i=this.constants_.STATEMENT_INPUT_PADDING_LEFT+2*this.constants_.INSIDE_CORNERS.width+o.utils.svgPaths.lineOnAxis("h",-this.constants_.INSIDE_CORNERS.width)+this.constants_.INSIDE_CORNERS.pathTop,s=t.height-2*this.constants_.INSIDE_CORNERS.height,n=this.constants_.INSIDE_CORNERS.pathBottom+o.utils.svgPaths.lineOnAxis("h",this.constants_.INSIDE_CORNERS.width),r=this.constants_.ellipses;this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.bottomRight+o.utils.svgPaths.lineOnAxis("H",e)+i+o.utils.svgPaths.lineOnAxis("v",s/2)+r+o.utils.svgPaths.lineOnAxis("v",s/2)+n+o.utils.svgPaths.lineOnAxis("H",t.xPos+t.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 t=1;t<this.info_.rows.length-1;t++){const e=this.info_.rows[t];e.hasJaggedEdge?this.drawJaggedEdge_(e):(0,s.isCollapsedInputRow)(e)?this.drawCollapsedStack_(e):e.hasStatement?this.drawStatementInput_(e):e.hasExternalInput?this.drawValueInput_(e):this.drawRightSideRow_(e)}this.drawBottom_(),this.drawLeft_()}}drawLeft_(){super.drawLeft_();if(this.info_.rows.find(function(t){return(0,s.isCollapsedInputRow)(t)})){let t=this.info_.startY;o.blockRendering.Types.isLeftRoundedCorner(this.info_.topRow.elements[0])&&(t+=this.constants_.OUTSIDE_CORNERS.rightHeight),this.outlinePath_=this.outlinePath_.slice(0,-1),this.outlinePath_+=o.utils.svgPaths.lineOnAxis("V",t)}}}i.Drawer=n},{"./collapsedInputRow":139,blockly:192}],144:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./renderer"),i),s(t("./connectionPreviewer"),i),s(t("./css"),i)},{"./connectionPreviewer":140,"./css":142,"./renderer":147}],145:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RenderInfo=void 0;const o=t("blockly"),s=t("./collapsedInputRow");class n extends o.zelos.RenderInfo{measure(){if(this.block_)for(const t of this.block_.inputList)t.init();super.measure()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let t=new o.blockRendering.InputRow(this.constants_);this.inputRows.push(t);const e=this.block_.getIcons();for(let i,s=0;i=e[s];s++){const e=new o.blockRendering.Icon(this.constants_,i);this.isCollapsed&&!i.isShownWhenCollapsed()||t.elements.push(e)}let i;for(let e,s=0;e=this.block_.inputList[s];s++)if(e.isVisible()){this.shouldStartNewRow_(e,i)&&(this.rows.push(t),t=new o.blockRendering.InputRow(this.constants_),this.inputRows.push(t));for(let i,s=0;i=e.fieldRow[s];s++)t.elements.push(new o.blockRendering.Field(this.constants_,i,e));this.addInput_(e,t),i=e}if(this.isCollapsed){this.block_.inputList.find(function(t){return t.type==o.inputs.inputTypes.STATEMENT})?t=this.addCollapsedRow_(t):(t.hasJaggedEdge=!0,t.elements.push(new o.blockRendering.JaggedEdge(this.constants_)))}(t.elements.length||t.hasDummyInput)&&this.rows.push(t),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;const t=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof o.inputs.StatementInput||this.rows.some(t=>(0,s.isCollapsedInputRow)(t));this.bottomRow.minHeight=t?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new o.blockRendering.SquareCorner(this.constants_)):this.bottomRow.elements.push(new o.blockRendering.RoundCorner(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new o.blockRendering.NextConnection(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new o.blockRendering.SquareCorner(this.constants_,"right")):this.bottomRow.elements.push(new o.blockRendering.RoundCorner(this.constants_,"right"))}addCollapsedRow_(t){this.rows.push(t);const e=new s.CollapsedInputRow(this.constants_);return e.hasDummyInput=!0,e}}i.RenderInfo=n},{"./collapsedInputRow":139,blockly:192}],146:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PathObject=void 0;const o=t("blockly"),s="blockly-dotted-outline-on-hover",n="hover";class r extends o.zelos.PathObject{constructor(){super(...arguments),this.connectionPointIndicators=new WeakMap}setPath(t){super.setPath(t),this.svgPathHighlighted&&this.svgPathHighlighted.setAttribute("d",t)}updateHighlighted(t){if(t){if(!this.svgPathHighlighted){const t=this.constants,e=this.hasError?t.errorOutlineFilterId:t.highlightOutlineFilterId;this.svgPathHighlighted=this.svgPath.cloneNode(!0),this.svgPathHighlighted.classList.add("pxtRendererHighlight"),this.svgPathHighlighted.setAttribute("fill","none"),this.svgPathHighlighted.setAttribute("filter","url(#"+e+")"),this.svgRoot.appendChild(this.svgPathHighlighted)}}else this.svgPathHighlighted&&(this.svgRoot.removeChild(this.svgPathHighlighted),this.svgPathHighlighted=null)}updateSelected(t){t&&this.svgPath.classList.remove(n),super.updateSelected(t)}addConnectionHighlight(t,e,i,s){const n=super.addConnectionHighlight(t,e,i,s);return this.staticConnectionIndicatorParentGroup?this.svgRoot.appendChild(this.staticConnectionIndicatorParentGroup):this.staticConnectionIndicatorParentGroup=o.utils.dom.createSvgElement("g",{class:"blocklyConnectionIndicatorParent"},this.svgRoot),n}removeConnectionHighlight(t){var e;null===(e=this.staticConnectionIndicatorParentGroup)||void 0===e||e.remove(),super.removeConnectionHighlight(t)}applyColour(t){if(super.applyColour(t),t.outputConnection){let e=!1;const i=t.getParent();if(i)if(t.isShadow()){const t=i.style.colourTertiary,s=function(t){return(.2126*t[0]+.7152*t[1]+.0722*t[2])/255}(o.utils.colour.hexToRgb(t));s<.15&&(this.svgPath.setAttribute("stroke",o.utils.colour.blend("#ffffff",t,.3)),e=!0)}else{const s=i.style.colourPrimary,n=t.style.colourPrimary;if(s===n){const t=.6,i=o.utils.colour.blend("#0000000",n,t),r=o.utils.colour.blend("#ffffff",n,t);pxt.contrastRatio(i,s)>pxt.contrastRatio(r,s)?this.svgPath.setAttribute("stroke",i):this.svgPath.setAttribute("stroke",r),e=!0}}e||this.svgPath.setAttribute("stroke",t.style.colourTertiary)}}setHasDottedOutlineOnHover(t){this.hasDottedOutlineOnHover=t,t?(this.svgPath.classList.add(s),this.mouseOverData||(this.mouseOverData=o.browserEvents.bind(this.svgRoot,"mouseover",this,()=>{this.svgPath.classList.add(n)}),this.mouseLeaveData=o.browserEvents.bind(this.svgRoot,"mouseleave",this,()=>{this.svgPath.classList.remove(n)}))):(this.svgPath.classList.remove(s),this.mouseOverData&&(o.browserEvents.unbind(this.mouseOverData),o.browserEvents.unbind(this.mouseLeaveData),this.mouseOverData=void 0,this.mouseLeaveData=void 0),this.svgPath.classList.remove(s))}setHasError(t){this.hasError=t}isHighlighted(){return!!this.svgPathHighlighted}}i.PathObject=r,r.CONNECTION_INDICATOR_RADIUS=9,o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Renderer=void 0;const o=t("blockly"),s=t("./pathObject"),n=t("./constants"),r=t("./info"),a=t("./drawer");class l extends o.zelos.Renderer{makePathObject(t,e){return new s.PathObject(t,e,this.getConstants())}makeConstants_(){return new n.ConstantProvider}makeRenderInfo_(t){return new r.RenderInfo(this,t)}makeDrawer_(t,e){return new a.Drawer(t,e)}render(t){t.updateBeforeRender&&t.updateBeforeRender(),super.render(t)}}i.Renderer=l,o.blockRendering.register("pxt",l)},{"./constants":141,"./drawer":143,"./info":145,"./pathObject":146,blockly:192}],148:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldString=void 0;const o=t("blockly");class s extends o.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_=o.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_=o.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_(t){super.updateSize_(t);const e=this.value_?this.size_.width:1;let i=this.positionLeft(e+3);this.textElement_.setAttribute("x",i+""),i+=this.positionRight(i+e+3),this.size_.width=e+i}positionLeft(t){if(!this.quoteLeft_)return 0;let e=0;return this.sourceBlock_.RTL?(this.quoteLeftX_=t+this.quoteWidth_+2*s.quotePadding,e=this.quoteWidth_+s.quotePadding):(this.quoteLeftX_=0,e=this.quoteWidth_+s.quotePadding),this.quoteLeft_.setAttribute("transform","translate("+this.quoteLeftX_+","+this.quoteY_+")"),e}positionRight(t){if(!this.quoteRight_)return 0;let e=0;return this.sourceBlock_.RTL?(this.quoteRightX_=s.quotePadding,e=this.quoteWidth_+s.quotePadding):(this.quoteRightX_=t+s.quotePadding,e=this.quoteWidth_+s.quotePadding),this.quoteRight_.setAttribute("transform","translate("+this.quoteRightX_+","+this.quoteY_+")"),e}}i.FieldString=s,s.quotePadding=0,o.Css.register("\n.field-text-quote {\n fill: #a31515 !important;\n}\n"),o.fieldRegistry.register("field_string",s)},{blockly:192}],149:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldString"),i),s(t("./text"),i),s(t("./join"),i)},{"./fieldString":148,"./join":150,"./text":151}],150:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../../fields/field_imagenotext"),n=t("../../utils"),r={itemCount_:0,valueConnections_:[],buttons:null,delta:0,mutationToDom:function(){const t=o.utils.xml.createElement("mutation");return t.setAttribute("items",this.itemCount_+""),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},storeValueConnections_:function(){this.valueConnections_=[];for(let t=0;t<this.itemCount_;t++)this.valueConnections_.push(this.getInput("ADD"+t).connection.targetConnection)},restoreValueConnections_:function(){var t;for(let e=0;e<this.itemCount_;e++)null===(t=this.valueConnections_[e])||void 0===t||t.reconnect(this,"ADD"+e)},addItem_:function(){this.storeValueConnections_();if(this.delta=1,this.update_(()=>{this.itemCount_++}),this.restoreValueConnections_(),this.itemCount_>1){const t=this.getInput("ADD0");if(t&&t.connection.targetConnection){const e=this.getInput("ADD"+(this.itemCount_-1)),i=t.connection.getShadowDom();if(i){const t=o.utils.xml.createElement("shadow"),s=i.getAttribute("type");t.setAttribute("type",s),t&&(t.setAttribute("id",o.utils.idGenerator.genUid()),e.connection.setShadowDom(t))}}}},removeItem_:function(){this.storeValueConnections_();this.delta=-1,this.update_(()=>{this.itemCount_--}),this.restoreValueConnections_()},update_:function(t){o.Events.setGroup(!0);const e=this,i=e.mutationToDom(),s=i&&o.Xml.domToText(i);t&&t.call(this),this.updateShape_(),e instanceof o.BlockSvg&&e.initSvg();const r=o.Events.getGroup(),a=e.mutationToDom(),l=a&&o.Xml.domToText(a);s!=l&&(o.Events.fire(new o.Events.BlockChange(e,"mutation",null,s,l)),setTimeout(function(){o.Events.setGroup(r),e.bumpNeighbours(),o.Events.setGroup(!1)},o.config.bumpDelay)),e.rendered&&e instanceof o.BlockSvg&&e.queueRender().then(()=>{if(this.buttons){let t=this.buttons.fieldRow[0];this.buttons.fieldRow.length>1&&(t=this.delta<0?t:this.buttons.fieldRow[1]),(0,n.maybeMoveFocusFromButton)(t),this.buttons=null,this.delta=0}}),o.Events.setGroup(!1)},updateShape_:function(){const t=this,e=function(){t.removeItem_()};let i;for(this.getInput("EMPTY")&&this.removeInput("EMPTY"),this.getInput("TITLE")||this.appendDummyInput("TITLE").appendField(o.Msg.TEXT_JOIN_TITLE_CREATEWITH),i=0;i<this.itemCount_;i++)if(!this.getInput("ADD"+i)){this.appendValueInput("ADD"+i).setAlign(o.inputs.Align.LEFT).setAriaLabelProvider(o.Msg.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(i+1).toString()))}for(;this.getInput("ADD"+i);)this.removeInput("ADD"+i),i++;this.getInput("BUTTONS")&&this.removeInput("BUTTONS"),this.buttons=this.appendDummyInput("BUTTONS"),this.itemCount_>1&&this.buttons.appendField(new s.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,lf("remove argument"),e,!1)),this.buttons.appendField(new s.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,lf("add argument"),function(){t.addItem_()},!1));const n=this.itemCount_<=4;if(this.setInputsInline(n),this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer();this.setOutputShape(n?t.getConstants().SHAPES.ROUND:t.getConstants().SHAPES.SQUARE)}}};o.Extensions.registerMutator("pxt_text_join_mutator",r,function(){o.Extensions.apply("inline-svgs",this,!1),this.itemCount_=2,this.updateShape_()}),o.defineBlocksWithJsonArray([{type:"text_join",message0:"",output:"String",outputShape:(new o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly");o.defineBlocksWithJsonArray([{type:"text",message0:"%1",args0:[{type:"field_string",name:"TEXT",text:""}],output:"String",outputShape:(new o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.blocksMetrics=i.render=i.renderWorkspace=i.cleanRenderingWorkspace=i.initRenderingWorkspace=void 0;const o=t("blockly"),s=t("./layout"),n=t("./importer");let r,a;function l(){return r||(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),r=o.inject(a,{move:{scrollbars:!1},readOnly:!0,sounds:!1,media:pxt.webConfig.commitCdnUrl+"blockly/media/",rtl:pxt.Util.isUserLanguageRtl(),renderer:"pxt"})),(0,n.clearWithoutEvents)(r),r}function c(){r&&r.dispose(),r=void 0}function h(t={emPixels:18,layout:1}){switch(t.splitSvg?1:t.layout||4){case 1:(0,s.verticalAlign)(r,t.emPixels||18);break;case 4:(0,s.flow)(r,{ratio:t.aspectRatio,useViewWidth:t.useViewWidth});break;case 3:r.cleanUp_&&r.cleanUp_()}let e=r.getMetrics();const i=a.querySelectorAll("svg")[0],o=i.cloneNode(!0);return(0,s.cleanUpBlocklySvg)(o,i),pxt.U.toArray(o.querySelectorAll(".blocklyBlockCanvas,.blocklyBubbleCanvas")).forEach(t=>t.setAttribute("transform",`translate(${-e.contentLeft}, ${-e.contentTop}) scale(1)`)),o.setAttribute("viewBox",`0 0 ${e.contentWidth} ${e.contentHeight}`),t.emPixels&&(o.style.width=e.contentWidth/t.emPixels+"em",o.style.height=e.contentHeight/t.emPixels+"em"),t.splitSvg?(0,s.splitSvg)(o,r,t.emPixels):o}i.initRenderingWorkspace=l,i.cleanRenderingWorkspace=c,i.renderWorkspace=h,i.render=function(t,e={emPixels:18,layout:1}){l();try{let i=t||'<xml xmlns="http://www.w3.org/1999/xhtml"></xml>',s=o.utils.xml.textToDom(i);return(0,n.domToWorkspaceNoEvents)(s,r,{applyHideMetaComment:!0}),h(e)}catch(t){return void pxt.reportException(t)}finally{c()}},i.blocksMetrics=function(t){const e=t.getTopBlocks(!1);if(!e.length)return{width:0,height:0};let i;return e.forEach(t=>{const e=t.getBoundingRectangle();i?(i.l=Math.min(i.l,e.left),i.r=Math.max(i.r,e.right),i.t=Math.min(i.t,e.top),i.b=Math.min(i.b,e.bottom)):i={l:e.left,r:e.right,t:e.top,b:e.bottom}}),{width:i.r-i.l,height:i.b-i.t}}},{"./importer":75,"./layout":77,blockly:192}],153:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.findBlockIdByLine=i.findBlockIdByPosition=void 0,i.findBlockIdByPosition=function(t,e){if(!e)return;let i,o;for(let s=0;s<t.length;++s){let n=t[s];n.startPos<=e.start&&n.endPos>=e.start+e.length&&(!i||o>n.endPos-n.startPos)&&(i=n,o=n.endPos-n.startPos)}return i?i.id:void 0},i.findBlockIdByLine=function(t,e){if(!e)return;let i,o;for(let s=0;s<t.length;++s){let n=t[s];n.startLine<=e.start&&n.endLine>e.start+e.length&&(!i||o>n.endLine-n.startLine)&&(i=n,o=n.endLine-n.startLine)}return i?i.id:void 0}},{}],154:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createFunctionsFlyoutCategory=i.mkReturnStatementBlock=i.mkVariableFieldBlock=i.mkFieldBlock=i.mkPredicateBlock=i.createToolboxBlock=i.createFlyoutGap=i.createFlyoutButton=i.createFlyoutGroupLabel=i.createFlyoutHeadingLabel=i.createShadowValue=i.isArrayType=void 0;const o=t("blockly"),s=t("./plugins/functions"),n=t("./loader"),r=/^(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(t){let e=/^(?:Array<(.+)>)|(?:(.+)\[\])|(?:\[.+\])$/.exec(t);return e?e[1]?e[1]:e[2]:void 0}function c(t,e,i,o,s,n=0){let r;if(o=o||e.defaultValue,!(i=i||e.shadowBlockId)&&e.range&&(i="math_number_minmax"),r=o&&'"'==o.slice(0,1)?JSON.parse(o):o,"number"==e.type&&"value"==i){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode("0")),t}if(e.fieldEditor){if(e.defaultValue){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode(e.defaultValue)),t}return}let c=pxt.Util.lookup(t.apis.byQName,e.type),u=6==(null==c?void 0:c.kind),d=c&&!!c.attributes.fixedInstances&&!e.shadowBlockId,p="@combined@"==e.type;if(!i&&(u||d||p)){if(o){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode(o)),t}return}const m="variables_get"==i,_="text"==i,f=document.createElement("value");f.setAttribute("name",e.definitionName);const T="lists_create_with"!==i&&i?void 0:l(e.type),b=document.createElement(!m&&!T||s?"shadow":"block");f.appendChild(b);const E=a[T||e.type];if(b.setAttribute("type",i||(T?"lists_create_with":E&&E.block||e.type)),b.setAttribute("colour","#fff"),T){if(E&&!i){let t;switch(T){case"number":t=["0","1"];break;case"string":t=["a","b","c"];break;case"boolean":t=["FALSE","FALSE","FALSE"]}return h(b,E.block,E.field,t),f}if(i&&r)return h(b,r),f}if(!E||i&&E.block!==i&&"math_number_minmax"!==i){if(r){const o=document.createElement("field");if(o.textContent=r,m)o.setAttribute("name","VAR"),b.appendChild(o);else if(_)o.setAttribute("name","TEXT"),b.appendChild(o);else if(i){const e=t.blocksById[i];if(e&&e.attributes._def&&e.attributes._def.parameters.length){const t=e.attributes._def.parameters[0];o.setAttribute("name",t.name),b.appendChild(o)}}else o.setAttribute("name",e.definitionName),b.appendChild(o)}}else{const t=document.createElement("field");let o,s;switch(b.appendChild(t),i){case"variables_get":o="VAR";break;case"math_number_minmax":o="SLIDER";break;default:o=E.field}t.setAttribute("name",o),s="boolean"==e.type?document.createTextNode((r||E.defaultValue).toUpperCase()):document.createTextNode(r||E.defaultValue),t.appendChild(s)}let y;if(e.range&&(y=document.createElement("mutation"),y.setAttribute("min",e.range.min.toString()),y.setAttribute("max",e.range.max.toString()),y.setAttribute("label",e.actualName.charAt(0).toUpperCase()+e.actualName.slice(1)),e.fieldOptions&&(e.fieldOptions.step&&y.setAttribute("step",e.fieldOptions.step),e.fieldOptions.color&&y.setAttribute("color",e.fieldOptions.color),e.fieldOptions.precision&&y.setAttribute("precision",e.fieldOptions.precision))),e.fieldOptions&&(y||(y=document.createElement("mutation")),y.setAttribute("customfield",JSON.stringify(e.fieldOptions))),y&&b.appendChild(y),n){const e=pxt.Util.toArray(f.getElementsByTagName("shadow"));for(const i of e)if(!i.innerHTML){const e=t.blocks.find(t=>t.attributes.blockId===i.getAttribute("type"));if(e){const o=g(t,e,pxt.blocks.compileInfo(e),!0,n-1);for(;o.firstChild;)i.appendChild(o.firstChild.cloneNode(!0)),o.firstChild.remove()}}}return f}function h(t,e,i,o){const s=o?o.length:2,n=document.createElement("mutation");n.setAttribute("items",""+s),n.setAttribute("horizontalafter",""+s),t.appendChild(n);for(let n=0;n<s;n++){const s=document.createElement("value");s.setAttribute("name","ADD"+n);const r=document.createElement("shadow");if(r.setAttribute("type",e),i){const t=document.createElement("field");t.setAttribute("name",i),o&&t.appendChild(document.createTextNode(o[n])),r.appendChild(t)}s.appendChild(r),t.appendChild(s)}}function u(t,e,i,o){const s=p(t,pxt.toolbox.convertColor(e),i,o);return s.setAttribute("web-class","blocklyFlyoutHeading"),s}function d(t,e,i,o){const s=p(t,void 0,e);return s.setAttribute("web-class","blocklyFlyoutGroup"),s.setAttribute("web-line","1.5"),i&&s.setAttribute("web-line-width",i),o&&(s.setAttribute("web-help-button","true"),s.setAttribute("callbackKey",o)),s}function p(t,e,i,s){let n=o.utils.xml.createElement("label");return n.setAttribute("text",t),e&&n.setAttribute("web-icon-color",pxt.toolbox.convertColor(e)),i&&(1===i.length?(n.setAttribute("web-icon",i),s&&n.setAttribute("web-icon-class",s)):(n.setAttribute("web-icon-class",`blocklyFlyoutIcon${t}`),pxt.toolbox.isImageIcon(i)&&n.setAttribute("web-icon-image",pxt.Util.pathJoin(pxt.webConfig.commitCdnUrl,encodeURI(i))))),n}function g(t,e,i,o=!1,a=0){var h,u;let d,p;if(e.attributes.builtinBlockId)return function(t){const e=t.attributes.builtinBlockId,i=t.attributes.color;if("makecode_color_picker"===e){const t=document.createElement("block");t.setAttribute("type","makecode_color_picker");const e=document.createElement("field");e.setAttribute("name","FORMAT"),e.textContent="rgb",t.appendChild(e);for(let e=0;e<3;e++){const i=document.createElement("value");i.setAttribute("name",`INPUT${e}`);const o=document.createElement("shadow");o.setAttribute("type","makecode_color_picker_number");const s=document.createElement("field");s.setAttribute("name","NUM"),s.textContent="0",o.appendChild(s),i.appendChild(o),t.appendChild(i)}if(i){const e=document.createElement("mutation");e.setAttribute("color",i),t.appendChild(e)}return t}return void pxt.warn(`Unsupported builtin block id: ${e}`)}(e);if(e.attributes.toolboxParent){const i=t.blocksById[e.attributes.toolboxParent];if(i){const s=pxt.blocks.compileInfo(i);if(d=g(t,i,s,o),e.attributes.toolboxParentArgument)p=d.querySelector(`value[name=${e.attributes.toolboxParentArgument}]`),!p&&s.parameters.some(t=>t.definitionName===e.attributes.toolboxParentArgument)&&(p=document.createElement("value"),p.setAttribute("name",e.attributes.toolboxParentArgument),d.appendChild(p));else if(p=d.querySelector("value"),!p)for(const t of s.parameters)if(!d.querySelector(`field[name=${t.definitionName}]`)){p=document.createElement("value"),p.setAttribute("name",t.definitionName),d.appendChild(p);break}if(p)for(;p.firstChild;)p.removeChild(p.firstChild);else d=void 0}}let m=document.createElement(d||o?"shadow":"block");if(m.setAttribute("type",e.attributes.blockId),e.attributes.blockGap?m.setAttribute("gap",e.attributes.blockGap):pxt.appTarget.appTheme&&pxt.appTarget.appTheme.defaultBlockGap&&m.setAttribute("gap",pxt.appTarget.appTheme.defaultBlockGap.toString()),i.thisParameter){const e=i.thisParameter,s=!!(null===(h=t.apis.byQName[e.type])||void 0===h?void 0:h.attributes.fixedInstances);let n=e.shadowBlockId,r=e.defaultValue;s||n&&"variables_get"!==n||(n="variables_get",r=r||e.definitionName);const l=c(t,e,n,r,o,a);l&&m.appendChild(l)}if("ENUM_GET"===e.attributes.shim||"KIND_GET"===e.attributes.shim){if(null===(u=e.parameters)||void 0===u?void 0:u.length){const t=e.parameters[0].default;if(t){const e=document.createElement("field");e.setAttribute("name","MEMBER"),e.textContent=t,m.appendChild(e)}}}else e.parameters&&(i.parameters.filter(t=>r.test(t.type)||r.test(l(t.type))||t.shadowBlockId||t.defaultValue).forEach(e=>{const i=c(t,e,void 0,void 0,o,a);i&&m.appendChild(i)}),e.attributes.draggableParameters?i.handlerArgs.forEach(t=>{const i="reporter"===e.attributes.draggableParameters,o=document.createElement("value");o.setAttribute("name",n.DRAGGABLE_PARAM_INPUT_PREFIX+t.name);const r=i?pxt.blocks.reporterTypeForArgType(t.type):"variables_get_reporter",a=document.createElement("block");a.setAttribute("type",r);const l=document.createElement("mutation");a.appendChild(l),i&&"argument_reporter_custom"===r&&l.setAttribute("typename",t.type),l.setAttribute(s.LOCALIZATION_NAME_MUTATION_KEY,t.localizationKey);const c=document.createElement("field");c.setAttribute("name",i?"VALUE":"VAR"),c.textContent=pxt.Util.htmlEscape(t.name),a.appendChild(c),o.appendChild(a),m.appendChild(o)}):i.handlerArgs.forEach(t=>{const e=document.createElement("field");e.setAttribute("name","HANDLER_"+t.name),e.textContent=t.name,m.appendChild(e)}));if(e.attributes.expandArgumentsInToolbox){let t;for(const e of m.children)if("mutation"===e.tagName){t=e;break}t||(t=document.createElement("mutation"),m.appendChild(t)),t.setAttribute("_expanded",""+e.attributes._expandedDef.parameters.length)}return d?(p.appendChild(m),d):m}function m(t,e,i,o){const s=document.createElement(o?"shadow":"block");s.setAttribute("type",pxt.Util.htmlEscape(t));const n=document.createElement("field");return n.setAttribute("name",pxt.Util.htmlEscape(e)),n.textContent=pxt.Util.htmlEscape(i),s.appendChild(n),s}function _(){const t=document.createElement("block");t.setAttribute("type","function_return");const e=document.createElement("value");e.setAttribute("name","RETURN_VALUE"),t.appendChild(e);const i=m("math_number","NUM","0",!0);return e.appendChild(i),t}i.isArrayType=l,i.createShadowValue=c,i.createFlyoutHeadingLabel=u,i.createFlyoutGroupLabel=d,i.createFlyoutButton=function(t,e){let i=o.utils.xml.createElement("button");return i.setAttribute("text",e),i.setAttribute("callbackKey",t),i},i.createFlyoutGap=function(t){const e=o.utils.xml.createElement("sep");return e.setAttribute("gap",t+""),e},i.createToolboxBlock=g,i.mkPredicateBlock=function(t){const e=document.createElement("block");e.setAttribute("type",t);const i=document.createElement("value");i.setAttribute("name","PREDICATE"),e.appendChild(i);const o=m("logic_boolean","BOOL","TRUE",!0);return i.appendChild(o),e},i.mkFieldBlock=m,i.mkVariableFieldBlock=function(t,e,i,o,s){const n=document.createElement(s?"shadow":"block");n.setAttribute("type",pxt.Util.htmlEscape(t));const r=document.createElement("field");return r.setAttribute("name","VAR"),r.id=e,r.setAttribute("variabletype",pxt.Util.htmlEscape(i)),r.textContent=pxt.Util.htmlEscape(o),n.appendChild(r),n},i.mkReturnStatementBlock=_,i.createFunctionsFlyoutCategory=function(t){const e=(0,s.flyoutCategory)(t);if(e.length>1){let t=_();e.splice(1,0,d(lf("Your Functions"))),e.splice(1,0,t)}const i=(0,s.getAllFunctionDefinitionBlocks)(t).filter(t=>t.getDescendants(!1).some(t=>"function_return"===t.type&&t.getInputTargetBlock("RETURN_VALUE"))).map(t=>t.getField("function_name").getText()),o=u(lf("Functions"),pxt.toolbox.getNamespaceColor("functions"),pxt.toolbox.getNamespaceIcon("functions"),"blocklyFlyoutIconfunctions");e.unshift(o);const n=[];for(const t of e)if(n.push(t),"function_call"===t.getAttribute("type")){const e=t.children.item(0);if(e){const o=e.getAttribute("name");if(i.some(t=>t===o)){const e=t.cloneNode(!0);e.setAttribute("type","function_call_output"),n.push(e)}}}return n}},{"./loader":79,"./plugins/functions":127,blockly:192}],155:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.maybeMoveFocusFromButton=void 0;const o=t("blockly"),s=t("./fields/field_imagenotext");i.maybeMoveFocusFromButton=t=>{const e=o.getFocusManager(),i=e.getFocusedNode();t&&(i instanceof s.FieldImageNoText||!i)&&e.focusNode(t)}},{"./fields/field_imagenotext":38,blockly:192}],156:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PxtWorkspaceSearch=void 0;const o=t("blockly"),s=t("@blockly/plugin-workspace-search");class n extends s.WorkspaceSearch{constructor(t){super(t),this.injectionDiv=t.getInjectionDiv()}highlightSearchGroup(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.addClass(e,"blockly-ws-search-highlight-pxt")})}unhighlightSearchGroup(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.removeClass(e,"blockly-ws-search-highlight-pxt")})}open(){super.open(),o.utils.dom.addClass(this.injectionDiv,"blockly-ws-searching")}close(){super.close(),o.utils.dom.removeClass(this.injectionDiv,"blockly-ws-searching")}}i.PxtWorkspaceSearch=n,o.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(t,e,i){"use strict";function o(t,e,i,o){return pxt.Util.toArray(t.getElementsByTagName(e)).filter(t=>t.getAttribute(i)===o)}Object.defineProperty(i,"__esModule",{value:!0}),i.cleanOuterHTML=i.getDirectChildren=i.getFirstChildWithAttr=i.getChildrenWithAttr=i.getBlocksWithType=void 0,i.getBlocksWithType=function(t,e){return o(t,"block","type",e).concat(o(t,"shadow","type",e))},i.getChildrenWithAttr=o,i.getFirstChildWithAttr=function(t,e,i,s){const n=o(t,e,i,s);return n.length?n[0]:void 0},i.getDirectChildren=function(t,e){const i=[];for(let o=0;o<t.childNodes.length;o++){const s=t.childNodes.item(o);s.tagName===e&&i.push(s)}return i},i.cleanOuterHTML=function(t){return t.outerHTML.replace(/^<\?[^>]*>/,"")}},{}],158:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getNestedChildBlocks=void 0,i.getNestedChildBlocks=function(t){return t.getDescendants(!0).filter(e=>e.isEnabled()&&e.getSurroundParent()===t)}},{}],159:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./runValidatorPlan"),i),s(t("./validateBlocksExist"),i),s(t("./validateBlocksInSetExist"),i),s(t("./validateCommentsExist"),i),s(t("./validateSpecificBlockCommentsExist"),i)},{"./runValidatorPlan":160,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165}],160:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.runValidatorPlan=void 0;const o=t("./validateBlockFieldValueExists"),s=t("./validateBlocksExist"),n=t("./validateBlocksInSetExist"),r=t("./validateCommentsExist"),a=t("./validateSpecificBlockCommentsExist"),l=t("./getNestedChildBlocks"),c=t("./validateVariableUsage");function h(t,e){const i=e.blockCounts.reduce((t,e)=>(t[e.blockId]=e.count,t),{}),o=(0,s.validateBlocksExist)({usedBlocks:t,requiredBlockCounts:i});let n=[];if(o.passed)for(const t of e.blockCounts){const e=t.blockId;n.push(...o.successfulBlocks[e])}return[n,o.passed]}function u(t,e){return(0,r.validateBlockCommentsExist)({usedBlocks:t,numRequired:e.count}).passed}function d(t,e){return(0,r.validateCommentsExist)({usedBlocks:t,numRequired:e.count}).passed}function p(t,e){return(0,a.validateSpecificBlockCommentsExist)({usedBlocks:t,blockType:e.blockType}).passed}function g(t,e){const i=(0,n.validateBlocksInSetExist)({usedBlocks:t,blockIdsToCheck:e.blocks,count:e.count});return[i.successfulBlocks,i.passed]}function m(t,e){const i=(0,o.validateBlockFieldValueExists)({usedBlocks:t,fieldType:e.fieldType,fieldValue:e.fieldValue,specifiedBlock:e.blockType});return[i.successfulBlocks,i.passed]}function _(t,e){const i=(0,c.validateVariableUsage)({usedBlocks:t,count:e.count,name:e.name}),o=[];for(const t of i.passingVarDefinitions.values())o.push(...t);return[o,i.passed]}i.runValidatorPlan=function t(e,i,o){const s=Date.now();let n=0,r=[];for(const s of i.checks){let i=!1;switch(s.validator){case"blocksExist":[r,i]=[...h(e,s)];break;case"commentsExist":i=d(e,s);break;case"blockCommentsExist":i=u(e,s);break;case"specificBlockCommentsExist":i=p(e,s);break;case"blocksInSetExist":[r,i]=[...g(e,s)];break;case"blockFieldValueExists":[r,i]=[...m(e,s)];break;case"variableUsage":[r,i]=[..._(e,s)];break;default:return pxt.debug(`Unrecognized validator: ${s.validator}`),pxt.tickEvent("validation.unrecognized_validator",{validator:s.validator}),{executionSuccess:!1,executionErrorMsg:lf("Unrecognized evaluation rule")}}if(i&&s.childValidatorPlans)for(const e of s.childValidatorPlans){let s=0;for(const i of r){const n=(0,l.getNestedChildBlocks)(i),r=o.find(t=>t.name===e);s+=t(n,r,o)?1:0}i=i&&s>0}n+=i?1:0}const a=n>=i.threshold;return pxt.tickEvent("validation.evaluation_complete",{plan:i.name,durationMs:Date.now()-s,passed:`${a}`}),{result:a,executionSuccess:!0}}},{"./getNestedChildBlocks":158,"./validateBlockFieldValueExists":161,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165,"./validateVariableUsage":166}],161:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlockFieldValueExists=void 0,i.validateBlockFieldValueExists=function({usedBlocks:t,fieldType:e,fieldValue:i,specifiedBlock:o}){const s=t.filter(t=>t.isEnabled()&&t.type===o).filter(t=>{var o;return"VAR"===e?(null===(o=t.getVarModels())||void 0===o?void 0:o[0].getName())===i:t.getFieldValue(e)===i});return{successfulBlocks:s,passed:s.length>0}}},{}],162:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlocksExist=void 0,i.validateBlocksExist=function({usedBlocks:t,requiredBlockCounts:e}){let i=[],o=[],s=[],n={};const r=null==t?void 0:t.reduce((t,e)=>(t[e.type]=(t[e.type]||0)+(e.isEnabled()?1:0),t),{});for(const[a,l]of Object.entries(e||{})){const e=r[a],c=t.filter(t=>t.isEnabled()&&t.type===a);c.length>0&&(n[a]=c),void 0===e?i.push(a):e?e<l&&s.push(a):o.push(a)}return{missingBlocks:i,disabledBlocks:o,insufficientBlocks:s,successfulBlocks:n,passed:0===i.length&&0===o.length&&0===s.length}}},{}],163:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlocksInSetExist=void 0,i.validateBlocksInSetExist=function({usedBlocks:t,blockIdsToCheck:e,count:i,requireUnique:o}){const s=[],n=t.filter(t=>t.isEnabled());for(const t of e){const e=n.filter(e=>e.type===t);o&&e.length>=1?s.push(e[0]):s.push(...e)}return{successfulBlocks:s,passed:s.length>=i}}},{}],164:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateCommentsExist=i.validateWorkspaceCommentsExist=i.validateBlockCommentsExist=void 0;const o=t("blockly");function s(t){return t.filter(t=>!!t.getCommentText())}function n(t){var e,i,s;const n=null!==(i=null===(e=t[0])||void 0===e?void 0:e.workspace)&&void 0!==i?i:o.getMainWorkspace();return(null!==(s=null==n?void 0:n.getTopComments())&&void 0!==s?s:[]).filter(t=>!!t.getText())}i.validateBlockCommentsExist=function({usedBlocks:t,numRequired:e}){const i=s(t);return{commentedBlocks:i,passed:i.length>=e}},i.validateWorkspaceCommentsExist=function({usedBlocks:t,numRequired:e}){const i=n(t);return{workspaceComments:i,passed:i.length>=e}},i.validateCommentsExist=function({usedBlocks:t,numRequired:e}){const i=[...s(t),...n(t)];return{comments:i,passed:i.length>=e}}},{blockly:192}],165:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateSpecificBlockCommentsExist=void 0,i.validateSpecificBlockCommentsExist=function({usedBlocks:t,blockType:e}){const i=t.filter(t=>t.type===e),o=i.filter(t=>!t.getCommentText());return{uncommentedBlocks:o,passed:0!==i.length&&0===o.length}}},{}],166:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateVariableUsage=void 0,i.validateVariableUsage=function({usedBlocks:t,count:e,name:i}){const o=new Map,s=new Set;for(const e of t){if(!e.isEnabled())continue;const t=e.getVarModels();for(const n of null!=t?t:[]){const t=n.getName();i&&t!==i||("variables_set"===e.type||"variables_change"===e.type?(o.has(t)||o.set(t,[]),o.get(t).push(e)):s.add(t))}}const n=new Map;for(const[t,e]of o)s.has(t)&&n.set(t,e);return{passingVarDefinitions:n,passed:n.size>=e}}},{}],167:[function(t,e,i){"use strict";let o;Object.defineProperty(i,"__esModule",{value:!0}),i.isBlocks=i.initEditorExtensionsAsync=i.HELP_IMAGE_URI=void 0,i.HELP_IMAGE_URI="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIHZpZXdCb3g9IjAgMCAyNiAyNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTMiIGN5PSIxMyIgcj0iMTMiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xNy45NTIgOS4xODQwMkMxNy45NTIgMTAuMjU2IDE3LjgxNiAxMS4wNzIgMTcuNTQ0IDExLjYzMkMxNy4yODggMTIuMTkyIDE2Ljc1MiAxMi43OTIgMTUuOTM2IDEzLjQzMkMxNS4xMiAxNC4wNzIgMTQuNTc2IDE0LjU4NCAxNC4zMDQgMTQuOTY4QzE0LjA0OCAxNS4zMzYgMTMuOTIgMTUuNzM2IDEzLjkyIDE2LjE2OFYxNi45NkgxMS44MDhDMTEuNDI0IDE2LjQ2NCAxMS4yMzIgMTUuODQgMTEuMjMyIDE1LjA4OEMxMS4yMzIgMTQuNjg4IDExLjM4NCAxNC4yODggMTEuNjg4IDEzLjg4OEMxMS45OTIgMTMuNDg4IDEyLjUzNiAxMi45NjggMTMuMzIgMTIuMzI4QzE0LjEwNCAxMS42NzIgMTQuNjI0IDExLjE2OCAxNC44OCAxMC44MTZDMTUuMTM2IDEwLjQ0OCAxNS4yNjQgOS45NjgwMiAxNS4yNjQgOS4zNzYwMkMxNS4yNjQgOC4yMDgwMiAxNC40MTYgNy42MjQwMiAxMi43MiA3LjYyNDAyQzExLjc2IDcuNjI0MDIgMTAuNzUyIDcuNzM2MDIgOS42OTYgNy45NjAwMkw5LjE0NCA4LjA4MDAyTDkgNi4wODgwMkMxMC40ODggNS41NjAwMiAxMS44NCA1LjI5NjAyIDEzLjA1NiA1LjI5NjAyQzE0LjczNiA1LjI5NjAyIDE1Ljk2OCA1LjYwODAyIDE2Ljc1MiA2LjIzMjAyQzE3LjU1MiA2Ljg0MDAyIDE3Ljk1MiA3LjgyNDAyIDE3Ljk1MiA5LjE4NDAyWk0xMS40IDIyVjE4LjY0SDE0LjE4NFYyMkgxMS40WiIgZmlsbD0iIzU5NUU3NCIvPgo8L3N2Zz4K",i.initEditorExtensionsAsync=function(){if(!o&&(o=Promise.resolve(),pxt.appTarget&&pxt.appTarget.appTheme&&pxt.appTarget.appTheme.extendFieldEditors)){const t={};o=o.then(()=>pxt.BrowserUtils.loadBlocklyAsync()).then(()=>pxt.BrowserUtils.loadScriptAsync("fieldeditors.js")).then(()=>pxt.editor.initFieldExtensionsAsync(t)).then(t=>{t.fieldEditors&&t.fieldEditors.forEach(t=>{pxt.blocks.registerFieldEditor(t.selector,t.editor,t.validator)})})}return o},i.isBlocks=function(t){return pxt.U.endsWith(t.name,".blocks")}},{}],168:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.postHostMessageAsync=i.shouldPostHostMessages=i.enableControllerAnalytics=i.bindEditorMessages=void 0;const o=t("./code-validation/runValidatorPlan"),s=t("../pxtservices/iframeEmbeddedClient"),n=t("./projectImport"),r={};let a;i.bindEditorMessages=function(t){const e=pxt.appTarget.appTheme.allowParentController||pxt.shell.isControllerMode(),i=pxt.appTarget.appTheme.allowPackageExtensions,l=pxt.appTarget.appTheme.allowSimulatorTelemetry;if(!e&&!i&&!l)return;a=new s.IFrameEmbeddedClient(s=>{const a=s.data;if(!a||!/^pxt(host|editor|pkgext|sim)$/.test(a.type))return!1;if("pxtpkgext"===a.type&&i)t().then(t=>{t.handleExtensionRequest(a)});else if("pxtsim"===a.type&&l){const t=a;"event"===t.action&&(t.category||t.message?pxt.reportError(t.category,t.message,t.data):pxt.tickEvent(t.tick,t.data))}else if(e){let e,i=Promise.resolve();if("pxthost"==a.type){const t=r[a.id];t?i=i.then(()=>t.resolve(a)):pxt.debug(`pxthost: unknown request ${a.id}`)}else"pxteditor"==a.type&&(i=i.then(()=>t().then(t=>{const i=a;switch(pxt.debug(`pxteditor: ${i.action}`),i.action.toLowerCase()){case"switchjavascript":return Promise.resolve().then(()=>t.openJavaScript());case"switchpython":return Promise.resolve().then(()=>t.openPython());case"switchblocks":return Promise.resolve().then(()=>t.openBlocks());case"startsimulator":return Promise.resolve().then(()=>t.startSimulator());case"restartsimulator":return Promise.resolve().then(()=>t.restartSimulator());case"hidesimulator":return Promise.resolve().then(()=>t.collapseSimulator());case"showsimulator":return Promise.resolve().then(()=>t.expandSimulator());case"closeflyout":return Promise.resolve().then(()=>t.closeFlyout());case"unloadproject":return Promise.resolve().then(()=>t.unloadProjectAsync());case"saveproject":return t.saveProjectAsync();case"compile":return t.compile();case"redo":return Promise.resolve().then(()=>{const e=t.editor;e&&e.hasRedo()&&e.redo()});case"undo":return Promise.resolve().then(()=>{const e=t.editor;e&&e.hasUndo()&&e.undo()});case"setscale":{const e=a;return Promise.resolve().then(()=>t.editor.setScale(e.scale))}case"stopsimulator":{const e=a;return Promise.resolve().then(()=>t.stopSimulator(e.unload))}case"newproject":{const e=a;return Promise.resolve().then(()=>t.newProject(e.options))}case"importproject":{const e=a;return Promise.resolve().then(()=>t.importProjectAsync(e.project,{filters:e.filters,searchBar:e.searchBar}))}case"importexternalproject":{const t=a;return(0,n.saveProjectAsync)(t.project).then(t=>{const i=location.origin+location.pathname+`#embedimport:${t}`;e={importUrl:i}})}case"openheader":{const e=a;return t.openProjectByHeaderIdAsync(e.headerId)}case"startactivity":{const e=a;let i,o=e.path;return/^([jt]s|py|blocks?):/i.test(o)&&(i=/^py:/i.test(o)?pxt.PYTHON_PROJECT_NAME:/^[jt]s:/i.test(o)?pxt.JAVASCRIPT_PROJECT_NAME:pxt.BLOCKS_PROJECT_NAME,o=o.substr(o.indexOf(":")+1)),Promise.resolve().then(()=>t.startActivity({activity:e.activityType,path:o,title:e.title,editor:i,previousProjectHeaderId:e.previousProjectHeaderId,carryoverPreviousCode:e.carryoverPreviousCode}))}case"importtutorial":{const e=a;return Promise.resolve().then(()=>t.importTutorialAsync(e.markdown))}case"proxytosim":{const e=a;return Promise.resolve().then(()=>t.proxySimulatorMessage(e.content))}case"renderblocks":{const i=a;return Promise.resolve().then(()=>t.renderBlocksAsync(i)).then(t=>t.xml.then(t=>{e=t.xml}))}case"renderxml":{const i=a;return Promise.resolve().then(()=>t.renderXml(i).resultXml.then(t=>{e=t.xml}))}case"renderbyblockid":{const i=a;return Promise.resolve().then(()=>t.renderByBlockIdAsync(i)).then(t=>t.resultXml.then(t=>{e=t.xml}))}case"runeval":{const i=a,s=i.validatorPlan,n=i.planLib;return Promise.resolve().then(()=>{const e=t.getBlocks();return(0,o.runValidatorPlan)(e,s,n)}).then(t=>{e=t})}case"gettoolboxcategories":{const i=a;return Promise.resolve().then(()=>{e=t.getToolboxCategories(i.advanced)})}case"getblockastext":{const i=a;return Promise.resolve().then(()=>{const o=t.getBlockAsText(i.blockId);e={blockAsText:o}})}case"renderpython":{const i=a;return Promise.resolve().then(()=>t.renderPythonAsync(i)).then(t=>{e=t.python})}case"toggletrace":{const e=a;return Promise.resolve().then(()=>t.toggleTrace(e.intervalSpeed))}case"settracestate":{const e=a;return Promise.resolve().then(()=>t.setTrace(e.enabled,e.intervalSpeed))}case"setsimulatorfullscreen":{const e=a;return Promise.resolve().then(()=>t.setSimulatorFullScreen(e.enabled))}case"showthemepicker":return Promise.resolve().then(()=>t.showThemePicker());case"togglehighcontrast":return Promise.resolve().then(()=>t.toggleHighContrast());case"sethighcontrast":{const e=a;return Promise.resolve().then(()=>t.setHighContrast(e.on))}case"togglegreenscreen":return Promise.resolve().then(()=>t.toggleGreenScreen());case"togglekeyboardcontrols":return Promise.resolve();case"print":return Promise.resolve().then(()=>t.printCode());case"pair":return t.pairAsync().then(()=>{});case"info":return Promise.resolve().then(()=>{e={versions:pxt.appTarget.versions,locale:ts.pxtc.Util.userLanguage(),availableLocales:pxt.appTarget.appTheme.availableLocales,keyboardControls:!0}});case"shareproject":{const i=a;return t.anonymousPublishHeaderByIdAsync(i.headerId,i.projectName).then(t=>{e=t})}case"savelocalprojectstocloud":{const i=a;return t.saveLocalProjectsToCloudAsync(i.headerIds).then(t=>{e={headerIdMap:t}})}case"requestprojectcloudstatus":{const e=a;return t.requestProjectCloudStatus(e.headerIds)}case"convertcloudprojectstolocal":{const e=a;return t.convertCloudProjectsToLocal(e.userId)}case"setlanguagerestriction":{const e=a;if("no-blocks"===e.restriction)throw pxt.warn("no-blocks language restriction is not supported"),new Error("no-blocks language restriction is not supported");return t.setLanguageRestrictionAsync(e.restriction)}case"precachetutorial":{const t=a,e=t.data,i=t.lang||pxt.Util.userLanguage();return pxt.github.db.cacheReposAsync(e).then(async()=>{if("string"==typeof e.markdown){const t=await pxt.BrowserUtils.translationDbAsync();await t.setAsync(i,e.path,void 0,void 0,e.markdown)}})}case"setcolorthemebyid":{const e=a;return t.setColorThemeById(e.colorThemeId,!!e.savePreference),Promise.resolve()}}return Promise.resolve()})));i.then(()=>c(a,e,!0,void 0),t=>c(a,e,!1,t))}return!0})};let l=!1;function c(t,e,i,o){if(t.response){const s={type:t.type,id:t.id,resp:e,success:i,error:o};a?a.postMessage(s):window.parent.postMessage(s,"*")}}function h(t){return new Promise((e,i)=>{const o=pxt.Util.clone(t);if(o.id=ts.pxtc.Util.guidGen(),t.response&&(r[o.id]={resolve:e,reject:i}),a?a.postMessage(o):window.parent.postMessage(o,"*"),pxt.commands.onPostHostMessage)try{pxt.commands.onPostHostMessage(o)}catch(t){pxt.reportException(t)}t.response||e(void 0)})}i.enableControllerAnalytics=function(){if(l)return;const t=!!pxt.commands.onPostHostMessage,e=pxt.appTarget.appTheme.allowParentController,i=pxt.BrowserUtils.isIFrame();if(!(t||e&&i))return;const o=pxt.tickEvent;pxt.tickEvent=function(t,e,i){o&&o(t,e,i),h({type:"pxthost",action:"event",tick:t,response:!1,data:e})};const s=pxt.reportException;pxt.reportException=function(t,e){s&&s(t,e);try{h({type:"pxthost",action:"event",tick:"error",message:t.message,response:!1,data:e})}catch(t){}};const n=pxt.reportError;pxt.reportError=function(t,e,i){n&&n(t,e,i),h({type:"pxthost",action:"event",tick:"error",category:t,message:e,data:i})},l=!0},i.shouldPostHostMessages=function(){return pxt.appTarget.appTheme.allowParentController&&pxt.BrowserUtils.isIFrame()},i.postHostMessageAsync=h},{"../pxtservices/iframeEmbeddedClient":185,"./code-validation/runValidatorPlan":160,"./projectImport":180}],169:[function(t,e,i){"use strict";function o(t){return`experiments-${"object"==typeof t?t.id:t}`}let s;function n(){const t=pxt.savedAppTheme(),e={},i=r();return i.forEach(i=>{const o=a(i);t[i.id]=!!o,o&&(e[i.id]=o?1:0)}),i.length&&Object.keys(e).length&&(pxt.tickEvent("experiments.loaded",e),pxt.reloadAppTargetVariant()),pxt.appTarget.appTheme}function r(){const t=pxt.appTarget.appTheme.experiments;if(!t)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(e=>t.indexOf(e.id)>-1).concat(s||[]).filter(t=>!(pxt.BrowserUtils.isPxtElectron()&&t.enableOnline))}function a(t){return!!pxt.storage.getLocal(o(t))}function l(t,e){e!=a(t)&&(e?pxt.storage.setLocal(o(t),"1"):pxt.storage.removeLocal(o(t)),n())}Object.defineProperty(i,"__esModule",{value:!0}),i.setState=i.state=i.toggle=i.isEnabled=i.someEnabled=i.clear=i.all=i.syncTheme=i.setEditorExtensionExperiments=void 0,i.setEditorExtensionExperiments=function(t){s=t},i.syncTheme=n,i.all=r,i.clear=function(){r().forEach(t=>pxt.storage.removeLocal(o(t))),n()},i.someEnabled=function(){return r().some(t=>a(t))},i.isEnabled=a,i.toggle=function(t){t.onClick?t.onClick():l(t,!a(t))},i.state=function(){const t={};return r().forEach(e=>t[e.id]=a(e)),JSON.stringify(t)},i.setState=l},{}],170:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.patchConfigEditorVersion=i.getTextAtTime=i.updateShareHistory=i.pushSnapshotOnHistory=i.updateHistory=i.parseHistoryFile=i.applySnapshot=i.createSnapshot=i.applyDiff=i.diffScriptText=i.collapseHistory=void 0;const o=18e5,s=864e5;function n(t,e,i,o,s){const n=[],l=t.entries.slice();let c=Object.assign({},e),{interval:h,minTime:u,maxTime:d}=i;void 0===u&&(u=0),void 0===d&&(d=t.lastSaveTime);let p=Object.assign({},c),g=t.lastSaveTime;for(;l.length;){const t=l.pop();c=a(c,t,s),t.timestamp>d?(n.unshift(t),p=Object.assign({},c),g=t.timestamp):t.timestamp<u?p?(n.unshift({timestamp:t.timestamp,editorVersion:t.editorVersion,changes:r(c,p,t.timestamp,o).changes}),p=void 0):n.unshift(t):g-t.timestamp>=h&&(n.unshift({timestamp:t.timestamp,editorVersion:t.editorVersion,changes:r(c,p,t.timestamp,o).changes}),p=Object.assign({},c),g=t.timestamp)}return p&&g>t.entries[0].timestamp&&n.unshift({timestamp:t.entries[0].timestamp,editorVersion:t.entries[0].editorVersion,changes:r(c,p,t.entries[0].timestamp,o).changes}),Object.assign(Object.assign({},t),{entries:n})}function r(t,e,i,o){var s,n;const r=[];for(const i of Object.keys(t))(i.endsWith(".ts")||i.endsWith(".jres")||i.endsWith(".py")||i.endsWith(".blocks")||"pxt.json"===i)&&(null==e[i]?r.push({type:"removed",filename:i,value:t[i]}):t[i]!==e[i]&&r.push({type:"edited",filename:i,patch:o(e[i],t[i])}));for(const i of Object.keys(e))(i.endsWith(".ts")||i.endsWith(".jres")||i.endsWith(".py")||i.endsWith(".blocks")||"pxt.json"===i)&&null==t[i]&&r.push({type:"added",filename:i,value:e[i]});if(r.length)return{timestamp:i,editorVersion:null===(n=null===(s=pxt.appTarget)||void 0===s?void 0:s.versions)||void 0===n?void 0:n.target,changes:r}}function a(t,e,i){const o=Object.assign({},t);for(const s of e.changes)"added"===s.type?delete o[s.filename]:"removed"===s.type?o[s.filename]=s.value:o[s.filename]=i(s.patch,t[s.filename]);return o}function l(t){let e;try{e={};const i=JSON.parse(t[pxt.CONFIG_NAME]);for(const o of i.files)o===pxt.IMAGES_CODE||o===pxt.TILEMAP_CODE?e[o]="":e[o]=t[o];if(e[pxt.CONFIG_NAME]=t[pxt.CONFIG_NAME],i.preferredEditor===pxt.BLOCKS_PROJECT_NAME?e[pxt.MAIN_BLOCKS]&&(e[pxt.MAIN_TS]=""):i.preferredEditor===pxt.PYTHON_PROJECT_NAME&&e[pxt.MAIN_PY]&&(e[pxt.MAIN_TS]=""),i.testFiles)for(const o of i.testFiles)e[o]=t[o]}catch(i){e=Object.assign({},t)}return e[pxt.HISTORY_FILE]&&delete e[pxt.HISTORY_FILE],e}function c(t){const e=JSON.parse(t);return e.entries||(e.entries=[]),e.shares||(e.shares=[]),e.snapshots||(e.snapshots=[]),e}function h(t,e){t=Object.assign({},t);try{const i=JSON.parse(t[pxt.CONFIG_NAME]);i.targetVersions&&(i.targetVersions.target=e),t[pxt.CONFIG_NAME]=JSON.stringify(i,null,4)}catch(t){}return{files:t,editorVersion:e}}function u(t,e){return{timestamp:e,editorVersion:pxt.appTarget.versions.target,text:l(t)}}function d(){var t,e;return null!=(null===(e=null===(t=pxt.appTarget)||void 0===t?void 0:t.appTheme)||void 0===e?void 0:e.timeMachineDiffInterval)?pxt.appTarget.appTheme.timeMachineDiffInterval:3e5}i.collapseHistory=function(t,e,i,o){if(!t[pxt.HISTORY_FILE])return;const s=n(c(t[pxt.HISTORY_FILE]),t,e,i,o);t[pxt.HISTORY_FILE]=JSON.stringify(s)},i.diffScriptText=r,i.applyDiff=a,i.createSnapshot=l,i.applySnapshot=function(t,e){var i;try{const o=Object.assign({},e),s=JSON.parse(t[pxt.CONFIG_NAME]);for(const e of Object.keys(t))e!==pxt.HISTORY_FILE&&(-1!==s.files.indexOf(e)||-1!==(null===(i=s.testFiles)||void 0===i?void 0:i.indexOf(e))||o[e]||(o[e]=t[e]));return o}catch(i){const o=Object.assign({},t);for(const t of Object.keys(e))o[t]=e[t];return o}},i.parseHistoryFile=c,i.updateHistory=function(t,e,i,l,h,p,g=!1){let m;t[pxt.HISTORY_FILE]?(m=c(t[pxt.HISTORY_FILE]),void 0===m.lastSaveTime&&(m.lastSaveTime=i)):m={entries:[],snapshots:[u(t,i-1)],shares:[],lastSaveTime:i};const _=m.lastSaveTime;for(const t of l)m.shares.some(e=>e.id===t.id)||m.shares.push({id:t.id,timestamp:i});if(function(t,e){const i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(const s of i){if(-1===o.indexOf(s))return!1;if(t[s]!==e[s])return!1}return!0}(t,e))return void(e[pxt.HISTORY_FILE]=JSON.stringify(m));let f=!1;if(1===m.entries.length){i-m.entries[m.entries.length-1].timestamp<d()&&(f=!0)}else if(m.entries.length>1){const t=m.entries[m.entries.length-1].timestamp,e=m.entries[m.entries.length-2].timestamp;i-t<d()&&t-e<d()&&(f=!0)}if(f){const i=m.entries.pop(),o=r(a(t,i,p),e,i.timestamp,h);o&&m.entries.push(o)}else{const i=r(t,e,m.lastSaveTime,h);i&&m.entries.push(i)}if(g&&Math.floor(_/s)!==Math.floor(i/s)&&(m=n(m,e,{interval:72e5,maxTime:i-s},h,p)),m.lastSaveTime=i,0==m.snapshots.length)m.snapshots.push(u(t,i-1));else if(i-m.snapshots[m.snapshots.length-1].timestamp>=function(){var t,e;if(null!=(null===(e=null===(t=pxt.appTarget)||void 0===t?void 0:t.appTheme)||void 0===e?void 0:e.timeMachineSnapshotInterval))return pxt.appTarget.appTheme.timeMachineSnapshotInterval;return o}()){m.snapshots.push(u(t,i));const e=[];let o=Math.floor(i/s)*s;for(let t=0;t<m.snapshots.length;t++){const n=m.snapshots[m.snapshots.length-1-t];i-n.timestamp<s||t===m.snapshots.length-1?e.unshift(n):n.timestamp<o&&(e.unshift(n),o=Math.floor(n.timestamp/s)*s)}m.snapshots=e}for(const t of m.snapshots)t.text[pxt.HISTORY_FILE]&&delete t.text[pxt.HISTORY_FILE];e[pxt.HISTORY_FILE]=JSON.stringify(m)},i.pushSnapshotOnHistory=function(t,e){let i;i=t[pxt.HISTORY_FILE]?c(t[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:e},i.snapshots.push(u(t,e)),t[pxt.HISTORY_FILE]=JSON.stringify(i)},i.updateShareHistory=function(t,e,i){let o;o=t[pxt.HISTORY_FILE]?c(t[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:e};for(const t of i)o.shares.some(e=>e.id===t.id)||o.shares.push({id:t.id,timestamp:e});t[pxt.HISTORY_FILE]=JSON.stringify(o)},i.getTextAtTime=function(t,e,i,o){let s=Object.assign({},t);for(let t=0;t<e.entries.length;t++){const n=e.entries.length-1-t,r=e.entries[n];if(s=a(s,r,o),r.timestamp===i){return h(s,n>0?e.entries[n-1].editorVersion:r.editorVersion)}}return{files:s,editorVersion:pxt.appTarget.versions.target}},i.patchConfigEditorVersion=h},{}],171:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.importDb=i.validation=i.experiments=i.workspace=i.monaco=i.history=void 0;const n=t("./history");i.history=n;const r=t("./monaco");i.monaco=r;const a=t("./workspace");i.workspace=a;const l=t("./experiments");i.experiments=l;const c=t("./code-validation");i.validation=c;const h=t("./projectImport");i.importDb=h,s(t("./editor"),i),s(t("./editorcontroller"),i),s(t("./monaco-fields/monacoFieldEditor"),i),s(t("./monaco-fields/field_tilemap"),i),s(t("./monaco-fields/field_musiceditor"),i),s(t("./monaco-fields/field_soundEffect"),i),s(t("./monaco-fields/field_sprite"),i),s(t("./monaco-fields/field_animation"),i),s(t("./monaco-fields/field_react"),i)},{"./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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.animationEditorDefinition=i.MonacoAnimationEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="animation-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`");const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject(),s=o.lookupAssetByName("animation",i);if(s)return this.editing=s,s;{const t=o.createNewAnimation();return i&&!o.isNameTaken("animation",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("animation"),this.editing=t,t}}}resultToText(t){const e=pxt.react.getTilemapProject();return e.pushUndo(),t=pxt.patchTemporaryAsset(this.editing,t,e),t=e.updateAsset(t),pxt.getTSReferenceForAsset(t,this.isPython)}getFieldEditorId(){return n}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}i.MonacoAnimationEditor=r;const a=["assets\\s*\\.\\s*animation\\s*`[^`]*`",'assets\\s*\\.\\s*animation\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(t=>`(?:${t})`).join("|");i.animationEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.animationEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],173:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.songEditorDefinition=i.MonacoSongEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="music-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`"),this.text=t;const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject();this.isAsset=!0;const s=o.lookupAssetByName("song",i);if(s)return this.editing=s,s;{const t=o.createNewSong(pxt.assets.music.getEmptySong(2));return i&&!o.isNameTaken("song",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("song"),this.editing=t,t}}const i=/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m.exec(t);if(i){const t=i[1].trim();return this.editing=a(t?pxt.assets.music.decodeSongFromHex(t):pxt.assets.music.getEmptySong(2)),this.editing}}resultToText(t){var e;const i=pxt.react.getTilemapProject();if(i.pushUndo(),null===(e=(t=pxt.patchTemporaryAsset(this.editing,t,i)).meta)||void 0===e?void 0:e.displayName){t=this.isAsset||i.lookupAsset(t.type,t.id)?i.updateAsset(t):i.createNewSong(t.song,t.meta.displayName);let e=pxt.getTSReferenceForAsset(t,this.isPython);return this.isAsset||(e=this.isPython?`music.create_song(${e})`:`music.createSong(${e})`),e}let o=pxt.assets.music.encodeSongToHex(t.song);return o=this.isPython?`hex("""${o}""")`:"hex`"+o+"`",this.text.replace(/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m,o)}getFieldEditorId(){return n}getOptions(){return{blocksInfo:this.host.blocksInfo()}}}function a(t){return{type:"song",id:"",internalID:0,meta:{},song:t}}i.MonacoSongEditor=r;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(t=>`(?:${t})`).join("|");i.songEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:l,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.songEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],174:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MonacoReactFieldEditor=void 0;i.MonacoReactFieldEditor=class{getId(){return"image-editor"}showEditorAsync(t,e,i){return this.fileType=t,this.editrange=e,this.host=i,this.initAsync().then(()=>{const t=this.textToValue(i.getText(e));return t?(this.fv=pxt.react.getFieldEditorView(this.getFieldEditorId(),t,this.getOptions()),this.fv.onHide(()=>{this.onClosed()}),this.fv.show(),new Promise((t,e)=>{this.resolver=t,this.rejecter=e})):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(t){return null}resultToText(t){return t+""}getFieldEditorId(){return""}getOptions(){return null}}},{}],175:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.soundEditorDefinition=i.MonacoSoundEffectEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="soundeffect-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){const e={wave:"sine",startFrequency:5e3,endFrequency:0,startVolume:255,endVolume:0,duration:500,effect:"none",interpolation:"linear"};this.value=e;const i=/\(([^)]*)\)/.exec(t)[1].split(",").map(t=>t.replace(/\s/g,""));if(8!==i.length)return e;switch(i[0]){case"WaveShape.Sawtooth":e.wave="sawtooth";break;case"WaveShape.Square":e.wave="square";break;case"WaveShape.Noise":e.wave="noise";break;case"WaveShape.Triangle":e.wave="triangle";break;default:e.wave="sine"}const o=(t,e)=>isNaN(t)?e:t;switch(e.startFrequency=o(parseInt(i[1]),e.startFrequency),e.endFrequency=o(parseInt(i[2]),e.endFrequency),e.startVolume=o(parseInt(i[3]),e.startVolume),e.endVolume=o(parseInt(i[4]),e.endVolume),e.duration=o(parseInt(i[5]),e.duration),i[6]){case"SoundExpressionEffect.Vibrato":e.effect="vibrato";break;case"SoundExpressionEffect.Tremolo":e.effect="tremolo";break;case"SoundExpressionEffect.Warble":e.effect="warble";break;default:e.effect="none"}switch(i[7]){case"InterpolationCurve.Logarithmic":e.interpolation="logarithmic";break;case"InterpolationCurve.Curve":e.interpolation="curve";break;default:e.interpolation="linear"}return e}resultToText(t){let e,i,o;switch((t=this.value).wave){case"sine":e="WaveShape.Sine";break;case"square":e="WaveShape.Square";break;case"triangle":e="WaveShape.Triangle";break;case"noise":e="WaveShape.Noise";break;case"sawtooth":e="WaveShape.Sawtooth"}switch(t.effect){case"vibrato":i="SoundExpressionEffect.Vibrato";break;case"tremolo":i="SoundExpressionEffect.Tremolo";break;case"warble":i="SoundExpressionEffect.Warble";break;case"none":i="SoundExpressionEffect.None"}switch(t.interpolation){case"curve":o="InterpolationCurve.Curve";break;case"linear":o="InterpolationCurve.Linear";break;case"logarithmic":o="InterpolationCurve.Logarithmic"}return`music.createSoundEffect(${e}, ${Math.round(t.startFrequency)}, ${Math.round(t.endFrequency)}, ${Math.round(t.startVolume)}, ${Math.round(t.endVolume)}, ${Math.round(t.duration)}, ${i}, ${o})`}getFieldEditorId(){return n}getOptions(){return{onClose:()=>this.fv.hide(),onSoundChange:t=>this.value=t,initialSound:this.value,useFlex:!0,useMixerSynthesizer:"microbit"!==pxt.appTarget.id}}}i.MonacoSoundEffectEditor=r,i.soundEditorDefinition={id:n,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(t,e){let i=t.startLineNumber,o=0,s=!1,n=0;const r="createSoundEffect",a=e.getLineCount();for(;i<a;){const a=e.getLineContent(i),l=a.indexOf(r);if(-1!==l&&(s=!0,o=l+17),s)for(;o<a.length;){const s=a.charAt(o);if("("===s)n++;else if(")"===s&&(n--,0===n))return new monaco.Range(t.startLineNumber,t.startColumn,i,o+e.getLineMinColumn(i)+1);o++}o=0,i++}}},proto:r},(0,s.registerMonacoFieldEditor)(n,i.soundEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],176:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.spriteEditorDefinition=i.MonacoSpriteEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="image-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`"),this.template=t.startsWith("bmp")?"bmp":"img";const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject();this.isAsset=!0;const s=o.lookupAssetByName("image",i);if(s)return this.editing=s,s;{const t=o.createNewImage();return i&&!o.isNameTaken("image",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("image"),this.editing=t,t}}return this.editing={type:"image",id:"",internalID:0,bitmap:pxt.sprite.imageLiteralToBitmap(t,this.template).data(),meta:{},jresData:""},this.editing}resultToText(t){var e;const i=pxt.react.getTilemapProject();return i.pushUndo(),(null===(e=(t=pxt.patchTemporaryAsset(this.editing,t,i)).meta)||void 0===e?void 0:e.displayName)?(t=this.isAsset||i.lookupAsset(t.type,t.id)?i.updateAsset(t):i.createNewProjectImage(t.bitmap,t.meta.displayName),this.isAsset=!0,pxt.getTSReferenceForAsset(t,this.isPython)):pxt.sprite.bitmapToImageLiteral(pxt.sprite.Bitmap.fromData(t.bitmap),this.isPython?"python":"typescript",this.template)}getFieldEditorId(){return"image-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}i.MonacoSpriteEditor=r;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(t=>`(?:${t})`).join("|");i.spriteEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.spriteEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],177:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.tilemapEditorDefinition=i.MonacoTilemapEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="tilemap-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){const e=this.readTilemap(t),i=pxt.react.getTilemapProject();return pxt.sprite.addMissingTilemapTilesAndReferences(i,e),this.editing=e,e}readTilemap(t){const e=pxt.react.getTilemapProject();if(/^\s*tiles\s*\./.test(t)&&(this.isTilemapLiteral=!1,t)){try{return function(t){return{type:"tilemap",id:"",internalID:0,meta:{},data:t}}(pxt.sprite.decodeTilemap(t,"typescript",e))}catch(t){}return null}this.isTilemapLiteral=!0;const i=/^\s*(tilemap(?:4|8|16|32)?)\s*(?:`([^`]*)`)|(?:\(\s*"""([^"]*)"""\s*\))\s*$/.exec(t),o=(i[2]||i[3]||"").trim();let s,n;if(this.tilemapLiteral=i[1],o&&(n=ts.pxtc.escapeIdentifier(o),s=e.getTilemap(n)||e.lookupAssetByName("tilemap",o)),!s){let t=16;"tilemap8"===this.tilemapLiteral?t=8:"tilemap32"===this.tilemapLiteral?t=32:"tilemap4"===this.tilemapLiteral&&(t=4);const[i]=e.createNewTilemap(n,t,16,16);s=e.getTilemap(i),n=i}return s}resultToText(t){const e=pxt.react.getTilemapProject();return e.pushUndo(),t=pxt.patchTemporaryAsset(this.editing,t,e),pxt.sprite.updateTilemapReferencesFromResult(e,t),this.isTilemapLiteral?(e.updateAsset(t),pxt.getTSReferenceForAsset(t,"python"===this.fileType)):pxt.sprite.encodeTilemap(t.data,"typescript"===this.fileType?"typescript":"python")}getFieldEditorId(){return"tilemap-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}getCreateTilemapRange(){const t=this.editrange.getStartPosition();let e,i=this.editrange.getEndPosition(),o=1;for(;;){e=new monaco.Range(i.lineNumber,i.column,i.lineNumber+1,0);const s=this.host.getText(e);for(let e=0;e<s.length;e++)if("("===s.charAt(e))o++;else if(")"===s.charAt(e)&&(o--,0===o)){const o=new monaco.Position(i.lineNumber,i.column+e+2);return monaco.Range.fromPositions(t,o)}if(i=e.getEndPosition(),i.lineNumber>t.lineNumber+20)return null}}}i.MonacoTilemapEditor=r,i.tilemapEditorDefinition={id:n,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:r},(0,s.registerMonacoFieldEditor)(n,i.tilemapEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],178:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getMonacoFieldEditor=i.registerMonacoFieldEditor=void 0;const o={};i.registerMonacoFieldEditor=function(t,e){o[t]=e},i.getMonacoFieldEditor=function(t){return o[t]}},{}],179:[function(t,e,i){"use strict";function o(t){const e=pxt.appTarget.appTheme.invertedMonaco,i=!(!pxt.appTarget.appTheme.monacoFieldEditors||!pxt.appTarget.appTheme.monacoFieldEditors.length);let o=monaco.editor.create(t,{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:i,glyphMargin:i||pxt.appTarget.appTheme.debugger,minimap:{enabled:!1},fixedOverflowWidgets:!0,autoIndent:"full",useTabStops:!0,dragAndDrop:!0,matchBrackets:"always",occurrencesHighlight:!1,quickSuggestionsDelay:200,theme:e?"vs-dark":"vs",renderIndentGuides:!0,accessibilityHelpUrl:"",quickSuggestions:{other:!0,comments:!0,strings:!0},acceptSuggestionOnCommitCharacter:!0,acceptSuggestionOnEnter:"on",accessibilitySupport:"on"});return o.layout(),o}Object.defineProperty(i,"__esModule",{value:!0}),i.createEditor=i.initMonacoAsync=i.syncModels=void 0,i.syncModels=function(t,e,i,o){if(o)return;let s=monaco.languages.typescript.typescriptDefaults.getExtraLibs(),n={};t.sortedDeps().forEach(t=>{t.getFiles().forEach(o=>{let s=t.id+"/"+o;if(/\.(ts)$/.test(o)&&s!=i){if(!monaco.languages.typescript.typescriptDefaults.getExtraLibs()[s]){let i=t.readFile(o)||"\n";e[s]=monaco.languages.typescript.typescriptDefaults.addExtraLib(i,s)}n[s]="1"}})}),Object.keys(s).filter(t=>/\.(ts)$/.test(t)&&!n[t]).forEach(t=>{e[t].dispose()})},i.initMonacoAsync=function(t){return new Promise((e,i)=>{if("object"==typeof window.monaco)return void e(o(t));let s=window.MonacoPaths,n=()=>{let i=window.require;i.config({paths:s}),i(["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})),e(o(t))})};if(window.require)n();else{let t=document.createElement("script");t.type="text/javascript",t.src=s["vs/loader"],t.addEventListener("load",n),document.body.appendChild(t)}})},i.createEditor=o},{}],180:[function(t,e,i){"use strict";let o;Object.defineProperty(i,"__esModule",{value:!0}),i.removeProjectAsync=i.saveProjectAsync=void 0;const s="projects";async function n(){if(o)return o;const t=pxt.appTarget.id+"-import";return o=new pxt.BrowserUtils.IDBWrapper(t,1,(t,e)=>{e.result.createObjectStore(s,{keyPath:"importId"})}),await o.openAsync(),o}i.saveProjectAsync=async function(t){const e={importId:pxt.U.guidGen(),project:t},i=await n();return await i.deleteAllAsync(s),await i.setAsync(s,e),e.importId},i.removeProjectAsync=async function(t){const e=await n(),i=await e.getAsync(s,t);return await e.deleteAllAsync(s),null==i?void 0:i.project}},{}],181:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.freshHeader=void 0,i.freshHeader=function(t,e){return{target:pxt.appTarget.id,targetVersion:pxt.appTarget.versions.target,name:t,meta:{},editor:pxt.JAVASCRIPT_PROJECT_NAME,pubId:"",pubCurrent:!1,_rev:null,id:pxt.U.guidGen(),recentUse:e,modificationTime:e,cloudUserId:null,cloudCurrent:!1,cloudVersion:null,cloudLastSyncTime:0,isDeleted:!1}}},{}],182:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("./runner"),s=t("./renderer"),n=t("../pxteditor");window.pxt||(window.pxt={}),window.pxt.runner=Object.assign(Object.assign({},o),s),window.pxt.editor=Object.assign({},n),function(){let t=window.ksRunnerWhenLoaded;t&&t()}()},{"../pxteditor":171,"./renderer":183,"./runner":184}],183:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.renderAsync=i.fireClickOnEnter=i.defaultClientRenderOptions=void 0;const o=t("./runner"),s=t("blockly"),n=t("../pxtblocks"),r=t("../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(t){"undefined"!=typeof hljs&&(t.hasClass("highlight")?hljs.highlightBlock(t[0]):t.find("code.highlight").each(function(t,e){hljs.highlightBlock(e)}),c(t))}function c(t){t.find("span.hljs-comment:contains(@highlight)").each((t,e)=>{try{!function(t){const e=$(t),i=document.createElement("span");i.className="highlight-line";let o=t.nextSibling;if(!o||o.nodeType!=Node.TEXT_NODE)return;let s=o.textContent,n=s.indexOf("\n");if(n<0)return;o.textContent=s.substring(0,n+1),$(document.createTextNode(s.substring(n+1).replace(/^\s+/,""))).insertAfter($(o)),o=o.nextSibling;for(;o;){let t=o.nextSibling;if(o.nodeType==Node.TEXT_NODE){s=o.textContent;const e=s.indexOf("\n");if(!(e<0)){i.appendChild(document.createTextNode(s.substring(0,e))),o.textContent=s.substring(e+1);break}i.appendChild(o),o=t}else i.appendChild(o),o=t}$(i).insertAfter(e),e.remove()}(e)}catch(t){pxt.reportException(t)}})}function h(t,e){t.append($('<div class="ui content blocks"/>').append(e))}function u(t,e,i){t.append($('<div class="ui content js"><div class="subheading"><i class="ui icon xicon js"></i>JavaScript</div></div>').append(e)),l(e)}function d(t,e,i){t.append($('<div class="ui content py"><div class="subheading"><i class="ui icon xicon python"></i>Python</div></div>').append(e)),l(e)}function p(t,e){const i=$('<a class="item" role="button" tabindex="0"><i role="presentation" aria-hidden="true"></i><span class="ui desktop only"></span></a>');return i.attr("aria-label",t),i.attr("title",t),i.find("i").attr("class",e),i.find("span").text(t),i.keypress(g),i}function g(t){const e="number"==typeof t.which?t.which:t.keyCode;13!==e&&32!==e||(t.preventDefault(),t.currentTarget.click())}i.defaultClientRenderOptions=a,i.fireClickOnEnter=g;let m=!1;function _(t,e,i,o,s,n,r={}){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 g=pxt.appTarget.appTheme||{};if(r.showEdit&&!g.hideDocsEdit&&n){const e=p(lf("Edit"),"edit icon"),{package:i,compileBlocks:r,compilePython:a}=n,l=i.host();if(s&&r?(i.setPreferredEditor(pxt.BLOCKS_PROJECT_NAME),l.writeFile(i,pxt.MAIN_BLOCKS,r.outfiles[pxt.MAIN_BLOCKS])):o&&a?(i.setPreferredEditor(pxt.PYTHON_PROJECT_NAME),l.writeFile(i,pxt.MAIN_PY,r.outfiles[pxt.MAIN_PY])):i.setPreferredEditor(pxt.JAVASCRIPT_PROJECT_NAME),t.assetJSON)for(const e of Object.keys(t.assetJSON))i.config.files.indexOf(e)<0&&i.config.files.push(e),l.writeFile(i,e,t.assetJSON[e]);const h=i.compressToFileAsync();e.click(()=>{pxt.tickEvent("docs.btn",{button:"edit"}),h.then(e=>{window.open(`${function(t){const e=t.pxtUrl||pxt.appTarget.appTheme.homeUrl;return(e||"").replace(/\/$/,"")}(t)}/#project:${ts.pxtc.encodeBase64(pxt.Util.uint8ArrayToString(e))}`,"pxt")})}),c.append(e)}if(t.showJavaScript||!s&&!o?(l.append(i),f(),b()):s?(l.append(s),T(),b()):o&&(l.append(o),f(),T()),r.run&&!g.hideDocsSimulator){let e=p(lf("Run"),"play icon").click(()=>{if(pxt.tickEvent("docs.btn",{button:"sim"}),l.find(".sim")[0])l.find(".sim").remove(),E(l);else{m||(m=!0,window.addEventListener("message",t=>{const e=t.data;if("aspectratio"!==e.type)return;const i=e.frameid,o=e.value,s=document.querySelector(`iframe[data-frameid="${i}"]`);(null==s?void 0:s.parentElement)&&(s.parentElement.style.paddingBottom=100/o+"%")}));let e="81.97%";pxt.appTarget.simulator&&(e=100/pxt.appTarget.simulator.aspectRatio+"%");const o=t.package?"&deps="+encodeURIComponent(t.package):"",s=A(t)+"#nofooter=1"+o,n=t.assetJSON?`data-assets="${encodeURIComponent(JSON.stringify(t.assetJSON))}"`:"",r=encodeURIComponent(i.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:${e};overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="${s}" data-code="${r}" data-frameid="${a}" ${n} allowfullscreen="allowfullscreen" sandbox="allow-popups allow-forms allow-scripts allow-same-origin" frameborder="0"></iframe></div></div></div>`);l.append(c),E(c)}});c.append(e)}if(r.hexname&&r.hex){let t=p(lf("Download"),"download icon").click(()=>{pxt.tickEvent("docs.btn",{button:"hex"}),pxt.BrowserUtils.browserDownloadBinText(r.hex,r.hexname,{contentType:pxt.appTarget.compile.hexMimeType})});c.append(t)}let _=$("<div class=codesnippet></div>");function f(){if(!s)return;const t=p(lf("Blocks"),"icon xicon blocks").click(()=>{pxt.tickEvent("docs.btn",{button:"blocks"}),l.find(".blocks")[0]?(l.find(".blocks").remove(),E(l)):(h(i?i.parent():l,s),E(s))});c.append(t)}function T(){if(i)if(r.showJs)u(l,i);else{const t=p("JavaScript","icon xicon js").click(()=>{pxt.tickEvent("docs.btn",{button:"js"}),l.find(".js")[0]?(l.find(".js").remove(),E(l)):(u(s?s.parent():l,i),E(i))});c.append(t)}}function b(){if(o)if(r.showPy)d(l,o);else{const t=p("Python","icon xicon python").click(()=>{pxt.tickEvent("docs.btn",{button:"py"}),l.find(".py")[0]?(l.find(".py").remove(),E(l)):(d(s?s.parent():l,o),E(o))});c.append(t)}}function E(t){var e;null===(e=t[0])||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})}c.children().length&&_.append(a),_.append(l),e.replaceWith(_)}let f,T=[];function b(t,e,i){if(!t)return Promise.resolve();let o=$("."+t).first();return o[0]?(i.emPixels||(i.emPixels=18),i.layout||(i.layout=1),i.splitSvg=!0,T.push({el:o,source:o.text(),options:i,render:e}),o.addClass("lang-shadow"),o.removeClass(t),b(t,e,i)):Promise.resolve()}function E(t){if(!t||t.kind!=ts.SyntaxKind.ExpressionStatement)return null;let e=t;if(!e.expression||e.expression.kind!=ts.SyntaxKind.CallExpression)return null;let i=e.expression;return pxtc.pxtInfo(i).callInfo}function y(t){return f||(f=(0,o.decompileSnippetAsync)("",t)),f}function v(t,e){if(!e)return;const i=/^\/(v\d+)/.exec(e.url),o=/^\/(v\d+)/.exec(window.location.pathname),s=/#doc/i.test(window.location.href);e.url&&!i&&o&&!s&&(e.url=`/${o[1]}/${e.url}`);const n=document.createElement("div");n.setAttribute("role","listitem"),n.append((0,r.renderCodeCard)(e,{hideHeader:!0,shortName:!0})),t.append(n)}function C(t,e,i){const o=e.attributes,n=!o.blockHidden&&s.Blocks[o.blockId];if(null==n?void 0:n.codeCard){const e=pxt.U.clone(n.codeCard);i&&(e.style=i),v(t,e)}else v(t,{name:e.qName,description:o.jsDoc,url:o.help||void 0,style:i})}function I(t,e,i,o){return b(e,(t,e)=>{const n=e.compileProgram;if(!n)return;const r=n.getSourceFile(pxt.MAIN_TS).statements.slice(0),a=document.createElement("div");a.setAttribute("role","list"),a.className="card-list",r.forEach(t=>{const i=t.kind,n=E(t);if(n&&e.apiInfo&&e.apiInfo.byQName[n.qName]){const t=e.apiInfo.byQName[n.qName],i=t.attributes,r=s.Blocks[i.blockId];if(o){const o=t,s=e.compileBlocks.blocksInfo.apis.byQName[o.namespace];v(a,{name:s.attributes.blockNamespace||s.name,url:s.attributes.help||"reference/"+(s.attributes.blockNamespace||s.name).toLowerCase(),description:s.attributes.jsDoc,blocksXml:r&&r.codeCard?r.codeCard.blocksXml:i.blockId?`<xml xmlns="http://www.w3.org/1999/xhtml"><block type="${i.blockId}"></block></xml>`:void 0})}else C(a,t)}else switch(i){case ts.SyntaxKind.ExpressionStatement:{const e=t;switch(e.expression.kind){case ts.SyntaxKind.TrueKeyword:case ts.SyntaxKind.FalseKeyword:v(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: ${e.expression.kind}`)}break}case ts.SyntaxKind.IfStatement:v(a,{name:o?"Logic":"if",url:"blocks/logic"+(o?"":"/if"),description:o?lf("Logic operators and constants"):lf("Conditional statement"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_if"></block></xml>'});break;case ts.SyntaxKind.WhileStatement:v(a,{name:o?"Loops":"while",url:"blocks/loops"+(o?"":"/while"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"for of",url:"blocks/loops"+(o?"":"/for-of"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"break",url:"blocks/loops"+(o?"":"/break"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"continue",url:"blocks/loops"+(o?"":"/continue"),description:o?lf("Loops and repetition"):lf("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 e=t,i=!0;3==e.condition.getChildCount()&&(i=!("0"==e.condition.getChildAt(0).getText()||e.condition.getChildAt(1).kind==ts.SyntaxKind.LessThanToken)),v(a,i?{name:o?"Loops":"for",url:"blocks/loops"+(o?"":"/for"),description:o?lf("Loops and repetition"):lf("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:o?"Loops":"repeat",url:"blocks/loops"+(o?"":"/repeat"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Variables":"variable declaration",url:"blocks/variables"+(o?"":"/assign"),description:o?lf("Variables"):lf("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: ${i}`)}}),i&&(t=t.parent()),t.replaceWith(a)},{package:t.package,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}function k(t,e){if(!t)return Promise.resolve();let i=$("."+t).first();if(!i[0])return Promise.resolve();i.removeClass(t);const o=pxt.gallery.parseCodeCardsHtml(i[0]);return o||i.append($("<div/>").addClass("ui segment warning").text("invalid codecard format")),e.snippetReplaceParent&&(i=i.parent()),function(t,e,i){if(!e||0==e.length)return Promise.resolve();if(0==e.length){let o=(0,r.renderCodeCard)(e[0],i);t.replaceWith(o)}else{let o=document.createElement("div");o.className="card-list",o.setAttribute("role","list"),o.setAttribute("aria-label",i.cardCategory||lf("Content cards")),e.forEach(t=>{const e=/^\/(v\d+)/.exec(t.url),s=/^\/(v\d+)/.exec(window.location.pathname),n=/#doc/i.test(window.location.href);t.url&&!e&&s&&!n&&(t.url=`/${s[1]}${t.url}`);const a=(0,r.renderCodeCard)(t,i),l=document.createElement("div");if(l.setAttribute("role","listitem"),l.appendChild(a),o.appendChild(l),"package"==t.cardType){const e=pxt.github.parseRepoId((t.url||"").replace(/^\/pkg\//,""));e&&pxt.packagesConfigAsync().then(o=>{switch(pxt.github.repoStatus(e,o)){case pxt.github.GitRepoStatus.Banned:a.remove();break;case pxt.github.GitRepoStatus.Approved:t.imageUrl=pxt.github.mkRepoIconUrl(e),l.insertBefore((0,r.renderCodeCard)(t,i),a),a.remove()}}).catch(e=>{pxt.reportException(e),pxt.debug(`failed to load repo ${t.url}`)})}}),t.replaceWith(o)}return Promise.resolve()}(i,o,{hideHeader:!0,cardCategory:e.hexName}).then(()=>pxt.U.delay(1,k(t,e)))}function A(t){return t.pxtUrl?t.pxtUrl+"/--run":pxt.webConfig&&pxt.webConfig.runUrl?pxt.webConfig.runUrl:"/--run"}function S(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};$("code.lang-python").each((i,o)=>{!function(i,o){"undefined"!=typeof hljs&&($(i).text($(i).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(i),c($(i)));const s=pxt.U.clone(e);o&&(s.run=!1,s.showEdit=!1),_(t,$(i).parent(),$(i),void 0,void 0,void 0,s)}(o,!1),$(o).removeClass("lang-python")})}function O(t,e){e.snippetReplaceParent&&(t=t.parent()),t.remove()}function R(t,e,i){$(`code.lang-${t}\\.${e}`).each((t,e)=>{O($(e),i)})}i.renderAsync=function(t){return pxt.analytics.enable(pxt.Util.userLanguage()),t||(t=a()),t.pxtUrl&&(t.pxtUrl=t.pxtUrl.replace(/\/$/,"")),t.showEdit&&(t.showEdit=!pxt.BrowserUtils.isIFrame()),pxt.docs.hydrateYouTubeEmbeds(document.body,!1),function(t){t.packageClass&&($("."+t.packageClass).each((e,i)=>{let o=$(i),s=o.text().split("\n").map(t=>t.replace(/\s*/g,"")).filter(t=>!!t).join(",");t.package=t.package?`${t.package},${s}`:s,t.snippetReplaceParent&&(o=o.parent()),o.remove()}),$(".lang-config").each((e,i)=>{let o=$(i);t.snippetReplaceParent&&(o=o.parent()),o.remove()}))}(t),function(t){let e,i;t.jresClass&&$(`.${t.jresClass}`).each((t,e)=>{const o=$(e);i=o.text(),e.parentElement.remove()}),t.assetJSONClass&&$(`.${t.assetJSONClass}`).each((t,i)=>{const o=$(i);e=o.text(),i.parentElement.remove()}),t.assetJSON=function(t,e){if(!t&&!e)return;const i=pxt.tutorial.parseAssetJson(t)||{};if(e){const t=JSON.parse(e);i[pxt.TILEMAP_JRES]=JSON.stringify(t),i[pxt.TILEMAP_CODE]=pxt.emitTilemapsFromJRes(t)}return i}(e,i)}(t),T=[],function(t){O($("code.lang-ghost"),t)}(t),function(t){R("blockconfig","local",t),R("blockconfig","global",t)}(t),function(t){O($("code.lang-template"),t)}(t),function(t){R("validation","local",t),R("validation","global",t)}(t),function(t){t.simulatorClass&&$("."+t.simulatorClass).each((e,i)=>{var o;let s=$(i),n="81.97%";pxt.appTarget.simulator&&(n=100/pxt.appTarget.simulator.aspectRatio+"%");const r=lf("MakeCode {0} Simulator",(null===(o=pxt.appTarget.appTheme)||void 0===o?void 0:o.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:${n};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(r)}"\n ></iframe>\n </div>\n </div>\n </div>\n `);const l=t.package?"&deps="+encodeURIComponent(t.package):"",c=A(t)+"#nofooter=1"+l,h=encodeURIComponent(s.text().trim()),u=a.find("iframe");u.attr("src",c),u.attr("data-code",h),t.assetJSON&&u.attr("data-assets",JSON.stringify(t.assetJSON)),t.snippetReplaceParent&&(s=s.parent()),s.replaceWith(a)})}(t),function(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};function i(i,o){"undefined"!=typeof hljs&&($(i).text($(i).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(i),c($(i)));const s=pxt.U.clone(e);o&&(s.run=!1,s.showEdit=!1),_(t,$(i).parent(),$(i),void 0,void 0,void 0,s)}$("code.lang-typescript").each((t,e)=>{i(e,!1),$(e).removeClass("lang-typescript")}),$("code.lang-typescript-ignore").each((t,e)=>{$(e).removeClass("lang-typescript-ignore"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript")}),$("code.lang-typescript-invalid").each((t,e)=>{$(e).removeClass("lang-typescript-invalid"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript"),$(e).parent("div").addClass("invalid"),$(e).parent("div").prepend($("<i>",{class:"icon ban"})),$(e).addClass("invalid")}),$("code.lang-typescript-valid").each((t,e)=>{$(e).removeClass("lang-typescript-valid"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript"),$(e).parent("div").addClass("valid"),$(e).parent("div").prepend($("<i>",{class:"icon check"})),$(e).addClass("valid")})}(t),S(t),Promise.resolve().then(()=>k(t.codeCardClass,t)).then(()=>async function(t){if("core"==pxt.appTarget.id)return;const e=(await y(t)).compileBlocks.blocksInfo;let i={};for(const t of e.blocks){const o=(t.attributes.blockNamespace||t.namespace).split(".")[0];if(!i[o]){const t=e.apis.byQName[o];t&&t.attributes.color&&(i[o]=t.attributes.color)}}let o="";for(const t of Object.keys(i)){const e=i[t];o+=`\n span.docs.${t.toLowerCase()} {\n --inline-namespace-color: ${e};\n }\n `}for(const t of Object.keys(pxt.toolbox.blockColors)){const e=pxt.toolbox.getNamespaceColor(t);o+=`\n span.docs.${t.toLowerCase()} {\n --inline-namespace-color: ${e};\n }\n `}let s=document.createElement("style");s.id="namespaceColors",s.type="text/css",(document.head||document.getElementsByTagName("head")[0]).appendChild(s),s.appendChild(document.createTextNode(o))}(t)).then(()=>function(t){(t=pxt.Util.clone(t)).emPixels=18,t.snippetMode=!0;const e=$(":not(pre) > code");let i=0;return function s(){if(i>=e.length)return Promise.resolve();const n=$(e[i++]),r=n.text(),a=/^(\|+)([^\|]+)\|+$/.exec(r);if(a){const t=/^(([^\:\.]*?)[\:\.])?(.*)$/.exec(a[2]),e=(t[2]?t[2].trim().toLowerCase():"").replace(/\(.*?\)/g,""),i=1==a[1].length?`docs inlinebutton ${e}`:`docs inlineblock ${e}`,o=t[3].trim();return n.replaceWith($(`<span class="${i}"/>`).text(pxt.U.rlf(o))),s()}const l=/^\[(.+)\]$/.exec(r);if(!l)return s();const c=l[1];return(0,o.decompileSnippetAsync)(c,t).then(t=>{if(t.blocksSvg){let e=$('<span class="block"/>').append(t.blocksSvg);const i=E(t.compileProgram.getSourceFile(pxt.MAIN_TS).statements[0]);if(i&&t.apiInfo){const o=t.apiInfo.byQName[i.qName];if(o&&o.attributes.help){const t=o.name||o.qName,i=lf("Documentation for {0} block",t);e=$('<a class="ui link"/>').attr("href",`/reference/${o.attributes.help}`).attr("aria-label",i).append(e)}}n.replaceWith(e)}return pxt.U.delay(1,s())})}()}(t)).then(()=>I(t,t.linksClass,t.snippetReplaceParent,!1)).then(()=>I(t,t.namespacesClass,t.snippetReplaceParent,!0)).then(()=>function(t,e){const i=t.apisClass;if(!i)return Promise.resolve();const o=$("."+i);return o.length?y(t).then(t=>{const i=t.compileBlocks.blocksInfo,n=pxt.Util.values(i.apis.byQName).filter(t=>!(t.attributes.hidden||t.attributes.deprecated||t.attributes.blockAliasFor||!t.attributes.jsDoc||!t.attributes.block||/^__/.test(t.name)));o.each((t,i)=>{let o=$(i);const r=pxt.Util.toDictionary(o.text().split("\n"),t=>t),a=n.filter(t=>!!r[t.attributes.blockNamespace||t.namespace]);if(!a.length)return;a.sort((t,e)=>{const i=!t.attributes.blockHidden&&s.Blocks[t.attributes.blockId],o=!e.attributes.blockHidden&&s.Blocks[e.attributes.blockId];return!!i!=!!o?(o?1:0)-(i?1:0):t.name.localeCompare(e.name)});const l=document.createElement("div");l.className="ui divided items",l.setAttribute("role","list"),a.forEach(t=>C(l,t,"item")),e&&(o=o.parent()),o.replaceWith(l)})}):Promise.resolve()}(t,t.snippetReplaceParent)).then(()=>function(t){return b(t.signatureClass,(e,i)=>{var o,r,a,l;let c=i.compileProgram;if(!c)return;let h=E(c.getSourceFile(pxt.MAIN_TS).statements[0]);if(!h||!i.apiInfo)return;const u=i.apiInfo.byQName[h.qName];if(!u)return;let d=s.Blocks[u.attributes.blockId],p=(null===(o=null==d?void 0:d.codeCard)||void 0===o?void 0:o.blocksXml)||void 0;const g=p?(0,n.render)(p):(null===(r=i.compileBlocks)||void 0===r?void 0:r.success)?i.blocksSvg:void 0,m=g?$(g):void 0;let f=ts.pxtc.service.displayStringForSymbol(u,!1,i.apiInfo).split("\n")[1]+";";const T=$('<code class="lang-typescript highlight"/>').text(f),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(u,!0,i.apiInfo).split("\n")[1],y=b&&$('<code class="lang-python highlight"/>').text(b);if(t.snippetReplaceParent&&(e=e.parent()),pxt.Util.isTranslationMode()){const t=$('<div class="ui segment" />');t.append($('<div class="ui header"><i class="ui xicon globe"></i></div>')),u.attributes.translationId&&t.append($('<div class="ui message">').text(u.attributes.translationId)),u.attributes.jsDoc&&t.append($('<div class="ui message">').text(u.attributes.jsDoc)),t.insertAfter(e)}_(t,e,T,y,m,i,{showJs:!0,showPy:!0,hideGutter:!0})},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>function(t){if(t.tutorial)return b(t.snippetClass,(e,i)=>{const o=i.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const s=$('<div class="ui segment codewidget"/>').append(o);e.replaceWith(s)},{package:t.package,snippetMode:!1,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON});let e=0;return b(t.snippetClass,(i,o)=>{const s=o.compileBlocks&&o.compileBlocks.success?$(o.blocksSvg):void 0,n=o.compilePython&&o.compilePython.success&&o.compilePython.outfiles[pxt.MAIN_PY],r=$('<code class="lang-typescript highlight"/>').text(i.text().trim()),a=n?$('<code class="lang-python highlight"/>').text(n.trim()):void 0;t.snippetReplaceParent&&(i=i.parent());const l=o.compileJS&&o.compileJS.success,c=t.hex&&l&&o.compileJS.outfiles[pxtc.BINARY_HEX]?o.compileJS.outfiles[pxtc.BINARY_HEX]:void 0,h=`${pxt.appTarget.nickname||pxt.appTarget.id}-${t.hexName||""}-${e++}.hex`;_(t,i,r,a,s,o,{showEdit:t.showEdit,run:t.simulator,hexname:h,hex:c})},{package:t.package,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>function(t){return b(t.blocksClass,(e,i)=>{const o=i.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const s=$('<div class="ui segment codewidget"/>').append(o);e.replaceWith(s)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>{return(e=t).blocksXmlClass?function t(e,i,s){let n=$("."+e).first();return n[0]?(s.emPixels||(s.emPixels=18),s.splitSvg=!0,(0,o.compileBlocksAsync)(n.text(),s).then(o=>{try{i(n,o)}catch(t){pxt.reportException(t),n.append($("<div/>").addClass("ui segment warning").text(t.message))}return n.removeClass(e),pxt.U.delay(1,t(e,i,s))})):Promise.resolve()}(e.blocksXmlClass,(t,i)=>{const o=i.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const s=$('<div class="ui segment codewidget"/>').append(o);t.replaceWith(s)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON}):Promise.resolve();var e}).then(()=>{return(e=t).diffBlocksXmlClass?function t(e,i,s){let r=$("."+e).first();if(!r[0])return Promise.resolve();s.emPixels||(s.emPixels=18),s.splitSvg=!0;const a=r.text().split(/-{10,}/),l=a[0],c=a[1];return(0,o.compileBlocksAsync)("",s).then(o=>{r.removeClass(e);try{const t=(0,n.diffXml)(l,c);t?(o.blocksSvg=t.svg,i(r,o)):r.text("no changes")}catch(t){pxt.reportException(t),r.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(e,i,s))})}(e.diffBlocksXmlClass,(t,i)=>{const o=i.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const s=$('<div class="ui segment codewidget"/>').append(o);t.replaceWith(s)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON}):Promise.resolve();var e}).then(()=>{return(e=t).diffBlocksClass?function t(i){let s=$("."+i).first();if(!s[0])return Promise.resolve();const{fileA:r,fileB:a}=pxt.diff.split(s.text(),{removeTrailingSemiColumns:!0});return pxt.U.promiseMapAllSeries([r,a],t=>(0,o.decompileSnippetAsync)(t,{generateSourceMap:!0})).then(o=>{try{const t=(0,n.decompiledDiffAsync)(r,o[0].compileBlocks,a,o[1].compileBlocks,{hideDeletedTopBlocks:!0,hideDeletedBlocks:!0}),i=pxt.diff.render(r,a,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});let l;const[c,h]=o.map(t=>t.compilePython&&t.compilePython.outfiles&&t.compilePython.outfiles[pxt.MAIN_PY]);c&&h&&(l=pxt.diff.render(c,h,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0})),_(e,s.parent(),$(i),l&&$(l),$(t.svg),void 0,{showEdit:!1,run:!1,hexname:void 0,hex:void 0})}catch(t){pxt.reportException(t),s.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(i))})}(e.diffBlocksClass):Promise.resolve();var e}).then(()=>{return(e=t).diffClass?function t(i){let o=$("."+i).first();if(!o[0])return Promise.resolve();const{fileA:s,fileB:n}=pxt.diff.split(o.text());try{const t=pxt.diff.render(s,n,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});e.snippetReplaceParent&&(o=o.parent());const r=$('<div class="ui segment codewidget"/>').append(t);o.removeClass(i),o.replaceWith(r)}catch(t){pxt.reportException(t),o.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(i))}(e.diffClass):Promise.resolve();var e}).then(()=>function(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};return b(t.staticPythonClass,(i,o)=>{const s=o.compilePython;if(s&&s.success){const n=i.clone().removeClass("lang-shadow").addClass("highlight"),r=n.clone().addClass("lang-python").text(s.outfiles[pxt.MAIN_PY]);n.addClass("lang-typescript"),l(r),_(t,i.parent(),n,r,void 0,o,e)}},{package:t.package,snippetMode:!0,assets:t.assetJSON})}(t)).then(()=>function(t){return t.projectClass?function e(){let i=$("."+t.projectClass).first(),s=i[0];if(!s)return Promise.resolve();i.removeClass(t.projectClass);let n=pxt.Cloud.parseScriptId(s.innerText);if(n){if(t.snippetReplaceParent){s=s.parentElement;let t=document.createElement("div");s.parentElement.insertBefore(t,s),s.parentElement.removeChild(s),s=t}return(0,o.renderProjectAsync)(s,n).then(()=>e())}return e()}():Promise.resolve()}(t)).then(()=>function(){const t={};return function e(){const i=T.shift();if(!i)return Promise.resolve();const{el:s,options:n,render:r}=i;return(0,o.decompileSnippetAsync)(s.text(),n).then(e=>{const i=e.compileJS&&e.compileJS.diagnostics&&e.compileJS.diagnostics.filter(t=>t.category==pxtc.DiagnosticCategory.Error);i&&i.length&&i.forEach(t=>pxt.reportError("docs.decompile",""+t.messageText,{code:t.code+""})),e.blocksSvg.querySelectorAll("defs *").forEach(e=>{t[e.id]?e.remove():t[e.id]=!0}),r(s,e)},t=>{pxt.reportException(t),s.append($("<div/>").addClass("ui segment warning").text(t.message))}).finally(()=>(s.removeClass("lang-shadow"),e()))}().then(()=>{s.Workspace.getAll().forEach(t=>t.dispose()),(0,n.cleanRenderingWorkspace)()})}())}},{"../pxtblocks":76,"../pxtblocks/codecardRenderer":11,"./runner":184,blockly:192}],184:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.init=i.setInitCallbacks=i.compileBlocksAsync=i.decompileSnippetAsync=i.renderMarkdownAsync=i.renderProjectFilesAsync=i.renderProjectAsync=i.startDocsServer=i.startRenderServer=i.setEditorContextAsync=i.editorLanguageMode=i.LanguageMode=i.buildSimJsInfo=i.fetchSimJsInfo=i.postSimMessage=i.currentDriver=i.preloadSim=i.simulateAsync=i.generateVMFileAsync=i.generateHexFileAsync=i.showError=i.initFooter=i.initHost=i.mainPkg=void 0;const o=t("../pxtblocks"),s=t("../pxteditor/editor"),n=t("./renderer"),r=t("../pxtblocks"),a=t("blockly");pxt.blocks.requirePxtBlockly=()=>r,pxt.blocks.requireBlockly=()=>a,pxt.blocks.registerFieldEditor=(t,e,i)=>r.registerFieldEditor(t,e,i);class l{constructor(t,e){this.ksPkg=t,this.topPkg=e,this.files={}}getKsPkg(){return this.ksPkg}getPkgId(){return this.ksPkg?this.ksPkg.id:this.id}isTopLevel(){return this.ksPkg&&0==this.ksPkg.level}setFiles(t){this.files=t}getAllFiles(){return pxt.Util.mapMap(this.files,(t,e)=>e)}}class c{constructor(){this.githubPackageCache={}}readFile(t,e){let i=m(t);return pxt.U.lookup(i.files,e)}writeFile(t,e,i){m(t).files[e]=i}getHexInfoAsync(t){return pxt.hexloader.getHexInfoAsync(this,t)}cacheStoreAsync(t,e){return Promise.resolve()}cacheGetAsync(t){return Promise.resolve(null)}patchDependencies(t,e,i){if(!i)return!1;const o=pxt.github.parseRepoId(i);if(!o)return!1;for(const e of Object.keys(t.dependencies)){const s=t.dependencies[e],n=pxt.github.parseRepoId(s);if(n&&o.fullName==n.fullName)return pxt.semver.strcmp(o.tag,n.tag)<0&&(t.dependencies[e]=i),!0}return!1}downloadPackageAsync(t,e){let i,o=t.verProtocol();"github"==o&&(i=this.githubPackageCache[t._verspec]);let s=m(t);return(i?Promise.resolve(i):t.commonDownloadAsync()).then(n=>{if(n)return"github"!=o||i||(this.githubPackageCache[t._verspec]=pxt.Util.clone(n)),s.setFiles(n),Promise.resolve();if("empty"==o){if(0==Object.keys(s.files).length&&s.setFiles(_()),e&&e.length){const i=m(t).files,o=JSON.parse(i[pxt.CONFIG_NAME]);e.forEach(t=>{g(o,t)}),i[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(o)}return Promise.resolve()}if("docs"==o){let e=_(),i=JSON.parse(e[pxt.CONFIG_NAME]);return t.verArgument().split(",").forEach(t=>{g(i,t)}),i.yotta||(i.yotta={}),i.yotta.ignoreConflicts=!0,e[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i),s.setFiles(e),Promise.resolve()}return"invalid"==o?(pxt.log(`skipping invalid pkg ${t.id}`),Promise.resolve()):Promise.reject(`Cannot download ${t.version()}; unknown protocol`)})}}let h,u,d,p;function g(t,e){let i=/^([a-zA-Z0-9_-]+)(=(.+))?$/.exec(e);return i?t.dependencies[i[1]]=i[3]||"*":pxt.warn(`unknown package syntax ${e}`),!0}function m(t){let e=t._editorPkg;if(e)return e;let o=null;t!=i.mainPkg&&(o=m(i.mainPkg));let s=new l(t,o);return t==i.mainPkg&&(s.topPkg=s),t._editorPkg=s,s}function _(){let t=pxt.appTarget.tsprj,e=pxt.U.clone(t.files);return e[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(t.config),e[pxt.MAIN_BLOCKS]="",e}function f(){pxt.setAppTarget(window.pxtTargetBundle),pxt.analytics.enable(pxt.Util.userLanguage()),pxt.Util.assert(!!pxt.appTarget);const t=window.location.href;let e,i=!1;if(/[&?]translate=1/.test(t)&&!pxt.BrowserUtils.isIE())e=ts.pxtc.Util.TRANSLATION_LOCALE,i=!0,pxt.Util.enableLiveLocalizationUpdates();else{const o=/PXT_LANG=(.*?)(?:;|$)/.exec(document.cookie),s=/(live)?(force)?lang=([a-z]{2,}(-[A-Z]+)?)/i.exec(t);e=s?s[3]:o&&o[1]||pxt.appTarget.appTheme.defaultLocale||navigator.userLanguage||navigator.language;const n=pxt.appTarget.appTheme.defaultLocale,r=null==e?void 0:e.toLocaleLowerCase(),a=pxt.BrowserUtils.isLocalHostDev()&&(!r||(n?n.toLocaleLowerCase()===r:"en"===r||"en-us"===r));(pxt.BrowserUtils.isPxtElectron()||a||pxt.appTarget.appTheme.disableLiveTranslations)&&!(null==s?void 0:s[1])||pxt.Util.enableLiveLocalizationUpdates(),i=!!s&&!!s[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 o=pxt.webConfig;return pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:o.commitCdnUrl,code:e,force:i}).then(()=>T())}function T(){i.mainPkg=new pxt.MainPackage(new c)}function b(t){pxt.error(t)}function E(t,e,o){const s=t?/\w+:\w+/.test(t)?t:"pub:"+t:"empty:tsprj";let n,r,a;return u&&u._verspec==s?(i.mainPkg=u,n=i.mainPkg.host(),r=Promise.resolve(),a=Promise.resolve()):(n=i.mainPkg.host(),i.mainPkg=new pxt.MainPackage(n),i.mainPkg._verspec=t?/\w+:\w+/.test(t)?t:"pub:"+t:"empty:tsprj",r=n.downloadPackageAsync(i.mainPkg,o),a=i.mainPkg.installAllAsync(),u=i.mainPkg),r.then(()=>n.readFile(i.mainPkg,pxt.CONFIG_NAME)).then(t=>t?a.then(()=>{if(e){let t=m(i.mainPkg);t.files[pxt.MAIN_TS]=e;let o=JSON.parse(t.files[pxt.CONFIG_NAME]);o.name=window.location.href.split("/").pop().split(/[?#]/)[0],t.files[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(o),i.mainPkg.config.name=o.name,-1==i.mainPkg.config.files.indexOf(pxt.MAIN_BLOCKS)&&i.mainPkg.config.files.push(pxt.MAIN_BLOCKS)}}).catch(t=>{b(lf("Cannot load extension: {0}",t.message))}):Promise.resolve())}function y(t){let e=i.mainPkg.getTargetOptions();return e.isNative=!!t,e.hasHex=!!t,i.mainPkg.getCompileOptionsAsync(e)}function v(t,e){return y(t).then(t=>{e&&e(t);let i=pxtc.compile(t);return i.diagnostics&&i.diagnostics.length>0&&i.diagnostics.forEach(t=>{pxt.error(t.messageText)}),i})}function C(t,e,o){var s,n;d&&e.embedId&&p===e.embedId?d.container=t:(d=new pxsim.SimulatorDriver(t),p=e.embedId);const{fnArgs:r,parts:a,usedBuiltinParts:l}=o||{};let c=pxt.appTarget.simulator.boardDefinition,h=A(e.id),u={debug:e.debug,mute:e.mute,boardDefinition:c,parts:a,builtinParts:l,fnArgs:r,cdnUrl:pxt.webConfig.commitCdnUrl,localizedStrings:pxt.Util.getLocalizedStrings(),partDefinitions:null===i.mainPkg||void 0===i.mainPkg?void 0:i.mainPkg.computePartDefinitions(a),highContrast:e.highContrast,storedState:h,light:e.light,single:e.single,hideSimButtons:e.hideSimButtons,autofocus:e.autofocus,queryParameters:e.additionalQueryParameters,mpRole:e.mpRole,theme:null===(s=i.mainPkg.config)||void 0===s?void 0:s.theme};if(pxt.appTarget.simulator&&!e.fullScreen&&(u.aspectRatio=a.length&&pxt.appTarget.simulator.partsAspectRatio?pxt.appTarget.simulator.partsAspectRatio:pxt.appTarget.simulator.aspectRatio),window.parent&&u.aspectRatio&&u.aspectRatio!==pxt.appTarget.simulator.aspectRatio){const t=null===(n=window.frameElement)||void 0===n?void 0:n.getAttribute("data-frameid");t&&window.parent.postMessage({type:"aspectratio",frameid:t,value:u.aspectRatio},"*")}return d.setRunOptions(u),u}async function I(t){try{const e=Date.now(),i=await pxt.Cloud.downloadBuiltSimJsInfoAsync(t.id);return pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-e,operation:"fetchSimJsInfo"}),i}catch(t){return void pxt.debug(t.toString())}}async function k(t){var e,o,s;const n=Date.now();await E(t.id,t.code,t.dependencies);let r=!1;const a=pxt.appTarget.versions.target;let l=await v(!1,e=>{var o;if(e.computeUsedParts=!0,e.computeUsedSymbols=!0,t.debug&&(e.breakpoints=!0),t.assets){const i=JSON.parse(t.assets);for(const t of Object.keys(i)){const o=i[t];if(e.fileSystem[t]=o,e.sourceFiles.indexOf(t)<0&&e.sourceFiles.push(t),/\.jres$/.test(t)){const t=JSON.parse(o);e.jres=pxt.inflateJRes(t,e.jres)}}}if(t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code),e.target.preferredEditor===pxt.PYTHON_PROJECT_NAME){e.target.preferredEditor=pxt.JAVASCRIPT_PROJECT_NAME,e.ast=!0;const t=P(pxtc.compile(e).ast,e);e.apisInfo=t,e.target.preferredEditor=pxt.PYTHON_PROJECT_NAME}const s=null===(o=i.mainPkg.config.targetVersions)||void 0===o?void 0:o.target;if(s&&a&&pxt.semver.cmp(pxt.semver.parse(s),pxt.semver.parse(a))<0)for(const t of Object.keys(e.fileSystem))!pxt.Util.startsWith(t,"pxt_modules")&&pxt.Util.endsWith(t,".ts")&&(r=!0,e.fileSystem[t]=pxt.patching.patchJavaScript(s,e.fileSystem[t]))});(null===(e=l.diagnostics)||void 0===e?void 0:e.length)>0&&r&&(pxt.log("Compile with upgrade rules failed, trying again with original code"),l=await v(!1,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})),l.diagnostics&&l.diagnostics.length>0&&pxt.error("Diagnostics",l.diagnostics);const c=pxtc.buildSimJsInfo(l),h=(null===(s=null===(o=pxt.appTarget.simulator)||void 0===o?void 0:o.boardDefinition)||void 0===s?void 0:s.onboardComponents)||[];return c.allParts=l.usedParts||[],c.usedBuiltinParts=l.usedParts.filter(t=>-1!==h.indexOf(t)),c.parts=l.usedParts.filter(t=>-1===h.indexOf(t)),pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-n,operation:"buildSimJsInfo"}),c}function A(t){let e={};try{let i=window.localStorage.getItem(t);i&&(e=JSON.parse(i))}catch(t){}return e}var S;function O(t,e){if(i.editorLanguageMode=t,e!=pxt.Util.localeInfo()){const t=/^live-/;return t.test(e)&&pxt.Util.enableLiveLocalizationUpdates(),pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:pxt.webConfig.commitCdnUrl,code:e.replace(t,"")})}return Promise.resolve()}function R(t){let e=t.data;if(e)switch(e.type){case"fileloaded":let t=e,i=t.name,o=S.Blocks;/\.ts$/i.test(i)?o=S.TypeScript:/\.py$/i.test(i)&&(o=S.Python),O(o,t.locale);break;case"popout":let s=/((\/v[0-9+])\/)?[^\/]*#(doc|md):([^&?:]+)/i.exec(window.location.href);if(s){const t=pxt.webConfig.docsUrl||"/--docs";let e=s[2]||"",i="doc"==s[3]?pxt.webConfig.isStatic?`/docs${s[4]}.html`:`${s[4]}`:`${t}?md=${s[4]}`;window.parent&&window.parent.postMessage({type:"opendoc",url:pxt.BrowserUtils.urlJoin(e,i)},"*")}break;case"localtoken":let n=e;n&&n.localToken&&(pxt.Cloud.localToken=n.localToken,U.forEach(t=>t()),U=[])}}function w(t,e){return pxt.Cloud.privateGetTextAsync(e+"/text").then(t=>JSON.parse(t)).then(i=>N(t,i,e))}function N(t,e,o=null,s=!1){const n=JSON.parse(e[pxt.CONFIG_NAME])||{};let r=`# ${n.name} ${n.version?n.version:""}\n\n`;const a="README.md";e[a]&&(r+=e[a].replace(/^#+/,"$0#")+"\n"),n.files.filter(t=>t!=pxt.CONFIG_NAME&&t!=a).filter(t=>function(t,e){switch(e){case S.Blocks:return/\.blocks?$/.test(t);case S.TypeScript:return/\.ts?$/.test(t);case S.Python:return/\.py?$/.test(t)}}(t,i.editorLanguageMode)).forEach(t=>{/^main\.(ts|blocks)$/.test(t)||(r+=`\n## ${t}\n`),/\.ts$/.test(t)?r+=`\`\`\`typescript\n${e[t]}\n\`\`\`\n`:/\.blocks?$/.test(t)?r+=`\`\`\`blocksxml\n${e[t]}\n\`\`\`\n`:r+=`\`\`\`${t.substr(t.indexOf("."))}\n${e[t]}\n\`\`\`\n`});const l=n&&n.dependencies&&Object.keys(n.dependencies).filter(t=>t!=pxt.appTarget.corepkg);if(l&&l.length&&(r+=`\n## ${lf("Extensions")} #extensions\n\n${l.map(t=>`* ${t}, ${n.dependencies[t]}`).join("\n")}\n\n\`\`\`package\n${l.map(t=>`${t}=${n.dependencies[t]}`).join("\n")}\n\`\`\`\n`),o){let t=(pxt.appTarget.appTheme.shareUrl||"https://makecode.com/")+o;s&&(t="`"+t+"`"),r+=`\n${t}\n\n`}pxt.debug(`print md: ${r}`);return x(t,r,{print:!0})}pxt.react.getTilemapProject||(pxt.react.getTilemapProject=()=>(h||(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg)),h)),i.initHost=T,i.initFooter=function(t,e){if(!t)return;let i=pxt.appTarget.appTheme,o=$("body"),s=$(t),n=$("<a/>").attr("href",i.homeUrl).attr("target","_blank");s.append(n),i.organizationLogo?n.append($("<img/>").attr("src",pxt.Util.toDataUri(i.organizationLogo))):n.append(lf("powered by {0}",i.title)),o.mouseenter(t=>s.fadeOut()),o.mouseleave(t=>s.fadeIn())},i.showError=b,i.generateHexFileAsync=function(t){return E(t.id).then(()=>v(!0,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})).then(t=>(t.diagnostics&&t.diagnostics.length>0&&pxt.error("Diagnostics",t.diagnostics),t.outfiles[pxtc.BINARY_HEX]))},i.generateVMFileAsync=function(t){return pxt.setHwVariant("vm"),E(t.id).then(()=>v(!0,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})).then(t=>(pxt.log(t),t))},i.simulateAsync=async function(t,e){var i,o;const s=e.builtJsInfo||await I(e)||await k(e),{js:n}=s;if(!n)return void pxt.error("Program failed to compile");const r=C(t,e,s);return d.options.messageSimulators=null===(o=null===(i=pxt.appTarget)||void 0===i?void 0:i.simulator)||void 0===o?void 0:o.messageSimulators,d.options.onSimulatorCommand=t=>{"restart"===t.command?(r.storedState=A(e.id),d.run(n,r)):"setstate"===t.command?t.stateKey&&function(t,e,i){let o=A(t);if(!t)return;null!=i?o[e]=i:delete o[e];try{window.localStorage.setItem(t,JSON.stringify(o))}catch(t){}}(e.id,t.stateKey,t.stateValue):"single"===t.command&&d.setSingleSimulator()},s.breakpoints&&e.debug&&d.setBreakpoints(s.breakpoints),d.run(n,r),s},i.preloadSim=function(t,e){var i,o;C(t,e),d.preload((null===(o=null===(i=pxt.appTarget)||void 0===i?void 0:i.simulator)||void 0===o?void 0:o.aspectRatio)||1,!0)},i.currentDriver=function(){return d},i.postSimMessage=function(t){null==d||d.postMessage(t)},i.fetchSimJsInfo=I,i.buildSimJsInfo=k,function(t){t[t.Blocks=0]="Blocks",t[t.TypeScript=1]="TypeScript",t[t.Python=2]="Python"}(S=i.LanguageMode||(i.LanguageMode={})),i.editorLanguageMode=S.Blocks,i.setEditorContextAsync=O,i.startRenderServer=function(){pxt.tickEvent("renderer.ready");const t=[];let e;function i(){if(e)return;const s=t.shift();if(!s)return;const n=s.options||{};n.splitSvg=!1,pxt.tickEvent("renderer.job");const r=/^\s*<xml/.test(s.code);e=(async()=>{const t=(r?await F(s.code,n):await B(s.code,s.options)).blocksSvg;if(!t)throw new Error("Failed to generate blocks SVG");const e=t.viewBox.baseVal.width,i=t.viewBox.baseVal.height;let a,l;try{a=await(0,o.blocklyToSvgAsync)(t,0,0,e,i)}catch(t){throw pxt.reportException(t),t}try{l=a?await pxt.BrowserUtils.encodeToPngAsync(a.xml,{width:e,height:i}):void 0}catch(t){pxt.warn(t)}window.parent.postMessage({source:"makecode",type:"renderblocks",id:s.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(t=>{window.parent.postMessage({source:"makecode",type:"renderblocks",id:s.id,error:t.message},"*")}).finally(()=>{e=void 0,i()})}(0,s.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",function(e){const o=e.data;"renderblocks"==o.type&&(t.push(o),i())},!1),window.parent.postMessage({source:"makecode",type:"renderready",versions:pxt.appTarget.versions},"*")})},i.startDocsServer=function(t,e,i){pxt.tickEvent("docrenderer.ready");const o=[];function r(o,s){pxt.debug(`rendering ${o}`),i&&$(i).hide(),$(e).hide(),$(t).show(),pxt.U.delay(100).then(()=>{switch(o){case"print":const t=window.localStorage.printjob;return delete window.localStorage.printjob,N(e,JSON.parse(t),void 0,!0).then(()=>pxsim.print(1e3));case"project":return N(e,JSON.parse(s)).then(()=>pxsim.print(1e3));case"projectid":return w(e,JSON.parse(s)).then(()=>pxsim.print(1e3));case"doc":return async function(t,e){e=e.replace(/^\//,"");const i=await pxt.Cloud.markdownAsync(e,void 0,!0);try{await x(t,i,{path:e})}catch(t){pxt.warn(t)}}(e,s);case"book":return function(t,e){e=e.replace(/^\//,""),pxt.tickEvent("book",{id:e}),pxt.log(`rendering book from ${e}`);let i;return $("#loading").find(".loader").addClass("text").text(lf("Compiling your book (this may take a minute)")),pxt.U.delay(100).then(()=>pxt.Cloud.markdownAsync(e,void 0,!0)).then(t=>{i=pxt.docs.buildTOC(t),pxt.log(`TOC: ${JSON.stringify(i,null,2)}`);const e=[];return pxt.docs.visitTOC(i,t=>{/^\//.test(t.path)&&!/^\/pkg\//.test(t.path)&&e.push(t)}),pxt.U.promisePoolAsync(4,e,async t=>{try{const e=await pxt.Cloud.markdownAsync(t.path,void 0,!0);t.markdown=e}catch(e){t.markdown=`_${t.path} failed to load._`}})}).then(e=>{let o=i[0].name;return pxt.docs.visitTOC(i,t=>{t.markdown&&(o+="\n\n"+t.markdown)}),x(t,o)})}(e,s);default:return x(e,s)}}).catch(t=>{$(e).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>`),$(e).find("#tryagain").click(()=>{r(o,s)}),window.parent&&window.parent.postMessage({type:"docfailed",docType:o,src:s},"*")}).finally(()=>{$(t).hide(),i&&$(i).show(),$(e).show()}).then(()=>{})}function a(t,e){e?(pxsim.U.addClass(t,"disabled"),t.setAttribute("aria-disabled","true")):(pxsim.U.removeClass(t,"disabled"),t.setAttribute("aria-disabled","false"))}async function l(){let t=/^#(doc|md|tutorial|book|project|projectid|print):([^&?:]+)(:([^&?:]+):([^&?:]+))?/i.exec(window.location.hash);if(t){if(i&&(o.push(window.location.hash),o.length>10&&o.shift(),o.length>1&&a(i,!1)),t[4]){let e=S.TypeScript;/^blocks$/i.test(t[4])?e=S.Blocks:/^python$/i.test(t[4])&&(e=S.Python),await O(e,t[5])}r(t[1],decodeURIComponent(t[2]))}}i&&(i.addEventListener("click",()=>{!function(){if(!i)return;o.length>1&&(o.pop(),window.location.hash=o.pop());o.length<=1&&a(i,!0)}()}),i.addEventListener("keydown",n.fireClickOnEnter),a(i,!0)),(0,s.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",R,!1),window.addEventListener("hashchange",()=>{l()},!1),parent.postMessage({type:"sidedocready"},"*"),setTimeout(()=>l(),1)})},i.renderProjectAsync=w,i.renderProjectFilesAsync=N;const L='\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 x(t,e,o={}){const s=pxt.docs.renderMarkdown({template:L,markdown:e,theme:pxt.appTarget.appTheme});let r=o.blocksAspectRatio||window.innerHeight<window.innerWidth?1.62:1/1.62;$(t).html(s),$(t).find("a").attr("target","_blank");const a=(0,n.defaultClientRenderOptions)();return a.tutorial=!!o.tutorial,a.blocksAspectRatio=r||a.blocksAspectRatio,a.showJavaScript=i.editorLanguageMode==S.TypeScript,o.print&&(a.showEdit=!1,a.simulator=!1),(0,n.renderAsync)(a).then(()=>{$(t).find('a[href^="/"]').removeAttr("target").each((t,e)=>{$(e).attr("href","#doc:"+$(e).attr("href").replace(/^\//,""))}),$(t).find(".ui.embed").embed()})}let D,M;function B(t,e){const{assets:s,forceCompilation:n,snippetMode:r,generateSourceMap:a}=e||{};return E(e&&e.packageId?"pub:"+e.packageId:e&&e.package?"docs:"+e.package:null,t).then(()=>y(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(l=>{if(t&&(l.fileSystem[pxt.MAIN_TS]=t),l.ast=!0,s)for(const t of Object.keys(s))l.sourceFiles.indexOf(t)<0&&l.sourceFiles.push(t),l.fileSystem[t]=s[t];let c,u,d;n?(c=pxtc.compile(l),u=c&&c.ast):u=pxtc.getTSProgram(l,D),D=u,pxt.appTarget.appTheme.python&&(d=ts.pxtc.transpile.tsToPy(u,pxt.MAIN_TS));let p=P(u,l);return ts.pxtc.localizeApisAsync(p,i.mainPkg).then(()=>{let t=pxtc.getBlocksInfo(p);(0,o.initializeAndInject)(t);const n=null==s?void 0:s[pxt.TILEMAP_JRES],l=null==s?void 0:s[pxt.IMAGES_JRES];(n||l)&&(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg),n&&h.loadTilemapJRes(JSON.parse(n),!0),l&&h.loadAssetsJRes(JSON.parse(l)));let g=pxtc.decompiler.decompileToBlocks(t,u.getSourceFile(pxt.MAIN_TS),{snippetMode:r,generateSourceMap:a});if(g.diagnostics&&g.diagnostics.length>0&&g.diagnostics.forEach(t=>pxt.error(t.messageText)),!g.success)return{package:i.mainPkg,compileProgram:u,compileJS:c,compileBlocks:g,apiInfo:p};pxt.debug(g.outfiles[pxt.MAIN_BLOCKS]);const m=(0,o.render)(g.outfiles[pxt.MAIN_BLOCKS],e);return(n||l)&&(h=null),{package:i.mainPkg,compileProgram:u,compileJS:c,compileBlocks:g,compilePython:d,apiInfo:p,blocksSvg:m}})})}function P(t,e){M||(M={});const i=Object.keys(e.fileSystem).sort().join(";");return M[i]||(M[i]=pxtc.getApiInfo(t,e.jres)),M[i]}function F(t,e){const{assets:s}=e||{};return E(e&&e.packageId?"pub:"+e.packageId:e&&e.package?"docs:"+e.package:null,"").then(()=>y(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(n=>{if(n.ast=!0,s)for(const t of Object.keys(s))n.sourceFiles.indexOf(t)<0&&n.sourceFiles.push(t),n.fileSystem[t]=s[t];const r=P(pxtc.compile(n).ast,n);return ts.pxtc.localizeApisAsync(r,i.mainPkg).then(()=>{const n=pxtc.getBlocksInfo(r);(0,o.initializeAndInject)(n);const a=null==s?void 0:s[pxt.TILEMAP_JRES],l=null==s?void 0:s[pxt.IMAGES_JRES];(a||l)&&(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg),a&&h.loadTilemapJRes(JSON.parse(a),!0),l&&h.loadAssetsJRes(JSON.parse(l)));const c=(0,o.render)(t,e);return(a||l)&&(h=null),{package:i.mainPkg,blocksSvg:c,apiInfo:r}})})}i.renderMarkdownAsync=x,i.decompileSnippetAsync=B,i.compileBlocksAsync=F;let U=[];let H=[];i.setInitCallbacks=function(t){H=t},i.init=function(){f().then(()=>{for(let t=0;t<H.length;++t)H[t]()})}},{"../pxtblocks":76,"../pxteditor/editor":167,"./renderer":183,blockly:192}],185:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.IFrameEmbeddedClient=void 0;i.IFrameEmbeddedClient=class{constructor(t){this.messageHandler=t,this.onMessageReceived=t=>{const e=t.data;if(e){if("iframeclientsetmessageport"===e.type)return this.port=t.ports[0],this.port.onmessage=this.onMessageReceived,void this.postMessage({type:"iframeclientsetmessageport"});if("iframeclientready"===e.type)return void this.sendReadyMessage()}this.messageHandler(t)},this.frameId=function(){const t=/frameid=([a-zA-Z0-9\-]+)/i.exec(window.location.href);if(t)return t[1];return}(),window.addEventListener("message",this.onMessageReceived),this.sendReadyMessage()}dispose(){window.removeEventListener("message",this.onMessageReceived),this.port&&this.port.close()}postMessage(t){this.postMessageCore(t)}postMessageCore(t){this.frameId&&(t.frameId=this.frameId),this.port?this.port.postMessage(t):window.acquireVsCodeApi?window.acquireVsCodeApi().postMessage(t):window.parent&&window.parent!==window&&window.parent.postMessage(t,"*")}sendReadyMessage(){this.postMessage({type:"iframeclientready"})}}},{}],186:[function(t,e,i){
|
|
6
|
+
*/Object.defineProperty(i,"__esModule",{value:!0}),i.setDuplicateOnDragStrategy=i.DuplicateOnDragStrategy=void 0;const o=t("blockly"),s=t("./duplicateOnDrag");class n extends o.dragging.BlockDragStrategy{getTargetBlock(){const t=this;return t.block.isShadow()&&(0,s.isAllowlistedShadow)(t.block)?t.block:super.getTargetBlock()}drag(t,e){if(super.drag(t,e),!e||e instanceof PointerEvent){this.block.moveDuringDrag(t)}}disconnectBlock(t){var e;const i=this;let n,r,a;const l=i.block.isShadow();if(l&&i.block.setShadow(!1),(0,s.shouldDuplicateOnDrag)(i.block)){const t=i.block.outputConnection;if(!(null==t?void 0:t.targetConnection))return;a=o.Xml.blockToDom(i.block,!0),l||(n=o.Xml.domToBlock(a,i.block.workspace)),r=t.targetConnection}t&&(i.startChildConn=null===(e=i.block.nextConnection)||void 0===e?void 0:e.targetConnection),r&&l&&r.setShadowDom(a),i.block.unplug(t),o.blockAnimations.disconnectUiEffect(i.block),(0,s.updateDuplicateOnDragState)(i.block),r&&n&&r.connect(n.outputConnection)}}i.DuplicateOnDragStrategy=n,i.setDuplicateOnDragStrategy=function(t){var e,i;null===(i=(e=t).setDragStrategy)||void 0===i||i.call(e,new n(t))}},{"./duplicateOnDrag":106,blockly:192}],106:[function(t,e,i){"use strict";let o,s;function n(t){return!(!o||-1===o.indexOf(t.type))}function r(t){var e,i;if(t.isShadow()&&n(t))return!0;if(s){const o=null===(e=t.outputConnection)||void 0===e?void 0:e.targetBlock();if(o){const e=s.filter(t=>t.parentBlockType===o.type);for(const o of e)if(o&&(!o.childBlockType||o.childBlockType===t.type)){if(!o.inputName)return!0;if((null===(i=t.outputConnection.targetConnection.getParentInput())||void 0===i?void 0:i.name)===o.inputName)return!0}}}return!1}Object.defineProperty(i,"__esModule",{value:!0}),i.updateDuplicateOnDragState=i.shouldDuplicateOnDrag=i.isAllowlistedShadow=i.setDuplicateOnDrag=i.setDraggableShadowBlocks=void 0,i.setDraggableShadowBlocks=function(t){o=t},i.setDuplicateOnDrag=function(t,e,i){s||(s=[]),s.some(o=>o.parentBlockType===t&&o.inputName===e&&o.childBlockType===i)||s.push({parentBlockType:t,inputName:e,childBlockType:i})},i.isAllowlistedShadow=n,i.shouldDuplicateOnDrag=r,i.updateDuplicateOnDragState=function(t){setTimeout(()=>{const e=r(t);t.pathObject&&t.pathObject.setHasDottedOutlineOnHover(e),t.setDeletable(!e)})}},{}],107:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./duplicateOnDrag"),i),s(t("./variablesGetReporter"),i),s(t("./connectionChecker"),i),s(t("./dragStrategy"),i)},{"./connectionChecker":104,"./dragStrategy":105,"./duplicateOnDrag":106,"./variablesGetReporter":108}],108:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("./duplicateOnDrag");o.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 o.zelos.ConstantProvider).SHAPES.ROUND,helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableReporter"]}),(0,s.updateDuplicateOnDragState)(this)}}},{"./duplicateOnDrag":106,blockly:192}],109:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MultiFlyoutRecyclableBlockInflater=i.HIDDEN_CLASS_NAME=void 0;const o=t("blockly");i.HIDDEN_CLASS_NAME="pxtFlyoutHidden";class s extends o.BlockFlyoutInflater{constructor(){super(...arguments),this.keyToBlock=new Map,this.blockToKey=new Map}static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,"block",s,!0)}isBlockRecycleable(t){switch(t.type){case"variables_get":case"variables_set":case"variables_change":return!1}return!0}createBlock(t,e){const s=function(t){if(t.blockxml)return"string"==typeof t.blockxml?t.blockxml:o.Xml.domToText(t.blockxml);return t.type}(t);if(!s)return super.createBlock(t,e);let n;return this.keyToBlock.has(s)&&(n=this.keyToBlock.get(s),this.keyToBlock.delete(s),e.getCanvas().appendChild(n.getSvgRoot())),n=null!=n?n:super.createBlock(t,e),this.blockToKey.set(n,s),n.removeClass(i.HIDDEN_CLASS_NAME),n.getFocusableElement().ariaHidden="false",n.setDisabledReason(!1,i.HIDDEN_CLASS_NAME),n}disposeItem(t){const e=t.getElement();if(e instanceof o.BlockSvg&&this.blockToKey.has(e)){if(this.isBlockRecycleable(e))return void this.recycleBlock(e);this.blockToKey.delete(e)}super.disposeItem(t)}clearCache(){this.blockToKey=new Map,this.keyToBlock=new Map}recycleBlock(t){const e=t.getRelativeToSurfaceXY();t.moveBy(-e.x,-e.y),t.addClass(i.HIDDEN_CLASS_NAME),t.getFocusableElement().ariaHidden="true",t.setDisabledReason(!0,i.HIDDEN_CLASS_NAME),t.getSvgRoot().remove();const o=this.blockToKey.get(t);this.keyToBlock.set(o,t),this.removeListeners(t.id)}}i.MultiFlyoutRecyclableBlockInflater=s,o.Css.register(`\n.${i.HIDDEN_CLASS_NAME} {\n display: none;\n}\n`)},{blockly:192}],110:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ButtonFlyoutInflater=void 0;const o=t("blockly"),s=t("./flyoutButton"),n="button";class r extends o.ButtonFlyoutInflater{static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,n,r,!0)}load(t,e){const i=new s.FlyoutButton(e.getWorkspace(),e.targetWorkspace,t,!1);return i.show(),new o.FlyoutItem(i,n)}}i.ButtonFlyoutInflater=r},{"./flyoutButton":112,blockly:192}],111:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.CachingFlyout=void 0;const o=t("blockly"),s=t("./blockInflater");class n extends o.VerticalFlyout{constructor(){super(...arguments),this.forceOpen=!1}clearBlockCache(){const t=this.getInflaterForType("block");t instanceof s.MultiFlyoutRecyclableBlockInflater&&t.clearCache()}getFlyoutElement(){return this.svgGroup_}setForceOpen(t){this.forceOpen=t}}i.CachingFlyout=n},{"./blockInflater":109,blockly:192}],112:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FlyoutButton=void 0;const o=t("blockly"),s={"":"usb","":"accessible-icon","":"adn","":"pied-piper-pp","":"steam","":"bluetooth-b","":"rebel","":"maxcdn","":"joomla","":"sellsy","":"connectdevelop","":"github-alt"};class n extends o.FlyoutButton{constructor(t,e,i,n){super(t,e,i,n);const r=this.getSvgRoot();if(!n){const t=17.5,e=14,i=this.height;this.width+=2*(t-o.FlyoutButton.TEXT_MARGIN_X),this.height+=2*(e-o.FlyoutButton.TEXT_MARGIN_Y);const s=r.getElementsByClassName("blocklyFlyoutButtonShadow").item(0),n=r.getElementsByClassName("blocklyFlyoutButtonBackground").item(0),a=r.getElementsByTagName("text").item(0);return s.setAttribute("width",String(this.width)),s.setAttribute("height",String(this.height)),n.setAttribute("width",String(this.width)),n.setAttribute("height",String(this.height)),a.setAttribute("x",String(this.width/2)),void a.setAttribute("y",String(parseFloat(a.getAttribute("y"))-i/2+this.height/2))}const a=i;a["web-class"]&&r.classList.add(a["web-class"]);const l=a["web-icon"],c=a["web-icon-class"],h=a["web-icon-color"],u=a["web-icon-image"];if(u){const t=20,e=this.getTargetWorkspace(),i=o.utils.dom.createSvgElement("image",{height:String(t),width:String(t),x:String(e.RTL?this.width+o.FlyoutButton.TEXT_MARGIN_X:o.FlyoutButton.TEXT_MARGIN_X),y:String(this.height/2+o.FlyoutButton.TEXT_MARGIN_Y-t/2)},r);i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);const s=t+2*o.FlyoutButton.TEXT_MARGIN_X;this.width+=s;const n=r.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);n.setAttribute("width",String(this.width));for(let t=0;t<r.children.length;t++){const e=r.children.item(t);if(e!==i&&e!==n){const t=Number(e.getAttribute("x"));e.setAttribute("x",t+s+"")}}}else if(l||c){const t=Object.keys(s).includes(l)?"brandIcon":"",e=o.utils.dom.createSvgElement("text",{class:`blocklyFlyoutLabelIcon${c?" "+c:""}${t?" "+t:""}`,x:0,y:0,"text-anchor":"start"},r);l&&(e.textContent=l),h&&e.setAttribute("style","fill: "+h);const i=this.getTargetWorkspace();e.setAttribute("dominant-baseline","central"),e.setAttribute("dy","0"),e.setAttribute("x",(i.RTL?this.width+o.FlyoutButton.TEXT_MARGIN_X:0)+""),e.setAttribute("y",this.height/2+o.FlyoutButton.TEXT_MARGIN_Y+"");const n=o.utils.dom.getTextWidth(e)+2*o.FlyoutButton.TEXT_MARGIN_X;this.width+=n;const a=r.getElementsByClassName("blocklyFlyoutLabelBackground").item(0);a.setAttribute("width",String(this.width));for(let t=0;t<r.children.length;t++){const i=r.children.item(t);if(i!==e&&i!==a){const t=Number(i.getAttribute("x"));i.setAttribute("x",t+n+"")}}}const d=a["web-line"],p=a["web-line-width"];if(d){const t=o.utils.dom.createSvgElement("line",{class:"blocklyFlyoutLine","stroke-dasharray":d,"text-anchor":"middle"},r);t.setAttribute("x1","0"),t.setAttribute("x2",null!=p?p:this.width+""),t.setAttribute("y1",this.height+10+""),t.setAttribute("y2",this.height+10+"")}}isDisposed(){return null===this.getSvgRoot().parentNode}}i.FlyoutButton=n},{blockly:192}],113:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.registerFlyoutInflaters=i.MultiFlyoutRecyclableBlockInflater=i.LabelFlyoutInflater=i.ButtonFlyoutInflater=void 0;const n=t("./buttonFlyoutInflater");Object.defineProperty(i,"ButtonFlyoutInflater",{enumerable:!0,get:function(){return n.ButtonFlyoutInflater}});const r=t("./labelFlyoutInflater");Object.defineProperty(i,"LabelFlyoutInflater",{enumerable:!0,get:function(){return r.LabelFlyoutInflater}});const a=t("./blockInflater");Object.defineProperty(i,"MultiFlyoutRecyclableBlockInflater",{enumerable:!0,get:function(){return a.MultiFlyoutRecyclableBlockInflater}}),s(t("./cachingFlyout"),i),i.registerFlyoutInflaters=function(){n.ButtonFlyoutInflater.register(),r.LabelFlyoutInflater.register(),a.MultiFlyoutRecyclableBlockInflater.register()}},{"./blockInflater":109,"./buttonFlyoutInflater":110,"./cachingFlyout":111,"./labelFlyoutInflater":114}],114:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LabelFlyoutInflater=void 0;const o=t("blockly"),s=t("./flyoutButton"),n="label";class r extends o.LabelFlyoutInflater{static register(){o.registry.register(o.registry.Type.FLYOUT_INFLATER,n,r,!0)}load(t,e){const i=new s.FlyoutButton(e.getWorkspace(),e.targetWorkspace,t,!0);return i.show(),new o.FlyoutItem(i,n)}}i.LabelFlyoutInflater=r},{"./flyoutButton":112,blockly:192}],115:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../constants"),n={typeName_:"",getTypeName(){return this.typeName_},removeFieldCallback(t){const e=this.getParent();(null==e?void 0:e.removeFieldCallback)&&e.removeFieldCallback(t)}};o.Blocks[s.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"bool"}],extensions:["output_boolean","text_field_color"]}),this.typeName_="boolean"}}),o.Blocks[s.ARGUMENT_EDITOR_STRING_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"text"}],extensions:["output_string","text_field_color"]}),this.typeName_="string"}}),o.Blocks[s.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"num"}],extensions:["output_number","text_field_color"]}),this.typeName_="number"}}),o.Blocks[s.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"list"}],extensions:["output_array","text_field_color"]}),this.typeName_="Array"}}),o.Blocks[s.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE]=Object.assign(Object.assign({},n),{init:function(){this.jsonInit({message0:" %1",args0:[{type:"field_argument_editor",name:"TEXT",text:"arg"}],outputShape:(new o.zelos.ConstantProvider).SHAPES.ROUND,extensions:["text_field_color"]}),this.typeName_="any"},mutationToDom(){const t=o.utils.xml.createElement("mutation");return t.setAttribute("typename",this.typeName_),t},domToMutation(t){this.typeName_=t.getAttribute("typename"),this.setOutput(!0,this.typeName_)}})},{"../constants":121,blockly:192}],116:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LOCALIZATION_NAME_MUTATION_KEY=void 0;const o=t("blockly"),s=t("../constants"),n=t("../msg"),r=t("../../duplicateOnDrag");i.LOCALIZATION_NAME_MUTATION_KEY="localizationname";const a={typeName_:"",localizationName_:"",getTypeName(){return this.typeName_},getLocalizationName(){return this.localizationName_||this.getFieldValue("VALUE")},mutationToDom(){const t=o.utils.xml.createElement("mutation");return this.localizationName_&&t.setAttribute(i.LOCALIZATION_NAME_MUTATION_KEY,this.localizationName_),t},domToMutation(t){t.hasAttribute(i.LOCALIZATION_NAME_MUTATION_KEY)&&(this.localizationName_=t.getAttribute(i.LOCALIZATION_NAME_MUTATION_KEY))}};function l(t){(0,r.setDuplicateOnDragStrategy)(t),(0,r.updateDuplicateOnDragState)(t)}o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_boolean"]}),this.typeName_="boolean",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_string"]}),this.typeName_="string",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_number"]}),this.typeName_="number",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],extensions:["output_array"]}),this.typeName_="Array",l(this)}}),o.Blocks[s.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:o.Msg[n.MsgKey.REPORTERS_HUE],inputsInline:!0,outputShape:(new o.zelos.ConstantProvider).SHAPES.ROUND,output:null}),this.typeName_="",l(this)},mutationToDom(){const t=a.mutationToDom.call(this);return t.setAttribute("typename",this.typeName_),t},domToMutation(t){this.typeName_=t.getAttribute("typename"),this.setOutput(!0,this.typeName_),a.domToMutation.call(this,t)}})},{"../../duplicateOnDrag":107,"../constants":121,"../msg":128,blockly:192}],117:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../msg"),l=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){let s=null,n=null;if(e&&t.id in e){const i=e[t.id];s=i.block,n=i.shadow}const r=null==s?void 0:s.workspace.connectionChecker;o.Events.disable();try{if(s&&!s.isDisposed()&&e&&(null==r?void 0:r.canConnectWithReason(null==s?void 0:s.outputConnection,i.connection,!1))===o.Connection.CAN_CONNECT){let r;s.outputConnection.connect(i.connection),r=s.isShadow()?o.Xml.blockToDom(s):n||this.buildShadowDom_(t.type),"variables_get"!==r.getAttribute("type")&&i.connection.setShadowDom(r),delete e[i.name]}else this.attachShadow_(i,t.type)}finally{o.Events.enable()}},afterWorkspaceLoad:function(){var t;for(const e of this.inputList){if(e.type!==o.inputs.inputTypes.VALUE)continue;const i=null===(t=e.connection)||void 0===t?void 0:t.targetBlock();i&&i.isShadow()&&i.getVarModels().length&&i.setShadow(!1);const s=e.connection&&e.getShadowDom();(0,r.isVariableBlockType)(null==s?void 0:s.getAttribute("type"))&&e.setShadowDom(null)}},addFunctionLabel_:function(t){this.appendDummyInput("function_name").appendField(new o.FieldLabel(t,"functionNameText"),"function_name")},updateFunctionLabel_:function(t){this.getField("function_name").setValue(t)},attachShadow_(t,e){const i=(0,r.getShadowBlockInfoFromType_)(e,this.workspace),s=i[0],n=i[1],a=i[2];o.Events.disable();let l=null;try{l=this.workspace.newBlock(s),l.setFieldValue(a,n),l.setShadow("variables_get"!==s),!this.isInsertionMarker()&&l instanceof o.BlockSvg&&(l.initSvg(),l.queueRender())}finally{o.Events.enable()}l&&(l.setShadow(!0),l.outputConnection.connect(t.connection))},buildShadowDom_(t){const e=o.utils.xml.createElement("shadow"),i=(0,r.getShadowBlockInfoFromType_)(t,this.workspace),s=i[0],n=i[1],a=i[2],l="variables_get"===s;e.setAttribute("type",s);const c=o.utils.xml.createElement("field");if(c.textContent=a,l){c.setAttribute("id",a);const t=this.workspace.getVariableMap().getVariableById(a);c.textContent=t?t.getName():""}return c.setAttribute("name",n),e.appendChild(c),e},onchange(t){var e;if(this.workspace&&!this.workspace.isFlyout)if(t.type==o.Events.BLOCK_CREATE&&-1!=(null===(e=t.ids)||void 0===e?void 0:e.indexOf(this.id))){const e=this.getName(),i=(0,r.getDefinition)(e,this.workspace);if(i){const t=i.getArguments().slice(),e=this.arguments_.slice();JSON.stringify(e)!==JSON.stringify(t)&&(0,r.mutateCallersAndDefinition)(i.getName(),this.workspace,i.mutationToDom()),this.functionId_=i.functionId_}else{o.Events.setGroup(t.group);const e=o.utils.xml.createElement("xml"),i=o.utils.xml.createElement("block");i.setAttribute("type",n.FUNCTION_DEFINITION_BLOCK_TYPE);const s=this.getRelativeToSurfaceXY(),r=s.x+o.config.snapRadius*(this.RTL?-1:1),a=s.y+2*o.config.snapRadius;i.setAttribute("x",r+""),i.setAttribute("y",a+"");const l=this.mutationToDom();i.appendChild(l),e.appendChild(i),o.Xml.domToWorkspace(e,this.workspace),o.Events.setGroup(!1)}}else if(t.type==o.Events.BLOCK_DELETE){const e=this.getName();(0,r.getDefinition)(e,this.workspace)||(o.Events.setGroup(t.group),this.dispose(!0),o.Events.setGroup(!1))}},serializeChangedInputs(t){const e=[],i=(0,r.getArgMap)(t,!0);for(const t of this.arguments_){if(i[t.id])continue;const o=this.getInput(t.id).connection,s=o.targetBlock();s.isShadow()?e.push({inputName:t.id,connectedShadow:o.getShadowState(!0)}):e.push({inputName:t.id,connectedBlock:s.id})}return e}});o.Blocks[n.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(o.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(o.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(o.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}}),o.Blocks[n.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 o.zelos.ConstantProvider).SHAPES.ROUND),this.setColour(o.Msg[a.MsgKey.PROCEDURES_HUE]),this.setHelpUrl(o.Msg[a.MsgKey.PROCEDURES_CALLNORETURN_HELPURL]),this.setTooltip(o.Msg[a.MsgKey.FUNCTION_CALL_TOOLTIP]),this.setInputsInline(!0)}})},{"../commonFunctionMixin":120,"../constants":121,"../msg":128,"../utils":130,blockly:192}],118:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.newFunctionMutation=void 0;const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../fields/fieldAutocapitalizeTextInput"),l=t("../functionManager"),c=t("../msg"),h=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){const o=this.createArgumentEditor_(t.type,t.name);i.connection.connect(o.outputConnection)},addFunctionLabel_:function(t){const e=new a.FieldAutocapitalizeTextInput(t||"",void 0,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(e,"function_name")},updateFunctionLabel_:function(t){o.Events.disable(),this.getField("function_name").setValue(t),o.Events.enable()},createArgumentEditor_:function(t,e){let i;o.Events.disable();try{let s="";switch(t){case"boolean":s=n.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE;break;case"number":s=n.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE;break;case"string":s=n.ARGUMENT_EDITOR_STRING_BLOCK_TYPE;break;case"Array":s=n.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE;break;default:s=n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE}i=s==n.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE?(0,r.createCustomArgumentEditor)(t,this.workspace):this.workspace.newBlock(s),i.setFieldValue(e,"TEXT"),i.setShadow(!0),!this.isInsertionMarker()&&i instanceof o.BlockSvg&&(i.initSvg(),i.queueRender())}finally{o.Events.enable()}return i},async focusLastEditorAsync_(){if(await o.renderManagement.finishQueuedRenders(),this.inputList.length>0){let t=this.inputList[this.inputList.length-2];if(t.type==o.inputs.inputTypes.DUMMY){const e=this.workspace;e instanceof o.WorkspaceSvg&&e.centerOnBlock(this.id,!0),t.fieldRow[0].showEditor()}else if(t.type==o.inputs.inputTypes.VALUE){const e=t.connection.targetBlock(),i=e.workspace;i instanceof o.WorkspaceSvg&&i.centerOnBlock(e.id,!0),e.getField("TEXT").showEditor()}}},removeFieldCallback(t){let e=null;for(let i=0;i<this.inputList.length&&!e;i++){let o=this.inputList[i];if(o.connection){let i=o.connection.targetBlock();if(!i)continue;i.getField(t.name)===t&&(e=o.name)}else for(let i=0;i<o.fieldRow.length;i++)o.fieldRow[i]==t&&(e=o.name)}e&&(o.WidgetDiv.hide(),this.removeInput(e),this.updateFunctionSignature(),this.updateDisplay_())},addParam_(t,e){o.WidgetDiv.hide();const i=(0,r.findUniqueParamName)(e,this.arguments_.map(t=>t.name));this.arguments_.push({id:o.utils.idGenerator.genUid(),name:i,type:t}),this.updateDisplay_(),this.focusLastEditorAsync_()},addBooleanExternal(){this.addParam_("boolean",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME])},addStringExternal(){this.addParam_("string",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_STRING_ARG_NAME])},addNumberExternal(){this.addParam_("number",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME])},addArrayExternal(){this.addParam_("Array",o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME])},addCustomExternal(t){this.addParam_(t,l.FunctionManager.getInstance().getArgumentNameForType(t))},updateFunctionSignature(){this.arguments_=[];for(let t=1;t<this.inputList.length;t++){const e=this.inputList[t];switch(e.type){case o.inputs.inputTypes.STATEMENT:break;case o.inputs.inputTypes.DUMMY:this.name_=e.fieldRow[0].getValue()||e.fieldRow[0].getText();break;case o.inputs.inputTypes.VALUE:const t=e.connection.targetBlock();this.arguments_.push({id:e.name,name:t.getFieldValue("TEXT"),type:t.getTypeName()});break;default:pxt.warn("Unexpected input type on a function mutator root: "+e.type)}}}});i.newFunctionMutation=function(t){const e=(0,r.findLegalName)(o.Msg[c.MsgKey.FUNCTIONS_DEFAULT_FUNCTION_NAME],t),i=o.utils.xml.createElement("mutation");return i.setAttribute("name",e),i.setAttribute("functionid",o.utils.idGenerator.genUid()),i},o.Blocks[n.FUNCTION_DECLARATION_BLOCK_TYPE]=Object.assign(Object.assign({},h),{init:function(){this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../commonFunctionMixin"),n=t("../constants"),r=t("../utils"),a=t("../fields/fieldAutocapitalizeTextInput"),l=t("../msg"),c=t("../functionManager"),h=t("../svgs"),u=t("../../duplicateOnDrag"),d=t("../../../fields/field_imagenotext"),p=t("../../../utils"),g=Object.assign(Object.assign({},s.COMMON_FUNCTION_MIXIN),{populateArgument_:function(t,e,i){let o,s=null;if(null==e?void 0:e[t.id]){s=e[t.id].block}e&&s&&!s.isDisposed()?(o=s,o.setFieldValue(t.name,"VALUE"),delete e[i.name]):o=this.createArgumentReporter_(t),i.connection.connect(o.outputConnection)},afterWorkspaceLoad:function(){for(const t of this.inputList){if(t.type!==o.inputs.inputTypes.VALUE)continue;const e=this.arguments_.find(e=>e.id===t.name);if(!e)continue;let i=t.connection.targetBlock();i||(this.populateArgument_(e,null,t),i=t.connection.targetBlock()),i.setFieldValue(e.name,"VALUE"),i.isShadow()&&i.setShadow(!1),t.setShadowDom(null)}},addFunctionLabel_:function(t){const e=new a.FieldAutocapitalizeTextInput(t||"",r.rename,{spellcheck:!1,disableAutocapitalize:!0});this.appendDummyInput("function_name").appendField(e,"function_name")},updateFunctionLabel_:function(t){o.Events.disable(),this.getField("function_name").setValue(t),o.Events.enable()},createArgumentReporter_:function(t){let e,i="";switch(t.type){case"boolean":i=n.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE;break;case"number":i=n.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE;break;case"string":i=n.ARGUMENT_REPORTER_STRING_BLOCK_TYPE;break;case"Array":i=n.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE;break;default:i=n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}o.Events.disable();try{e=i==n.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE?(0,r.createCustomArgumentReporter)(t.type,this.workspace):this.workspace.newBlock(i),e.setFieldValue(t.name,"VALUE"),e.setShadow(!0),!this.isInsertionMarker()&&e instanceof o.BlockSvg&&(e.initSvg(),e.queueRender())}finally{o.Events.enable()}return e},customContextMenu:function(t){var e,i;this.isInFlyout||(null===(i=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===i?void 0:i.readOnly)||(t.push(this.makeEditOption()),t.push(this.makeCallOption()))},makeEditOption:function(){var t,e;return{enabled:!(null===(e=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===e?void 0:e.readOnly),text:o.Msg.FUNCTIONS_EDIT_OPTION,callback:()=>{!function(t){if(t.type==n.FUNCTION_CALL_BLOCK_TYPE||t.type==n.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const e=t.workspace;t=(0,r.getDefinition)(t.getName(),e)}o.hideChaff(),o.getSelected()&&o.getSelected().unselect();c.FunctionManager.getInstance().editFunctionExternal(t.mutationToDom(),e=>{e&&((0,r.mutateCallersAndDefinition)(t.getName(),t.workspace,e),t.updateDisplay_()),setTimeout(()=>{t.afterWorkspaceLoad&&t.afterWorkspaceLoad()})})}(this)}}},makeCallOption:function(){var t,e;const i=this.getName(),s=o.utils.xml.createElement("mutation");s.setAttribute("name",i);const r=o.utils.xml.createElement("block");return r.appendChild(s),r.setAttribute("type",n.FUNCTION_CALL_BLOCK_TYPE),{enabled:this.workspace.remainingCapacity()>0&&!(null===(e=null===(t=this.workspace)||void 0===t?void 0:t.options)||void 0===e?void 0:e.readOnly),text:o.Msg.FUNCTIONS_CREATE_CALL_OPTION.replace("%1",i),callback:o.ContextMenu.callbackFactory(this,r)}}});o.Blocks[n.FUNCTION_DEFINITION_BLOCK_TYPE]=Object.assign(Object.assign({},g),{init:function(){if(this.jsonInit({style:{hat:"cap"}}),this.name_="",this.arguments_=[],this.functionId_="",this.createAllInputs_(),this.setColour(o.Msg[l.MsgKey.PROCEDURES_HUE]),this.setTooltip(o.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_TOOLTIP]),this.setHelpUrl(o.Msg[l.MsgKey.PROCEDURES_DEFNORETURN_HELPURL]),this.setStatements_(!0),this.setInputsInline(!0),this.workspace.options.collapse){const t=h.COLLAPSE_IMAGE_DATAURI;this.appendDummyInput("function_collapse").appendField(new d.FieldImageNoText(t,24,24,lf("Collapse block"),()=>{var t;this.setCollapsed(!0);const e=null===(t=this.inputList.find(t=>t.name===o.constants.COLLAPSED_INPUT_NAME))||void 0===t?void 0:t.fieldRow[1];(0,p.maybeMoveFocusFromButton)(e)},!1))}}}),(0,u.setDuplicateOnDrag)(n.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.COMMON_FUNCTION_MIXIN=void 0;const o=t("blockly"),s=t("./constants"),n=t("./utils"),r=t("./msg");i.COMMON_FUNCTION_MIXIN={name_:"",functionId_:"",arguments_:[],mutationToDom:function(){this.ensureIds_();const t=o.utils.xml.createElement("mutation");return t.setAttribute("name",this.name_),t.setAttribute("functionid",this.functionId_),this.arguments_.forEach(function(e){const i=o.utils.xml.createElement("arg");i.setAttribute("name",e.name),i.setAttribute("id",e.id),i.setAttribute("type",e.type),t.appendChild(i)}),t},domToMutation:function(t){const e=[];for(let i=0;i<t.childNodes.length;++i){const o=t.childNodes[i];"arg"==o.nodeName.toLowerCase()&&e.push({id:o.getAttribute("id"),name:o.getAttribute("name"),type:o.getAttribute("type")})}this.arguments_=e,this.name_=t.getAttribute("name"),this.restoreSavedFunctionId(t.getAttribute("functionid"))},saveExtraState:function(){return{name:this.name_,functionid:this.functionId_,arguments:this.arguments_.slice()}},loadExtraState:function(t){this.arguments_=t.arguments.slice(),this.name_=t.name,this.restoreSavedFunctionId(t.functionid)},restoreSavedFunctionId:function(t){(0,n.idsInUse)(this.workspace).indexOf(t)<0&&(this.functionId_=t),this.ensureIds_();let e=null;this instanceof o.BlockSvg&&(e=this.getHeightWidth()),this.type!==s.FUNCTION_DEFINITION_BLOCK_TYPE||e&&!e.height&&!e.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 t=[];for(let e,i=0;e=this.inputList[i];i++)e.type==o.inputs.inputTypes.VALUE?e.dispose():t.push(e);this.inputList=t},createAllInputs_:function(){let t=!1,e=!1;if(this.inputList.forEach(function(i){"function_title"==i.name?t=!0:"function_name"==i.name&&(e=!0)}),!t){let t="";switch(this.type){case s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case s.FUNCTION_CALL_BLOCK_TYPE:t=o.Msg[r.MsgKey.FUNCTIONS_CALL_TITLE];break;case s.FUNCTION_DEFINITION_BLOCK_TYPE:case s.FUNCTION_DECLARATION_BLOCK_TYPE:t=o.Msg[r.MsgKey.FUNCTIONS_DEFNORETURN_TITLE]}this.appendDummyInput("function_title").appendField(t,"function_title")}e?this.updateFunctionLabel_(this.getName()):this.addFunctionLabel_(this.getName()),this.updateArgumentInputs_()},updateArgumentInputs_(){var t;for(const t of this.inputList)if(t.type===o.inputs.inputTypes.VALUE&&!this.arguments_.some(e=>e.id===t.name)){if(this.type===s.FUNCTION_DEFINITION_BLOCK_TYPE){const e=t.connection.targetBlock();e&&e.dispose()}this.removeInput(t.name)}let e=this.inputList.findIndex(t=>t.type===o.inputs.inputTypes.VALUE);-1===e&&(e=this.inputList.length);for(const i of this.arguments_){let o=this.inputList.find(t=>t.name===i.id);const s=!o;s&&(o=this.appendValueInput(i.id)),this.inputList.indexOf(o)!==e&&this.moveInputBefore(o.name,null===(t=this.inputList[e+1])||void 0===t?void 0:t.name),(0,n.isCustomType)(i.type)?o.setCheck(i.type):o.setCheck(i.type.charAt(0).toUpperCase()+i.type.slice(1)),!this.isInsertionMarker()&&s&&this.populateArgument_(i,void 0,o),e++}this.inputList.some(t=>"function_collapse"===t.name)&&this.moveInputBefore("function_collapse",null),this.hasStatements_&&this.moveInputBefore("STACK",null)},updateDisplay_:function(){let t=this.rendered;this.createAllInputs_(),t&&!this.isInsertionMarker()&&this instanceof o.BlockSvg&&(this.initSvg(),this.queueRender())},setStatements_:function(t){this.hasStatements_!==t&&(t?this.appendStatementInput("STACK"):this.removeInput("STACK",!0),this.hasStatements_=t)},ensureIds_:function(){switch(this.type){case s.FUNCTION_DEFINITION_BLOCK_TYPE:this.functionId_&&"null"!=this.functionId_||(this.functionId_=o.utils.idGenerator.genUid());for(let t=0;t<this.arguments_.length;++t)this.arguments_[t].id||(this.arguments_[t].id=o.utils.idGenerator.genUid());break;case s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE:case s.FUNCTION_CALL_BLOCK_TYPE:const t=(0,n.getDefinition)(this.name_,this.workspace);if(t){this.functionId_=t.getFunctionId();const e=t.getArguments();for(let t=0;t<this.arguments_.length;++t)for(let i=0;i<e.length;++i)if(e[i].name==this.arguments_[t].name){this.arguments_[t].id=e[i].id;break}}}}}},{"./constants":121,"./msg":128,"./utils":130,blockly:192}],121:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE=i.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE=i.ARGUMENT_EDITOR_STRING_BLOCK_TYPE=i.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE=i.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE=i.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE=i.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE=i.ARGUMENT_REPORTER_STRING_BLOCK_TYPE=i.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE=i.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE=i.FUNCTION_CALL_OUTPUT_BLOCK_TYPE=i.FUNCTION_CALL_BLOCK_TYPE=i.FUNCTION_DECLARATION_BLOCK_TYPE=i.FUNCTION_DEFINITION_BLOCK_TYPE=void 0,i.FUNCTION_DEFINITION_BLOCK_TYPE="function_definition",i.FUNCTION_DECLARATION_BLOCK_TYPE="function_declaration",i.FUNCTION_CALL_BLOCK_TYPE="function_call",i.FUNCTION_CALL_OUTPUT_BLOCK_TYPE="function_call_output",i.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE="argument_reporter_boolean",i.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE="argument_reporter_number",i.ARGUMENT_REPORTER_STRING_BLOCK_TYPE="argument_reporter_string",i.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE="argument_reporter_array",i.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE="argument_reporter_custom",i.ARGUMENT_EDITOR_BOOLEAN_BLOCK_TYPE="argument_editor_boolean",i.ARGUMENT_EDITOR_NUMBER_BLOCK_TYPE="argument_editor_number",i.ARGUMENT_EDITOR_STRING_BLOCK_TYPE="argument_editor_string",i.ARGUMENT_EDITOR_ARRAY_BLOCK_TYPE="argument_editor_array",i.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE="argument_editor_custom"},{}],122:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("./utils"),n=t("./msg"),r=t("./svgs"),a=new o.zelos.ConstantProvider;const l={customContextMenu:function(t){var e,i;const r={enabled:!(null===(i=null===(e=this.workspace)||void 0===e?void 0:e.options)||void 0===i?void 0:i.readOnly),text:o.Msg[n.MsgKey.FUNCTIONS_GO_TO_DEFINITION_OPTION],callback:()=>{const t=this.getField("function_name").getText(),e=(0,s.getDefinition)(t,this.workspace);e&&this.workspace instanceof o.WorkspaceSvg&&this.workspace.centerOnBlock(e.id,!0)}};t.push(r)}},c={customContextMenu:function(t){if(this.isCollapsed())return;const e={text:o.Msg.RENAME_VARIABLE,enabled:!this.workspace.options.readOnly,callback:()=>{const t=this.workspace,e=this.getField("VAR").getVariable();o.Variables.renameVariable(t,e)}};if(t.unshift(e),!this.isInFlyout){const e=this.workspace.getVariableMap().getVariablesOfType("");for(const i of e){const e={enabled:!this.workspace.options.readOnly,text:i.getName(),callback:()=>{let t=this.getField("VAR");t||pxt.log("Tried to get a variable field on the wrong type of block."),t.setValue(i.getId())}};t.unshift(e)}}}};o.Extensions.registerMixin("function_contextmenu_edit",l),o.Extensions.registerMixin("contextMenu_variableReporter",c),o.Extensions.register("output_number",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Number")}),o.Extensions.register("output_string",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"String")}),o.Extensions.register("output_boolean",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.HEXAGONAL),this.setOutput(!0,"Boolean")}),o.Extensions.register("output_array",function(){this.setInputsInline(!0),this.setOutputShape(a.SHAPES.ROUND),this.setOutput(!0,"Array")}),o.Extensions.register("text_field_color",function(){if(this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer().getConstants();this.setColour(t.FIELD_BORDER_RECT_COLOUR)}else this.setColour("#fff")}),o.Extensions.register("inline-svgs",function(){this.ADD_IMAGE_DATAURI=r.ADD_IMAGE_DATAURI,this.REMOVE_IMAGE_DATAURI=r.REMOVE_IMAGE_DATAURI})},{"./msg":128,"./svgs":129,"./utils":130,blockly:192}],123:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldArgumentEditor=void 0;const o=t("blockly"),s=t("../functionManager"),n=t("../../../external"),r=t("../msg");class a extends o.FieldTextInput{constructor(t,e,i){super(t,e,i)}showEditor(t){var e,i;super.showEditor(t);const n=o.WidgetDiv.getDiv();n.className+=" argumentEditorInput";const r=document.createElement("img");r.setAttribute("class","argumentEditorRemoveIcon"),r.setAttribute("src",a.REMOVE_ARG_URI),this.removeButtonMouseWrapper_=o.browserEvents.conditionalBind(r,"mousedown",this,this.removeCallback),n.appendChild(r);const l=null===(e=this.sourceBlock_)||void 0===e?void 0:e.getTypeName();if(l&&(null===(i=this.sourceBlock_)||void 0===i?void 0:i.workspace)){const t=s.FunctionManager.getInstance().getIconForType(l);if(t){const e=t+" icon argumentEditorTypeIcon",i=document.createElement("i");i.className=e,n.appendChild(i)}}}showEditor_(t,e=!1,i=!0){this.workspace_=this.sourceBlock_.workspace,!e&&this.workspace_.options.modalInputs&&(o.utils.userAgent.MOBILE||o.utils.userAgent.ANDROID||o.utils.userAgent.IPAD)?this.showPromptEditorModal():super.showEditor_(t,e,i)}showPromptEditorModal(){(0,n.prompt)(o.Msg.CHANGE_VALUE_TITLE,this.getText(),t=>{null!==t&&this.setValue(this.getValueFromEditorText_(t)),this.onFinishEditing_(this.value_)},{placeholder:void 0,buttons:[{label:o.Msg[r.MsgKey.FUNCTIONS_DELETE_PARAMETER_BUTTON],className:"red",icon:"trash",onclick:()=>{this.removeCallback()}}]})}removeCallback(){var t,e;const i=null===(t=this.sourceBlock_)||void 0===t?void 0:t.getParent();if(!i)return;let s;for(const t of i.inputList){if((null===(e=t.connection)||void 0===e?void 0:e.targetBlock())===this.sourceBlock_){s=t.name;break}}s&&(o.WidgetDiv.hide(),i.removeInput(s))}}i.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",o.fieldRegistry.register("field_argument_editor",a),o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.setArgumentReporterLocalizeFunction=i.FieldArgumentReporter=void 0;const o=t("blockly"),s=t("../utils");let n;class r extends o.FieldLabelSerializable{getDisplayText_(){const t=this.getSourceBlock();if(t&&(0,s.isFunctionArgumentReporter)(t)&&n){const e=n(this,t);if(e)return e}return super.getDisplayText_()}}i.FieldArgumentReporter=r,i.setArgumentReporterLocalizeFunction=function(t){n=t},o.registry.register(o.registry.Type.FIELD,"field_argument_reporter",r)},{"../utils":130,blockly:192}],125:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldAutocapitalizeTextInput=void 0;const o=t("blockly");class s extends o.FieldTextInput{constructor(t,e,i){super(t,e,i),this.disableAutocapitalize=!1}setAutocapitalize(t){this.disableAutocapitalize=!t,this.htmlInput_&&(this.disableAutocapitalize?this.htmlInput_.setAttribute("autocapitalize","none"):this.htmlInput_.removeAttribute("autocapitalize"))}configure_(t){super.configure_(t),void 0!==t.disableAutocapitalize&&(this.disableAutocapitalize=t.disableAutocapitalize)}widgetCreate_(){const t=super.widgetCreate_();return this.disableAutocapitalize&&t.setAttribute("autocapitalize","none"),t}}i.FieldAutocapitalizeTextInput=s,o.fieldRegistry.register("field_autocapitalize_text_input",s)},{blockly:192}],126:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FunctionManager=void 0;const o=t("blockly"),s=t("./msg");class n{constructor(){this.typeIcons={},this.typeArgumentNames={}}static getInstance(){return n.instance}getIconForType(t){return this.typeIcons[t]}setIconForType(t,e){this.typeIcons[t]=e}setArgumentNameForType(t,e){this.typeArgumentNames[t]=e}getArgumentNameForType(t){return this.typeArgumentNames[t]?this.typeArgumentNames[t]:o.Msg[s.MsgKey.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME]}setEditFunctionExternal(t){this._editFunctionExternal=t}editFunctionExternal(t,e){this._editFunctionExternal?this._editFunctionExternal(t,e):pxt.warn("External function editor must be overriden: Blockly.Functions.editFunctionExternalHandler",t,e)}}i.FunctionManager=n,n.instance=new n},{"./msg":128,blockly:192}],127:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.validateFunctionExternal=i.getAllFunctionDefinitionBlocks=i.getDefinition=i.flyoutCategory=void 0,s(t("./msg"),i),s(t("./extensions"),i),s(t("./fields/fieldArgumentEditor"),i),s(t("./fields/fieldArgumentReporter"),i),s(t("./fields/fieldAutocapitalizeTextInput"),i),s(t("./blocks/argumentEditorBlocks"),i),s(t("./blocks/argumentReporterBlocks"),i),s(t("./blocks/functionDeclarationBlock"),i),s(t("./blocks/functionDefinitionBlock"),i),s(t("./blocks/functionCallBlocks"),i),s(t("./functionManager"),i);var n=t("./utils");Object.defineProperty(i,"flyoutCategory",{enumerable:!0,get:function(){return n.flyoutCategory}}),Object.defineProperty(i,"getDefinition",{enumerable:!0,get:function(){return n.getDefinition}}),Object.defineProperty(i,"getAllFunctionDefinitionBlocks",{enumerable:!0,get:function(){return n.getAllFunctionDefinitionBlocks}}),Object.defineProperty(i,"validateFunctionExternal",{enumerable:!0,get:function(){return n.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MsgKey=void 0;const o=t("blockly");var s;function n(t,e){o.Msg[t]||(o.Msg[t]=e)}!function(t){t.REPORTERS_HUE="REPORTERS_HUE",t.FUNCTIONS_CALL_TITLE="FUNCTIONS_CALL_TITLE",t.FUNCTIONS_DEFNORETURN_TITLE="FUNCTIONS_DEFNORETURN_TITLE",t.FUNCTIONS_GO_TO_DEFINITION_OPTION="FUNCTIONS_GO_TO_DEFINITION_OPTION",t.FUNCTION_CALL_TOOLTIP="FUNCTION_CALL_TOOLTIP",t.PROCEDURES_HUE="PROCEDURES_HUE",t.PROCEDURES_CALLNORETURN_HELPURL="PROCEDURES_CALLNORETURN_HELPURL",t.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME="FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME",t.FUNCTIONS_DEFAULT_STRING_ARG_NAME="FUNCTIONS_DEFAULT_STRING_ARG_NAME",t.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME="FUNCTIONS_DEFAULT_NUMBER_ARG_NAME",t.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME="FUNCTIONS_DEFAULT_ARRAY_ARG_NAME",t.PROCEDURES_DEFNORETURN_TOOLTIP="PROCEDURES_DEFNORETURN_TOOLTIP",t.PROCEDURES_DEFNORETURN_HELPURL="PROCEDURES_DEFNORETURN_HELPURL",t.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME="FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME",t.FUNCTIONS_DEFAULT_FUNCTION_NAME="FUNCTIONS_DEFAULT_FUNCTION_NAME",t.FUNCTION_CREATE_NEW="FUNCTION_CREATE_NEW",t.FUNCTION_FLYOUT_LABEL="FUNCTION_FLYOUT_LABEL",t.FUNCTIONS_EDIT_OPTION="FUNCTIONS_EDIT_OPTION",t.FUNCTIONS_CREATE_CALL_OPTION="FUNCTIONS_CREATE_CALL_OPTION",t.FUNCTIONS_DELETE_PARAMETER_BUTTON="FUNCTIONS_DELETE_PARAMETER_BUTTON"}(s=i.MsgKey||(i.MsgKey={})),n(s.REPORTERS_HUE,"#A80000"),n(s.FUNCTIONS_CALL_TITLE,"call"),n(s.FUNCTIONS_DEFNORETURN_TITLE,"function"),n(s.FUNCTIONS_GO_TO_DEFINITION_OPTION,"Go to Definition"),n(s.FUNCTIONS_DEFAULT_BOOLEAN_ARG_NAME,"bool"),n(s.FUNCTIONS_DEFAULT_STRING_ARG_NAME,"text"),n(s.FUNCTIONS_DEFAULT_NUMBER_ARG_NAME,"num"),n(s.FUNCTIONS_DEFAULT_ARRAY_ARG_NAME,"array"),n(s.FUNCTIONS_DEFAULT_CUSTOM_ARG_NAME,"value"),n(s.FUNCTIONS_DEFAULT_FUNCTION_NAME,"doSomething"),n(s.FUNCTION_CREATE_NEW,"Make a Function"),n(s.FUNCTION_FLYOUT_LABEL,"Your Functions"),n(s.FUNCTIONS_EDIT_OPTION,"Edit Function"),n(s.FUNCTIONS_CREATE_CALL_OPTION,"Create 'call %1'"),n(s.FUNCTIONS_DELETE_PARAMETER_BUTTON,"Delete")},{blockly:192}],129:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.REMOVE_IMAGE_DATAURI=i.ADD_IMAGE_DATAURI=i.COLLAPSE_IMAGE_DATAURI=void 0,i.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",i.ADD_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJhZGQuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjQ4MjEiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NjkiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjEyLjkxNTI1NCIKICAgICBpbmtzY2FwZTpjeT0iMTYuMDY3Nzk2IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIwIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0icmVwZWF0IiAvPjxzdHlsZQogICAgIHR5cGU9InRleHQvY3NzIgogICAgIGlkPSJzdHlsZTMiPgoJLnN0MHtmaWxsOiNDRjhCMTc7fQoJLnN0MXtmaWxsOiNGRkZGRkY7fQo8L3N0eWxlPjx0aXRsZQogICAgIGlkPSJ0aXRsZTUiPnJlcGVhdDwvdGl0bGU+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMiCiAgICAgd2lkdGg9IjQuMDUwMDAwMiIKICAgICBoZWlnaHQ9IjEyLjM5NzA1IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSItMTguMTk4NTI2IgogICAgIHJ4PSIwLjgxIgogICAgIHJ5PSIwLjgxIgogICAgIHRyYW5zZm9ybT0ic2NhbGUoMSwtMSkiIC8+PHJlY3QKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6I2ZmZmZmZjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MTtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MC4wNzg0MzEzNyIKICAgICBpZD0icmVjdDQxNDMtMSIKICAgICB3aWR0aD0iNC4wNTAwMDAyIgogICAgIGhlaWdodD0iMTIuMzk3MTE5IgogICAgIHg9IjkuOTc1MDAwNCIKICAgICB5PSI1LjgwMTQ0MDciCiAgICAgcng9IjAuODEiCiAgICAgcnk9IjAuODEiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMCwxLDEsMCwwLDApIiAvPjxjaXJjbGUKICAgICBzdHlsZT0ib3BhY2l0eToxO2ZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6I2ZmZmZmZjtzdHJva2Utd2lkdGg6MjtzdHJva2UtbGluZWNhcDpzcXVhcmU7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLW9wYWNpdHk6MSIKICAgICBpZD0icGF0aDQxMzYiCiAgICAgY3g9IjEyIgogICAgIGN5PSIxMiIKICAgICByPSIxMC41MDMxOTEiIC8+PC9zdmc+",i.REMOVE_IMAGE_DATAURI="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0icmVwZWF0IgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDI0IDI0IgogICBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJyZW1vdmUuc3ZnIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGExNSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+cmVwZWF0PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PGRlZnMKICAgICBpZD0iZGVmczEzIiAvPjxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBwYWdlY29sb3I9IiNmZjFhZmYiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMSIKICAgICBvYmplY3R0b2xlcmFuY2U9IjEwIgogICAgIGdyaWR0b2xlcmFuY2U9IjEwIgogICAgIGd1aWRldG9sZXJhbmNlPSIxMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTY4MCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI5NTAiCiAgICAgaWQ9Im5hbWVkdmlldzExIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTp6b29tPSIxOS42NjY2NjciCiAgICAgaW5rc2NhcGU6Y3g9IjAuMDUwODQ3NTIxIgogICAgIGlua3NjYXBlOmN5PSI5Ljk2NjEwMTciCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJyZXBlYXQiIC8+PHN0eWxlCiAgICAgdHlwZT0idGV4dC9jc3MiCiAgICAgaWQ9InN0eWxlMyI+Cgkuc3Qwe2ZpbGw6I0NGOEIxNzt9Cgkuc3Qxe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU+PHRpdGxlCiAgICAgaWQ9InRpdGxlNSI+cmVwZWF0PC90aXRsZT48cmVjdAogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eTowLjA3ODQzMTM3IgogICAgIGlkPSJyZWN0NDE0My0xIgogICAgIHdpZHRoPSI0LjA1MDAwMDIiCiAgICAgaGVpZ2h0PSIxMi4zOTcxMTkiCiAgICAgeD0iOS45NzUwMDA0IgogICAgIHk9IjUuODAxNDQwNyIKICAgICByeD0iMC44MSIKICAgICByeT0iMC44MSIKICAgICB0cmFuc2Zvcm09Im1hdHJpeCgwLDEsMSwwLDAsMCkiIC8+PGNpcmNsZQogICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojZmZmZmZmO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnNxdWFyZTtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLWRhc2hvZmZzZXQ6MDtzdHJva2Utb3BhY2l0eToxIgogICAgIGlkPSJwYXRoNDEzNiIKICAgICBjeD0iMTIiCiAgICAgY3k9IjEyIgogICAgIHI9IjEwLjUwMzE5MSIgLz48L3N2Zz4="},{}],130:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isVariableBlockType=i.validateFunctionExternal=i.flyoutCategory=i.getShadowBlockInfoFromType_=i.findUniqueParamName=i.getArgumentReporterParent=i.doArgumentReporterDragChecks=i.isFunctionArgumentReporter=i.getArgMap=i.mutateCallersAndDefinition=i.idsInUse=i.findLegalName=i.createCustomArgumentEditor=i.createCustomArgumentReporter=i.isCustomType=i.getAllFunctionDefinitionBlocks=i.getDefinition=i.rename=void 0;const o=t("blockly"),s=t("./constants"),n=t("./functionManager"),r=t("./msg"),a=t("./blocks/functionDeclarationBlock"),l=t("../../compiler/util"),c=t("../../loader");function h(t,e){for(const i of e.getTopBlocks(!1))if(i.type===s.FUNCTION_DEFINITION_BLOCK_TYPE){const e=i;if(e.getName()===t)return e}return null}function u(t){return t.getTopBlocks(!1).filter(t=>t.type===s.FUNCTION_DEFINITION_BLOCK_TYPE)}function d(t,e,i){const s=i.newBlock(t),n=o.utils.xml.createElement("mutation");return n.setAttribute("typename",e),s.domToMutation(n),s}function p(t,e,i){if(null==i?void 0:i.isInFlyout)return t;const o=g(e,i);for(;o[t];)t=m(t);return t}function g(t,e,i){const o={};return t.getVariableMap().getAllVariables().forEach(function(t){o[t.getName()]=!0}),t.getAllBlocks(!1).forEach(function(t){const n=t;n==e||i&&n.getFunctionId&&n.getFunctionId()==i||(n.type==s.FUNCTION_DEFINITION_BLOCK_TYPE?o[n.getName()]=!0:"procedures_defreturn"==t.type||t.type)}),o}function m(t){const e=t.match(/^(.*?)(\d+)$/);return e?t=e[1]+(parseInt(e[2],10)+1):t+="2",t}function _(t,e,i){const n=h(t,e);if(n){const r=n.mutationToDom(),a=f(r,!1),l=f(i,!0),c=[];for(const t of n.getDescendants(!1)){if(!T(t))continue;const e=b(t,t);if(e&&e!==n)continue;const i=t.getFieldValue("VALUE"),o=l[a[i]];if(i===o)continue;const s=t.outputConnection.targetBlock().id,r=t.outputConnection.targetConnection.getParentInput().name;c.push({id:t.id,type:t.type,oldName:i,newName:o,targetBlockId:s,targetInputName:r})}const h=function(t,e){const i=[];for(const o of e.getAllBlocks(!1))if(o.type===s.FUNCTION_CALL_BLOCK_TYPE||o.type===s.FUNCTION_CALL_OUTPUT_BLOCK_TYPE){const e=o;e.getName()===t&&i.push(e)}return i}(t,n.workspace).map(t=>({id:t.id,oldMutation:o.utils.xml.domToText(t.mutationToDom()),shadows:t.serializeChangedInputs(i)})),u=new y(n.id,h,o.Xml.domToText(r),o.Xml.domToText(i),c);u.workspaceId=e.id,u.run(!0),o.Events.fire(u)}else pxt.warn("Attempted to change function "+t+", but no definition block was found on the workspace")}function f(t,e){const i={};for(let o=0;o<t.childNodes.length;++o){const s=t.childNodes[o],n=e?s.getAttribute("id"):s.getAttribute("name"),r=e?s.getAttribute("name"):s.getAttribute("id");i[n]=r}return i}function T(t){return t.type==s.ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_STRING_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE||t.type==s.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE}function b(t,e){pxt.U.assert(T(t));const i=t.getFieldValue("VALUE"),o=t.getTypeName();for(;e.getSurroundParent();){e=e.getSurroundParent();for(const t of e.inputList){if(!t.connection||!t.name.startsWith(c.DRAGGABLE_PARAM_INPUT_PREFIX))continue;if(t.name.slice(c.DRAGGABLE_PARAM_INPUT_PREFIX.length)!==i)continue;let s=o;return"string"!==s&&"number"!==s&&"boolean"!==s||(s=s.charAt(0).toUpperCase()+s.slice(1)),-1!==t.connection.getCheck().indexOf(s)?e:void 0}}if(!e.isEnabled())return e;if((0,l.isFunctionDefinition)(e)){if(e.getArguments().some(t=>t.name===i&&t.type===o))return e}}function E(t,e){return!e||-1==e.indexOf(t)}i.rename=function(t){t=t.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");const e=this.sourceBlock_,i=p(t,e.workspace,e),o=this.getValue();if(!t)return o;if(!i)return t;if(!o)return e.name_=i,i;if(o!=t&&o!=i){e.name_=i;const t=e.mutationToDom();e.name_=o,_(o,e.workspace,t)}return i},i.getDefinition=h,i.getAllFunctionDefinitionBlocks=u,i.isCustomType=function(t){return!("boolean"==t||"string"==t||"number"==t)},i.createCustomArgumentReporter=function(t,e){return d(s.ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE,t,e)},i.createCustomArgumentEditor=function(t,e){return d(s.ARGUMENT_EDITOR_CUSTOM_BLOCK_TYPE,t,e)},i.findLegalName=p,i.idsInUse=function(t){const e=[];return t.getAllBlocks(!1).forEach(function(t){t.type==s.FUNCTION_DEFINITION_BLOCK_TYPE&&e.push(t.getFunctionId())}),e},i.mutateCallersAndDefinition=_,i.getArgMap=f,i.isFunctionArgumentReporter=T,i.doArgumentReporterDragChecks=function(t,e,i){const o=t.getSourceBlock();if(!T(o))return!0;const s=e.getSourceBlock();return!s||!!b(o,s)},i.getArgumentReporterParent=b,i.findUniqueParamName=function(t,e){for(;!E(t,e);)t=m(t);return t},i.getShadowBlockInfoFromType_=function(t,e){let i="",s="",r="";switch(t){case"boolean":i="logic_boolean",s="BOOL",r="TRUE";break;case"number":i="math_number",s="NUM",r="1";break;case"string":i="text",s="TEXT",r="abc";break;case"Array":i="variables_get",s="VAR",r=o.Variables.getOrCreateVariablePackage(e,null,"list","").getId();break;default:i="variables_get",s="VAR",r=o.Variables.getOrCreateVariablePackage(e,null,n.FunctionManager.getInstance().getArgumentNameForType(t),"").getId()}return[i,s,r]},i.flyoutCategory=function(t){const e=[],i=document.createElement("button"),l=o.Msg[r.MsgKey.FUNCTION_CREATE_NEW],c="CREATE_FUNCTION";i.setAttribute("text",l),i.setAttribute("callbackKey",c),t.registerButtonCallback(c,()=>{!function(t){o.hideChaff(),o.getSelected()&&o.getSelected().unselect();n.FunctionManager.getInstance().editFunctionExternal((0,a.newFunctionMutation)(t),function(t){return function(e){if(e){const i='<xml><block type="'+s.FUNCTION_DEFINITION_BLOCK_TYPE+'">'+o.Xml.domToText(e)+"</block></xml>",n=o.utils.xml.textToDom(i);o.Events.setGroup(!0);const r=o.Xml.domToBlock(n.firstChild,t);if(r.updateDisplay_(),t.getMetrics){const e=t.getMetrics(),i=r.getHeightWidth();r.moveBy(e.viewLeft+e.viewWidth/2-i.width/2,e.viewTop+e.viewHeight/2-i.height/2),r.scheduleSnapAndBump()}t.centerOnBlock(r.id,!0),o.Events.setGroup(!1),setTimeout(()=>{r.afterWorkspaceLoad&&r.afterWorkspaceLoad(),o.getFocusManager().focusNode(r)})}}}(t))}(t)}),e.push(i);for(const i of u(t)){const t=i.getName(),s=i.getArguments(),n=o.utils.xml.createElement("block");n.setAttribute("type","function_call"),n.setAttribute("gap","16");const r=o.utils.xml.createElement("mutation");r.setAttribute("name",t),n.appendChild(r);for(let t=0;t<s.length;t++){const e=o.utils.xml.createElement("arg");e.setAttribute("name",s[t].name),e.setAttribute("type",s[t].type),e.setAttribute("id",s[t].id),r.appendChild(e)}e.push(n)}return e},i.validateFunctionExternal=function(t,e){const i=t.getAttribute("name");if(!i)return o.dialog.alert(o.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;const s={};for(let e=0;e<t.childNodes.length;++e){const i=t.childNodes[e].getAttribute("name");if(!i)return o.dialog.alert(o.Msg.FUNCTION_WARNING_EMPTY_NAME),!1;if(s[i])return o.dialog.alert(o.Msg.FUNCTION_WARNING_DUPLICATE_ARG),!1;s[i]=!0}return s[i]?(o.dialog.alert(o.Msg.FUNCTION_WARNING_ARG_NAME_IS_FUNCTION_NAME),!1):!g(e,null,t.getAttribute("functionid"))[i]||(o.dialog.alert(o.Msg.VARIABLE_ALREADY_EXISTS.replace("%1",i)),!1)},i.isVariableBlockType=function(t){switch(t){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 y extends o.Events.Abstract{constructor(t,e,i,o,s){super(),this.definition=t,this.callers=e,this.oldMutation=i,this.newMutation=o,this.descendantChanges=s,this.type="pxt_mutate_function"}static fromJson(t,e,i){const o=i=super.fromJson(t,e,i||new y(t.definition,t.callers,t.oldMutation,t.newMutation,t.descendantChanges));return o.definition=t.definition,o.callers=t.callers,o.oldMutation=t.oldMutation,o.newMutation=t.newMutation,o.descendantChanges=t.descendantChanges,i}toJson(){return{type:this.type,group:this.group,definition:this.definition,callers:this.callers,oldMutation:this.oldMutation,newMutation:this.newMutation,descendantChanges:this.descendantChanges}}run(t){const e=this.getEventWorkspace_(),i=o.utils.xml.textToDom(t?this.newMutation:this.oldMutation),s=e.getBlockById(this.definition);o.Events.disable(),s.domToMutation(i),s.updateArgumentInputs_(),s.afterWorkspaceLoad();for(const s of this.callers){const n=e.getBlockById(s.id);if(t)n.domToMutation(i);else{n.domToMutation(o.utils.xml.textToDom(s.oldMutation));for(const t of s.shadows)if(t.connectedBlock){const i=e.getBlockById(t.connectedBlock);n.getInput(t.inputName).connection.connect(i.outputConnection)}else n.getInput(t.inputName).connection.setShadowState(t.connectedShadow)}}for(const i of this.descendantChanges)if(i.newName){e.getBlockById(i.id).setFieldValue(t?i.newName:i.oldName,"VALUE")}else if(t){const t=e.getBlockById(i.id);t&&t.dispose()}else{const t=e.newBlock(i.type,i.id);t.setFieldValue(i.oldName,"VALUE"),t.initSvg();const o=e.getBlockById(i.targetBlockId).getInput(i.targetInputName).connection,s=o.targetBlock();s&&(s.isShadow()||s.dispose()),o.connect(t.outputConnection)}o.Events.enable()}}},{"../../compiler/util":15,"../../loader":79,"./blocks/functionDeclarationBlock":118,"./constants":121,"./functionManager":126,"./msg":128,blockly:192}],131:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly");o.Extensions.unregister("logic_compare"),o.Extensions.register("logic_compare",function(){})},{blockly:192}],132:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../../fields/field_imagenotext"),n=t("../../utils"),r={elseifCount_:0,elseCount_:0,valueConnections_:[],statementConnections_:[],elseStatementConnection_:null,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=o.utils.xml.createElement("mutation");return this.elseifCount_&&t.setAttribute("elseif",this.elseifCount_+""),this.elseCount_&&t.setAttribute("else","1"),t},domToMutation:function(t){t&&(this.elseifCount_=parseInt(t.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(t.getAttribute("else"),10)||0,this.rebuildShape_())},storeConnections_:function(t){t||(t=0),this.valueConnections_=[null],this.statementConnections_=[null],this.elseStatementConnection_=null;for(let e=1;e<=this.elseifCount_;e++)t!=e&&(this.valueConnections_.push(this.getInput("IF"+e).connection.targetConnection),this.statementConnections_.push(this.getInput("DO"+e).connection.targetConnection));this.getInput("ELSE")&&(this.elseStatementConnection_=this.getInput("ELSE").connection.targetConnection)},restoreConnections_:function(){var t,e;for(let e=1;e<=this.elseifCount_;e++)this.reconnectValueConnection_(e,this.valueConnections_),null===(t=this.statementConnections_[e])||void 0===t||t.reconnect(this,"DO"+e);this.getInput("ELSE")&&(null===(e=this.elseStatementConnection_)||void 0===e||e.reconnect(this,"ELSE"))},addElse_:function(){o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch added."));this.update_(()=>{this.elseCount_++})},removeElse_:function(){var t,e;o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else branch removed."));this.update_(()=>{this.elseCount_--});const i="IF"+this.elseifCount_;(0,n.maybeMoveFocusFromButton)(null===(e=null===(t=this.getInput(i))||void 0===t?void 0:t.connection)||void 0===e?void 0:e.targetBlock())},addElseIf_:function(){o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch added."));this.update_(()=>{this.elseifCount_++})},removeElseIf_:function(t){var e,i;o.utils.aria.announceDynamicAriaState(pxt.Util.lf("Else if branch removed."));this.update_(()=>{this.elseifCount_--},t);const s="IF"+(t-1);(0,n.maybeMoveFocusFromButton)(null===(i=null===(e=this.getInput(s))||void 0===e?void 0:e.connection)||void 0===i?void 0:i.targetBlock())},update_:function(t,e){o.Events.setGroup(!0),this.storeConnections_(e);const i=this,s=i.mutationToDom(),n=s&&o.Xml.domToText(s);t&&t.call(this),this.updateShape_(),i instanceof o.BlockSvg&&i.initSvg();const r=o.Events.getGroup(),a=i.mutationToDom(),l=a&&o.Xml.domToText(a);n!=l&&(o.Events.fire(new o.Events.BlockChange(i,"mutation",null,n,l)),setTimeout(function(){o.Events.setGroup(r),i.bumpNeighbours(),o.Events.setGroup(!1)},o.config.bumpDelay)),i.rendered&&i instanceof o.BlockSvg&&i.queueRender(),this.restoreConnections_(),o.Events.setGroup(!1)},updateShape_:function(){this.getInput("ELSE")&&(this.removeInput("ELSE"),this.removeInput("ELSETITLE"),this.removeInput("ELSEBUTTONS"));let t=1;for(;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("IFTITLE"+t),this.removeInput("IFBUTTONS"+t),this.removeInput("DO"+t),t++;for(let t=1;t<=this.elseifCount_;t++){const i=function(t){return function(){e.removeElseIf_(t)}}(t);this.appendValueInput("IF"+t).setCheck("Boolean").appendField(o.Msg.CONTROLS_IF_MSG_ELSEIF).setShadowDom(a()),this.appendDummyInput("IFTITLE"+t).appendField(o.Msg.CONTROLS_IF_MSG_THEN),this.appendDummyInput("IFBUTTONS"+t).appendField(new s.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,pxt.Util.lf("remove else if branch"),i,!1)).setAlign(o.inputs.Align.RIGHT),this.appendStatementInput("DO"+t)}this.elseCount_&&(this.appendDummyInput("ELSETITLE").appendField(o.Msg.CONTROLS_IF_MSG_ELSE),this.appendDummyInput("ELSEBUTTONS").setAlign(o.inputs.Align.RIGHT).appendField(new s.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 e=this,i=function(){var t,i,s;if(0==e.elseCount_)e.addElse_(),(0,n.maybeMoveFocusFromButton)(null===(t=e.getInput("ELSEBUTTONS"))||void 0===t?void 0:t.fieldRow[0]);else{e.elseifCount_||(e.elseifCount_=0),e.addElseIf_();const t=o.getFocusManager(),n=null===(s=null===(i=e.getInput("IF"+e.elseifCount_))||void 0===i?void 0:i.connection)||void 0===s?void 0:s.targetBlock();t.focusNode(n)}};this.appendDummyInput("ADDBUTTON").appendField(new s.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,this.elseCount_?pxt.Util.lf("add else if branch"):pxt.Util.lf("add else branch"),i,!1))},rebuildShape_:function(){const t=[null],e=[null];let i=null;this.getInput("ELSE")&&(i=this.getInput("ELSE").connection.targetConnection);let o=1;for(;this.getInput("IF"+o);){const i=this.getInput("IF"+o),s=this.getInput("DO"+o);t.push(i.connection.targetConnection),e.push(s.connection.targetConnection),o++}this.updateShape_(),this.reconnectChildBlocks_(t,e,i)},reconnectChildBlocks_:function(t,e,i){var o;for(let i=1;i<=this.elseifCount_;i++)this.reconnectValueConnection_(i,t),null===(o=e[i])||void 0===o||o.reconnect(this,"DO"+i);null==i||i.reconnect(this,"ELSE")},reconnectValueConnection_:function(t,e){var i;const o=null===(i=this.getInput("IF"+t))||void 0===i?void 0:i.connection.targetBlock();e[t]&&(e[t].reconnect(this,"IF"+t),o&&!o.getParent()&&o.dispose())}};function a(){const t=document.createElement("shadow");t.setAttribute("type","logic_boolean");const e=document.createElement("field");return e.setAttribute("name","BOOL"),e.textContent="FALSE",t.appendChild(e),t}o.Blocks.controls_if=Object.assign(Object.assign({},r),{init(){if(o.Extensions.apply("inline-svgs",this,!1),this.elseifCount_=0,this.elseCount_=0,this.setHelpUrl(o.Msg.CONTROLS_IF_HELPURL),this.appendValueInput("IF0").setCheck("Boolean").appendField(o.Msg.CONTROLS_IF_MSG_IF),this.appendDummyInput("THEN0").appendField(o.Msg.CONTROLS_IF_MSG_THEN),this.appendStatementInput("DO0"),this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer();this.setOutputShape(t.getConstants().SHAPES.HEXAGONAL)}this.updateShape_(),this.setInputsInline(!0),this.setColour(o.Msg.LOGIC_HUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(()=>this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?o.Msg.CONTROLS_IF_TOOLTIP_4:"":o.Msg.CONTROLS_IF_TOOLTIP_1)}})},{"../../fields/field_imagenotext":38,"../../utils":155,blockly:192}],133:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./extensions"),i),s(t("./ifElse"),i)},{"./extensions":131,"./ifElse":132}],134:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldSlider=void 0;const o=t("blockly");class s extends o.FieldNumber{constructor(t,e,i,o,s,n,r,a){super(t,e,i,o,r,a),this.keyboardControlActive=!1,"string"==typeof s?this.step_=parseFloat(s):"number"==typeof s&&(this.step_=s),this.labelText_=n}hasMin(){return this.getMin()>-1/0}hasMax(){return this.getMax()<1/0}getStep(){return this.step_}getLabel(){return this.labelText_}setLabel(t){this.labelText_=t}setOptions(t,e,i,o){this.setConstraints(t,e,o),this.step_=parseFloat(i)||void 0}getFieldDescription(){return this.getValue()+""}doClassValidation_(t){if(null===t)return null;t=(t=(t=(t=`${t}`).replace(/O/gi,"0")).replace(/,/g,"")).replace(/infinity/i,"Infinity");let e=Number(t||0);if(isNaN(e))return null;this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_);let i=String(this.precision_);-1!==i.indexOf("e")&&(i=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const o=i.indexOf(".");let s;return s=-1===o?this.precision_?0:null:i.length-o-1,null!==s&&(e=Number(e.toFixed(s))),e}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(t){"ArrowDown"===t.key&&(t.preventDefault(),this.keyboardControlActive=!0,this.slider_.focus())}sliderPointerdownListener(t){this.keyboardControlActive=!1}sliderKeydownListener(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.htmlInput_.focus();break;case"Enter":case" ":t.preventDefault(),t.stopPropagation(),o.hideChaff();break;case"ArrowDown":t.preventDefault(),t.stopPropagation()}}sliderBlurListener(t){this.keyboardControlActive=!1}showEditor_(t,e){super.showEditor_(t,!0),"number"==typeof this.min_&&"number"==typeof this.max_&&(this.htmlInput_.ariaLabel=lf("Enter a value between {0} and {1}",this.min_,this.max_)),o.DropDownDiv.hideWithoutAnimation(),o.DropDownDiv.clearContent();const i=o.DropDownDiv.getContentDiv();i.style.height="",i.parentElement.classList.add("blocklyFieldSliderDropdown"),this.addSlider_(i),o.DropDownDiv.setColour("#ffffff","#dddddd"),o.DropDownDiv.showPositionedByBlock(this,this.sourceBlock_,void 0,void 0,!1),this.addEventListeners(),e||(this.htmlInput_.focus(),this.htmlInput_.select())}addSlider_(t){if(this.labelText_){let e=this.createLabelDom_(this.labelText_);t.appendChild(e[0]),this.readout_=e[1],this.setReadout(this.value_)}this.slider_=this.createSlider(),t.appendChild(this.slider_);const e=()=>{pxt.BrowserUtils.isFirefox()||this.keyboardControlActive||this.htmlInput_.focus()};o.browserEvents.bind(this.slider_,"input",this,t=>{const i=parseFloat(this.slider_.value)||0;if(null!==i){this.setValue(i);const t=this.htmlInput_;t&&(t.value=i+"",e())}}),o.browserEvents.bind(this.slider_,"focus",this,t=>{e()})}setValue(t,e){super.setValue(t,e),this.updateDom(),this.slider_&&(this.slider_.value=this.getValue()+"")}createSlider(){const t=document.createElement("input");let e;return t.setAttribute("class","blocklyFieldSlider"),t.type="range",t.min=this.getMin()+"",t.max=this.getMax()+"",t.value=this.getValue()+"",this.sourceBlock_ instanceof o.BlockSvg&&("#ffffff"===this.sourceBlock_.getColour()?this.sourceBlock_.getParent()&&(e=this.sourceBlock_.getParent().getColourTertiary()):e=this.sourceBlock_.getColourTertiary()),e&&t.setAttribute("style",`--blocklyFieldSliderBackgroundColor: ${e}`),Number.isNaN(this.step_)||(t.step=this.step_+""),t}updateDom(){this.setReadout(this.getValue())}setReadout(t){this.readout_&&(this.readout_.innerText=t+"")}createLabelDom_(t){const e=document.createElement("div");e.setAttribute("class","blocklyFieldSliderLabel");const i=document.createElement("span");i.setAttribute("class","blocklyFieldSliderReadout");const o=document.createElement("span");return o.setAttribute("class","blocklyFieldSliderLabelText"),o.innerText=t,e.appendChild(o),e.appendChild(i),[e,i]}}i.FieldSlider=s,o.fieldRegistry.register("field_slider",s),o.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(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldSlider"),i),s(t("./numberBlocks"),i)},{"./fieldSlider":134,"./numberBlocks":136}],136:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=new o.zelos.ConstantProvider;o.defineBlocksWithJsonArray([{type:"math_integer",message0:"%1",args0:[{type:"field_number",name:"NUM",precision:1,ariaTypeName:lf("value")}],output:"Number",outputShape:s.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:s.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:s.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:s.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 n={mutationToDom:function(){const t=this.inputList[0].fieldRow[0];let e=o.utils.xml.createElement("mutation");return t.hasMin()&&e.setAttribute("min",t.getMin()+""),t.hasMax()&&e.setAttribute("max",t.getMax()+""),null!=t.getLabel()&&e.setAttribute("label",t.getLabel()),null!=t.getStep()&&e.setAttribute("step",t.getStep()+""),null!=t.getPrecision()&&e.setAttribute("precision",t.getPrecision()+""),e},domToMutation:function(t){const e=this.inputList[0].fieldRow[0],i=t.getAttribute("min"),o=t.getAttribute("max"),s=t.getAttribute("step"),n=t.getAttribute("label"),r=t.getAttribute("precision");e.setLabel(n),e.setOptions(i,o,s,r)}};o.Extensions.registerMutator("math_number_minmax_mutator",n)},{blockly:192}],137:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldVariable=void 0;const o=t("blockly");class s extends o.FieldVariable{constructor(t,e,i,o,n){super(t,e,i,o,n),this.svgRootBinding=null,this.fieldRootBinding=null,this.menuGenerator_=s.dropdownCreate}static dropdownCreate(){const t=o.FieldVariable.dropdownCreate.call(this),e=t.findIndex(t=>"RENAME_VARIABLE_ID"===t[1]);return t.splice(e,0,[o.Msg.NEW_VARIABLE_DROPDOWN,s.CREATE_VARIABLE_ID],o.FieldDropdown.SEPARATOR),t}onItemSelected_(t,e){if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e.getValue()===s.CREATE_VARIABLE_ID)return void o.Variables.createVariableButtonHandler(this.sourceBlock_.workspace,t=>{const e=this.sourceBlock_.workspace.getVariableMap().getVariable(t);e&&this.setValue(e.getId())})}super.onItemSelected_(t,e)}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 t of this.sourceBlock_.inputList)for(const e of t.fieldRow)if(e!==this&&e.EDITABLE)return!0;return!this.sourceBlock_.getInputsInline()||super.shouldAddBorderRect_()}bindEvents_(){this.shouldAddBorderRect_()?super.bindEvents_():(this.svgRootBinding=o.browserEvents.conditionalBind(this.sourceBlock_.getSvgRoot(),"pointerdown",this,t=>{this.sourceBlock_.icons.length||this.onMouseDown_(t)},!1),this.fieldRootBinding=o.browserEvents.conditionalBind(this.getSvgRoot(),"pointerdown",this,t=>{this.sourceBlock_.icons.length&&this.onMouseDown_(t)},!1))}dispose(){super.dispose(),this.svgRootBinding&&(o.browserEvents.unbind(this.svgRootBinding),o.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 t,e;const i=super.getValue();if(null===(t=this.sourceBlock_)||void 0===t?void 0:t.isInFlyout){if((null===(e=this.sourceBlock_.workspace)||void 0===e?void 0:e.getPotentialVariableMap()).getVariableById(i))return"potential_"+i}return i}}i.FieldVariable=s,s.CREATE_VARIABLE_ID="CREATE_VARIABLE",o.fieldRegistry.unregister("field_variable"),o.fieldRegistry.register("field_variable",s)},{blockly:192}],138:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldVariable"),i)},{"./fieldVariable":137}],139:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isCollapsedInputRow=i.CollapsedInputRow=void 0;const o=t("blockly");class s extends o.blockRendering.InputRow{constructor(t){super(t),this.type|=o.blockRendering.Types.INPUT_ROW|o.blockRendering.Types.getType("COLLAPSED_INPUT_ROW")}measure(){this.width=this.minWidth,this.height=this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT}}i.CollapsedInputRow=s,i.isCollapsedInputRow=function(t){return!!(t.type&o.blockRendering.Types.getType("COLLAPSED_INPUT_ROW"))}},{blockly:192}],140:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConnectionPreviewer=void 0;const o=t("blockly");class s extends o.InsertionMarkerPreviewer{previewConnection(t,e){super.previewConnection(t,e),e.type!==o.ConnectionType.INPUT_VALUE&&e.type!==o.ConnectionType.OUTPUT_VALUE||this.showDraggedIndicatorWithLine(t,e)}previewReplacement(t,e,i){super.previewReplacement(t,e,i),this.showDraggedIndicatorWithLine(t,e)}showDraggedIndicatorWithLine(t,e){if(!this.connectionLine){this.connectionLine=o.utils.dom.createSvgElement("line",{class:"blocklyConnectionLine",x1:0,y1:0,x2:0,y2:0},t.sourceBlock_.getSvgRoot()),this.draggedConnectionIndicator=this.createConnectionIndicator(t.sourceBlock_.getSvgRoot(),t);const i=e.sourceBlock_.getSvgRoot().querySelector(":scope>.blocklyConnectionIndicatorParent");this.staticConnectionIndicator=this.createConnectionIndicator(i,e)}this.raiseIndicators(),this.updateLineCoords(t,e),o.renderManagement.finishQueuedRenders().then(()=>{this.connectionLine&&(this.raiseIndicators(),this.updateLineCoords(t,e))})}raiseIndicators(){var t,e;null===(t=this.draggedConnectionIndicator.parentElement)||void 0===t||t.appendChild(this.draggedConnectionIndicator);const i=this.staticConnectionIndicator.parentElement;i.appendChild(this.staticConnectionIndicator),null===(e=i.parentElement)||void 0===e||e.appendChild(i)}updateLineCoords(t,e){const i=s.CONNECTION_INDICATOR_RADIUS,n=t.getOffsetInBlock(),r=e.getOffsetInBlock();this.draggedConnectionIndicator.setAttribute("transform",`translate(${n.x}, ${n.y})`),this.staticConnectionIndicator.setAttribute("transform",`translate(${r.x}, ${r.y})`);const a=o.utils.Coordinate.sum(t.sourceBlock_.getRelativeToSurfaceXY(),n),l=o.utils.Coordinate.sum(e.sourceBlock_.getRelativeToSurfaceXY(),r),c=l.x-a.x,h=l.y-a.y;if(Math.sqrt(c*c+h*h)<2*i+1)return void o.utils.dom.addClass(this.connectionLine,"hidden");o.utils.dom.removeClass(this.connectionLine,"hidden");const u=Math.atan2(h,c);this.connectionLine.setAttribute("x1",String(n.x+Math.cos(u)*i)),this.connectionLine.setAttribute("y1",String(n.y+Math.sin(u)*i)),this.connectionLine.setAttribute("x2",String(n.x+c-Math.cos(u)*i)),this.connectionLine.setAttribute("y2",String(n.y+h-Math.sin(u)*i))}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(t,e){const i=o.utils.dom.createSvgElement("g",{class:"blocklyInputConnectionIndicator"},t);o.utils.dom.createSvgElement("circle",{r:s.CONNECTION_INDICATOR_RADIUS},i);const n=e.getOffsetInBlock();return i.setAttribute("transform","translate("+n.x+","+n.y+")"),i}}i.ConnectionPreviewer=s,s.CONNECTION_INDICATOR_RADIUS=9},{blockly:192}],141:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConstantProvider=void 0;const o=t("blockly");class s extends o.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(t,e,i){super.createDom(t,e,i);const s=o.utils.dom.createSvgElement(o.utils.Svg.DEFS,{},t);this.highlightOutlineFilter=this.createHighlight(s,"blocklyHighlightedGlowFilter",this.HIGHLIGHT_GLOW_COLOUR),this.highlightOutlineFilterId=this.highlightOutlineFilter.id,this.errorOutlineFilter=this.createHighlight(s,"blocklyErrorHighlightedGlowFilter",this.ERROR_HIGHLIGHT_GLOW_COLOR),this.errorOutlineFilterId=this.errorOutlineFilter.id,this.embossFilterOverride=this.createOutline(s,"blocklyBubbleEmbossGlowFilter"),this.embossFilterId=this.embossFilterOverride.id}dispose(){super.dispose(),this.highlightOutlineFilter&&o.utils.dom.removeNode(this.highlightOutlineFilter)}makeEllipses(){const t=this.ELLIPSES_RADIUS,e=this.ELLIPSES_SPACING;let i="";for(let s=0;s<3;s++)i+=o.utils.svgPaths.moveBy(e,0)+o.utils.svgPaths.arc("a","180 1,1",t,o.utils.svgPaths.point(2*t,0));for(let s=0;s<3;s++)i+=o.utils.svgPaths.arc("a","180 1,1",t,o.utils.svgPaths.point(2*-t,0))+o.utils.svgPaths.moveBy(-e,0);return i}getCSS_(t){return super.getCSS_(t).concat([t+" .blocklyConnectionIndicator, "+t+" .blocklyInputConnectionIndicator {","fill: #ff0000;","stroke: #ffff00;","stroke-width: 3px;","}",t+" .blocklyConnectionIndicator {","display: none;","}",t+" .blocklyBlockDragSurface > g > .blocklyDraggable > .blocklyConnectionIndicator {","display: block;","}",t+" .blocklyConnectionLine {","stroke: #ffff00;","stroke-width: 4px;","}",t+" .blocklyConnectionLine.hidden {","display: none;","}",t+" .blocklyFlyoutHeading .blocklyFlyoutLabelText {font-size: 1.5rem;","}",`${t} .blocklyText::selection {`,"fill: #fff;","}",`${t} .blocklyNonEditableField>text::selection,`,`${t} .blocklyEditableField>text::selection,`,`${t} .blocklyNonEditableField>g>text::selection,`,`${t} .blocklyEditableField>g>text::selection {`,"fill: #575E75;","}",`${t} .blocklyDropdownText::selection {`,"fill: #fff !important;","}"])}createHighlight(t,e,i){const s=o.utils.dom.createSvgElement(o.utils.Svg.FILTER,{id:e+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t);o.utils.dom.createSvgElement(o.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.HIGHLIGHT_GLOW_SIZE},s);const n=o.utils.dom.createSvgElement(o.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},s);return o.utils.dom.createSvgElement(o.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},n),o.utils.dom.createSvgElement(o.utils.Svg.FEFLOOD,{"flood-color":i,"flood-opacity":1,result:"outColor"},s),o.utils.dom.createSvgElement(o.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},s),s}createOutline(t,e){const i=o.utils.dom.createSvgElement(o.utils.Svg.FILTER,{id:e+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t);o.utils.dom.createSvgElement(o.utils.Svg.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:.92},i);const s=o.utils.dom.createSvgElement(o.utils.Svg.FECOMPONENTTRANSFER,{result:"outBlur"},i);o.utils.dom.createSvgElement(o.utils.Svg.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),o.utils.dom.createSvgElement(o.utils.Svg.FEFLOOD,{"flood-color":"#000000","flood-opacity":.5,result:"outColor"},i),o.utils.dom.createSvgElement(o.utils.Svg.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},i);const n=o.utils.dom.createSvgElement("feMerge",{},i);return o.utils.dom.createSvgElement("feMergeNode",{in:"outBlur"},n),o.utils.dom.createSvgElement("feMergeNode",{in:"outGlow"},n),o.utils.dom.createSvgElement("feMergeNode",{in:"SourceGraphic"},n),i}shapeFor(t){let e=t.getCheck();switch(!e&&t.targetConnection&&(e=t.targetConnection.getCheck()),t.type){case o.ConnectionType.INPUT_VALUE:case o.ConnectionType.OUTPUT_VALUE:return e&&e.includes("Boolean")?this.HEXAGONAL:(e&&e.includes("Number")||e&&e.includes("String"),this.ROUNDED);case o.ConnectionType.PREVIOUS_STATEMENT:case o.ConnectionType.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}}i.ConstantProvider=s,s.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",s.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});t("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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Drawer=void 0;const o=t("blockly"),s=t("./collapsedInputRow");class n extends o.zelos.Drawer{drawCollapsedStack_(t){const e=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.constants_.INSIDE_CORNERS.width,i=this.constants_.STATEMENT_INPUT_PADDING_LEFT+2*this.constants_.INSIDE_CORNERS.width+o.utils.svgPaths.lineOnAxis("h",-this.constants_.INSIDE_CORNERS.width)+this.constants_.INSIDE_CORNERS.pathTop,s=t.height-2*this.constants_.INSIDE_CORNERS.height,n=this.constants_.INSIDE_CORNERS.pathBottom+o.utils.svgPaths.lineOnAxis("h",this.constants_.INSIDE_CORNERS.width),r=this.constants_.ellipses;this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.bottomRight+o.utils.svgPaths.lineOnAxis("H",e)+i+o.utils.svgPaths.lineOnAxis("v",s/2)+r+o.utils.svgPaths.lineOnAxis("v",s/2)+n+o.utils.svgPaths.lineOnAxis("H",t.xPos+t.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 t=1;t<this.info_.rows.length-1;t++){const e=this.info_.rows[t];e.hasJaggedEdge?this.drawJaggedEdge_(e):(0,s.isCollapsedInputRow)(e)?this.drawCollapsedStack_(e):e.hasStatement?this.drawStatementInput_(e):e.hasExternalInput?this.drawValueInput_(e):this.drawRightSideRow_(e)}this.drawBottom_(),this.drawLeft_()}}drawLeft_(){super.drawLeft_();if(this.info_.rows.find(function(t){return(0,s.isCollapsedInputRow)(t)})){let t=this.info_.startY;o.blockRendering.Types.isLeftRoundedCorner(this.info_.topRow.elements[0])&&(t+=this.constants_.OUTSIDE_CORNERS.rightHeight),this.outlinePath_=this.outlinePath_.slice(0,-1),this.outlinePath_+=o.utils.svgPaths.lineOnAxis("V",t)}}}i.Drawer=n},{"./collapsedInputRow":139,blockly:192}],144:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./renderer"),i),s(t("./connectionPreviewer"),i),s(t("./css"),i)},{"./connectionPreviewer":140,"./css":142,"./renderer":147}],145:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RenderInfo=void 0;const o=t("blockly"),s=t("./collapsedInputRow");class n extends o.zelos.RenderInfo{measure(){if(this.block_)for(const t of this.block_.inputList)t.init();super.measure()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let t=new o.blockRendering.InputRow(this.constants_);this.inputRows.push(t);const e=this.block_.getIcons();for(let i,s=0;i=e[s];s++){const e=new o.blockRendering.Icon(this.constants_,i);this.isCollapsed&&!i.isShownWhenCollapsed()||t.elements.push(e)}let i;for(let e,s=0;e=this.block_.inputList[s];s++)if(e.isVisible()){this.shouldStartNewRow_(e,i)&&(this.rows.push(t),t=new o.blockRendering.InputRow(this.constants_),this.inputRows.push(t));for(let i,s=0;i=e.fieldRow[s];s++)t.elements.push(new o.blockRendering.Field(this.constants_,i,e));this.addInput_(e,t),i=e}if(this.isCollapsed){this.block_.inputList.find(function(t){return t.type==o.inputs.inputTypes.STATEMENT})?t=this.addCollapsedRow_(t):(t.hasJaggedEdge=!0,t.elements.push(new o.blockRendering.JaggedEdge(this.constants_)))}(t.elements.length||t.hasDummyInput)&&this.rows.push(t),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;const t=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof o.inputs.StatementInput||this.rows.some(t=>(0,s.isCollapsedInputRow)(t));this.bottomRow.minHeight=t?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new o.blockRendering.SquareCorner(this.constants_)):this.bottomRow.elements.push(new o.blockRendering.RoundCorner(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new o.blockRendering.NextConnection(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new o.blockRendering.SquareCorner(this.constants_,"right")):this.bottomRow.elements.push(new o.blockRendering.RoundCorner(this.constants_,"right"))}addCollapsedRow_(t){this.rows.push(t);const e=new s.CollapsedInputRow(this.constants_);return e.hasDummyInput=!0,e}}i.RenderInfo=n},{"./collapsedInputRow":139,blockly:192}],146:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PathObject=void 0;const o=t("blockly"),s="blockly-dotted-outline-on-hover",n="hover";class r extends o.zelos.PathObject{constructor(){super(...arguments),this.connectionPointIndicators=new WeakMap}setPath(t){super.setPath(t),this.svgPathHighlighted&&this.svgPathHighlighted.setAttribute("d",t)}updateHighlighted(t){if(t){if(!this.svgPathHighlighted){const t=this.constants,e=this.hasError?t.errorOutlineFilterId:t.highlightOutlineFilterId;this.svgPathHighlighted=this.svgPath.cloneNode(!0),this.svgPathHighlighted.classList.add("pxtRendererHighlight"),this.svgPathHighlighted.setAttribute("fill","none"),this.svgPathHighlighted.setAttribute("filter","url(#"+e+")"),this.svgRoot.appendChild(this.svgPathHighlighted)}}else this.svgPathHighlighted&&(this.svgRoot.removeChild(this.svgPathHighlighted),this.svgPathHighlighted=null)}updateSelected(t){t&&this.svgPath.classList.remove(n),super.updateSelected(t)}addConnectionHighlight(t,e,i,s){const n=super.addConnectionHighlight(t,e,i,s);return this.staticConnectionIndicatorParentGroup?this.svgRoot.appendChild(this.staticConnectionIndicatorParentGroup):this.staticConnectionIndicatorParentGroup=o.utils.dom.createSvgElement("g",{class:"blocklyConnectionIndicatorParent"},this.svgRoot),n}removeConnectionHighlight(t){var e;null===(e=this.staticConnectionIndicatorParentGroup)||void 0===e||e.remove(),super.removeConnectionHighlight(t)}applyColour(t){if(super.applyColour(t),t.outputConnection){let e=!1;const i=t.getParent();if(i)if(t.isShadow()){const t=i.style.colourTertiary,s=function(t){return(.2126*t[0]+.7152*t[1]+.0722*t[2])/255}(o.utils.colour.hexToRgb(t));s<.15&&(this.svgPath.setAttribute("stroke",o.utils.colour.blend("#ffffff",t,.3)),e=!0)}else{const s=i.style.colourPrimary,n=t.style.colourPrimary;if(s===n){const t=.6,i=o.utils.colour.blend("#0000000",n,t),r=o.utils.colour.blend("#ffffff",n,t);pxt.contrastRatio(i,s)>pxt.contrastRatio(r,s)?this.svgPath.setAttribute("stroke",i):this.svgPath.setAttribute("stroke",r),e=!0}}e||this.svgPath.setAttribute("stroke",t.style.colourTertiary)}}setHasDottedOutlineOnHover(t){this.hasDottedOutlineOnHover=t,t?(this.svgPath.classList.add(s),this.mouseOverData||(this.mouseOverData=o.browserEvents.bind(this.svgRoot,"mouseover",this,()=>{this.svgPath.classList.add(n)}),this.mouseLeaveData=o.browserEvents.bind(this.svgRoot,"mouseleave",this,()=>{this.svgPath.classList.remove(n)}))):(this.svgPath.classList.remove(s),this.mouseOverData&&(o.browserEvents.unbind(this.mouseOverData),o.browserEvents.unbind(this.mouseLeaveData),this.mouseOverData=void 0,this.mouseLeaveData=void 0),this.svgPath.classList.remove(s))}setHasError(t){this.hasError=t}isHighlighted(){return!!this.svgPathHighlighted}}i.PathObject=r,r.CONNECTION_INDICATOR_RADIUS=9,o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Renderer=void 0;const o=t("blockly"),s=t("./pathObject"),n=t("./constants"),r=t("./info"),a=t("./drawer");class l extends o.zelos.Renderer{makePathObject(t,e){return new s.PathObject(t,e,this.getConstants())}makeConstants_(){return new n.ConstantProvider}makeRenderInfo_(t){return new r.RenderInfo(this,t)}makeDrawer_(t,e){return new a.Drawer(t,e)}render(t){t.updateBeforeRender&&t.updateBeforeRender(),super.render(t)}}i.Renderer=l,o.blockRendering.register("pxt",l)},{"./constants":141,"./drawer":143,"./info":145,"./pathObject":146,blockly:192}],148:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FieldString=void 0;const o=t("blockly");class s extends o.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_=o.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_=o.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_(t){super.updateSize_(t);const e=this.value_?this.size_.width:1;let i=this.positionLeft(e+3);this.textElement_.setAttribute("x",i+""),i+=this.positionRight(i+e+3),this.size_.width=e+i}positionLeft(t){if(!this.quoteLeft_)return 0;let e=0;return this.sourceBlock_.RTL?(this.quoteLeftX_=t+this.quoteWidth_+2*s.quotePadding,e=this.quoteWidth_+s.quotePadding):(this.quoteLeftX_=0,e=this.quoteWidth_+s.quotePadding),this.quoteLeft_.setAttribute("transform","translate("+this.quoteLeftX_+","+this.quoteY_+")"),e}positionRight(t){if(!this.quoteRight_)return 0;let e=0;return this.sourceBlock_.RTL?(this.quoteRightX_=s.quotePadding,e=this.quoteWidth_+s.quotePadding):(this.quoteRightX_=t+s.quotePadding,e=this.quoteWidth_+s.quotePadding),this.quoteRight_.setAttribute("transform","translate("+this.quoteRightX_+","+this.quoteY_+")"),e}}i.FieldString=s,s.quotePadding=0,o.Css.register("\n.field-text-quote {\n fill: #a31515 !important;\n}\n"),o.fieldRegistry.register("field_string",s)},{blockly:192}],149:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./fieldString"),i),s(t("./text"),i),s(t("./join"),i)},{"./fieldString":148,"./join":150,"./text":151}],150:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly"),s=t("../../fields/field_imagenotext"),n=t("../../utils"),r={itemCount_:0,valueConnections_:[],buttons:null,delta:0,mutationToDom:function(){const t=o.utils.xml.createElement("mutation");return t.setAttribute("items",this.itemCount_+""),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},storeValueConnections_:function(){this.valueConnections_=[];for(let t=0;t<this.itemCount_;t++)this.valueConnections_.push(this.getInput("ADD"+t).connection.targetConnection)},restoreValueConnections_:function(){var t;for(let e=0;e<this.itemCount_;e++)null===(t=this.valueConnections_[e])||void 0===t||t.reconnect(this,"ADD"+e)},addItem_:function(){this.storeValueConnections_();if(this.delta=1,this.update_(()=>{this.itemCount_++}),this.restoreValueConnections_(),this.itemCount_>1){const t=this.getInput("ADD0");if(t&&t.connection.targetConnection){const e=this.getInput("ADD"+(this.itemCount_-1)),i=t.connection.getShadowDom();if(i){const t=o.utils.xml.createElement("shadow"),s=i.getAttribute("type");t.setAttribute("type",s),t&&(t.setAttribute("id",o.utils.idGenerator.genUid()),e.connection.setShadowDom(t))}}}},removeItem_:function(){this.storeValueConnections_();this.delta=-1,this.update_(()=>{this.itemCount_--}),this.restoreValueConnections_()},update_:function(t){o.Events.setGroup(!0);const e=this,i=e.mutationToDom(),s=i&&o.Xml.domToText(i);t&&t.call(this),this.updateShape_(),e instanceof o.BlockSvg&&e.initSvg();const r=o.Events.getGroup(),a=e.mutationToDom(),l=a&&o.Xml.domToText(a);s!=l&&(o.Events.fire(new o.Events.BlockChange(e,"mutation",null,s,l)),setTimeout(function(){o.Events.setGroup(r),e.bumpNeighbours(),o.Events.setGroup(!1)},o.config.bumpDelay)),e.rendered&&e instanceof o.BlockSvg&&e.queueRender().then(()=>{if(this.buttons){let t=this.buttons.fieldRow[0];this.buttons.fieldRow.length>1&&(t=this.delta<0?t:this.buttons.fieldRow[1]),(0,n.maybeMoveFocusFromButton)(t),this.buttons=null,this.delta=0}}),o.Events.setGroup(!1)},updateShape_:function(){const t=this,e=function(){t.removeItem_()};let i;for(this.getInput("EMPTY")&&this.removeInput("EMPTY"),this.getInput("TITLE")||this.appendDummyInput("TITLE").appendField(o.Msg.TEXT_JOIN_TITLE_CREATEWITH),i=0;i<this.itemCount_;i++)if(!this.getInput("ADD"+i)){this.appendValueInput("ADD"+i).setAlign(o.inputs.Align.LEFT).setAriaLabelProvider(o.Msg.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(i+1).toString()))}for(;this.getInput("ADD"+i);)this.removeInput("ADD"+i),i++;this.getInput("BUTTONS")&&this.removeInput("BUTTONS"),this.buttons=this.appendDummyInput("BUTTONS"),this.itemCount_>1&&this.buttons.appendField(new s.FieldImageNoText(this.REMOVE_IMAGE_DATAURI,24,24,lf("remove argument"),e,!1)),this.buttons.appendField(new s.FieldImageNoText(this.ADD_IMAGE_DATAURI,24,24,lf("add argument"),function(){t.addItem_()},!1));const n=this.itemCount_<=4;if(this.setInputsInline(n),this.workspace instanceof o.WorkspaceSvg){const t=this.workspace.getRenderer();this.setOutputShape(n?t.getConstants().SHAPES.ROUND:t.getConstants().SHAPES.SQUARE)}}};o.Extensions.registerMutator("pxt_text_join_mutator",r,function(){o.Extensions.apply("inline-svgs",this,!1),this.itemCount_=2,this.updateShape_()}),o.defineBlocksWithJsonArray([{type:"text_join",message0:"",output:"String",outputShape:(new o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("blockly");o.defineBlocksWithJsonArray([{type:"text",message0:"%1",args0:[{type:"field_string",name:"TEXT",text:""}],output:"String",outputShape:(new o.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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.blocksMetrics=i.render=i.renderWorkspace=i.cleanRenderingWorkspace=i.initRenderingWorkspace=void 0;const o=t("blockly"),s=t("./layout"),n=t("./importer");let r,a;function l(){return r||(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),r=o.inject(a,{move:{scrollbars:!1},readOnly:!0,sounds:!1,media:pxt.webConfig.commitCdnUrl+"blockly/media/",rtl:pxt.Util.isUserLanguageRtl(),renderer:"pxt"})),(0,n.clearWithoutEvents)(r),r}function c(){r&&r.dispose(),r=void 0}function h(t={emPixels:18,layout:1}){switch(t.splitSvg?1:t.layout||4){case 1:(0,s.verticalAlign)(r,t.emPixels||18);break;case 4:(0,s.flow)(r,{ratio:t.aspectRatio,useViewWidth:t.useViewWidth});break;case 3:r.cleanUp_&&r.cleanUp_()}let e=r.getMetrics();const i=a.querySelectorAll("svg")[0],o=i.cloneNode(!0);return(0,s.cleanUpBlocklySvg)(o,i),pxt.U.toArray(o.querySelectorAll(".blocklyBlockCanvas,.blocklyBubbleCanvas")).forEach(t=>t.setAttribute("transform",`translate(${-e.contentLeft}, ${-e.contentTop}) scale(1)`)),o.setAttribute("viewBox",`0 0 ${e.contentWidth} ${e.contentHeight}`),t.emPixels&&(o.style.width=e.contentWidth/t.emPixels+"em",o.style.height=e.contentHeight/t.emPixels+"em"),t.splitSvg?(0,s.splitSvg)(o,r,t.emPixels):o}i.initRenderingWorkspace=l,i.cleanRenderingWorkspace=c,i.renderWorkspace=h,i.render=function(t,e={emPixels:18,layout:1}){l();try{let i=t||'<xml xmlns="http://www.w3.org/1999/xhtml"></xml>',s=o.utils.xml.textToDom(i);return(0,n.domToWorkspaceNoEvents)(s,r,{applyHideMetaComment:!0}),h(e)}catch(t){return void pxt.reportException(t)}finally{c()}},i.blocksMetrics=function(t){const e=t.getTopBlocks(!1);if(!e.length)return{width:0,height:0};let i;return e.forEach(t=>{const e=t.getBoundingRectangle();i?(i.l=Math.min(i.l,e.left),i.r=Math.max(i.r,e.right),i.t=Math.min(i.t,e.top),i.b=Math.min(i.b,e.bottom)):i={l:e.left,r:e.right,t:e.top,b:e.bottom}}),{width:i.r-i.l,height:i.b-i.t}}},{"./importer":75,"./layout":77,blockly:192}],153:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.findBlockIdByLine=i.findBlockIdByPosition=void 0,i.findBlockIdByPosition=function(t,e){if(!e)return;let i,o;for(let s=0;s<t.length;++s){let n=t[s];n.startPos<=e.start&&n.endPos>=e.start+e.length&&(!i||o>n.endPos-n.startPos)&&(i=n,o=n.endPos-n.startPos)}return i?i.id:void 0},i.findBlockIdByLine=function(t,e){if(!e)return;let i,o;for(let s=0;s<t.length;++s){let n=t[s];n.startLine<=e.start&&n.endLine>e.start+e.length&&(!i||o>n.endLine-n.startLine)&&(i=n,o=n.endLine-n.startLine)}return i?i.id:void 0}},{}],154:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createFunctionsFlyoutCategory=i.mkReturnStatementBlock=i.mkVariableFieldBlock=i.mkFieldBlock=i.mkPredicateBlock=i.createToolboxBlock=i.createFlyoutGap=i.createFlyoutButton=i.createFlyoutGroupLabel=i.createFlyoutHeadingLabel=i.createShadowValue=i.isArrayType=void 0;const o=t("blockly"),s=t("./plugins/functions"),n=t("./loader"),r=/^(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(t){let e=/^(?:Array<(.+)>)|(?:(.+)\[\])|(?:\[.+\])$/.exec(t);return e?e[1]?e[1]:e[2]:void 0}function c(t,e,i,o,s,n=0){let r;if(o=o||e.defaultValue,!(i=i||e.shadowBlockId)&&e.range&&(i="math_number_minmax"),r=o&&'"'==o.slice(0,1)?JSON.parse(o):o,"number"==e.type&&"value"==i){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode("0")),t}if(e.fieldEditor){if(e.defaultValue){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode(e.defaultValue)),t}return}let c=pxt.Util.lookup(t.apis.byQName,e.type),u=6==(null==c?void 0:c.kind),d=c&&!!c.attributes.fixedInstances&&!e.shadowBlockId,p="@combined@"==e.type;if(!i&&(u||d||p)){if(o){const t=document.createElement("field");return t.setAttribute("name",e.definitionName),t.appendChild(document.createTextNode(o)),t}return}const m="variables_get"==i,_="text"==i,f=document.createElement("value");f.setAttribute("name",e.definitionName);const T="lists_create_with"!==i&&i?void 0:l(e.type),b=document.createElement(!m&&!T||s?"shadow":"block");f.appendChild(b);const E=a[T||e.type];if(b.setAttribute("type",i||(T?"lists_create_with":E&&E.block||e.type)),b.setAttribute("colour","#fff"),T){if(E&&!i){let t;switch(T){case"number":t=["0","1"];break;case"string":t=["a","b","c"];break;case"boolean":t=["FALSE","FALSE","FALSE"]}return h(b,E.block,E.field,t),f}if(i&&r)return h(b,r),f}if(!E||i&&E.block!==i&&"math_number_minmax"!==i){if(r){const o=document.createElement("field");if(o.textContent=r,m)o.setAttribute("name","VAR"),b.appendChild(o);else if(_)o.setAttribute("name","TEXT"),b.appendChild(o);else if(i){const e=t.blocksById[i];if(e&&e.attributes._def&&e.attributes._def.parameters.length){const t=e.attributes._def.parameters[0];o.setAttribute("name",t.name),b.appendChild(o)}}else o.setAttribute("name",e.definitionName),b.appendChild(o)}}else{const t=document.createElement("field");let o,s;switch(b.appendChild(t),i){case"variables_get":o="VAR";break;case"math_number_minmax":o="SLIDER";break;default:o=E.field}t.setAttribute("name",o),s="boolean"==e.type?document.createTextNode((r||E.defaultValue).toUpperCase()):document.createTextNode(r||E.defaultValue),t.appendChild(s)}let y;if(e.range&&(y=document.createElement("mutation"),y.setAttribute("min",e.range.min.toString()),y.setAttribute("max",e.range.max.toString()),y.setAttribute("label",e.actualName.charAt(0).toUpperCase()+e.actualName.slice(1)),e.fieldOptions&&(e.fieldOptions.step&&y.setAttribute("step",e.fieldOptions.step),e.fieldOptions.color&&y.setAttribute("color",e.fieldOptions.color),e.fieldOptions.precision&&y.setAttribute("precision",e.fieldOptions.precision))),e.fieldOptions&&(y||(y=document.createElement("mutation")),y.setAttribute("customfield",JSON.stringify(e.fieldOptions))),y&&b.appendChild(y),n){const e=pxt.Util.toArray(f.getElementsByTagName("shadow"));for(const i of e)if(!i.innerHTML){const e=t.blocks.find(t=>t.attributes.blockId===i.getAttribute("type"));if(e){const o=g(t,e,pxt.blocks.compileInfo(e),!0,n-1);for(;o.firstChild;)i.appendChild(o.firstChild.cloneNode(!0)),o.firstChild.remove()}}}return f}function h(t,e,i,o){const s=o?o.length:2,n=document.createElement("mutation");n.setAttribute("items",""+s),n.setAttribute("horizontalafter",""+s),t.appendChild(n);for(let n=0;n<s;n++){const s=document.createElement("value");s.setAttribute("name","ADD"+n);const r=document.createElement("shadow");if(r.setAttribute("type",e),i){const t=document.createElement("field");t.setAttribute("name",i),o&&t.appendChild(document.createTextNode(o[n])),r.appendChild(t)}s.appendChild(r),t.appendChild(s)}}function u(t,e,i,o){const s=p(t,pxt.toolbox.convertColor(e),i,o);return s.setAttribute("web-class","blocklyFlyoutHeading"),s}function d(t,e,i,o){const s=p(t,void 0,e);return s.setAttribute("web-class","blocklyFlyoutGroup"),s.setAttribute("web-line","1.5"),i&&s.setAttribute("web-line-width",i),o&&(s.setAttribute("web-help-button","true"),s.setAttribute("callbackKey",o)),s}function p(t,e,i,s){let n=o.utils.xml.createElement("label");return n.setAttribute("text",t),e&&n.setAttribute("web-icon-color",pxt.toolbox.convertColor(e)),i&&(1===i.length?(n.setAttribute("web-icon",i),s&&n.setAttribute("web-icon-class",s)):(n.setAttribute("web-icon-class",`blocklyFlyoutIcon${t}`),pxt.toolbox.isImageIcon(i)&&n.setAttribute("web-icon-image",pxt.Util.pathJoin(pxt.webConfig.commitCdnUrl,encodeURI(i))))),n}function g(t,e,i,o=!1,a=0){var h,u;let d,p;if(e.attributes.builtinBlockId)return function(t){const e=t.attributes.builtinBlockId,i=t.attributes.color;if("makecode_color_picker"===e){const t=document.createElement("block");t.setAttribute("type","makecode_color_picker");const e=document.createElement("field");e.setAttribute("name","FORMAT"),e.textContent="rgb",t.appendChild(e);for(let e=0;e<3;e++){const i=document.createElement("value");i.setAttribute("name",`INPUT${e}`);const o=document.createElement("shadow");o.setAttribute("type","makecode_color_picker_number");const s=document.createElement("field");s.setAttribute("name","NUM"),s.textContent="0",o.appendChild(s),i.appendChild(o),t.appendChild(i)}if(i){const e=document.createElement("mutation");e.setAttribute("color",i),t.appendChild(e)}return t}return void pxt.warn(`Unsupported builtin block id: ${e}`)}(e);if(e.attributes.toolboxParent){const i=t.blocksById[e.attributes.toolboxParent];if(i){const s=pxt.blocks.compileInfo(i);if(d=g(t,i,s,o),e.attributes.toolboxParentArgument)p=d.querySelector(`value[name=${e.attributes.toolboxParentArgument}]`),!p&&s.parameters.some(t=>t.definitionName===e.attributes.toolboxParentArgument)&&(p=document.createElement("value"),p.setAttribute("name",e.attributes.toolboxParentArgument),d.appendChild(p));else if(p=d.querySelector("value"),!p)for(const t of s.parameters)if(!d.querySelector(`field[name=${t.definitionName}]`)){p=document.createElement("value"),p.setAttribute("name",t.definitionName),d.appendChild(p);break}if(p)for(;p.firstChild;)p.removeChild(p.firstChild);else d=void 0}}let m=document.createElement(d||o?"shadow":"block");if(m.setAttribute("type",e.attributes.blockId),e.attributes.blockGap?m.setAttribute("gap",e.attributes.blockGap):pxt.appTarget.appTheme&&pxt.appTarget.appTheme.defaultBlockGap&&m.setAttribute("gap",pxt.appTarget.appTheme.defaultBlockGap.toString()),i.thisParameter){const e=i.thisParameter,s=!!(null===(h=t.apis.byQName[e.type])||void 0===h?void 0:h.attributes.fixedInstances);let n=e.shadowBlockId,r=e.defaultValue;s||n&&"variables_get"!==n||(n="variables_get",r=r||e.definitionName);const l=c(t,e,n,r,o,a);l&&m.appendChild(l)}if("ENUM_GET"===e.attributes.shim||"KIND_GET"===e.attributes.shim){if(null===(u=e.parameters)||void 0===u?void 0:u.length){const t=e.parameters[0].default;if(t){const e=document.createElement("field");e.setAttribute("name","MEMBER"),e.textContent=t,m.appendChild(e)}}}else e.parameters&&(i.parameters.filter(t=>r.test(t.type)||r.test(l(t.type))||t.shadowBlockId||t.defaultValue).forEach(e=>{const i=c(t,e,void 0,void 0,o,a);i&&m.appendChild(i)}),e.attributes.draggableParameters?i.handlerArgs.forEach(t=>{const i="reporter"===e.attributes.draggableParameters,o=document.createElement("value");o.setAttribute("name",n.DRAGGABLE_PARAM_INPUT_PREFIX+t.name);const r=i?pxt.blocks.reporterTypeForArgType(t.type):"variables_get_reporter",a=document.createElement("block");a.setAttribute("type",r);const l=document.createElement("mutation");a.appendChild(l),i&&"argument_reporter_custom"===r&&l.setAttribute("typename",t.type),l.setAttribute(s.LOCALIZATION_NAME_MUTATION_KEY,t.localizationKey);const c=document.createElement("field");c.setAttribute("name",i?"VALUE":"VAR"),c.textContent=pxt.Util.htmlEscape(t.name),a.appendChild(c),o.appendChild(a),m.appendChild(o)}):i.handlerArgs.forEach(t=>{const e=document.createElement("field");e.setAttribute("name","HANDLER_"+t.name),e.textContent=t.name,m.appendChild(e)}));if(e.attributes.expandArgumentsInToolbox){let t;for(const e of m.children)if("mutation"===e.tagName){t=e;break}t||(t=document.createElement("mutation"),m.appendChild(t)),t.setAttribute("_expanded",""+e.attributes._expandedDef.parameters.length)}return d?(p.appendChild(m),d):m}function m(t,e,i,o){const s=document.createElement(o?"shadow":"block");s.setAttribute("type",pxt.Util.htmlEscape(t));const n=document.createElement("field");return n.setAttribute("name",pxt.Util.htmlEscape(e)),n.textContent=pxt.Util.htmlEscape(i),s.appendChild(n),s}function _(){const t=document.createElement("block");t.setAttribute("type","function_return");const e=document.createElement("value");e.setAttribute("name","RETURN_VALUE"),t.appendChild(e);const i=m("math_number","NUM","0",!0);return e.appendChild(i),t}i.isArrayType=l,i.createShadowValue=c,i.createFlyoutHeadingLabel=u,i.createFlyoutGroupLabel=d,i.createFlyoutButton=function(t,e){let i=o.utils.xml.createElement("button");return i.setAttribute("text",e),i.setAttribute("callbackKey",t),i},i.createFlyoutGap=function(t){const e=o.utils.xml.createElement("sep");return e.setAttribute("gap",t+""),e},i.createToolboxBlock=g,i.mkPredicateBlock=function(t){const e=document.createElement("block");e.setAttribute("type",t);const i=document.createElement("value");i.setAttribute("name","PREDICATE"),e.appendChild(i);const o=m("logic_boolean","BOOL","TRUE",!0);return i.appendChild(o),e},i.mkFieldBlock=m,i.mkVariableFieldBlock=function(t,e,i,o,s){const n=document.createElement(s?"shadow":"block");n.setAttribute("type",pxt.Util.htmlEscape(t));const r=document.createElement("field");return r.setAttribute("name","VAR"),r.id=e,r.setAttribute("variabletype",pxt.Util.htmlEscape(i)),r.textContent=pxt.Util.htmlEscape(o),n.appendChild(r),n},i.mkReturnStatementBlock=_,i.createFunctionsFlyoutCategory=function(t){const e=(0,s.flyoutCategory)(t);if(e.length>1){let t=_();e.splice(1,0,d(lf("Your Functions"))),e.splice(1,0,t)}const i=(0,s.getAllFunctionDefinitionBlocks)(t).filter(t=>t.getDescendants(!1).some(t=>"function_return"===t.type&&t.getInputTargetBlock("RETURN_VALUE"))).map(t=>t.getField("function_name").getText()),o=u(lf("Functions"),pxt.toolbox.getNamespaceColor("functions"),pxt.toolbox.getNamespaceIcon("functions"),"blocklyFlyoutIconfunctions");e.unshift(o);const n=[];for(const t of e)if(n.push(t),"function_call"===t.getAttribute("type")){const e=t.children.item(0);if(e){const o=e.getAttribute("name");if(i.some(t=>t===o)){const e=t.cloneNode(!0);e.setAttribute("type","function_call_output"),n.push(e)}}}return n}},{"./loader":79,"./plugins/functions":127,blockly:192}],155:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.maybeMoveFocusFromButton=void 0;const o=t("blockly"),s=t("./fields/field_imagenotext");i.maybeMoveFocusFromButton=t=>{const e=o.getFocusManager(),i=e.getFocusedNode();t&&(i instanceof s.FieldImageNoText||!i)&&e.focusNode(t)}},{"./fields/field_imagenotext":38,blockly:192}],156:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PxtWorkspaceSearch=void 0;const o=t("blockly"),s=t("@blockly/plugin-workspace-search");class n extends s.WorkspaceSearch{constructor(t){super(t),this.injectionDiv=t.getInjectionDiv()}highlightSearchGroup(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.addClass(e,"blockly-ws-search-highlight-pxt")})}unhighlightSearchGroup(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.removeClass(e,"blockly-ws-search-highlight-pxt")})}open(){super.open(),o.utils.dom.addClass(this.injectionDiv,"blockly-ws-searching")}close(){super.close(),o.utils.dom.removeClass(this.injectionDiv,"blockly-ws-searching")}}i.PxtWorkspaceSearch=n,o.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(t,e,i){"use strict";function o(t,e,i,o){return pxt.Util.toArray(t.getElementsByTagName(e)).filter(t=>t.getAttribute(i)===o)}Object.defineProperty(i,"__esModule",{value:!0}),i.cleanOuterHTML=i.getDirectChildren=i.getFirstChildWithAttr=i.getChildrenWithAttr=i.getBlocksWithType=void 0,i.getBlocksWithType=function(t,e){return o(t,"block","type",e).concat(o(t,"shadow","type",e))},i.getChildrenWithAttr=o,i.getFirstChildWithAttr=function(t,e,i,s){const n=o(t,e,i,s);return n.length?n[0]:void 0},i.getDirectChildren=function(t,e){const i=[];for(let o=0;o<t.childNodes.length;o++){const s=t.childNodes.item(o);s.tagName===e&&i.push(s)}return i},i.cleanOuterHTML=function(t){return t.outerHTML.replace(/^<\?[^>]*>/,"")}},{}],158:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getNestedChildBlocks=void 0,i.getNestedChildBlocks=function(t){return t.getDescendants(!0).filter(e=>e.isEnabled()&&e.getSurroundParent()===t)}},{}],159:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),s(t("./runValidatorPlan"),i),s(t("./validateBlocksExist"),i),s(t("./validateBlocksInSetExist"),i),s(t("./validateCommentsExist"),i),s(t("./validateSpecificBlockCommentsExist"),i)},{"./runValidatorPlan":160,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165}],160:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.runValidatorPlan=void 0;const o=t("./validateBlockFieldValueExists"),s=t("./validateBlocksExist"),n=t("./validateBlocksInSetExist"),r=t("./validateCommentsExist"),a=t("./validateSpecificBlockCommentsExist"),l=t("./getNestedChildBlocks"),c=t("./validateVariableUsage");function h(t,e){const i=e.blockCounts.reduce((t,e)=>(t[e.blockId]=e.count,t),{}),o=(0,s.validateBlocksExist)({usedBlocks:t,requiredBlockCounts:i});let n=[];if(o.passed)for(const t of e.blockCounts){const e=t.blockId;n.push(...o.successfulBlocks[e])}return[n,o.passed]}function u(t,e){return(0,r.validateBlockCommentsExist)({usedBlocks:t,numRequired:e.count}).passed}function d(t,e){return(0,r.validateCommentsExist)({usedBlocks:t,numRequired:e.count}).passed}function p(t,e){return(0,a.validateSpecificBlockCommentsExist)({usedBlocks:t,blockType:e.blockType}).passed}function g(t,e){const i=(0,n.validateBlocksInSetExist)({usedBlocks:t,blockIdsToCheck:e.blocks,count:e.count});return[i.successfulBlocks,i.passed]}function m(t,e){const i=(0,o.validateBlockFieldValueExists)({usedBlocks:t,fieldType:e.fieldType,fieldValue:e.fieldValue,specifiedBlock:e.blockType});return[i.successfulBlocks,i.passed]}function _(t,e){const i=(0,c.validateVariableUsage)({usedBlocks:t,count:e.count,name:e.name}),o=[];for(const t of i.passingVarDefinitions.values())o.push(...t);return[o,i.passed]}i.runValidatorPlan=function t(e,i,o){const s=Date.now();let n=0,r=[];for(const s of i.checks){let i=!1;switch(s.validator){case"blocksExist":[r,i]=[...h(e,s)];break;case"commentsExist":i=d(e,s);break;case"blockCommentsExist":i=u(e,s);break;case"specificBlockCommentsExist":i=p(e,s);break;case"blocksInSetExist":[r,i]=[...g(e,s)];break;case"blockFieldValueExists":[r,i]=[...m(e,s)];break;case"variableUsage":[r,i]=[..._(e,s)];break;default:return pxt.debug(`Unrecognized validator: ${s.validator}`),pxt.tickEvent("validation.unrecognized_validator",{validator:s.validator}),{executionSuccess:!1,executionErrorMsg:lf("Unrecognized evaluation rule")}}if(i&&s.childValidatorPlans)for(const e of s.childValidatorPlans){let s=0;for(const i of r){const n=(0,l.getNestedChildBlocks)(i),r=o.find(t=>t.name===e);s+=t(n,r,o)?1:0}i=i&&s>0}n+=i?1:0}const a=n>=i.threshold;return pxt.tickEvent("validation.evaluation_complete",{plan:i.name,durationMs:Date.now()-s,passed:`${a}`}),{result:a,executionSuccess:!0}}},{"./getNestedChildBlocks":158,"./validateBlockFieldValueExists":161,"./validateBlocksExist":162,"./validateBlocksInSetExist":163,"./validateCommentsExist":164,"./validateSpecificBlockCommentsExist":165,"./validateVariableUsage":166}],161:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlockFieldValueExists=void 0,i.validateBlockFieldValueExists=function({usedBlocks:t,fieldType:e,fieldValue:i,specifiedBlock:o}){const s=t.filter(t=>t.isEnabled()&&t.type===o).filter(t=>{var o;return"VAR"===e?(null===(o=t.getVarModels())||void 0===o?void 0:o[0].getName())===i:t.getFieldValue(e)===i});return{successfulBlocks:s,passed:s.length>0}}},{}],162:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlocksExist=void 0,i.validateBlocksExist=function({usedBlocks:t,requiredBlockCounts:e}){let i=[],o=[],s=[],n={};const r=null==t?void 0:t.reduce((t,e)=>(t[e.type]=(t[e.type]||0)+(e.isEnabled()?1:0),t),{});for(const[a,l]of Object.entries(e||{})){const e=r[a],c=t.filter(t=>t.isEnabled()&&t.type===a);c.length>0&&(n[a]=c),void 0===e?i.push(a):e?e<l&&s.push(a):o.push(a)}return{missingBlocks:i,disabledBlocks:o,insufficientBlocks:s,successfulBlocks:n,passed:0===i.length&&0===o.length&&0===s.length}}},{}],163:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateBlocksInSetExist=void 0,i.validateBlocksInSetExist=function({usedBlocks:t,blockIdsToCheck:e,count:i,requireUnique:o}){const s=[],n=t.filter(t=>t.isEnabled());for(const t of e){const e=n.filter(e=>e.type===t);o&&e.length>=1?s.push(e[0]):s.push(...e)}return{successfulBlocks:s,passed:s.length>=i}}},{}],164:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateCommentsExist=i.validateWorkspaceCommentsExist=i.validateBlockCommentsExist=void 0;const o=t("blockly");function s(t){return t.filter(t=>!!t.getCommentText())}function n(t){var e,i,s;const n=null!==(i=null===(e=t[0])||void 0===e?void 0:e.workspace)&&void 0!==i?i:o.getMainWorkspace();return(null!==(s=null==n?void 0:n.getTopComments())&&void 0!==s?s:[]).filter(t=>!!t.getText())}i.validateBlockCommentsExist=function({usedBlocks:t,numRequired:e}){const i=s(t);return{commentedBlocks:i,passed:i.length>=e}},i.validateWorkspaceCommentsExist=function({usedBlocks:t,numRequired:e}){const i=n(t);return{workspaceComments:i,passed:i.length>=e}},i.validateCommentsExist=function({usedBlocks:t,numRequired:e}){const i=[...s(t),...n(t)];return{comments:i,passed:i.length>=e}}},{blockly:192}],165:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateSpecificBlockCommentsExist=void 0,i.validateSpecificBlockCommentsExist=function({usedBlocks:t,blockType:e}){const i=t.filter(t=>t.type===e),o=i.filter(t=>!t.getCommentText());return{uncommentedBlocks:o,passed:0!==i.length&&0===o.length}}},{}],166:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateVariableUsage=void 0,i.validateVariableUsage=function({usedBlocks:t,count:e,name:i}){const o=new Map,s=new Set;for(const e of t){if(!e.isEnabled())continue;const t=e.getVarModels();for(const n of null!=t?t:[]){const t=n.getName();i&&t!==i||("variables_set"===e.type||"variables_change"===e.type?(o.has(t)||o.set(t,[]),o.get(t).push(e)):s.add(t))}}const n=new Map;for(const[t,e]of o)s.has(t)&&n.set(t,e);return{passingVarDefinitions:n,passed:n.size>=e}}},{}],167:[function(t,e,i){"use strict";let o;Object.defineProperty(i,"__esModule",{value:!0}),i.isBlocks=i.initEditorExtensionsAsync=i.HELP_IMAGE_URI=void 0,i.HELP_IMAGE_URI="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIHZpZXdCb3g9IjAgMCAyNiAyNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTMiIGN5PSIxMyIgcj0iMTMiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xNy45NTIgOS4xODQwMkMxNy45NTIgMTAuMjU2IDE3LjgxNiAxMS4wNzIgMTcuNTQ0IDExLjYzMkMxNy4yODggMTIuMTkyIDE2Ljc1MiAxMi43OTIgMTUuOTM2IDEzLjQzMkMxNS4xMiAxNC4wNzIgMTQuNTc2IDE0LjU4NCAxNC4zMDQgMTQuOTY4QzE0LjA0OCAxNS4zMzYgMTMuOTIgMTUuNzM2IDEzLjkyIDE2LjE2OFYxNi45NkgxMS44MDhDMTEuNDI0IDE2LjQ2NCAxMS4yMzIgMTUuODQgMTEuMjMyIDE1LjA4OEMxMS4yMzIgMTQuNjg4IDExLjM4NCAxNC4yODggMTEuNjg4IDEzLjg4OEMxMS45OTIgMTMuNDg4IDEyLjUzNiAxMi45NjggMTMuMzIgMTIuMzI4QzE0LjEwNCAxMS42NzIgMTQuNjI0IDExLjE2OCAxNC44OCAxMC44MTZDMTUuMTM2IDEwLjQ0OCAxNS4yNjQgOS45NjgwMiAxNS4yNjQgOS4zNzYwMkMxNS4yNjQgOC4yMDgwMiAxNC40MTYgNy42MjQwMiAxMi43MiA3LjYyNDAyQzExLjc2IDcuNjI0MDIgMTAuNzUyIDcuNzM2MDIgOS42OTYgNy45NjAwMkw5LjE0NCA4LjA4MDAyTDkgNi4wODgwMkMxMC40ODggNS41NjAwMiAxMS44NCA1LjI5NjAyIDEzLjA1NiA1LjI5NjAyQzE0LjczNiA1LjI5NjAyIDE1Ljk2OCA1LjYwODAyIDE2Ljc1MiA2LjIzMjAyQzE3LjU1MiA2Ljg0MDAyIDE3Ljk1MiA3LjgyNDAyIDE3Ljk1MiA5LjE4NDAyWk0xMS40IDIyVjE4LjY0SDE0LjE4NFYyMkgxMS40WiIgZmlsbD0iIzU5NUU3NCIvPgo8L3N2Zz4K",i.initEditorExtensionsAsync=function(){if(!o&&(o=Promise.resolve(),pxt.appTarget&&pxt.appTarget.appTheme&&pxt.appTarget.appTheme.extendFieldEditors)){const t={};o=o.then(()=>pxt.BrowserUtils.loadBlocklyAsync()).then(()=>pxt.BrowserUtils.loadScriptAsync("fieldeditors.js")).then(()=>pxt.editor.initFieldExtensionsAsync(t)).then(t=>{t.fieldEditors&&t.fieldEditors.forEach(t=>{pxt.blocks.registerFieldEditor(t.selector,t.editor,t.validator)})})}return o},i.isBlocks=function(t){return pxt.U.endsWith(t.name,".blocks")}},{}],168:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.postHostMessageAsync=i.shouldPostHostMessages=i.enableControllerAnalytics=i.bindEditorMessages=void 0;const o=t("./code-validation/runValidatorPlan"),s=t("../pxtservices/iframeEmbeddedClient"),n=t("./projectImport"),r={};let a;i.bindEditorMessages=function(t){const e=pxt.appTarget.appTheme.allowParentController||pxt.shell.isControllerMode(),i=pxt.appTarget.appTheme.allowPackageExtensions,l=pxt.appTarget.appTheme.allowSimulatorTelemetry;if(!e&&!i&&!l)return;a=new s.IFrameEmbeddedClient(s=>{const a=s.data;if(!a||!/^pxt(host|editor|pkgext|sim)$/.test(a.type))return!1;if("pxtpkgext"===a.type&&i)t().then(t=>{t.handleExtensionRequest(a)});else if("pxtsim"===a.type&&l){const t=a;"event"===t.action&&(t.category||t.message?pxt.reportError(t.category,t.message,t.data):pxt.tickEvent(t.tick,t.data))}else if(e){let e,i=Promise.resolve();if("pxthost"==a.type){const t=r[a.id];t?i=i.then(()=>t.resolve(a)):pxt.debug(`pxthost: unknown request ${a.id}`)}else"pxteditor"==a.type&&(i=i.then(()=>t().then(t=>{const i=a;switch(pxt.debug(`pxteditor: ${i.action}`),i.action.toLowerCase()){case"switchjavascript":return Promise.resolve().then(()=>t.openJavaScript());case"switchpython":return Promise.resolve().then(()=>t.openPython());case"switchblocks":return Promise.resolve().then(()=>t.openBlocks());case"startsimulator":return Promise.resolve().then(()=>t.startSimulator());case"restartsimulator":return Promise.resolve().then(()=>t.restartSimulator());case"hidesimulator":return Promise.resolve().then(()=>t.collapseSimulator());case"showsimulator":return Promise.resolve().then(()=>t.expandSimulator());case"closeflyout":return Promise.resolve().then(()=>t.closeFlyout());case"unloadproject":return Promise.resolve().then(()=>t.unloadProjectAsync());case"saveproject":return t.saveProjectAsync();case"compile":return t.compile();case"redo":return Promise.resolve().then(()=>{const e=t.editor;e&&e.hasRedo()&&e.redo()});case"undo":return Promise.resolve().then(()=>{const e=t.editor;e&&e.hasUndo()&&e.undo()});case"setscale":{const e=a;return Promise.resolve().then(()=>t.editor.setScale(e.scale))}case"stopsimulator":{const e=a;return Promise.resolve().then(()=>t.stopSimulator(e.unload))}case"newproject":{const e=a;return Promise.resolve().then(()=>t.newProject(e.options))}case"importproject":{const e=a;return Promise.resolve().then(()=>t.importProjectAsync(e.project,{filters:e.filters,searchBar:e.searchBar}))}case"importexternalproject":{const t=a;return(0,n.saveProjectAsync)(t.project).then(t=>{const i=location.origin+location.pathname+`#embedimport:${t}`;e={importUrl:i}})}case"openheader":{const e=a;return t.openProjectByHeaderIdAsync(e.headerId)}case"startactivity":{const e=a;let i,o=e.path;return/^([jt]s|py|blocks?):/i.test(o)&&(i=/^py:/i.test(o)?pxt.PYTHON_PROJECT_NAME:/^[jt]s:/i.test(o)?pxt.JAVASCRIPT_PROJECT_NAME:pxt.BLOCKS_PROJECT_NAME,o=o.substr(o.indexOf(":")+1)),Promise.resolve().then(()=>t.startActivity({activity:e.activityType,path:o,title:e.title,editor:i,previousProjectHeaderId:e.previousProjectHeaderId,carryoverPreviousCode:e.carryoverPreviousCode}))}case"importtutorial":{const e=a;return Promise.resolve().then(()=>t.importTutorialAsync(e.markdown))}case"proxytosim":{const e=a;return Promise.resolve().then(()=>t.proxySimulatorMessage(e.content))}case"renderblocks":{const i=a;return Promise.resolve().then(()=>t.renderBlocksAsync(i)).then(t=>t.xml.then(t=>{e=t.xml}))}case"renderxml":{const i=a;return Promise.resolve().then(()=>t.renderXml(i).resultXml.then(t=>{e=t.xml}))}case"renderbyblockid":{const i=a;return Promise.resolve().then(()=>t.renderByBlockIdAsync(i)).then(t=>t.resultXml.then(t=>{e=t.xml}))}case"runeval":{const i=a,s=i.validatorPlan,n=i.planLib;return Promise.resolve().then(()=>{const e=t.getBlocks();return(0,o.runValidatorPlan)(e,s,n)}).then(t=>{e=t})}case"gettoolboxcategories":{const i=a;return Promise.resolve().then(()=>{e=t.getToolboxCategories(i.advanced)})}case"getblockastext":{const i=a;return Promise.resolve().then(()=>{const o=t.getBlockAsText(i.blockId);e={blockAsText:o}})}case"renderpython":{const i=a;return Promise.resolve().then(()=>t.renderPythonAsync(i)).then(t=>{e=t.python})}case"toggletrace":{const e=a;return Promise.resolve().then(()=>t.toggleTrace(e.intervalSpeed))}case"settracestate":{const e=a;return Promise.resolve().then(()=>t.setTrace(e.enabled,e.intervalSpeed))}case"setsimulatorfullscreen":{const e=a;return Promise.resolve().then(()=>t.setSimulatorFullScreen(e.enabled))}case"showthemepicker":return Promise.resolve().then(()=>t.showThemePicker());case"togglehighcontrast":return Promise.resolve().then(()=>t.toggleHighContrast());case"sethighcontrast":{const e=a;return Promise.resolve().then(()=>t.setHighContrast(e.on))}case"togglegreenscreen":return Promise.resolve().then(()=>t.toggleGreenScreen());case"togglekeyboardcontrols":return Promise.resolve();case"togglescreenreadermode":return t.toggleScreenReaderModeAsync("settings");case"print":return Promise.resolve().then(()=>t.printCode());case"pair":return t.pairAsync().then(()=>{});case"info":return Promise.resolve().then(()=>{e={versions:pxt.appTarget.versions,locale:ts.pxtc.Util.userLanguage(),availableLocales:pxt.appTarget.appTheme.availableLocales,keyboardControls:!0,screenReaderMode:t.isScreenReaderModeEnabled()}});case"shareproject":{const i=a;return t.anonymousPublishHeaderByIdAsync(i.headerId,i.projectName).then(t=>{e=t})}case"savelocalprojectstocloud":{const i=a;return t.saveLocalProjectsToCloudAsync(i.headerIds).then(t=>{e={headerIdMap:t}})}case"requestprojectcloudstatus":{const e=a;return t.requestProjectCloudStatus(e.headerIds)}case"convertcloudprojectstolocal":{const e=a;return t.convertCloudProjectsToLocal(e.userId)}case"setlanguagerestriction":{const e=a;if("no-blocks"===e.restriction)throw pxt.warn("no-blocks language restriction is not supported"),new Error("no-blocks language restriction is not supported");return t.setLanguageRestrictionAsync(e.restriction)}case"precachetutorial":{const t=a,e=t.data,i=t.lang||pxt.Util.userLanguage();return pxt.github.db.cacheReposAsync(e).then(async()=>{if("string"==typeof e.markdown){const t=await pxt.BrowserUtils.translationDbAsync();await t.setAsync(i,e.path,void 0,void 0,e.markdown)}})}case"setcolorthemebyid":{const e=a;return t.setColorThemeById(e.colorThemeId,!!e.savePreference),Promise.resolve()}}return Promise.resolve()})));i.then(()=>c(a,e,!0,void 0),t=>c(a,e,!1,t))}return!0})};let l=!1;function c(t,e,i,o){if(t.response){const s={type:t.type,id:t.id,resp:e,success:i,error:o};a?a.postMessage(s):window.parent.postMessage(s,"*")}}function h(t){return new Promise((e,i)=>{const o=pxt.Util.clone(t);if(o.id=ts.pxtc.Util.guidGen(),t.response&&(r[o.id]={resolve:e,reject:i}),a?a.postMessage(o):window.parent.postMessage(o,"*"),pxt.commands.onPostHostMessage)try{pxt.commands.onPostHostMessage(o)}catch(t){pxt.reportException(t)}t.response||e(void 0)})}i.enableControllerAnalytics=function(){if(l)return;const t=!!pxt.commands.onPostHostMessage,e=pxt.appTarget.appTheme.allowParentController,i=pxt.BrowserUtils.isIFrame();if(!(t||e&&i))return;const o=pxt.tickEvent;pxt.tickEvent=function(t,e,i){o&&o(t,e,i),h({type:"pxthost",action:"event",tick:t,response:!1,data:e})};const s=pxt.reportException;pxt.reportException=function(t,e){s&&s(t,e);try{h({type:"pxthost",action:"event",tick:"error",message:t.message,response:!1,data:e})}catch(t){}};const n=pxt.reportError;pxt.reportError=function(t,e,i){n&&n(t,e,i),h({type:"pxthost",action:"event",tick:"error",category:t,message:e,data:i})},l=!0},i.shouldPostHostMessages=function(){return pxt.appTarget.appTheme.allowParentController&&pxt.BrowserUtils.isIFrame()},i.postHostMessageAsync=h},{"../pxtservices/iframeEmbeddedClient":185,"./code-validation/runValidatorPlan":160,"./projectImport":180}],169:[function(t,e,i){"use strict";function o(t){return`experiments-${"object"==typeof t?t.id:t}`}let s;function n(){const t=pxt.savedAppTheme(),e={},i=r();return i.forEach(i=>{const o=a(i);t[i.id]=!!o,o&&(e[i.id]=o?1:0)}),i.length&&Object.keys(e).length&&(pxt.tickEvent("experiments.loaded",e),pxt.reloadAppTargetVariant()),pxt.appTarget.appTheme}function r(){const t=pxt.appTarget.appTheme.experiments;if(!t)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(e=>t.indexOf(e.id)>-1).concat(s||[]).filter(t=>!(pxt.BrowserUtils.isPxtElectron()&&t.enableOnline))}function a(t){return!!pxt.storage.getLocal(o(t))}function l(t,e){e!=a(t)&&(e?pxt.storage.setLocal(o(t),"1"):pxt.storage.removeLocal(o(t)),n())}Object.defineProperty(i,"__esModule",{value:!0}),i.setState=i.state=i.toggle=i.isEnabled=i.someEnabled=i.clear=i.all=i.syncTheme=i.setEditorExtensionExperiments=void 0,i.setEditorExtensionExperiments=function(t){s=t},i.syncTheme=n,i.all=r,i.clear=function(){r().forEach(t=>pxt.storage.removeLocal(o(t))),n()},i.someEnabled=function(){return r().some(t=>a(t))},i.isEnabled=a,i.toggle=function(t){t.onClick?t.onClick():l(t,!a(t))},i.state=function(){const t={};return r().forEach(e=>t[e.id]=a(e)),JSON.stringify(t)},i.setState=l},{}],170:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.patchConfigEditorVersion=i.getTextAtTime=i.updateShareHistory=i.pushSnapshotOnHistory=i.updateHistory=i.parseHistoryFile=i.applySnapshot=i.createSnapshot=i.applyDiff=i.diffScriptText=i.collapseHistory=void 0;const o=18e5,s=864e5;function n(t,e,i,o,s){const n=[],l=t.entries.slice();let c=Object.assign({},e),{interval:h,minTime:u,maxTime:d}=i;void 0===u&&(u=0),void 0===d&&(d=t.lastSaveTime);let p=Object.assign({},c),g=t.lastSaveTime;for(;l.length;){const t=l.pop();c=a(c,t,s),t.timestamp>d?(n.unshift(t),p=Object.assign({},c),g=t.timestamp):t.timestamp<u?p?(n.unshift({timestamp:t.timestamp,editorVersion:t.editorVersion,changes:r(c,p,t.timestamp,o).changes}),p=void 0):n.unshift(t):g-t.timestamp>=h&&(n.unshift({timestamp:t.timestamp,editorVersion:t.editorVersion,changes:r(c,p,t.timestamp,o).changes}),p=Object.assign({},c),g=t.timestamp)}return p&&g>t.entries[0].timestamp&&n.unshift({timestamp:t.entries[0].timestamp,editorVersion:t.entries[0].editorVersion,changes:r(c,p,t.entries[0].timestamp,o).changes}),Object.assign(Object.assign({},t),{entries:n})}function r(t,e,i,o){var s,n;const r=[];for(const i of Object.keys(t))(i.endsWith(".ts")||i.endsWith(".jres")||i.endsWith(".py")||i.endsWith(".blocks")||"pxt.json"===i)&&(null==e[i]?r.push({type:"removed",filename:i,value:t[i]}):t[i]!==e[i]&&r.push({type:"edited",filename:i,patch:o(e[i],t[i])}));for(const i of Object.keys(e))(i.endsWith(".ts")||i.endsWith(".jres")||i.endsWith(".py")||i.endsWith(".blocks")||"pxt.json"===i)&&null==t[i]&&r.push({type:"added",filename:i,value:e[i]});if(r.length)return{timestamp:i,editorVersion:null===(n=null===(s=pxt.appTarget)||void 0===s?void 0:s.versions)||void 0===n?void 0:n.target,changes:r}}function a(t,e,i){const o=Object.assign({},t);for(const s of e.changes)"added"===s.type?delete o[s.filename]:"removed"===s.type?o[s.filename]=s.value:o[s.filename]=i(s.patch,t[s.filename]);return o}function l(t){let e;try{e={};const i=JSON.parse(t[pxt.CONFIG_NAME]);for(const o of i.files)o===pxt.IMAGES_CODE||o===pxt.TILEMAP_CODE?e[o]="":e[o]=t[o];if(e[pxt.CONFIG_NAME]=t[pxt.CONFIG_NAME],i.preferredEditor===pxt.BLOCKS_PROJECT_NAME?e[pxt.MAIN_BLOCKS]&&(e[pxt.MAIN_TS]=""):i.preferredEditor===pxt.PYTHON_PROJECT_NAME&&e[pxt.MAIN_PY]&&(e[pxt.MAIN_TS]=""),i.testFiles)for(const o of i.testFiles)e[o]=t[o]}catch(i){e=Object.assign({},t)}return e[pxt.HISTORY_FILE]&&delete e[pxt.HISTORY_FILE],e}function c(t){const e=JSON.parse(t);return e.entries||(e.entries=[]),e.shares||(e.shares=[]),e.snapshots||(e.snapshots=[]),e}function h(t,e){t=Object.assign({},t);try{const i=JSON.parse(t[pxt.CONFIG_NAME]);i.targetVersions&&(i.targetVersions.target=e),t[pxt.CONFIG_NAME]=JSON.stringify(i,null,4)}catch(t){}return{files:t,editorVersion:e}}function u(t,e){return{timestamp:e,editorVersion:pxt.appTarget.versions.target,text:l(t)}}function d(){var t,e;return null!=(null===(e=null===(t=pxt.appTarget)||void 0===t?void 0:t.appTheme)||void 0===e?void 0:e.timeMachineDiffInterval)?pxt.appTarget.appTheme.timeMachineDiffInterval:3e5}i.collapseHistory=function(t,e,i,o){if(!t[pxt.HISTORY_FILE])return;const s=n(c(t[pxt.HISTORY_FILE]),t,e,i,o);t[pxt.HISTORY_FILE]=JSON.stringify(s)},i.diffScriptText=r,i.applyDiff=a,i.createSnapshot=l,i.applySnapshot=function(t,e){var i;try{const o=Object.assign({},e),s=JSON.parse(t[pxt.CONFIG_NAME]);for(const e of Object.keys(t))e!==pxt.HISTORY_FILE&&(-1!==s.files.indexOf(e)||-1!==(null===(i=s.testFiles)||void 0===i?void 0:i.indexOf(e))||o[e]||(o[e]=t[e]));return o}catch(i){const o=Object.assign({},t);for(const t of Object.keys(e))o[t]=e[t];return o}},i.parseHistoryFile=c,i.updateHistory=function(t,e,i,l,h,p,g=!1){let m;t[pxt.HISTORY_FILE]?(m=c(t[pxt.HISTORY_FILE]),void 0===m.lastSaveTime&&(m.lastSaveTime=i)):m={entries:[],snapshots:[u(t,i-1)],shares:[],lastSaveTime:i};const _=m.lastSaveTime;for(const t of l)m.shares.some(e=>e.id===t.id)||m.shares.push({id:t.id,timestamp:i});if(function(t,e){const i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(const s of i){if(-1===o.indexOf(s))return!1;if(t[s]!==e[s])return!1}return!0}(t,e))return void(e[pxt.HISTORY_FILE]=JSON.stringify(m));let f=!1;if(1===m.entries.length){i-m.entries[m.entries.length-1].timestamp<d()&&(f=!0)}else if(m.entries.length>1){const t=m.entries[m.entries.length-1].timestamp,e=m.entries[m.entries.length-2].timestamp;i-t<d()&&t-e<d()&&(f=!0)}if(f){const i=m.entries.pop(),o=r(a(t,i,p),e,i.timestamp,h);o&&m.entries.push(o)}else{const i=r(t,e,m.lastSaveTime,h);i&&m.entries.push(i)}if(g&&Math.floor(_/s)!==Math.floor(i/s)&&(m=n(m,e,{interval:72e5,maxTime:i-s},h,p)),m.lastSaveTime=i,0==m.snapshots.length)m.snapshots.push(u(t,i-1));else if(i-m.snapshots[m.snapshots.length-1].timestamp>=function(){var t,e;if(null!=(null===(e=null===(t=pxt.appTarget)||void 0===t?void 0:t.appTheme)||void 0===e?void 0:e.timeMachineSnapshotInterval))return pxt.appTarget.appTheme.timeMachineSnapshotInterval;return o}()){m.snapshots.push(u(t,i));const e=[];let o=Math.floor(i/s)*s;for(let t=0;t<m.snapshots.length;t++){const n=m.snapshots[m.snapshots.length-1-t];i-n.timestamp<s||t===m.snapshots.length-1?e.unshift(n):n.timestamp<o&&(e.unshift(n),o=Math.floor(n.timestamp/s)*s)}m.snapshots=e}for(const t of m.snapshots)t.text[pxt.HISTORY_FILE]&&delete t.text[pxt.HISTORY_FILE];e[pxt.HISTORY_FILE]=JSON.stringify(m)},i.pushSnapshotOnHistory=function(t,e){let i;i=t[pxt.HISTORY_FILE]?c(t[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:e},i.snapshots.push(u(t,e)),t[pxt.HISTORY_FILE]=JSON.stringify(i)},i.updateShareHistory=function(t,e,i){let o;o=t[pxt.HISTORY_FILE]?c(t[pxt.HISTORY_FILE]):{entries:[],snapshots:[],shares:[],lastSaveTime:e};for(const t of i)o.shares.some(e=>e.id===t.id)||o.shares.push({id:t.id,timestamp:e});t[pxt.HISTORY_FILE]=JSON.stringify(o)},i.getTextAtTime=function(t,e,i,o){let s=Object.assign({},t);for(let t=0;t<e.entries.length;t++){const n=e.entries.length-1-t,r=e.entries[n];if(s=a(s,r,o),r.timestamp===i){return h(s,n>0?e.entries[n-1].editorVersion:r.editorVersion)}}return{files:s,editorVersion:pxt.appTarget.versions.target}},i.patchConfigEditorVersion=h},{}],171:[function(t,e,i){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,o,s)}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),s=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(i,"__esModule",{value:!0}),i.importDb=i.validation=i.experiments=i.workspace=i.monaco=i.history=void 0;const n=t("./history");i.history=n;const r=t("./monaco");i.monaco=r;const a=t("./workspace");i.workspace=a;const l=t("./experiments");i.experiments=l;const c=t("./code-validation");i.validation=c;const h=t("./projectImport");i.importDb=h,s(t("./editor"),i),s(t("./editorcontroller"),i),s(t("./monaco-fields/monacoFieldEditor"),i),s(t("./monaco-fields/field_tilemap"),i),s(t("./monaco-fields/field_musiceditor"),i),s(t("./monaco-fields/field_soundEffect"),i),s(t("./monaco-fields/field_sprite"),i),s(t("./monaco-fields/field_animation"),i),s(t("./monaco-fields/field_react"),i)},{"./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(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.animationEditorDefinition=i.MonacoAnimationEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="animation-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`");const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject(),s=o.lookupAssetByName("animation",i);if(s)return this.editing=s,s;{const t=o.createNewAnimation();return i&&!o.isNameTaken("animation",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("animation"),this.editing=t,t}}}resultToText(t){const e=pxt.react.getTilemapProject();return e.pushUndo(),t=pxt.patchTemporaryAsset(this.editing,t,e),t=e.updateAsset(t),pxt.getTSReferenceForAsset(t,this.isPython)}getFieldEditorId(){return n}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}i.MonacoAnimationEditor=r;const a=["assets\\s*\\.\\s*animation\\s*`[^`]*`",'assets\\s*\\.\\s*animation\\s*\\(\\s*"""[^"]*"""\\s*\\)'].map(t=>`(?:${t})`).join("|");i.animationEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.animationEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],173:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.songEditorDefinition=i.MonacoSongEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="music-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`"),this.text=t;const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject();this.isAsset=!0;const s=o.lookupAssetByName("song",i);if(s)return this.editing=s,s;{const t=o.createNewSong(pxt.assets.music.getEmptySong(2));return i&&!o.isNameTaken("song",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("song"),this.editing=t,t}}const i=/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m.exec(t);if(i){const t=i[1].trim();return this.editing=a(t?pxt.assets.music.decodeSongFromHex(t):pxt.assets.music.getEmptySong(2)),this.editing}}resultToText(t){var e;const i=pxt.react.getTilemapProject();if(i.pushUndo(),null===(e=(t=pxt.patchTemporaryAsset(this.editing,t,i)).meta)||void 0===e?void 0:e.displayName){t=this.isAsset||i.lookupAsset(t.type,t.id)?i.updateAsset(t):i.createNewSong(t.song,t.meta.displayName);let e=pxt.getTSReferenceForAsset(t,this.isPython);return this.isAsset||(e=this.isPython?`music.create_song(${e})`:`music.createSong(${e})`),e}let o=pxt.assets.music.encodeSongToHex(t.song);return o=this.isPython?`hex("""${o}""")`:"hex`"+o+"`",this.text.replace(/hex\s*(?:`|\(""")\s*([a-fA-F0-9]*)\s*(?:`|"""\))\s*(?:;?)/m,o)}getFieldEditorId(){return n}getOptions(){return{blocksInfo:this.host.blocksInfo()}}}function a(t){return{type:"song",id:"",internalID:0,meta:{},song:t}}i.MonacoSongEditor=r;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(t=>`(?:${t})`).join("|");i.songEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"fas fa-music sprite-focus-hover",heightInPixels:510,matcher:{searchString:l,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.songEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],174:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.MonacoReactFieldEditor=void 0;i.MonacoReactFieldEditor=class{getId(){return"image-editor"}showEditorAsync(t,e,i){return this.fileType=t,this.editrange=e,this.host=i,this.initAsync().then(()=>{const t=this.textToValue(i.getText(e));return t?(this.fv=pxt.react.getFieldEditorView(this.getFieldEditorId(),t,this.getOptions()),this.fv.onHide(()=>{this.onClosed()}),this.fv.show(),new Promise((t,e)=>{this.resolver=t,this.rejecter=e})):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(t){return null}resultToText(t){return t+""}getFieldEditorId(){return""}getOptions(){return null}}},{}],175:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.soundEditorDefinition=i.MonacoSoundEffectEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="soundeffect-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){const e={wave:"sine",startFrequency:5e3,endFrequency:0,startVolume:255,endVolume:0,duration:500,effect:"none",interpolation:"linear"};this.value=e;const i=/\(([^)]*)\)/.exec(t)[1].split(",").map(t=>t.replace(/\s/g,""));if(8!==i.length)return e;switch(i[0]){case"WaveShape.Sawtooth":e.wave="sawtooth";break;case"WaveShape.Square":e.wave="square";break;case"WaveShape.Noise":e.wave="noise";break;case"WaveShape.Triangle":e.wave="triangle";break;default:e.wave="sine"}const o=(t,e)=>isNaN(t)?e:t;switch(e.startFrequency=o(parseInt(i[1]),e.startFrequency),e.endFrequency=o(parseInt(i[2]),e.endFrequency),e.startVolume=o(parseInt(i[3]),e.startVolume),e.endVolume=o(parseInt(i[4]),e.endVolume),e.duration=o(parseInt(i[5]),e.duration),i[6]){case"SoundExpressionEffect.Vibrato":e.effect="vibrato";break;case"SoundExpressionEffect.Tremolo":e.effect="tremolo";break;case"SoundExpressionEffect.Warble":e.effect="warble";break;default:e.effect="none"}switch(i[7]){case"InterpolationCurve.Logarithmic":e.interpolation="logarithmic";break;case"InterpolationCurve.Curve":e.interpolation="curve";break;default:e.interpolation="linear"}return e}resultToText(t){let e,i,o;switch((t=this.value).wave){case"sine":e="WaveShape.Sine";break;case"square":e="WaveShape.Square";break;case"triangle":e="WaveShape.Triangle";break;case"noise":e="WaveShape.Noise";break;case"sawtooth":e="WaveShape.Sawtooth"}switch(t.effect){case"vibrato":i="SoundExpressionEffect.Vibrato";break;case"tremolo":i="SoundExpressionEffect.Tremolo";break;case"warble":i="SoundExpressionEffect.Warble";break;case"none":i="SoundExpressionEffect.None"}switch(t.interpolation){case"curve":o="InterpolationCurve.Curve";break;case"linear":o="InterpolationCurve.Linear";break;case"logarithmic":o="InterpolationCurve.Logarithmic"}return`music.createSoundEffect(${e}, ${Math.round(t.startFrequency)}, ${Math.round(t.endFrequency)}, ${Math.round(t.startVolume)}, ${Math.round(t.endVolume)}, ${Math.round(t.duration)}, ${i}, ${o})`}getFieldEditorId(){return n}getOptions(){return{onClose:()=>this.fv.hide(),onSoundChange:t=>this.value=t,initialSound:this.value,useFlex:!0,useMixerSynthesizer:"microbit"!==pxt.appTarget.id}}}i.MonacoSoundEffectEditor=r,i.soundEditorDefinition={id:n,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(t,e){let i=t.startLineNumber,o=0,s=!1,n=0;const r="createSoundEffect",a=e.getLineCount();for(;i<a;){const a=e.getLineContent(i),l=a.indexOf(r);if(-1!==l&&(s=!0,o=l+17),s)for(;o<a.length;){const s=a.charAt(o);if("("===s)n++;else if(")"===s&&(n--,0===n))return new monaco.Range(t.startLineNumber,t.startColumn,i,o+e.getLineMinColumn(i)+1);o++}o=0,i++}}},proto:r},(0,s.registerMonacoFieldEditor)(n,i.soundEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],176:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.spriteEditorDefinition=i.MonacoSpriteEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="image-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){this.isPython=-1===t.indexOf("`"),this.template=t.startsWith("bmp")?"bmp":"img";const e=pxt.parseAssetTSReference(t);if(e){const{name:t}=e,i=t.trim(),o=pxt.react.getTilemapProject();this.isAsset=!0;const s=o.lookupAssetByName("image",i);if(s)return this.editing=s,s;{const t=o.createNewImage();return i&&!o.isNameTaken("image",i)&&pxt.validateAssetName(i)?t.meta.displayName=i:t.meta.displayName=o.generateNewName("image"),this.editing=t,t}}return this.editing={type:"image",id:"",internalID:0,bitmap:pxt.sprite.imageLiteralToBitmap(t,this.template).data(),meta:{},jresData:""},this.editing}resultToText(t){var e;const i=pxt.react.getTilemapProject();return i.pushUndo(),(null===(e=(t=pxt.patchTemporaryAsset(this.editing,t,i)).meta)||void 0===e?void 0:e.displayName)?(t=this.isAsset||i.lookupAsset(t.type,t.id)?i.updateAsset(t):i.createNewProjectImage(t.bitmap,t.meta.displayName),this.isAsset=!0,pxt.getTSReferenceForAsset(t,this.isPython)):pxt.sprite.bitmapToImageLiteral(pxt.sprite.Bitmap.fromData(t.bitmap),this.isPython?"python":"typescript",this.template)}getFieldEditorId(){return"image-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}}i.MonacoSpriteEditor=r;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(t=>`(?:${t})`).join("|");i.spriteEditorDefinition={id:n,foldMatches:!0,glyphCssClass:"sprite-editor-glyph sprite-focus-hover",heightInPixels:510,matcher:{searchString:a,isRegex:!0,matchCase:!0,matchWholeWord:!1},proto:r},(0,s.registerMonacoFieldEditor)(n,i.spriteEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],177:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.tilemapEditorDefinition=i.MonacoTilemapEditor=void 0;const o=t("./field_react"),s=t("./monacoFieldEditor"),n="tilemap-editor";class r extends o.MonacoReactFieldEditor{textToValue(t){const e=this.readTilemap(t),i=pxt.react.getTilemapProject();return pxt.sprite.addMissingTilemapTilesAndReferences(i,e),this.editing=e,e}readTilemap(t){const e=pxt.react.getTilemapProject();if(/^\s*tiles\s*\./.test(t)&&(this.isTilemapLiteral=!1,t)){try{return function(t){return{type:"tilemap",id:"",internalID:0,meta:{},data:t}}(pxt.sprite.decodeTilemap(t,"typescript",e))}catch(t){}return null}this.isTilemapLiteral=!0;const i=/^\s*(tilemap(?:4|8|16|32)?)\s*(?:`([^`]*)`)|(?:\(\s*"""([^"]*)"""\s*\))\s*$/.exec(t),o=(i[2]||i[3]||"").trim();let s,n;if(this.tilemapLiteral=i[1],o&&(n=ts.pxtc.escapeIdentifier(o),s=e.getTilemap(n)||e.lookupAssetByName("tilemap",o)),!s){let t=16;"tilemap8"===this.tilemapLiteral?t=8:"tilemap32"===this.tilemapLiteral?t=32:"tilemap4"===this.tilemapLiteral&&(t=4);const[i]=e.createNewTilemap(n,t,16,16);s=e.getTilemap(i),n=i}return s}resultToText(t){const e=pxt.react.getTilemapProject();return e.pushUndo(),t=pxt.patchTemporaryAsset(this.editing,t,e),pxt.sprite.updateTilemapReferencesFromResult(e,t),this.isTilemapLiteral?(e.updateAsset(t),pxt.getTSReferenceForAsset(t,"python"===this.fileType)):pxt.sprite.encodeTilemap(t.data,"typescript"===this.fileType?"typescript":"python")}getFieldEditorId(){return"tilemap-editor"}getOptions(){return{initWidth:16,initHeight:16,blocksInfo:this.host.blocksInfo()}}getCreateTilemapRange(){const t=this.editrange.getStartPosition();let e,i=this.editrange.getEndPosition(),o=1;for(;;){e=new monaco.Range(i.lineNumber,i.column,i.lineNumber+1,0);const s=this.host.getText(e);for(let e=0;e<s.length;e++)if("("===s.charAt(e))o++;else if(")"===s.charAt(e)&&(o--,0===o)){const o=new monaco.Position(i.lineNumber,i.column+e+2);return monaco.Range.fromPositions(t,o)}if(i=e.getEndPosition(),i.lineNumber>t.lineNumber+20)return null}}}i.MonacoTilemapEditor=r,i.tilemapEditorDefinition={id:n,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:r},(0,s.registerMonacoFieldEditor)(n,i.tilemapEditorDefinition)},{"./field_react":174,"./monacoFieldEditor":178}],178:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getMonacoFieldEditor=i.registerMonacoFieldEditor=void 0;const o={};i.registerMonacoFieldEditor=function(t,e){o[t]=e},i.getMonacoFieldEditor=function(t){return o[t]}},{}],179:[function(t,e,i){"use strict";function o(t){const e=pxt.appTarget.appTheme.invertedMonaco,i=!(!pxt.appTarget.appTheme.monacoFieldEditors||!pxt.appTarget.appTheme.monacoFieldEditors.length);let o=monaco.editor.create(t,{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:i,glyphMargin:i||pxt.appTarget.appTheme.debugger,minimap:{enabled:!1},fixedOverflowWidgets:!0,autoIndent:"full",useTabStops:!0,dragAndDrop:!0,matchBrackets:"always",occurrencesHighlight:!1,quickSuggestionsDelay:200,theme:e?"vs-dark":"vs",renderIndentGuides:!0,accessibilityHelpUrl:"",quickSuggestions:{other:!0,comments:!0,strings:!0},acceptSuggestionOnCommitCharacter:!0,acceptSuggestionOnEnter:"on",accessibilitySupport:"on"});return o.layout(),o}Object.defineProperty(i,"__esModule",{value:!0}),i.createEditor=i.initMonacoAsync=i.syncModels=void 0,i.syncModels=function(t,e,i,o){if(o)return;let s=monaco.languages.typescript.typescriptDefaults.getExtraLibs(),n={};t.sortedDeps().forEach(t=>{t.getFiles().forEach(o=>{let s=t.id+"/"+o;if(/\.(ts)$/.test(o)&&s!=i){if(!monaco.languages.typescript.typescriptDefaults.getExtraLibs()[s]){let i=t.readFile(o)||"\n";e[s]=monaco.languages.typescript.typescriptDefaults.addExtraLib(i,s)}n[s]="1"}})}),Object.keys(s).filter(t=>/\.(ts)$/.test(t)&&!n[t]).forEach(t=>{e[t].dispose()})},i.initMonacoAsync=function(t){return new Promise((e,i)=>{if("object"==typeof window.monaco)return void e(o(t));let s=window.MonacoPaths,n=()=>{let i=window.require;i.config({paths:s}),i(["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})),e(o(t))})};if(window.require)n();else{let t=document.createElement("script");t.type="text/javascript",t.src=s["vs/loader"],t.addEventListener("load",n),document.body.appendChild(t)}})},i.createEditor=o},{}],180:[function(t,e,i){"use strict";let o;Object.defineProperty(i,"__esModule",{value:!0}),i.removeProjectAsync=i.saveProjectAsync=void 0;const s="projects";async function n(){if(o)return o;const t=pxt.appTarget.id+"-import";return o=new pxt.BrowserUtils.IDBWrapper(t,1,(t,e)=>{e.result.createObjectStore(s,{keyPath:"importId"})}),await o.openAsync(),o}i.saveProjectAsync=async function(t){const e={importId:pxt.U.guidGen(),project:t},i=await n();return await i.deleteAllAsync(s),await i.setAsync(s,e),e.importId},i.removeProjectAsync=async function(t){const e=await n(),i=await e.getAsync(s,t);return await e.deleteAllAsync(s),null==i?void 0:i.project}},{}],181:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.freshHeader=void 0,i.freshHeader=function(t,e){return{target:pxt.appTarget.id,targetVersion:pxt.appTarget.versions.target,name:t,meta:{},editor:pxt.JAVASCRIPT_PROJECT_NAME,pubId:"",pubCurrent:!1,_rev:null,id:pxt.U.guidGen(),recentUse:e,modificationTime:e,cloudUserId:null,cloudCurrent:!1,cloudVersion:null,cloudLastSyncTime:0,isDeleted:!1}}},{}],182:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});const o=t("./runner"),s=t("./renderer"),n=t("../pxteditor");window.pxt||(window.pxt={}),window.pxt.runner=Object.assign(Object.assign({},o),s),window.pxt.editor=Object.assign({},n),function(){let t=window.ksRunnerWhenLoaded;t&&t()}()},{"../pxteditor":171,"./renderer":183,"./runner":184}],183:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.renderAsync=i.fireClickOnEnter=i.defaultClientRenderOptions=void 0;const o=t("./runner"),s=t("blockly"),n=t("../pxtblocks"),r=t("../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(t){"undefined"!=typeof hljs&&(t.hasClass("highlight")?hljs.highlightBlock(t[0]):t.find("code.highlight").each(function(t,e){hljs.highlightBlock(e)}),c(t))}function c(t){t.find("span.hljs-comment:contains(@highlight)").each((t,e)=>{try{!function(t){const e=$(t),i=document.createElement("span");i.className="highlight-line";let o=t.nextSibling;if(!o||o.nodeType!=Node.TEXT_NODE)return;let s=o.textContent,n=s.indexOf("\n");if(n<0)return;o.textContent=s.substring(0,n+1),$(document.createTextNode(s.substring(n+1).replace(/^\s+/,""))).insertAfter($(o)),o=o.nextSibling;for(;o;){let t=o.nextSibling;if(o.nodeType==Node.TEXT_NODE){s=o.textContent;const e=s.indexOf("\n");if(!(e<0)){i.appendChild(document.createTextNode(s.substring(0,e))),o.textContent=s.substring(e+1);break}i.appendChild(o),o=t}else i.appendChild(o),o=t}$(i).insertAfter(e),e.remove()}(e)}catch(t){pxt.reportException(t)}})}function h(t,e){t.append($('<div class="ui content blocks"/>').append(e))}function u(t,e,i){t.append($('<div class="ui content js"><div class="subheading"><i class="ui icon xicon js"></i>JavaScript</div></div>').append(e)),l(e)}function d(t,e,i){t.append($('<div class="ui content py"><div class="subheading"><i class="ui icon xicon python"></i>Python</div></div>').append(e)),l(e)}function p(t,e){const i=$('<a class="item" role="button" tabindex="0"><i role="presentation" aria-hidden="true"></i><span class="ui desktop only"></span></a>');return i.attr("aria-label",t),i.attr("title",t),i.find("i").attr("class",e),i.find("span").text(t),i.keypress(g),i}function g(t){const e="number"==typeof t.which?t.which:t.keyCode;13!==e&&32!==e||(t.preventDefault(),t.currentTarget.click())}i.defaultClientRenderOptions=a,i.fireClickOnEnter=g;let m=!1;function _(t,e,i,o,s,n,r={}){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 g=pxt.appTarget.appTheme||{};if(r.showEdit&&!g.hideDocsEdit&&n){const e=p(lf("Edit"),"edit icon"),{package:i,compileBlocks:r,compilePython:a}=n,l=i.host();if(s&&r?(i.setPreferredEditor(pxt.BLOCKS_PROJECT_NAME),l.writeFile(i,pxt.MAIN_BLOCKS,r.outfiles[pxt.MAIN_BLOCKS])):o&&a?(i.setPreferredEditor(pxt.PYTHON_PROJECT_NAME),l.writeFile(i,pxt.MAIN_PY,r.outfiles[pxt.MAIN_PY])):i.setPreferredEditor(pxt.JAVASCRIPT_PROJECT_NAME),t.assetJSON)for(const e of Object.keys(t.assetJSON))i.config.files.indexOf(e)<0&&i.config.files.push(e),l.writeFile(i,e,t.assetJSON[e]);const h=i.compressToFileAsync();e.click(()=>{pxt.tickEvent("docs.btn",{button:"edit"}),h.then(e=>{window.open(`${function(t){const e=t.pxtUrl||pxt.appTarget.appTheme.homeUrl;return(e||"").replace(/\/$/,"")}(t)}/#project:${ts.pxtc.encodeBase64(pxt.Util.uint8ArrayToString(e))}`,"pxt")})}),c.append(e)}if(t.showJavaScript||!s&&!o?(l.append(i),f(),b()):s?(l.append(s),T(),b()):o&&(l.append(o),f(),T()),r.run&&!g.hideDocsSimulator){let e=p(lf("Run"),"play icon").click(()=>{if(pxt.tickEvent("docs.btn",{button:"sim"}),l.find(".sim")[0])l.find(".sim").remove(),E(l);else{m||(m=!0,window.addEventListener("message",t=>{const e=t.data;if("aspectratio"!==e.type)return;const i=e.frameid,o=e.value,s=document.querySelector(`iframe[data-frameid="${i}"]`);(null==s?void 0:s.parentElement)&&(s.parentElement.style.paddingBottom=100/o+"%")}));let e="81.97%";pxt.appTarget.simulator&&(e=100/pxt.appTarget.simulator.aspectRatio+"%");const o=t.package?"&deps="+encodeURIComponent(t.package):"",s=A(t)+"#nofooter=1"+o,n=t.assetJSON?`data-assets="${encodeURIComponent(JSON.stringify(t.assetJSON))}"`:"",r=encodeURIComponent(i.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:${e};overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="${s}" data-code="${r}" data-frameid="${a}" ${n} allowfullscreen="allowfullscreen" sandbox="allow-popups allow-forms allow-scripts allow-same-origin" frameborder="0"></iframe></div></div></div>`);l.append(c),E(c)}});c.append(e)}if(r.hexname&&r.hex){let t=p(lf("Download"),"download icon").click(()=>{pxt.tickEvent("docs.btn",{button:"hex"}),pxt.BrowserUtils.browserDownloadBinText(r.hex,r.hexname,{contentType:pxt.appTarget.compile.hexMimeType})});c.append(t)}let _=$("<div class=codesnippet></div>");function f(){if(!s)return;const t=p(lf("Blocks"),"icon xicon blocks").click(()=>{pxt.tickEvent("docs.btn",{button:"blocks"}),l.find(".blocks")[0]?(l.find(".blocks").remove(),E(l)):(h(i?i.parent():l,s),E(s))});c.append(t)}function T(){if(i)if(r.showJs)u(l,i);else{const t=p("JavaScript","icon xicon js").click(()=>{pxt.tickEvent("docs.btn",{button:"js"}),l.find(".js")[0]?(l.find(".js").remove(),E(l)):(u(s?s.parent():l,i),E(i))});c.append(t)}}function b(){if(o)if(r.showPy)d(l,o);else{const t=p("Python","icon xicon python").click(()=>{pxt.tickEvent("docs.btn",{button:"py"}),l.find(".py")[0]?(l.find(".py").remove(),E(l)):(d(s?s.parent():l,o),E(o))});c.append(t)}}function E(t){var e;null===(e=t[0])||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})}c.children().length&&_.append(a),_.append(l),e.replaceWith(_)}let f,T=[];function b(t,e,i){if(!t)return Promise.resolve();let o=$("."+t).first();return o[0]?(i.emPixels||(i.emPixels=18),i.layout||(i.layout=1),i.splitSvg=!0,T.push({el:o,source:o.text(),options:i,render:e}),o.addClass("lang-shadow"),o.removeClass(t),b(t,e,i)):Promise.resolve()}function E(t){if(!t||t.kind!=ts.SyntaxKind.ExpressionStatement)return null;let e=t;if(!e.expression||e.expression.kind!=ts.SyntaxKind.CallExpression)return null;let i=e.expression;return pxtc.pxtInfo(i).callInfo}function y(t){return f||(f=(0,o.decompileSnippetAsync)("",t)),f}function v(t,e){if(!e)return;const i=/^\/(v\d+)/.exec(e.url),o=/^\/(v\d+)/.exec(window.location.pathname),s=/#doc/i.test(window.location.href);e.url&&!i&&o&&!s&&(e.url=`/${o[1]}/${e.url}`);const n=document.createElement("div");n.setAttribute("role","listitem"),n.append((0,r.renderCodeCard)(e,{hideHeader:!0,shortName:!0})),t.append(n)}function C(t,e,i){const o=e.attributes,n=!o.blockHidden&&s.Blocks[o.blockId];if(null==n?void 0:n.codeCard){const e=pxt.U.clone(n.codeCard);i&&(e.style=i),v(t,e)}else v(t,{name:e.qName,description:o.jsDoc,url:o.help||void 0,style:i})}function I(t,e,i,o){return b(e,(t,e)=>{const n=e.compileProgram;if(!n)return;const r=n.getSourceFile(pxt.MAIN_TS).statements.slice(0),a=document.createElement("div");a.setAttribute("role","list"),a.className="card-list",r.forEach(t=>{const i=t.kind,n=E(t);if(n&&e.apiInfo&&e.apiInfo.byQName[n.qName]){const t=e.apiInfo.byQName[n.qName],i=t.attributes,r=s.Blocks[i.blockId];if(o){const o=t,s=e.compileBlocks.blocksInfo.apis.byQName[o.namespace];v(a,{name:s.attributes.blockNamespace||s.name,url:s.attributes.help||"reference/"+(s.attributes.blockNamespace||s.name).toLowerCase(),description:s.attributes.jsDoc,blocksXml:r&&r.codeCard?r.codeCard.blocksXml:i.blockId?`<xml xmlns="http://www.w3.org/1999/xhtml"><block type="${i.blockId}"></block></xml>`:void 0})}else C(a,t)}else switch(i){case ts.SyntaxKind.ExpressionStatement:{const e=t;switch(e.expression.kind){case ts.SyntaxKind.TrueKeyword:case ts.SyntaxKind.FalseKeyword:v(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: ${e.expression.kind}`)}break}case ts.SyntaxKind.IfStatement:v(a,{name:o?"Logic":"if",url:"blocks/logic"+(o?"":"/if"),description:o?lf("Logic operators and constants"):lf("Conditional statement"),blocksXml:'<xml xmlns="http://www.w3.org/1999/xhtml"><block type="controls_if"></block></xml>'});break;case ts.SyntaxKind.WhileStatement:v(a,{name:o?"Loops":"while",url:"blocks/loops"+(o?"":"/while"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"for of",url:"blocks/loops"+(o?"":"/for-of"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"break",url:"blocks/loops"+(o?"":"/break"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Loops":"continue",url:"blocks/loops"+(o?"":"/continue"),description:o?lf("Loops and repetition"):lf("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 e=t,i=!0;3==e.condition.getChildCount()&&(i=!("0"==e.condition.getChildAt(0).getText()||e.condition.getChildAt(1).kind==ts.SyntaxKind.LessThanToken)),v(a,i?{name:o?"Loops":"for",url:"blocks/loops"+(o?"":"/for"),description:o?lf("Loops and repetition"):lf("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:o?"Loops":"repeat",url:"blocks/loops"+(o?"":"/repeat"),description:o?lf("Loops and repetition"):lf("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:v(a,{name:o?"Variables":"variable declaration",url:"blocks/variables"+(o?"":"/assign"),description:o?lf("Variables"):lf("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: ${i}`)}}),i&&(t=t.parent()),t.replaceWith(a)},{package:t.package,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}function k(t,e){if(!t)return Promise.resolve();let i=$("."+t).first();if(!i[0])return Promise.resolve();i.removeClass(t);const o=pxt.gallery.parseCodeCardsHtml(i[0]);return o||i.append($("<div/>").addClass("ui segment warning").text("invalid codecard format")),e.snippetReplaceParent&&(i=i.parent()),function(t,e,i){if(!e||0==e.length)return Promise.resolve();if(0==e.length){let o=(0,r.renderCodeCard)(e[0],i);t.replaceWith(o)}else{let o=document.createElement("div");o.className="card-list",o.setAttribute("role","list"),o.setAttribute("aria-label",i.cardCategory||lf("Content cards")),e.forEach(t=>{const e=/^\/(v\d+)/.exec(t.url),s=/^\/(v\d+)/.exec(window.location.pathname),n=/#doc/i.test(window.location.href);t.url&&!e&&s&&!n&&(t.url=`/${s[1]}${t.url}`);const a=(0,r.renderCodeCard)(t,i),l=document.createElement("div");if(l.setAttribute("role","listitem"),l.appendChild(a),o.appendChild(l),"package"==t.cardType){const e=pxt.github.parseRepoId((t.url||"").replace(/^\/pkg\//,""));e&&pxt.packagesConfigAsync().then(o=>{switch(pxt.github.repoStatus(e,o)){case pxt.github.GitRepoStatus.Banned:a.remove();break;case pxt.github.GitRepoStatus.Approved:t.imageUrl=pxt.github.mkRepoIconUrl(e),l.insertBefore((0,r.renderCodeCard)(t,i),a),a.remove()}}).catch(e=>{pxt.reportException(e),pxt.debug(`failed to load repo ${t.url}`)})}}),t.replaceWith(o)}return Promise.resolve()}(i,o,{hideHeader:!0,cardCategory:e.hexName}).then(()=>pxt.U.delay(1,k(t,e)))}function A(t){return t.pxtUrl?t.pxtUrl+"/--run":pxt.webConfig&&pxt.webConfig.runUrl?pxt.webConfig.runUrl:"/--run"}function S(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};$("code.lang-python").each((i,o)=>{!function(i,o){"undefined"!=typeof hljs&&($(i).text($(i).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(i),c($(i)));const s=pxt.U.clone(e);o&&(s.run=!1,s.showEdit=!1),_(t,$(i).parent(),$(i),void 0,void 0,void 0,s)}(o,!1),$(o).removeClass("lang-python")})}function O(t,e){e.snippetReplaceParent&&(t=t.parent()),t.remove()}function R(t,e,i){$(`code.lang-${t}\\.${e}`).each((t,e)=>{O($(e),i)})}i.renderAsync=function(t){return pxt.analytics.enable(pxt.Util.userLanguage()),t||(t=a()),t.pxtUrl&&(t.pxtUrl=t.pxtUrl.replace(/\/$/,"")),t.showEdit&&(t.showEdit=!pxt.BrowserUtils.isIFrame()),pxt.docs.hydrateYouTubeEmbeds(document.body,!1),function(t){t.packageClass&&($("."+t.packageClass).each((e,i)=>{let o=$(i),s=o.text().split("\n").map(t=>t.replace(/\s*/g,"")).filter(t=>!!t).join(",");t.package=t.package?`${t.package},${s}`:s,t.snippetReplaceParent&&(o=o.parent()),o.remove()}),$(".lang-config").each((e,i)=>{let o=$(i);t.snippetReplaceParent&&(o=o.parent()),o.remove()}))}(t),function(t){let e,i;t.jresClass&&$(`.${t.jresClass}`).each((t,e)=>{const o=$(e);i=o.text(),e.parentElement.remove()}),t.assetJSONClass&&$(`.${t.assetJSONClass}`).each((t,i)=>{const o=$(i);e=o.text(),i.parentElement.remove()}),t.assetJSON=function(t,e){if(!t&&!e)return;const i=pxt.tutorial.parseAssetJson(t)||{};if(e){const t=JSON.parse(e);i[pxt.TILEMAP_JRES]=JSON.stringify(t),i[pxt.TILEMAP_CODE]=pxt.emitTilemapsFromJRes(t)}return i}(e,i)}(t),T=[],function(t){O($("code.lang-ghost"),t)}(t),function(t){R("blockconfig","local",t),R("blockconfig","global",t)}(t),function(t){O($("code.lang-template"),t)}(t),function(t){R("validation","local",t),R("validation","global",t)}(t),function(t){t.simulatorClass&&$("."+t.simulatorClass).each((e,i)=>{var o;let s=$(i),n="81.97%";pxt.appTarget.simulator&&(n=100/pxt.appTarget.simulator.aspectRatio+"%");const r=lf("MakeCode {0} Simulator",(null===(o=pxt.appTarget.appTheme)||void 0===o?void 0:o.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:${n};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(r)}"\n ></iframe>\n </div>\n </div>\n </div>\n `);const l=t.package?"&deps="+encodeURIComponent(t.package):"",c=A(t)+"#nofooter=1"+l,h=encodeURIComponent(s.text().trim()),u=a.find("iframe");u.attr("src",c),u.attr("data-code",h),t.assetJSON&&u.attr("data-assets",JSON.stringify(t.assetJSON)),t.snippetReplaceParent&&(s=s.parent()),s.replaceWith(a)})}(t),function(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};function i(i,o){"undefined"!=typeof hljs&&($(i).text($(i).text().replace(/^\s*\r?\n/,"")),hljs.highlightBlock(i),c($(i)));const s=pxt.U.clone(e);o&&(s.run=!1,s.showEdit=!1),_(t,$(i).parent(),$(i),void 0,void 0,void 0,s)}$("code.lang-typescript").each((t,e)=>{i(e,!1),$(e).removeClass("lang-typescript")}),$("code.lang-typescript-ignore").each((t,e)=>{$(e).removeClass("lang-typescript-ignore"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript")}),$("code.lang-typescript-invalid").each((t,e)=>{$(e).removeClass("lang-typescript-invalid"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript"),$(e).parent("div").addClass("invalid"),$(e).parent("div").prepend($("<i>",{class:"icon ban"})),$(e).addClass("invalid")}),$("code.lang-typescript-valid").each((t,e)=>{$(e).removeClass("lang-typescript-valid"),$(e).addClass("lang-typescript"),i(e,!0),$(e).removeClass("lang-typescript"),$(e).parent("div").addClass("valid"),$(e).parent("div").prepend($("<i>",{class:"icon check"})),$(e).addClass("valid")})}(t),S(t),Promise.resolve().then(()=>k(t.codeCardClass,t)).then(()=>async function(t){if("core"==pxt.appTarget.id)return;const e=(await y(t)).compileBlocks.blocksInfo;let i={};for(const t of e.blocks){const o=(t.attributes.blockNamespace||t.namespace).split(".")[0];if(!i[o]){const t=e.apis.byQName[o];t&&t.attributes.color&&(i[o]=t.attributes.color)}}let o="";for(const t of Object.keys(i)){const e=i[t];o+=`\n span.docs.${t.toLowerCase()} {\n --inline-namespace-color: ${e};\n }\n `}for(const t of Object.keys(pxt.toolbox.blockColors)){const e=pxt.toolbox.getNamespaceColor(t);o+=`\n span.docs.${t.toLowerCase()} {\n --inline-namespace-color: ${e};\n }\n `}let s=document.createElement("style");s.id="namespaceColors",s.type="text/css",(document.head||document.getElementsByTagName("head")[0]).appendChild(s),s.appendChild(document.createTextNode(o))}(t)).then(()=>function(t){(t=pxt.Util.clone(t)).emPixels=18,t.snippetMode=!0;const e=$(":not(pre) > code");let i=0;return function s(){if(i>=e.length)return Promise.resolve();const n=$(e[i++]),r=n.text(),a=/^(\|+)([^\|]+)\|+$/.exec(r);if(a){const t=/^(([^\:\.]*?)[\:\.])?(.*)$/.exec(a[2]),e=(t[2]?t[2].trim().toLowerCase():"").replace(/\(.*?\)/g,""),i=1==a[1].length?`docs inlinebutton ${e}`:`docs inlineblock ${e}`,o=t[3].trim();return n.replaceWith($(`<span class="${i}"/>`).text(pxt.U.rlf(o))),s()}const l=/^\[(.+)\]$/.exec(r);if(!l)return s();const c=l[1];return(0,o.decompileSnippetAsync)(c,t).then(t=>{if(t.blocksSvg){let e=$('<span class="block"/>').append(t.blocksSvg);const i=E(t.compileProgram.getSourceFile(pxt.MAIN_TS).statements[0]);if(i&&t.apiInfo){const o=t.apiInfo.byQName[i.qName];if(o&&o.attributes.help){const t=o.name||o.qName,i=lf("Documentation for {0} block",t);e=$('<a class="ui link"/>').attr("href",`/reference/${o.attributes.help}`).attr("aria-label",i).append(e)}}n.replaceWith(e)}return pxt.U.delay(1,s())})}()}(t)).then(()=>I(t,t.linksClass,t.snippetReplaceParent,!1)).then(()=>I(t,t.namespacesClass,t.snippetReplaceParent,!0)).then(()=>function(t,e){const i=t.apisClass;if(!i)return Promise.resolve();const o=$("."+i);return o.length?y(t).then(t=>{const i=t.compileBlocks.blocksInfo,n=pxt.Util.values(i.apis.byQName).filter(t=>!(t.attributes.hidden||t.attributes.deprecated||t.attributes.blockAliasFor||!t.attributes.jsDoc||!t.attributes.block||/^__/.test(t.name)));o.each((t,i)=>{let o=$(i);const r=pxt.Util.toDictionary(o.text().split("\n"),t=>t),a=n.filter(t=>!!r[t.attributes.blockNamespace||t.namespace]);if(!a.length)return;a.sort((t,e)=>{const i=!t.attributes.blockHidden&&s.Blocks[t.attributes.blockId],o=!e.attributes.blockHidden&&s.Blocks[e.attributes.blockId];return!!i!=!!o?(o?1:0)-(i?1:0):t.name.localeCompare(e.name)});const l=document.createElement("div");l.className="ui divided items",l.setAttribute("role","list"),a.forEach(t=>C(l,t,"item")),e&&(o=o.parent()),o.replaceWith(l)})}):Promise.resolve()}(t,t.snippetReplaceParent)).then(()=>function(t){return b(t.signatureClass,(e,i)=>{var o,r,a,l;let c=i.compileProgram;if(!c)return;let h=E(c.getSourceFile(pxt.MAIN_TS).statements[0]);if(!h||!i.apiInfo)return;const u=i.apiInfo.byQName[h.qName];if(!u)return;let d=s.Blocks[u.attributes.blockId],p=(null===(o=null==d?void 0:d.codeCard)||void 0===o?void 0:o.blocksXml)||void 0;const g=p?(0,n.render)(p):(null===(r=i.compileBlocks)||void 0===r?void 0:r.success)?i.blocksSvg:void 0,m=g?$(g):void 0;let f=ts.pxtc.service.displayStringForSymbol(u,!1,i.apiInfo).split("\n")[1]+";";const T=$('<code class="lang-typescript highlight"/>').text(f),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(u,!0,i.apiInfo).split("\n")[1],y=b&&$('<code class="lang-python highlight"/>').text(b);if(t.snippetReplaceParent&&(e=e.parent()),pxt.Util.isTranslationMode()){const t=$('<div class="ui segment" />');t.append($('<div class="ui header"><i class="ui xicon globe"></i></div>')),u.attributes.translationId&&t.append($('<div class="ui message">').text(u.attributes.translationId)),u.attributes.jsDoc&&t.append($('<div class="ui message">').text(u.attributes.jsDoc)),t.insertAfter(e)}_(t,e,T,y,m,i,{showJs:!0,showPy:!0,hideGutter:!0})},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>function(t){if(t.tutorial)return b(t.snippetClass,(e,i)=>{const o=i.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const s=$('<div class="ui segment codewidget"/>').append(o);e.replaceWith(s)},{package:t.package,snippetMode:!1,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON});let e=0;return b(t.snippetClass,(i,o)=>{const s=o.compileBlocks&&o.compileBlocks.success?$(o.blocksSvg):void 0,n=o.compilePython&&o.compilePython.success&&o.compilePython.outfiles[pxt.MAIN_PY],r=$('<code class="lang-typescript highlight"/>').text(i.text().trim()),a=n?$('<code class="lang-python highlight"/>').text(n.trim()):void 0;t.snippetReplaceParent&&(i=i.parent());const l=o.compileJS&&o.compileJS.success,c=t.hex&&l&&o.compileJS.outfiles[pxtc.BINARY_HEX]?o.compileJS.outfiles[pxtc.BINARY_HEX]:void 0,h=`${pxt.appTarget.nickname||pxt.appTarget.id}-${t.hexName||""}-${e++}.hex`;_(t,i,r,a,s,o,{showEdit:t.showEdit,run:t.simulator,hexname:h,hex:c})},{package:t.package,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>function(t){return b(t.blocksClass,(e,i)=>{const o=i.blocksSvg;t.snippetReplaceParent&&(e=e.parent());const s=$('<div class="ui segment codewidget"/>').append(o);e.replaceWith(s)},{package:t.package,snippetMode:!0,aspectRatio:t.blocksAspectRatio,assets:t.assetJSON})}(t)).then(()=>{return(e=t).blocksXmlClass?function t(e,i,s){let n=$("."+e).first();return n[0]?(s.emPixels||(s.emPixels=18),s.splitSvg=!0,(0,o.compileBlocksAsync)(n.text(),s).then(o=>{try{i(n,o)}catch(t){pxt.reportException(t),n.append($("<div/>").addClass("ui segment warning").text(t.message))}return n.removeClass(e),pxt.U.delay(1,t(e,i,s))})):Promise.resolve()}(e.blocksXmlClass,(t,i)=>{const o=i.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const s=$('<div class="ui segment codewidget"/>').append(o);t.replaceWith(s)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON}):Promise.resolve();var e}).then(()=>{return(e=t).diffBlocksXmlClass?function t(e,i,s){let r=$("."+e).first();if(!r[0])return Promise.resolve();s.emPixels||(s.emPixels=18),s.splitSvg=!0;const a=r.text().split(/-{10,}/),l=a[0],c=a[1];return(0,o.compileBlocksAsync)("",s).then(o=>{r.removeClass(e);try{const t=(0,n.diffXml)(l,c);t?(o.blocksSvg=t.svg,i(r,o)):r.text("no changes")}catch(t){pxt.reportException(t),r.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(e,i,s))})}(e.diffBlocksXmlClass,(t,i)=>{const o=i.blocksSvg;e.snippetReplaceParent&&(t=t.parent());const s=$('<div class="ui segment codewidget"/>').append(o);t.replaceWith(s)},{package:e.package,snippetMode:!0,aspectRatio:e.blocksAspectRatio,assets:e.assetJSON}):Promise.resolve();var e}).then(()=>{return(e=t).diffBlocksClass?function t(i){let s=$("."+i).first();if(!s[0])return Promise.resolve();const{fileA:r,fileB:a}=pxt.diff.split(s.text(),{removeTrailingSemiColumns:!0});return pxt.U.promiseMapAllSeries([r,a],t=>(0,o.decompileSnippetAsync)(t,{generateSourceMap:!0})).then(o=>{try{const t=(0,n.decompiledDiffAsync)(r,o[0].compileBlocks,a,o[1].compileBlocks,{hideDeletedTopBlocks:!0,hideDeletedBlocks:!0}),i=pxt.diff.render(r,a,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});let l;const[c,h]=o.map(t=>t.compilePython&&t.compilePython.outfiles&&t.compilePython.outfiles[pxt.MAIN_PY]);c&&h&&(l=pxt.diff.render(c,h,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0})),_(e,s.parent(),$(i),l&&$(l),$(t.svg),void 0,{showEdit:!1,run:!1,hexname:void 0,hex:void 0})}catch(t){pxt.reportException(t),s.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(i))})}(e.diffBlocksClass):Promise.resolve();var e}).then(()=>{return(e=t).diffClass?function t(i){let o=$("."+i).first();if(!o[0])return Promise.resolve();const{fileA:s,fileB:n}=pxt.diff.split(o.text());try{const t=pxt.diff.render(s,n,{hideLineNumbers:!0,hideMarkerLine:!0,hideMarker:!0,hideRemoved:!0,update:!0,ignoreWhitespace:!0});e.snippetReplaceParent&&(o=o.parent());const r=$('<div class="ui segment codewidget"/>').append(t);o.removeClass(i),o.replaceWith(r)}catch(t){pxt.reportException(t),o.append($("<div/>").addClass("ui segment warning").text(t.message))}return pxt.U.delay(1,t(i))}(e.diffClass):Promise.resolve();var e}).then(()=>function(t){const e={showEdit:!!t.showEdit,run:!!t.simulator};return b(t.staticPythonClass,(i,o)=>{const s=o.compilePython;if(s&&s.success){const n=i.clone().removeClass("lang-shadow").addClass("highlight"),r=n.clone().addClass("lang-python").text(s.outfiles[pxt.MAIN_PY]);n.addClass("lang-typescript"),l(r),_(t,i.parent(),n,r,void 0,o,e)}},{package:t.package,snippetMode:!0,assets:t.assetJSON})}(t)).then(()=>function(t){return t.projectClass?function e(){let i=$("."+t.projectClass).first(),s=i[0];if(!s)return Promise.resolve();i.removeClass(t.projectClass);let n=pxt.Cloud.parseScriptId(s.innerText);if(n){if(t.snippetReplaceParent){s=s.parentElement;let t=document.createElement("div");s.parentElement.insertBefore(t,s),s.parentElement.removeChild(s),s=t}return(0,o.renderProjectAsync)(s,n).then(()=>e())}return e()}():Promise.resolve()}(t)).then(()=>function(){const t={};return function e(){const i=T.shift();if(!i)return Promise.resolve();const{el:s,options:n,render:r}=i;return(0,o.decompileSnippetAsync)(s.text(),n).then(e=>{const i=e.compileJS&&e.compileJS.diagnostics&&e.compileJS.diagnostics.filter(t=>t.category==pxtc.DiagnosticCategory.Error);i&&i.length&&i.forEach(t=>pxt.reportError("docs.decompile",""+t.messageText,{code:t.code+""})),e.blocksSvg.querySelectorAll("defs *").forEach(e=>{t[e.id]?e.remove():t[e.id]=!0}),r(s,e)},t=>{pxt.reportException(t),s.append($("<div/>").addClass("ui segment warning").text(t.message))}).finally(()=>(s.removeClass("lang-shadow"),e()))}().then(()=>{s.Workspace.getAll().forEach(t=>t.dispose()),(0,n.cleanRenderingWorkspace)()})}())}},{"../pxtblocks":76,"../pxtblocks/codecardRenderer":11,"./runner":184,blockly:192}],184:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.init=i.setInitCallbacks=i.compileBlocksAsync=i.decompileSnippetAsync=i.renderMarkdownAsync=i.renderProjectFilesAsync=i.renderProjectAsync=i.startDocsServer=i.startRenderServer=i.setEditorContextAsync=i.editorLanguageMode=i.LanguageMode=i.buildSimJsInfo=i.fetchSimJsInfo=i.postSimMessage=i.currentDriver=i.preloadSim=i.simulateAsync=i.generateVMFileAsync=i.generateHexFileAsync=i.showError=i.initFooter=i.initHost=i.mainPkg=void 0;const o=t("../pxtblocks"),s=t("../pxteditor/editor"),n=t("./renderer"),r=t("../pxtblocks"),a=t("blockly");pxt.blocks.requirePxtBlockly=()=>r,pxt.blocks.requireBlockly=()=>a,pxt.blocks.registerFieldEditor=(t,e,i)=>r.registerFieldEditor(t,e,i);class l{constructor(t,e){this.ksPkg=t,this.topPkg=e,this.files={}}getKsPkg(){return this.ksPkg}getPkgId(){return this.ksPkg?this.ksPkg.id:this.id}isTopLevel(){return this.ksPkg&&0==this.ksPkg.level}setFiles(t){this.files=t}getAllFiles(){return pxt.Util.mapMap(this.files,(t,e)=>e)}}class c{constructor(){this.githubPackageCache={}}readFile(t,e){let i=m(t);return pxt.U.lookup(i.files,e)}writeFile(t,e,i){m(t).files[e]=i}getHexInfoAsync(t){return pxt.hexloader.getHexInfoAsync(this,t)}cacheStoreAsync(t,e){return Promise.resolve()}cacheGetAsync(t){return Promise.resolve(null)}patchDependencies(t,e,i){if(!i)return!1;const o=pxt.github.parseRepoId(i);if(!o)return!1;for(const e of Object.keys(t.dependencies)){const s=t.dependencies[e],n=pxt.github.parseRepoId(s);if(n&&o.fullName==n.fullName)return pxt.semver.strcmp(o.tag,n.tag)<0&&(t.dependencies[e]=i),!0}return!1}downloadPackageAsync(t,e){let i,o=t.verProtocol();"github"==o&&(i=this.githubPackageCache[t._verspec]);let s=m(t);return(i?Promise.resolve(i):t.commonDownloadAsync()).then(n=>{if(n)return"github"!=o||i||(this.githubPackageCache[t._verspec]=pxt.Util.clone(n)),s.setFiles(n),Promise.resolve();if("empty"==o){if(0==Object.keys(s.files).length&&s.setFiles(_()),e&&e.length){const i=m(t).files,o=JSON.parse(i[pxt.CONFIG_NAME]);e.forEach(t=>{g(o,t)}),i[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(o)}return Promise.resolve()}if("docs"==o){let e=_(),i=JSON.parse(e[pxt.CONFIG_NAME]);return t.verArgument().split(",").forEach(t=>{g(i,t)}),i.yotta||(i.yotta={}),i.yotta.ignoreConflicts=!0,e[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(i),s.setFiles(e),Promise.resolve()}return"invalid"==o?(pxt.log(`skipping invalid pkg ${t.id}`),Promise.resolve()):Promise.reject(`Cannot download ${t.version()}; unknown protocol`)})}}let h,u,d,p;function g(t,e){let i=/^([a-zA-Z0-9_-]+)(=(.+))?$/.exec(e);return i?t.dependencies[i[1]]=i[3]||"*":pxt.warn(`unknown package syntax ${e}`),!0}function m(t){let e=t._editorPkg;if(e)return e;let o=null;t!=i.mainPkg&&(o=m(i.mainPkg));let s=new l(t,o);return t==i.mainPkg&&(s.topPkg=s),t._editorPkg=s,s}function _(){let t=pxt.appTarget.tsprj,e=pxt.U.clone(t.files);return e[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(t.config),e[pxt.MAIN_BLOCKS]="",e}function f(){pxt.setAppTarget(window.pxtTargetBundle),pxt.analytics.enable(pxt.Util.userLanguage()),pxt.Util.assert(!!pxt.appTarget);const t=window.location.href;let e,i=!1;if(/[&?]translate=1/.test(t)&&!pxt.BrowserUtils.isIE())e=ts.pxtc.Util.TRANSLATION_LOCALE,i=!0,pxt.Util.enableLiveLocalizationUpdates();else{const o=/PXT_LANG=(.*?)(?:;|$)/.exec(document.cookie),s=/(live)?(force)?lang=([a-z]{2,}(-[A-Z]+)?)/i.exec(t);e=s?s[3]:o&&o[1]||pxt.appTarget.appTheme.defaultLocale||navigator.userLanguage||navigator.language;const n=pxt.appTarget.appTheme.defaultLocale,r=null==e?void 0:e.toLocaleLowerCase(),a=pxt.BrowserUtils.isLocalHostDev()&&(!r||(n?n.toLocaleLowerCase()===r:"en"===r||"en-us"===r));(pxt.BrowserUtils.isPxtElectron()||a||pxt.appTarget.appTheme.disableLiveTranslations)&&!(null==s?void 0:s[1])||pxt.Util.enableLiveLocalizationUpdates(),i=!!s&&!!s[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 o=pxt.webConfig;return pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:o.commitCdnUrl,code:e,force:i}).then(()=>T())}function T(){i.mainPkg=new pxt.MainPackage(new c)}function b(t){pxt.error(t)}function E(t,e,o){const s=t?/\w+:\w+/.test(t)?t:"pub:"+t:"empty:tsprj";let n,r,a;return u&&u._verspec==s?(i.mainPkg=u,n=i.mainPkg.host(),r=Promise.resolve(),a=Promise.resolve()):(n=i.mainPkg.host(),i.mainPkg=new pxt.MainPackage(n),i.mainPkg._verspec=t?/\w+:\w+/.test(t)?t:"pub:"+t:"empty:tsprj",r=n.downloadPackageAsync(i.mainPkg,o),a=i.mainPkg.installAllAsync(),u=i.mainPkg),r.then(()=>n.readFile(i.mainPkg,pxt.CONFIG_NAME)).then(t=>t?a.then(()=>{if(e){let t=m(i.mainPkg);t.files[pxt.MAIN_TS]=e;let o=JSON.parse(t.files[pxt.CONFIG_NAME]);o.name=window.location.href.split("/").pop().split(/[?#]/)[0],t.files[pxt.CONFIG_NAME]=pxt.Package.stringifyConfig(o),i.mainPkg.config.name=o.name,-1==i.mainPkg.config.files.indexOf(pxt.MAIN_BLOCKS)&&i.mainPkg.config.files.push(pxt.MAIN_BLOCKS)}}).catch(t=>{b(lf("Cannot load extension: {0}",t.message))}):Promise.resolve())}function y(t){let e=i.mainPkg.getTargetOptions();return e.isNative=!!t,e.hasHex=!!t,i.mainPkg.getCompileOptionsAsync(e)}function v(t,e){return y(t).then(t=>{e&&e(t);let i=pxtc.compile(t);return i.diagnostics&&i.diagnostics.length>0&&i.diagnostics.forEach(t=>{pxt.error(t.messageText)}),i})}function C(t,e,o){var s,n;d&&e.embedId&&p===e.embedId?d.container=t:(d=new pxsim.SimulatorDriver(t),p=e.embedId);const{fnArgs:r,parts:a,usedBuiltinParts:l}=o||{};let c=pxt.appTarget.simulator.boardDefinition,h=A(e.id),u={debug:e.debug,mute:e.mute,boardDefinition:c,parts:a,builtinParts:l,fnArgs:r,cdnUrl:pxt.webConfig.commitCdnUrl,localizedStrings:pxt.Util.getLocalizedStrings(),partDefinitions:null===i.mainPkg||void 0===i.mainPkg?void 0:i.mainPkg.computePartDefinitions(a),highContrast:e.highContrast,storedState:h,light:e.light,single:e.single,hideSimButtons:e.hideSimButtons,autofocus:e.autofocus,queryParameters:e.additionalQueryParameters,mpRole:e.mpRole,theme:null===(s=i.mainPkg.config)||void 0===s?void 0:s.theme};if(pxt.appTarget.simulator&&!e.fullScreen&&(u.aspectRatio=a.length&&pxt.appTarget.simulator.partsAspectRatio?pxt.appTarget.simulator.partsAspectRatio:pxt.appTarget.simulator.aspectRatio),window.parent&&u.aspectRatio&&u.aspectRatio!==pxt.appTarget.simulator.aspectRatio){const t=null===(n=window.frameElement)||void 0===n?void 0:n.getAttribute("data-frameid");t&&window.parent.postMessage({type:"aspectratio",frameid:t,value:u.aspectRatio},"*")}return d.setRunOptions(u),u}async function I(t){try{const e=Date.now(),i=await pxt.Cloud.downloadBuiltSimJsInfoAsync(t.id);return pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-e,operation:"fetchSimJsInfo"}),i}catch(t){return void pxt.debug(t.toString())}}async function k(t){var e,o,s;const n=Date.now();await E(t.id,t.code,t.dependencies);let r=!1;const a=pxt.appTarget.versions.target;let l=await v(!1,e=>{var o;if(e.computeUsedParts=!0,e.computeUsedSymbols=!0,t.debug&&(e.breakpoints=!0),t.assets){const i=JSON.parse(t.assets);for(const t of Object.keys(i)){const o=i[t];if(e.fileSystem[t]=o,e.sourceFiles.indexOf(t)<0&&e.sourceFiles.push(t),/\.jres$/.test(t)){const t=JSON.parse(o);e.jres=pxt.inflateJRes(t,e.jres)}}}if(t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code),e.target.preferredEditor===pxt.PYTHON_PROJECT_NAME){e.target.preferredEditor=pxt.JAVASCRIPT_PROJECT_NAME,e.ast=!0;const t=P(pxtc.compile(e).ast,e);e.apisInfo=t,e.target.preferredEditor=pxt.PYTHON_PROJECT_NAME}const s=null===(o=i.mainPkg.config.targetVersions)||void 0===o?void 0:o.target;if(s&&a&&pxt.semver.cmp(pxt.semver.parse(s),pxt.semver.parse(a))<0)for(const t of Object.keys(e.fileSystem))!pxt.Util.startsWith(t,"pxt_modules")&&pxt.Util.endsWith(t,".ts")&&(r=!0,e.fileSystem[t]=pxt.patching.patchJavaScript(s,e.fileSystem[t]))});(null===(e=l.diagnostics)||void 0===e?void 0:e.length)>0&&r&&(pxt.log("Compile with upgrade rules failed, trying again with original code"),l=await v(!1,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})),l.diagnostics&&l.diagnostics.length>0&&pxt.error("Diagnostics",l.diagnostics);const c=pxtc.buildSimJsInfo(l),h=(null===(s=null===(o=pxt.appTarget.simulator)||void 0===o?void 0:o.boardDefinition)||void 0===s?void 0:s.onboardComponents)||[];return c.allParts=l.usedParts||[],c.usedBuiltinParts=l.usedParts.filter(t=>-1!==h.indexOf(t)),c.parts=l.usedParts.filter(t=>-1===h.indexOf(t)),pxt.tickEvent("perfMeasurement",{durationMs:Date.now()-n,operation:"buildSimJsInfo"}),c}function A(t){let e={};try{let i=window.localStorage.getItem(t);i&&(e=JSON.parse(i))}catch(t){}return e}var S;function O(t,e){if(i.editorLanguageMode=t,e!=pxt.Util.localeInfo()){const t=/^live-/;return t.test(e)&&pxt.Util.enableLiveLocalizationUpdates(),pxt.Util.updateLocalizationAsync({targetId:pxt.appTarget.id,baseUrl:pxt.webConfig.commitCdnUrl,code:e.replace(t,"")})}return Promise.resolve()}function R(t){let e=t.data;if(e)switch(e.type){case"fileloaded":let t=e,i=t.name,o=S.Blocks;/\.ts$/i.test(i)?o=S.TypeScript:/\.py$/i.test(i)&&(o=S.Python),O(o,t.locale);break;case"popout":let s=/((\/v[0-9+])\/)?[^\/]*#(doc|md):([^&?:]+)/i.exec(window.location.href);if(s){const t=pxt.webConfig.docsUrl||"/--docs";let e=s[2]||"",i="doc"==s[3]?pxt.webConfig.isStatic?`/docs${s[4]}.html`:`${s[4]}`:`${t}?md=${s[4]}`;window.parent&&window.parent.postMessage({type:"opendoc",url:pxt.BrowserUtils.urlJoin(e,i)},"*")}break;case"localtoken":let n=e;n&&n.localToken&&(pxt.Cloud.localToken=n.localToken,U.forEach(t=>t()),U=[])}}function w(t,e){return pxt.Cloud.privateGetTextAsync(e+"/text").then(t=>JSON.parse(t)).then(i=>N(t,i,e))}function N(t,e,o=null,s=!1){const n=JSON.parse(e[pxt.CONFIG_NAME])||{};let r=`# ${n.name} ${n.version?n.version:""}\n\n`;const a="README.md";e[a]&&(r+=e[a].replace(/^#+/,"$0#")+"\n"),n.files.filter(t=>t!=pxt.CONFIG_NAME&&t!=a).filter(t=>function(t,e){switch(e){case S.Blocks:return/\.blocks?$/.test(t);case S.TypeScript:return/\.ts?$/.test(t);case S.Python:return/\.py?$/.test(t)}}(t,i.editorLanguageMode)).forEach(t=>{/^main\.(ts|blocks)$/.test(t)||(r+=`\n## ${t}\n`),/\.ts$/.test(t)?r+=`\`\`\`typescript\n${e[t]}\n\`\`\`\n`:/\.blocks?$/.test(t)?r+=`\`\`\`blocksxml\n${e[t]}\n\`\`\`\n`:r+=`\`\`\`${t.substr(t.indexOf("."))}\n${e[t]}\n\`\`\`\n`});const l=n&&n.dependencies&&Object.keys(n.dependencies).filter(t=>t!=pxt.appTarget.corepkg);if(l&&l.length&&(r+=`\n## ${lf("Extensions")} #extensions\n\n${l.map(t=>`* ${t}, ${n.dependencies[t]}`).join("\n")}\n\n\`\`\`package\n${l.map(t=>`${t}=${n.dependencies[t]}`).join("\n")}\n\`\`\`\n`),o){let t=(pxt.appTarget.appTheme.shareUrl||"https://makecode.com/")+o;s&&(t="`"+t+"`"),r+=`\n${t}\n\n`}pxt.debug(`print md: ${r}`);return x(t,r,{print:!0})}pxt.react.getTilemapProject||(pxt.react.getTilemapProject=()=>(h||(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg)),h)),i.initHost=T,i.initFooter=function(t,e){if(!t)return;let i=pxt.appTarget.appTheme,o=$("body"),s=$(t),n=$("<a/>").attr("href",i.homeUrl).attr("target","_blank");s.append(n),i.organizationLogo?n.append($("<img/>").attr("src",pxt.Util.toDataUri(i.organizationLogo))):n.append(lf("powered by {0}",i.title)),o.mouseenter(t=>s.fadeOut()),o.mouseleave(t=>s.fadeIn())},i.showError=b,i.generateHexFileAsync=function(t){return E(t.id).then(()=>v(!0,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})).then(t=>(t.diagnostics&&t.diagnostics.length>0&&pxt.error("Diagnostics",t.diagnostics),t.outfiles[pxtc.BINARY_HEX]))},i.generateVMFileAsync=function(t){return pxt.setHwVariant("vm"),E(t.id).then(()=>v(!0,e=>{t.code&&(e.fileSystem[pxt.MAIN_TS]=t.code)})).then(t=>(pxt.log(t),t))},i.simulateAsync=async function(t,e){var i,o;const s=e.builtJsInfo||await I(e)||await k(e),{js:n}=s;if(!n)return void pxt.error("Program failed to compile");const r=C(t,e,s);return d.options.messageSimulators=null===(o=null===(i=pxt.appTarget)||void 0===i?void 0:i.simulator)||void 0===o?void 0:o.messageSimulators,d.options.onSimulatorCommand=t=>{"restart"===t.command?(r.storedState=A(e.id),d.run(n,r)):"setstate"===t.command?t.stateKey&&function(t,e,i){let o=A(t);if(!t)return;null!=i?o[e]=i:delete o[e];try{window.localStorage.setItem(t,JSON.stringify(o))}catch(t){}}(e.id,t.stateKey,t.stateValue):"single"===t.command&&d.setSingleSimulator()},s.breakpoints&&e.debug&&d.setBreakpoints(s.breakpoints),d.run(n,r),s},i.preloadSim=function(t,e){var i,o;C(t,e),d.preload((null===(o=null===(i=pxt.appTarget)||void 0===i?void 0:i.simulator)||void 0===o?void 0:o.aspectRatio)||1,!0)},i.currentDriver=function(){return d},i.postSimMessage=function(t){null==d||d.postMessage(t)},i.fetchSimJsInfo=I,i.buildSimJsInfo=k,function(t){t[t.Blocks=0]="Blocks",t[t.TypeScript=1]="TypeScript",t[t.Python=2]="Python"}(S=i.LanguageMode||(i.LanguageMode={})),i.editorLanguageMode=S.Blocks,i.setEditorContextAsync=O,i.startRenderServer=function(){pxt.tickEvent("renderer.ready");const t=[];let e;function i(){if(e)return;const s=t.shift();if(!s)return;const n=s.options||{};n.splitSvg=!1,pxt.tickEvent("renderer.job");const r=/^\s*<xml/.test(s.code);e=(async()=>{const t=(r?await F(s.code,n):await B(s.code,s.options)).blocksSvg;if(!t)throw new Error("Failed to generate blocks SVG");const e=t.viewBox.baseVal.width,i=t.viewBox.baseVal.height;let a,l;try{a=await(0,o.blocklyToSvgAsync)(t,0,0,e,i)}catch(t){throw pxt.reportException(t),t}try{l=a?await pxt.BrowserUtils.encodeToPngAsync(a.xml,{width:e,height:i}):void 0}catch(t){pxt.warn(t)}window.parent.postMessage({source:"makecode",type:"renderblocks",id:s.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(t=>{window.parent.postMessage({source:"makecode",type:"renderblocks",id:s.id,error:t.message},"*")}).finally(()=>{e=void 0,i()})}(0,s.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",function(e){const o=e.data;"renderblocks"==o.type&&(t.push(o),i())},!1),window.parent.postMessage({source:"makecode",type:"renderready",versions:pxt.appTarget.versions},"*")})},i.startDocsServer=function(t,e,i){pxt.tickEvent("docrenderer.ready");const o=[];function r(o,s){pxt.debug(`rendering ${o}`),i&&$(i).hide(),$(e).hide(),$(t).show(),pxt.U.delay(100).then(()=>{switch(o){case"print":const t=window.localStorage.printjob;return delete window.localStorage.printjob,N(e,JSON.parse(t),void 0,!0).then(()=>pxsim.print(1e3));case"project":return N(e,JSON.parse(s)).then(()=>pxsim.print(1e3));case"projectid":return w(e,JSON.parse(s)).then(()=>pxsim.print(1e3));case"doc":return async function(t,e){e=e.replace(/^\//,"");const i=await pxt.Cloud.markdownAsync(e,void 0,!0);try{await x(t,i,{path:e})}catch(t){pxt.warn(t)}}(e,s);case"book":return function(t,e){e=e.replace(/^\//,""),pxt.tickEvent("book",{id:e}),pxt.log(`rendering book from ${e}`);let i;return $("#loading").find(".loader").addClass("text").text(lf("Compiling your book (this may take a minute)")),pxt.U.delay(100).then(()=>pxt.Cloud.markdownAsync(e,void 0,!0)).then(t=>{i=pxt.docs.buildTOC(t),pxt.log(`TOC: ${JSON.stringify(i,null,2)}`);const e=[];return pxt.docs.visitTOC(i,t=>{/^\//.test(t.path)&&!/^\/pkg\//.test(t.path)&&e.push(t)}),pxt.U.promisePoolAsync(4,e,async t=>{try{const e=await pxt.Cloud.markdownAsync(t.path,void 0,!0);t.markdown=e}catch(e){t.markdown=`_${t.path} failed to load._`}})}).then(e=>{let o=i[0].name;return pxt.docs.visitTOC(i,t=>{t.markdown&&(o+="\n\n"+t.markdown)}),x(t,o)})}(e,s);default:return x(e,s)}}).catch(t=>{$(e).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>`),$(e).find("#tryagain").click(()=>{r(o,s)}),window.parent&&window.parent.postMessage({type:"docfailed",docType:o,src:s},"*")}).finally(()=>{$(t).hide(),i&&$(i).show(),$(e).show()}).then(()=>{})}function a(t,e){e?(pxsim.U.addClass(t,"disabled"),t.setAttribute("aria-disabled","true")):(pxsim.U.removeClass(t,"disabled"),t.setAttribute("aria-disabled","false"))}async function l(){let t=/^#(doc|md|tutorial|book|project|projectid|print):([^&?:]+)(:([^&?:]+):([^&?:]+))?/i.exec(window.location.hash);if(t){if(i&&(o.push(window.location.hash),o.length>10&&o.shift(),o.length>1&&a(i,!1)),t[4]){let e=S.TypeScript;/^blocks$/i.test(t[4])?e=S.Blocks:/^python$/i.test(t[4])&&(e=S.Python),await O(e,t[5])}r(t[1],decodeURIComponent(t[2]))}}i&&(i.addEventListener("click",()=>{!function(){if(!i)return;o.length>1&&(o.pop(),window.location.hash=o.pop());o.length<=1&&a(i,!0)}()}),i.addEventListener("keydown",n.fireClickOnEnter),a(i,!0)),(0,s.initEditorExtensionsAsync)().then(()=>{window.addEventListener("message",R,!1),window.addEventListener("hashchange",()=>{l()},!1),parent.postMessage({type:"sidedocready"},"*"),setTimeout(()=>l(),1)})},i.renderProjectAsync=w,i.renderProjectFilesAsync=N;const L='\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 x(t,e,o={}){const s=pxt.docs.renderMarkdown({template:L,markdown:e,theme:pxt.appTarget.appTheme});let r=o.blocksAspectRatio||window.innerHeight<window.innerWidth?1.62:1/1.62;$(t).html(s),$(t).find("a").attr("target","_blank");const a=(0,n.defaultClientRenderOptions)();return a.tutorial=!!o.tutorial,a.blocksAspectRatio=r||a.blocksAspectRatio,a.showJavaScript=i.editorLanguageMode==S.TypeScript,o.print&&(a.showEdit=!1,a.simulator=!1),(0,n.renderAsync)(a).then(()=>{$(t).find('a[href^="/"]').removeAttr("target").each((t,e)=>{$(e).attr("href","#doc:"+$(e).attr("href").replace(/^\//,""))}),$(t).find(".ui.embed").embed()})}let D,M;function B(t,e){const{assets:s,forceCompilation:n,snippetMode:r,generateSourceMap:a}=e||{};return E(e&&e.packageId?"pub:"+e.packageId:e&&e.package?"docs:"+e.package:null,t).then(()=>y(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(l=>{if(t&&(l.fileSystem[pxt.MAIN_TS]=t),l.ast=!0,s)for(const t of Object.keys(s))l.sourceFiles.indexOf(t)<0&&l.sourceFiles.push(t),l.fileSystem[t]=s[t];let c,u,d;n?(c=pxtc.compile(l),u=c&&c.ast):u=pxtc.getTSProgram(l,D),D=u,pxt.appTarget.appTheme.python&&(d=ts.pxtc.transpile.tsToPy(u,pxt.MAIN_TS));let p=P(u,l);return ts.pxtc.localizeApisAsync(p,i.mainPkg).then(()=>{let t=pxtc.getBlocksInfo(p);(0,o.initializeAndInject)(t);const n=null==s?void 0:s[pxt.TILEMAP_JRES],l=null==s?void 0:s[pxt.IMAGES_JRES];(n||l)&&(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg),n&&h.loadTilemapJRes(JSON.parse(n),!0),l&&h.loadAssetsJRes(JSON.parse(l)));let g=pxtc.decompiler.decompileToBlocks(t,u.getSourceFile(pxt.MAIN_TS),{snippetMode:r,generateSourceMap:a});if(g.diagnostics&&g.diagnostics.length>0&&g.diagnostics.forEach(t=>pxt.error(t.messageText)),!g.success)return{package:i.mainPkg,compileProgram:u,compileJS:c,compileBlocks:g,apiInfo:p};pxt.debug(g.outfiles[pxt.MAIN_BLOCKS]);const m=(0,o.render)(g.outfiles[pxt.MAIN_BLOCKS],e);return(n||l)&&(h=null),{package:i.mainPkg,compileProgram:u,compileJS:c,compileBlocks:g,compilePython:d,apiInfo:p,blocksSvg:m}})})}function P(t,e){M||(M={});const i=Object.keys(e.fileSystem).sort().join(";");return M[i]||(M[i]=pxtc.getApiInfo(t,e.jres)),M[i]}function F(t,e){const{assets:s}=e||{};return E(e&&e.packageId?"pub:"+e.packageId:e&&e.package?"docs:"+e.package:null,"").then(()=>y(!!pxt.appTarget.compile&&pxt.appTarget.compile.hasHex)).then(n=>{if(n.ast=!0,s)for(const t of Object.keys(s))n.sourceFiles.indexOf(t)<0&&n.sourceFiles.push(t),n.fileSystem[t]=s[t];const r=P(pxtc.compile(n).ast,n);return ts.pxtc.localizeApisAsync(r,i.mainPkg).then(()=>{const n=pxtc.getBlocksInfo(r);(0,o.initializeAndInject)(n);const a=null==s?void 0:s[pxt.TILEMAP_JRES],l=null==s?void 0:s[pxt.IMAGES_JRES];(a||l)&&(h=new pxt.TilemapProject,h.loadPackage(i.mainPkg),a&&h.loadTilemapJRes(JSON.parse(a),!0),l&&h.loadAssetsJRes(JSON.parse(l)));const c=(0,o.render)(t,e);return(a||l)&&(h=null),{package:i.mainPkg,blocksSvg:c,apiInfo:r}})})}i.renderMarkdownAsync=x,i.decompileSnippetAsync=B,i.compileBlocksAsync=F;let U=[];let H=[];i.setInitCallbacks=function(t){H=t},i.init=function(){f().then(()=>{for(let t=0;t<H.length;++t)H[t]()})}},{"../pxtblocks":76,"../pxteditor/editor":167,"./renderer":183,blockly:192}],185:[function(t,e,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.IFrameEmbeddedClient=void 0;i.IFrameEmbeddedClient=class{constructor(t){this.messageHandler=t,this.onMessageReceived=t=>{const e=t.data;if(e){if("iframeclientsetmessageport"===e.type)return this.port=t.ports[0],this.port.onmessage=this.onMessageReceived,void this.postMessage({type:"iframeclientsetmessageport"});if("iframeclientready"===e.type)return void this.sendReadyMessage()}this.messageHandler(t)},this.frameId=function(){const t=/frameid=([a-zA-Z0-9\-]+)/i.exec(window.location.href);if(t)return t[1];return}(),window.addEventListener("message",this.onMessageReceived),this.sendReadyMessage()}dispose(){window.removeEventListener("message",this.onMessageReceived),this.port&&this.port.close()}postMessage(t){this.postMessageCore(t)}postMessageCore(t){this.frameId&&(t.frameId=this.frameId),this.port?this.port.postMessage(t):window.acquireVsCodeApi?window.acquireVsCodeApi().postMessage(t):window.parent&&window.parent!==window&&window.parent.postMessage(t,"*")}sendReadyMessage(){this.postMessage({type:"iframeclientready"})}}},{}],186:[function(t,e,i){
|
|
7
7
|
/*! For license information please see index.js.LICENSE.txt */
|
|
8
8
|
!function(o,s){if("object"==typeof i&&"object"==typeof e)e.exports=s(t("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],s);else{var n=s("object"==typeof i?t("blockly/core"):o.Blockly);for(var r in n)("object"==typeof i?i:o)[r]=n[r]}}(this,t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},i={};function o(t){var s=i[t];if(void 0!==s)return s.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};o.r(s),o.d(s,{FieldGridDropdown:()=>l});var n=o(370);class r{constructor(t,e,i,o){this.value=i,this.selected=!1,this.selectionCallback=o,this.element=document.createElement("button"),this.element.id=n.utils.idGenerator.getNextUniqueId(),this.element.className="blocklyFieldGridItem",this.clickHandler=n.browserEvents.conditionalBind(this.element,"click",this,this.onClick,!0),t.appendChild(this.element);const s="string"==typeof e?document.createTextNode(e):e;this.element.appendChild(s),n.utils.aria.setRole(this.element,n.utils.aria.Role.GRIDCELL)}dispose(){this.selectionCallback=null,this.element.remove(),this.clickHandler&&(n.browserEvents.unbind(this.clickHandler),this.clickHandler=null)}getId(){return this.element.id}getValue(){return this.value}isSelected(){return this.selected}setSelected(t){this.selected=t,n.utils.aria.setState(this.element,n.utils.aria.State.SELECTED,this.selected),this.element.classList.toggle("blocklyFieldGridItemSelected",this.selected),this.isSelected()&&this.focus()}onClick(){var t;this.setSelected(!0),null===(t=this.selectionCallback)||void 0===t||t.call(this,this)}focus(){this.element.focus({preventScroll:!0});const t=this.element.offsetParent;if(!t)return;const e=this.element.offsetTop,i=t.scrollTop,o=this.getInterItemSpacing();e<i?t.scrollTo(0,e-o):e+this.element.offsetHeight>i+t.clientHeight&&t.scrollBy(0,e+this.element.clientHeight-(i+t.clientHeight)+o)}getInterItemSpacing(){const t=this.element.closest(".blocklyFieldGrid");if(!t)return 0;const e=[...t.querySelectorAll(".blocklyFieldGridItem")];if(!e.length)return 0;const i=e[0].offsetTop,o=e[0].offsetHeight;for(const t of e)if(t.offsetTop!==i)return t.offsetTop-o-i;return 0}}class a{constructor(t,e,i,o,s){if(this.columns=i,this.rtl=o,this.itemIndices=new Map,this.items=new Array,this.keyDownHandler=null,this.pointerMoveHandler=null,this.selectionCallback=s,this.root=document.createElement("div"),this.root.className="blocklyFieldGrid",this.root.tabIndex=0,n.utils.aria.setRole(this.root,n.utils.aria.Role.GRID),t.appendChild(this.root),this.populateItems(e),this.keyDownHandler=n.browserEvents.conditionalBind(this.root,"keydown",this,this.onKeyDown),this.pointerMoveHandler=n.browserEvents.conditionalBind(this.root,"pointermove",this,this.onPointerMove,!0),!(i>=1))throw new Error(`Number of columns must be >= 1; got ${i}`);this.columns=i,this.root.style.setProperty("--grid-columns",`${this.columns}`)}populateItems(t){let e=document.createElement("div");for(const[i,o]of t.entries()){if(o===n.FieldDropdown.SEPARATOR)continue;i%this.columns===0&&(e=document.createElement("div"),e.className="blocklyFieldGridRow",n.utils.aria.setRole(e,n.utils.aria.Role.ROW),this.root.appendChild(e));const[t,s]=o,a=(()=>{if((e=t)&&"object"==typeof e&&"src"in e&&"string"==typeof e.src&&"alt"in e&&"string"==typeof e.alt&&"width"in e&&"number"==typeof e.width&&"height"in e&&"number"==typeof e.height){const e=new Image(t.width,t.height);return e.src=t.src,e.alt=t.alt||"",e}var e;return t})(),l=new r(e,a,s,t=>{var e;this.setSelectedValue(t.getValue()),null===(e=this.selectionCallback)||void 0===e||e.call(this,t)});this.itemIndices.set(l.getId(),this.itemIndices.size),this.items.push(l)}}dispose(){this.selectionCallback=void 0;for(const t of this.items)t.dispose();this.itemIndices.clear(),this.items.length=0,this.keyDownHandler&&(n.browserEvents.unbind(this.keyDownHandler),this.keyDownHandler=null),this.pointerMoveHandler&&(n.browserEvents.unbind(this.pointerMoveHandler),this.pointerMoveHandler=null),this.root.remove()}onKeyDown(t){if(!(!this.items.length||t.shiftKey||t.ctrlKey||t.metaKey||t.altKey)){switch(t.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 t.stopPropagation();default:return}t.preventDefault(),t.stopPropagation()}}onPointerMove(t){if(!t.movementX&&!t.movementY||!(t.target instanceof Element))return;const e=t.target.closest(".blocklyFieldGridItem");if(!e)return;const i=e.id,o=this.itemIndices.get(i);void 0!==o&&this.moveFocus(o,!1)}setSelectedValue(t){for(const[e,i]of this.items.entries()){const o=i.getValue()===t;i.setSelected(o),o&&this.moveFocus(e,!1)}}moveFocus(t,e){let i=t;if(e){const t=this.getFocusedItem();if(!t)return;i+=this.indexOfItem(t)}const o=this.itemAtIndex(i);o&&(o.focus(),n.utils.aria.setState(this.root,n.utils.aria.State.ACTIVEDESCENDANT,o.getId()))}indexOfItem(t){var e;return null!==(e=this.itemIndices.get(t.getId()))&&void 0!==e?e:-1}itemAtIndex(t){return this.items[t]}getFocusedItem(){var t;const e=null!==(t=this.root.querySelector(".blocklyFieldGridItem:focus"))&&void 0!==t?t:this.root.querySelector(".blocklyFieldGridItem");if(!e||!e.id)return;const i=this.itemIndices.get(e.id);return void 0!==i?this.itemAtIndex(i):void 0}}class l extends n.FieldDropdown{constructor(t,e,i){super(t,e,i),this.columns=3,(null==i?void 0:i.columns)&&this.setColumns(parseInt(`${i.columns}`)),i&&i.primaryColour&&(this.primaryColour=i.primaryColour),i&&i.borderColour&&(this.borderColour=i.borderColour)}static fromJson(t){if(!t.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(t.options,void 0,t)}setColumns(t){var e;!isNaN(t)&&t>=1&&(this.columns=t,n.DropDownDiv.getOwner()===this&&n.DropDownDiv.isVisible()&&(null===(e=this.grid)||void 0===e||e.dispose(),this.showEditor_()))}showEditor_(t){var e;n.DropDownDiv.clearContent();const i=!!(null===(e=this.getSourceBlock())||void 0===e?void 0:e.workspace.RTL);this.grid=new a(n.DropDownDiv.getContentDiv(),this.getOptions(!1),this.columns,i,t=>{n.DropDownDiv.hideIfOwner(this),this.setValue(t.getValue())}),n.DropDownDiv.getContentDiv().classList.add("blocklyFieldGridContainer");const o=this.getColours();o&&o.border&&n.DropDownDiv.setColour(o.primary,o.border),n.DropDownDiv.showPositionedByField(this,this.dropdownDispose_.bind(this));const s=this.getValue();s&&this.grid.setSelectedValue(s)}doValueUpdate_(t){var e;super.doValueUpdate_(t),null===(e=this.grid)||void 0===e||e.setSelectedValue(t)}getColours(){var t,e;if(this.primaryColour&&this.borderColour)return{primary:this.primaryColour,border:this.borderColour};const i=this.getSourceBlock();if(!(i instanceof n.BlockSvg))return;const o=i.isShadow()?i.getParent():i;return o?{primary:null!==(t=this.primaryColour)&&void 0!==t?t:o.getColour(),border:null!==(e=this.borderColour)&&void 0!==e?e:o.getColourTertiary()}:void 0}}return n.fieldRegistry.register("field_grid_dropdown",l),n.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 "),s})())},{"blockly/core":191}],187:[function(t,e,i){
|
|
9
9
|
/*! For license information please see index.js.LICENSE.txt */
|