Files
mixly3/common/blockly-core/plugins/lexical_variables.js
2024-07-19 10:16:00 +08:00

2 lines
44 KiB
JavaScript

/*! For license information please see index.js.LICENSE.txt */
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],t);else{var r="object"==typeof exports?t(require("blockly/core")):t(e.Blockly);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={573:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{FieldFlydown:()=>w,FieldGlobalFlydown:()=>B,FieldLexicalVariable:()=>g,FieldNoCheckDropdown:()=>W,FieldParameterFlydown:()=>z,FieldProcedureName:()=>Q,Flydown:()=>k,LexicalVariable:()=>R,init:()=>ee});var e={};o.r(e),o.d(e,{checkDropDownContainsValidValue:()=>s,checkErrors:()=>i,checkIsInDefinition:()=>a});var t=o(573),r=o.n(t);r().Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT="initialize global",r().Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME="name",r().Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO="to",r().Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT="global",r().Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP="Creates a global variable and gives it the value of the attached blocks.",r().Msg.LANG_VARIABLES_GLOBAL_PREFIX="global",r().Msg.LANG_VARIABLES_GET_TITLE_GET="get",r().Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT="get",r().Msg.LANG_VARIABLES_GET_TOOLTIP="Returns the value of this variable.",r().Msg.LANG_VARIABLES_SET_TITLE_SET="set",r().Msg.LANG_VARIABLES_SET_TITLE_TO="to",r().Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT="set",r().Msg.LANG_VARIABLES_SET_TOOLTIP="Sets this variable to be equal to the input.",r().Msg.LANG_VARIABLES_VARIABLE=" variable",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT="initialize local",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME="name",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO="to",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO="in",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT="local",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP="Allows you to create variables that are only accessible in the do part of this block.",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME="initialize local in do",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN="in",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT="local",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP="Allows you to create variables that are only accessible in the return part of this block.",r().Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME="initialize local in return",r().Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES="local names",r().Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP="",r().Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME="name",r().Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE="x",r().Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE="to",r().Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE="procedure",r().Msg.LANG_PROCEDURES_DEFNORETURN_DO="do",r().Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX="to ",r().Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP="A procedure that does not return a value.",r().Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN="result",r().Msg.LANG_PROCEDURES_DOTHENRETURN_DO="do",r().Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN="result",r().Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP="Runs the blocks in 'do' and returns a statement. Useful if you need to run a procedure before returning a value to a variable.",r().Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT="do/result",r().Msg.LANG_PROCEDURES_DEFRETURN_DEFINE="to",r().Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE="procedure",r().Msg.LANG_PROCEDURES_DEFRETURN_RETURN="result",r().Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX="to ",r().Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP="A procedure returning a result value.",r().Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING="Warning:\nThis procedure has\nduplicate inputs.",r().Msg.LANG_PROCEDURES_CALLNORETURN_CALL="call ",r().Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE="procedure",r().Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX="call ",r().Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP="Call a procedure with no return value.",r().Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME="call no return",r().Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX="call ",r().Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP="Call a procedure with a return value.",r().Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME="call return",r().Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE="inputs",r().Msg.LANG_PROCEDURES_MUTATORARG_TITLE="input:",r().Msg.LANG_PROCEDURES_HIGHLIGHT_DEF="Highlight Procedure",r().Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP="",r().Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP="",r().Msg.LANG_CONTROLS_FOR_INPUT_WITH="count with",r().Msg.LANG_CONTROLS_FOR_INPUT_VAR="x",r().Msg.LANG_CONTROLS_FOR_INPUT_FROM="from",r().Msg.LANG_CONTROLS_FOR_INPUT_TO="to",r().Msg.LANG_CONTROLS_FOR_INPUT_DO="do",r().Msg.LANG_CONTROLS_FOR_TOOLTIP="Count from a start number to an end number.\nFor each count, set the current count number to\nvariable '%1', and then do some statements.",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM="for each",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR="number",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_START="from",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_END="to",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP="by",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_DO="do",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT="for number in range",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX="for",r().Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX=" in range",r().Msg.LANG_CONTROLS_FORRANGE_TOOLTIP="Runs the blocks in the 'do' section for each numeric value in the range from start to end, stepping the value each time. Use the given variable name to refer to the current value.",r().Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM="for each",r().Msg.LANG_CONTROLS_FOREACH_INPUT_VAR="item",r().Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST="in list",r().Msg.LANG_CONTROLS_FOREACH_INPUT_DO="do",r().Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT="for item in list",r().Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX="for ",r().Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX=" in list",r().Msg.LANG_CONTROLS_FOREACH_TOOLTIP="Runs the blocks in the 'do' section for each item in the list. Use the given variable name to refer to the current list item.",r().Msg.LANG_CONTROLS_FOREACH_DICT_INPUT="for each %1 with %2 in dictionary %3",r().Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_DO="do",r().Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_KEY="key",r().Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_VALUE="value",r().Msg.LANG_CONTROLS_FOREACH_DICT_TITLE="for each in dictionary",r().Msg.LANG_CONTROLS_FOREACH_DICT_TOOLTIP="Runs the blocks in the 'do' section for each key-value entry in the dictionary. Use the given variable names to refer to the key/value of the current dictionary item.",r().Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN="Select a valid item in the drop down.",r().Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINITION="This block cannot be in a definition",r().Msg.HORIZONTAL_PARAMETERS="Arrange Parameters Horizontally",r().Msg.VERTICAL_PARAMETERS="Arrange Parameters Vertically",r().Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO="do",r().Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN="result",r().Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP="Runs the blocks in 'do' and returns a statement. Useful if you need to run a procedure before returning a value to a variable.",r().Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT="do/result",r().Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE="do result";var i=function(e){if(!e.getSvgRoot()||e.readOnly)return e.hasWarning&&(e.hasWarning=!1),void(e.hasError&&(e.hasError=!1));e.errors||(e.errors=[]),e.warnings||(e.warnings=[]);for(var t=e.errors,r=e.warnings,o=0;o<t.length;o++)if(t[o].func&&t[o].func.call(this,e,t[o]))return e.hasError||(e.hasError=!0),void(e.hasWarning&&(e.hasWarning=!1));e.hasError&&(e.hasError=!1);for(var n=0;n<r.length;n++)if(r[n].func&&r[n].func.call(this,e,r[n]))return void(e.hasWarning||(e.hasWarning=!0));e.warning&&e.setWarningText(null),e.hasWarning&&(e.hasWarning=!1)},a=function(e){if("global_declaration"===e.getRootBlock().type){var t=r().Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINITION;return e.setWarningText(t),!0}return!1},s=function(e,t){if(e.workspace.isDragging())return!1;for(var o=0;o<t.dropDowns.length;o++){var n=e.getField(t.dropDowns[o]),i=n.menuGenerator_(),a=n.getText(),s=n.getValue(),l=!1;n.updateMutation&&n.updateMutation();for(var c=0;c<i.length;c++)if(i[c][1]===s&&" "!==s){l=!0,i[c][0]!==a&&n.setValue(i[c][0]);break}if(!l){var u=r().Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN;return e.setWarningText(u),!0}}return!1},l="global",c=" ",u=function(e){return r().Msg.LANG_VARIABLES_GLOBAL_PREFIX+c+e};function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,n=function(e,t){if("object"!==f(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,"string");if("object"!==f(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===f(n)?n:String(n)),o)}var n}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(o){var n=Object.getOwnPropertyDescriptor(o,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},d.apply(this,arguments)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}var g=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(s,e);var t,o,n,i,a=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=y(n);if(i){var r=y(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),t=a.call(this,s.dropdownCreate,s.dropdownChange),e?t.doValueUpdate_(e):t.doValueUpdate_(r().Variables.generateUniqueName()),t}return t=s,(o=[{key:"setValue",value:function(e){if(e&&" "!==e){var t=e.split(" ");2==t.length&&"global"!==t[0]&&(e="global "+t[1])}d(y(s.prototype),"setValue",this).call(this,e)}}])&&_(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),s}(r().FieldDropdown);g.prototype.doClassValidation_=function(e){return e},g.prototype.getBlock=function(){return this.block_},g.prototype.setBlock=function(e){this.block_=e},g.getGlobalNames=function(e){if(r().common.getMainWorkspace()&&r().common.getMainWorkspace().getWarningHandler&&r().common.getMainWorkspace().getWarningHandler().cacheGlobalNames)return r().common.getMainWorkspace().getWarningHandler().cachedGlobalNames;var t,o=[];if(r().common.getMainWorkspace()){var n;n=r().common.getMainWorkspace().getTopBlocks();for(var i=0;i<n.length;i++){var a=n[i];a.getGlobalNames&&a!=e&&o.push.apply(o,function(e){if(Array.isArray(e))return p(e)}(t=a.getGlobalNames())||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}return o},g.prototype.getNamesInScope=function(){return g.getNamesInScope(this.block_)},g.getNamesInScope=function(e){var t=g.getGlobalNames();t=(t=R.sortAndRemoveDuplicates(t)).map((function(e){return[u(e),"global "+e]}));var r=g.getLexicalNamesInScope(e);return t.concat(r)},g.getLexicalNamesInScope=function(e){var t,r,o=[],n={};function i(e,t,r){var o;n[e]||(n[e]=r),o=(n[e],function(e){return""+e})(e),t.push(o)}if((r=e)&&(t=r.getParent()))for(;t;)t.withLexicalVarsAndPrefix&&t.withLexicalVarsAndPrefix(r,(function(e,t){i(e,o,t)})),r=t,t=t.getParent();return(o=R.sortAndRemoveDuplicates(o)).map((function(e){return[e,e]}))},g.dropdownCreate=function(){var e=this.getNamesInScope();return 0==e.length?[[" "," "]]:e},g.prototype.doValueUpdate_=function(e){Object.getPrototypeOf(r().FieldDropdown).prototype.doValueUpdate_.call(this,e);for(var t,o,n=this.getOptions(!0,[[(t=e,t.startsWith("global ")?t.replace("global ",r().Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "):t),e]]),i=0;o=n[i];i++)if(o[1]==this.value_){this.selectedOption_=o;break}this.forceRerender()},g.prototype.getOptions=function(e,t){Array.isArray(e)&&(t=e);var r=t||[];return this.isOptionListDynamic()?(this.generatedOptions_&&e||(this.generatedOptions_=this.menuGenerator_.call(this).concat(r),O(this.generatedOptions_)),this.generatedOptions_.concat(r)):this.menuGenerator_};var O=function(e){if(!Array.isArray(e))throw TypeError("FieldDropdown options must be an array.");if(!e.length)throw TypeError("FieldDropdown options must not be an empty array.");for(var t=!1,r=0;r<e.length;++r){var o=e[r];Array.isArray(o)?"string"!=typeof o[1]?(t=!0,console.error("Invalid option["+r+"]: Each FieldDropdown option id must be a string. Found "+o[1]+" in: ",o)):o[0]&&"string"!=typeof o[0]&&"string"!=typeof o[0].src&&(t=!0,console.error("Invalid option["+r+"]: Each FieldDropdown option must have a string label or image description. Found"+o[0]+" in: ",o)):(t=!0,console.error("Invalid option["+r+"]: Each FieldDropdown option must be an array. Found: ",o))}if(t)throw TypeError("Found invalid FieldDropdown options.")};g.dropdownChange=function(e){if(e){this.doValueUpdate_(e);var t=this.sourceBlock_.workspace.getTopWorkspace();t.getWarningHandler&&t.getWarningHandler().checkErrors(this.sourceBlock_)}},g.nameNotIn=function(e,t){for(var r=g.prefixSuffix(e),o=r[0],n=r[1],i=!1,a=!1,s=[],l=0;l<t.length;l++){var c=g.prefixSuffix(t[l]),u=c[0],f=c[1];u===o&&(f===n&&(a=!0),""===f?i=!0:s.push(f))}if(a){if(i){var p=s.map((function(e,t,r){return parseInt(e,10)}));p.sort((function(e,t){return e-t}));for(var _=2,d=0;d<p.length;){if(_<p[d])return o+_;_==p[d]?(_++,d++):d++}return o+_}return o}return e},g.prefixSuffix=function(e){var t=e.match(/^(.*?)(\d+)$/);return t?[t[1],t[2]]:[e,""]},g.fromJson=function(e){var t=r().utils.replaceMessageReferences(e.name);return new g(t)},r().fieldRegistry.register("field_lexical_variable",g);var R={renameGlobal:function(e){var t=this.value_;e=R.makeLegalIdentifier(e),this.sourceBlock_.getField("NAME").doValueUpdate_(e);var o=g.getGlobalNames(this.sourceBlock_);if(e=g.nameNotIn(e,o),this.sourceBlock_.rendered&&r().common.getMainWorkspace())for(var n=r().common.getMainWorkspace().getAllBlocks(),i=0;i<n.length;i++){var a=n[i],s=a.renameLexicalVar;s&&s.call(a,l+c+t,l+c+e,r().Msg.LANG_VARIABLES_GLOBAL_PREFIX+c+t,r().Msg.LANG_VARIABLES_GLOBAL_PREFIX+c+e)}return e},renameParam:function(e){var t=this.htmlInput_,r=this.getValue()||t&&t.defaultValue||this.getText();return e=R.makeLegalIdentifier(e),R.renameParamFromTo(this.sourceBlock_,r,e,!1)},renameParamFromTo:function(e,t,r,o){return e.mustNotRenameCapturables?R.renameParamWithoutRenamingCapturables(e,t,r,[]):o?(R.renameParamRenamingCapturables(e,t,r),r):R.renameParamWithoutRenamingCapturables(e,t,r,[])},renameParamRenamingCapturables:function(e,t,o){if(o!==t){var n=e.declaredNames?e.declaredNames():[];if(-1==n.indexOf(t))throw Error("LexicalVariable.renamingCapturables: oldName "+t+" is not in declarations {"+n.join(",")+"}");var i=[];g.getNamesInScope(e).map((function(e){e[0]==e[1]?i.push(e[0]):i.push(e[0],e[1])}));var a=n.concat(i);if(-1!=a.indexOf(o))throw Error("LexicalVariable.renameParamRenamingCapturables: newName "+o+" is in existing declarations {"+a.join(",")+"}");if(!e.renameBound)throw Error("LexicalVariable.renameParamRenamingCapturables: block "+e.type+" is not a declaration block.");var s=r().Substitution.simpleSubstitution(t,o),l=new(r().Substitution);e.renameBound(s,l)}},renameFree:function(e,t){e&&(e.renameFree?e.renameFree(t):e.getChildren().map((function(e){R.renameFree(e,t)})))},freeVariables:function(e){var t=[];if(e)if(e.freeVariables)t=e.freeVariables();else{var o=e.getChildren().map((function(e){return R.freeVariables(e)}));t=r().NameSet.unionAll(o)}else t=new(r().NameSet);return t},renameParamWithoutRenamingCapturables:function(e,t,r,o){if(t===r)return t;!e.declaredNames||e.declaredNames();var n=R.renameParamWithoutRenamingCapturablesInfo(e,t,""),i=n[0],a=n[1],s=[];if(e.declaredNames){var l=(s=e.declaredNames()).indexOf(t);if(-1!=l&&s.splice(l,1),-1!=o.indexOf(r)){var c=s.indexOf(r);-1!=c&&s.splice(c,1)}}var u=R.sortAndRemoveDuplicates(a.concat(s));if((r=g.nameNotIn(r,u))!==t&&-1==s.indexOf(t))for(var f=0;f<i.length;f++){var p=i[f],_=p.renameLexicalVar;_&&_.call(p,""+t,function(e){return""+e}(r))}return r},renameParamWithoutRenamingCapturablesInfo:function(e,t,r){var o=[];e.blocksInScope&&(o=e.blocksInScope());for(var n=o.map((function(e){return R.referenceResult(e,t,r,[])})),i=[],a=[],s=0;s<n.length;s++)i=i.concat(n[s][0]),a=a.concat(n[s][1]);return[i,a=R.sortAndRemoveDuplicates(a)]},checkIdentifier:function(e){var t=e.trim().replace(/[\s\xa0]+/g,"_"),r=new RegExp("^[^-0-9!&%^/>=<`'\"#:;,\\\\*+.()|{}[\\] ][^-!&%^/>=<'\"#:;,\\\\*+.()|{}[\\] ]*$");return{isLegal:0==t.search(r),transformed:t}},makeLegalIdentifier:function(e){var t=R.checkIdentifier(e);return t.isLegal?t.transformed:""===t.transformed?"_":"name"},referenceResult:function(e,t,r,o){if(!e)return[[],[]];for(var n=e.referenceResults?e.referenceResults(t,r,o):e.getChildren().map((function(e){return R.referenceResult(e,t,r,o)})),i=[],a=[],s=0;s<n.length;s++)i=i.concat(n[s][0]),a=a.concat(n[s][1]);return[i,a]},sortAndRemoveDuplicates:function(e){var t=e.sort(),r=[];if(e.length>=1){var o=t[0];r.push(o);for(var n=1;n<t.length;n++)t[n]!==o&&(o=t[n],r.push(o))}return r},getNextTargetBlock:function(e){return e&&e.nextConnection&&e.nextConnection.targetBlock()?e.nextConnection.targetBlock():null},stringListsEqual:function(e,t){var r=e.length;if(r!==t.length)return!1;for(var o=0;o<r;o++)if(e[o]!==t[o])return!1;return!0}},b=["",""],A=function(e,t){for(var o=(t||r().common.getMainWorkspace()).getTopBlocks(),n=[b],i=0;i<o.length;i++){var a=o[i].getFieldValue("NAME");"procedures_defnoreturn"!=o[i].type||e?"procedures_defreturn"==o[i].type&&e&&n.push([a,a]):n.push([a,a])}return n.length>1&&n.splice(0,1),n},E=function(e){var t=this.oldName_||this.getValue(),r=e;e=R.makeLegalIdentifier(e);var o=function(e){for(var t=e.workspace.getTopBlocks(!1),r=[],o=0;o<t.length;o++)"procedures_defnoreturn"!==t[o].type&&"procedures_defreturn"!==t[o].type||t[o]!==e&&r.push(t[o]);return r}(this.sourceBlock_).map((function(e){return e.getFieldValue("NAME")}));(e=g.nameNotIn(e,o))!==r&&this.doValueUpdate_(e);for(var n=this.sourceBlock_.workspace.getAllBlocks(),i=0;i<n.length;i++){var a=n[i].renameProcedure;a&&a.call(n[i],t,e)}return this.oldName_=e,e},m=function(e){this.workspace_=e,this.procedures_={},this.returnProcedures_={},this.voidProcedures_={},this.length=0,this.returnProcedures=0,this.voidProcedures=0};function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function v(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,C(o.key),o)}}function T(){return T="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=P(e)););return e}(e,t);if(o){var n=Object.getOwnPropertyDescriptor(o,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},T.apply(this,arguments)}function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},N(e,t)}function P(e){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(e)}function S(e,t,r){return(t=C(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function C(e){var t=function(e,t){if("object"!==L(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,"string");if("object"!==L(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===L(t)?t:String(t)}m.defaultValue=["","none"],m.prototype.getNames=function(e){return A(e,this.workspace_).map((function(e){return e[0]}))},m.prototype.getMenuItems=function(e){return A(e,this.workspace_)},m.prototype.getDeclarationBlocks=function(e){return r().utils.object.values(e?this.returnProcedures_:this.voidProcedures_)},m.prototype.getDeclarationsBlocksExcept=function(e){var t=[];return r().utils.values(this.procedures_).forEach((function(r){r!==e&&t.push(r)})),t},m.prototype.getAllDeclarationNames=function(){return r().utils.values(this.procedures_).map((function(e){return e.getFieldValue("NAME")}))},m.prototype.addProcedure=function(e,t){if("procedures_defnoreturn"!=t.type&&"procedures_defreturn"!=t.type)return console.warn("Attempt to addProcedure with block type "+t.type),!1;var r=t.id;return!(r in this.procedures_)&&(this.procedures_[r]=t,this.length++,"procedures_defnoreturn"==t.type?(this.voidProcedures_[r]=t,this.voidProcedures++):(this.returnProcedures_[r]=t,this.returnProcedures++),!0)},m.prototype.removeProcedure=function(e){return e in this.procedures_&&("procedures_defnoreturn"==this.procedures_[e].type?(delete this.voidProcedures_[e],this.voidProcedures--):(delete this.returnProcedures_[e],this.returnProcedures--),delete this.procedures_[e],this.length--),!0},m.prototype.renameProcedure=function(e,t,r){},m.prototype.getProcedure=function(e){return this.procedures_[e]||this.getProcedureByName(e)},m.prototype.getProcedureByName=function(e){for(var t in this.procedures_)if(this.procedures_[t].getFieldValue("NAME")===e)return this.procedures_[t]},m.prototype.clear=function(){this.procedures_={},this.returnProcedures_={},this.voidProcedures_={},this.length=0,this.returnProcedures=0,this.voidProcedures=0},r().WorkspaceSvg.prototype.flydown_=null,r().WorkspaceSvg.prototype.getFlydown=function(){return this.flydown_},r().WorkspaceSvg.prototype.getProcedureDatabase=function(){return this.procedureDb_||(this.procedureDb_=new m(this)),this.procedureDb_},r().WorkspaceSvg.prototype.getTopWorkspace=function(){for(var e=this;e.targetWorkspace;)e=e.targetWorkspace;return e},r().WorkspaceSvg.prototype.getWarningHandler=function(){return e};var w=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&N(e,t)}(s,e);var t,o,n,i,a=(n=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=P(n);if(i){var r=P(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===L(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function s(e,t,r,o){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(n=a.call(this,e,o)).EDITABLE=t,n.displayLocation=r||s.DISPLAY_RIGHT,n}return t=s,(o=[{key:"showEditor_",value:function(){this.EDITABLE&&(s.showPid_&&(clearTimeout(s.showPid_),s.showPid_=0,r().common.getMainWorkspace().hideChaff()),T(P(s.prototype),"showEditor_",this).call(this))}},{key:"init",value:function(e){T(P(s.prototype),"init",this).call(this,e),r().utils.dom.removeClass(this.fieldGroup_,"blocklyEditableText"),r().utils.dom.removeClass(this.fieldGroup_,"blocklyNoNEditableText"),r().utils.dom.addClass(this.fieldGroup_,this.fieldCSSClassName),this.mouseOverWrapper_=r().browserEvents.bind(this.fieldGroup_,"mouseover",this,this.onMouseOver_),this.mouseOutWrapper_=r().browserEvents.bind(this.fieldGroup_,"mouseout",this,this.onMouseOut_)}}])&&v(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),s}(r().FieldTextInput);function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function M(e,t){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},M(e,t)}function D(e){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},D(e)}S(w,"timeout",500),S(w,"showPid_",0),S(w,"openFieldFlydown_",null),S(w,"DISPLAY_BELOW","BELOW"),S(w,"DISPLAY_RIGHT","RIGHT"),S(w,"DISPLAY_LOCATION",w.DISPLAY_BELOW),w.prototype.fieldCSSClassName="blocklyFieldFlydownField",w.prototype.flyoutCSSClassName="blocklyFieldFlydownFlydown",w.prototype.onMouseOver_=function(e){this.sourceBlock_.isInFlyout||0!=w.showPid_||(w.showPid_=window.setTimeout(this.showFlydownMaker_(),w.timeout)),e.stopPropagation()},w.prototype.onMouseOut_=function(e){window.clearTimeout(w.showPid_),w.showPid_=0,e.stopPropagation()},w.prototype.showFlydownMaker_=function(){var e=this;return function(){if(0!==w.showPid_&&!e.getSourceBlock().workspace.isDragging()&&!this.htmlInput_)try{e.showFlydown_()}catch(e){console.error("Failed to show flydown",e)}w.showPid_=0}},w.prototype.showFlydown_=function(){r().common.getMainWorkspace().hideChaff();var e=r().common.getMainWorkspace().getFlydown();r().common.getMainWorkspace().getParentSvg().appendChild(e.svgGroup_);var t=e.targetWorkspace.scale;e.workspace_.setScale(t),e.setCSSClass(this.flyoutCSSClassName);var o,n=this.flydownBlocksXML_(),i=void 0!==(o=r().Xml.textToDom(n)).children?o.children:Array.prototype.filter.call(o.childNodes,(function(e){return e.nodeType==r().utils.dom.NodeType.ELEMENT_NODE})),a=r().common.getMainWorkspace().getSvgXY(this.borderRect_),s=this.borderRect_.getBBox();this.displayLocation===w.DISPLAY_BELOW?a.y+=s.height*t:a.x+=s.width*t,e.field_=this,e.showAt(i,a.x,a.y),w.openFieldFlydown_=this},w.hide=function(){window.clearTimeout(w.showPid_);var e=r().common.getMainWorkspace().getFlydown();e&&e.hide()},w.prototype.onHtmlInputChange_=function(e){var t=this.htmlInput_,o=t.value;if(o!==t.oldValue_){t.oldValue_=o;var n=!0;this.sourceBlock_&&(n=function(e,t){var r=e.doClassValidation_(t);if(null===r)return null;void 0!==r&&(t=r);var o=e.getValidator();if(o){var n=o.call(e,t);if(null===n)return null;void 0!==n&&(t=n)}return t}(this,t.value)),null===n?r().utils.dom.addClass(t,"blocklyInvalidInput"):(r().utils.dom.removeClass(t,"blocklyInvalidInput"),this.doValueUpdate_(n))}else r().utils.userAgent.WEBKIT&&this.sourceBlock_.render();this.textContent_.nodeValue=o,this.forceRerender(),this.resizeEditor_(),r().svgResize(this.sourceBlock_.workspace)},w.prototype.dispose=function(){w.openFieldFlydown_==this&&w.hide(),r().FieldTextInput.prototype.dispose.call(this)},w.fromJson=function(e){var t=r().utils.replaceMessageReferences(e.name);return new w(t,e.is_editable)},r().fieldRegistry.register("field_flydown",w);var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&M(e,t)}(i,e);var t,r,o,n=(r=i,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=D(r);if(o){var n=D(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===I(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=n.call(this,e)).dragAngleRange_=360,t}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(r().VerticalFlyout);function G(e){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G(e)}function F(e,t){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},F(e,t)}function U(e){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},U(e)}k.prototype.previousCSSClassName_="",k.prototype.VERTICAL_SEPARATION_FACTOR=1,k.prototype.createDom=function(e){return this.previousCSSClassName_=e,this.svgGroup_=r().utils.dom.createSvgElement("g",{class:e},null),this.svgBackground_=r().utils.dom.createSvgElement("path",{},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.svgGroup_},k.prototype.setCSSClass=function(e){e!==this.previousCSSClassName_&&(r().utils.dom.removeClass(this.svgGroup_,this.previousCSSClassName_),r().utils.dom.addClass(this.svgGroup_,e),this.previousCSSClassName_=e)},k.prototype.init=function(e){r().Flyout.prototype.init.call(this,e,!1),this.workspace_.setTheme(e.getTheme()),e.getComponentManager().addCapability(this.id,r().ComponentManager.Capability.AUTOHIDEABLE)},k.prototype.position=function(){},k.prototype.showAt=function(e,t,o){r().Events.disable();try{this.show(e)}finally{r().Events.enable()}var n=this.CORNER_RADIUS*this.workspace_.scale,i=this.width_-2*n,a=this.height_-2*n,s=["M 0,"+n];s.push("a",n,n,0,0,1,n,-n),s.push("h",i),s.push("a",n,n,0,0,1,n,n),s.push("v",a),s.push("a",n,n,0,0,1,-n,n),s.push("h",-i),s.push("a",n,n,0,0,1,-n,-n),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" ")),this.svgGroup_.setAttribute("transform","translate("+t+", "+o+")")},k.prototype.reflow=function(){this.workspace_.scale=this.targetWorkspace.scale;for(var e,t=this.workspace_.scale,r=0,o=0,n=this.CORNER_RADIUS*t,i=this.workspace_.getTopBlocks(!1),a=0;e=i[a];a++){var s=e.getHeightWidth();r=Math.max(r,s.width*t),o+=s.height*t}r+=2*n+this.tabWidth_*t;var l=this.workspace_.getRenderer().getConstants(),c=l.ADD_START_HATS?l.START_HAT_HEIGHT:0;if(o+=3*n+n*this.VERTICAL_SEPARATION_FACTOR*i.length+c*t/2,this.width_!=r){for(var u,f=0;u=i[f];f++){var p=u.getHeightWidth(),_=u.getRelativeToSurfaceXY();if(this.RTL){var d=r-n-t*(this.tabWidth_-_.x);u.moveBy(d,0),_.x+=d}u.flyoutRect_&&(u.flyoutRect_.setAttribute("width",p.width),u.flyoutRect_.setAttribute("height",p.height),u.flyoutRect_.setAttribute("x",this.RTL?_.x-p.width:_.x),u.flyoutRect_.setAttribute("y",_.y))}this.width_=r,this.height_=o}},k.prototype.onMouseMove_=function(e){},k.prototype.placeNewBlock_=function(e){var t=this.targetWorkspace,o=e.getSvgRoot();if(!o)throw Error("originBlock is not rendered.");var n=this.workspace_.scale,i=this.workspace_.getSvgXY(o),a=i.x;i.x+=a/t.scale-a;var s=i.y;n=t.scale,i.y+=s/n-s;var l=r().Xml.blockToDom(e),c=r().Xml.domToBlock(l,t),u=c.getSvgRoot();if(!u)throw Error("block is not rendered.");var f=t.getSvgXY(u);return f.x+=t.scrollX/t.scale-t.scrollX,f.y+=t.scrollY/t.scale-t.scrollY,t.toolbox_&&!t.scrollbar&&(f.x+=t.toolbox_.getWidth()/t.scale,f.y+=t.toolbox_.getHeight()/t.scale),c.moveBy(i.x-f.x,i.y-f.y),c},k.prototype.shouldHide=!0,k.prototype.hide=function(){this.shouldHide&&(r().Flyout.prototype.hide.call(this),w.openFieldFlydown_=null),this.shouldHide=!0},k.prototype.autoHide=function(){this.hide()};var B=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&F(e,t)}(i,e);var t,r,o,n=(r=i,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=U(r);if(o){var n=U(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===G(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function i(e,t){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),n.call(this,e,!0,t,R.renameGlobal)}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(w);function x(e){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},x(e)}function j(e,t){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j(e,t)}function V(e){return V=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},V(e)}B.prototype.fieldCSSClassName="blocklyFieldParameter",B.prototype.flyoutCSSClassName="blocklyFieldParameterFlydown",B.prototype.flydownBlocksXML_=function(){var e=r().Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+this.getText();return'<xml><block type="lexical_variable_get"><title name="VAR">'+e+'</title></block><block type="lexical_variable_set"><title name="VAR">'+e+"</title></block></xml>"},B.fromJson=function(e){var t=r().utils.replaceMessageReferences(e.name);return new B(t)},r().fieldRegistry.register("field_global_flydown",B);var W=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&j(e,t)}(i,e);var t,r,o,n=(r=i,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=V(r);if(o){var n=V(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===x(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function i(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i);for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.call.apply(n,[this].concat(t))}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(r().FieldDropdown);function H(e){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(e)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},X(e,t)}function Y(e){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Y(e)}W.prototype.doClassValidation_=function(e){for(var t,r=!1,o=this.getOptions(!0),n=0;t=o[n];n++)if(t[1]===e){r=!0;break}return r||this.generatedOptions_.push([e,e]),e},W.fromJson=function(e){return new W(e.options,void 0,e)},r().fieldRegistry.register("field_nocheck_dropdown",W);var z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}(i,e);var t,r,o,n=(r=i,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Y(r);if(o){var n=Y(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===H(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function i(e,t,r,o){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),n.call(this,e,t,r,(function(e){if(!i.changeHandlerEnabled)return e;var t=R.renameParam.call(this,e);return o&&o.call(this,t),t}))}return t=i,Object.defineProperty(t,"prototype",{writable:!1}),t}(w);function J(e){return J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},J(e)}function q(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,n=function(e,t){if("object"!==J(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,"string");if("object"!==J(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===J(n)?n:String(n)),o)}var n}function K(){return K="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Z(e)););return e}(e,t);if(o){var n=Object.getOwnPropertyDescriptor(o,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},K.apply(this,arguments)}function $(e,t){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},$(e,t)}function Z(e){return Z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Z(e)}z.prototype.fieldCSSClassName="blocklyFieldParameter",z.prototype.flyoutCSSClassName="blocklyFieldParameterFlydown",z.changeHandlerEnabled=!0,z.withChangeHanderDisabled=function(e){var t=z.changeHandlerEnabled;z.changeHandlerEnabled=!1;try{e()}finally{z.changeHandlerEnabled=t}},z.prototype.flydownBlocksXML_=function(){var e=this.getText();return'<xml><block type="lexical_variable_get"><field name="VAR">'+e+'</field></block><block type="lexical_variable_set"><field name="VAR">'+e+"</field></block></xml>"},z.addHorizontalVerticalOption=function(e,t){var o=0;if(e.getParameters&&(o=e.getParameters().length),!(e.isCollapsed()||o<=0)){for(var n,i={enabled:!0,text:e.horizontalParameters?r().Msg.VERTICAL_PARAMETERS:r().Msg.HORIZONTAL_PARAMETERS,callback:function(){e.setParameterOrientation(!e.horizontalParameters)}},a=0;(n=t[a])&&n.text!=r().Msg.COLLAPSE_BLOCK;a++);t.splice(a,0,i);for(var s,l=0;s=t[l];l++)if(s.text==r().Msg.INLINE_INPUTS){t.splice(l,1);break}}},z.fromJson=function(e){var t=r().utils.replaceMessageReferences(e.name);return new z(t,e.is_editable)},r().fieldRegistry.register("field_parameter_flydown",z);var Q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$(e,t)}(a,e);var t,r,o,n,i=(o=a,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Z(o);if(n){var r=Z(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===J(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function a(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),i.call(this,e,E)}return t=a,(r=[{key:"setValue",value:function(e){var t=this.getValue();if(this.oldName_=t,this.doValueUpdate_(e),K(Z(a.prototype),"setValue",this).call(this,e),"string"==typeof(e=this.getValue())&&this.sourceBlock_){var r=this.sourceBlock_.workspace.getProcedureDatabase();r&&(r.getProcedure(this.sourceBlock_.id)?r.renameProcedure(this.sourceBlock_.id,t,e):r.addProcedure(e,this.sourceBlock_))}this.oldName_=void 0}}])&&q(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(r().FieldTextInput);function ee(e){var t=new k(new(r().Options)({scrollbars:!1,rtl:e.RTL,renderer:e.options.renderer,rendererOverrides:e.options.rendererOverrides}));e.flydown_=t,r().utils.dom.insertAfter(t.createDom("g"),e.svgBubbleCanvas_),t.init(e),t.autoClose=!0}Q.fromJson=function(e){var t=r().utils.replaceMessageReferences(e.name);return new Q(t)},r().fieldRegistry.register("field_procedurename",Q),r().Css.register(["\n .blocklyFieldParameter>rect {\n fill: rgb(222, 143, 108);\n fill-opacity: 1.0;\n stroke-width: 2;\n stroke: rgb(231, 175, 150);\n }\n .blocklyFieldParameter>text {\n stroke-width: 1;\n fill: #000;\n }\n .blocklyFieldParameter:hover>rect {\n stroke-width: 2;\n stroke: rgb(231,175,150);\n fill: rgb(231,175,150);\n fill-opacity: 1.0;\n }\n /*\n * [lyn, 10/08/13] Control flydown with the getter/setter blocks.\n */\n .blocklyFieldParameterFlydown {\n fill: rgb(231,175,150);\n fill-opacity: 0.8;\n }\n /*\n * [lyn, 10/08/13] Control parameter fields with flydown procedure\n * caller block.\n */\n .blocklyFieldProcedure>rect {\n fill: rgb(215,203,218);\n fill-opacity: 1.0;\n stroke-width: 0;\n stroke: #000;\n }\n .blocklyFieldProcedure>text {\n fill: #000;\n }\n .blocklyFieldProcedure:hover>rect {\n stroke-width: 2;\n stroke: #fff;\n fill: rgb(215,203,218);\n fill-opacity: 1.0;\n }\n /*\n * [lyn, 10/08/13] Control flydown with the procedure caller block.\n */\n .blocklyFieldProcedureFlydown {\n fill: rgb(215,203,218);\n fill-opacity: 0.8;\n }\n"])})(),n})()));