/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@code-dot-org/blockly@4.1.0/dist/blockly.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var $jscomp=$jscomp||{};$jscomp.scope={},$jscomp.checkStringArgs=function(e,t,o){if(null==e)throw new TypeError("The 'this' value for String.prototype."+o+" must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype."+o+" must not be a regular expression");return e+""},$jscomp.ASSUME_ES5=!1,$jscomp.ASSUME_NO_NATIVE_MAP=!1,$jscomp.ASSUME_NO_NATIVE_SET=!1,$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,o){e!=Array.prototype&&e!=Object.prototype&&(e[t]=o.value)},$jscomp.getGlobal=function(e){return"undefined"!=typeof window&&window===e?e:"undefined"!=typeof global&&null!=global?global:e},$jscomp.global=$jscomp.getGlobal(this),$jscomp.polyfill=function(e,t,o,n){if(t){for(o=$jscomp.global,e=e.split("."),n=0;n<e.length-1;n++){var i=e[n];i in o||(o[i]={}),o=o[i]}(t=t(n=o[e=e[e.length-1]]))!=n&&null!=t&&$jscomp.defineProperty(o,e,{configurable:!0,writable:!0,value:t})}},$jscomp.polyfill("String.prototype.repeat",function(e){return e||function(e){var t=$jscomp.checkStringArgs(this,null,"repeat");if(0>e||1342177279<e)throw new RangeError("Invalid count value");e|=0;for(var o="";e;)1&e&&(o+=t),(e>>>=1)&&(t+=t);return o}},"es6","es3"),$jscomp.findInternal=function(e,t,o){e instanceof String&&(e=String(e));for(var n=e.length,i=0;i<n;i++){var r=e[i];if(t.call(o,r,i,e))return{i:i,v:r}}return{i:-1,v:void 0}},$jscomp.polyfill("Array.prototype.findIndex",function(e){return e||function(e,t){return $jscomp.findInternal(this,e,t).i}},"es6","es3"),$jscomp.polyfill("Array.prototype.find",function(e){return e||function(e,t){return $jscomp.findInternal(this,e,t).v}},"es6","es3"),$jscomp.SYMBOL_PREFIX="jscomp_symbol_",$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){},$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)},$jscomp.Symbol=function(){var e=0;return function(t){return $jscomp.SYMBOL_PREFIX+(t||"")+e++}}(),$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var e=$jscomp.global.Symbol.iterator;e||(e=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator")),"function"!=typeof Array.prototype[e]&&$jscomp.defineProperty(Array.prototype,e,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}}),$jscomp.initSymbolIterator=function(){}},$jscomp.arrayIterator=function(e){var t=0;return $jscomp.iteratorPrototype(function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}})},$jscomp.iteratorPrototype=function(e){return $jscomp.initSymbolIterator(),(e={next:e})[$jscomp.global.Symbol.iterator]=function(){return this},e},$jscomp.iteratorFromArray=function(e,t){$jscomp.initSymbolIterator(),e instanceof String&&(e+="");var o=0,n={next:function(){if(o<e.length){var i=o++;return{value:t(i,e[i]),done:!1}}return n.next=function(){return{done:!0,value:void 0}},n.next()}};return n[Symbol.iterator]=function(){return n},n},$jscomp.polyfill("Array.prototype.keys",function(e){return e||function(){return $jscomp.iteratorFromArray(this,function(e){return e})}},"es6","es3"),$jscomp.polyfill("String.prototype.endsWith",function(e){return e||function(e,t){var o=$jscomp.checkStringArgs(this,e,"endsWith");e+="",void 0===t&&(t=o.length),t=Math.max(0,Math.min(0|t,o.length));for(var n=e.length;0<n&&0<t;)if(o[--t]!=e[--n])return!1;return 0>=n}},"es6","es3"),$jscomp.polyfill("String.prototype.startsWith",function(e){return e||function(e,t){var o=$jscomp.checkStringArgs(this,e,"startsWith");e+="";var n=o.length,i=e.length;t=Math.max(0,Math.min(0|t,o.length));for(var r=0;r<i&&t<n;)if(o[t++]!=e[r++])return!1;return r>=i}},"es6","es3"),$jscomp.polyfill("Array.prototype.values",function(e){return e||function(){return $jscomp.iteratorFromArray(this,function(e,t){return t})}},"es8","es3");var COMPILED=!0,goog=goog||{};goog.global=this,goog.isDef=function(e){return void 0!==e},goog.exportPath_=function(e,t,o){e=e.split("."),o=o||goog.global,e[0]in o||!o.execScript||o.execScript("var "+e[0]);for(var n;e.length&&(n=e.shift());)!e.length&&goog.isDef(t)?o[n]=t:o=o[n]?o[n]:o[n]={}},goog.define=function(e,t){COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,e)?t=goog.global.CLOSURE_UNCOMPILED_DEFINES[e]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,e)&&(t=goog.global.CLOSURE_DEFINES[e])),goog.exportPath_(e,t)},goog.DEBUG=!0,goog.LOCALE="en",goog.TRUSTED_SITE=!0,goog.STRICT_MODE_COMPATIBLE=!1,goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG,goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1,goog.provide=function(e){if(goog.isInModuleLoader_())throw Error("goog.provide can not be used within a goog.module.");if(!COMPILED&&goog.isProvided_(e))throw Error('Namespace "'+e+'" already declared.');goog.constructNamespace_(e)},goog.constructNamespace_=function(e,t){if(!COMPILED){delete goog.implicitNamespaces_[e];for(var o=e;(o=o.substring(0,o.lastIndexOf(".")))&&!goog.getObjectByName(o);)goog.implicitNamespaces_[o]=!0}goog.exportPath_(e,t)},goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/,goog.module=function(e){if(!goog.isString(e)||!e||-1==e.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+e+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");if(goog.moduleLoaderState_.moduleName=e,!COMPILED){if(goog.isProvided_(e))throw Error('Namespace "'+e+'" already declared.');delete goog.implicitNamespaces_[e]}},goog.module.get=function(e){return goog.module.getInternal_(e)},goog.module.getInternal_=function(e){if(!COMPILED){if(e in goog.loadedModules_)return goog.loadedModules_[e];if(!goog.implicitNamespaces_[e])return null!=(e=goog.getObjectByName(e))?e:null}return null},goog.moduleLoaderState_=null,goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_},goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0},goog.setTestOnly=function(e){if(goog.DISALLOW_TEST_ONLY_CODE)throw e=e||"",Error("Importing test-only code into non-debug environment"+(e?": "+e:"."))},goog.forwardDeclare=function(e){},COMPILED||(goog.isProvided_=function(e){return e in goog.loadedModules_||!goog.implicitNamespaces_[e]&&goog.isDefAndNotNull(goog.getObjectByName(e))},goog.implicitNamespaces_={"goog.module":!0}),goog.getObjectByName=function(e,t){e=e.split("."),t=t||goog.global;for(var o;o=e.shift();){if(!goog.isDefAndNotNull(t[o]))return null;t=t[o]}return t},goog.globalize=function(e,t){for(var o in t=t||goog.global,e)t[o]=e[o]},goog.addDependency=function(e,t,o,n){if(goog.DEPENDENCIES_ENABLED){var i;e=e.replace(/\\/g,"/");var r=goog.dependencies_;n&&"boolean"!=typeof n||(n=n?{module:"goog"}:{});for(var l=0;i=t[l];l++)r.nameToPath[i]=e,r.loadFlags[e]=n;for(n=0;t=o[n];n++)e in r.requires||(r.requires[e]={}),r.requires[e][t]=!0}},goog.ENABLE_DEBUG_LOADER=!0,goog.logToConsole_=function(e){goog.global.console&&goog.global.console.error(e)},goog.require=function(e){if(!COMPILED){if(goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_&&goog.maybeProcessDeferredDep_(e),goog.isProvided_(e)){if(goog.isInModuleLoader_())return goog.module.getInternal_(e)}else if(goog.ENABLE_DEBUG_LOADER){var t=goog.getPathFromDeps_(e);if(!t)throw e="goog.require could not find: "+e,goog.logToConsole_(e),Error(e);goog.writeScripts_(t)}return null}},goog.basePath="",goog.nullFunction=function(){},goog.abstractMethod=function(){throw Error("unimplemented abstract method")},goog.addSingletonGetter=function(e){e.instance_=void 0,e.getInstance=function(){return e.instance_?e.instance_:(goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=e),e.instance_=new e)}},goog.instantiatedSingletons_=[],goog.LOAD_MODULE_USING_EVAL=!0,goog.SEAL_MODULE_EXPORTS=goog.DEBUG,goog.loadedModules_={},goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER,goog.TRANSPILE="detect",goog.TRANSPILER="transpile.js",goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={loadFlags:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var e=goog.global.document;return null!=e&&"write"in e},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var e=goog.global.document.getElementsByTagName("SCRIPT"),t=e.length-1;0<=t;--t){var o=e[t].src,n=o.lastIndexOf("?");if(n=-1==n?o.length:n,"base.js"==o.substr(n-7,7)){goog.basePath=o.substr(0,n-7);break}}},goog.importScript_=function(e,t){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(e,t)&&(goog.dependencies_.written[e]=!0)},goog.IS_OLD_IE_=!(goog.global.atob||!goog.global.document||!goog.global.document.all),goog.importProcessedScript_=function(e,t,o){goog.importScript_("",'goog.retrieveAndExec_("'+e+'", '+t+", "+o+");")},goog.queuedModules_=[],goog.wrapModule_=function(e,t){return goog.LOAD_MODULE_USING_EVAL&&goog.isDef(goog.global.JSON)?"goog.loadModule("+goog.global.JSON.stringify(t+"\n//# sourceURL="+e+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+t+"\n;return exports});\n//# sourceURL="+e+"\n"},goog.loadQueuedModules_=function(){var e=goog.queuedModules_.length;if(0<e){var t=goog.queuedModules_;goog.queuedModules_=[];for(var o=0;o<e;o++)goog.maybeProcessDeferredPath_(t[o])}},goog.maybeProcessDeferredDep_=function(e){goog.isDeferredModule_(e)&&goog.allDepsAreAvailable_(e)&&(e=goog.getPathFromDeps_(e),goog.maybeProcessDeferredPath_(goog.basePath+e))},goog.isDeferredModule_=function(e){var t=(e=goog.getPathFromDeps_(e))&&goog.dependencies_.loadFlags[e]||{},o=t.lang||"es3";return!(!e||"goog"!=t.module&&!goog.needsTranspile_(o))&&goog.basePath+e in goog.dependencies_.deferred},goog.allDepsAreAvailable_=function(e){if((e=goog.getPathFromDeps_(e))&&e in goog.dependencies_.requires)for(var t in goog.dependencies_.requires[e])if(!goog.isProvided_(t)&&!goog.isDeferredModule_(t))return!1;return!0},goog.maybeProcessDeferredPath_=function(e){if(e in goog.dependencies_.deferred){var t=goog.dependencies_.deferred[e];delete goog.dependencies_.deferred[e],goog.globalEval(t)}},goog.loadModuleFromUrl=function(e){goog.retrieveAndExec_(e,!0,!1)},goog.writeScriptSrcNode_=function(e){goog.global.document.write('<script type="text/javascript" src="'+e+'"><\/script>')},goog.appendScriptSrcNode_=function(e){var t=goog.global.document,o=t.createElement("script");o.type="text/javascript",o.src=e,o.defer=!1,o.async=!1,t.head.appendChild(o)},goog.writeScriptTag_=function(e,t){if(goog.inHtmlDocument_()){var o=goog.global.document;if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&"complete"==o.readyState){if(/\bdeps.js$/.test(e))return!1;throw Error('Cannot write "'+e+'" after document load')}return void 0===t?goog.IS_OLD_IE_?(t=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ",o.write('<script type="text/javascript" src="'+e+'"'+t+"><\/script>")):goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING?goog.appendScriptSrcNode_(e):goog.writeScriptSrcNode_(e):o.write('<script type="text/javascript">'+goog.protectScriptTag_(t)+"<\/script>"),!0}return!1},goog.protectScriptTag_=function(e){return e.replace(/<\/(SCRIPT)/gi,"\\x3c\\$1")},goog.needsTranspile_=function(e){if("always"==goog.TRANSPILE)return!0;if("never"==goog.TRANSPILE)return!1;if(goog.requiresTranspilation_||(goog.requiresTranspilation_=goog.createRequiresTranspilation_()),e in goog.requiresTranspilation_)return goog.requiresTranspilation_[e];throw Error("Unknown language mode: "+e)},goog.requiresTranspilation_=null,goog.lastNonModuleScriptIndex_=0,goog.onScriptLoad_=function(e,t){return"complete"==e.readyState&&goog.lastNonModuleScriptIndex_==t&&goog.loadQueuedModules_(),!0},goog.writeScripts_=function(e){var t=[],o={},n=goog.dependencies_;for(function e(i){if(!(i in n.written||i in n.visited)){if(n.visited[i]=!0,i in n.requires)for(var r in n.requires[i])if(!goog.isProvided_(r)){if(!(r in n.nameToPath))throw Error("Undefined nameToPath for "+r);e(n.nameToPath[r])}i in o||(o[i]=!0,t.push(i))}}(e),e=0;e<t.length;e++){var i=t[e];goog.dependencies_.written[i]=!0}var r=goog.moduleLoaderState_;for(goog.moduleLoaderState_=null,e=0;e<t.length;e++){if(!(i=t[e]))throw goog.moduleLoaderState_=r,Error("Undefined script input");var l=n.loadFlags[i]||{},s=goog.needsTranspile_(l.lang||"es3");"goog"==l.module||s?goog.importProcessedScript_(goog.basePath+i,"goog"==l.module,s):goog.importScript_(goog.basePath+i)}goog.moduleLoaderState_=r},goog.getPathFromDeps_=function(e){return e in goog.dependencies_.nameToPath?goog.dependencies_.nameToPath[e]:null},goog.findBasePath_(),goog.global.CLOSURE_NO_DEPS||goog.importScript_(goog.basePath+"deps.js")),goog.loadModule=function(e){var t=goog.moduleLoaderState_;try{if(goog.moduleLoaderState_={moduleName:void 0,declareLegacyNamespace:!1},goog.isFunction(e))var o=e.call(void 0,{});else{if(!goog.isString(e))throw Error("Invalid module definition");o=goog.loadModuleFromSource_.call(void 0,e)}var n=goog.moduleLoaderState_.moduleName;if(!goog.isString(n)||!n)throw Error('Invalid module name "'+n+'"');goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(n,o):goog.SEAL_MODULE_EXPORTS&&Object.seal&&goog.isObject(o)&&Object.seal(o),goog.loadedModules_[n]=o}finally{goog.moduleLoaderState_=t}},goog.loadModuleFromSource_=function(a){return eval(a),{}},goog.normalizePath_=function(e){e=e.split("/");for(var t=0;t<e.length;)"."==e[t]?e.splice(t,1):t&&".."==e[t]&&e[t-1]&&".."!=e[t-1]?e.splice(--t,2):t++;return e.join("/")},goog.loadFileSync_=function(e){if(goog.global.CLOSURE_LOAD_FILE_SYNC)return goog.global.CLOSURE_LOAD_FILE_SYNC(e);try{var t=new goog.global.XMLHttpRequest;return t.open("get",e,!1),t.send(),0==t.status||200==t.status?t.responseText:null}catch(e){return null}},goog.retrieveAndExec_=function(e,t,o){if(!COMPILED){var n=e;e=goog.normalizePath_(e);var i=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_,r=goog.loadFileSync_(e);if(null==r)throw Error('Load of "'+e+'" failed');o&&(r=goog.transpile_.call(goog.global,r,e)),r=t?goog.wrapModule_(e,r):r+"\n//# sourceURL="+e,goog.IS_OLD_IE_?(goog.dependencies_.deferred[n]=r,goog.queuedModules_.push(n)):i(e,r)}},goog.transpile_=function(a,b){var c=goog.global.$jscomp;c||(goog.global.$jscomp=c={});var d=c.transpile;if(!d){var e=goog.basePath+goog.TRANSPILER,f=goog.loadFileSync_(e);if(f){if(eval(f+"\n//# sourceURL="+e),goog.global.$gwtExport&&goog.global.$gwtExport.$jscomp&&!goog.global.$gwtExport.$jscomp.transpile)throw Error('The transpiler did not properly export the "transpile" method. $gwtExport: '+JSON.stringify(goog.global.$gwtExport));goog.global.$jscomp.transpile=goog.global.$gwtExport.$jscomp.transpile,c=goog.global.$jscomp,d=c.transpile}}return d||(d=c.transpile=function(e,t){return goog.logToConsole_(t+" requires transpilation but no transpiler was found."),e}),d(a,b)},goog.typeOf=function(e){var t=typeof e;if("object"==t){if(!e)return"null";if(e instanceof Array)return"array";if(e instanceof Object)return t;var o=Object.prototype.toString.call(e);if("[object Window]"==o)return"object";if("[object Array]"==o||"number"==typeof e.length&&void 0!==e.splice&&void 0!==e.propertyIsEnumerable&&!e.propertyIsEnumerable("splice"))return"array";if("[object Function]"==o||void 0!==e.call&&void 0!==e.propertyIsEnumerable&&!e.propertyIsEnumerable("call"))return"function"}else if("function"==t&&void 0===e.call)return"object";return t},goog.isNull=function(e){return null===e},goog.isDefAndNotNull=function(e){return null!=e},goog.isArray=function(e){return"array"==goog.typeOf(e)},goog.isArrayLike=function(e){var t=goog.typeOf(e);return"array"==t||"object"==t&&"number"==typeof e.length},goog.isDateLike=function(e){return goog.isObject(e)&&"function"==typeof e.getFullYear},goog.isString=function(e){return"string"==typeof e},goog.isBoolean=function(e){return"boolean"==typeof e},goog.isNumber=function(e){return"number"==typeof e},goog.isFunction=function(e){return"function"==goog.typeOf(e)},goog.isObject=function(e){var t=typeof e;return"object"==t&&null!=e||"function"==t},goog.getUid=function(e){return e[goog.UID_PROPERTY_]||(e[goog.UID_PROPERTY_]=++goog.uidCounter_)},goog.hasUid=function(e){return!!e[goog.UID_PROPERTY_]},goog.removeUid=function(e){null!==e&&"removeAttribute"in e&&e.removeAttribute(goog.UID_PROPERTY_);try{delete e[goog.UID_PROPERTY_]}catch(e){}},goog.UID_PROPERTY_="closure_uid_"+(1e9*Math.random()>>>0),goog.uidCounter_=0,goog.getHashCode=goog.getUid,goog.removeHashCode=goog.removeUid,goog.cloneObject=function(e){var t=goog.typeOf(e);if("object"==t||"array"==t){if(e.clone)return e.clone();for(var o in t="array"==t?[]:{},e)t[o]=goog.cloneObject(e[o]);return t}return e},goog.bindNative_=function(e,t,o){return e.call.apply(e.bind,arguments)},goog.bindJs_=function(e,t,o){if(!e)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var o=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(o,n),e.apply(t,o)}}return function(){return e.apply(t,arguments)}},goog.bind=function(e,t,o){return Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_,goog.bind.apply(null,arguments)},goog.partial=function(e,t){var o=Array.prototype.slice.call(arguments,1);return function(){var t=o.slice();return t.push.apply(t,arguments),e.apply(this,t)}},goog.mixin=function(e,t){for(var o in t)e[o]=t[o]},goog.now=goog.TRUSTED_SITE&&Date.now||function(){return+new Date},goog.globalEval=function(e){if(goog.global.execScript)goog.global.execScript(e,"JavaScript");else{if(!goog.global.eval)throw Error("goog.globalEval not available");if(null==goog.evalWorksForGlobals_)if(goog.global.eval("var _evalTest_ = 1;"),void 0!==goog.global._evalTest_){try{delete goog.global._evalTest_}catch(e){}goog.evalWorksForGlobals_=!0}else goog.evalWorksForGlobals_=!1;if(goog.evalWorksForGlobals_)goog.global.eval(e);else{var t=goog.global.document,o=t.createElement("SCRIPT");o.type="text/javascript",o.defer=!1,o.appendChild(t.createTextNode(e)),t.body.appendChild(o),t.body.removeChild(o)}}},goog.evalWorksForGlobals_=null,goog.getCssName=function(e,t){if("."==String(e).charAt(0))throw Error('className passed in goog.getCssName must not start with ".". You passed: '+e);var o=function(e){return goog.cssNameMapping_[e]||e},n=function(e){e=e.split("-");for(var t=[],n=0;n<e.length;n++)t.push(o(e[n]));return t.join("-")};return n=goog.cssNameMapping_?"BY_WHOLE"==goog.cssNameMappingStyle_?o:n:function(e){return e},e=t?e+"-"+n(t):n(e),goog.global.CLOSURE_CSS_NAME_MAP_FN?goog.global.CLOSURE_CSS_NAME_MAP_FN(e):e},goog.setCssNameMapping=function(e,t){goog.cssNameMapping_=e,goog.cssNameMappingStyle_=t},!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING),goog.getMsg=function(e,t){return t&&(e=e.replace(/\{\$([^}]+)}/g,function(e,o){return null!=t&&o in t?t[o]:e})),e},goog.getMsgWithFallback=function(e,t){return e},goog.exportSymbol=function(e,t,o){goog.exportPath_(e,t,o)},goog.exportProperty=function(e,t,o){e[t]=o},goog.inherits=function(e,t){function o(){}o.prototype=t.prototype,e.superClass_=t.prototype,e.prototype=new o,e.prototype.constructor=e,e.base=function(e,o,n){for(var i=Array(arguments.length-2),r=2;r<arguments.length;r++)i[r-2]=arguments[r];return t.prototype[o].apply(e,i)}},goog.base=function(e,t,o){var n=arguments.callee.caller;if(goog.STRICT_MODE_COMPATIBLE||goog.DEBUG&&!n)throw Error("arguments.caller not defined.  goog.base() cannot be used with strict mode code. See http://www.ecma-international.org/ecma-262/5.1/#sec-C");if(n.superClass_){for(var i=Array(arguments.length-1),r=1;r<arguments.length;r++)i[r-1]=arguments[r];return n.superClass_.constructor.apply(e,i)}for(i=Array(arguments.length-2),r=2;r<arguments.length;r++)i[r-2]=arguments[r];r=!1;for(var l=e.constructor;l;l=l.superClass_&&l.superClass_.constructor)if(l.prototype[t]===n)r=!0;else if(r)return l.prototype[t].apply(e,i);if(e[t]===n)return e.constructor.prototype[t].apply(e,i);throw Error("goog.base called from a method of one name to a method of a different name")},goog.scope=function(e){if(goog.isInModuleLoader_())throw Error("goog.scope is not supported within a goog.module.");e.call(goog.global)},COMPILED||(goog.global.COMPILED=COMPILED),goog.defineClass=function(e,t){var o=t.constructor,n=t.statics;return o&&o!=Object.prototype.constructor||(o=function(){throw Error("cannot instantiate an interface (no constructor defined).")}),o=goog.defineClass.createSealingConstructor_(o,e),e&&goog.inherits(o,e),delete t.constructor,delete t.statics,goog.defineClass.applyProperties_(o.prototype,t),null!=n&&(n instanceof Function?n(o):goog.defineClass.applyProperties_(o,n)),o},goog.defineClass.SEAL_CLASS_INSTANCES=goog.DEBUG,goog.defineClass.createSealingConstructor_=function(e,t){if(!goog.defineClass.SEAL_CLASS_INSTANCES)return e;var o=!goog.defineClass.isUnsealable_(t),n=function(){var t=e.apply(this,arguments)||this;return t[goog.UID_PROPERTY_]=t[goog.UID_PROPERTY_],this.constructor===n&&o&&Object.seal instanceof Function&&Object.seal(t),t};return n},goog.defineClass.isUnsealable_=function(e){return e&&e.prototype&&e.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_]},goog.defineClass.OBJECT_PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),goog.defineClass.applyProperties_=function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);for(var n=0;n<goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length;n++)o=goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[n],Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},goog.tagUnsealableClass=function(e){!COMPILED&&goog.defineClass.SEAL_CLASS_INSTANCES&&(e.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_]=!0)},goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_="goog_defineClass_legacy_unsealable",goog.createRequiresTranspilation_=function(){function a(e,t){d?c[e]=!0:t()?c[e]=!1:d=c[e]=!0}function b(a){try{return!!eval(a)}catch(e){return!1}}var c={es3:!1},d=!1;return a("es5",function(){return b("[1,].length==1")}),a("es6",function(){return b('(()=>{"use strict";class X{constructor(){if(new.target!=String)throw 1;this.x=42}}let q=Reflect.construct(X,[],String);if(q.x!=42||!(q instanceof String))throw 1;for(const a of[2,3]){if(a==2)continue;function f(z={a}){let a=0;return z.a}{function f(){return 0;}}return f()==3}})()')}),a("es6-impl",function(){return!0}),a("es7",function(){return b("2 ** 2 == 4")}),a("es8",function(){return b("async () => 1, true")}),c};var Blockly={},FRAME_MARGIN_SIDE=15,FRAME_MARGIN_TOP=10,FRAME_MARGIN_BOTTOM=5,FRAME_HEADER_HEIGHT=25;Blockly.BlockSvgUnused=function(e){this.block_=e,this.frameHelp_=this.frameText_=this.frameHeader_=this.frameBase_=this.frameClipRect_=this.frameGroup_=this.bindData_=void 0,this.initChildren()},Blockly.BlockSvgUnused.UNUSED_BLOCK_HELP_EVENT="blocklyUnusedBlockHelpClicked",Blockly.BlockSvgUnused.prototype.initChildren=function(){this.frameGroup_=Blockly.createSvgElement("g",{class:"blocklyUnusedFrame"});var e=Blockly.createSvgElement("clipPath",{id:"frameClip"+this.block_.id},this.frameGroup_);this.frameClipRect_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),height:FRAME_HEADER_HEIGHT},e),this.frameBase_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),fill:"#e7e8ea",stroke:"#c6cacd",rx:15,ry:15},this.frameGroup_),this.frameHeader_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),fill:"#c6cacd",rx:15,ry:15,"clip-path":"url(#frameClip"+this.block_.id+")"},this.frameGroup_),e=-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT/2),Blockly.ieVersion()&&(e+=4),this.frameText_=Blockly.createSvgElement("text",{class:"blocklyText",style:"font-size: 12pt",y:e,"dominant-baseline":"central"},this.frameGroup_),this.frameText_.appendChild(document.createTextNode(Blockly.Msg.UNUSED_CODE)),this.frameHelp_=Blockly.createSvgElement("g",{class:"blocklyHelp"},this.frameGroup_),Blockly.createSvgElement("circle",{fill:"#7665a0",r:.375*FRAME_HEADER_HEIGHT},this.frameHelp_),Blockly.createSvgElement("text",{class:"blocklyText",y:Blockly.ieVersion()?4:0},this.frameHelp_).appendChild(document.createTextNode("?"))},Blockly.BlockSvgUnused.prototype.getPadding=function(){return{top:FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT,right:FRAME_MARGIN_SIDE,bottom:FRAME_MARGIN_BOTTOM,left:FRAME_MARGIN_SIDE}},Blockly.BlockSvgUnused.prototype.bindClickEvent=function(){this.isbound_||(this.isbound_=!0,Blockly.bindEvent_(this.frameHelp_,"mousedown",this,function(e){Blockly.isRightButton(e)||(Blockly.fireUiEvent(this.frameHelp_,Blockly.BlockSvgUnused.UNUSED_BLOCK_HELP_EVENT),e.stopPropagation(),e.preventDefault())}))},Blockly.BlockSvgUnused.prototype.render=function(e){goog.dom.removeNode(this.frameGroup_);var t=e.getBoundingClientRect();goog.dom.insertChildAt(e,this.frameGroup_,0),Blockly.addClass_(this.frameGroup_,"hidden");var o=this.frameGroup_;setTimeout(function(){Blockly.removeClass_(o,"hidden")},0),this.bindClickEvent(),e=this.frameText_.getBoundingClientRect().width+this.frameHelp_.getBoundingClientRect().width,e=Math.max(t.width,e)+2*FRAME_MARGIN_SIDE,t=t.height+FRAME_MARGIN_TOP+FRAME_MARGIN_BOTTOM+FRAME_HEADER_HEIGHT,this.frameClipRect_.setAttribute("width",e),this.frameBase_.setAttribute("width",e),this.frameBase_.setAttribute("height",t),this.frameHeader_.setAttribute("width",e),this.frameHeader_.setAttribute("height",t),Blockly.RTL&&(this.frameClipRect_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameHeader_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameBase_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameText_.setAttribute("x",2*FRAME_MARGIN_SIDE-e)),this.frameHelp_.setAttribute("transform","translate("+(e-2*FRAME_MARGIN_SIDE)+","+-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT/2)+")")},Blockly.BlockSvgUnused.prototype.dispose=function(){this.bindData_&&Blockly.unbindEvent_(this.bindData_),goog.dom.removeNode(this.frameGroup_),this.frameHelp_=this.frameText_=this.frameHeader_=this.frameBase_=this.frameClipRect_=this.frameGroup_=void 0},goog.debug={},goog.debug.Error=function(e){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var t=Error().stack;t&&(this.stack=t)}e&&(this.message=String(e)),this.reportErrorToServer=!0},goog.inherits(goog.debug.Error,Error),goog.debug.Error.prototype.name="CustomError",goog.dom={},goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12},goog.string={},goog.string.DETECT_DOUBLE_ESCAPING=!1,goog.string.FORCE_NON_DOM_HTML_UNESCAPING=!1,goog.string.Unicode={NBSP:" "},goog.string.startsWith=function(e,t){return 0==e.lastIndexOf(t,0)},goog.string.endsWith=function(e,t){var o=e.length-t.length;return 0<=o&&e.indexOf(t,o)==o},goog.string.caseInsensitiveStartsWith=function(e,t){return 0==goog.string.caseInsensitiveCompare(t,e.substr(0,t.length))},goog.string.caseInsensitiveEndsWith=function(e,t){return 0==goog.string.caseInsensitiveCompare(t,e.substr(e.length-t.length,t.length))},goog.string.caseInsensitiveEquals=function(e,t){return e.toLowerCase()==t.toLowerCase()},goog.string.subs=function(e,t){for(var o=e.split("%s"),n="",i=Array.prototype.slice.call(arguments,1);i.length&&1<o.length;)n+=o.shift()+i.shift();return n+o.join("%s")},goog.string.collapseWhitespace=function(e){return e.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")},goog.string.isEmptyOrWhitespace=function(e){return/^[\s\xa0]*$/.test(e)},goog.string.isEmptyString=function(e){return 0==e.length},goog.string.isEmpty=goog.string.isEmptyOrWhitespace,goog.string.isEmptyOrWhitespaceSafe=function(e){return goog.string.isEmptyOrWhitespace(goog.string.makeSafe(e))},goog.string.isEmptySafe=goog.string.isEmptyOrWhitespaceSafe,goog.string.isBreakingWhitespace=function(e){return!/[^\t\n\r ]/.test(e)},goog.string.isAlpha=function(e){return!/[^a-zA-Z]/.test(e)},goog.string.isNumeric=function(e){return!/[^0-9]/.test(e)},goog.string.isAlphaNumeric=function(e){return!/[^a-zA-Z0-9]/.test(e)},goog.string.isSpace=function(e){return" "==e},goog.string.isUnicodeChar=function(e){return 1==e.length&&" "<=e&&"~">=e||""<=e&&"�">=e},goog.string.stripNewlines=function(e){return e.replace(/(\r\n|\r|\n)+/g," ")},goog.string.canonicalizeNewlines=function(e){return e.replace(/(\r\n|\r|\n)/g,"\n")},goog.string.normalizeWhitespace=function(e){return e.replace(/\xa0|\s/g," ")},goog.string.normalizeSpaces=function(e){return e.replace(/\xa0|[ \t]+/g," ")},goog.string.collapseBreakingSpaces=function(e){return e.replace(/[\t\r\n ]+/g," ").replace(/^[\t\r\n ]+|[\t\r\n ]+$/g,"")},goog.string.trim=goog.TRUSTED_SITE&&String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},goog.string.trimLeft=function(e){return e.replace(/^[\s\xa0]+/,"")},goog.string.trimRight=function(e){return e.replace(/[\s\xa0]+$/,"")},goog.string.caseInsensitiveCompare=function(e,t){return(e=String(e).toLowerCase())<(t=String(t).toLowerCase())?-1:e==t?0:1},goog.string.numberAwareCompare_=function(e,t,o){if(e==t)return 0;if(!e)return-1;if(!t)return 1;for(var n=e.toLowerCase().match(o),i=t.toLowerCase().match(o),r=Math.min(n.length,i.length),l=0;l<r;l++){o=n[l];var s=i[l];if(o!=s)return e=parseInt(o,10),!isNaN(e)&&(t=parseInt(s,10),!isNaN(t)&&e-t)?e-t:o<s?-1:1}return n.length!=i.length?n.length-i.length:e<t?-1:1},goog.string.intAwareCompare=function(e,t){return goog.string.numberAwareCompare_(e,t,/\d+|\D+/g)},goog.string.floatAwareCompare=function(e,t){return goog.string.numberAwareCompare_(e,t,/\d+|\.\d+|\D+/g)},goog.string.numerateCompare=goog.string.floatAwareCompare,goog.string.urlEncode=function(e){return encodeURIComponent(String(e))},goog.string.urlDecode=function(e){return decodeURIComponent(e.replace(/\+/g," "))},goog.string.newLineToBr=function(e,t){return e.replace(/(\r\n|\r|\n)/g,t?"<br />":"<br>")},goog.string.htmlEscape=function(e,t){if(t)e=e.replace(goog.string.AMP_RE_,"&amp;").replace(goog.string.LT_RE_,"&lt;").replace(goog.string.GT_RE_,"&gt;").replace(goog.string.QUOT_RE_,"&quot;").replace(goog.string.SINGLE_QUOTE_RE_,"&#39;").replace(goog.string.NULL_RE_,"&#0;"),goog.string.DETECT_DOUBLE_ESCAPING&&(e=e.replace(goog.string.E_RE_,"&#101;"));else{if(!goog.string.ALL_RE_.test(e))return e;-1!=e.indexOf("&")&&(e=e.replace(goog.string.AMP_RE_,"&amp;")),-1!=e.indexOf("<")&&(e=e.replace(goog.string.LT_RE_,"&lt;")),-1!=e.indexOf(">")&&(e=e.replace(goog.string.GT_RE_,"&gt;")),-1!=e.indexOf('"')&&(e=e.replace(goog.string.QUOT_RE_,"&quot;")),-1!=e.indexOf("'")&&(e=e.replace(goog.string.SINGLE_QUOTE_RE_,"&#39;")),-1!=e.indexOf("\0")&&(e=e.replace(goog.string.NULL_RE_,"&#0;")),goog.string.DETECT_DOUBLE_ESCAPING&&-1!=e.indexOf("e")&&(e=e.replace(goog.string.E_RE_,"&#101;"))}return e},goog.string.AMP_RE_=/&/g,goog.string.LT_RE_=/</g,goog.string.GT_RE_=/>/g,goog.string.QUOT_RE_=/"/g,goog.string.SINGLE_QUOTE_RE_=/'/g,goog.string.NULL_RE_=/\x00/g,goog.string.E_RE_=/e/g,goog.string.ALL_RE_=goog.string.DETECT_DOUBLE_ESCAPING?/[\x00&<>"'e]/:/[\x00&<>"']/,goog.string.unescapeEntities=function(e){return goog.string.contains(e,"&")?!goog.string.FORCE_NON_DOM_HTML_UNESCAPING&&"document"in goog.global?goog.string.unescapeEntitiesUsingDom_(e):goog.string.unescapePureXmlEntities_(e):e},goog.string.unescapeEntitiesWithDocument=function(e,t){return goog.string.contains(e,"&")?goog.string.unescapeEntitiesUsingDom_(e,t):e},goog.string.unescapeEntitiesUsingDom_=function(e,t){var o={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"'},n=t?t.createElement("div"):goog.global.document.createElement("div");return e.replace(goog.string.HTML_ENTITY_PATTERN_,function(e,t){var i=o[e];return i||("#"==t.charAt(0)&&(t=Number("0"+t.substr(1)),isNaN(t)||(i=String.fromCharCode(t))),i||(n.innerHTML=e+" ",i=n.firstChild.nodeValue.slice(0,-1)),o[e]=i)})},goog.string.unescapePureXmlEntities_=function(e){return e.replace(/&([^;]+);/g,function(e,t){switch(t){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';default:return"#"!=t.charAt(0)||(t=Number("0"+t.substr(1)),isNaN(t))?e:String.fromCharCode(t)}})},goog.string.HTML_ENTITY_PATTERN_=/&([^;\s<&]+);?/g,goog.string.whitespaceEscape=function(e,t){return goog.string.newLineToBr(e.replace(/  /g," &#160;"),t)},goog.string.preserveSpaces=function(e){return e.replace(/(^|[\n ]) /g,"$1"+goog.string.Unicode.NBSP)},goog.string.stripQuotes=function(e,t){for(var o=t.length,n=0;n<o;n++){var i=1==o?t:t.charAt(n);if(e.charAt(0)==i&&e.charAt(e.length-1)==i)return e.substring(1,e.length-1)}return e},goog.string.truncate=function(e,t,o){return o&&(e=goog.string.unescapeEntities(e)),e.length>t&&(e=e.substring(0,t-3)+"..."),o&&(e=goog.string.htmlEscape(e)),e},goog.string.truncateMiddle=function(e,t,o,n){if(o&&(e=goog.string.unescapeEntities(e)),n&&e.length>t){n>t&&(n=t);var i=e.length-n;e=e.substring(0,t-n)+"..."+e.substring(i)}else e.length>t&&(n=Math.floor(t/2),i=e.length-n,e=e.substring(0,n+t%2)+"..."+e.substring(i));return o&&(e=goog.string.htmlEscape(e)),e},goog.string.specialEscapeChars_={"\0":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\x0B",'"':'\\"',"\\":"\\\\","<":"<"},goog.string.jsEscapeCache_={"'":"\\'"},goog.string.quote=function(e){e=String(e);for(var t=['"'],o=0;o<e.length;o++){var n=e.charAt(o),i=n.charCodeAt(0);t[o+1]=goog.string.specialEscapeChars_[n]||(31<i&&127>i?n:goog.string.escapeChar(n))}return t.push('"'),t.join("")},goog.string.escapeString=function(e){for(var t=[],o=0;o<e.length;o++)t[o]=goog.string.escapeChar(e.charAt(o));return t.join("")},goog.string.escapeChar=function(e){if(e in goog.string.jsEscapeCache_)return goog.string.jsEscapeCache_[e];if(e in goog.string.specialEscapeChars_)return goog.string.jsEscapeCache_[e]=goog.string.specialEscapeChars_[e];var t=e.charCodeAt(0);if(31<t&&127>t)var o=e;else 256>t?(o="\\x",(16>t||256<t)&&(o+="0")):(o="\\u",4096>t&&(o+="0")),o+=t.toString(16).toUpperCase();return goog.string.jsEscapeCache_[e]=o},goog.string.contains=function(e,t){return-1!=e.indexOf(t)},goog.string.caseInsensitiveContains=function(e,t){return goog.string.contains(e.toLowerCase(),t.toLowerCase())},goog.string.countOf=function(e,t){return e&&t?e.split(t).length-1:0},goog.string.removeAt=function(e,t,o){var n=e;return 0<=t&&t<e.length&&0<o&&(n=e.substr(0,t)+e.substr(t+o,e.length-t-o)),n},goog.string.remove=function(e,t){return e.replace(t,"")},goog.string.removeAll=function(e,t){return t=new RegExp(goog.string.regExpEscape(t),"g"),e.replace(t,"")},goog.string.replaceAll=function(e,t,o){return t=new RegExp(goog.string.regExpEscape(t),"g"),e.replace(t,o.replace(/\$/g,"$$$$"))},goog.string.regExpEscape=function(e){return String(e).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")},goog.string.repeat=String.prototype.repeat?function(e,t){return e.repeat(t)}:function(e,t){return Array(t+1).join(e)},goog.string.padNumber=function(e,t,o){return-1==(o=(e=goog.isDef(o)?e.toFixed(o):String(e)).indexOf("."))&&(o=e.length),goog.string.repeat("0",Math.max(0,t-o))+e},goog.string.makeSafe=function(e){return null==e?"":String(e)},goog.string.buildString=function(e){return Array.prototype.join.call(arguments,"")},goog.string.getRandomString=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^goog.now()).toString(36)},goog.string.compareVersions=function(e,t){var o=0;e=goog.string.trim(String(e)).split("."),t=goog.string.trim(String(t)).split(".");for(var n=Math.max(e.length,t.length),i=0;0==o&&i<n;i++){var r=e[i]||"",l=t[i]||"";do{if(r=/(\d*)(\D*)(.*)/.exec(r)||["","","",""],l=/(\d*)(\D*)(.*)/.exec(l)||["","","",""],0==r[0].length&&0==l[0].length)break;o=0==r[1].length?0:parseInt(r[1],10);var s=0==l[1].length?0:parseInt(l[1],10);o=goog.string.compareElements_(o,s)||goog.string.compareElements_(0==r[2].length,0==l[2].length)||goog.string.compareElements_(r[2],l[2]),r=r[3],l=l[3]}while(0==o)}return o},goog.string.compareElements_=function(e,t){return e<t?-1:e>t?1:0},goog.string.hashCode=function(e){for(var t=0,o=0;o<e.length;++o)t=31*t+e.charCodeAt(o)>>>0;return t},goog.string.uniqueStringCounter_=2147483648*Math.random()|0,goog.string.createUniqueString=function(){return"goog_"+goog.string.uniqueStringCounter_++},goog.string.toNumber=function(e){var t=Number(e);return 0==t&&goog.string.isEmptyOrWhitespace(e)?NaN:t},goog.string.isLowerCamelCase=function(e){return/^[a-z]+([A-Z][a-z]*)*$/.test(e)},goog.string.isUpperCamelCase=function(e){return/^([A-Z][a-z]*)+$/.test(e)},goog.string.toCamelCase=function(e){return String(e).replace(/\-([a-z])/g,function(e,t){return t.toUpperCase()})},goog.string.toSelectorCase=function(e){return String(e).replace(/([A-Z])/g,"-$1").toLowerCase()},goog.string.toTitleCase=function(e,t){return t=goog.isString(t)?goog.string.regExpEscape(t):"\\s",e.replace(new RegExp("(^"+(t?"|["+t+"]+":"")+")([a-z])","g"),function(e,t,o){return t+o.toUpperCase()})},goog.string.capitalize=function(e){return String(e.charAt(0)).toUpperCase()+String(e.substr(1)).toLowerCase()},goog.string.parseInt=function(e){return isFinite(e)&&(e=String(e)),goog.isString(e)?/^\s*-?0x/i.test(e)?parseInt(e,16):parseInt(e,10):NaN},goog.string.splitLimit=function(e,t,o){e=e.split(t);for(var n=[];0<o&&e.length;)n.push(e.shift()),o--;return e.length&&n.push(e.join(t)),n},goog.string.lastComponent=function(e,t){if(!t)return e;"string"==typeof t&&(t=[t]);for(var o=-1,n=0;n<t.length;n++)if(""!=t[n]){var i=e.lastIndexOf(t[n]);i>o&&(o=i)}return-1==o?e:e.slice(o+1)},goog.string.editDistance=function(e,t){var o=[],n=[];if(e==t)return 0;if(!e.length||!t.length)return Math.max(e.length,t.length);for(var i=0;i<t.length+1;i++)o[i]=i;for(i=0;i<e.length;i++){n[0]=i+1;for(var r=0;r<t.length;r++)n[r+1]=Math.min(n[r]+1,o[r+1]+1,o[r]+Number(e[i]!=t[r]));for(r=0;r<o.length;r++)o[r]=n[r]}return n[t.length]},goog.asserts={},goog.asserts.ENABLE_ASSERTS=goog.DEBUG,goog.asserts.AssertionError=function(e,t){t.unshift(e),goog.debug.Error.call(this,goog.string.subs.apply(null,t)),t.shift(),this.messagePattern=e},goog.inherits(goog.asserts.AssertionError,goog.debug.Error),goog.asserts.AssertionError.prototype.name="AssertionError",goog.asserts.DEFAULT_ERROR_HANDLER=function(e){throw e},goog.asserts.errorHandler_=goog.asserts.DEFAULT_ERROR_HANDLER,goog.asserts.doAssertFailure_=function(e,t,o,n){var i="Assertion failed";if(o){i+=": "+o;var r=n}else e&&(i+=": "+e,r=t);e=new goog.asserts.AssertionError(""+i,r||[]),goog.asserts.errorHandler_(e)},goog.asserts.setErrorHandler=function(e){goog.asserts.ENABLE_ASSERTS&&(goog.asserts.errorHandler_=e)},goog.asserts.assert=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!e&&goog.asserts.doAssertFailure_("",null,t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.fail=function(e,t){goog.asserts.ENABLE_ASSERTS&&goog.asserts.errorHandler_(new goog.asserts.AssertionError("Failure"+(e?": "+e:""),Array.prototype.slice.call(arguments,1)))},goog.asserts.assertNumber=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isNumber(e)&&goog.asserts.doAssertFailure_("Expected number but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertString=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isString(e)&&goog.asserts.doAssertFailure_("Expected string but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertFunction=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isFunction(e)&&goog.asserts.doAssertFailure_("Expected function but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertObject=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isObject(e)&&goog.asserts.doAssertFailure_("Expected object but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertArray=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isArray(e)&&goog.asserts.doAssertFailure_("Expected array but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertBoolean=function(e,t,o){return goog.asserts.ENABLE_ASSERTS&&!goog.isBoolean(e)&&goog.asserts.doAssertFailure_("Expected boolean but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertElement=function(e,t,o){return!goog.asserts.ENABLE_ASSERTS||goog.isObject(e)&&e.nodeType==goog.dom.NodeType.ELEMENT||goog.asserts.doAssertFailure_("Expected Element but got %s: %s.",[goog.typeOf(e),e],t,Array.prototype.slice.call(arguments,2)),e},goog.asserts.assertInstanceof=function(e,t,o,n){return!goog.asserts.ENABLE_ASSERTS||e instanceof t||goog.asserts.doAssertFailure_("Expected instanceof %s but got %s.",[goog.asserts.getType_(t),goog.asserts.getType_(e)],o,Array.prototype.slice.call(arguments,3)),e},goog.asserts.assertObjectPrototypeIsIntact=function(){for(var e in Object.prototype)goog.asserts.fail(e+" should not be enumerable in Object.prototype.")},goog.asserts.getType_=function(e){return e instanceof Function?e.displayName||e.name||"unknown type name":e instanceof Object?e.constructor.displayName||e.constructor.name||Object.prototype.toString.call(e):null===e?"null":typeof e},goog.array={},goog.NATIVE_ARRAY_PROTOTYPES=goog.TRUSTED_SITE,goog.array.ASSUME_NATIVE_FUNCTIONS=!1,goog.array.peek=function(e){return e[e.length-1]},goog.array.last=goog.array.peek,goog.array.indexOf=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.indexOf)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.indexOf.call(e,t,o)}:function(e,t,o){if(o=null==o?0:0>o?Math.max(0,e.length+o):o,goog.isString(e))return goog.isString(t)&&1==t.length?e.indexOf(t,o):-1;for(;o<e.length;o++)if(o in e&&e[o]===t)return o;return-1},goog.array.lastIndexOf=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.lastIndexOf)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.lastIndexOf.call(e,t,null==o?e.length-1:o)}:function(e,t,o){if(0>(o=null==o?e.length-1:o)&&(o=Math.max(0,e.length+o)),goog.isString(e))return goog.isString(t)&&1==t.length?e.lastIndexOf(t,o):-1;for(;0<=o;o--)if(o in e&&e[o]===t)return o;return-1},goog.array.forEach=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.forEach)?function(e,t,o){goog.asserts.assert(null!=e.length),Array.prototype.forEach.call(e,t,o)}:function(e,t,o){for(var n=e.length,i=goog.isString(e)?e.split(""):e,r=0;r<n;r++)r in i&&t.call(o,i[r],r,e)},goog.array.forEachRight=function(e,t,o){var n=e.length,i=goog.isString(e)?e.split(""):e;for(--n;0<=n;--n)n in i&&t.call(o,i[n],n,e)},goog.array.filter=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.filter)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.filter.call(e,t,o)}:function(e,t,o){for(var n=e.length,i=[],r=0,l=goog.isString(e)?e.split(""):e,s=0;s<n;s++)if(s in l){var a=l[s];t.call(o,a,s,e)&&(i[r++]=a)}return i},goog.array.map=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.map)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.map.call(e,t,o)}:function(e,t,o){for(var n=e.length,i=Array(n),r=goog.isString(e)?e.split(""):e,l=0;l<n;l++)l in r&&(i[l]=t.call(o,r[l],l,e));return i},goog.array.reduce=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.reduce)?function(e,t,o,n){return goog.asserts.assert(null!=e.length),n&&(t=goog.bind(t,n)),Array.prototype.reduce.call(e,t,o)}:function(e,t,o,n){var i=o;return goog.array.forEach(e,function(o,r){i=t.call(n,i,o,r,e)}),i},goog.array.reduceRight=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.reduceRight)?function(e,t,o,n){return goog.asserts.assert(null!=e.length),goog.asserts.assert(null!=t),n&&(t=goog.bind(t,n)),Array.prototype.reduceRight.call(e,t,o)}:function(e,t,o,n){var i=o;return goog.array.forEachRight(e,function(o,r){i=t.call(n,i,o,r,e)}),i},goog.array.some=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.some)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.some.call(e,t,o)}:function(e,t,o){for(var n=e.length,i=goog.isString(e)?e.split(""):e,r=0;r<n;r++)if(r in i&&t.call(o,i[r],r,e))return!0;return!1},goog.array.every=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||Array.prototype.every)?function(e,t,o){return goog.asserts.assert(null!=e.length),Array.prototype.every.call(e,t,o)}:function(e,t,o){for(var n=e.length,i=goog.isString(e)?e.split(""):e,r=0;r<n;r++)if(r in i&&!t.call(o,i[r],r,e))return!1;return!0},goog.array.count=function(e,t,o){var n=0;return goog.array.forEach(e,function(e,i,r){t.call(o,e,i,r)&&++n},o),n},goog.array.find=function(e,t,o){return 0>(t=goog.array.findIndex(e,t,o))?null:goog.isString(e)?e.charAt(t):e[t]},goog.array.findIndex=function(e,t,o){for(var n=e.length,i=goog.isString(e)?e.split(""):e,r=0;r<n;r++)if(r in i&&t.call(o,i[r],r,e))return r;return-1},goog.array.findRight=function(e,t,o){return 0>(t=goog.array.findIndexRight(e,t,o))?null:goog.isString(e)?e.charAt(t):e[t]},goog.array.findIndexRight=function(e,t,o){var n=e.length,i=goog.isString(e)?e.split(""):e;for(--n;0<=n;n--)if(n in i&&t.call(o,i[n],n,e))return n;return-1},goog.array.contains=function(e,t){return 0<=goog.array.indexOf(e,t)},goog.array.isEmpty=function(e){return 0==e.length},goog.array.clear=function(e){if(!goog.isArray(e))for(var t=e.length-1;0<=t;t--)delete e[t];e.length=0},goog.array.insert=function(e,t){goog.array.contains(e,t)||e.push(t)},goog.array.insertAt=function(e,t,o){goog.array.splice(e,o,0,t)},goog.array.insertArrayAt=function(e,t,o){goog.partial(goog.array.splice,e,o,0).apply(null,t)},goog.array.insertBefore=function(e,t,o){var n;2==arguments.length||0>(n=goog.array.indexOf(e,o))?e.push(t):goog.array.insertAt(e,t,n)},goog.array.remove=function(e,t){var o;return(o=0<=(t=goog.array.indexOf(e,t)))&&goog.array.removeAt(e,t),o},goog.array.removeLast=function(e,t){return 0<=(t=goog.array.lastIndexOf(e,t))&&(goog.array.removeAt(e,t),!0)},goog.array.removeAt=function(e,t){return goog.asserts.assert(null!=e.length),1==Array.prototype.splice.call(e,t,1).length},goog.array.removeIf=function(e,t,o){return 0<=(t=goog.array.findIndex(e,t,o))&&(goog.array.removeAt(e,t),!0)},goog.array.removeAllIf=function(e,t,o){var n=0;return goog.array.forEachRight(e,function(i,r){t.call(o,i,r,e)&&goog.array.removeAt(e,r)&&n++}),n},goog.array.concat=function(e){return Array.prototype.concat.apply(Array.prototype,arguments)},goog.array.join=function(e){return Array.prototype.concat.apply(Array.prototype,arguments)},goog.array.toArray=function(e){var t=e.length;if(0<t){for(var o=Array(t),n=0;n<t;n++)o[n]=e[n];return o}return[]},goog.array.clone=goog.array.toArray,goog.array.extend=function(e,t){for(var o=1;o<arguments.length;o++){var n=arguments[o];if(goog.isArrayLike(n)){var i=e.length||0,r=n.length||0;e.length=i+r;for(var l=0;l<r;l++)e[i+l]=n[l]}else e.push(n)}},goog.array.splice=function(e,t,o,n){return goog.asserts.assert(null!=e.length),Array.prototype.splice.apply(e,goog.array.slice(arguments,1))},goog.array.slice=function(e,t,o){return goog.asserts.assert(null!=e.length),2>=arguments.length?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,o)},goog.array.removeDuplicates=function(e,t,o){t=t||e;var n=function(e){return goog.isObject(e)?"o"+goog.getUid(e):(typeof e).charAt(0)+e};o=o||n,n={};for(var i=0,r=0;r<e.length;){var l=e[r++],s=o(l);Object.prototype.hasOwnProperty.call(n,s)||(n[s]=!0,t[i++]=l)}t.length=i},goog.array.binarySearch=function(e,t,o){return goog.array.binarySearch_(e,o||goog.array.defaultCompare,!1,t)},goog.array.binarySelect=function(e,t,o){return goog.array.binarySearch_(e,t,!0,void 0,o)},goog.array.binarySearch_=function(e,t,o,n,i){for(var r,l=0,s=e.length;l<s;){var a=l+s>>1,g=o?t.call(i,e[a],a,e):t(n,e[a]);0<g?l=a+1:(s=a,r=!g)}return r?l:~l},goog.array.sort=function(e,t){e.sort(t||goog.array.defaultCompare)},goog.array.stableSort=function(e,t){for(var o=Array(e.length),n=0;n<e.length;n++)o[n]={index:n,value:e[n]};var i=t||goog.array.defaultCompare;for(goog.array.sort(o,function(e,t){return i(e.value,t.value)||e.index-t.index}),n=0;n<e.length;n++)e[n]=o[n].value},goog.array.sortByKey=function(e,t,o){var n=o||goog.array.defaultCompare;goog.array.sort(e,function(e,o){return n(t(e),t(o))})},goog.array.sortObjectsByKey=function(e,t,o){goog.array.sortByKey(e,function(e){return e[t]},o)},goog.array.isSorted=function(e,t,o){t=t||goog.array.defaultCompare;for(var n=1;n<e.length;n++){var i=t(e[n-1],e[n]);if(0<i||0==i&&o)return!1}return!0},goog.array.equals=function(e,t,o){if(!goog.isArrayLike(e)||!goog.isArrayLike(t)||e.length!=t.length)return!1;var n=e.length;o=o||goog.array.defaultCompareEquality;for(var i=0;i<n;i++)if(!o(e[i],t[i]))return!1;return!0},goog.array.compare3=function(e,t,o){o=o||goog.array.defaultCompare;for(var n=Math.min(e.length,t.length),i=0;i<n;i++){var r=o(e[i],t[i]);if(0!=r)return r}return goog.array.defaultCompare(e.length,t.length)},goog.array.defaultCompare=function(e,t){return e>t?1:e<t?-1:0},goog.array.inverseDefaultCompare=function(e,t){return-goog.array.defaultCompare(e,t)},goog.array.defaultCompareEquality=function(e,t){return e===t},goog.array.binaryInsert=function(e,t,o){return 0>(o=goog.array.binarySearch(e,t,o))&&(goog.array.insertAt(e,t,-(o+1)),!0)},goog.array.binaryRemove=function(e,t,o){return 0<=(t=goog.array.binarySearch(e,t,o))&&goog.array.removeAt(e,t)},goog.array.bucket=function(e,t,o){for(var n={},i=0;i<e.length;i++){var r=e[i],l=t.call(o,r,i,e);goog.isDef(l)&&(n[l]||(n[l]=[])).push(r)}return n},goog.array.toObject=function(e,t,o){var n={};return goog.array.forEach(e,function(i,r){n[t.call(o,i,r,e)]=i}),n},goog.array.range=function(e,t,o){var n=[],i=0,r=e;if(void 0!==t&&(i=e,r=t),0>(o=o||1)*(r-i))return[];if(0<o)for(e=i;e<r;e+=o)n.push(e);else for(e=i;e>r;e+=o)n.push(e);return n},goog.array.repeat=function(e,t){for(var o=[],n=0;n<t;n++)o[n]=e;return o},goog.array.flatten=function(e){for(var t=[],o=0;o<arguments.length;o++){var n=arguments[o];if(goog.isArray(n))for(var i=0;i<n.length;i+=8192){var r=goog.array.slice(n,i,i+8192);r=goog.array.flatten.apply(null,r);for(var l=0;l<r.length;l++)t.push(r[l])}else t.push(n)}return t},goog.array.rotate=function(e,t){return goog.asserts.assert(null!=e.length),e.length&&(0<(t%=e.length)?Array.prototype.unshift.apply(e,e.splice(-t,t)):0>t&&Array.prototype.push.apply(e,e.splice(0,-t))),e},goog.array.moveItem=function(e,t,o){goog.asserts.assert(0<=t&&t<e.length),goog.asserts.assert(0<=o&&o<e.length),t=Array.prototype.splice.call(e,t,1),Array.prototype.splice.call(e,o,0,t[0])},goog.array.zip=function(e){if(!arguments.length)return[];for(var t=[],o=arguments[0].length,n=1;n<arguments.length;n++)arguments[n].length<o&&(o=arguments[n].length);for(n=0;n<o;n++){for(var i=[],r=0;r<arguments.length;r++)i.push(arguments[r][n]);t.push(i)}return t},goog.array.shuffle=function(e,t){t=t||Math.random;for(var o=e.length-1;0<o;o--){var n=Math.floor(t()*(o+1)),i=e[o];e[o]=e[n],e[n]=i}},goog.array.copyByIndex=function(e,t){var o=[];return goog.array.forEach(t,function(t){o.push(e[t])}),o},goog.array.concatMap=function(e,t,o){return goog.array.concat.apply([],goog.array.map(e,t,o))},goog.labs={},goog.labs.userAgent={},goog.labs.userAgent.util={},goog.labs.userAgent.util.getNativeUserAgentString_=function(){var e=goog.labs.userAgent.util.getNavigator_();return e&&(e=e.userAgent)?e:""},goog.labs.userAgent.util.getNavigator_=function(){return goog.global.navigator},goog.labs.userAgent.util.userAgent_=goog.labs.userAgent.util.getNativeUserAgentString_(),goog.labs.userAgent.util.setUserAgent=function(e){goog.labs.userAgent.util.userAgent_=e||goog.labs.userAgent.util.getNativeUserAgentString_()},goog.labs.userAgent.util.getUserAgent=function(){return goog.labs.userAgent.util.userAgent_},goog.labs.userAgent.util.matchUserAgent=function(e){var t=goog.labs.userAgent.util.getUserAgent();return goog.string.contains(t,e)},goog.labs.userAgent.util.matchUserAgentIgnoreCase=function(e){var t=goog.labs.userAgent.util.getUserAgent();return goog.string.caseInsensitiveContains(t,e)},goog.labs.userAgent.util.extractVersionTuples=function(e){for(var t,o=/(\w[\w ]+)\/([^\s]+)\s*(?:\((.*?)\))?/g,n=[];t=o.exec(e);)n.push([t[1],t[2],t[3]||void 0]);return n},goog.object={},goog.object.is=function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},goog.object.forEach=function(e,t,o){for(var n in e)t.call(o,e[n],n,e)},goog.object.filter=function(e,t,o){var n,i={};for(n in e)t.call(o,e[n],n,e)&&(i[n]=e[n]);return i},goog.object.map=function(e,t,o){var n,i={};for(n in e)i[n]=t.call(o,e[n],n,e);return i},goog.object.some=function(e,t,o){for(var n in e)if(t.call(o,e[n],n,e))return!0;return!1},goog.object.every=function(e,t,o){for(var n in e)if(!t.call(o,e[n],n,e))return!1;return!0},goog.object.getCount=function(e){var t,o=0;for(t in e)o++;return o},goog.object.getAnyKey=function(e){for(var t in e)return t},goog.object.getAnyValue=function(e){for(var t in e)return e[t]},goog.object.contains=function(e,t){return goog.object.containsValue(e,t)},goog.object.getValues=function(e){var t,o=[],n=0;for(t in e)o[n++]=e[t];return o},goog.object.getKeys=function(e){var t,o=[],n=0;for(t in e)o[n++]=t;return o},goog.object.getValueByKeys=function(e,t){var o=goog.isArrayLike(t),n=o?t:arguments;for(o=o?0:1;o<n.length&&(e=e[n[o]],goog.isDef(e));o++);return e},goog.object.containsKey=function(e,t){return null!==e&&t in e},goog.object.containsValue=function(e,t){for(var o in e)if(e[o]==t)return!0;return!1},goog.object.findKey=function(e,t,o){for(var n in e)if(t.call(o,e[n],n,e))return n},goog.object.findValue=function(e,t,o){return(t=goog.object.findKey(e,t,o))&&e[t]},goog.object.isEmpty=function(e){for(var t in e)return!1;return!0},goog.object.clear=function(e){for(var t in e)delete e[t]},goog.object.remove=function(e,t){var o;return(o=t in e)&&delete e[t],o},goog.object.add=function(e,t,o){if(null!==e&&t in e)throw Error('The object already contains the key "'+t+'"');goog.object.set(e,t,o)},goog.object.get=function(e,t,o){return null!==e&&t in e?e[t]:o},goog.object.set=function(e,t,o){e[t]=o},goog.object.setIfUndefined=function(e,t,o){return t in e?e[t]:e[t]=o},goog.object.setWithReturnValueIfNotSet=function(e,t,o){return t in e?e[t]:(o=o(),e[t]=o)},goog.object.equals=function(e,t){for(var o in e)if(!(o in t)||e[o]!==t[o])return!1;for(o in t)if(!(o in e))return!1;return!0},goog.object.clone=function(e){var t,o={};for(t in e)o[t]=e[t];return o},goog.object.unsafeClone=function(e){var t=goog.typeOf(e);if("object"==t||"array"==t){if(goog.isFunction(e.clone))return e.clone();for(var o in t="array"==t?[]:{},e)t[o]=goog.object.unsafeClone(e[o]);return t}return e},goog.object.transpose=function(e){var t,o={};for(t in e)o[e[t]]=t;return o},goog.object.PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),goog.object.extend=function(e,t){for(var o,n,i=1;i<arguments.length;i++){for(o in n=arguments[i])e[o]=n[o];for(var r=0;r<goog.object.PROTOTYPE_FIELDS_.length;r++)o=goog.object.PROTOTYPE_FIELDS_[r],Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}},goog.object.create=function(e){var t=arguments.length;if(1==t&&goog.isArray(arguments[0]))return goog.object.create.apply(null,arguments[0]);if(t%2)throw Error("Uneven number of arguments");for(var o={},n=0;n<t;n+=2)o[arguments[n]]=arguments[n+1];return o},goog.object.createSet=function(e){var t=arguments.length;if(1==t&&goog.isArray(arguments[0]))return goog.object.createSet.apply(null,arguments[0]);for(var o={},n=0;n<t;n++)o[arguments[n]]=!0;return o},goog.object.createImmutableView=function(e){var t=e;return Object.isFrozen&&!Object.isFrozen(e)&&(t=Object.create(e),Object.freeze(t)),t},goog.object.isImmutableView=function(e){return!!Object.isFrozen&&Object.isFrozen(e)},goog.object.getAllPropertyNames=function(e,t){if(!e)return[];if(!Object.getOwnPropertyNames||!Object.getPrototypeOf)return goog.object.getKeys(e);for(var o={};e&&(e!==Object.prototype||t);){for(var n=Object.getOwnPropertyNames(e),i=0;i<n.length;i++)o[n[i]]=!0;e=Object.getPrototypeOf(e)}return goog.object.getKeys(o)},goog.labs.userAgent.browser={},goog.labs.userAgent.browser.matchOpera_=function(){return goog.labs.userAgent.util.matchUserAgent("Opera")},goog.labs.userAgent.browser.matchIE_=function(){return goog.labs.userAgent.util.matchUserAgent("Trident")||goog.labs.userAgent.util.matchUserAgent("MSIE")},goog.labs.userAgent.browser.matchEdge_=function(){return goog.labs.userAgent.util.matchUserAgent("Edge")},goog.labs.userAgent.browser.matchFirefox_=function(){return goog.labs.userAgent.util.matchUserAgent("Firefox")},goog.labs.userAgent.browser.matchSafari_=function(){return goog.labs.userAgent.util.matchUserAgent("Safari")&&!(goog.labs.userAgent.browser.matchChrome_()||goog.labs.userAgent.browser.matchCoast_()||goog.labs.userAgent.browser.matchOpera_()||goog.labs.userAgent.browser.matchEdge_()||goog.labs.userAgent.browser.isSilk()||goog.labs.userAgent.util.matchUserAgent("Android"))},goog.labs.userAgent.browser.matchCoast_=function(){return goog.labs.userAgent.util.matchUserAgent("Coast")},goog.labs.userAgent.browser.matchIosWebview_=function(){return(goog.labs.userAgent.util.matchUserAgent("iPad")||goog.labs.userAgent.util.matchUserAgent("iPhone"))&&!goog.labs.userAgent.browser.matchSafari_()&&!goog.labs.userAgent.browser.matchChrome_()&&!goog.labs.userAgent.browser.matchCoast_()&&goog.labs.userAgent.util.matchUserAgent("AppleWebKit")},goog.labs.userAgent.browser.matchChrome_=function(){return(goog.labs.userAgent.util.matchUserAgent("Chrome")||goog.labs.userAgent.util.matchUserAgent("CriOS"))&&!goog.labs.userAgent.browser.matchEdge_()},goog.labs.userAgent.browser.matchAndroidBrowser_=function(){return goog.labs.userAgent.util.matchUserAgent("Android")&&!(goog.labs.userAgent.browser.isChrome()||goog.labs.userAgent.browser.isFirefox()||goog.labs.userAgent.browser.isOpera()||goog.labs.userAgent.browser.isSilk())},goog.labs.userAgent.browser.isOpera=goog.labs.userAgent.browser.matchOpera_,goog.labs.userAgent.browser.isIE=goog.labs.userAgent.browser.matchIE_,goog.labs.userAgent.browser.isEdge=goog.labs.userAgent.browser.matchEdge_,goog.labs.userAgent.browser.isFirefox=goog.labs.userAgent.browser.matchFirefox_,goog.labs.userAgent.browser.isSafari=goog.labs.userAgent.browser.matchSafari_,goog.labs.userAgent.browser.isCoast=goog.labs.userAgent.browser.matchCoast_,goog.labs.userAgent.browser.isIosWebview=goog.labs.userAgent.browser.matchIosWebview_,goog.labs.userAgent.browser.isChrome=goog.labs.userAgent.browser.matchChrome_,goog.labs.userAgent.browser.isAndroidBrowser=goog.labs.userAgent.browser.matchAndroidBrowser_,goog.labs.userAgent.browser.isSilk=function(){return goog.labs.userAgent.util.matchUserAgent("Silk")},goog.labs.userAgent.browser.getVersion=function(){function e(e){return e=goog.array.find(e,n),o[e]||""}var t=goog.labs.userAgent.util.getUserAgent();if(goog.labs.userAgent.browser.isIE())return goog.labs.userAgent.browser.getIEVersion_(t);t=goog.labs.userAgent.util.extractVersionTuples(t);var o={};goog.array.forEach(t,function(e){o[e[0]]=e[1]});var n=goog.partial(goog.object.containsKey,o);return goog.labs.userAgent.browser.isOpera()?e(["Version","Opera"]):goog.labs.userAgent.browser.isEdge()?e(["Edge"]):goog.labs.userAgent.browser.isChrome()?e(["Chrome","CriOS"]):(t=t[2])&&t[1]||""},goog.labs.userAgent.browser.isVersionOrHigher=function(e){return 0<=goog.string.compareVersions(goog.labs.userAgent.browser.getVersion(),e)},goog.labs.userAgent.browser.getIEVersion_=function(e){var t=/rv: *([\d\.]*)/.exec(e);if(t&&t[1])return t[1];t="";var o=/MSIE +([\d\.]+)/.exec(e);if(o&&o[1])if(e=/Trident\/(\d.\d)/.exec(e),"7.0"==o[1])if(e&&e[1])switch(e[1]){case"4.0":t="8.0";break;case"5.0":t="9.0";break;case"6.0":t="10.0";break;case"7.0":t="11.0"}else t="7.0";else t=o[1];return t},goog.labs.userAgent.engine={},goog.labs.userAgent.engine.isPresto=function(){return goog.labs.userAgent.util.matchUserAgent("Presto")},goog.labs.userAgent.engine.isTrident=function(){return goog.labs.userAgent.util.matchUserAgent("Trident")||goog.labs.userAgent.util.matchUserAgent("MSIE")},goog.labs.userAgent.engine.isEdge=function(){return goog.labs.userAgent.util.matchUserAgent("Edge")},goog.labs.userAgent.engine.isWebKit=function(){return goog.labs.userAgent.util.matchUserAgentIgnoreCase("WebKit")&&!goog.labs.userAgent.engine.isEdge()},goog.labs.userAgent.engine.isGecko=function(){return goog.labs.userAgent.util.matchUserAgent("Gecko")&&!goog.labs.userAgent.engine.isWebKit()&&!goog.labs.userAgent.engine.isTrident()&&!goog.labs.userAgent.engine.isEdge()},goog.labs.userAgent.engine.getVersion=function(){var e=goog.labs.userAgent.util.getUserAgent();if(e){e=goog.labs.userAgent.util.extractVersionTuples(e);var t,o=goog.labs.userAgent.engine.getEngineTuple_(e);if(o)return"Gecko"==o[0]?goog.labs.userAgent.engine.getVersionForKey_(e,"Firefox"):o[1];if((e=e[0])&&(t=e[2])&&(t=/Trident\/([^\s;]+)/.exec(t)))return t[1]}return""},goog.labs.userAgent.engine.getEngineTuple_=function(e){if(!goog.labs.userAgent.engine.isEdge())return e[1];for(var t=0;t<e.length;t++){var o=e[t];if("Edge"==o[0])return o}},goog.labs.userAgent.engine.isVersionOrHigher=function(e){return 0<=goog.string.compareVersions(goog.labs.userAgent.engine.getVersion(),e)},goog.labs.userAgent.engine.getVersionForKey_=function(e,t){return(e=goog.array.find(e,function(e){return t==e[0]}))&&e[1]||""},goog.labs.userAgent.platform={},goog.labs.userAgent.platform.isAndroid=function(){return goog.labs.userAgent.util.matchUserAgent("Android")},goog.labs.userAgent.platform.isIpod=function(){return goog.labs.userAgent.util.matchUserAgent("iPod")},goog.labs.userAgent.platform.isIphone=function(){return goog.labs.userAgent.util.matchUserAgent("iPhone")&&!goog.labs.userAgent.util.matchUserAgent("iPod")&&!goog.labs.userAgent.util.matchUserAgent("iPad")},goog.labs.userAgent.platform.isIpad=function(){return goog.labs.userAgent.util.matchUserAgent("iPad")},goog.labs.userAgent.platform.isIos=function(){return goog.labs.userAgent.platform.isIphone()||goog.labs.userAgent.platform.isIpad()||goog.labs.userAgent.platform.isIpod()},goog.labs.userAgent.platform.isMacintosh=function(){return goog.labs.userAgent.util.matchUserAgent("Macintosh")},goog.labs.userAgent.platform.isLinux=function(){return goog.labs.userAgent.util.matchUserAgent("Linux")},goog.labs.userAgent.platform.isWindows=function(){return goog.labs.userAgent.util.matchUserAgent("Windows")},goog.labs.userAgent.platform.isChromeOS=function(){return goog.labs.userAgent.util.matchUserAgent("CrOS")},goog.labs.userAgent.platform.getVersion=function(){var e=goog.labs.userAgent.util.getUserAgent(),t="";return goog.labs.userAgent.platform.isWindows()?t=(e=(t=/Windows (?:NT|Phone) ([0-9.]+)/).exec(e))?e[1]:"0.0":goog.labs.userAgent.platform.isIos()?t=(e=(t=/(?:iPhone|iPod|iPad|CPU)\s+OS\s+(\S+)/).exec(e))&&e[1].replace(/_/g,"."):goog.labs.userAgent.platform.isMacintosh()?t=(e=(t=/Mac OS X ([0-9_.]+)/).exec(e))?e[1].replace(/_/g,"."):"10":goog.labs.userAgent.platform.isAndroid()?t=(e=(t=/Android\s+([^\);]+)(\)|;)/).exec(e))&&e[1]:goog.labs.userAgent.platform.isChromeOS()&&(t=(e=(t=/(?:CrOS\s+(?:i686|x86_64)\s+([0-9.]+))/).exec(e))&&e[1]),t||""},goog.labs.userAgent.platform.isVersionOrHigher=function(e){return 0<=goog.string.compareVersions(goog.labs.userAgent.platform.getVersion(),e)},goog.reflect={},goog.reflect.object=function(e,t){return t},goog.reflect.objectProperty=function(e,t){return e},goog.reflect.sinkValue=function(e){return goog.reflect.sinkValue[" "](e),e},goog.reflect.sinkValue[" "]=goog.nullFunction,goog.reflect.canAccessProperty=function(e,t){try{return goog.reflect.sinkValue(e[t]),!0}catch(e){}return!1},goog.reflect.cache=function(e,t,o,n){return n=n?n(t):t,Object.prototype.hasOwnProperty.call(e,n)?e[n]:e[n]=o(t)},goog.userAgent={},goog.userAgent.ASSUME_IE=!1,goog.userAgent.ASSUME_EDGE=!1,goog.userAgent.ASSUME_GECKO=!1,goog.userAgent.ASSUME_WEBKIT=!1,goog.userAgent.ASSUME_MOBILE_WEBKIT=!1,goog.userAgent.ASSUME_OPERA=!1,goog.userAgent.ASSUME_ANY_VERSION=!1,goog.userAgent.BROWSER_KNOWN_=goog.userAgent.ASSUME_IE||goog.userAgent.ASSUME_EDGE||goog.userAgent.ASSUME_GECKO||goog.userAgent.ASSUME_MOBILE_WEBKIT||goog.userAgent.ASSUME_WEBKIT||goog.userAgent.ASSUME_OPERA,goog.userAgent.getUserAgentString=function(){return goog.labs.userAgent.util.getUserAgent()},goog.userAgent.getNavigator=function(){return goog.global.navigator||null},goog.userAgent.OPERA=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_OPERA:goog.labs.userAgent.browser.isOpera(),goog.userAgent.IE=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_IE:goog.labs.userAgent.browser.isIE(),goog.userAgent.EDGE=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_EDGE:goog.labs.userAgent.engine.isEdge(),goog.userAgent.EDGE_OR_IE=goog.userAgent.EDGE||goog.userAgent.IE,goog.userAgent.GECKO=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_GECKO:goog.labs.userAgent.engine.isGecko(),goog.userAgent.WEBKIT=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_WEBKIT||goog.userAgent.ASSUME_MOBILE_WEBKIT:goog.labs.userAgent.engine.isWebKit(),goog.userAgent.isMobile_=function(){return goog.userAgent.WEBKIT&&goog.labs.userAgent.util.matchUserAgent("Mobile")},goog.userAgent.MOBILE=goog.userAgent.ASSUME_MOBILE_WEBKIT||goog.userAgent.isMobile_(),goog.userAgent.SAFARI=goog.userAgent.WEBKIT,goog.userAgent.determinePlatform_=function(){var e=goog.userAgent.getNavigator();return e&&e.platform||""},goog.userAgent.PLATFORM=goog.userAgent.determinePlatform_(),goog.userAgent.ASSUME_MAC=!1,goog.userAgent.ASSUME_WINDOWS=!1,goog.userAgent.ASSUME_LINUX=!1,goog.userAgent.ASSUME_X11=!1,goog.userAgent.ASSUME_ANDROID=!1,goog.userAgent.ASSUME_IPHONE=!1,goog.userAgent.ASSUME_IPAD=!1,goog.userAgent.ASSUME_IPOD=!1,goog.userAgent.PLATFORM_KNOWN_=goog.userAgent.ASSUME_MAC||goog.userAgent.ASSUME_WINDOWS||goog.userAgent.ASSUME_LINUX||goog.userAgent.ASSUME_X11||goog.userAgent.ASSUME_ANDROID||goog.userAgent.ASSUME_IPHONE||goog.userAgent.ASSUME_IPAD||goog.userAgent.ASSUME_IPOD,goog.userAgent.MAC=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_MAC:goog.labs.userAgent.platform.isMacintosh(),goog.userAgent.WINDOWS=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_WINDOWS:goog.labs.userAgent.platform.isWindows(),goog.userAgent.isLegacyLinux_=function(){return goog.labs.userAgent.platform.isLinux()||goog.labs.userAgent.platform.isChromeOS()},goog.userAgent.LINUX=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_LINUX:goog.userAgent.isLegacyLinux_(),goog.userAgent.isX11_=function(){var e=goog.userAgent.getNavigator();return!!e&&goog.string.contains(e.appVersion||"","X11")},goog.userAgent.X11=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_X11:goog.userAgent.isX11_(),goog.userAgent.ANDROID=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_ANDROID:goog.labs.userAgent.platform.isAndroid(),goog.userAgent.IPHONE=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPHONE:goog.labs.userAgent.platform.isIphone(),goog.userAgent.IPAD=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPAD:goog.labs.userAgent.platform.isIpad(),goog.userAgent.IPOD=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPOD:goog.labs.userAgent.platform.isIpod(),goog.userAgent.IOS=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPHONE||goog.userAgent.ASSUME_IPAD||goog.userAgent.ASSUME_IPOD:goog.labs.userAgent.platform.isIos(),goog.userAgent.determineVersion_=function(){var e="",t=goog.userAgent.getVersionRegexResult_();return t&&(e=t?t[1]:""),goog.userAgent.IE&&(null!=(t=goog.userAgent.getDocumentMode_())&&t>parseFloat(e))?String(t):e},goog.userAgent.getVersionRegexResult_=function(){var e=goog.userAgent.getUserAgentString();return goog.userAgent.GECKO?/rv:([^\);]+)(\)|;)/.exec(e):goog.userAgent.EDGE?/Edge\/([\d\.]+)/.exec(e):goog.userAgent.IE?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(e):goog.userAgent.WEBKIT?/WebKit\/(\S+)/.exec(e):goog.userAgent.OPERA?/(?:Version)[ \/]?(\S+)/.exec(e):void 0},goog.userAgent.getDocumentMode_=function(){var e=goog.global.document;return e?e.documentMode:void 0},goog.userAgent.VERSION=goog.userAgent.determineVersion_(),goog.userAgent.compare=function(e,t){return goog.string.compareVersions(e,t)},goog.userAgent.isVersionOrHigherCache_={},goog.userAgent.isVersionOrHigher=function(e){return goog.userAgent.ASSUME_ANY_VERSION||goog.reflect.cache(goog.userAgent.isVersionOrHigherCache_,e,function(){return 0<=goog.string.compareVersions(goog.userAgent.VERSION,e)})},goog.userAgent.isVersion=goog.userAgent.isVersionOrHigher,goog.userAgent.isDocumentModeOrHigher=function(e){return Number(goog.userAgent.DOCUMENT_MODE)>=e},goog.userAgent.isDocumentMode=goog.userAgent.isDocumentModeOrHigher,goog.userAgent.DOCUMENT_MODE=function(){var e=goog.global.document,t=goog.userAgent.getDocumentMode_();if(e&&goog.userAgent.IE)return t||("CSS1Compat"==e.compatMode?parseInt(goog.userAgent.VERSION,10):5)}();var INLINE_ROW=-1;Blockly.BlockSvg=function(e){this.block_=e;var t={tabindex:0,"block-id":e.id};e.htmlId&&(t.id=e.htmlId),this.svgGroup_=Blockly.createSvgElement("g",t,null),this.initChildren(),this.forcedInputWidths={}},Blockly.BlockSvg.prototype.initChildren=function(){if(Blockly.typeHints){this.svgTypeHints_=Blockly.createSvgElement("g",{class:"blocklyTypeHint"},this.svgGroup_);for(var e=0;e<this.block_.inputList.length;e++)Blockly.createSvgElement("path",{filter:"url(#blocklyTypeHintFilter)"},this.svgTypeHints_)}this.svgPathDark_=Blockly.createSvgElement("path",{class:"blocklyPathDark",transform:"translate(1, 1)","fill-rule":"evenodd"},this.svgGroup_),this.svgPath_=Blockly.createSvgElement("path",{class:"blocklyPath","fill-rule":"evenodd"},this.svgGroup_),this.block_.getFillPattern()&&(this.svgPathFill_=Blockly.createSvgElement("path",{class:"blocklyPath"},this.svgGroup_)),this.svgPathLight_=Blockly.createSvgElement("path",{class:"blocklyPathLight"},this.svgGroup_),this.svgPath_.tooltip=this.block_,this.block_.blockSpace.blockSpaceEditor.disableTooltip||Blockly.Tooltip.bindMouseEvents(this.svgPath_),this.updateMovable()},Blockly.BlockSvg.DISABLED_COLOUR="#808080",Blockly.BlockSvg.prototype.init=function(){var e=this.block_;this.updateColour();for(var t,o=0;t=e.inputList[o];o++)t.init();e.mutator&&e.mutator.createIcon()},Blockly.BlockSvg.prototype.updateMovable=function(){this.block_.isMovable()?(Blockly.addClass_(this.svgGroup_,"blocklyDraggable"),Blockly.removeClass_(this.svgGroup_,"blocklyUndraggable")):(Blockly.removeClass_(this.svgGroup_,"blocklyDraggable"),Blockly.addClass_(this.svgGroup_,"blocklyUndraggable")),this.updateColour()},Blockly.BlockSvg.prototype.grayOut=function(e){e?(Blockly.addClass_(this.svgGroup_,"blocklyUndeletable"),Blockly.removeClass_(this.svgGroup_,"blocklyDeletable")):(Blockly.addClass_(this.svgGroup_,"blocklyDeletable"),Blockly.removeClass_(this.svgGroup_,"blocklyUndeletable")),this.updateColour()},Blockly.BlockSvg.prototype.getRootElement=function(){return this.svgGroup_};var BS=Blockly.BlockSvg;function brokenControlPointWorkaround(){return Blockly.BROKEN_CONTROL_POINTS?"c 0,5 0,-5 0,0":""}function oppositeIfRTL(e){return Blockly.RTL?-e:e}function thickenInlineRows(e){for(var t,o=0;t=e[o];o++)if(t.thicker=!1,t.type===INLINE_ROW)for(var n,i=0;n=t[i];i++)if(n.type===Blockly.INPUT_VALUE||n.type===Blockly.FUNCTIONAL_INPUT){t.height+=2*BS.INLINE_PADDING_Y,t.thicker=!0;break}}function inputRenderSize(e){var t=BS.MIN_BLOCK_Y,o=BS.TAB_WIDTH+BS.SEP_SPACE_X;if(e.type===Blockly.FUNCTIONAL_INPUT&&(o=BS.NOTCH_WIDTH+BS.SEP_SPACE_X),e.connection&&e.connection.targetConnection){var n=e.connection.targetBlock().getHeightWidth();t=Math.max(t,n.height),o=Math.max(o,n.width),t+=e.getStatementTrailingSpace()}return{width:o,height:t}}function inputTitleRenderSize(e,t){t=oppositeIfRTL(t);for(var o,n=0,i=0;o=e.titleRow[i];i++)(o=o.getSize()).width&&(t+=o.width+(0<i?BS.SEP_SPACE_X:0)),n=Math.max(n,o.height);return{width:t,height:n}}BS.SEP_SPACE_X=10,BS.SEP_SPACE_Y=10,BS.INLINE_PADDING_Y=5,BS.MIN_BLOCK_Y=25,BS.TAB_HEIGHT=20,BS.TAB_WIDTH=8,BS.NOTCH_WIDTH=30,BS.CORNER_RADIUS=8,BS.TITLE_HEIGHT=18,BS.DISTANCE_45_INSIDE=(1-Math.SQRT1_2)*(BS.CORNER_RADIUS-1)+1,BS.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(BS.CORNER_RADIUS+1)-1,BS.NOTCH_PATH_WIDTH=15,BS.JAGGED_TEETH="l 8,0 0,4 8,4 -16,8 8,4",BS.JAGGED_TEETH_HEIGHT=20,BS.TAB_PATH_DOWN="v 5 c 0,10 -"+BS.TAB_WIDTH+",-8 -"+BS.TAB_WIDTH+",7.5 s "+BS.TAB_WIDTH+",-2.5 "+BS.TAB_WIDTH+",7.5",BS.TAB_PATH_DOWN_HIGHLIGHT="m -4.2,"+(BS.TAB_HEIGHT-.4)+" l "+.42*BS.TAB_WIDTH+",-1.8",BS.TAB_PATH_DOWN_HIGHLIGHT_RTL="v 6.5 m -"+.98*BS.TAB_WIDTH+",2.5 q -"+.05*BS.TAB_WIDTH+",10 "+.27*BS.TAB_WIDTH+",10 m "+.71*BS.TAB_WIDTH+",-2.5 v 3.5",BS.TAB_PATH_UP="V "+BS.TAB_HEIGHT+"c 0,-10 -"+BS.TAB_WIDTH+",8 -"+BS.TAB_WIDTH+",-7.5 s "+BS.TAB_WIDTH+",2.5 "+BS.TAB_WIDTH+",-7.5",BS.TAB_PATH_UP_HIGHLIGHT="V "+(BS.TAB_HEIGHT-1)+" m "+-.92*BS.TAB_WIDTH+",-1 q "+-.19*BS.TAB_WIDTH+",-5.5 0,-11 m "+.92*BS.TAB_WIDTH+",1 V 1 H 2",BS.TAB_PATH_UP_HIGHLIGHT_RTL="M "+-.3*BS.TAB_WIDTH+",8.9 l "+-.45*BS.TAB_WIDTH+",-2.1",BS.ANGLE_TAB_PATH_DOWN="v "+BS.TAB_HEIGHT/3+" l "+-1*BS.TAB_WIDTH+" "+BS.TAB_HEIGHT/3+" l "+BS.TAB_WIDTH+" "+BS.TAB_HEIGHT/3,BS.ANGLE_TAB_PATH_DOWN_HIGHLIGHT_RTL="v 5.5 m -"+(BS.TAB_WIDTH-1)+","+(BS.TAB_HEIGHT/3+1)+" l "+(BS.TAB_WIDTH-1)+","+BS.TAB_HEIGHT/3,BS.ANGLE_TAB_PATH_UP="V"+BS.TAB_HEIGHT+" L"+-1*BS.TAB_WIDTH+", "+.66*BS.TAB_HEIGHT+" L0, "+.33*BS.TAB_HEIGHT,BS.ANGLE_TAB_PATH_UP_HIGHLIGHT="V "+(BS.TAB_HEIGHT+2)+" M "+(-1*BS.TAB_WIDTH+1)+", "+.66*BS.TAB_HEIGHT+" L 1, "+(.33*BS.TAB_HEIGHT+1)+" V 1",BS.SQUARE_TAB_PATH_DOWN="v 7 h "+-1*BS.TAB_WIDTH+" v 11 h "+BS.TAB_WIDTH+" v 2",BS.SQUARE_TAB_PATH_DOWN_HIGHLIGHT="m 0 18.5 h "+-.85*BS.TAB_WIDTH,BS.SQUARE_TAB_PATH_DOWN_HIGHLIGHT_RTL="v 6 m "+-1*BS.TAB_WIDTH+" 1 v 11 h "+BS.TAB_WIDTH+" v 2",BS.SQUARE_TAB_PATH_UP="V 17 h "+-1*BS.TAB_WIDTH+" v -10 h "+BS.TAB_WIDTH,BS.SQUARE_TAB_PATH_UP_HIGHLIGHT="V 18 m "+-1*BS.TAB_WIDTH+" -1.5 v -9 h "+BS.TAB_WIDTH+" v -6.5",BS.SQUARE_TAB_PATH_UP_HIGHLIGHT_RTL="M -1.5 7.5 h "+-.8*BS.TAB_WIDTH,BS.ROUNDED_TAB_PATH_DOWN="v 5.5 c "+-.5*BS.TAB_WIDTH+" 0, "+-1*BS.TAB_WIDTH+" 2, "+-1*BS.TAB_WIDTH+" 7 c 0 5, "+.5*BS.TAB_WIDTH+" 7, "+BS.TAB_WIDTH+" 7 v 0.5",BS.ROUNDED_TAB_PATH_DOWN_HIGHLIGHT="m 0 20 c -2 0, -4 -0.5, -4 -0.5",BS.ROUNDED_TAB_PATH_DOWN_HIGHLIGHT_RTL="v 4.5 m -6 2.5 c -2 0, -2 5, -2 5.5 c 0 5, "+.5*BS.TAB_WIDTH+" 7, "+BS.TAB_WIDTH+" 7 v 1",BS.ROUNDED_TAB_PATH_UP="V 19 c "+-.5*BS.TAB_WIDTH+" 0, "+-1*BS.TAB_WIDTH+" 0, "+-1*BS.TAB_WIDTH+" -6 c 0 -6, "+.5*BS.TAB_WIDTH+" -6, "+BS.TAB_WIDTH+" -6 ",BS.ROUNDED_TAB_PATH_UP_HIGHLIGHT="V 19.5 m -6 -2 c -1 -1, -2 -2, -2 -4.5 c 0 -6, "+.5*BS.TAB_WIDTH+" -6, "+BS.TAB_WIDTH+" -6 v -6",BS.ROUNDED_TAB_PATH_UP_HIGHLIGHT_RTL="M -0.5 7.5 c -2 0, -4 0.5, -4 0.5",BS.TAB_PATHS_BY_SHAPE={standard:{TAB_PATH_DOWN:BS.TAB_PATH_DOWN,TAB_PATH_DOWN_HIGHLIGHT:BS.TAB_PATH_DOWN_HIGHLIGHT,TAB_PATH_DOWN_HIGHLIGHT_RTL:BS.TAB_PATH_DOWN_HIGHLIGHT_RTL,TAB_PATH_UP:BS.TAB_PATH_UP,TAB_PATH_UP_HIGHLIGHT:BS.TAB_PATH_UP_HIGHLIGHT,TAB_PATH_UP_HIGHLIGHT_RTL:BS.TAB_PATH_UP_HIGHLIGHT_RTL},angle:{TAB_PATH_DOWN:BS.ANGLE_TAB_PATH_DOWN,TAB_PATH_DOWN_HIGHLIGHT:"",TAB_PATH_DOWN_HIGHLIGHT_RTL:BS.ANGLE_TAB_PATH_DOWN_HIGHLIGHT_RTL,TAB_PATH_UP:BS.ANGLE_TAB_PATH_UP,TAB_PATH_UP_HIGHLIGHT:BS.ANGLE_TAB_PATH_UP_HIGHLIGHT,TAB_PATH_UP_HIGHLIGHT_RTL:""},square:{TAB_PATH_DOWN:BS.SQUARE_TAB_PATH_DOWN,TAB_PATH_DOWN_HIGHLIGHT:BS.SQUARE_TAB_PATH_DOWN_HIGHLIGHT,TAB_PATH_DOWN_HIGHLIGHT_RTL:BS.SQUARE_TAB_PATH_DOWN_HIGHLIGHT_RTL,TAB_PATH_UP:BS.SQUARE_TAB_PATH_UP,TAB_PATH_UP_HIGHLIGHT:BS.SQUARE_TAB_PATH_UP_HIGHLIGHT,TAB_PATH_UP_HIGHLIGHT_RTL:BS.SQUARE_TAB_PATH_UP_HIGHLIGHT_RTL},rounded:{TAB_PATH_DOWN:BS.ROUNDED_TAB_PATH_DOWN,TAB_PATH_DOWN_HIGHLIGHT:BS.ROUNDED_TAB_PATH_DOWN_HIGHLIGHT,TAB_PATH_DOWN_HIGHLIGHT_RTL:BS.ROUNDED_TAB_PATH_DOWN_HIGHLIGHT_RTL,TAB_PATH_UP:BS.ROUNDED_TAB_PATH_UP,TAB_PATH_UP_HIGHLIGHT:BS.ROUNDED_TAB_PATH_UP_HIGHLIGHT,TAB_PATH_UP_HIGHLIGHT_RTL:BS.ROUNDED_TAB_PATH_UP_HIGHLIGHT_RTL}},BS.TOP_LEFT_CORNER_START="m 0,"+BS.CORNER_RADIUS,BS.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL="m "+BS.DISTANCE_45_INSIDE+","+BS.DISTANCE_45_INSIDE,BS.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR="m 1,"+(BS.CORNER_RADIUS-1),BS.TOP_LEFT_CORNER="A "+BS.CORNER_RADIUS+","+BS.CORNER_RADIUS+" 0 0,1 "+BS.CORNER_RADIUS+",0",BS.TOP_LEFT_CORNER_HIGHLIGHT="A "+(BS.CORNER_RADIUS-1)+","+(BS.CORNER_RADIUS-1)+" 0 0,1 "+BS.CORNER_RADIUS+",1",BS.INNER_BOTTOM_LEFT_CORNER="a "+BS.CORNER_RADIUS+","+BS.CORNER_RADIUS+" 0 0,0 "+BS.CORNER_RADIUS+","+BS.CORNER_RADIUS,BS.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL="a "+(BS.CORNER_RADIUS+1)+","+(BS.CORNER_RADIUS+1)+" 0 0,0 "+(-BS.DISTANCE_45_OUTSIDE-1)+","+(BS.CORNER_RADIUS-BS.DISTANCE_45_OUTSIDE),BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL="a "+(BS.CORNER_RADIUS+1)+","+(BS.CORNER_RADIUS+1)+" 0 0,0 "+(BS.CORNER_RADIUS+1)+","+(BS.CORNER_RADIUS+1),BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR="a "+(BS.CORNER_RADIUS+1)+","+(BS.CORNER_RADIUS+1)+" 0 0,0 "+(BS.CORNER_RADIUS-BS.DISTANCE_45_OUTSIDE)+","+(BS.DISTANCE_45_OUTSIDE+1),Blockly.BlockSvg.prototype.getPadding=function(){return this.unusedSvg_?this.unusedSvg_.getPadding():{top:0,right:0,bottom:0,left:0}},Blockly.BlockSvg.prototype.dispose=function(){goog.dom.removeNode(this.svgGroup_),this.svgPathDark_=this.svgPathLight_=this.svgTypeHints_=this.svgPathFill_=this.svgPath_=this.svgGroup_=null,this.removeUnusedFrame(),this.block_=null},Blockly.BlockSvg.prototype.disposeUiEffect=function(){Blockly.playAudio("delete");var e=this.block_.blockSpace.blockSpaceEditor.svg_,t=Blockly.getSvgXY_(this.svgGroup_,e),o=this.svgGroup_.cloneNode(!0);o.translateX_=t.x,o.translateY_=t.y,o.setAttribute("transform","translate("+o.translateX_+","+o.translateY_+")"),e.appendChild(o),0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")?(o.style.display="inline",o.bBox_={x:o.getBBox().x,y:o.getBBox().y,width:o.scrollWidth,height:o.scrollHeight}):o.bBox_=o.getBBox(),o.startDate_=new Date,Blockly.BlockSvg.disposeUiStep_(o)},Blockly.BlockSvg.disposeUiStep_=function(e){var t=(new Date-e.startDate_)/150;if(1<t)goog.dom.removeNode(e);else{var o=e.translateX_+oppositeIfRTL(e.bBox_.width/2*t);e.setAttribute("transform","translate("+o+", "+(e.translateY_+e.bBox_.height*t)+") scale("+(1-t)+")"),window.setTimeout(function(){Blockly.BlockSvg.disposeUiStep_(e)},10)}},Blockly.BlockSvg.prototype.connectionUiEffect=function(){Blockly.playAudio("click");var e=Blockly.getSvgXY_(this.svgGroup_,this.block_.blockSpace.blockSpaceEditor.svg_);this.block_.outputConnection?(e.x+=oppositeIfRTL(-3),e.y+=13):this.block_.previousConnection&&(e.x+=oppositeIfRTL(23),e.y+=3),(e=Blockly.createSvgElement("circle",{cx:e.x,cy:e.y,r:0,fill:"none",stroke:"#888","stroke-width":10},this.block_.blockSpace.blockSpaceEditor.svg_)).startDate_=new Date,Blockly.BlockSvg.connectionUiStep_(e)},Blockly.BlockSvg.connectionUiStep_=function(e){var t=(new Date-e.startDate_)/150;1<t?goog.dom.removeNode(e):(e.setAttribute("r",25*t),e.style.opacity=1-t,window.setTimeout(function(){Blockly.BlockSvg.connectionUiStep_(e)},10))},Blockly.BlockSvg.prototype.updateColour=function(){if(!this.block_.disabled){var e=this.block_.shouldBeGrayedOut()?BS.DISABLED_COLOUR:this.block_.getHexColour();this.updateToColour_(e)}},Blockly.BlockSvg.prototype.updateToColour_=function(e){var t=goog.color.hexToRgb(e),o=goog.color.lighten(t,.3);t=goog.color.darken(t,.4),this.svgPathLight_.setAttribute("stroke",goog.color.rgbArrayToHex(o)),this.svgPathDark_.setAttribute("fill",goog.color.rgbArrayToHex(t)),this.svgPath_.setAttribute("fill",e),(e=this.block_.getFillPattern())&&this.svgPathFill_.setAttribute("fill","url(#"+e+")")},Blockly.BlockSvg.prototype.updateDisabled=function(){this.block_.disabled||this.block_.getInheritedDisabled()?(Blockly.addClass_(this.svgGroup_,"blocklyDisabled"),this.svgPath_.setAttribute("fill","url(#blocklyDisabledPattern)")):(Blockly.removeClass_(this.svgGroup_,"blocklyDisabled"),this.updateColour());for(var e,t=this.block_.getChildren(),o=0;e=t[o];o++)e.svg_.updateDisabled()},Blockly.BlockSvg.prototype.updateLimit=function(e){this.limitGroup_||(this.limitGroup_=Blockly.createSvgElement("g",{class:"blocklyLimit",y:-3},this.svgGroup_),this.limitRect_=Blockly.createSvgElement("rect",{height:18,width:18,x:-9,y:-9,rx:9,ry:9},this.limitGroup_),this.limitText_=Blockly.createSvgElement("text",{class:"blocklyText","dominant-baseline":"central","text-anchor":"middle"},this.limitGroup_)),0>e?(this.limitText_.textContent="!",Blockly.addClass_(this.limitGroup_,"overLimit")):(this.limitText_.textContent=e,Blockly.removeClass_(this.limitGroup_,"overLimit"));try{var t=this.limitText_.getBBox?Math.ceil(this.limitText_.getBBox().width):9}catch(e){t=9}e=Math.max(t+9,18),this.limitRect_.setAttribute("width",e),this.limitText_.setAttribute("x",Math.round(.5*e)-9),(Blockly.isMsie()||Blockly.isTrident())&&this.limitText_.setAttribute("y",4.5)},Blockly.BlockSvg.prototype.addSelect=function(e){Blockly.addClass_(this.svgGroup_,"blocklySelected"),e&&this.svgGroup_.parentNode.appendChild(this.svgGroup_)},Blockly.BlockSvg.prototype.addSelectNoMove=function(){Blockly.elementHasClass_(this.svgGroup_,"blocklyDraggable")&&Blockly.addClass_(this.svgGroup_,"blocklySelected")},Blockly.BlockSvg.prototype.removeSelect=function(){Blockly.removeClass_(this.svgGroup_,"blocklySelected")},Blockly.BlockSvg.prototype.addDragging=function(){Blockly.addClass_(this.svgGroup_,"blocklyDragging")},Blockly.BlockSvg.prototype.removeDragging=function(){Blockly.removeClass_(this.svgGroup_,"blocklyDragging")},Blockly.BlockSvg.prototype.addSpotlight=function(){Blockly.addClass_(this.svgGroup_,"blocklySpotlight")},Blockly.BlockSvg.prototype.removeSpotlight=function(){Blockly.removeClass_(this.svgGroup_,"blocklySpotlight")},Blockly.BlockSvg.prototype.render=function(e){this.block_.rendered=!0;for(var t=oppositeIfRTL(BS.SEP_SPACE_X),o=this.block_.getIcons(),n=0;n<o.length;n++)t=o[n].renderIcon(t);t-=oppositeIfRTL(BS.SEP_SPACE_X),o=this.renderCompute_(t),this.renderDraw_(t,o),e||((e=this.block_.getParent())?e.render():Blockly.fireUiEvent(window,"resize")),this.removeUnusedFrame()},Blockly.BlockSvg.prototype.renderTitles_=function(e,t,o){for(var n,i=t,r=0;n=e[r];r++){var l=n.getSize(),s=t;Blockly.RTL&&(s=-(t+l.width)),n.getRootElement().setAttribute("transform","translate("+s+", "+(o+n.getBufferY())+")"),l.width&&(t+=l.width+BS.SEP_SPACE_X)}return t-i},Blockly.BlockSvg.prototype.renderCompute_=function(e){var t=this.block_.inputList,o=[];o.rightEdge=e+2*BS.SEP_SPACE_X,(this.block_.previousConnection||this.block_.nextConnection)&&(o.rightEdge=Math.max(o.rightEdge,BS.NOTCH_WIDTH+BS.SEP_SPACE_X));for(var n,i,r=0,l=0,s=!1,a=!1,g=!1,c=0;i=t[c];c++)if(i.isVisible()){0!==c&&i.isInline()||((n=[]).type=i.type,n.height=0,o.push(n)),(0<n.length||i.isInline())&&(n.type=INLINE_ROW),0===n.length&&i.type===Blockly.FUNCTIONAL_INPUT&&(n.type=INLINE_ROW),n.push(i);var u=inputRenderSize(i);i.renderHeight=u.height,i.renderWidth=u.width,n.height=Math.max(n.height,i.renderHeight),u=inputTitleRenderSize(i,0===c?e:0),i.titleWidth=u.width,n.height=Math.max(n.height,u.height),n.type!=INLINE_ROW&&(n.type==Blockly.NEXT_STATEMENT?(a=!0,l=Math.max(l,i.titleWidth)):(n.type===Blockly.INPUT_VALUE||n.type===Blockly.FUNCTIONAL_INPUT?s=!0:n.type===Blockly.DUMMY_INPUT&&(g=!0),r=Math.max(r,i.titleWidth)))}for(thickenInlineRows(o),o.statementEdge=2*BS.SEP_SPACE_X+l,a&&(o.rightEdge=Math.max(o.rightEdge,o.statementEdge+BS.NOTCH_WIDTH)),s?o.rightEdge=Math.max(o.rightEdge,r+2*BS.SEP_SPACE_X+BS.TAB_WIDTH):g&&(o.rightEdge=Math.max(o.rightEdge,r+2*BS.SEP_SPACE_X)),o.hasValue=s,o.hasStatement=a,o.hasDummy=g,o.rightEdgeWithoutInline=o.rightEdge,c=0;n=o[c];c++)n.type===INLINE_ROW&&(o.rightEdge=Math.max(o.rightEdge,this.widthInlineRow(n)));return this.block_.miniFlyout&&this.block_.miniFlyout.width_&&(o.rightEdge=Math.max(o.rightEdge,this.block_.miniFlyout.minFlyoutWidth_)),o},Blockly.BlockSvg.prototype.widthInlineRow=function(e){for(var t,o=BS.SEP_SPACE_X,n=0;t=e[n];n++)o+=BS.SEP_SPACE_X+this.inputWidthToOccupy_(t);return o},Blockly.BlockSvg.prototype.renderDraw_=function(e,t){if(this.block_.outputConnection)this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0;else{if(this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!1,this.block_.previousConnection){var o=this.block_.previousConnection.targetBlock();o&&o.nextConnection&&o.nextConnection.targetConnection==this.block_.previousConnection&&(this.squareTopLeftCorner_=!0)}this.block_.nextConnection&&(o=this.block_.nextConnection.targetBlock())&&o.previousConnection&&o.previousConnection.targetConnection==this.block_.nextConnection&&(this.squareBottomLeftCorner_=!0)}for(this.block_.previousConnection&&this.block_.previousConnection.type===Blockly.FUNCTIONAL_OUTPUT&&(this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0),o=0;o<this.block_.inputList.length;o++)this.block_.inputList[o].type===Blockly.FUNCTIONAL_INPUT&&(this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0);var n=this.block_.getRelativeToSurfaceXY();if(o={core:[],inline:[],highlight:[],highlightInline:[],curX:e,curY:0},this.renderDrawTop_(o,t.rightEdge,n),this.renderDrawRight_(o,n,t,e),this.renderDrawBottom_(o,n),this.renderDrawLeft_(o),e=o.core.join(" ")+"\n"+o.inline.join(" "),this.svgPath_.setAttribute("d",e),this.svgPathFill_&&this.svgPathFill_.setAttribute("d",e),this.svgTypeHints_){t=this.svgTypeHints_,n=Math.max(this.block_.inputList.length,t.childNodes.length);for(var i=0;i<n;i++){var r=t.childNodes[i]||Blockly.createSvgElement("path",{filter:"url(#blocklyTypeHintFilter)"},t),l=this.block_.inputList[i];l&&l.connection&&(l=l.connection.getPathInfo())&&l.color?(r.setAttribute("d",l.steps),r.setAttribute("transform",l.transform),r.setAttribute("stroke",Blockly.makeColour.apply(null,l.color))):r.setAttribute("d","")}}this.svgPathDark_.setAttribute("d",e),e=o.highlight.join(" ")+"\n"+o.highlightInline.join(" "),this.svgPathLight_.setAttribute("d",e),Blockly.RTL&&(this.svgPath_.setAttribute("transform","scale(-1 1)"),this.svgPathLight_.setAttribute("transform","scale(-1 1)"),this.svgPathDark_.setAttribute("transform","translate(1,1) scale(-1 1)"))},Blockly.BlockSvg.prototype.renderDrawTop_=function(e,t,o){if(this.squareTopLeftCorner_?(e.core.push("m 0,0"),e.highlight.push("m 1,1")):(e.core.push(BS.TOP_LEFT_CORNER_START),e.highlight.push(Blockly.RTL?BS.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL:BS.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR),e.core.push(BS.TOP_LEFT_CORNER),e.highlight.push(BS.TOP_LEFT_CORNER_HIGHLIGHT)),e.core.push(brokenControlPointWorkaround()),this.block_.previousConnection){var n=this.block_.previousConnection.getNotchPaths();e.core.push("H",BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH),e.highlight.push("H",BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH),e.core.push(n.left),e.highlight.push(n.leftHighlight),n=o.x+oppositeIfRTL(BS.NOTCH_WIDTH),this.block_.previousConnection.moveTo(n,o.y)}e.core.push("H",t),e.highlight.push("H",t+(Blockly.RTL?-1:0)),e.curX=t},Blockly.BlockSvg.prototype.renderDrawRight_=function(e,t,o,n){for(var i,r=0;i=o[r];r++)e.curX=BS.SEP_SPACE_X,0===r&&(e.curX+=oppositeIfRTL(n)),e.highlight.push("M",o.rightEdge-1+","+(e.curY+1)),this.block_.isCollapsed()?this.renderDrawRightCollapsed_(e,i):i.type===INLINE_ROW?this.renderDrawRightInline_(e,o,r,t):i.type===Blockly.INPUT_VALUE?this.renderDrawRightInputValue_(e,o,r,t):i.type===Blockly.DUMMY_INPUT?this.renderDrawRightDummyInput_(e,o,r):i.type===Blockly.NEXT_STATEMENT&&this.renderDrawRightNextStatement_(e,o,r,t),e.curY+=i.height;this.block_.miniFlyout&&(this.block_.isMiniFlyoutOpen?(this.block_.miniFlyout.customMetrics=function(){return{absoluteTop:e.curY-4,absoluteLeft:Blockly.RTL?-e.curX:5,viewWidth:e.curX-10}},this.block_.miniFlyout.softShow(),this.renderDrawTray_(e,this.block_.miniFlyout.getHeight()+7)):this.block_.miniFlyout.softHide()),o.length||(e.curY=BS.MIN_BLOCK_Y,e.core.push("V",e.curY),Blockly.RTL&&e.highlight.push("V",e.curY-1))},Blockly.BlockSvg.prototype.renderDrawTray_=function(e,t){void 0===t&&(t=50),e.core.push("v",t),Blockly.RTL?e.highlight.push("v",t):e.highlight.push("m 0",t),e.curY+=t},Blockly.BlockSvg.prototype.renderDrawRightCollapsed_=function(e,t){e.curX+=this.renderTitles_(t[0].titleRow,e.curX,e.curY+BS.TITLE_HEIGHT),e.core.push(BS.JAGGED_TEETH),Blockly.RTL?e.highlight.push("l 8,0 0,3.8 7,3.2 m -14.5,9 l 8,4"):e.highlight.push("h 8"),t=t.height-BS.JAGGED_TEETH_HEIGHT,e.core.push("v",t),Blockly.RTL&&e.highlight.push("v",t-2)},Blockly.BlockSvg.prototype.renderDrawRightInputValue_=function(e,t,o,n){var i=t[o];o=i[0];var r=e.curX,l=e.curY+BS.TITLE_HEIGHT;if(o.align!=Blockly.ALIGN_LEFT){var s=t.rightEdge-o.titleWidth-BS.TAB_WIDTH-2*BS.SEP_SPACE_X;o.align===Blockly.ALIGN_RIGHT?r+=s:o.align===Blockly.ALIGN_CENTRE&&(r+=(s+r)/2)}e.curX+=this.renderTitles_(o.titleRow,r,l),r=BS.TAB_PATHS_BY_SHAPE[o.connection.getTabShape()],e.core.push(r.TAB_PATH_DOWN),Blockly.RTL?(e.highlight.push(r.TAB_PATH_DOWN_HIGHLIGHT_RTL),e.highlight.push("v",i.height-BS.TAB_HEIGHT-2)):(e.highlight.push("M",t.rightEdge+","+e.curY),e.highlight.push(r.TAB_PATH_DOWN_HIGHLIGHT)),e.core.push("v",i.height-BS.TAB_HEIGHT),t=n.x+oppositeIfRTL(t.rightEdge+1),o.connection.moveTo(t,n.y+e.curY),o.connection.targetConnection&&o.connection.tighten_()},Blockly.BlockSvg.prototype.renderDrawRightDummyInput_=function(e,t,o){var n=(o=t[o])[0],i=e.curX,r=e.curY+BS.TITLE_HEIGHT;if(n.align===Blockly.ALIGN_RIGHT){var l=t.rightEdge-n.titleWidth-2*BS.SEP_SPACE_X;t.hasValue&&(l-=BS.TAB_WIDTH),i+=l}n.align===Blockly.ALIGN_CENTRE&&(i=(t.rightEdge-n.titleWidth)/2),this.renderTitles_(n.titleRow,i,r),e.core.push("v",o.height),Blockly.RTL&&e.highlight.push("v",o.height-2)},Blockly.BlockSvg.prototype.renderDrawRightNextStatement_=function(e,t,o,n){var i=t[o],r=i[0];0===o&&(e.core.push("v",BS.SEP_SPACE_Y),Blockly.RTL&&e.highlight.push("v",BS.SEP_SPACE_Y-1),e.curY+=BS.SEP_SPACE_Y);var l=e.curX,s=e.curY+BS.TITLE_HEIGHT;if(r.align!=Blockly.ALIGN_LEFT){var a=t.statementEdge-r.titleWidth-2*BS.SEP_SPACE_X;r.align==Blockly.ALIGN_RIGHT?l+=a:r.align==Blockly.ALIGN_CENTRE&&(l+=(a+l)/2)}a=r.connection.getNotchPaths(),this.renderTitles_(r.titleRow,l,s),e.curX=t.statementEdge+BS.NOTCH_WIDTH,e.core.push("H",e.curX),e.core.push(this.innerTopLeftCorner(a.right)),e.core.push("v",i.height-2*BS.CORNER_RADIUS),e.core.push(BS.INNER_BOTTOM_LEFT_CORNER),e.core.push("H",t.rightEdgeWithoutInline),Blockly.RTL?(e.highlight.push("M",e.curX-BS.NOTCH_WIDTH+BS.DISTANCE_45_OUTSIDE+","+(e.curY+BS.DISTANCE_45_OUTSIDE)),e.highlight.push(BS.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),e.highlight.push("v",i.height-2*BS.CORNER_RADIUS),e.highlight.push(BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL),e.highlight.push("H",t.rightEdgeWithoutInline-1)):(e.highlight.push("M",e.curX-BS.NOTCH_WIDTH+BS.DISTANCE_45_OUTSIDE+","+(e.curY+i.height-BS.DISTANCE_45_OUTSIDE)),e.highlight.push(BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR),e.highlight.push("H",t.rightEdgeWithoutInline)),i=n.x+oppositeIfRTL(e.curX),r.connection.moveTo(i,n.y+e.curY+1),r.connection.targetConnection&&r.connection.tighten_(),o!==t.length-1&&t[o+1].type!==Blockly.NEXT_STATEMENT||(e.core.push("v",BS.SEP_SPACE_Y),Blockly.RTL&&e.highlight.push("v",BS.SEP_SPACE_Y-1),e.curY+=BS.SEP_SPACE_Y)},Blockly.BlockSvg.prototype.renderDrawRightInline_=function(e,t,o,n){var i,r=!1,l=(o=t[o])[0].align;if(o[0].type===Blockly.FUNCTIONAL_INPUT){var s=BS.SEP_SPACE_X*(o.length-1);o.forEach(function(e){s+=this.inputWidthToOccupy_(e)},this),t.rightEdge>s&&l===Blockly.ALIGN_CENTRE&&(e.curX=(t.rightEdge-s)/2)}for(l=0;i=o[l];l++){var a=e.curX,g=e.curY+BS.TITLE_HEIGHT;o.thicker&&(g+=BS.INLINE_PADDING_Y),e.curX+=this.renderTitles_(i.titleRow,a,g),i.type===Blockly.INPUT_VALUE?(e.curX+=i.renderWidth+BS.SEP_SPACE_X,e.inline.push("M",e.curX-BS.SEP_SPACE_X+","+(e.curY+BS.INLINE_PADDING_Y)),e.inline.push("h",BS.TAB_WIDTH-i.renderWidth),a=BS.TAB_PATHS_BY_SHAPE[i.connection.getTabShape()],e.inline.push(a.TAB_PATH_DOWN),e.inline.push("v",i.renderHeight-BS.TAB_HEIGHT),e.inline.push("h",i.renderWidth-BS.TAB_WIDTH),e.inline.push("z"),Blockly.RTL?(e.highlightInline.push("M",e.curX-BS.SEP_SPACE_X+BS.TAB_WIDTH-i.renderWidth-1+","+(e.curY+BS.INLINE_PADDING_Y+1)),e.highlightInline.push(a.TAB_PATH_DOWN_HIGHLIGHT_RTL),e.highlightInline.push("v",i.renderHeight-BS.TAB_HEIGHT),e.highlightInline.push("h",i.renderWidth-BS.TAB_WIDTH)):(e.highlightInline.push("M",e.curX-BS.SEP_SPACE_X+1+","+(e.curY+BS.INLINE_PADDING_Y+1)),e.highlightInline.push("v",i.renderHeight),e.highlightInline.push("h",BS.TAB_WIDTH-i.renderWidth),e.highlightInline.push("M",e.curX-i.renderWidth-BS.SEP_SPACE_X+BS.TAB_WIDTH+","+(e.curY+BS.INLINE_PADDING_Y)),e.highlightInline.push(a.TAB_PATH_DOWN_HIGHLIGHT)),a=n.x+oppositeIfRTL(e.curX+BS.TAB_WIDTH-BS.SEP_SPACE_X-i.renderWidth+1),g=n.y+e.curY+BS.INLINE_PADDING_Y,i.connection.moveTo(a,g),i.connection.targetConnection&&i.connection.tighten_()):i.type===Blockly.FUNCTIONAL_INPUT?(r=!0,this.renderDrawRightInlineFunctional_(e,i,n)):i.type!=Blockly.DUMMY_INPUT&&(e.curX+=i.renderWidth+BS.SEP_SPACE_X)}e.curX=Math.max(e.curX,t.rightEdge),e.core.push("H",e.curX),r||e.highlight.push("H",e.curX+(Blockly.RTL?-1:0)),e.core.push("v",o.height),Blockly.RTL&&e.highlight.push("v",o.height-2)},Blockly.BlockSvg.prototype.inputWidthToOccupy_=function(e){return e.renderWidth+(e.extraSpace||0)},Blockly.BlockSvg.prototype.renderDrawRightInlineFunctional_=function(){throw"Only supported for functional blocks"},Blockly.BlockSvg.prototype.renderDrawBottom_=function(e,t){if(e.core.push(brokenControlPointWorkaround()),this.block_.nextConnection){var o=this.block_.nextConnection.getNotchPaths();e.core.push("H",BS.NOTCH_WIDTH+" "+o.right),o=t.x+oppositeIfRTL(BS.NOTCH_WIDTH),this.block_.nextConnection.moveTo(o,t.y+e.curY+1),this.block_.nextConnection.targetConnection&&this.block_.nextConnection.tighten_()}this.squareBottomLeftCorner_?(e.core.push("H 0"),Blockly.RTL||e.highlight.push("M","1,"+e.curY)):(e.core.push("H",BS.CORNER_RADIUS),e.core.push("a",BS.CORNER_RADIUS+","+BS.CORNER_RADIUS+" 0 0,1 -"+BS.CORNER_RADIUS+",-"+BS.CORNER_RADIUS),Blockly.RTL||(e.highlight.push("M",BS.DISTANCE_45_INSIDE+","+(e.curY-BS.DISTANCE_45_INSIDE)),e.highlight.push("A",BS.CORNER_RADIUS-1+","+(BS.CORNER_RADIUS-1)+" 0 0,1 1,"+(e.curY-BS.CORNER_RADIUS))))},Blockly.BlockSvg.prototype.renderDrawLeft_=function(e){if(this.block_.outputConnection){var t=BS.TAB_PATHS_BY_SHAPE[this.block_.outputConnection.getTabShape()];e.core.push(t.TAB_PATH_UP),Blockly.RTL?e.highlight.push(t.TAB_PATH_UP_HIGHLIGHT_RTL):e.highlight.push(t.TAB_PATH_UP_HIGHLIGHT)}else Blockly.RTL||e.highlight.push("V",this.squareTopLeftCorner_?1:BS.CORNER_RADIUS);e.core.push("z")},Blockly.BlockSvg.prototype.setVisible=function(e){this.svgGroup_.style.display=e?"":"none"},Blockly.BlockSvg.prototype.innerTopLeftCorner=function(e){return e+" h -"+(BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH-BS.CORNER_RADIUS)+" a "+BS.CORNER_RADIUS+","+BS.CORNER_RADIUS+" 0 0,0 -"+BS.CORNER_RADIUS+","+BS.CORNER_RADIUS},Blockly.BlockSvg.prototype.isUnused=function(){return Blockly.elementHasClass_(this.svgGroup_,"blocklyUnused")},Blockly.BlockSvg.prototype.setIsUnused=function(e){e?Blockly.addClass_(this.svgGroup_,"blocklyUnused"):Blockly.removeClass_(this.svgGroup_,"blocklyUnused"),this.removeUnusedFrame()},Blockly.BlockSvg.prototype.addUnusedFrame=function(){this.unusedSvg_||(this.unusedSvg_=new Blockly.BlockSvgUnused(this)),this.unusedSvg_.render(this.svgGroup_)},Blockly.BlockSvg.prototype.removeUnusedFrame=function(){this.unusedSvg_&&(this.unusedSvg_.dispose(),this.unusedSvg_=null)},FRAME_MARGIN_SIDE=15,FRAME_MARGIN_TOP=10,FRAME_MARGIN_BOTTOM=5,FRAME_HEADER_HEIGHT=25,Blockly.BlockSvgFramed=function(e){Blockly.BlockSvg.call(this,e)},goog.inherits(Blockly.BlockSvgFramed,Blockly.BlockSvg),Blockly.BlockSvgFramed.prototype.initChildren=function(){var e=Blockly.createSvgElement("clipPath",{id:"frameClip"+this.block_.id},this.svgGroup_);this.frameClipRect_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),height:FRAME_HEADER_HEIGHT},e),this.frameBase_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),fill:"#dddddd",stroke:"#aaaaaa",rx:15,ry:15},this.svgGroup_),this.frameHeader_=Blockly.createSvgElement("rect",{x:-FRAME_MARGIN_SIDE,y:-(FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT),fill:"#aaaaaa",rx:15,ry:15,"clip-path":"url(#frameClip"+this.block_.id+")"},this.svgGroup_),this.frameText_=Blockly.createSvgElement("text",{class:"blocklyText",style:"font-size: 12pt"},this.svgGroup_),this.frameText_.appendChild(document.createTextNode(Blockly.Msg.FUNCTION_HEADER)),Blockly.BlockSvgFramed.superClass_.initChildren.call(this)},Blockly.BlockSvgFramed.prototype.getPadding=function(){return{top:FRAME_MARGIN_TOP+FRAME_HEADER_HEIGHT,right:FRAME_MARGIN_SIDE,bottom:FRAME_MARGIN_BOTTOM,left:FRAME_MARGIN_SIDE}},Blockly.BlockSvgFramed.prototype.renderDraw_=function(e,t){Blockly.BlockSvgFramed.superClass_.renderDraw_.call(this,e,t),e=(t=this.svgPath_.getBoundingClientRect()).width+2*FRAME_MARGIN_SIDE,t=t.height+FRAME_MARGIN_TOP+FRAME_MARGIN_BOTTOM+FRAME_HEADER_HEIGHT,this.frameClipRect_.setAttribute("width",e),this.frameBase_.setAttribute("width",e),this.frameBase_.setAttribute("height",t),this.frameHeader_.setAttribute("width",e),this.frameHeader_.setAttribute("height",t),Blockly.RTL&&(this.frameClipRect_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameHeader_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameBase_.setAttribute("x",-e+FRAME_MARGIN_SIDE),this.frameText_.setAttribute("x",2*FRAME_MARGIN_SIDE-e)),this.frameText_.getAttribute("y")||(e=Math.abs(this.frameText_.getBoundingClientRect().top-this.svgPathDark_.getBoundingClientRect().top),this.frameText_.setAttribute("y",-(FRAME_MARGIN_TOP+(FRAME_HEADER_HEIGHT-e)/2)))},Blockly.BlockSvgFramed.prototype.dispose=function(){Blockly.BlockSvgFramed.superClass_.dispose.call(this),this.frameText_=this.frameHeader_=this.frameBase_=this.frameClipRect_=null},Blockly.BlockSvgFunctional=function(e,t){t=t||{},this.headerHeight=t.headerHeight||0,this.rowBuffer=t.rowBuffer||0,this.patternId_=null,this.inputMarkers_={},this.inputClickTargets_={},this.forcedInputSpacings={},Blockly.BlockSvg.call(this,e)},goog.inherits(Blockly.BlockSvgFunctional,Blockly.BlockSvg),Blockly.BlockSvgFunctional.prototype.initChildren=function(){var e=Blockly.makeColour(this.block_.getColour(),this.block_.getSaturation(),this.block_.getValue());e=goog.color.lighten(goog.color.hexToRgb(e),.3),Blockly.BlockSvgFunctional.superClass_.initChildren.call(this);var t=Blockly.createSvgElement("clipPath",{id:"blockClip"+this.block_.id},this.svgGroup_);this.blockClipRect_=Blockly.createSvgElement("path",{},t),this.divider_=Blockly.createSvgElement("rect",{x:1,y:this.headerHeight,height:3,width:0,fill:goog.color.rgbArrayToHex(e),"clip-path":"url(#blockClip"+this.block_.id+")",visibility:0<this.headerHeight?"visible":"hidden"},this.svgGroup_),this.createFunctionalMarkers_()},Blockly.BlockSvgFunctional.prototype.renderDraw_=function(e,t){this.createFunctionalMarkers_(),Blockly.BlockSvgFunctional.superClass_.renderDraw_.call(this,e,t),this.blockClipRect_.setAttribute("d",this.svgPath_.getAttribute("d"));try{var o=this.svgPath_.getBBox();this.divider_.setAttribute("width",Math.max(0,o.width-2))}catch(e){}},Blockly.BlockSvgFunctional.prototype.createFunctionalMarkers_=function(){for(var e=[],t=0;t<this.block_.inputList.length;t++){var o=this.block_.inputList[t];e.push(o.name),this.inputMarkers_[o.name]||o.type!==Blockly.FUNCTIONAL_INPUT||(this.inputMarkers_[o.name]=Blockly.createSvgElement("rect",{fill:"white"},this.svgGroup_),this.inputClickTargets_[o.name]=Blockly.createSvgElement("path",{fill:"white",opacity:"0",class:"inputClickTarget"},this.svgGroup_),this.block_.blockSpace.isFlyout||this.addInputClickListener_(o.name))}Object.keys(this.inputMarkers_).forEach(function(t){if(-1===e.indexOf(t)){var o=this.inputMarkers_[t];o.parentNode.removeChild(o),delete this.inputMarkers_[t],(o=this.inputClickTargets_[t]).parentNode.removeChild(o),delete this.inputMarkers_[t]}},this)},Blockly.BlockSvgFunctional.prototype.addInputClickListener_=function(e){var t=this.block_.blockSpace,o=this.block_;Blockly.bindEvent_(this.inputClickTargets_[e],"mousedown",this,function(n){if(!Blockly.isRightButton(n)){var i=o.getInput(e);if(!i.connection.acceptsAnyType()){if(i.connection.acceptsType("Number"))n="functional_math_number";else{if(!i.connection.acceptsType("String"))return;n="functional_string"}(n=new Blockly.Block(t,n)).initSvg(),i.connection.connect(n.previousConnection),i=n.getTitles();for(var r=0;r<i.length;r++)i[r]instanceof Blockly.FieldTextInput&&i[r].showEditor_();n.render()}}})},Blockly.BlockSvgFunctional.prototype.renderDrawRight_=function(e,t,o,n){this.rowBuffer&&(e.core.push("v",this.rowBuffer),e.curY+=this.rowBuffer),Blockly.BlockSvgFunctional.superClass_.renderDrawRight_.call(this,e,t,o,n)},Blockly.BlockSvgFunctional.prototype.renderDrawRightInlineFunctional_=function(e,t,o){var n=e.curX,i=e.curY+Blockly.BlockSvg.INLINE_PADDING_Y,r=Blockly.BlockSvg.NOTCH_WIDTH-Blockly.BlockSvg.NOTCH_PATH_WIDTH,l=t.connection.getNotchPaths(),s=[];s.push("M",n+","+i),s.push("h",r),s.push(l.left),s.push("H",n+t.renderWidth),s.push("v",t.renderHeight),s.push("H",n),s.push("z"),e.inline=e.inline.concat(s),this.inputClickTargets_[t.name].setAttribute("d",s.join(" ")),this.inputMarkers_[t.name].setAttribute("x",n+5),this.inputMarkers_[t.name].setAttribute("y",i+15),this.inputMarkers_[t.name].setAttribute("width",t.renderWidth-10),this.inputMarkers_[t.name].setAttribute("height",5),this.inputMarkers_[t.name].setAttribute("fill",t.getHexColour()),this.inputMarkers_[t.name].setAttribute("visibility",t.connection.targetConnection?"hidden":"visible"),this.inputClickTargets_[t.name].setAttribute("visibility",t.connection.targetConnection?"hidden":"visible"),e.curX+=this.inputWidthToOccupy_(t)+Blockly.BlockSvg.SEP_SPACE_X,t.connection.moveTo(o.x+n+Blockly.BlockSvg.NOTCH_WIDTH,o.y+i),t.connection.targetConnection&&t.connection.tighten_()},Blockly.BlockSvgFunctional.prototype.updateToColour_=function(e){Blockly.BlockSvgFunctional.superClass_.updateToColour_.call(this,e),this.divider_&&(e=goog.color.lighten(goog.color.hexToRgb(e),.3),this.divider_.setAttribute("fill",goog.color.rgbArrayToHex(e)))},Blockly.BlockSvgFunctional.prototype.dispose=function(){Blockly.BlockSvgFunctional.superClass_.dispose.call(this),this.divider_=this.blockClipRect_=null},Blockly.Blocks={},Blockly.ScrollbarPair=function(e,t,o){this.blockSpace_=e,this.oldHostMetrics_=null,t&&(this.hScroll=new Blockly.Scrollbar(e,!0,t&&o)),o&&(this.vScroll=new Blockly.Scrollbar(e,!1,t&&o)),t&&o&&(this.corner_=Blockly.createSvgElement("rect",{height:Blockly.Scrollbar.scrollbarThickness,width:Blockly.Scrollbar.scrollbarThickness,style:"fill: #fff"},null),Blockly.Scrollbar.insertAfter_(this.corner_,e.getBubbleCanvas()))},Blockly.ScrollbarPair.prototype.dispose=function(){this.onResizeWrapper_&&(Blockly.unbindEvent_(this.onResizeWrapper_),this.onResizeWrapper_=null),this.corner_&&goog.dom.removeNode(this.corner_),this.oldHostMetrics_=this.blockSpace_=this.corner_=null,this.hScroll&&this.hScroll.dispose(),this.hScroll=null,this.vScroll&&this.vScroll.dispose(),this.vScroll=null},Blockly.ScrollbarPair.prototype.canScrollHorizontally=function(){return!!this.hScroll},Blockly.ScrollbarPair.prototype.canScrollVertically=function(){return!!this.vScroll},Blockly.ScrollbarPair.prototype.resize=function(){var e=this.blockSpace_.getMetrics();if(e){var t=this.metricsChangedOnAxis.bind(this,this.oldHostMetrics_,e),o=t(["viewWidth","absoluteLeft","viewHeight","absoluteTop"]),n=o||t(["contentWidth","viewLeft","contentLeft"]);t=o||t(["contentHeight","viewTop","contentTop"]),this.hScroll&&n&&this.hScroll.resize(e),this.vScroll&&t&&this.vScroll.resize(e),this.vScroll&&this.hScroll&&o&&(this.corner_.setAttribute("x",this.vScroll.xCoordinate),this.corner_.setAttribute("y",this.hScroll.yCoordinate)),this.oldHostMetrics_=e}},Blockly.ScrollbarPair.prototype.metricsChangedOnAxis=function(e,t,o){return!e||o.some(function(o){return e[o]!=t[o]})},Blockly.ScrollbarPair.prototype.set=function(e,t){this.hScroll&&this.hScroll.set(e,!0),this.vScroll&&this.vScroll.set(t,!0)},Blockly.ScrollbarSvg=function(e,t,o){this.blockSpace_=e,this.pair_=o||!1,this.horizontal_=t,this.createDom_(),t?(this.svgBackground_.setAttribute("height",Blockly.Scrollbar.scrollbarThickness),this.svgKnob_.setAttribute("height",Blockly.Scrollbar.scrollbarThickness-6),this.svgKnob_.setAttribute("y",3)):(this.svgBackground_.setAttribute("width",Blockly.Scrollbar.scrollbarThickness),this.svgKnob_.setAttribute("width",Blockly.Scrollbar.scrollbarThickness-6),this.svgKnob_.setAttribute("x",3)),this.onMouseDownBarWrapper_=Blockly.bindEvent_(this.svgBackground_,"mousedown",this,this.onMouseDownBar_),this.onMouseDownKnobWrapper_=Blockly.bindEvent_(this.svgKnob_,"mousedown",this,this.onMouseDownKnob_)},Blockly.ScrollbarSvg.prototype.dispose=function(){this.onMouseUpKnob_(),this.onResizeWrapper_&&(Blockly.unbindEvent_(this.onResizeWrapper_),this.onResizeWrapper_=null),Blockly.unbindEvent_(this.onMouseDownBarWrapper_),this.onMouseDownBarWrapper_=null,Blockly.unbindEvent_(this.onMouseDownKnobWrapper_),this.onMouseDownKnobWrapper_=null,goog.dom.removeNode(this.svgGroup_),this.blockSpace_=this.svgKnob_=this.svgBackground_=this.svgGroup_=null},Blockly.ScrollbarSvg.prototype.resize=function(e){if(e||(e=this.blockSpace_.getMetrics())){var t=this.blockSpace_.getScrollableSize(e);if(this.horizontal_){var o=e.viewWidth;this.pair_?o-=Blockly.Scrollbar.scrollbarThickness:this.setVisible(o<t.width),this.ratio_=o/t.width,(-1/0===this.ratio_||1/0===this.ratio_||isNaN(this.ratio_))&&(this.ratio_=0),t=e.viewWidth*this.ratio_;var n=e.viewLeft*this.ratio_;this.svgKnob_.setAttribute("width",Math.max(0,t)),this.xCoordinate=e.absoluteLeft,this.pair_&&Blockly.RTL&&(this.xCoordinate+=e.absoluteLeft+Blockly.Scrollbar.scrollbarThickness),this.yCoordinate=e.absoluteTop+e.viewHeight-Blockly.Scrollbar.scrollbarThickness,this.svgGroup_.setAttribute("transform","translate("+this.xCoordinate+", "+this.yCoordinate+")"),this.svgBackground_.setAttribute("width",Math.max(0,o)),this.svgKnob_.setAttribute("x",this.constrainKnob_(n))}else o=e.viewHeight,this.pair_?o-=Blockly.Scrollbar.scrollbarThickness:this.setVisible(o<t.height),this.ratio_=o/t.height,(-1/0===this.ratio_||1/0===this.ratio_||isNaN(this.ratio_))&&(this.ratio_=0),t=e.viewHeight*this.ratio_,n=e.viewTop*this.ratio_,this.svgKnob_.setAttribute("height",Math.max(0,t)),this.xCoordinate=e.absoluteLeft,Blockly.RTL||(this.xCoordinate+=e.viewWidth-Blockly.Scrollbar.scrollbarThickness),this.yCoordinate=e.absoluteTop,this.svgGroup_.setAttribute("transform","translate("+this.xCoordinate+", "+this.yCoordinate+")"),this.svgBackground_.setAttribute("height",Math.max(0,o)),this.svgKnob_.setAttribute("y",this.constrainKnob_(n));this.onScroll_()}},Blockly.ScrollbarSvg.prototype.createDom_=function(){this.svgGroup_=Blockly.createSvgElement("g",{},null),this.svgBackground_=Blockly.createSvgElement("rect",{class:"blocklyScrollbarBackground"},this.svgGroup_);var e=Math.floor((Blockly.Scrollbar.scrollbarThickness-6)/2);this.svgKnob_=Blockly.createSvgElement("rect",{class:"blocklyScrollbarKnob",rx:e,ry:e},this.svgGroup_),Blockly.Scrollbar.insertAfter_(this.svgGroup_,this.blockSpace_.getBubbleCanvas())},Blockly.ScrollbarSvg.prototype.isVisible=function(){return"none"!=this.svgGroup_.getAttribute("display")},Blockly.ScrollbarSvg.prototype.setVisible=function(e){if(e!=this.isVisible()){if(this.pair_)throw"Unable to toggle visibility of paired scrollbars.";e?this.svgGroup_.setAttribute("display","block"):(this.blockSpace_.setMetrics({x:0,y:0}),this.svgGroup_.setAttribute("display","none"))}},Blockly.ScrollbarSvg.prototype.onMouseDownBar_=function(e){if(this.blockSpace_.blockSpaceEditor.hideChaff(!0),!Blockly.isRightButton(e)){var t=Blockly.mouseToSvg(e,this.blockSpace_.blockSpaceEditor.svg_);t=this.horizontal_?t.x:t.y;var o=Blockly.getSvgXY_(this.svgKnob_,this.blockSpace_.blockSpaceEditor.svg_);o=this.horizontal_?o.x:o.y;var n=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"width":"height")),i=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),r=.95*n;t<=o?i-=r:t>=o+n&&(i+=r),this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(i)),this.onScroll_()}e.stopPropagation()},Blockly.ScrollbarSvg.prototype.onMouseDownKnob_=function(e){this.blockSpace_.blockSpaceEditor.hideChaff(!0),this.onMouseUpKnob_(),Blockly.isRightButton(e)||(this.startDragKnob=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),this.startDragMouse=this.horizontal_?e.clientX:e.clientY,Blockly.ScrollbarSvg.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUpKnob_),Blockly.ScrollbarSvg.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMoveKnob_)),e.stopPropagation()},Blockly.ScrollbarSvg.prototype.onMouseMoveKnob_=function(e){this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(this.startDragKnob+((this.horizontal_?e.clientX:e.clientY)-this.startDragMouse))),this.onScroll_()},Blockly.ScrollbarSvg.prototype.onMouseUpKnob_=function(){Blockly.ScrollbarSvg.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.ScrollbarSvg.onMouseUpWrapper_),Blockly.ScrollbarSvg.onMouseUpWrapper_=null),Blockly.ScrollbarSvg.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.ScrollbarSvg.onMouseMoveWrapper_),Blockly.ScrollbarSvg.onMouseMoveWrapper_=null)},Blockly.ScrollbarSvg.prototype.constrainKnob_=function(e){if(0>=e||isNaN(e))e=0;else{var t=this.horizontal_?"width":"height",o=parseFloat(this.svgBackground_.getAttribute(t));t=parseFloat(this.svgKnob_.getAttribute(t)),e=Math.min(e,o-t)}return e},Blockly.ScrollbarSvg.prototype.onScroll_=function(){var e=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),t=parseFloat(this.svgBackground_.getAttribute(this.horizontal_?"width":"height"));e/=t,isNaN(e)&&(e=0),t={},this.horizontal_?t.x=e:t.y=e,this.blockSpace_.setMetrics(t)},Blockly.ScrollbarSvg.prototype.set=function(e,t){this.svgKnob_.setAttribute(this.horizontal_?"x":"y",e*this.ratio_),t&&this.onScroll_()},Blockly.Scrollbar=Blockly.ScrollbarSvg,Blockly.Scrollbar.scrollbarThickness=15,Blockly.Scrollbar.insertAfter_=function(e,t){var o=t.nextSibling;if(!(t=t.parentNode))throw"Reference node has no parent.";o?t.insertBefore(e,o):t.appendChild(e)},goog.math={},goog.math.randomInt=function(e){return Math.floor(Math.random()*e)},goog.math.uniformRandom=function(e,t){return e+Math.random()*(t-e)},goog.math.clamp=function(e,t,o){return Math.min(Math.max(e,t),o)},goog.math.modulo=function(e,t){return 0>(e%=t)*t?e+t:e},goog.math.lerp=function(e,t,o){return e+o*(t-e)},goog.math.nearlyEquals=function(e,t,o){return Math.abs(e-t)<=(o||1e-6)},goog.math.standardAngle=function(e){return goog.math.modulo(e,360)},goog.math.standardAngleInRadians=function(e){return goog.math.modulo(e,2*Math.PI)},goog.math.toRadians=function(e){return e*Math.PI/180},goog.math.toDegrees=function(e){return 180*e/Math.PI},goog.math.angleDx=function(e,t){return t*Math.cos(goog.math.toRadians(e))},goog.math.angleDy=function(e,t){return t*Math.sin(goog.math.toRadians(e))},goog.math.angle=function(e,t,o,n){return goog.math.standardAngle(goog.math.toDegrees(Math.atan2(n-t,o-e)))},goog.math.angleDifference=function(e,t){return 180<(e=goog.math.standardAngle(t)-goog.math.standardAngle(e))?e-=360:-180>=e&&(e=360+e),e},goog.math.sign=function(e){return 0<e?1:0>e?-1:e},goog.math.longestCommonSubsequence=function(e,t,o,n){o=o||function(e,t){return e==t},n=n||function(t,o){return e[t]};for(var i=e.length,r=t.length,l=[],s=0;s<i+1;s++)l[s]=[],l[s][0]=0;for(var a=0;a<r+1;a++)l[0][a]=0;for(s=1;s<=i;s++)for(a=1;a<=r;a++)o(e[s-1],t[a-1])?l[s][a]=l[s-1][a-1]+1:l[s][a]=Math.max(l[s-1][a],l[s][a-1]);var g=[];for(s=i,a=r;0<s&&0<a;)o(e[s-1],t[a-1])?(g.unshift(n(s-1,a-1)),s--,a--):l[s-1][a]>l[s][a-1]?s--:a--;return g},goog.math.sum=function(e){return goog.array.reduce(arguments,function(e,t){return e+t},0)},goog.math.average=function(e){return goog.math.sum.apply(null,arguments)/arguments.length},goog.math.sampleVariance=function(e){var t=arguments.length;if(2>t)return 0;var o=goog.math.average.apply(null,arguments);return goog.math.sum.apply(null,goog.array.map(arguments,function(e){return Math.pow(e-o,2)}))/(t-1)},goog.math.standardDeviation=function(e){return Math.sqrt(goog.math.sampleVariance.apply(null,arguments))},goog.math.isInt=function(e){return isFinite(e)&&0==e%1},goog.math.isFiniteNumber=function(e){return isFinite(e)&&!isNaN(e)},goog.math.isNegativeZero=function(e){return 0==e&&0>1/e},goog.math.log10Floor=function(e){if(0<e){var t=Math.round(Math.log(e)*Math.LOG10E);return t-(parseFloat("1e"+t)>e?1:0)}return 0==e?-1/0:NaN},goog.math.safeFloor=function(e,t){return goog.asserts.assert(!goog.isDef(t)||0<t),Math.floor(e+(t||2e-15))},goog.math.safeCeil=function(e,t){return goog.asserts.assert(!goog.isDef(t)||0<t),Math.ceil(e-(t||2e-15))},goog.math.Coordinate=function(e,t){this.x=goog.isDef(e)?e:0,this.y=goog.isDef(t)?t:0},goog.math.Coordinate.prototype.clone=function(){return new goog.math.Coordinate(this.x,this.y)},goog.DEBUG&&(goog.math.Coordinate.prototype.toString=function(){return"("+this.x+", "+this.y+")"}),goog.math.Coordinate.prototype.equals=function(e){return e instanceof goog.math.Coordinate&&goog.math.Coordinate.equals(this,e)},goog.math.Coordinate.equals=function(e,t){return e==t||!(!e||!t)&&(e.x==t.x&&e.y==t.y)},goog.math.Coordinate.distance=function(e,t){var o=e.x-t.x;return e=e.y-t.y,Math.sqrt(o*o+e*e)},goog.math.Coordinate.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},goog.math.Coordinate.azimuth=function(e){return goog.math.angle(0,0,e.x,e.y)},goog.math.Coordinate.squaredDistance=function(e,t){var o=e.x-t.x;return o*o+(e=e.y-t.y)*e},goog.math.Coordinate.difference=function(e,t){return new goog.math.Coordinate(e.x-t.x,e.y-t.y)},goog.math.Coordinate.sum=function(e,t){return new goog.math.Coordinate(e.x+t.x,e.y+t.y)},goog.math.Coordinate.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},goog.math.Coordinate.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},goog.math.Coordinate.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},goog.math.Coordinate.prototype.translate=function(e,t){return e instanceof goog.math.Coordinate?(this.x+=e.x,this.y+=e.y):(this.x+=Number(e),goog.isNumber(t)&&(this.y+=t)),this},goog.math.Coordinate.prototype.scale=function(e,t){return t=goog.isNumber(t)?t:e,this.x*=e,this.y*=t,this},goog.math.Coordinate.prototype.rotateRadians=function(e,t){t=t||new goog.math.Coordinate(0,0);var o=this.x,n=this.y,i=Math.cos(e);e=Math.sin(e),this.x=(o-t.x)*i-(n-t.y)*e+t.x,this.y=(o-t.x)*e+(n-t.y)*i+t.y},goog.math.Coordinate.prototype.rotateDegrees=function(e,t){this.rotateRadians(goog.math.toRadians(e),t)},goog.math.Box=function(e,t,o,n){this.top=e,this.right=t,this.bottom=o,this.left=n},goog.math.Box.boundingBox=function(e){for(var t=new goog.math.Box(arguments[0].y,arguments[0].x,arguments[0].y,arguments[0].x),o=1;o<arguments.length;o++)t.expandToIncludeCoordinate(arguments[o]);return t},goog.math.Box.prototype.getWidth=function(){return this.right-this.left},goog.math.Box.prototype.getHeight=function(){return this.bottom-this.top},goog.math.Box.prototype.clone=function(){return new goog.math.Box(this.top,this.right,this.bottom,this.left)},goog.DEBUG&&(goog.math.Box.prototype.toString=function(){return"("+this.top+"t, "+this.right+"r, "+this.bottom+"b, "+this.left+"l)"}),goog.math.Box.prototype.contains=function(e){return goog.math.Box.contains(this,e)},goog.math.Box.prototype.expand=function(e,t,o,n){return goog.isObject(e)?(this.top-=e.top,this.right+=e.right,this.bottom+=e.bottom,this.left-=e.left):(this.top-=e,this.right+=Number(t),this.bottom+=Number(o),this.left-=Number(n)),this},goog.math.Box.prototype.expandToInclude=function(e){this.left=Math.min(this.left,e.left),this.top=Math.min(this.top,e.top),this.right=Math.max(this.right,e.right),this.bottom=Math.max(this.bottom,e.bottom)},goog.math.Box.prototype.expandToIncludeCoordinate=function(e){this.top=Math.min(this.top,e.y),this.right=Math.max(this.right,e.x),this.bottom=Math.max(this.bottom,e.y),this.left=Math.min(this.left,e.x)},goog.math.Box.equals=function(e,t){return e==t||!(!e||!t)&&(e.top==t.top&&e.right==t.right&&e.bottom==t.bottom&&e.left==t.left)},goog.math.Box.contains=function(e,t){return!(!e||!t)&&(t instanceof goog.math.Box?t.left>=e.left&&t.right<=e.right&&t.top>=e.top&&t.bottom<=e.bottom:t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom)},goog.math.Box.relativePositionX=function(e,t){return t.x<e.left?t.x-e.left:t.x>e.right?t.x-e.right:0},goog.math.Box.relativePositionY=function(e,t){return t.y<e.top?t.y-e.top:t.y>e.bottom?t.y-e.bottom:0},goog.math.Box.distance=function(e,t){var o=goog.math.Box.relativePositionX(e,t);return e=goog.math.Box.relativePositionY(e,t),Math.sqrt(o*o+e*e)},goog.math.Box.intersects=function(e,t){return e.left<=t.right&&t.left<=e.right&&e.top<=t.bottom&&t.top<=e.bottom},goog.math.Box.intersectsWithPadding=function(e,t,o){return e.left<=t.right+o&&t.left<=e.right+o&&e.top<=t.bottom+o&&t.top<=e.bottom+o},goog.math.Box.prototype.ceil=function(){return this.top=Math.ceil(this.top),this.right=Math.ceil(this.right),this.bottom=Math.ceil(this.bottom),this.left=Math.ceil(this.left),this},goog.math.Box.prototype.floor=function(){return this.top=Math.floor(this.top),this.right=Math.floor(this.right),this.bottom=Math.floor(this.bottom),this.left=Math.floor(this.left),this},goog.math.Box.prototype.round=function(){return this.top=Math.round(this.top),this.right=Math.round(this.right),this.bottom=Math.round(this.bottom),this.left=Math.round(this.left),this},goog.math.Box.prototype.translate=function(e,t){return e instanceof goog.math.Coordinate?(this.left+=e.x,this.right+=e.x,this.top+=e.y,this.bottom+=e.y):(goog.asserts.assertNumber(e),this.left+=e,this.right+=e,goog.isNumber(t)&&(this.top+=t,this.bottom+=t)),this},goog.math.Box.prototype.scale=function(e,t){return t=goog.isNumber(t)?t:e,this.left*=e,this.right*=e,this.top*=t,this.bottom*=t,this},goog.math.IRect=function(){},goog.math.Size=function(e,t){this.width=e,this.height=t},goog.math.Size.equals=function(e,t){return e==t||!(!e||!t)&&(e.width==t.width&&e.height==t.height)},goog.math.Size.prototype.clone=function(){return new goog.math.Size(this.width,this.height)},goog.DEBUG&&(goog.math.Size.prototype.toString=function(){return"("+this.width+" x "+this.height+")"}),goog.math.Size.prototype.getLongest=function(){return Math.max(this.width,this.height)},goog.math.Size.prototype.getShortest=function(){return Math.min(this.width,this.height)},goog.math.Size.prototype.area=function(){return this.width*this.height},goog.math.Size.prototype.perimeter=function(){return 2*(this.width+this.height)},goog.math.Size.prototype.aspectRatio=function(){return this.width/this.height},goog.math.Size.prototype.isEmpty=function(){return!this.area()},goog.math.Size.prototype.ceil=function(){return this.width=Math.ceil(this.width),this.height=Math.ceil(this.height),this},goog.math.Size.prototype.fitsInside=function(e){return this.width<=e.width&&this.height<=e.height},goog.math.Size.prototype.floor=function(){return this.width=Math.floor(this.width),this.height=Math.floor(this.height),this},goog.math.Size.prototype.round=function(){return this.width=Math.round(this.width),this.height=Math.round(this.height),this},goog.math.Size.prototype.scale=function(e,t){return t=goog.isNumber(t)?t:e,this.width*=e,this.height*=t,this},goog.math.Size.prototype.scaleToCover=function(e){return e=this.aspectRatio()<=e.aspectRatio()?e.width/this.width:e.height/this.height,this.scale(e)},goog.math.Size.prototype.scaleToFit=function(e){return e=this.aspectRatio()>e.aspectRatio()?e.width/this.width:e.height/this.height,this.scale(e)},goog.math.Rect=function(e,t,o,n){this.left=e,this.top=t,this.width=o,this.height=n},goog.math.Rect.prototype.clone=function(){return new goog.math.Rect(this.left,this.top,this.width,this.height)},goog.math.Rect.prototype.toBox=function(){return new goog.math.Box(this.top,this.left+this.width,this.top+this.height,this.left)},goog.math.Rect.createFromPositionAndSize=function(e,t){return new goog.math.Rect(e.x,e.y,t.width,t.height)},goog.math.Rect.createFromBox=function(e){return new goog.math.Rect(e.left,e.top,e.right-e.left,e.bottom-e.top)},goog.DEBUG&&(goog.math.Rect.prototype.toString=function(){return"("+this.left+", "+this.top+" - "+this.width+"w x "+this.height+"h)"}),goog.math.Rect.equals=function(e,t){return e==t||!(!e||!t)&&(e.left==t.left&&e.width==t.width&&e.top==t.top&&e.height==t.height)},goog.math.Rect.prototype.intersection=function(e){var t=Math.max(this.left,e.left),o=Math.min(this.left+this.width,e.left+e.width);if(t<=o){var n=Math.max(this.top,e.top);if(n<=(e=Math.min(this.top+this.height,e.top+e.height)))return this.left=t,this.top=n,this.width=o-t,this.height=e-n,!0}return!1},goog.math.Rect.intersection=function(e,t){var o=Math.max(e.left,t.left),n=Math.min(e.left+e.width,t.left+t.width);if(o<=n){var i=Math.max(e.top,t.top);if(i<=(e=Math.min(e.top+e.height,t.top+t.height)))return new goog.math.Rect(o,i,n-o,e-i)}return null},goog.math.Rect.intersects=function(e,t){return e.left<=t.left+t.width&&t.left<=e.left+e.width&&e.top<=t.top+t.height&&t.top<=e.top+e.height},goog.math.Rect.prototype.intersects=function(e){return goog.math.Rect.intersects(this,e)},goog.math.Rect.difference=function(e,t){var o=goog.math.Rect.intersection(e,t);if(!o||!o.height||!o.width)return[e.clone()];o=[];var n=e.top,i=e.height,r=e.left+e.width,l=e.top+e.height,s=t.left+t.width,a=t.top+t.height;return t.top>e.top&&(o.push(new goog.math.Rect(e.left,e.top,e.width,t.top-e.top)),n=t.top,i-=t.top-e.top),a<l&&(o.push(new goog.math.Rect(e.left,a,e.width,l-a)),i=a-n),t.left>e.left&&o.push(new goog.math.Rect(e.left,n,t.left-e.left,i)),s<r&&o.push(new goog.math.Rect(s,n,r-s,i)),o},goog.math.Rect.prototype.difference=function(e){return goog.math.Rect.difference(this,e)},goog.math.Rect.prototype.boundingRect=function(e){var t=Math.max(this.left+this.width,e.left+e.width),o=Math.max(this.top+this.height,e.top+e.height);this.left=Math.min(this.left,e.left),this.top=Math.min(this.top,e.top),this.width=t-this.left,this.height=o-this.top},goog.math.Rect.boundingRect=function(e,t){return e&&t?((e=new goog.math.Rect(e.left,e.top,e.width,e.height)).boundingRect(t),e):null},goog.math.Rect.prototype.contains=function(e){return e instanceof goog.math.Coordinate?e.x>=this.left&&e.x<=this.left+this.width&&e.y>=this.top&&e.y<=this.top+this.height:this.left<=e.left&&this.left+this.width>=e.left+e.width&&this.top<=e.top&&this.top+this.height>=e.top+e.height},goog.math.Rect.prototype.squaredDistance=function(e){var t=e.x<this.left?this.left-e.x:Math.max(e.x-(this.left+this.width),0);return t*t+(e=e.y<this.top?this.top-e.y:Math.max(e.y-(this.top+this.height),0))*e},goog.math.Rect.prototype.distance=function(e){return Math.sqrt(this.squaredDistance(e))},goog.math.Rect.prototype.getSize=function(){return new goog.math.Size(this.width,this.height)},goog.math.Rect.prototype.getTopLeft=function(){return new goog.math.Coordinate(this.left,this.top)},goog.math.Rect.prototype.getCenter=function(){return new goog.math.Coordinate(this.left+this.width/2,this.top+this.height/2)},goog.math.Rect.prototype.getBottomRight=function(){return new goog.math.Coordinate(this.left+this.width,this.top+this.height)},goog.math.Rect.prototype.ceil=function(){return this.left=Math.ceil(this.left),this.top=Math.ceil(this.top),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height),this},goog.math.Rect.prototype.floor=function(){return this.left=Math.floor(this.left),this.top=Math.floor(this.top),this.width=Math.floor(this.width),this.height=Math.floor(this.height),this},goog.math.Rect.prototype.round=function(){return this.left=Math.round(this.left),this.top=Math.round(this.top),this.width=Math.round(this.width),this.height=Math.round(this.height),this},goog.math.Rect.prototype.translate=function(e,t){return e instanceof goog.math.Coordinate?(this.left+=e.x,this.top+=e.y):(this.left+=goog.asserts.assertNumber(e),goog.isNumber(t)&&(this.top+=t)),this},goog.math.Rect.prototype.scale=function(e,t){return t=goog.isNumber(t)?t:e,this.left*=e,this.width*=e,this.top*=t,this.height*=t,this},Blockly.Trashcan=function(e){this.blockSpace_=e},Blockly.Trashcan.CLOSED_URL_="media/canclosed.png",Blockly.Trashcan.OPEN_URL_="media/canopen.png",Blockly.Trashcan.WIDTH_=70,Blockly.Trashcan.HEIGHT_=70,Blockly.Trashcan.MARGIN_TOP_=15,Blockly.Trashcan.MARGIN_SIDE_=22,Blockly.Trashcan.MARGIN_HOTSPOT_=25,Blockly.Trashcan.prototype.isOpen=!1,Blockly.Trashcan.prototype.radius=50,Blockly.Trashcan.prototype.svgGroup_=null,Blockly.Trashcan.prototype.svgClosedCan_=null,Blockly.Trashcan.prototype.svgOpenCan_=null,Blockly.Trashcan.prototype.left_=0,Blockly.Trashcan.prototype.top_=0,Blockly.Trashcan.prototype.createDom=function(){return this.svgGroup_=Blockly.createSvgElement("g",{id:"trashcan",filter:"url(#blocklyTrashcanShadowFilter)"},null),this.svgClosedCan_=Blockly.createSvgElement("image",{width:Blockly.Trashcan.WIDTH_,height:Blockly.Trashcan.HEIGHT_},this.svgGroup_),this.svgClosedCan_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.assetUrl(Blockly.Trashcan.CLOSED_URL_)),this.svgOpenCan_=Blockly.createSvgElement("image",{width:Blockly.Trashcan.WIDTH_,height:Blockly.Trashcan.HEIGHT_},this.svgGroup_),this.svgOpenCan_.setAttribute("visibility","hidden"),this.svgOpenCan_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.assetUrl(Blockly.Trashcan.OPEN_URL_)),this.notAllowed_=Blockly.createSvgElement("g",{},this.svgGroup_),Blockly.createSvgElement("line",{x1:15,y1:15,x2:55,y2:55,stroke:"#c00","stroke-width":5},this.notAllowed_),Blockly.createSvgElement("circle",{cx:36,cy:34,r:28,stroke:"#c00","stroke-width":5,fill:"none"},this.notAllowed_),this.notAllowed_.setAttribute("visibility","hidden"),this.svgGroup_},Blockly.Trashcan.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null),this.blockSpace_=this.notAllowed_=this.svgOpenCan_=this.svgClosedCan_=null},Blockly.Trashcan.prototype.getHeight=function(){return Blockly.Trashcan.HEIGHT_},Blockly.Trashcan.prototype.setOpen_=function(e){this.isOpen!=e&&(this.isOpen=e,this.animateLid_())},Blockly.Trashcan.prototype.setDisabled=function(e){this.isDisabled!==e&&((this.isDisabled=e)?this.notAllowed_.setAttribute("visibility","visible"):this.notAllowed_.setAttribute("visibility","hidden"))},Blockly.Trashcan.prototype.animateLid_=function(){this.isOpen?this.svgOpenCan_.setAttribute("visibility","visible"):this.svgOpenCan_.setAttribute("visibility","hidden")},Blockly.Trashcan.prototype.close=function(){this.setOpen_(!1)},Blockly.PanDragHandler=function(e){this.blockSpace_=e,this.startScrollY_=this.startScrollX_=this.startMouseY_=this.startMouseX_=this.mouseUpEventBindData_=this.mouseMoveEventBindData_=this.contextMenuBlockEventBindData_=this.mousewheelEventBindData_=this.wheelEventBindData_=this.mouseDownEventBindData_=this.onTargetMouseDown_=this.target_=null},Blockly.PanDragHandler.prototype.bindBeginPanDragHandler=function(e,t){this.unbindBeginPanDragHandler(),this.target_=e,this.onTargetMouseDown_=t,this.mouseDownEventBindData_=Blockly.bindEvent_(e,"mousedown",this,this.onPanDragTargetMouseDown_),this.contextMenuBlockEventBindData_=Blockly.bindEvent_(e,"contextmenu",null,Blockly.blockContextMenu)},Blockly.PanDragHandler.prototype.unbindBeginPanDragHandler=function(){this.mouseDownEventBindData_&&(Blockly.unbindEvent_(this.mouseDownEventBindData_),this.mouseDownEventBindData_=null),this.contextMenuBlockEventBindData_&&(Blockly.unbindEvent_(this.contextMenuBlockEventBindData_),this.contextMenuBlockEventBindData_=null),this.target_=null},Blockly.PanDragHandler.prototype.bindDuringPanDragHandlers_=function(){this.unbindDuringPanDragHandlers_(),this.mouseMoveEventBindData_=Blockly.bindEvent_(window,"mousemove",this,this.onPanDragMouseMove_,!0),this.mouseUpEventBindData_=Blockly.bindEvent_(window,"mouseup",this,this.onPanDragMouseUp_,!0)},Blockly.PanDragHandler.prototype.unbindDuringPanDragHandlers_=function(){this.mouseMoveEventBindData_&&(Blockly.unbindEvent_(this.mouseMoveEventBindData_),this.mouseMoveEventBindData_=null),this.mouseUpEventBindData_&&(Blockly.unbindEvent_(this.mouseUpEventBindData_),this.mouseUpEventBindData_=null)},Blockly.PanDragHandler.prototype.onPanDragTargetMouseDown_=function(e){this.onTargetMouseDown_&&this.onTargetMouseDown_();var t=e.target&&e.target===this.target_;Blockly.selected&&!this.blockSpace_.isReadOnly()&&t&&Blockly.selected.unselect();var o=Blockly.selected&&!Blockly.selected.isMovable()&&!Blockly.selected.isEditable();t=t||o||this.blockSpace_.isReadOnly(),o=!Blockly.isRightButton(e),this.blockSpace_.scrollbarPair&&o&&t&&(this.beginDragScroll_(e),e.stopPropagation(),e.preventDefault())},Blockly.PanDragHandler.prototype.beginDragScroll_=function(e){this.startMouseX_=e.clientX,this.startMouseY_=e.clientY,this.startScrollX_=this.blockSpace_.getScrollOffsetX(),this.startScrollY_=this.blockSpace_.getScrollOffsetY(),this.bindDuringPanDragHandlers_()},Blockly.PanDragHandler.prototype.onPanDragMouseMove_=function(e){Blockly.removeAllRanges(),this.blockSpace_.scrollTo(this.startScrollX_+-(e.clientX-this.startMouseX_),this.startScrollY_+-(e.clientY-this.startMouseY_)),e.stopPropagation(),e.preventDefault()},Blockly.PanDragHandler.prototype.onPanDragMouseUp_=function(e){this.unbindDuringPanDragHandlers_(),e.stopPropagation(),e.preventDefault()},Blockly.ScrollOnWheelHandler=function(e){this.blockSpace_=e,this.mousewheelEventBindData_=this.wheelEventBindData_=null},Blockly.ScrollOnWheelHandler.prototype.bindTo=function(e){this.unbindWheelScrollHandler(),this.wheelEventBindData_=Blockly.bindEvent_(e,"wheel",this,this.onWheel_),this.mousewheelEventBindData_=Blockly.bindEvent_(e,"mousewheel",this,this.onWheel_)},Blockly.ScrollOnWheelHandler.prototype.unbindWheelScrollHandler=function(){this.wheelEventBindData_&&(Blockly.unbindEvent_(this.wheelEventBindData_),this.wheelEventBindData_=null),this.mousewheelEventBindData_&&(Blockly.unbindEvent_(this.mousewheelEventBindData_),this.mousewheelEventBindData_=null)},Blockly.ScrollOnWheelHandler.prototype.onWheel_=function(e){if(this.blockSpace_.scrollbarPair){var t=Blockly.getNormalizedWheelDeltaY(e);t&&(this.blockSpace_.scrollWithAnySelectedBlock(this.blockSpace_.getScrollOffsetX(),this.blockSpace_.getScrollOffsetY()+t,e.clientX,e.clientY),e.stopPropagation(),e.preventDefault())}},goog.disposable={},goog.disposable.IDisposable=function(){},goog.disposable.IDisposable.prototype.dispose=goog.abstractMethod,goog.disposable.IDisposable.prototype.isDisposed=goog.abstractMethod,goog.Disposable=function(){goog.Disposable.MONITORING_MODE!=goog.Disposable.MonitoringMode.OFF&&(goog.Disposable.INCLUDE_STACK_ON_CREATION&&(this.creationStack=Error().stack),goog.Disposable.instances_[goog.getUid(this)]=this),this.disposed_=this.disposed_,this.onDisposeCallbacks_=this.onDisposeCallbacks_},goog.Disposable.MonitoringMode={OFF:0,PERMANENT:1,INTERACTIVE:2},goog.Disposable.MONITORING_MODE=0,goog.Disposable.INCLUDE_STACK_ON_CREATION=!0,goog.Disposable.instances_={},goog.Disposable.getUndisposedObjects=function(){var e,t=[];for(e in goog.Disposable.instances_)goog.Disposable.instances_.hasOwnProperty(e)&&t.push(goog.Disposable.instances_[Number(e)]);return t},goog.Disposable.clearUndisposedObjects=function(){goog.Disposable.instances_={}},goog.Disposable.prototype.disposed_=!1,goog.Disposable.prototype.isDisposed=function(){return this.disposed_},goog.Disposable.prototype.getDisposed=goog.Disposable.prototype.isDisposed,goog.Disposable.prototype.dispose=function(){if(!this.disposed_&&(this.disposed_=!0,this.disposeInternal(),goog.Disposable.MONITORING_MODE!=goog.Disposable.MonitoringMode.OFF)){var e=goog.getUid(this);if(goog.Disposable.MONITORING_MODE==goog.Disposable.MonitoringMode.PERMANENT&&!goog.Disposable.instances_.hasOwnProperty(e))throw Error(this+" did not call the goog.Disposable base constructor or was disposed of after a clearUndisposedObjects call");delete goog.Disposable.instances_[e]}},goog.Disposable.prototype.registerDisposable=function(e){this.addOnDisposeCallback(goog.partial(goog.dispose,e))},goog.Disposable.prototype.addOnDisposeCallback=function(e,t){this.disposed_?goog.isDef(t)?e.call(t):e():(this.onDisposeCallbacks_||(this.onDisposeCallbacks_=[]),this.onDisposeCallbacks_.push(goog.isDef(t)?goog.bind(e,t):e))},goog.Disposable.prototype.disposeInternal=function(){if(this.onDisposeCallbacks_)for(;this.onDisposeCallbacks_.length;)this.onDisposeCallbacks_.shift()()},goog.Disposable.isDisposed=function(e){return!(!e||"function"!=typeof e.isDisposed)&&e.isDisposed()},goog.dispose=function(e){e&&"function"==typeof e.dispose&&e.dispose()},goog.disposeAll=function(e){for(var t=0,o=arguments.length;t<o;++t){var n=arguments[t];goog.isArrayLike(n)?goog.disposeAll.apply(null,n):goog.dispose(n)}},goog.debug.entryPointRegistry={},goog.debug.EntryPointMonitor=function(){},goog.debug.entryPointRegistry.refList_=[],goog.debug.entryPointRegistry.monitors_=[],goog.debug.entryPointRegistry.monitorsMayExist_=!1,goog.debug.entryPointRegistry.register=function(e){if(goog.debug.entryPointRegistry.refList_[goog.debug.entryPointRegistry.refList_.length]=e,goog.debug.entryPointRegistry.monitorsMayExist_)for(var t=goog.debug.entryPointRegistry.monitors_,o=0;o<t.length;o++)e(goog.bind(t[o].wrap,t[o]))},goog.debug.entryPointRegistry.monitorAll=function(e){goog.debug.entryPointRegistry.monitorsMayExist_=!0;for(var t=goog.bind(e.wrap,e),o=0;o<goog.debug.entryPointRegistry.refList_.length;o++)goog.debug.entryPointRegistry.refList_[o](t);goog.debug.entryPointRegistry.monitors_.push(e)},goog.debug.entryPointRegistry.unmonitorAllIfPossible=function(e){var t=goog.debug.entryPointRegistry.monitors_;goog.asserts.assert(e==t[t.length-1],"Only the most recent monitor can be unwrapped."),e=goog.bind(e.unwrap,e);for(var o=0;o<goog.debug.entryPointRegistry.refList_.length;o++)goog.debug.entryPointRegistry.refList_[o](e);t.length--},goog.events={},goog.events.BrowserFeature={HAS_W3C_BUTTON:!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9),HAS_W3C_EVENT_SUPPORT:!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9),SET_KEY_CODE_TO_PREVENT_DEFAULT:goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("9"),HAS_NAVIGATOR_ONLINE_PROPERTY:!goog.userAgent.WEBKIT||goog.userAgent.isVersionOrHigher("528"),HAS_HTML5_NETWORK_EVENT_SUPPORT:goog.userAgent.GECKO&&goog.userAgent.isVersionOrHigher("1.9b")||goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("8")||goog.userAgent.OPERA&&goog.userAgent.isVersionOrHigher("9.5")||goog.userAgent.WEBKIT&&goog.userAgent.isVersionOrHigher("528"),HTML5_NETWORK_EVENTS_FIRE_ON_BODY:goog.userAgent.GECKO&&!goog.userAgent.isVersionOrHigher("8")||goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("9"),TOUCH_ENABLED:"ontouchstart"in goog.global||!!(goog.global.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!goog.global.navigator||!goog.global.navigator.msMaxTouchPoints)},goog.events.EventId=function(e){this.id=e},goog.events.EventId.prototype.toString=function(){return this.id},goog.events.Event=function(e,t){this.type=e instanceof goog.events.EventId?String(e):e,this.currentTarget=this.target=t,this.defaultPrevented=this.propagationStopped_=!1,this.returnValue_=!0},goog.events.Event.prototype.stopPropagation=function(){this.propagationStopped_=!0},goog.events.Event.prototype.preventDefault=function(){this.defaultPrevented=!0,this.returnValue_=!1},goog.events.Event.stopPropagation=function(e){e.stopPropagation()},goog.events.Event.preventDefault=function(e){e.preventDefault()},goog.events.getVendorPrefixedName_=function(e){return goog.userAgent.WEBKIT?"webkit"+e:goog.userAgent.OPERA?"o"+e.toLowerCase():e.toLowerCase()},goog.events.EventType={CLICK:"click",RIGHTCLICK:"rightclick",DBLCLICK:"dblclick",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",MOUSEOVER:"mouseover",MOUSEOUT:"mouseout",MOUSEMOVE:"mousemove",MOUSEENTER:"mouseenter",MOUSELEAVE:"mouseleave",SELECTIONCHANGE:"selectionchange",SELECTSTART:"selectstart",WHEEL:"wheel",KEYPRESS:"keypress",KEYDOWN:"keydown",KEYUP:"keyup",BLUR:"blur",FOCUS:"focus",DEACTIVATE:"deactivate",FOCUSIN:goog.userAgent.IE?"focusin":"DOMFocusIn",FOCUSOUT:goog.userAgent.IE?"focusout":"DOMFocusOut",CHANGE:"change",RESET:"reset",SELECT:"select",SUBMIT:"submit",INPUT:"input",PROPERTYCHANGE:"propertychange",DRAGSTART:"dragstart",DRAG:"drag",DRAGENTER:"dragenter",DRAGOVER:"dragover",DRAGLEAVE:"dragleave",DROP:"drop",DRAGEND:"dragend",TOUCHSTART:"touchstart",TOUCHMOVE:"touchmove",TOUCHEND:"touchend",TOUCHCANCEL:"touchcancel",BEFOREUNLOAD:"beforeunload",CONSOLEMESSAGE:"consolemessage",CONTEXTMENU:"contextmenu",DEVICEORIENTATION:"deviceorientation",DOMCONTENTLOADED:"DOMContentLoaded",ERROR:"error",HELP:"help",LOAD:"load",LOSECAPTURE:"losecapture",ORIENTATIONCHANGE:"orientationchange",READYSTATECHANGE:"readystatechange",RESIZE:"resize",SCROLL:"scroll",UNLOAD:"unload",CANPLAY:"canplay",CANPLAYTHROUGH:"canplaythrough",DURATIONCHANGE:"durationchange",EMPTIED:"emptied",ENDED:"ended",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",PAUSE:"pause",PLAY:"play",PLAYING:"playing",RATECHANGE:"ratechange",SEEKED:"seeked",SEEKING:"seeking",STALLED:"stalled",SUSPEND:"suspend",TIMEUPDATE:"timeupdate",VOLUMECHANGE:"volumechange",WAITING:"waiting",HASHCHANGE:"hashchange",PAGEHIDE:"pagehide",PAGESHOW:"pageshow",POPSTATE:"popstate",COPY:"copy",PASTE:"paste",CUT:"cut",BEFORECOPY:"beforecopy",BEFORECUT:"beforecut",BEFOREPASTE:"beforepaste",ONLINE:"online",OFFLINE:"offline",MESSAGE:"message",CONNECT:"connect",ANIMATIONSTART:goog.events.getVendorPrefixedName_("AnimationStart"),ANIMATIONEND:goog.events.getVendorPrefixedName_("AnimationEnd"),ANIMATIONITERATION:goog.events.getVendorPrefixedName_("AnimationIteration"),TRANSITIONEND:goog.events.getVendorPrefixedName_("TransitionEnd"),POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTERCANCEL:"pointercancel",POINTERMOVE:"pointermove",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",GOTPOINTERCAPTURE:"gotpointercapture",LOSTPOINTERCAPTURE:"lostpointercapture",MSGESTURECHANGE:"MSGestureChange",MSGESTUREEND:"MSGestureEnd",MSGESTUREHOLD:"MSGestureHold",MSGESTURESTART:"MSGestureStart",MSGESTURETAP:"MSGestureTap",MSGOTPOINTERCAPTURE:"MSGotPointerCapture",MSINERTIASTART:"MSInertiaStart",MSLOSTPOINTERCAPTURE:"MSLostPointerCapture",MSPOINTERCANCEL:"MSPointerCancel",MSPOINTERDOWN:"MSPointerDown",MSPOINTERENTER:"MSPointerEnter",MSPOINTERHOVER:"MSPointerHover",MSPOINTERLEAVE:"MSPointerLeave",MSPOINTERMOVE:"MSPointerMove",MSPOINTEROUT:"MSPointerOut",MSPOINTEROVER:"MSPointerOver",MSPOINTERUP:"MSPointerUp",TEXT:"text",TEXTINPUT:"textInput",COMPOSITIONSTART:"compositionstart",COMPOSITIONUPDATE:"compositionupdate",COMPOSITIONEND:"compositionend",EXIT:"exit",LOADABORT:"loadabort",LOADCOMMIT:"loadcommit",LOADREDIRECT:"loadredirect",LOADSTART:"loadstart",LOADSTOP:"loadstop",RESPONSIVE:"responsive",SIZECHANGED:"sizechanged",UNRESPONSIVE:"unresponsive",VISIBILITYCHANGE:"visibilitychange",STORAGE:"storage",DOMSUBTREEMODIFIED:"DOMSubtreeModified",DOMNODEINSERTED:"DOMNodeInserted",DOMNODEREMOVED:"DOMNodeRemoved",DOMNODEREMOVEDFROMDOCUMENT:"DOMNodeRemovedFromDocument",DOMNODEINSERTEDINTODOCUMENT:"DOMNodeInsertedIntoDocument",DOMATTRMODIFIED:"DOMAttrModified",DOMCHARACTERDATAMODIFIED:"DOMCharacterDataModified",BEFOREPRINT:"beforeprint",AFTERPRINT:"afterprint"},goog.events.BrowserEvent=function(e,t){goog.events.Event.call(this,e?e.type:""),this.relatedTarget=this.currentTarget=this.target=null,this.charCode=this.keyCode=this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.platformModifierKey=!1,this.event_=null,e&&this.init(e,t)},goog.inherits(goog.events.BrowserEvent,goog.events.Event),goog.events.BrowserEvent.MouseButton={LEFT:0,MIDDLE:1,RIGHT:2},goog.events.BrowserEvent.IEButtonMap=[1,4,2],goog.events.BrowserEvent.prototype.init=function(e,t){var o=this.type=e.type,n=e.changedTouches?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.currentTarget=t,(t=e.relatedTarget)?goog.userAgent.GECKO&&(goog.reflect.canAccessProperty(t,"nodeName")||(t=null)):o==goog.events.EventType.MOUSEOVER?t=e.fromElement:o==goog.events.EventType.MOUSEOUT&&(t=e.toElement),this.relatedTarget=t,goog.isNull(n)?(this.offsetX=goog.userAgent.WEBKIT||void 0!==e.offsetX?e.offsetX:e.layerX,this.offsetY=goog.userAgent.WEBKIT||void 0!==e.offsetY?e.offsetY:e.layerY,this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0):(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0),this.button=e.button,this.keyCode=e.keyCode||0,this.charCode=e.charCode||("keypress"==o?e.keyCode:0),this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.platformModifierKey=goog.userAgent.MAC?e.metaKey:e.ctrlKey,this.state=e.state,this.event_=e,e.defaultPrevented&&this.preventDefault()},goog.events.BrowserEvent.prototype.isButton=function(e){return goog.events.BrowserFeature.HAS_W3C_BUTTON?this.event_.button==e:"click"==this.type?e==goog.events.BrowserEvent.MouseButton.LEFT:!!(this.event_.button&goog.events.BrowserEvent.IEButtonMap[e])},goog.events.BrowserEvent.prototype.isMouseActionButton=function(){return this.isButton(goog.events.BrowserEvent.MouseButton.LEFT)&&!(goog.userAgent.WEBKIT&&goog.userAgent.MAC&&this.ctrlKey)},goog.events.BrowserEvent.prototype.stopPropagation=function(){goog.events.BrowserEvent.superClass_.stopPropagation.call(this),this.event_.stopPropagation?this.event_.stopPropagation():this.event_.cancelBubble=!0},goog.events.BrowserEvent.prototype.preventDefault=function(){goog.events.BrowserEvent.superClass_.preventDefault.call(this);var e=this.event_;if(e.preventDefault)e.preventDefault();else if(e.returnValue=!1,goog.events.BrowserFeature.SET_KEY_CODE_TO_PREVENT_DEFAULT)try{(e.ctrlKey||112<=e.keyCode&&123>=e.keyCode)&&(e.keyCode=-1)}catch(e){}},goog.events.BrowserEvent.prototype.getBrowserEvent=function(){return this.event_},goog.events.Listenable=function(){},goog.events.Listenable.IMPLEMENTED_BY_PROP="closure_listenable_"+(1e6*Math.random()|0),goog.events.Listenable.addImplementation=function(e){e.prototype[goog.events.Listenable.IMPLEMENTED_BY_PROP]=!0},goog.events.Listenable.isImplementedBy=function(e){return!(!e||!e[goog.events.Listenable.IMPLEMENTED_BY_PROP])},goog.events.ListenableKey=function(){},goog.events.ListenableKey.counter_=0,goog.events.ListenableKey.reserveKey=function(){return++goog.events.ListenableKey.counter_},goog.events.Listener=function(e,t,o,n,i,r){goog.events.Listener.ENABLE_MONITORING&&(this.creationStack=Error().stack),this.listener=e,this.proxy=t,this.src=o,this.type=n,this.capture=!!i,this.handler=r,this.key=goog.events.ListenableKey.reserveKey(),this.removed=this.callOnce=!1},goog.events.Listener.ENABLE_MONITORING=!1,goog.events.Listener.prototype.markAsRemoved=function(){this.removed=!0,this.handler=this.src=this.proxy=this.listener=null},goog.events.ListenerMap=function(e){this.src=e,this.listeners={},this.typeCount_=0},goog.events.ListenerMap.prototype.getTypeCount=function(){return this.typeCount_},goog.events.ListenerMap.prototype.getListenerCount=function(){var e,t=0;for(e in this.listeners)t+=this.listeners[e].length;return t},goog.events.ListenerMap.prototype.add=function(e,t,o,n,i){var r=e.toString();(e=this.listeners[r])||(e=this.listeners[r]=[],this.typeCount_++);var l=goog.events.ListenerMap.findListenerIndex_(e,t,n,i);return-1<l?(t=e[l],o||(t.callOnce=!1)):((t=new goog.events.Listener(t,null,this.src,r,!!n,i)).callOnce=o,e.push(t)),t},goog.events.ListenerMap.prototype.remove=function(e,t,o,n){if(!((e=e.toString())in this.listeners))return!1;var i=this.listeners[e];return-1<(t=goog.events.ListenerMap.findListenerIndex_(i,t,o,n))&&(i[t].markAsRemoved(),goog.array.removeAt(i,t),0==i.length&&(delete this.listeners[e],this.typeCount_--),!0)},goog.events.ListenerMap.prototype.removeByKey=function(e){var t=e.type;if(!(t in this.listeners))return!1;var o=goog.array.remove(this.listeners[t],e);return o&&(e.markAsRemoved(),0==this.listeners[t].length&&(delete this.listeners[t],this.typeCount_--)),o},goog.events.ListenerMap.prototype.removeAll=function(e){e=e&&e.toString();var t,o=0;for(t in this.listeners)if(!e||t==e){for(var n=this.listeners[t],i=0;i<n.length;i++)++o,n[i].markAsRemoved();delete this.listeners[t],this.typeCount_--}return o},goog.events.ListenerMap.prototype.getListeners=function(e,t){var o=[];if(e=this.listeners[e.toString()])for(var n=0;n<e.length;++n){var i=e[n];i.capture==t&&o.push(i)}return o},goog.events.ListenerMap.prototype.getListener=function(e,t,o,n){var i=-1;return(e=this.listeners[e.toString()])&&(i=goog.events.ListenerMap.findListenerIndex_(e,t,o,n)),-1<i?e[i]:null},goog.events.ListenerMap.prototype.hasListener=function(e,t){var o=goog.isDef(e),n=o?e.toString():"",i=goog.isDef(t);return goog.object.some(this.listeners,function(e,r){for(r=0;r<e.length;++r)if(!(o&&e[r].type!=n||i&&e[r].capture!=t))return!0;return!1})},goog.events.ListenerMap.findListenerIndex_=function(e,t,o,n){for(var i=0;i<e.length;++i){var r=e[i];if(!r.removed&&r.listener==t&&r.capture==!!o&&r.handler==n)return i}return-1},goog.events.LISTENER_MAP_PROP_="closure_lm_"+(1e6*Math.random()|0),goog.events.onString_="on",goog.events.onStringMap_={},goog.events.CaptureSimulationMode={OFF_AND_FAIL:0,OFF_AND_SILENT:1,ON:2},goog.events.CAPTURE_SIMULATION_MODE=2,goog.events.listenerCountEstimate_=0,goog.events.listen=function(e,t,o,n,i){if(goog.isArray(t)){for(var r=0;r<t.length;r++)goog.events.listen(e,t[r],o,n,i);return null}return o=goog.events.wrapListener(o),goog.events.Listenable.isImplementedBy(e)?e.listen(t,o,n,i):goog.events.listen_(e,t,o,!1,n,i)},goog.events.listen_=function(e,t,o,n,i,r){if(!t)throw Error("Invalid event type");var l=!!i;if(l&&!goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT){if(goog.events.CAPTURE_SIMULATION_MODE==goog.events.CaptureSimulationMode.OFF_AND_FAIL)return goog.asserts.fail("Can not register capture listener in IE8-."),null;if(goog.events.CAPTURE_SIMULATION_MODE==goog.events.CaptureSimulationMode.OFF_AND_SILENT)return null}var s=goog.events.getListenerMap_(e);if(s||(e[goog.events.LISTENER_MAP_PROP_]=s=new goog.events.ListenerMap(e)),(o=s.add(t,o,n,i,r)).proxy)return o;if(n=goog.events.getProxy(),o.proxy=n,n.src=e,n.listener=o,e.addEventListener)e.addEventListener(t.toString(),n,l);else{if(!e.attachEvent)throw Error("addEventListener and attachEvent are unavailable.");e.attachEvent(goog.events.getOnString_(t.toString()),n)}return goog.events.listenerCountEstimate_++,o},goog.events.getProxy=function(){var e=goog.events.handleBrowserEvent_,t=goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT?function(o){return e.call(t.src,t.listener,o)}:function(o){if(!(o=e.call(t.src,t.listener,o)))return o};return t},goog.events.listenOnce=function(e,t,o,n,i){if(goog.isArray(t)){for(var r=0;r<t.length;r++)goog.events.listenOnce(e,t[r],o,n,i);return null}return o=goog.events.wrapListener(o),goog.events.Listenable.isImplementedBy(e)?e.listenOnce(t,o,n,i):goog.events.listen_(e,t,o,!0,n,i)},goog.events.listenWithWrapper=function(e,t,o,n,i){t.listen(e,o,n,i)},goog.events.unlisten=function(e,t,o,n,i){if(goog.isArray(t)){for(var r=0;r<t.length;r++)goog.events.unlisten(e,t[r],o,n,i);return null}return o=goog.events.wrapListener(o),goog.events.Listenable.isImplementedBy(e)?e.unlisten(t,o,n,i):!!e&&(n=!!n,!(!(e=goog.events.getListenerMap_(e))||!(t=e.getListener(t,o,n,i)))&&goog.events.unlistenByKey(t))},goog.events.unlistenByKey=function(e){if(goog.isNumber(e)||!e||e.removed)return!1;var t=e.src;if(goog.events.Listenable.isImplementedBy(t))return t.unlistenByKey(e);var o=e.type,n=e.proxy;return t.removeEventListener?t.removeEventListener(o,n,e.capture):t.detachEvent&&t.detachEvent(goog.events.getOnString_(o),n),goog.events.listenerCountEstimate_--,(o=goog.events.getListenerMap_(t))?(o.removeByKey(e),0==o.getTypeCount()&&(o.src=null,t[goog.events.LISTENER_MAP_PROP_]=null)):e.markAsRemoved(),!0},goog.events.unlistenWithWrapper=function(e,t,o,n,i){t.unlisten(e,o,n,i)},goog.events.removeAll=function(e,t){if(!e)return 0;if(goog.events.Listenable.isImplementedBy(e))return e.removeAllListeners(t);if(!(e=goog.events.getListenerMap_(e)))return 0;var o=0;for(var n in t=t&&t.toString(),e.listeners)if(!t||n==t)for(var i=e.listeners[n].concat(),r=0;r<i.length;++r)goog.events.unlistenByKey(i[r])&&++o;return o},goog.events.getListeners=function(e,t,o){return goog.events.Listenable.isImplementedBy(e)?e.getListeners(t,o):e&&(e=goog.events.getListenerMap_(e))?e.getListeners(t,o):[]},goog.events.getListener=function(e,t,o,n,i){return o=goog.events.wrapListener(o),n=!!n,goog.events.Listenable.isImplementedBy(e)?e.getListener(t,o,n,i):e&&(e=goog.events.getListenerMap_(e))?e.getListener(t,o,n,i):null},goog.events.hasListener=function(e,t,o){return goog.events.Listenable.isImplementedBy(e)?e.hasListener(t,o):!!(e=goog.events.getListenerMap_(e))&&e.hasListener(t,o)},goog.events.expose=function(e){var t,o=[];for(t in e)e[t]&&e[t].id?o.push(t+" = "+e[t]+" ("+e[t].id+")"):o.push(t+" = "+e[t]);return o.join("\n")},goog.events.getOnString_=function(e){return e in goog.events.onStringMap_?goog.events.onStringMap_[e]:goog.events.onStringMap_[e]=goog.events.onString_+e},goog.events.fireListeners=function(e,t,o,n){return goog.events.Listenable.isImplementedBy(e)?e.fireListeners(t,o,n):goog.events.fireListeners_(e,t,o,n)},goog.events.fireListeners_=function(e,t,o,n){var i=!0;if((e=goog.events.getListenerMap_(e))&&(t=e.listeners[t.toString()]))for(t=t.concat(),e=0;e<t.length;e++){var r=t[e];r&&r.capture==o&&!r.removed&&(r=goog.events.fireListener(r,n),i=i&&!1!==r)}return i},goog.events.fireListener=function(e,t){var o=e.listener,n=e.handler||e.src;return e.callOnce&&goog.events.unlistenByKey(e),o.call(n,t)},goog.events.getTotalListenerCount=function(){return goog.events.listenerCountEstimate_},goog.events.dispatchEvent=function(e,t){return goog.asserts.assert(goog.events.Listenable.isImplementedBy(e),"Can not use goog.events.dispatchEvent with non-goog.events.Listenable instance."),e.dispatchEvent(t)},goog.events.protectBrowserEventEntryPoint=function(e){goog.events.handleBrowserEvent_=e.protectEntryPoint(goog.events.handleBrowserEvent_)},goog.events.handleBrowserEvent_=function(e,t){if(e.removed)return!0;if(!goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT){var o=t||goog.getObjectByName("window.event");t=new goog.events.BrowserEvent(o,this);var n=!0;if(goog.events.CAPTURE_SIMULATION_MODE==goog.events.CaptureSimulationMode.ON){if(!goog.events.isMarkedIeEvent_(o)){goog.events.markIeEvent_(o),o=[];for(var i=t.currentTarget;i;i=i.parentNode)o.push(i);for(e=e.type,i=o.length-1;!t.propagationStopped_&&0<=i;i--){t.currentTarget=o[i];var r=goog.events.fireListeners_(o[i],e,!0,t);n=n&&r}for(i=0;!t.propagationStopped_&&i<o.length;i++)t.currentTarget=o[i],r=goog.events.fireListeners_(o[i],e,!1,t),n=n&&r}}else n=goog.events.fireListener(e,t);return n}return goog.events.fireListener(e,new goog.events.BrowserEvent(t,this))},goog.events.markIeEvent_=function(e){var t=!1;if(0==e.keyCode)try{return void(e.keyCode=-1)}catch(e){t=!0}(t||null==e.returnValue)&&(e.returnValue=!0)},goog.events.isMarkedIeEvent_=function(e){return 0>e.keyCode||null!=e.returnValue},goog.events.uniqueIdCounter_=0,goog.events.getUniqueId=function(e){return e+"_"+goog.events.uniqueIdCounter_++},goog.events.getListenerMap_=function(e){return(e=e[goog.events.LISTENER_MAP_PROP_])instanceof goog.events.ListenerMap?e:null},goog.events.LISTENER_WRAPPER_PROP_="__closure_events_fn_"+(1e9*Math.random()>>>0),goog.events.wrapListener=function(e){return goog.asserts.assert(e,"Listener can not be null."),goog.isFunction(e)?e:(goog.asserts.assert(e.handleEvent,"An object listener must have handleEvent method."),e[goog.events.LISTENER_WRAPPER_PROP_]||(e[goog.events.LISTENER_WRAPPER_PROP_]=function(t){return e.handleEvent(t)}),e[goog.events.LISTENER_WRAPPER_PROP_])},goog.debug.entryPointRegistry.register(function(e){goog.events.handleBrowserEvent_=e(goog.events.handleBrowserEvent_)}),goog.functions={},goog.functions.constant=function(e){return function(){return e}},goog.functions.FALSE=goog.functions.constant(!1),goog.functions.TRUE=goog.functions.constant(!0),goog.functions.NULL=goog.functions.constant(null),goog.functions.identity=function(e,t){return e},goog.functions.error=function(e){return function(){throw Error(e)}},goog.functions.fail=function(e){return function(){throw e}},goog.functions.lock=function(e,t){return t=t||0,function(){return e.apply(this,Array.prototype.slice.call(arguments,0,t))}},goog.functions.nth=function(e){return function(){return arguments[e]}},goog.functions.partialRight=function(e,t){var o=Array.prototype.slice.call(arguments,1);return function(){var t=Array.prototype.slice.call(arguments);return t.push.apply(t,o),e.apply(this,t)}},goog.functions.withReturnValue=function(e,t){return goog.functions.sequence(e,goog.functions.constant(t))},goog.functions.equalTo=function(e,t){return function(o){return t?e==o:e===o}},goog.functions.compose=function(e,t){var o=arguments,n=o.length;return function(){var e;n&&(e=o[n-1].apply(this,arguments));for(var t=n-2;0<=t;t--)e=o[t].call(this,e);return e}},goog.functions.sequence=function(e){var t=arguments,o=t.length;return function(){for(var e,n=0;n<o;n++)e=t[n].apply(this,arguments);return e}},goog.functions.and=function(e){var t=arguments,o=t.length;return function(){for(var e=0;e<o;e++)if(!t[e].apply(this,arguments))return!1;return!0}},goog.functions.or=function(e){var t=arguments,o=t.length;return function(){for(var e=0;e<o;e++)if(t[e].apply(this,arguments))return!0;return!1}},goog.functions.not=function(e){return function(){return!e.apply(this,arguments)}},goog.functions.create=function(e,t){var o=function(){};return o.prototype=e.prototype,o=new o,e.apply(o,Array.prototype.slice.call(arguments,1)),o},goog.functions.CACHE_RETURN_VALUE=!0,goog.functions.cacheReturnValue=function(e){var t,o=!1;return function(){return goog.functions.CACHE_RETURN_VALUE?(o||(t=e(),o=!0),t):e()}},goog.functions.once=function(e){var t=e;return function(){if(t){var e=t;t=null,e()}}},goog.functions.debounce=function(e,t,o){var n=0;return function(i){goog.global.clearTimeout(n);var r=arguments;n=goog.global.setTimeout(function(){e.apply(o,r)},t)}},goog.functions.throttle=function(e,t,o){var n=0,i=!1,r=[],l=function(){n=0,i&&(i=!1,s())},s=function(){n=goog.global.setTimeout(l,t),e.apply(o,r)};return function(e){r=arguments,n?i=!0:s()}},goog.functions.rateLimit=function(e,t,o){var n=0,i=function(){n=0};return function(r){n||(n=goog.global.setTimeout(i,t),e.apply(o,arguments))}},goog.async={},goog.async.AnimationDelay=function(e,t,o){goog.Disposable.call(this),this.id_=null,this.usingListeners_=!1,this.listener_=e,this.handler_=o,this.win_=t||window,this.callback_=goog.bind(this.doAction_,this)},goog.inherits(goog.async.AnimationDelay,goog.Disposable),goog.async.AnimationDelay.TIMEOUT=20,goog.async.AnimationDelay.MOZ_BEFORE_PAINT_EVENT_="MozBeforePaint",goog.async.AnimationDelay.prototype.start=function(){this.stop(),this.usingListeners_=!1;var e=this.getRaf_(),t=this.getCancelRaf_();e&&!t&&this.win_.mozRequestAnimationFrame?(this.id_=goog.events.listen(this.win_,goog.async.AnimationDelay.MOZ_BEFORE_PAINT_EVENT_,this.callback_),this.win_.mozRequestAnimationFrame(null),this.usingListeners_=!0):this.id_=e&&t?e.call(this.win_,this.callback_):this.win_.setTimeout(goog.functions.lock(this.callback_),goog.async.AnimationDelay.TIMEOUT)},goog.async.AnimationDelay.prototype.stop=function(){if(this.isActive()){var e=this.getRaf_(),t=this.getCancelRaf_();e&&!t&&this.win_.mozRequestAnimationFrame?goog.events.unlistenByKey(this.id_):e&&t?t.call(this.win_,this.id_):this.win_.clearTimeout(this.id_)}this.id_=null},goog.async.AnimationDelay.prototype.fire=function(){this.stop(),this.doAction_()},goog.async.AnimationDelay.prototype.fireIfActive=function(){this.isActive()&&this.fire()},goog.async.AnimationDelay.prototype.isActive=function(){return null!=this.id_},goog.async.AnimationDelay.prototype.doAction_=function(){this.usingListeners_&&this.id_&&goog.events.unlistenByKey(this.id_),this.id_=null,this.listener_.call(this.handler_,goog.now())},goog.async.AnimationDelay.prototype.disposeInternal=function(){this.stop(),goog.async.AnimationDelay.superClass_.disposeInternal.call(this)},goog.async.AnimationDelay.prototype.getRaf_=function(){var e=this.win_;return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||null},goog.async.AnimationDelay.prototype.getCancelRaf_=function(){var e=this.win_;return e.cancelAnimationFrame||e.cancelRequestAnimationFrame||e.webkitCancelRequestAnimationFrame||e.mozCancelRequestAnimationFrame||e.oCancelRequestAnimationFrame||e.msCancelRequestAnimationFrame||null},Blockly.AutoScroll=function(e,t){this.blockSpace_=e,this.activePanVector_=t,this.animationDelay_=new goog.async.AnimationDelay(this.handleAnimationDelay_.bind(this),window),this.lastTime_=Date.now(),this.animationDelay_.start()},Blockly.AutoScroll.prototype.stopAndDestroy=function(){this.activePanVector_=null,this.animationDelay_.dispose(),this.lastMouseY_=this.lastMouseX_=null},Blockly.AutoScroll.prototype.handleAnimationDelay_=function(e){var t=e-this.lastTime_;this.lastTime_=e,this.scrollTick_(t),this.animationDelay_.start()},Blockly.AutoScroll.prototype.scrollTick_=function(e){this.blockSpace_.scrollDeltaWithAnySelectedBlock(this.activePanVector_.x*e,this.activePanVector_.y*e,this.lastMouseX_,this.lastMouseY_)},Blockly.AutoScroll.prototype.updateProperties=function(e,t,o){this.activePanVector_=e,this.lastMouseX_=t,this.lastMouseY_=o},goog.math.Vec2=function(e,t){this.x=e,this.y=t},goog.inherits(goog.math.Vec2,goog.math.Coordinate),goog.math.Vec2.randomUnit=function(){var e=Math.random()*Math.PI*2;return new goog.math.Vec2(Math.cos(e),Math.sin(e))},goog.math.Vec2.random=function(){var e=Math.sqrt(Math.random()),t=Math.random()*Math.PI*2;return new goog.math.Vec2(Math.cos(t)*e,Math.sin(t)*e)},goog.math.Vec2.fromCoordinate=function(e){return new goog.math.Vec2(e.x,e.y)},goog.math.Vec2.prototype.clone=function(){return new goog.math.Vec2(this.x,this.y)},goog.math.Vec2.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},goog.math.Vec2.prototype.squaredMagnitude=function(){return this.x*this.x+this.y*this.y},goog.math.Vec2.prototype.scale=goog.math.Coordinate.prototype.scale,goog.math.Vec2.prototype.invert=function(){return this.x=-this.x,this.y=-this.y,this},goog.math.Vec2.prototype.normalize=function(){return this.scale(1/this.magnitude())},goog.math.Vec2.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},goog.math.Vec2.prototype.subtract=function(e){return this.x-=e.x,this.y-=e.y,this},goog.math.Vec2.prototype.rotate=function(e){var t=Math.cos(e);e=Math.sin(e);var o=this.y*t+this.x*e;return this.x=this.x*t-this.y*e,this.y=o,this},goog.math.Vec2.rotateAroundPoint=function(e,t,o){return e.clone().subtract(t).rotate(o).add(t)},goog.math.Vec2.prototype.equals=function(e){return this==e||e instanceof goog.math.Vec2&&!!e&&this.x==e.x&&this.y==e.y},goog.math.Vec2.distance=goog.math.Coordinate.distance,goog.math.Vec2.squaredDistance=goog.math.Coordinate.squaredDistance,goog.math.Vec2.equals=goog.math.Coordinate.equals,goog.math.Vec2.sum=function(e,t){return new goog.math.Vec2(e.x+t.x,e.y+t.y)},goog.math.Vec2.difference=function(e,t){return new goog.math.Vec2(e.x-t.x,e.y-t.y)},goog.math.Vec2.dot=function(e,t){return e.x*t.x+e.y*t.y},goog.math.Vec2.determinant=function(e,t){return e.x*t.y-e.y*t.x},goog.math.Vec2.lerp=function(e,t,o){return new goog.math.Vec2(goog.math.lerp(e.x,t.x,o),goog.math.lerp(e.y,t.y,o))},Blockly.ScrollOnBlockDragHandler=function(e){this.blockSpace_=e,this.SCROLL_DIRECTION_VECTORS={top:new goog.math.Vec2(0,-1),bottom:new goog.math.Vec2(0,1),left:new goog.math.Vec2(-1,0),right:new goog.math.Vec2(1,0)}},Blockly.ScrollOnBlockDragHandler.prototype.stopAutoScrolling=function(){this.activeAutoScroll_&&this.activeAutoScroll_.stopAndDestroy(),this.activeAutoScroll_=null};var MOUSE_SPEED_SLOW=.5,MOUSE_SPEED_FAST=1.6,BLOCK_SPEED_SLOW=.28,BLOCK_SPEED_FAST=1.4,MOUSE_START_DISTANCE=0,MOUSE_START_FAST_DISTANCE=35,BLOCK_START_DISTANCE=0,BLOCK_START_FAST_DISTANCE=50,OVERSIZE_BLOCK_THRESHOLD=.85,FALLBACK_DRAG_MARGIN=15;Blockly.ScrollOnBlockDragHandler.DEBUG=!1,Blockly.ScrollOnBlockDragHandler.prototype.panIfOverEdge=function(e,t,o){if(this.blockSpace_.currentlyScrollable()){var n=[];if(this.blockSpace_.scrollbarPair&&this.blockSpace_.scrollbarPair.canScrollHorizontally()&&n.push("left","right"),this.blockSpace_.scrollbarPair&&this.blockSpace_.scrollbarPair.canScrollVertically()&&n.push("top","bottom"),0!==n.length){var i=Blockly.mouseCoordinatesToSvg(t,o,this.blockSpace_.blockSpaceEditor.svg_);i=Blockly.svgCoordinatesToViewport(new goog.math.Coordinate(i.x,i.y),this.blockSpace_),i=Blockly.viewportCoordinateToBlockSpace(i,this.blockSpace_);var r=this.blockSpace_.getViewportBox(),l=e.getBox(),s=Blockly.getBoxHeight(l),a=Blockly.getBoxHeight(r);s>a*OVERSIZE_BLOCK_THRESHOLD&&(l.top=Math.max(l.top,i.y-FALLBACK_DRAG_MARGIN),l.bottom=Math.min(l.bottom,i.y+FALLBACK_DRAG_MARGIN)),(s=Blockly.getBoxWidth(l))>(a=Blockly.getBoxWidth(r))*OVERSIZE_BLOCK_THRESHOLD&&(l.left=Math.max(l.left,i.x-FALLBACK_DRAG_MARGIN),l.right=Math.min(l.right,i.x+FALLBACK_DRAG_MARGIN));var g=Blockly.getBoxOverflow(r,l),c=Blockly.getPointBoxOverflow(r,new goog.math.Coordinate(i.x,i.y));Blockly.ScrollOnBlockDragHandler.DEBUG&&(this.blockSpace_.drawDebugCircle("mouse circle",new goog.math.Coordinate(i.x,i.y),"orange"),this.blockSpace_.drawDebugBox("block box"+e.id,l,"purple"),this.blockSpace_.drawDebugBox("block space box",r,"blue"));var u=new goog.math.Vec2(0,0);n.forEach(function(e){var t=c[e],o=g[e];e=this.SCROLL_DIRECTION_VECTORS[e];var n=[];Blockly.numberWithin(o,BLOCK_START_DISTANCE,BLOCK_START_FAST_DISTANCE,!1)&&n.push(e.clone().scale(BLOCK_SPEED_SLOW)),o>BLOCK_START_FAST_DISTANCE&&n.push(e.clone().scale(BLOCK_SPEED_FAST)),Blockly.numberWithin(t,MOUSE_START_DISTANCE,MOUSE_START_FAST_DISTANCE,!1)&&n.push(e.clone().scale(MOUSE_SPEED_SLOW)),t>MOUSE_START_FAST_DISTANCE&&n.push(e.clone().scale(MOUSE_SPEED_FAST)),(t=n.reduce(function(e,t){return e&&e.magnitude()>t.magnitude()?e:t},null))&&(u=goog.math.Vec2.sum(u,t))},this),u.equals(new goog.math.Vec2(0,0))?this.stopAutoScrolling():(this.activeAutoScroll_=this.activeAutoScroll_||new Blockly.AutoScroll(this.blockSpace_,u),this.activeAutoScroll_.updateProperties(u,t,o))}}},Blockly.Xml={},Blockly.Xml.blockSpaceToDom=function(e){var t=Blockly.isMsie()?document.createElementNS(null,"xml"):document.createElement("xml");e=e.getTopBlocks(!0);for(var o,n=0;n<e.length;n++)o=e[n],o=Blockly.Xml.blockToDom(o),t.appendChild(o);return t},Blockly.Xml.blockToDom=function(e,t){var o,n,i,r=goog.dom.createDom("block");for(r.setAttribute("type",e.type),e.mutationToDom&&(i=e.mutationToDom())&&r.appendChild(i),e.miniFlyoutBlocks&&e.isMiniFlyoutOpen&&r.setAttribute("miniFlyout","open"),o=0;o<e.inputList.length;o++)for(i=e.inputList[o],n=0;n<i.titleRow.length;n++){var l=i.titleRow[n];if(l.name&&l.EDITABLE){var s=goog.dom.createDom("field",null,l.getValue());s.setAttribute("name",l.name),l.config&&s.setAttribute("config",l.config),l.id&&s.setAttribute("id",l.id),r.appendChild(s)}}for(o=0;o<e.inputList.length;o++)if(n=!0,(i=e.inputList[o]).type!=Blockly.DUMMY_INPUT){if(l=!1,s=i.connection.targetBlock(),i.type===Blockly.INPUT_VALUE)var a=goog.dom.createDom("value");else i.type===Blockly.NEXT_STATEMENT?(a=goog.dom.createDom("statement"),l=t):i.type===Blockly.FUNCTIONAL_INPUT&&(a=goog.dom.createDom("functional_input"),l=t);s&&!l&&(a.appendChild(Blockly.Xml.blockToDom(s)),n=!1),a.setAttribute("name",i.name),n||r.appendChild(a)}return e.isCollapsed()&&r.setAttribute("collapsed",!0),e.disabled&&r.setAttribute("disabled",!0),e.isDeletable()||r.setAttribute("deletable",!1),e.isMovable()||r.setAttribute("movable",!1),e.isEditable()||r.setAttribute("editable",!1),e.isUserVisible()||r.setAttribute("uservisible",!1),e.inputCount&&r.setAttribute("inputcount",String(e.inputCount)),e.isNextConnectionDisabled()&&r.setAttribute("next_connection_disabled",!0),e.canDisconnectFromParent()||r.setAttribute("can_disconnect_from_parent",!1),e.isFunctionDefinition()&&e.userCreated&&r.setAttribute("usercreated",!0),Blockly.editBlocks&&(a=e.blockSpace.blockSpaceEditor.blockLimits.getLimit(e.type))&&r.setAttribute("limit",a),e.htmlId&&r.setAttribute("id",e.htmlId),e.nextConnection&&!t&&(e=e.nextConnection.targetBlock())&&(a=goog.dom.createDom("next",null,Blockly.Xml.blockToDom(e)),r.appendChild(a)),r},Blockly.Xml.domToText=function(e){return(new XMLSerializer).serializeToString(e).replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g,"")},Blockly.Xml.domToPrettyText=function(e){e=Blockly.Xml.domToText(e).split("<");for(var t="",o=1;o<e.length;o++){var n=e[o];"/"==n[0]&&(t=t.substring(2)),e[o]=t+"<"+n,"/"!=n[0]&&"/>"!=n.slice(-2)&&(t+="  ")}return(e=(e=e.join("\n")).replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>")).replace(/^\n/,"")},Blockly.Xml.textToDom=function(e){if(!(e=(new DOMParser).parseFromString(e,"text/xml"))||!e.firstChild||"xml"!=e.firstChild.nodeName.toLowerCase())throw"Blockly.Xml.textToDom did not obtain a valid XML tree.";return e.firstChild},Blockly.Xml.domToBlockSpace=function(e,t){var o=e.getMetrics(),n=o?o.viewWidth:0,i=e.blockSpaceEditor.inline_,r=e.blockSpaceEditor.shouldHavePadding()?Blockly.BlockSpace.AUTO_LAYOUT_PADDING_LEFT:0;o=e.blockSpaceEditor.shouldHavePadding()?Blockly.BlockSpace.AUTO_LAYOUT_PADDING_TOP:0;var l=r,s=o;o=function(e){var t=e.blockly_block.getSvgPadding()||{top:0,right:0,bottom:0,left:0},o=e.blockly_block.getHeightWidth();Blockly.RTL&&(l=i?o.width-r:n-r),isNaN(e.x)?(e.x=l,e.x+=Blockly.RTL?-t.right:t.left):e.x=Blockly.RTL?n-e.x:e.x,isNaN(e.y)&&(e.y=s+t.top,s+=o.height+Blockly.BlockSvg.SEP_SPACE_Y+t.bottom+t.top),e.blockly_block.moveTo(e.x,e.y)};for(var a,g=[],c=0;a=t.childNodes[c];c++)if("block"===a.nodeName.toLowerCase()){var u=Blockly.Xml.domToBlock(e,a),h=parseInt(a.getAttribute("x"),10);a=parseInt(a.getAttribute("y"),10),g.push({blockly_block:u,x:h,y:a})}return g.filter(function(e){return e.blockly_block.isVisible()}).forEach(o),g.filter(function(e){return!e.blockly_block.isVisible()}).forEach(o),Blockly.topLevelProcedureAutopopulate&&e.blockSpaceEditor.updateFlyout(),e.events.dispatchEvent(Blockly.BlockSpace.EVENTS.EVENT_BLOCKS_IMPORTED),e.render(),g},Blockly.Xml.domToBlock=function(e,t){var o=t.getAttribute("type"),n=t.getAttribute("id");(o=new Blockly.Block(e,o,n)).initSvg(),(n=t.getAttribute("collapsed"))&&o.setCollapsed("true"===n),(n=t.getAttribute("disabled"))&&!o.unknownBlock&&o.setDisabled("true"===n),(n=t.getAttribute("deletable"))&&!o.unknownBlock&&o.setDeletable("true"===n),(n=t.getAttribute("movable"))&&!o.unknownBlock&&o.setMovable("true"===n),(n=t.getAttribute("editable"))&&o.setEditable("true"===n),o.unknownBlock&&o.setEditable(!1),(n=t.getAttribute("next_connection_disabled"))&&o.setNextConnectionDisabled("true"===n),(n=t.getAttribute("can_disconnect_from_parent"))&&o.setCanDisconnectFromParent("true"===n),(n=t.getAttribute("uservisible"))&&o.setUserVisible("true"===n),(n=t.getAttribute("usercreated"))&&(o.userCreated="true"===n),(n=t.getAttribute("inputcount"))&&o.setInputCount(n),n=t.getAttribute("limit");var i=Blockly.editBlocks?!e.isFlyout:e.isFlyout;for(n&&i&&e.blockSpaceEditor.blockLimits.setLimit(o.type,parseInt(n)),"open"==t.getAttribute("miniflyout")&&(o.isMiniFlyoutOpen=!0,o.setTitleValue("-","toggle")),n=0;n<t.childNodes.length;n++)if(3!=(i=t.childNodes[n]).nodeType||!i.data.match(/^\s*$/)){for(var r,l=null,s=0;s<i.childNodes.length;s++)3==(r=i.childNodes[s]).nodeType&&r.data.match(/^\s*$/)||(l=r);switch(s=i.getAttribute("name"),r=o.getInput(s),i.nodeName.toLowerCase()){case"mutation":o.domToMutation&&o.domToMutation(i);break;case"title":case"field":(l=i.getAttribute("config"))&&o.setFieldConfig(s,l),o.setTitleValue(i.textContent,s),l=o.getTitle_(s),i.id?l.id=i.id:"behavior_definition"!==o.type&&"gamelab_behavior_get"!==o.type||(l.id=i.textContent);break;case"value":r||(r=o.appendValueInput(s),console.warn('Unknown block input: "'+s+'" not found.'));case"statement":r||(r=o.appendStatementInput(s),console.warn('Unknown statement: "'+s+'" not found.'));case"functional_input":if(r||(r=o.appendFunctionalInput(s),console.warn('Unknown functional input: "'+s+'" not found.')),l&&"block"==l.nodeName.toLowerCase()){if(i=Blockly.Xml.domToBlock(e,l),o.unknownBlock&&i.setMovable(!0),i.unknownBlock)switch(r.connection.type){case Blockly.NEXT_STATEMENT:i.setPreviousStatement(!0);break;case Blockly.INPUT_VALUE:i.setOutput(!0);break;default:throw"Unable to infer connection type for unknown block."}if(i.outputConnection)r.connection.connect(i.outputConnection);else{if(!i.previousConnection)throw"Child block does not have output or previous statement.";r.connection.connect(i.previousConnection)}}break;case"next":if(l&&"block"==l.nodeName.toLowerCase()){if(o.nextConnection){if(o.nextConnection.targetConnection)throw"Next statement is already connected."}else{if(!o.unknownBlock)throw"Next statement does not exist.";o.setNextStatement(!0)}if(i=Blockly.Xml.domToBlock(e,l),o.unknownBlock&&i.setMovable(!0),i.unknownBlock&&i.setPreviousStatement(!0),!i.previousConnection)throw"Next block does not have previous statement.";o.nextConnection.connect(i.previousConnection)}}}return(e=o.nextConnection&&o.nextConnection.targetBlock())&&e.render(!0),o.render(!0),o},Blockly.Xml.deleteNext=function(e){for(var t,o=0;o<e.childNodes.length;o++)if("next"==(t=e.childNodes[o]).nodeName.toLowerCase()){e.removeChild(t);break}},Blockly.BlockSpace=function(e,t,o){this.blockSpaceEditor=e,this.getMetrics=t,this.setMetrics=function(e){o(e),Blockly.fireUiEvent(window,"block_space_metrics_set")},this.isFlyout=!1,this.topBlocks_=[],this.deleteAreas_=[],this.pickedUpBlockOrigin_=null,this.maxBlocks=1/0,this.events=new goog.events.EventTarget,this.panDragHandler_=new Blockly.PanDragHandler(this),this.scrollOnWheelHandler_=new Blockly.ScrollOnWheelHandler(this),this.scrollOnBlockDragHandler_=new Blockly.ScrollOnBlockDragHandler(this),Blockly.ConnectionDB.init(this),Blockly.BlockSpace.DEBUG_EVENTS&&this.debugLogOnEvents(),this.events.listen(Blockly.BlockSpace.EVENTS.EVENT_BLOCKS_IMPORTED,this.updateScrollableSize.bind(this))},Blockly.BlockSpace.DEBUG_EVENTS=!1,Blockly.BlockSpace.EVENTS={},Blockly.BlockSpace.EVENTS.MAIN_BLOCK_SPACE_CREATED="mainBlockSpaceCreated",Blockly.BlockSpace.EVENTS.EVENT_BLOCKS_IMPORTED="blocksImported",Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE="blockSpaceChange",Blockly.BlockSpace.EVENTS.BLOCK_SPACE_SCROLLED="blockSpaceScrolled",Blockly.BlockSpace.EVENTS.RUN_BUTTON_CLICKED="runButtonClicked",Blockly.BlockSpace.EVENTS.ANIMATIONS_CHANGED="animationsChanged",Blockly.BlockSpace.SCAN_ANGLE=3,Blockly.BlockSpace.AUTO_LAYOUT_PADDING_TOP=16,Blockly.BlockSpace.AUTO_LAYOUT_PADDING_LEFT=16,Blockly.BlockSpace.DROPPED_BLOCK_PAN_MARGIN=25,Blockly.BlockSpace.SCROLLABLE_MARGIN_BELOW_BOTTOM=100,Blockly.BlockSpace.createReadOnlyBlockSpace=function(e,t,o){return o=o||{},e=new Blockly.BlockSpaceEditor(e,{getMetrics:function(){var e=Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_.call(this);return e?(e.viewHeight+=Blockly.BlockSpace.SCROLLABLE_MARGIN_BELOW_BOTTOM,e):null},setMetrics:function(e){Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_.call(this,e)},hideTrashRect:!0,readOnly:!0,disableTooltip:!0,noScrolling:o.noScrolling,inline:o.inline,disableEventBindings:o.disableEventBindings}).blockSpace,Blockly.Xml.domToBlockSpace(e,t),e},Blockly.BlockSpace.onMainBlockSpaceCreated=function(e){Blockly.mainBlockSpace?e():document.addEventListener(Blockly.BlockSpace.EVENTS.MAIN_BLOCK_SPACE_CREATED,e)},Blockly.BlockSpace.prototype.xOffsetFromView=0,Blockly.BlockSpace.prototype.yOffsetFromView=0,Blockly.BlockSpace.prototype.trashcan=null;var fireGlobalChangeEventPid_=Blockly.BlockSpace.prototype.fireChangeEventPid_=null;Blockly.BlockSpace.prototype.scrollbarPair=null,Blockly.BlockSpace.prototype.isReadOnly=function(){return Blockly.readOnly||this.blockSpaceEditor.isReadOnly()},Blockly.BlockSpace.prototype.isMovementLocked=function(){return this.blockSpaceEditor.isMovementLocked()},Blockly.BlockSpace.prototype.debugLogOnEvents=function(){goog.object.forEach(Blockly.BlockSpace.EVENTS,function(e,t){this.events.listen(e,function(o){console.log(o),console.log(t),console.log(e)},!1,this)},this)},Blockly.BlockSpace.prototype.findFunction=function(e){return goog.array.find(this.getTopBlocks(),function(t){return goog.array.contains(Blockly.Procedures.DEFINITION_BLOCK_TYPES,t.type)&&Blockly.Names.equals(e,t.getTitle_("NAME").id||t.getTitleValue("NAME"))})},Blockly.BlockSpace.prototype.findFunctionExamples=function(e){return goog.array.filter(this.getTopBlocks(),function(t){return Blockly.ContractEditor.EXAMPLE_BLOCK_TYPE===t.type&&((t=t.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME))&&(!e||Blockly.Names.equals(e,t.getTitleValue("NAME"))))})},Blockly.BlockSpace.prototype.resizeWidth=function(e){this.clipRect_&&this.clipRect_.width!==e&&this.clipRect_.setAttribute("width",e)},Blockly.BlockSpace.prototype.resizeHeight=function(){var e=this.getMetrics()&&this.getMetrics().contentHeight;e&&this.clipRect_&&this.clipRect_.setAttribute("height",e)},Blockly.BlockSpace.prototype.createDom=function(e){this.svgGroup_=Blockly.createSvgElement("g",{class:"svgGroup"},null),this.clippingGroup_=Blockly.createSvgElement("g",{class:"svgClippingGroup"},this.svgGroup_);var t={class:"svgBlockCanvas"};return e&&(this.defs_=Blockly.createSvgElement("defs",{},this.clippingGroup_),this.clipPath_=Blockly.createSvgElement("clipPath",{id:"clipToolbox"},this.defs_),this.clipRect_=Blockly.createSvgElement("rect",{x:"0",y:"0"},this.clipPath_),t["clip-path"]="url(#clipToolbox)"),this.svgBlockCanvas_=Blockly.createSvgElement("g",t,this.clippingGroup_),this.svgBubbleCanvas_=Blockly.createSvgElement("g",{class:"svgBubbleCanvas"},this.svgGroup_),this.svgDebugCanvas_=Blockly.createSvgElement("g",{class:"svgDebugCanvas"},this.svgGroup_),Blockly.dragSvg||(Blockly.dragSvg=Blockly.createSvgElement("svg",{id:"blocklyDragCanvas",width:"100%",height:"100%"},document.body)),this.svgDragCanvas_=Blockly.createSvgElement("g",{class:"svgDragCanvas"},Blockly.dragSvg),Blockly.bindEvent_(this.svgBlockCanvas_,Blockly.BlockSpace.EVENTS.RUN_BUTTON_CLICKED,this,function(){this.getTopBlocks().forEach(function(e){e.isUnused()&&e.getSvgRenderer().addUnusedFrame()})}),this.fireChangeEvent(),this.svgGroup_},Blockly.BlockSpace.prototype.moveElementToDragCanvas=function(e){this.getDragCanvas().appendChild(e),Blockly.addClass_(Blockly.dragSvg,"isDragging")},Blockly.BlockSpace.prototype.moveElementToMainCanvas=function(e){this.getCanvas().appendChild(e),Blockly.removeClass_(Blockly.dragSvg,"isDragging")},Blockly.BlockSpace.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null),this.svgDragCanvas_&&goog.dom.removeNode(this.svgDragCanvas_),this.svgBubbleCanvas_=this.svgDebugCanvas_=this.svgDragCanvas_=this.svgBlockCanvas_=null,this.flyout_&&(this.flyout_.dispose(),this.flyout_=null),this.trashcan&&(this.trashcan.dispose(),this.trashcan=null),this.scrollbarPair&&(this.scrollbarPair.dispose(),this.scrollbarPair=null)},Blockly.BlockSpace.prototype.addTrashcan=function(){if(Blockly.hasTrashcan&&!this.isReadOnly()){this.trashcan=new Blockly.Trashcan(this);var e=this.trashcan.createDom();this.svgBlockCanvas_.appendChild(e),this.trashcan.init()}},Blockly.BlockSpace.prototype.setTrashcan=function(e){this.trashcan=e},Blockly.BlockSpace.prototype.getClippingGroup=function(){return this.clippingGroup_},Blockly.BlockSpace.prototype.getCanvas=function(){return this.svgBlockCanvas_},Blockly.BlockSpace.prototype.getDragCanvas=function(){return this.svgDragCanvas_},Blockly.BlockSpace.prototype.getBubbleCanvas=function(){return this.svgBubbleCanvas_},Blockly.BlockSpace.prototype.addTopBlock=function(e){this.topBlocks_.push(e),this.fireChangeEvent()},Blockly.BlockSpace.prototype.isTopBlock=function(e){return-1<this.topBlocks_.indexOf(e)},Blockly.BlockSpace.prototype.removeTopBlock=function(e){for(var t=!1,o=0;o<this.topBlocks_.length;o++)if(this.topBlocks_[o]==e){this.topBlocks_.splice(o,1),t=!0;break}if(!t)throw"Block not present this blockSpace's list of top-most blocks.";this.fireChangeEvent()},Blockly.BlockSpace.prototype.getTopBlocks=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!0);var o=[];if(o=!t||this!==Blockly.mainBlockSpace&&this!==Blockly.modalBlockSpace?o.concat(this.topBlocks_):o.concat(Blockly.mainBlockSpace.topBlocks_).concat(Blockly.modalBlockSpace?Blockly.modalBlockSpace.topBlocks_:[]),e&&1<o.length){var n=Math.sin(Blockly.BlockSpace.SCAN_ANGLE/180*Math.PI);Blockly.RTL&&(n*=-1),o.sort(function(e,t){return e=e.getRelativeToSurfaceXY(),t=t.getRelativeToSurfaceXY(),e.y+n*e.x-(t.y+n*t.x)})}return o},Blockly.BlockSpace.prototype.getAllVisibleBlocks=function(){return goog.array.filter(this.getAllBlocks(),function(e){return e.isUserVisible()})},Blockly.BlockSpace.prototype.getAllUsedBlocks=function(){return goog.array.filter(this.getAllBlocks(),function(e){return!e.getRootBlock().isUnused()})},Blockly.BlockSpace.prototype.getTopUsedBlocks=function(){return goog.array.filter(this.getTopBlocks(),function(e){return!e.isUnused()})},Blockly.BlockSpace.prototype.getAllBlocks=function(e){e=e||{},e=this.getTopBlocks(!1,e.shareMainModal);for(var t=0;t<e.length;t++)e=e.concat(e[t].getChildren());return e},Blockly.BlockSpace.prototype.getBlockCount=function(){return this.getAllVisibleBlocks().length},Blockly.BlockSpace.prototype.clear=function(){for(this.blockSpaceEditor.hideChaff();this.topBlocks_.length;)this.topBlocks_[0].dispose()},Blockly.BlockSpace.prototype.render=function(){for(var e,t=this.getAllVisibleBlocks(),o=0;o<t.length;o++)(e=t[o]).getChildren().length||e.render()},Blockly.BlockSpace.prototype.getBlockById=function(e){for(var t,o=this.getAllBlocks(),n=0;n<o.length;n++)if((t=o[n]).id==e)return t;return null},Blockly.BlockSpace.prototype.traceOn=function(e){this.traceOn_=e,this.traceWrapper_&&(Blockly.unbindEvent_(this.traceWrapper_),this.traceWrapper_=null),e&&(this.traceWrapper_=Blockly.bindEvent_(this.svgBlockCanvas_,"blocklySelectChange",this,function(){this.traceOn_=!1}))},Blockly.BlockSpace.prototype.highlightBlock=function(e,t){if(this.traceOn_&&!Blockly.Block.isDragging()){var o=null;if(e&&!(o=this.getBlockById(e)))return;this.traceOn(!1),o?o.select(t):Blockly.selected&&Blockly.selected.unselect(),this.traceOn(!0)}},Blockly.BlockSpace.prototype.fireChangeEvent=function(){this.fireChangeEventPid_&&window.clearTimeout(this.fireChangeEventPid_);var e=this.svgBlockCanvas_;if(e){var t=this;this.fireChangeEventPid_=window.setTimeout(function(){t.events.dispatchEvent(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE),Blockly.fireUiEvent(e,"blocklyBlockSpaceChange")},0)}fireGlobalChangeEventPid_&&window.clearTimeout(fireGlobalChangeEventPid_),fireGlobalChangeEventPid_=window.setTimeout(function(){Blockly.fireUiEvent(window,"workspaceChange")},0)},Blockly.BlockSpace.prototype.paste=function(e){this===Blockly.mainBlockSpace&&goog.array.forEach(e.querySelectorAll("block[type=parameters_get]"),function(e){goog.dom.removeNode(e)}),e.getElementsByTagName("block").length>=this.remainingCapacity()||((e=Blockly.Xml.domToBlockSpace(this,e)).forEach(function(e){e.blockly_block.bumpNeighbours()}),e[0].blockly_block.select())},Blockly.BlockSpace.prototype.remainingCapacity=function(){return 1/0==this.maxBlocks?1/0:this.maxBlocks-this.getAllBlocks().length},Blockly.BlockSpace.prototype.recordPickedUpBlockOrigin=function(){var e=this.blockSpaceEditor.getCanvasBBox(this.getDragCanvas());this.pickedUpBlockOrigin_=Blockly.svgRectToRect(e)},Blockly.BlockSpace.prototype.clearPickedUpBlockOrigin=function(){this.pickedUpBlockOrigin_=null},Blockly.BlockSpace.prototype.recordDeleteAreas=function(){this.deleteAreas_=[],this.trashcan?(goog.array.extend(this.deleteAreas_,this.trashcan.getRect()),this.deleteAreaTrash_=this.trashcan.getRect()):this.deleteAreaTrash_=null,this.flyout_&&goog.array.extend(this.deleteAreas_,this.flyout_.getRect()),this.blockSpaceEditor&&goog.array.extend(this.deleteAreas_,this.blockSpaceEditor.getDeleteAreas())},Blockly.BlockSpace.prototype.isDeleteArea=function(e,t,o,n){if(!Blockly.languageTree)return!1;for(e=Blockly.mouseCoordinatesToSvg(e,t,this.blockSpaceEditor.svg_),e=new goog.math.Coordinate(e.x,e.y),o=Blockly.mouseCoordinatesToSvg(o,0,this.blockSpaceEditor.svg_),o=new goog.math.Coordinate(o.x,o.x),this.deleteAreaTrash_&&(this.deleteAreaTrash_.contains(e)?this.trashcan.setOpen_(!0):this.trashcan.setOpen_(!1)),this.drawTrashZone(e.x,o.x,n),n=0;n<this.deleteAreas_.length;n++)if((o=this.deleteAreas_[n]).contains(e))return!0;return this.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),!1},Blockly.BlockSpace.prototype.hideDelete=function(){this.drawTrashZone(Blockly.RTL?-1e4:1e4,0)},Blockly.BlockSpace.prototype.drawTrashZone=function(e,t,o){var n=null,i=this.blockSpaceEditor.hideTrashRect_?Blockly.mainBlockSpaceEditor:this.blockSpaceEditor;if(this.blockSpaceEditor.toolbox){var r=i.toolbox,l=i.svgBackground_,s=r.tree_.element_,a=r.trashcan;r=r.trashcanHolder,this.blockSpaceEditor.hideTrashRect_&&(n=this.blockSpaceEditor.toolbox.tree_.element_)}else l=(a=i.flyout_).svgBackground_,s=a.blockSpace_.svgGroup_,r=(a=a.trashcan).svgGroup_,this.blockSpaceEditor.hideTrashRect_&&(n=this.blockSpaceEditor.flyout_.svgGroup_);var g=l.getBoundingClientRect().width;if(Blockly.RTL){var c=e>t+10;e=(i=i.svg_.getBoundingClientRect().width-g)-e,i=i-t-10}else c=e<t-10,e-=g,i=t-g-10;t=1,g=1-.8,o?a.setDisabled(!0):a.setDisabled(!1),c&&(0>=e?(t=0,o||a.setOpen_(!0)):(a.setOpen_(!1),t=e>=i?1:100>i?e/i:100>e?e/100*.8:.8+(e-100)/(i-100)*g)),o=1-t,l.style.fill="rgb("+Math.floor(170*o+221*t)+", "+Math.floor(170*o+221*t)+", "+Math.floor(170*o+221*t)+")",s.style.opacity=t,n&&(n.style.opacity=t),r.style.opacity=o,r.style.display=0===o?"none":"block"},Blockly.BlockSpace.prototype.getScrollableSize=function(e){var t=this.scrollbarPair,o=t&&t.canScrollHorizontally();t=t&&t.canScrollVertically();var n=this.isFlyout?0:Blockly.BlockSpace.SCROLLABLE_MARGIN_BELOW_BOTTOM;return{width:o?Math.max(e.contentLeft+e.contentWidth,e.viewWidth):e.viewWidth,height:t?Math.max(e.contentTop+e.contentHeight+n,e.viewHeight):e.viewHeight}},Blockly.BlockSpace.prototype.getScrollableBox=function(){var e=this.getScrollableSize(this.getMetrics());return new goog.math.Box(0,e.width,e.height,0)},Blockly.BlockSpace.prototype.getViewportBox=function(){var e=this.getMetrics();return new goog.math.Box(this.getScrollOffsetY(),this.getScrollOffsetX()+e.viewWidth,this.getScrollOffsetY()+e.viewHeight,this.getScrollOffsetX())},Blockly.BlockSpace.prototype.panIfOverEdge=function(e,t,o){this.scrollOnBlockDragHandler_.panIfOverEdge(e,t,o)},Blockly.BlockSpace.prototype.stopAutoScrolling=function(){this.scrollOnBlockDragHandler_.stopAutoScrolling()},Blockly.BlockSpace.prototype.scrollIntoView=function(e){var t=e.getBox(),o=this.getViewportBox();e=Blockly.getBoxOverflow(o,t),Blockly.addToNonZeroSides(e,Blockly.BlockSpace.DROPPED_BLOCK_PAN_MARGIN);var n=Blockly.isBoxWiderThan(t,o),i=Blockly.isBoxTallerThan(t,o);t=!(!n&&!i)&&goog.math.Box.intersects(t,o),this.scrollToDelta(n&&t?0:e.right-e.left,i&&t?0:e.bottom-e.top)},Blockly.BlockSpace.prototype.scrollDeltaWithAnySelectedBlock=function(e,t,o,n){this.scrollWithAnySelectedBlock(this.getScrollOffsetX()+e,this.getScrollOffsetY()+t,o,n)},Blockly.BlockSpace.prototype.scrollWithAnySelectedBlock=function(e,t,o,n){var i=this.getScrollOffset();this.scrollTo(e,t),Blockly.Block.isFreelyDragging()&&Blockly.selected&&(e=this.getScrollOffset().subtract(i),Blockly.selected.startDragMouseX-=e.x,Blockly.selected.startDragMouseY-=e.y,Blockly.selected.moveBlockBeingDragged_(o,n))},Blockly.BlockSpace.prototype.scrollToDelta=function(e,t){this.scrollTo(this.getScrollOffsetX()+e,this.getScrollOffsetY()+t)},Blockly.BlockSpace.prototype.scrollTo=function(e,t){if(this.scrollbarPair){var o=this.getMaxScrollOffsets();e=goog.math.clamp(e,0,o.x),t=goog.math.clamp(t,0,o.y),this.scrollbarPair.set(e,t),this.events.dispatchEvent(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_SCROLLED)}},Blockly.BlockSpace.prototype.currentlyScrollable=function(){var e=this.getMaxScrollOffsets();return 0<e.x||0<e.y},Blockly.BlockSpace.prototype.getMaxScrollOffsets=function(){var e=this.getMetrics(),t=this.getScrollableSize(e);return{x:t.width-e.viewWidth,y:t.height-e.viewHeight}},Blockly.BlockSpace.prototype.getScrollOffset=function(){return new goog.math.Vec2(this.getScrollOffsetX(),this.getScrollOffsetY())},Blockly.BlockSpace.prototype.getScrollOffsetX=function(){return-this.xOffsetFromView},Blockly.BlockSpace.prototype.getScrollOffsetY=function(){return-this.yOffsetFromView},Blockly.BlockSpace.prototype.updateScrollableSize=function(){this.scrollbarPair&&this.scrollbarPair.resize()},Blockly.BlockSpace.prototype.bindBeginPanDragHandler=function(e,t){this.panDragHandler_.bindBeginPanDragHandler(e,t)},Blockly.BlockSpace.prototype.bindScrollOnWheelHandler=function(e){this.scrollOnWheelHandler_.bindTo(e)},Blockly.BlockSpace.prototype.unbindBeginPanDragHandler=function(){this.panDragHandler_.unbindBeginPanDragHandler()},Blockly.BlockSpace.prototype.debugRects_={},Blockly.BlockSpace.prototype.drawDebugBox=function(e,t,o){t=goog.math.Rect.createFromBox(t),this.debugRects_[e]||(this.debugRects_[e]=Blockly.createSvgElement("rect",{fill:"none",style:"pointer-events: none"},this.svgDebugCanvas_)),this.svgDebugCanvas_.setAttribute("transform",this.svgBlockCanvas_.getAttribute("transform")),(e=this.debugRects_[e]).setAttribute("x",t.left),e.setAttribute("y",t.top),e.setAttribute("width",t.width),e.setAttribute("height",t.height),e.setAttribute("stroke",o),e.setAttribute("stroke-width",3)},Blockly.BlockSpace.prototype.debugCircles_={},Blockly.BlockSpace.prototype.drawDebugCircle=function(e,t,o){this.debugCircles_[e]||(this.debugCircles_[e]=Blockly.createSvgElement("circle",{cx:"50",cy:"50",r:"50",style:"pointer-events: none"},this.svgDebugCanvas_)),this.svgDebugCanvas_.setAttribute("transform",this.svgBlockCanvas_.getAttribute("transform")),(e=this.debugCircles_[e]).setAttribute("cx",""+t.x),e.setAttribute("cy",""+t.y),e.setAttribute("r",10),e.setAttribute("fill",o)},Blockly.BlockSpace.prototype.clearDebugDrawings=function(){[this.debugCircles_,this.debugRects_].forEach(function(e){for(var t in e)goog.dom.removeNode(e[t])}),this.debugCircles_={},this.debugRects_={}};var ROUNDED_NOTCH_PATHS={left:"l 6,4 3,0 6,-4",leftHighlight:"l 6.5,4 2,0 6.5,-4",right:"l -6,4 -3,0 -6,-4"},SQUARE_NOTCH_PATHS={left:"l 0,5 15,0 0,-5",leftHighlight:"l 0,5 15,0 0,-5",right:"l 0,5 -15,0 0,-5"};function getShadowBlocksInStack(e){var t=[];for(e=[e];e.length;){var o=e.shift();o.blockToShadow_&&t.push(o),e=e.concat(o.childBlocks_)}return t}Blockly.Connection=function(e,t){this.sourceBlock_=e,this.targetConnection=null,this.type=t,this.y_=this.x_=0,this.inDB_=!1,this.dbList_=this.sourceBlock_.blockSpace.connectionDBList,this.check_=null,this.fieldHelpers_={}},Blockly.Connection.Shapes={STANDARD:"standard",ANGLE:"angle",SQUARE:"square",ROUNDED:"rounded"},Blockly.Connection.prototype.isConnected=function(){return null!==this.targetConnection},Blockly.Connection.prototype.dispose=function(){if(this.isConnected())throw"Disconnect connection before disposing of it.";this.inDB_&&this.dbList_[this.type].removeConnection_(this),this.inDB_=!1,Blockly.highlightedConnection_==this&&(Blockly.highlightedConnection_=null),Blockly.localConnection_==this&&(Blockly.localConnection_=null)},Blockly.Connection.prototype.isSuperior=function(){return this.type===Blockly.INPUT_VALUE||this.type===Blockly.NEXT_STATEMENT||this.type===Blockly.FUNCTIONAL_INPUT},Blockly.Connection.prototype.connect=function(e){if(this.sourceBlock_==e.sourceBlock_)throw"Attempted to connect a block to itself.";if(this.sourceBlock_.blockSpace!==e.sourceBlock_.blockSpace)throw"Blocks are on different blockSpaces.";if(Blockly.OPPOSITE_TYPE[this.type]!=e.type)throw"Attempt to connect incompatible types.";if(this.isConnected())throw"Source connection already connected.";if(e.targetConnection&&this.handleOrphan_(e),this.isSuperior())var t=this.sourceBlock_,o=e.sourceBlock_;else t=e.sourceBlock_,o=this.sourceBlock_;this.targetConnection=e,e.targetConnection=this,o.setParent(t),t.rendered&&t.getSvgRenderer().updateDisabled(),o.rendered&&o.getSvgRenderer().updateDisabled(),t.rendered&&o.rendered&&(this.type==Blockly.NEXT_STATEMENT||this.type==Blockly.PREVIOUS_STATEMENT?o.render():t.render()),this.sourceBlock_.isUserVisible()||this.sourceBlock_.setUserVisible(!1)},Blockly.Connection.prototype.handleOrphan_=function(e){var t=e.targetBlock();if(t.setParent(null),t.setUserVisible(!0),this.type===Blockly.INPUT_VALUE||this.type===Blockly.OUTPUT_VALUE){if(!t.outputConnection)throw"Orphan block does not have an output connection.";for(var o=this.sourceBlock_;o=Blockly.Connection.singleConnection_(o,t);){if(!o.targetBlock()){o.connect(t.outputConnection),t=null;break}o=o.targetBlock()}t&&window.setTimeout(function(){t.outputConnection.bumpAwayFrom_(e)},Blockly.BUMP_DELAY)}else if(this.type===Blockly.FUNCTIONAL_INPUT||this.type===Blockly.FUNCTIONAL_OUTPUT){if(!t.previousConnection)throw"Orphan block does not have a previous connection.";window.setTimeout(function(){t.previousConnection.bumpAwayFrom_(e)},Blockly.BUMP_DELAY)}else{if(this.type!=Blockly.PREVIOUS_STATEMENT)throw"Can only do a mid-stack connection with the top of a block.";if(!t.previousConnection)throw"Orphan block does not have a previous connection.";for(o=this.sourceBlock_;o.nextConnection;){if(!o.nextConnection.targetConnection){o.nextConnection.connect(t.previousConnection),t=null;break}o=o.nextConnection.targetBlock()}t&&window.setTimeout(function(){t.previousConnection.bumpAwayFrom_(e)},Blockly.BUMP_DELAY)}},Blockly.Connection.singleConnection_=function(e,t){for(var o=!1,n=0;n<e.inputList.length;n++){var i=e.inputList[n].connection;if(i&&i.type==Blockly.INPUT_VALUE&&t.outputConnection.checkAllowedConnectionType_(i)){if(o)return null;o=i}}return o},Blockly.Connection.prototype.disconnect=function(){var e=this.targetConnection;if(!e)throw"Source connection not connected.";if(e.targetConnection!=this)throw"Target connection not connected to source connection.";if(this.targetConnection=e.targetConnection=null,this.sourceBlock_.setUserVisible(!0),this.isSuperior()){var t=this.sourceBlock_;e=e.sourceBlock_}else t=e.sourceBlock_,e=this.sourceBlock_;t.rendered&&t.render(),e.rendered&&(e.getSvgRenderer().updateDisabled(),e.render())},Blockly.Connection.prototype.targetBlock=function(){return this.targetConnection?this.targetConnection.sourceBlock_:null},Blockly.Connection.prototype.bumpAwayFrom_=function(e){if(!Blockly.Block.isDragging()){var t=this.sourceBlock_.getRootBlock();if(!t.isInFlyout){var o=!1;if(!t.isMovable()){if(!(t=e.sourceBlock_.getRootBlock()).isMovable())return;e=this,o=!0}t.getSvgRoot().parentNode.appendChild(t.getSvgRoot());var n=e.x_+Blockly.SNAP_RADIUS-this.x_;e=e.y_+2*Blockly.SNAP_RADIUS-this.y_,o&&(e=-e),Blockly.RTL&&(n=-n),t.moveBy(n,e),t.bumpNeighbours()}}},Blockly.Connection.prototype.moveTo=function(e,t){this.inDB_&&this.dbList_[this.type].removeConnection_(this),this.x_=e,this.y_=t,this.dbList_[this.type].addConnection_(this)},Blockly.Connection.prototype.moveBy=function(e,t){this.moveTo(this.x_+e,this.y_+t)},Blockly.Connection.prototype.colorForType=function(e){if(e&&!(1<e.length))switch(e[0]){case"String":return[160,.45,.65];case"Number":return[258,.35,.62];case"Boolean":return[196,1,.79];case"Array":return[40,1,.99];case"Colour":return[196,1,.79];case"Sprite":return[355,.7,.7];case"Behavior":return[136,.84,.8];case"Location":return[52,.7,.92]}},Blockly.Connection.prototype.getPathInfo=function(){if(this.type===Blockly.INPUT_VALUE||this.type===Blockly.OUTPUT_VALUE)var e="m 0,0 "+Blockly.BlockSvg.TAB_PATHS_BY_SHAPE[this.getTabShape()].TAB_PATH_DOWN+" v 5";else{e=5+Blockly.BlockSvg.NOTCH_PATH_WIDTH;var t=this.getNotchPaths();e="m -"+e+",0 h 5 "+t.left+" h 5"}return t=this.sourceBlock_.getRelativeToSurfaceXY(),t="translate("+(this.x_-t.x)+", "+(this.y_-t.y)+")",Blockly.RTL&&(t+=" scale(-1, 1)"),{steps:e,transform:t,color:this.colorForType(this.check_)}},Blockly.Connection.prototype.highlight=function(){var e=this.getPathInfo();Blockly.Connection.highlightedPath_=Blockly.createSvgElement("path",{class:"blocklyHighlightedConnectionPath",d:e.steps,transform:e.transform},this.sourceBlock_.getSvgRoot())},Blockly.Connection.prototype.unhighlight=function(){goog.dom.removeNode(Blockly.Connection.highlightedPath_),delete Blockly.Connection.highlightedPath_},Blockly.Connection.prototype.getNotchPaths=function(){if(Blockly.Connection.NOTCH_PATHS_OVERRIDE)return Blockly.Connection.NOTCH_PATHS_OVERRIDE;var e=this&&this.check_||[];return 1===e.length&&e[0]===Blockly.BlockValueType.FUNCTION?SQUARE_NOTCH_PATHS:ROUNDED_NOTCH_PATHS},Blockly.Connection.prototype.getTabShape=function(){if(this.type!==Blockly.INPUT_VALUE&&this.type!==Blockly.OUTPUT_VALUE)return null;if(!this.strictType_||!Blockly.valueTypeTabShapeMap)return Blockly.Connection.Shapes.STANDARD;var e=this.check_[0];if(!e)throw"strict connections require a type";return Blockly.valueTypeTabShapeMap[e]||Blockly.Connection.Shapes.STANDARD},Blockly.Connection.prototype.tighten_=function(){var e=Math.round(this.targetConnection.x_-this.x_),t=Math.round(this.targetConnection.y_-this.y_);if(0!=e||0!=t){var o=this.targetBlock(),n=o.getSvgRoot();if(!n)throw"block is not rendered.";n=Blockly.getRelativeXY(n),o.getSvgRoot().setAttribute("transform","translate("+(n.x-e)+", "+(n.y-t)+")"),o.moveConnections_(-e,-t)}},Blockly.Connection.prototype.closest=function(e,t,o){function n(n){var s=i[n],a=s.sourceBlock_;if(!a.isVisible()||(s.type===Blockly.OUTPUT_VALUE||s.type===Blockly.FUNCTIONAL_OUTPUT||s.type===Blockly.PREVIOUS_STATEMENT)&&s.targetConnection||s.targetConnection&&!s.targetBlock().isMovable()||s.targetConnection&&!s.targetBlock().canDisconnectFromParent()||!h.checkAllowedConnectionType_(s))return!0;do{if(u==a)return!0;a=a.getParent()}while(a);var g=s.x_;return a=s.y_,s.sourceBlock_.getDragging()&&(g+=t,a+=o),s=r-g,a=l-a,(s=Math.sqrt(s*s+a*a))<=e&&(c=i[n],e=s),a<e}if(this.isConnected())return{connection:null,radius:e};for(var i=this.dbList_[Blockly.OPPOSITE_TYPE[this.type]],r=this.x_+t,l=this.y_+o,s=0,a=i.length-2,g=a;s<g;)i[g].y_<l?s=g:a=g,g=Math.floor((s+a)/2);a=s=g;var c=null,u=this.sourceBlock_,h=this;if(i.length){for(;0<=s&&n(s);)s--;do{a++}while(a<i.length&&n(a))}return{connection:c,radius:e}},Blockly.Connection.prototype.checkAllowedConnectionType_=function(e){if(!this.strictCheck()&&!e.strictCheck()&&(this.acceptsAnyType()||e.acceptsAnyType()))return!0;if(this.strictCheck()&&e.acceptsAnyType()||this.acceptsAnyType()&&e.strictCheck())return!1;for(var t=0;t<this.check_.length;t++)if(e.acceptsType(this.check_[t]))return!0;return!1},Blockly.Connection.prototype.strictCheck=function(){return this.strictType_},Blockly.Connection.prototype.acceptsAnyType=function(){return!this.check_||this.acceptsType(Blockly.BlockValueType.NONE)},Blockly.Connection.prototype.acceptsType=function(e){return!this.check_||goog.array.contains(this.check_,e)},Blockly.Connection.prototype.setStrictCheck=function(e){return this.setCheck(e,!0)},Blockly.Connection.prototype.setCheck=function(e,t){if(e&&e!==Blockly.BlockValueType.NONE){if(e instanceof Array||(e=[e]),this.check_=e,(this.strictType_=!!t)&&!this.check_)throw"Strict connections must specify a type";this.targetConnection&&!this.checkAllowedConnectionType_(this.targetConnection)&&(this.isSuperior()?this.targetBlock().setParent(null):this.sourceBlock_.setParent(null),this.sourceBlock_.bumpNeighbours()),this.type!==Blockly.OUTPUT_VALUE||this.sourceBlock_.getColour()||this.sourceBlock_.setHSV.apply(this.sourceBlock_,this.colorForType(e))}else this.check_=null;return this},Blockly.Connection.prototype.addFieldHelper=function(e,t){return this.fieldHelpers_[e]=t,this},Blockly.Connection.prototype.getFieldHelperOptions=function(e){return this.fieldHelpers_&&this.fieldHelpers_[e]},Blockly.Connection.prototype.getCheck=function(){return this.check_},Blockly.Connection.prototype.neighbours_=function(e){function t(t){var o=r[t],n=o.sourceBlock_;return!Blockly.editBlocks&&!n.isVisible()||(n=a-o.x_,o=g-o.y_,Math.sqrt(n*n+o*o)<=e&&c.push(r[t]),o<e)}for(var o,n=this.dbList_[this.type],i=this.dbList_[Blockly.OPPOSITE_TYPE[this.type]],r=[],l=0,s=0;l<n.length||s<i.length;)!i[s]||n[l]&&n[l].y_<i[s].y_?((o=n[l])!==this&&r.push(o),l++):((o=i[s])!==this&&r.push(o),s++);var a=this.x_,g=this.y_;for(n=0,l=i=r.length-2;n<l;)r[l].y_<g?n=l:i=l,l=Math.floor((n+i)/2);i=n=l;var c=[];if(r.length){for(;0<=n&&t(n);)n--;do{i++}while(i<r.length&&t(i))}return c},Blockly.Connection.prototype.hideAll=function(){if(this.inDB_&&this.dbList_[this.type].removeConnection_(this),this.isConnected())for(var e=this.targetBlock().getDescendants(),t=0;t<e.length;t++){for(var o=e[t],n=o.getConnections_(!0),i=0;i<n.length;i++){var r=n[i];r.inDB_&&this.dbList_[r.type].removeConnection_(r)}for(o=o.getIcons(),n=0;n<o.length;n++)o[n].setVisible(!1)}},Blockly.Connection.prototype.unhideAll=function(){this.inDB_||this.dbList_[this.type].addConnection_(this);var e=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return e;var t=this.targetBlock();if(t){if(t.isCollapsed()){var o=[];t.outputConnection&&o.push(t.outputConnection),t.nextConnection&&o.push(t.nextConnection),t.previousConnection&&o.push(t.previousConnection)}else o=t.getConnections_(!0);for(var n=0;n<o.length;n++)e=e.concat(o[n].unhideAll());0==e.length&&(e[0]=t)}return e},Blockly.ConnectionDB=function(){},Blockly.ConnectionDB.prototype=[],Blockly.ConnectionDB.constructor=Blockly.ConnectionDB,Blockly.ConnectionDB.prototype.addConnection_=function(e){if(e.inDB_)throw"Connection already in database.";for(var t=0,o=this.length;t<o;){var n=Math.floor((t+o)/2);if(this[n].y_<e.y_)t=n+1;else{if(!(this[n].y_>e.y_)){t=n;break}o=n}}this.splice(t,0,e),e.inDB_=!0},Blockly.ConnectionDB.prototype.removeConnection_=function(e){if(!e.inDB_)throw"Connection not in database.";e.inDB_=!1;for(var t=0,o=this.length-2,n=o;t<n;)this[n].y_<e.y_?t=n:o=n,n=Math.floor((t+o)/2);for(o=t=n;0<=t&&this[t].y_==e.y_;){if(this[t]==e)return void this.splice(t,1);t--}do{if(this[o]==e)return void this.splice(o,1);o++}while(o<this.length&&this[o].y_==e.y_);throw"Unable to find connection in connectionDB."},Blockly.ConnectionDB.init=function(e){var t=[];t[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB,t[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB,t[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB,t[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB,t[Blockly.FUNCTIONAL_INPUT]=new Blockly.ConnectionDB,t[Blockly.FUNCTIONAL_OUTPUT]=new Blockly.ConnectionDB,e.connectionDBList=t},goog.dom.BrowserFeature={CAN_ADD_NAME_OR_TYPE_ATTRIBUTES:!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9),CAN_USE_CHILDREN_ATTRIBUTE:!goog.userAgent.GECKO&&!goog.userAgent.IE||goog.userAgent.IE&&goog.userAgent.isDocumentModeOrHigher(9)||goog.userAgent.GECKO&&goog.userAgent.isVersionOrHigher("1.9.1"),CAN_USE_INNER_TEXT:goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("9"),CAN_USE_PARENT_ELEMENT_PROPERTY:goog.userAgent.IE||goog.userAgent.OPERA||goog.userAgent.WEBKIT,INNER_HTML_NEEDS_SCOPED_ELEMENT:goog.userAgent.IE,LEGACY_IE_RANGES:goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(9)},goog.dom.TagName=function(e){this.tagName_=e},goog.dom.TagName.prototype.toString=function(){return this.tagName_},goog.dom.TagName.A=new goog.dom.TagName("A"),goog.dom.TagName.ABBR=new goog.dom.TagName("ABBR"),goog.dom.TagName.ACRONYM=new goog.dom.TagName("ACRONYM"),goog.dom.TagName.ADDRESS=new goog.dom.TagName("ADDRESS"),goog.dom.TagName.APPLET=new goog.dom.TagName("APPLET"),goog.dom.TagName.AREA=new goog.dom.TagName("AREA"),goog.dom.TagName.ARTICLE=new goog.dom.TagName("ARTICLE"),goog.dom.TagName.ASIDE=new goog.dom.TagName("ASIDE"),goog.dom.TagName.AUDIO=new goog.dom.TagName("AUDIO"),goog.dom.TagName.B=new goog.dom.TagName("B"),goog.dom.TagName.BASE=new goog.dom.TagName("BASE"),goog.dom.TagName.BASEFONT=new goog.dom.TagName("BASEFONT"),goog.dom.TagName.BDI=new goog.dom.TagName("BDI"),goog.dom.TagName.BDO=new goog.dom.TagName("BDO"),goog.dom.TagName.BIG=new goog.dom.TagName("BIG"),goog.dom.TagName.BLOCKQUOTE=new goog.dom.TagName("BLOCKQUOTE"),goog.dom.TagName.BODY=new goog.dom.TagName("BODY"),goog.dom.TagName.BR=new goog.dom.TagName("BR"),goog.dom.TagName.BUTTON=new goog.dom.TagName("BUTTON"),goog.dom.TagName.CANVAS=new goog.dom.TagName("CANVAS"),goog.dom.TagName.CAPTION=new goog.dom.TagName("CAPTION"),goog.dom.TagName.CENTER=new goog.dom.TagName("CENTER"),goog.dom.TagName.CITE=new goog.dom.TagName("CITE"),goog.dom.TagName.CODE=new goog.dom.TagName("CODE"),goog.dom.TagName.COL=new goog.dom.TagName("COL"),goog.dom.TagName.COLGROUP=new goog.dom.TagName("COLGROUP"),goog.dom.TagName.COMMAND=new goog.dom.TagName("COMMAND"),goog.dom.TagName.DATA=new goog.dom.TagName("DATA"),goog.dom.TagName.DATALIST=new goog.dom.TagName("DATALIST"),goog.dom.TagName.DD=new goog.dom.TagName("DD"),goog.dom.TagName.DEL=new goog.dom.TagName("DEL"),goog.dom.TagName.DETAILS=new goog.dom.TagName("DETAILS"),goog.dom.TagName.DFN=new goog.dom.TagName("DFN"),goog.dom.TagName.DIALOG=new goog.dom.TagName("DIALOG"),goog.dom.TagName.DIR=new goog.dom.TagName("DIR"),goog.dom.TagName.DIV=new goog.dom.TagName("DIV"),goog.dom.TagName.DL=new goog.dom.TagName("DL"),goog.dom.TagName.DT=new goog.dom.TagName("DT"),goog.dom.TagName.EM=new goog.dom.TagName("EM"),goog.dom.TagName.EMBED=new goog.dom.TagName("EMBED"),goog.dom.TagName.FIELDSET=new goog.dom.TagName("FIELDSET"),goog.dom.TagName.FIGCAPTION=new goog.dom.TagName("FIGCAPTION"),goog.dom.TagName.FIGURE=new goog.dom.TagName("FIGURE"),goog.dom.TagName.FONT=new goog.dom.TagName("FONT"),goog.dom.TagName.FOOTER=new goog.dom.TagName("FOOTER"),goog.dom.TagName.FORM=new goog.dom.TagName("FORM"),goog.dom.TagName.FRAME=new goog.dom.TagName("FRAME"),goog.dom.TagName.FRAMESET=new goog.dom.TagName("FRAMESET"),goog.dom.TagName.H1=new goog.dom.TagName("H1"),goog.dom.TagName.H2=new goog.dom.TagName("H2"),goog.dom.TagName.H3=new goog.dom.TagName("H3"),goog.dom.TagName.H4=new goog.dom.TagName("H4"),goog.dom.TagName.H5=new goog.dom.TagName("H5"),goog.dom.TagName.H6=new goog.dom.TagName("H6"),goog.dom.TagName.HEAD=new goog.dom.TagName("HEAD"),goog.dom.TagName.HEADER=new goog.dom.TagName("HEADER"),goog.dom.TagName.HGROUP=new goog.dom.TagName("HGROUP"),goog.dom.TagName.HR=new goog.dom.TagName("HR"),goog.dom.TagName.HTML=new goog.dom.TagName("HTML"),goog.dom.TagName.I=new goog.dom.TagName("I"),goog.dom.TagName.IFRAME=new goog.dom.TagName("IFRAME"),goog.dom.TagName.IMG=new goog.dom.TagName("IMG"),goog.dom.TagName.INPUT=new goog.dom.TagName("INPUT"),goog.dom.TagName.INS=new goog.dom.TagName("INS"),goog.dom.TagName.ISINDEX=new goog.dom.TagName("ISINDEX"),goog.dom.TagName.KBD=new goog.dom.TagName("KBD"),goog.dom.TagName.KEYGEN=new goog.dom.TagName("KEYGEN"),goog.dom.TagName.LABEL=new goog.dom.TagName("LABEL"),goog.dom.TagName.LEGEND=new goog.dom.TagName("LEGEND"),goog.dom.TagName.LI=new goog.dom.TagName("LI"),goog.dom.TagName.LINK=new goog.dom.TagName("LINK"),goog.dom.TagName.MAP=new goog.dom.TagName("MAP"),goog.dom.TagName.MARK=new goog.dom.TagName("MARK"),goog.dom.TagName.MATH=new goog.dom.TagName("MATH"),goog.dom.TagName.MENU=new goog.dom.TagName("MENU"),goog.dom.TagName.META=new goog.dom.TagName("META"),goog.dom.TagName.METER=new goog.dom.TagName("METER"),goog.dom.TagName.NAV=new goog.dom.TagName("NAV"),goog.dom.TagName.NOFRAMES=new goog.dom.TagName("NOFRAMES"),goog.dom.TagName.NOSCRIPT=new goog.dom.TagName("NOSCRIPT"),goog.dom.TagName.OBJECT=new goog.dom.TagName("OBJECT"),goog.dom.TagName.OL=new goog.dom.TagName("OL"),goog.dom.TagName.OPTGROUP=new goog.dom.TagName("OPTGROUP"),goog.dom.TagName.OPTION=new goog.dom.TagName("OPTION"),goog.dom.TagName.OUTPUT=new goog.dom.TagName("OUTPUT"),goog.dom.TagName.P=new goog.dom.TagName("P"),goog.dom.TagName.PARAM=new goog.dom.TagName("PARAM"),goog.dom.TagName.PRE=new goog.dom.TagName("PRE"),goog.dom.TagName.PROGRESS=new goog.dom.TagName("PROGRESS"),goog.dom.TagName.Q=new goog.dom.TagName("Q"),goog.dom.TagName.RP=new goog.dom.TagName("RP"),goog.dom.TagName.RT=new goog.dom.TagName("RT"),goog.dom.TagName.RUBY=new goog.dom.TagName("RUBY"),goog.dom.TagName.S=new goog.dom.TagName("S"),goog.dom.TagName.SAMP=new goog.dom.TagName("SAMP"),goog.dom.TagName.SCRIPT=new goog.dom.TagName("SCRIPT"),goog.dom.TagName.SECTION=new goog.dom.TagName("SECTION"),goog.dom.TagName.SELECT=new goog.dom.TagName("SELECT"),goog.dom.TagName.SMALL=new goog.dom.TagName("SMALL"),goog.dom.TagName.SOURCE=new goog.dom.TagName("SOURCE"),goog.dom.TagName.SPAN=new goog.dom.TagName("SPAN"),goog.dom.TagName.STRIKE=new goog.dom.TagName("STRIKE"),goog.dom.TagName.STRONG=new goog.dom.TagName("STRONG"),goog.dom.TagName.STYLE=new goog.dom.TagName("STYLE"),goog.dom.TagName.SUB=new goog.dom.TagName("SUB"),goog.dom.TagName.SUMMARY=new goog.dom.TagName("SUMMARY"),goog.dom.TagName.SUP=new goog.dom.TagName("SUP"),goog.dom.TagName.SVG=new goog.dom.TagName("SVG"),goog.dom.TagName.TABLE=new goog.dom.TagName("TABLE"),goog.dom.TagName.TBODY=new goog.dom.TagName("TBODY"),goog.dom.TagName.TD=new goog.dom.TagName("TD"),goog.dom.TagName.TEMPLATE=new goog.dom.TagName("TEMPLATE"),goog.dom.TagName.TEXTAREA=new goog.dom.TagName("TEXTAREA"),goog.dom.TagName.TFOOT=new goog.dom.TagName("TFOOT"),goog.dom.TagName.TH=new goog.dom.TagName("TH"),goog.dom.TagName.THEAD=new goog.dom.TagName("THEAD"),goog.dom.TagName.TIME=new goog.dom.TagName("TIME"),goog.dom.TagName.TITLE=new goog.dom.TagName("TITLE"),goog.dom.TagName.TR=new goog.dom.TagName("TR"),goog.dom.TagName.TRACK=new goog.dom.TagName("TRACK"),goog.dom.TagName.TT=new goog.dom.TagName("TT"),goog.dom.TagName.U=new goog.dom.TagName("U"),goog.dom.TagName.UL=new goog.dom.TagName("UL"),goog.dom.TagName.VAR=new goog.dom.TagName("VAR"),goog.dom.TagName.VIDEO=new goog.dom.TagName("VIDEO"),goog.dom.TagName.WBR=new goog.dom.TagName("WBR"),goog.dom.tags={},goog.dom.tags.VOID_TAGS_={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},goog.dom.tags.isVoidTag=function(e){return!0===goog.dom.tags.VOID_TAGS_[e]},goog.string.TypedString=function(){},goog.string.Const=function(){this.stringConstValueWithSecurityContract__googStringSecurityPrivate_="",this.STRING_CONST_TYPE_MARKER__GOOG_STRING_SECURITY_PRIVATE_=goog.string.Const.TYPE_MARKER_},goog.string.Const.prototype.implementsGoogStringTypedString=!0,goog.string.Const.prototype.getTypedStringValue=function(){return this.stringConstValueWithSecurityContract__googStringSecurityPrivate_},goog.string.Const.prototype.toString=function(){return"Const{"+this.stringConstValueWithSecurityContract__googStringSecurityPrivate_+"}"},goog.string.Const.unwrap=function(e){return e instanceof goog.string.Const&&e.constructor===goog.string.Const&&e.STRING_CONST_TYPE_MARKER__GOOG_STRING_SECURITY_PRIVATE_===goog.string.Const.TYPE_MARKER_?e.stringConstValueWithSecurityContract__googStringSecurityPrivate_:(goog.asserts.fail("expected object of type Const, got '"+e+"'"),"type_error:Const")},goog.string.Const.from=function(e){return goog.string.Const.create__googStringSecurityPrivate_(e)},goog.string.Const.TYPE_MARKER_={},goog.string.Const.create__googStringSecurityPrivate_=function(e){var t=new goog.string.Const;return t.stringConstValueWithSecurityContract__googStringSecurityPrivate_=e,t},goog.string.Const.EMPTY=goog.string.Const.from(""),goog.html={},goog.html.SafeScript=function(){this.privateDoNotAccessOrElseSafeScriptWrappedValue_="",this.SAFE_SCRIPT_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.SafeScript.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_},goog.html.SafeScript.prototype.implementsGoogStringTypedString=!0,goog.html.SafeScript.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.SafeScript.fromConstant=function(e){return 0===(e=goog.string.Const.unwrap(e)).length?goog.html.SafeScript.EMPTY:goog.html.SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(e)},goog.html.SafeScript.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseSafeScriptWrappedValue_},goog.DEBUG&&(goog.html.SafeScript.prototype.toString=function(){return"SafeScript{"+this.privateDoNotAccessOrElseSafeScriptWrappedValue_+"}"}),goog.html.SafeScript.unwrap=function(e){return e instanceof goog.html.SafeScript&&e.constructor===goog.html.SafeScript&&e.SAFE_SCRIPT_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.SafeScript.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseSafeScriptWrappedValue_:(goog.asserts.fail("expected object of type SafeScript, got '"+e+"' of type "+goog.typeOf(e)),"type_error:SafeScript")},goog.html.SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse=function(e){return(new goog.html.SafeScript).initSecurityPrivateDoNotAccessOrElse_(e)},goog.html.SafeScript.prototype.initSecurityPrivateDoNotAccessOrElse_=function(e){return this.privateDoNotAccessOrElseSafeScriptWrappedValue_=e,this},goog.html.SafeScript.EMPTY=goog.html.SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(""),goog.html.SafeStyle=function(){this.privateDoNotAccessOrElseSafeStyleWrappedValue_="",this.SAFE_STYLE_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.SafeStyle.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_},goog.html.SafeStyle.prototype.implementsGoogStringTypedString=!0,goog.html.SafeStyle.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.SafeStyle.fromConstant=function(e){return 0===(e=goog.string.Const.unwrap(e)).length?goog.html.SafeStyle.EMPTY:(goog.html.SafeStyle.checkStyle_(e),goog.asserts.assert(goog.string.endsWith(e,";"),"Last character of style string is not ';': "+e),goog.asserts.assert(goog.string.contains(e,":"),"Style string must contain at least one ':', to specify a \"name: value\" pair: "+e),goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(e))},goog.html.SafeStyle.checkStyle_=function(e){goog.asserts.assert(!/[<>]/.test(e),"Forbidden characters in style string: "+e)},goog.html.SafeStyle.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseSafeStyleWrappedValue_},goog.DEBUG&&(goog.html.SafeStyle.prototype.toString=function(){return"SafeStyle{"+this.privateDoNotAccessOrElseSafeStyleWrappedValue_+"}"}),goog.html.SafeStyle.unwrap=function(e){return e instanceof goog.html.SafeStyle&&e.constructor===goog.html.SafeStyle&&e.SAFE_STYLE_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.SafeStyle.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseSafeStyleWrappedValue_:(goog.asserts.fail("expected object of type SafeStyle, got '"+e+"' of type "+goog.typeOf(e)),"type_error:SafeStyle")},goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse=function(e){return(new goog.html.SafeStyle).initSecurityPrivateDoNotAccessOrElse_(e)},goog.html.SafeStyle.prototype.initSecurityPrivateDoNotAccessOrElse_=function(e){return this.privateDoNotAccessOrElseSafeStyleWrappedValue_=e,this},goog.html.SafeStyle.EMPTY=goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(""),goog.html.SafeStyle.INNOCUOUS_STRING="zClosurez",goog.html.SafeStyle.create=function(e){var t,o="";for(t in e){if(!/^[-_a-zA-Z0-9]+$/.test(t))throw Error("Name allows only [-_a-zA-Z0-9], got: "+t);var n=e[t];null!=n&&(n instanceof goog.string.Const?(n=goog.string.Const.unwrap(n),goog.asserts.assert(!/[{;}]/.test(n),"Value does not allow [{;}].")):goog.html.SafeStyle.VALUE_RE_.test(n)?goog.html.SafeStyle.hasBalancedQuotes_(n)||(goog.asserts.fail("String value requires balanced quotes, got: "+n),n=goog.html.SafeStyle.INNOCUOUS_STRING):(goog.asserts.fail("String value allows only [-,.\"'%_!# a-zA-Z0-9], rgb() and rgba(), got: "+n),n=goog.html.SafeStyle.INNOCUOUS_STRING),o+=t+":"+n+";")}return o?(goog.html.SafeStyle.checkStyle_(o),goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(o)):goog.html.SafeStyle.EMPTY},goog.html.SafeStyle.hasBalancedQuotes_=function(e){for(var t=!0,o=!0,n=0;n<e.length;n++){var i=e.charAt(n);"'"==i&&o?t=!t:'"'==i&&t&&(o=!o)}return t&&o},goog.html.SafeStyle.VALUE_RE_=/^([-,."'%_!# a-zA-Z0-9]+|(?:rgb|hsl)a?\([0-9.%, ]+\))$/,goog.html.SafeStyle.concat=function(e){var t="",o=function(e){goog.isArray(e)?goog.array.forEach(e,o):t+=goog.html.SafeStyle.unwrap(e)};return goog.array.forEach(arguments,o),t?goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(t):goog.html.SafeStyle.EMPTY},goog.html.SafeStyleSheet=function(){this.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_="",this.SAFE_STYLE_SHEET_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.SafeStyleSheet.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_},goog.html.SafeStyleSheet.prototype.implementsGoogStringTypedString=!0,goog.html.SafeStyleSheet.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.SafeStyleSheet.concat=function(e){var t="",o=function(e){goog.isArray(e)?goog.array.forEach(e,o):t+=goog.html.SafeStyleSheet.unwrap(e)};return goog.array.forEach(arguments,o),goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(t)},goog.html.SafeStyleSheet.fromConstant=function(e){return 0===(e=goog.string.Const.unwrap(e)).length?goog.html.SafeStyleSheet.EMPTY:(goog.asserts.assert(!goog.string.contains(e,"<"),"Forbidden '<' character in style sheet string: "+e),goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(e))},goog.html.SafeStyleSheet.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_},goog.DEBUG&&(goog.html.SafeStyleSheet.prototype.toString=function(){return"SafeStyleSheet{"+this.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_+"}"}),goog.html.SafeStyleSheet.unwrap=function(e){return e instanceof goog.html.SafeStyleSheet&&e.constructor===goog.html.SafeStyleSheet&&e.SAFE_STYLE_SHEET_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.SafeStyleSheet.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_:(goog.asserts.fail("expected object of type SafeStyleSheet, got '"+e+"' of type "+goog.typeOf(e)),"type_error:SafeStyleSheet")},goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse=function(e){return(new goog.html.SafeStyleSheet).initSecurityPrivateDoNotAccessOrElse_(e)},goog.html.SafeStyleSheet.prototype.initSecurityPrivateDoNotAccessOrElse_=function(e){return this.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_=e,this},goog.html.SafeStyleSheet.EMPTY=goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(""),goog.fs={},goog.fs.url={},goog.fs.url.createObjectUrl=function(e){return goog.fs.url.getUrlObject_().createObjectURL(e)},goog.fs.url.revokeObjectUrl=function(e){goog.fs.url.getUrlObject_().revokeObjectURL(e)},goog.fs.url.getUrlObject_=function(){var e=goog.fs.url.findUrlObject_();if(null!=e)return e;throw Error("This browser doesn't seem to support blob URLs")},goog.fs.url.findUrlObject_=function(){return goog.isDef(goog.global.URL)&&goog.isDef(goog.global.URL.createObjectURL)?goog.global.URL:goog.isDef(goog.global.webkitURL)&&goog.isDef(goog.global.webkitURL.createObjectURL)?goog.global.webkitURL:goog.isDef(goog.global.createObjectURL)?goog.global:null},goog.fs.url.browserSupportsObjectUrls=function(){return null!=goog.fs.url.findUrlObject_()},goog.i18n={},goog.i18n.bidi={},goog.i18n.bidi.FORCE_RTL=!1,goog.i18n.bidi.IS_RTL=goog.i18n.bidi.FORCE_RTL||("ar"==goog.LOCALE.substring(0,2).toLowerCase()||"fa"==goog.LOCALE.substring(0,2).toLowerCase()||"he"==goog.LOCALE.substring(0,2).toLowerCase()||"iw"==goog.LOCALE.substring(0,2).toLowerCase()||"ps"==goog.LOCALE.substring(0,2).toLowerCase()||"sd"==goog.LOCALE.substring(0,2).toLowerCase()||"ug"==goog.LOCALE.substring(0,2).toLowerCase()||"ur"==goog.LOCALE.substring(0,2).toLowerCase()||"yi"==goog.LOCALE.substring(0,2).toLowerCase())&&(2==goog.LOCALE.length||"-"==goog.LOCALE.substring(2,3)||"_"==goog.LOCALE.substring(2,3))||3<=goog.LOCALE.length&&"ckb"==goog.LOCALE.substring(0,3).toLowerCase()&&(3==goog.LOCALE.length||"-"==goog.LOCALE.substring(3,4)||"_"==goog.LOCALE.substring(3,4)),goog.i18n.bidi.Format={LRE:"‪",RLE:"‫",PDF:"‬",LRM:"‎",RLM:"‏"},goog.i18n.bidi.Dir={LTR:1,RTL:-1,NEUTRAL:0},goog.i18n.bidi.RIGHT="right",goog.i18n.bidi.LEFT="left",goog.i18n.bidi.I18N_RIGHT=goog.i18n.bidi.IS_RTL?goog.i18n.bidi.LEFT:goog.i18n.bidi.RIGHT,goog.i18n.bidi.I18N_LEFT=goog.i18n.bidi.IS_RTL?goog.i18n.bidi.RIGHT:goog.i18n.bidi.LEFT,goog.i18n.bidi.toDir=function(e,t){return"number"==typeof e?0<e?goog.i18n.bidi.Dir.LTR:0>e?goog.i18n.bidi.Dir.RTL:t?null:goog.i18n.bidi.Dir.NEUTRAL:null==e?null:e?goog.i18n.bidi.Dir.RTL:goog.i18n.bidi.Dir.LTR},goog.i18n.bidi.ltrChars_="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",goog.i18n.bidi.rtlChars_="֑-ۯۺ-߿‏יִ-﷿ﹰ-ﻼ",goog.i18n.bidi.htmlSkipReg_=/<[^>]*>|&[^;]+;/g,goog.i18n.bidi.stripHtmlIfNeeded_=function(e,t){return t?e.replace(goog.i18n.bidi.htmlSkipReg_,""):e},goog.i18n.bidi.rtlCharReg_=new RegExp("["+goog.i18n.bidi.rtlChars_+"]"),goog.i18n.bidi.ltrCharReg_=new RegExp("["+goog.i18n.bidi.ltrChars_+"]"),goog.i18n.bidi.hasAnyRtl=function(e,t){return goog.i18n.bidi.rtlCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.hasRtlChar=goog.i18n.bidi.hasAnyRtl,goog.i18n.bidi.hasAnyLtr=function(e,t){return goog.i18n.bidi.ltrCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.ltrRe_=new RegExp("^["+goog.i18n.bidi.ltrChars_+"]"),goog.i18n.bidi.rtlRe_=new RegExp("^["+goog.i18n.bidi.rtlChars_+"]"),goog.i18n.bidi.isRtlChar=function(e){return goog.i18n.bidi.rtlRe_.test(e)},goog.i18n.bidi.isLtrChar=function(e){return goog.i18n.bidi.ltrRe_.test(e)},goog.i18n.bidi.isNeutralChar=function(e){return!goog.i18n.bidi.isLtrChar(e)&&!goog.i18n.bidi.isRtlChar(e)},goog.i18n.bidi.ltrDirCheckRe_=new RegExp("^[^"+goog.i18n.bidi.rtlChars_+"]*["+goog.i18n.bidi.ltrChars_+"]"),goog.i18n.bidi.rtlDirCheckRe_=new RegExp("^[^"+goog.i18n.bidi.ltrChars_+"]*["+goog.i18n.bidi.rtlChars_+"]"),goog.i18n.bidi.startsWithRtl=function(e,t){return goog.i18n.bidi.rtlDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.isRtlText=goog.i18n.bidi.startsWithRtl,goog.i18n.bidi.startsWithLtr=function(e,t){return goog.i18n.bidi.ltrDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.isLtrText=goog.i18n.bidi.startsWithLtr,goog.i18n.bidi.isRequiredLtrRe_=/^http:\/\/.*/,goog.i18n.bidi.isNeutralText=function(e,t){return e=goog.i18n.bidi.stripHtmlIfNeeded_(e,t),goog.i18n.bidi.isRequiredLtrRe_.test(e)||!goog.i18n.bidi.hasAnyLtr(e)&&!goog.i18n.bidi.hasAnyRtl(e)},goog.i18n.bidi.ltrExitDirCheckRe_=new RegExp("["+goog.i18n.bidi.ltrChars_+"][^"+goog.i18n.bidi.rtlChars_+"]*$"),goog.i18n.bidi.rtlExitDirCheckRe_=new RegExp("["+goog.i18n.bidi.rtlChars_+"][^"+goog.i18n.bidi.ltrChars_+"]*$"),goog.i18n.bidi.endsWithLtr=function(e,t){return goog.i18n.bidi.ltrExitDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.isLtrExitText=goog.i18n.bidi.endsWithLtr,goog.i18n.bidi.endsWithRtl=function(e,t){return goog.i18n.bidi.rtlExitDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(e,t))},goog.i18n.bidi.isRtlExitText=goog.i18n.bidi.endsWithRtl,goog.i18n.bidi.rtlLocalesRe_=/^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Arab|Hebr|Thaa|Nkoo|Tfng))(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)/i,goog.i18n.bidi.isRtlLanguage=function(e){return goog.i18n.bidi.rtlLocalesRe_.test(e)},goog.i18n.bidi.bracketGuardTextRe_=/(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(<.*?>+)/g,goog.i18n.bidi.guardBracketInText=function(e,t){return t=(void 0===t?goog.i18n.bidi.hasAnyRtl(e):t)?goog.i18n.bidi.Format.RLM:goog.i18n.bidi.Format.LRM,e.replace(goog.i18n.bidi.bracketGuardTextRe_,t+"$&"+t)},goog.i18n.bidi.enforceRtlInHtml=function(e){return"<"==e.charAt(0)?e.replace(/<\w+/,"$& dir=rtl"):"\n<span dir=rtl>"+e+"</span>"},goog.i18n.bidi.enforceRtlInText=function(e){return goog.i18n.bidi.Format.RLE+e+goog.i18n.bidi.Format.PDF},goog.i18n.bidi.enforceLtrInHtml=function(e){return"<"==e.charAt(0)?e.replace(/<\w+/,"$& dir=ltr"):"\n<span dir=ltr>"+e+"</span>"},goog.i18n.bidi.enforceLtrInText=function(e){return goog.i18n.bidi.Format.LRE+e+goog.i18n.bidi.Format.PDF},goog.i18n.bidi.dimensionsRe_=/:\s*([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)/g,goog.i18n.bidi.leftRe_=/left/gi,goog.i18n.bidi.rightRe_=/right/gi,goog.i18n.bidi.tempRe_=/%%%%/g,goog.i18n.bidi.mirrorCSS=function(e){return e.replace(goog.i18n.bidi.dimensionsRe_,":$1 $4 $3 $2").replace(goog.i18n.bidi.leftRe_,"%%%%").replace(goog.i18n.bidi.rightRe_,goog.i18n.bidi.LEFT).replace(goog.i18n.bidi.tempRe_,goog.i18n.bidi.RIGHT)},goog.i18n.bidi.doubleQuoteSubstituteRe_=/([\u0591-\u05f2])"/g,goog.i18n.bidi.singleQuoteSubstituteRe_=/([\u0591-\u05f2])'/g,goog.i18n.bidi.normalizeHebrewQuote=function(e){return e.replace(goog.i18n.bidi.doubleQuoteSubstituteRe_,"$1״").replace(goog.i18n.bidi.singleQuoteSubstituteRe_,"$1׳")},goog.i18n.bidi.wordSeparatorRe_=/\s+/,goog.i18n.bidi.hasNumeralsRe_=/[\d\u06f0-\u06f9]/,goog.i18n.bidi.rtlDetectionThreshold_=.4,goog.i18n.bidi.estimateDirection=function(e,t){var o=0,n=0,i=!1;for(e=goog.i18n.bidi.stripHtmlIfNeeded_(e,t).split(goog.i18n.bidi.wordSeparatorRe_),t=0;t<e.length;t++){var r=e[t];goog.i18n.bidi.startsWithRtl(r)?(o++,n++):goog.i18n.bidi.isRequiredLtrRe_.test(r)?i=!0:goog.i18n.bidi.hasAnyLtr(r)?n++:goog.i18n.bidi.hasNumeralsRe_.test(r)&&(i=!0)}return 0==n?i?goog.i18n.bidi.Dir.LTR:goog.i18n.bidi.Dir.NEUTRAL:o/n>goog.i18n.bidi.rtlDetectionThreshold_?goog.i18n.bidi.Dir.RTL:goog.i18n.bidi.Dir.LTR},goog.i18n.bidi.detectRtlDirectionality=function(e,t){return goog.i18n.bidi.estimateDirection(e,t)==goog.i18n.bidi.Dir.RTL},goog.i18n.bidi.setElementDirAndAlign=function(e,t){e&&(t=goog.i18n.bidi.toDir(t))&&(e.style.textAlign=t==goog.i18n.bidi.Dir.RTL?goog.i18n.bidi.RIGHT:goog.i18n.bidi.LEFT,e.dir=t==goog.i18n.bidi.Dir.RTL?"rtl":"ltr")},goog.i18n.bidi.setElementDirByTextDirectionality=function(e,t){switch(goog.i18n.bidi.estimateDirection(t)){case goog.i18n.bidi.Dir.LTR:e.dir="ltr";break;case goog.i18n.bidi.Dir.RTL:e.dir="rtl";break;default:e.removeAttribute("dir")}},goog.i18n.bidi.DirectionalString=function(){},goog.html.SafeUrl=function(){this.privateDoNotAccessOrElseSafeHtmlWrappedValue_="",this.SAFE_URL_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.SafeUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_},goog.html.SafeUrl.INNOCUOUS_STRING="about:invalid#zClosurez",goog.html.SafeUrl.prototype.implementsGoogStringTypedString=!0,goog.html.SafeUrl.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseSafeHtmlWrappedValue_},goog.html.SafeUrl.prototype.implementsGoogI18nBidiDirectionalString=!0,goog.html.SafeUrl.prototype.getDirection=function(){return goog.i18n.bidi.Dir.LTR},goog.DEBUG&&(goog.html.SafeUrl.prototype.toString=function(){return"SafeUrl{"+this.privateDoNotAccessOrElseSafeHtmlWrappedValue_+"}"}),goog.html.SafeUrl.unwrap=function(e){return e instanceof goog.html.SafeUrl&&e.constructor===goog.html.SafeUrl&&e.SAFE_URL_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.SafeUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseSafeHtmlWrappedValue_:(goog.asserts.fail("expected object of type SafeUrl, got '"+e+"' of type "+goog.typeOf(e)),"type_error:SafeUrl")},goog.html.SafeUrl.fromConstant=function(e){return goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(goog.string.Const.unwrap(e))},goog.html.SAFE_MIME_TYPE_PATTERN_=/^(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm))$/i,goog.html.SafeUrl.fromBlob=function(e){return e=goog.html.SAFE_MIME_TYPE_PATTERN_.test(e.type)?goog.fs.url.createObjectUrl(e):goog.html.SafeUrl.INNOCUOUS_STRING,goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(e)},goog.html.DATA_URL_PATTERN_=/^data:([^;,]*);base64,[a-z0-9+\/]+=*$/i,goog.html.SafeUrl.fromDataUrl=function(e){var t=e.match(goog.html.DATA_URL_PATTERN_);return t=t&&goog.html.SAFE_MIME_TYPE_PATTERN_.test(t[1]),goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(t?e:goog.html.SafeUrl.INNOCUOUS_STRING)},goog.html.SafeUrl.fromTelUrl=function(e){return goog.string.caseInsensitiveStartsWith(e,"tel:")||(e=goog.html.SafeUrl.INNOCUOUS_STRING),goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(e)},goog.html.SAFE_URL_PATTERN_=/^(?:(?:https?|mailto|ftp):|[^&:/?#]*(?:[/?#]|$))/i,goog.html.SafeUrl.sanitize=function(e){return e instanceof goog.html.SafeUrl?e:(e=e.implementsGoogStringTypedString?e.getTypedStringValue():String(e),goog.html.SAFE_URL_PATTERN_.test(e)||(e=goog.html.SafeUrl.INNOCUOUS_STRING),goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(e))},goog.html.SafeUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse=function(e){var t=new goog.html.SafeUrl;return t.privateDoNotAccessOrElseSafeHtmlWrappedValue_=e,t},goog.html.SafeUrl.ABOUT_BLANK=goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse("about:blank"),goog.html.TrustedResourceUrl=function(){this.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_="",this.TRUSTED_RESOURCE_URL_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.TrustedResourceUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_},goog.html.TrustedResourceUrl.prototype.implementsGoogStringTypedString=!0,goog.html.TrustedResourceUrl.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_},goog.html.TrustedResourceUrl.prototype.implementsGoogI18nBidiDirectionalString=!0,goog.html.TrustedResourceUrl.prototype.getDirection=function(){return goog.i18n.bidi.Dir.LTR},goog.DEBUG&&(goog.html.TrustedResourceUrl.prototype.toString=function(){return"TrustedResourceUrl{"+this.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_+"}"}),goog.html.TrustedResourceUrl.unwrap=function(e){return e instanceof goog.html.TrustedResourceUrl&&e.constructor===goog.html.TrustedResourceUrl&&e.TRUSTED_RESOURCE_URL_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.TrustedResourceUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_:(goog.asserts.fail("expected object of type TrustedResourceUrl, got '"+e+"' of type "+goog.typeOf(e)),"type_error:TrustedResourceUrl")},goog.html.TrustedResourceUrl.format=function(e,t){var o=goog.string.Const.unwrap(e);if(!goog.html.TrustedResourceUrl.BASE_URL_.test(o))throw Error("Invalid TrustedResourceUrl format: "+o);return e=o.replace(goog.html.TrustedResourceUrl.FORMAT_MARKER_,function(e,n){if(!Object.prototype.hasOwnProperty.call(t,n))throw Error('Found marker, "'+n+'", in format string, "'+o+'", but no valid label mapping found in args: '+JSON.stringify(t));return(e=t[n])instanceof goog.string.Const?goog.string.Const.unwrap(e):encodeURIComponent(String(e))}),goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(e)},goog.html.TrustedResourceUrl.FORMAT_MARKER_=/%{(\w+)}/g,goog.html.TrustedResourceUrl.BASE_URL_=/^(?:https:)?\/\/[0-9a-z.:[\]-]+\/|^\/[^\/\\]/i,goog.html.TrustedResourceUrl.fromConstant=function(e){return goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(goog.string.Const.unwrap(e))},goog.html.TrustedResourceUrl.fromConstants=function(e){for(var t="",o=0;o<e.length;o++)t+=goog.string.Const.unwrap(e[o]);return goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(t)},goog.html.TrustedResourceUrl.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse=function(e){var t=new goog.html.TrustedResourceUrl;return t.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_=e,t},goog.html.SafeHtml=function(){this.privateDoNotAccessOrElseSafeHtmlWrappedValue_="",this.SAFE_HTML_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_=goog.html.SafeHtml.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_,this.dir_=null},goog.html.SafeHtml.prototype.implementsGoogI18nBidiDirectionalString=!0,goog.html.SafeHtml.prototype.getDirection=function(){return this.dir_},goog.html.SafeHtml.prototype.implementsGoogStringTypedString=!0,goog.html.SafeHtml.prototype.getTypedStringValue=function(){return this.privateDoNotAccessOrElseSafeHtmlWrappedValue_},goog.DEBUG&&(goog.html.SafeHtml.prototype.toString=function(){return"SafeHtml{"+this.privateDoNotAccessOrElseSafeHtmlWrappedValue_+"}"}),goog.html.SafeHtml.unwrap=function(e){return e instanceof goog.html.SafeHtml&&e.constructor===goog.html.SafeHtml&&e.SAFE_HTML_TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_===goog.html.SafeHtml.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_?e.privateDoNotAccessOrElseSafeHtmlWrappedValue_:(goog.asserts.fail("expected object of type SafeHtml, got '"+e+"' of type "+goog.typeOf(e)),"type_error:SafeHtml")},goog.html.SafeHtml.htmlEscape=function(e){if(e instanceof goog.html.SafeHtml)return e;var t=null;return e.implementsGoogI18nBidiDirectionalString&&(t=e.getDirection()),e=e.implementsGoogStringTypedString?e.getTypedStringValue():String(e),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(goog.string.htmlEscape(e),t)},goog.html.SafeHtml.htmlEscapePreservingNewlines=function(e){return e instanceof goog.html.SafeHtml?e:(e=goog.html.SafeHtml.htmlEscape(e),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(goog.string.newLineToBr(goog.html.SafeHtml.unwrap(e)),e.getDirection()))},goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces=function(e){return e instanceof goog.html.SafeHtml?e:(e=goog.html.SafeHtml.htmlEscape(e),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(goog.string.whitespaceEscape(goog.html.SafeHtml.unwrap(e)),e.getDirection()))},goog.html.SafeHtml.from=goog.html.SafeHtml.htmlEscape,goog.html.SafeHtml.VALID_NAMES_IN_TAG_=/^[a-zA-Z0-9-]+$/,goog.html.SafeHtml.URL_ATTRIBUTES_={action:!0,cite:!0,data:!0,formaction:!0,href:!0,manifest:!0,poster:!0,src:!0},goog.html.SafeHtml.NOT_ALLOWED_TAG_NAMES_={APPLET:!0,BASE:!0,EMBED:!0,IFRAME:!0,LINK:!0,MATH:!0,META:!0,OBJECT:!0,SCRIPT:!0,STYLE:!0,SVG:!0,TEMPLATE:!0},goog.html.SafeHtml.create=function(e,t,o){return goog.html.SafeHtml.verifyTagName(String(e)),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse(String(e),t,o)},goog.html.SafeHtml.verifyTagName=function(e){if(!goog.html.SafeHtml.VALID_NAMES_IN_TAG_.test(e))throw Error("Invalid tag name <"+e+">.");if(e.toUpperCase()in goog.html.SafeHtml.NOT_ALLOWED_TAG_NAMES_)throw Error("Tag name <"+e+"> is not allowed for SafeHtml.")},goog.html.SafeHtml.createIframe=function(e,t,o,n){e&&goog.html.TrustedResourceUrl.unwrap(e);var i={};return i.src=e||null,i.srcdoc=t&&goog.html.SafeHtml.unwrap(t),e=goog.html.SafeHtml.combineAttributes(i,{sandbox:""},o),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("iframe",e,n)},goog.html.SafeHtml.createSandboxIframe=function(e,t,o,n){if(!goog.html.SafeHtml.canUseSandboxIframe())throw Error("The browser does not support sandboxed iframes.");var i={};return i.src=e?goog.html.SafeUrl.unwrap(goog.html.SafeUrl.sanitize(e)):null,i.srcdoc=t||null,i.sandbox="",e=goog.html.SafeHtml.combineAttributes(i,{},o),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("iframe",e,n)},goog.html.SafeHtml.canUseSandboxIframe=function(){return goog.global.HTMLIFrameElement&&"sandbox"in goog.global.HTMLIFrameElement.prototype},goog.html.SafeHtml.createScriptSrc=function(e,t){return goog.html.TrustedResourceUrl.unwrap(e),e=goog.html.SafeHtml.combineAttributes({src:e},{},t),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("script",e)},goog.html.SafeHtml.createScript=function(e,t){for(var o in t){var n=o.toLowerCase();if("language"==n||"src"==n||"text"==n||"type"==n)throw Error('Cannot set "'+n+'" attribute')}for(o="",e=goog.array.concat(e),n=0;n<e.length;n++)o+=goog.html.SafeScript.unwrap(e[n]);return e=goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(o,goog.i18n.bidi.Dir.NEUTRAL),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("script",t,e)},goog.html.SafeHtml.createStyle=function(e,t){t=goog.html.SafeHtml.combineAttributes({type:"text/css"},{},t);var o="";e=goog.array.concat(e);for(var n=0;n<e.length;n++)o+=goog.html.SafeStyleSheet.unwrap(e[n]);return e=goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(o,goog.i18n.bidi.Dir.NEUTRAL),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("style",t,e)},goog.html.SafeHtml.createMetaRefresh=function(e,t){return e=goog.html.SafeUrl.unwrap(goog.html.SafeUrl.sanitize(e)),(goog.labs.userAgent.browser.isIE()||goog.labs.userAgent.browser.isEdge())&&goog.string.contains(e,";")&&(e="'"+e.replace(/'/g,"%27")+"'"),goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("meta",{"http-equiv":"refresh",content:(t||0)+"; url="+e})},goog.html.SafeHtml.getAttrNameAndValue_=function(e,t,o){if(o instanceof goog.string.Const)o=goog.string.Const.unwrap(o);else if("style"==t.toLowerCase())o=goog.html.SafeHtml.getStyleValue_(o);else{if(/^on/i.test(t))throw Error('Attribute "'+t+'" requires goog.string.Const value, "'+o+'" given.');if(t.toLowerCase()in goog.html.SafeHtml.URL_ATTRIBUTES_)if(o instanceof goog.html.TrustedResourceUrl)o=goog.html.TrustedResourceUrl.unwrap(o);else if(o instanceof goog.html.SafeUrl)o=goog.html.SafeUrl.unwrap(o);else{if(!goog.isString(o))throw Error('Attribute "'+t+'" on tag "'+e+'" requires goog.html.SafeUrl, goog.string.Const, or string, value "'+o+'" given.');o=goog.html.SafeUrl.sanitize(o).getTypedStringValue()}}return o.implementsGoogStringTypedString&&(o=o.getTypedStringValue()),goog.asserts.assert(goog.isString(o)||goog.isNumber(o),"String or number value expected, got "+typeof o+" with value: "+o),t+'="'+goog.string.htmlEscape(String(o))+'"'},goog.html.SafeHtml.getStyleValue_=function(e){if(!goog.isObject(e))throw Error('The "style" attribute requires goog.html.SafeStyle or map of style properties, '+typeof e+" given: "+e);return e instanceof goog.html.SafeStyle||(e=goog.html.SafeStyle.create(e)),goog.html.SafeStyle.unwrap(e)},goog.html.SafeHtml.createWithDir=function(e,t,o,n){return(t=goog.html.SafeHtml.create(t,o,n)).dir_=e,t},goog.html.SafeHtml.concat=function(e){var t=goog.i18n.bidi.Dir.NEUTRAL,o="",n=function(e){goog.isArray(e)?goog.array.forEach(e,n):(e=goog.html.SafeHtml.htmlEscape(e),o+=goog.html.SafeHtml.unwrap(e),e=e.getDirection(),t==goog.i18n.bidi.Dir.NEUTRAL?t=e:e!=goog.i18n.bidi.Dir.NEUTRAL&&t!=e&&(t=null))};return goog.array.forEach(arguments,n),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(o,t)},goog.html.SafeHtml.concatWithDir=function(e,t){var o=goog.html.SafeHtml.concat(goog.array.slice(arguments,1));return o.dir_=e,o},goog.html.SafeHtml.TYPE_MARKER_GOOG_HTML_SECURITY_PRIVATE_={},goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse=function(e,t){return(new goog.html.SafeHtml).initSecurityPrivateDoNotAccessOrElse_(e,t)},goog.html.SafeHtml.prototype.initSecurityPrivateDoNotAccessOrElse_=function(e,t){return this.privateDoNotAccessOrElseSafeHtmlWrappedValue_=e,this.dir_=t,this},goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse=function(e,t,o){var n=null,i="<"+e+goog.html.SafeHtml.stringifyAttributes(e,t);return goog.isDefAndNotNull(o)?goog.isArray(o)||(o=[o]):o=[],goog.dom.tags.isVoidTag(e.toLowerCase())?(goog.asserts.assert(!o.length,"Void tag <"+e+"> does not allow content."),i+=">"):(n=goog.html.SafeHtml.concat(o),i+=">"+goog.html.SafeHtml.unwrap(n)+"</"+e+">",n=n.getDirection()),(e=t&&t.dir)&&(n=/^(ltr|rtl|auto)$/i.test(e)?goog.i18n.bidi.Dir.NEUTRAL:null),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(i,n)},goog.html.SafeHtml.stringifyAttributes=function(e,t){var o="";if(t)for(var n in t){if(!goog.html.SafeHtml.VALID_NAMES_IN_TAG_.test(n))throw Error('Invalid attribute name "'+n+'".');var i=t[n];goog.isDefAndNotNull(i)&&(o+=" "+goog.html.SafeHtml.getAttrNameAndValue_(e,n,i))}return o},goog.html.SafeHtml.combineAttributes=function(e,t,o){var n,i={};for(n in e)goog.asserts.assert(n.toLowerCase()==n,"Must be lower case"),i[n]=e[n];for(n in t)goog.asserts.assert(n.toLowerCase()==n,"Must be lower case"),i[n]=t[n];for(n in o){var r=n.toLowerCase();if(r in e)throw Error('Cannot override "'+r+'" attribute, got "'+n+'" with value "'+o[n]+'"');r in t&&delete i[r],i[n]=o[n]}return i},goog.html.SafeHtml.DOCTYPE_HTML=goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("<!DOCTYPE html>",goog.i18n.bidi.Dir.NEUTRAL),goog.html.SafeHtml.EMPTY=goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("",goog.i18n.bidi.Dir.NEUTRAL),goog.html.SafeHtml.BR=goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("<br>",goog.i18n.bidi.Dir.NEUTRAL),goog.dom.safe={},goog.dom.safe.InsertAdjacentHtmlPosition={AFTERBEGIN:"afterbegin",AFTEREND:"afterend",BEFOREBEGIN:"beforebegin",BEFOREEND:"beforeend"},goog.dom.safe.insertAdjacentHtml=function(e,t,o){e.insertAdjacentHTML(t,goog.html.SafeHtml.unwrap(o))},goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_={MATH:!0,SCRIPT:!0,STYLE:!0,SVG:!0,TEMPLATE:!0},goog.dom.safe.setInnerHtml=function(e,t){if(goog.asserts.ENABLE_ASSERTS){var o=e.tagName.toUpperCase();if(goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_[o])throw Error("goog.dom.safe.setInnerHtml cannot be used to set content of "+e.tagName+".")}e.innerHTML=goog.html.SafeHtml.unwrap(t)},goog.dom.safe.setOuterHtml=function(e,t){e.outerHTML=goog.html.SafeHtml.unwrap(t)},goog.dom.safe.setStyle=function(e,t){e.style.cssText=goog.html.SafeStyle.unwrap(t)},goog.dom.safe.documentWrite=function(e,t){e.write(goog.html.SafeHtml.unwrap(t))},goog.dom.safe.setAnchorHref=function(e,t){goog.dom.safe.assertIsHTMLAnchorElement_(e),t=t instanceof goog.html.SafeUrl?t:goog.html.SafeUrl.sanitize(t),e.href=goog.html.SafeUrl.unwrap(t)},goog.dom.safe.setImageSrc=function(e,t){goog.dom.safe.assertIsHTMLImageElement_(e),t=t instanceof goog.html.SafeUrl?t:goog.html.SafeUrl.sanitize(t),e.src=goog.html.SafeUrl.unwrap(t)},goog.dom.safe.setEmbedSrc=function(e,t){goog.dom.safe.assertIsHTMLEmbedElement_(e),e.src=goog.html.TrustedResourceUrl.unwrap(t)},goog.dom.safe.setFrameSrc=function(e,t){goog.dom.safe.assertIsHTMLFrameElement_(e),e.src=goog.html.TrustedResourceUrl.unwrap(t)},goog.dom.safe.setIframeSrc=function(e,t){goog.dom.safe.assertIsHTMLIFrameElement_(e),e.src=goog.html.TrustedResourceUrl.unwrap(t)},goog.dom.safe.setIframeSrcdoc=function(e,t){goog.dom.safe.assertIsHTMLIFrameElement_(e),e.srcdoc=goog.html.SafeHtml.unwrap(t)},goog.dom.safe.setLinkHrefAndRel=function(e,t,o){goog.dom.safe.assertIsHTMLLinkElement_(e),e.rel=o,goog.string.caseInsensitiveContains(o,"stylesheet")?(goog.asserts.assert(t instanceof goog.html.TrustedResourceUrl,'URL must be TrustedResourceUrl because "rel" contains "stylesheet"'),e.href=goog.html.TrustedResourceUrl.unwrap(t)):e.href=t instanceof goog.html.TrustedResourceUrl?goog.html.TrustedResourceUrl.unwrap(t):t instanceof goog.html.SafeUrl?goog.html.SafeUrl.unwrap(t):goog.html.SafeUrl.sanitize(t).getTypedStringValue()},goog.dom.safe.setObjectData=function(e,t){goog.dom.safe.assertIsHTMLObjectElement_(e),e.data=goog.html.TrustedResourceUrl.unwrap(t)},goog.dom.safe.setScriptSrc=function(e,t){goog.dom.safe.assertIsHTMLScriptElement_(e),e.src=goog.html.TrustedResourceUrl.unwrap(t)},goog.dom.safe.setLocationHref=function(e,t){goog.dom.safe.assertIsLocation_(e),t=t instanceof goog.html.SafeUrl?t:goog.html.SafeUrl.sanitize(t),e.href=goog.html.SafeUrl.unwrap(t)},goog.dom.safe.openInWindow=function(e,t,o,n,i){return e=e instanceof goog.html.SafeUrl?e:goog.html.SafeUrl.sanitize(e),(t||window).open(goog.html.SafeUrl.unwrap(e),o?goog.string.Const.unwrap(o):"",n,i)},goog.dom.safe.assertIsLocation_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof Location&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof Location||!(e instanceof Element)),"Argument is not a Location (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLAnchorElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLAnchorElement&&"undefined"!=typeof Location&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLAnchorElement||!(e instanceof Location||e instanceof Element)),"Argument is not a HTMLAnchorElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLLinkElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLLinkElement&&"undefined"!=typeof Location&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLLinkElement||!(e instanceof Location||e instanceof Element)),"Argument is not a HTMLLinkElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLImageElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLImageElement||!(e instanceof Element)),"Argument is not a HTMLImageElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLEmbedElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLEmbedElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLEmbedElement||!(e instanceof Element)),"Argument is not a HTMLEmbedElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLFrameElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLFrameElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLFrameElement||!(e instanceof Element)),"Argument is not a HTMLFrameElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLIFrameElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLIFrameElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLIFrameElement||!(e instanceof Element)),"Argument is not a HTMLIFrameElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLObjectElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLObjectElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLObjectElement||!(e instanceof Element)),"Argument is not a HTMLObjectElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.assertIsHTMLScriptElement_=function(e){return goog.asserts.ENABLE_ASSERTS&&"undefined"!=typeof HTMLScriptElement&&"undefined"!=typeof Element&&goog.asserts.assert(e&&(e instanceof HTMLScriptElement||!(e instanceof Element)),"Argument is not a HTMLScriptElement (or a non-Element mock); got: %s",goog.dom.safe.debugStringForType_(e)),e},goog.dom.safe.debugStringForType_=function(e){return goog.isObject(e)?e.constructor.displayName||e.constructor.name||Object.prototype.toString.call(e):void 0===e?"undefined":null===e?"null":typeof e},goog.html.uncheckedconversions={},goog.html.uncheckedconversions.safeHtmlFromStringKnownToSatisfyTypeContract=function(e,t,o){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmptyOrWhitespace(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(t,o||null)},goog.html.uncheckedconversions.safeScriptFromStringKnownToSatisfyTypeContract=function(e,t){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmpty(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(t)},goog.html.uncheckedconversions.safeStyleFromStringKnownToSatisfyTypeContract=function(e,t){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmptyOrWhitespace(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(t)},goog.html.uncheckedconversions.safeStyleSheetFromStringKnownToSatisfyTypeContract=function(e,t){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmptyOrWhitespace(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(t)},goog.html.uncheckedconversions.safeUrlFromStringKnownToSatisfyTypeContract=function(e,t){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmptyOrWhitespace(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(t)},goog.html.uncheckedconversions.trustedResourceUrlFromStringKnownToSatisfyTypeContract=function(e,t){return goog.asserts.assertString(goog.string.Const.unwrap(e),"must provide justification"),goog.asserts.assert(!goog.string.isEmptyOrWhitespace(goog.string.Const.unwrap(e)),"must provide non-empty justification"),goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(t)},goog.dom.ASSUME_QUIRKS_MODE=!1,goog.dom.ASSUME_STANDARDS_MODE=!1,goog.dom.COMPAT_MODE_KNOWN_=goog.dom.ASSUME_QUIRKS_MODE||goog.dom.ASSUME_STANDARDS_MODE,goog.dom.getDomHelper=function(e){return e?new goog.dom.DomHelper(goog.dom.getOwnerDocument(e)):goog.dom.defaultDomHelper_||(goog.dom.defaultDomHelper_=new goog.dom.DomHelper)},goog.dom.getDocument=function(){return document},goog.dom.getElement=function(e){return goog.dom.getElementHelper_(document,e)},goog.dom.getElementHelper_=function(e,t){return goog.isString(t)?e.getElementById(t):t},goog.dom.getRequiredElement=function(e){return goog.dom.getRequiredElementHelper_(document,e)},goog.dom.getRequiredElementHelper_=function(e,t){return goog.asserts.assertString(t),e=goog.dom.getElementHelper_(e,t),goog.asserts.assertElement(e,"No element found with id: "+t)},goog.dom.$=goog.dom.getElement,goog.dom.getElementsByTagName=function(e,t){return(t||document).getElementsByTagName(String(e))},goog.dom.getElementsByTagNameAndClass=function(e,t,o){return goog.dom.getElementsByTagNameAndClass_(document,e,t,o)},goog.dom.getElementsByClass=function(e,t){var o=t||document;return goog.dom.canUseQuerySelector_(o)?o.querySelectorAll("."+e):goog.dom.getElementsByTagNameAndClass_(document,"*",e,t)},goog.dom.getElementByClass=function(e,t){var o=t||document;return(o.getElementsByClassName?o.getElementsByClassName(e)[0]:goog.dom.canUseQuerySelector_(o)?o.querySelector("."+e):goog.dom.getElementsByTagNameAndClass_(document,"*",e,t)[0])||null},goog.dom.getRequiredElementByClass=function(e,t){return t=goog.dom.getElementByClass(e,t),goog.asserts.assert(t,"No element found with className: "+e)},goog.dom.canUseQuerySelector_=function(e){return!(!e.querySelectorAll||!e.querySelector)},goog.dom.getElementsByTagNameAndClass_=function(e,t,o,n){if(e=n||e,t=t&&"*"!=t?String(t).toUpperCase():"",goog.dom.canUseQuerySelector_(e)&&(t||o))return e.querySelectorAll(t+(o?"."+o:""));if(o&&e.getElementsByClassName){if(e=e.getElementsByClassName(o),t){n={};for(var i,r=0,l=0;i=e[l];l++)t==i.nodeName&&(n[r++]=i);return n.length=r,n}return e}if(e=e.getElementsByTagName(t||"*"),o){for(n={},l=r=0;i=e[l];l++)"function"==typeof(t=i.className).split&&goog.array.contains(t.split(/\s+/),o)&&(n[r++]=i);return n.length=r,n}return e},goog.dom.$$=goog.dom.getElementsByTagNameAndClass,goog.dom.setProperties=function(e,t){goog.object.forEach(t,function(t,o){"style"==o?e.style.cssText=t:"class"==o?e.className=t:"for"==o?e.htmlFor=t:goog.dom.DIRECT_ATTRIBUTE_MAP_.hasOwnProperty(o)?e.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP_[o],t):goog.string.startsWith(o,"aria-")||goog.string.startsWith(o,"data-")?e.setAttribute(o,t):e[o]=t})},goog.dom.DIRECT_ATTRIBUTE_MAP_={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"},goog.dom.getViewportSize=function(e){return goog.dom.getViewportSize_(e||window)},goog.dom.getViewportSize_=function(e){return e=e.document,e=goog.dom.isCss1CompatMode_(e)?e.documentElement:e.body,new goog.math.Size(e.clientWidth,e.clientHeight)},goog.dom.getDocumentHeight=function(){return goog.dom.getDocumentHeight_(window)},goog.dom.getDocumentHeightForWindow=function(e){return goog.dom.getDocumentHeight_(e)},goog.dom.getDocumentHeight_=function(e){var t=e.document,o=0;if(t){o=t.body;var n=t.documentElement;if(!n||!o)return 0;if(e=goog.dom.getViewportSize_(e).height,goog.dom.isCss1CompatMode_(t)&&n.scrollHeight)o=n.scrollHeight!=e?n.scrollHeight:n.offsetHeight;else{t=n.scrollHeight;var i=n.offsetHeight;n.clientHeight!=i&&(t=o.scrollHeight,i=o.offsetHeight),o=t>e?t>i?t:i:t<i?t:i}}return o},goog.dom.getPageScroll=function(e){return goog.dom.getDomHelper((e||goog.global||window).document).getDocumentScroll()},goog.dom.getDocumentScroll=function(){return goog.dom.getDocumentScroll_(document)},goog.dom.getDocumentScroll_=function(e){var t=goog.dom.getDocumentScrollElement_(e);return e=goog.dom.getWindow_(e),goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("10")&&e.pageYOffset!=t.scrollTop?new goog.math.Coordinate(t.scrollLeft,t.scrollTop):new goog.math.Coordinate(e.pageXOffset||t.scrollLeft,e.pageYOffset||t.scrollTop)},goog.dom.getDocumentScrollElement=function(){return goog.dom.getDocumentScrollElement_(document)},goog.dom.getDocumentScrollElement_=function(e){return e.scrollingElement?e.scrollingElement:!goog.userAgent.WEBKIT&&goog.dom.isCss1CompatMode_(e)?e.documentElement:e.body||e.documentElement},goog.dom.getWindow=function(e){return e?goog.dom.getWindow_(e):window},goog.dom.getWindow_=function(e){return e.parentWindow||e.defaultView},goog.dom.createDom=function(e,t,o){return goog.dom.createDom_(document,arguments)},goog.dom.createDom_=function(e,t){var o=String(t[0]),n=t[1];if(!goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES&&n&&(n.name||n.type)){if(o=["<",o],n.name&&o.push(' name="',goog.string.htmlEscape(n.name),'"'),n.type){o.push(' type="',goog.string.htmlEscape(n.type),'"');var i={};goog.object.extend(i,n),delete i.type,n=i}o.push(">"),o=o.join("")}return o=e.createElement(o),n&&(goog.isString(n)?o.className=n:goog.isArray(n)?o.className=n.join(" "):goog.dom.setProperties(o,n)),2<t.length&&goog.dom.append_(e,o,t,2),o},goog.dom.append_=function(e,t,o,n){function i(o){o&&t.appendChild(goog.isString(o)?e.createTextNode(o):o)}for(;n<o.length;n++){var r=o[n];goog.isArrayLike(r)&&!goog.dom.isNodeLike(r)?goog.array.forEach(goog.dom.isNodeList(r)?goog.array.toArray(r):r,i):i(r)}},goog.dom.$dom=goog.dom.createDom,goog.dom.createElement=function(e){return goog.dom.createElement_(document,e)},goog.dom.createElement_=function(e,t){return e.createElement(String(t))},goog.dom.createTextNode=function(e){return document.createTextNode(String(e))},goog.dom.createTable=function(e,t,o){return goog.dom.createTable_(document,e,t,!!o)},goog.dom.createTable_=function(e,t,o,n){for(var i=goog.dom.createElement_(e,"TABLE"),r=i.appendChild(goog.dom.createElement_(e,"TBODY")),l=0;l<t;l++){for(var s=goog.dom.createElement_(e,"TR"),a=0;a<o;a++){var g=goog.dom.createElement_(e,"TD");n&&goog.dom.setTextContent(g,goog.string.Unicode.NBSP),s.appendChild(g)}r.appendChild(s)}return i},goog.dom.constHtmlToNode=function(e){var t=goog.array.map(arguments,goog.string.Const.unwrap);return t=goog.html.uncheckedconversions.safeHtmlFromStringKnownToSatisfyTypeContract(goog.string.Const.from("Constant HTML string, that gets turned into a Node later, so it will be automatically balanced."),t.join("")),goog.dom.safeHtmlToNode(t)},goog.dom.safeHtmlToNode=function(e){return goog.dom.safeHtmlToNode_(document,e)},goog.dom.safeHtmlToNode_=function(e,t){var o=goog.dom.createElement_(e,"DIV");return goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT?(goog.dom.safe.setInnerHtml(o,goog.html.SafeHtml.concat(goog.html.SafeHtml.BR,t)),o.removeChild(o.firstChild)):goog.dom.safe.setInnerHtml(o,t),goog.dom.childrenToNode_(e,o)},goog.dom.childrenToNode_=function(e,t){if(1==t.childNodes.length)return t.removeChild(t.firstChild);for(e=e.createDocumentFragment();t.firstChild;)e.appendChild(t.firstChild);return e},goog.dom.isCss1CompatMode=function(){return goog.dom.isCss1CompatMode_(document)},goog.dom.isCss1CompatMode_=function(e){return goog.dom.COMPAT_MODE_KNOWN_?goog.dom.ASSUME_STANDARDS_MODE:"CSS1Compat"==e.compatMode},goog.dom.canHaveChildren=function(e){if(e.nodeType!=goog.dom.NodeType.ELEMENT)return!1;switch(e.tagName){case"APPLET":case"AREA":case"BASE":case"BR":case"COL":case"COMMAND":case"EMBED":case"FRAME":case"HR":case"IMG":case"INPUT":case"IFRAME":case"ISINDEX":case"KEYGEN":case"LINK":case"NOFRAMES":case"NOSCRIPT":case"META":case"OBJECT":case"PARAM":case"SCRIPT":case"SOURCE":case"STYLE":case"TRACK":case"WBR":return!1}return!0},goog.dom.appendChild=function(e,t){e.appendChild(t)},goog.dom.append=function(e,t){goog.dom.append_(goog.dom.getOwnerDocument(e),e,arguments,1)},goog.dom.removeChildren=function(e){for(var t;t=e.firstChild;)e.removeChild(t)},goog.dom.insertSiblingBefore=function(e,t){t.parentNode&&t.parentNode.insertBefore(e,t)},goog.dom.insertSiblingAfter=function(e,t){t.parentNode&&t.parentNode.insertBefore(e,t.nextSibling)},goog.dom.insertChildAt=function(e,t,o){e.insertBefore(t,e.childNodes[o]||null)},goog.dom.removeNode=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},goog.dom.replaceNode=function(e,t){var o=t.parentNode;o&&o.replaceChild(e,t)},goog.dom.flattenElement=function(e){var t,o=e.parentNode;if(o&&o.nodeType!=goog.dom.NodeType.DOCUMENT_FRAGMENT){if(e.removeNode)return e.removeNode(!1);for(;t=e.firstChild;)o.insertBefore(t,e);return goog.dom.removeNode(e)}},goog.dom.getChildren=function(e){return goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE&&null!=e.children?e.children:goog.array.filter(e.childNodes,function(e){return e.nodeType==goog.dom.NodeType.ELEMENT})},goog.dom.getFirstElementChild=function(e){return goog.isDef(e.firstElementChild)?e.firstElementChild:goog.dom.getNextElementNode_(e.firstChild,!0)},goog.dom.getLastElementChild=function(e){return goog.isDef(e.lastElementChild)?e.lastElementChild:goog.dom.getNextElementNode_(e.lastChild,!1)},goog.dom.getNextElementSibling=function(e){return goog.isDef(e.nextElementSibling)?e.nextElementSibling:goog.dom.getNextElementNode_(e.nextSibling,!0)},goog.dom.getPreviousElementSibling=function(e){return goog.isDef(e.previousElementSibling)?e.previousElementSibling:goog.dom.getNextElementNode_(e.previousSibling,!1)},goog.dom.getNextElementNode_=function(e,t){for(;e&&e.nodeType!=goog.dom.NodeType.ELEMENT;)e=t?e.nextSibling:e.previousSibling;return e},goog.dom.getNextNode=function(e){if(!e)return null;if(e.firstChild)return e.firstChild;for(;e&&!e.nextSibling;)e=e.parentNode;return e?e.nextSibling:null},goog.dom.getPreviousNode=function(e){if(!e)return null;if(!e.previousSibling)return e.parentNode;for(e=e.previousSibling;e&&e.lastChild;)e=e.lastChild;return e},goog.dom.isNodeLike=function(e){return goog.isObject(e)&&0<e.nodeType},goog.dom.isElement=function(e){return goog.isObject(e)&&e.nodeType==goog.dom.NodeType.ELEMENT},goog.dom.isWindow=function(e){return goog.isObject(e)&&e.window==e},goog.dom.getParentElement=function(e){var t;return!goog.dom.BrowserFeature.CAN_USE_PARENT_ELEMENT_PROPERTY||goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("9")&&!goog.userAgent.isVersionOrHigher("10")&&goog.global.SVGElement&&e instanceof goog.global.SVGElement||!(t=e.parentElement)?(t=e.parentNode,goog.dom.isElement(t)?t:null):t},goog.dom.contains=function(e,t){if(!e||!t)return!1;if(e.contains&&t.nodeType==goog.dom.NodeType.ELEMENT)return e==t||e.contains(t);if(void 0!==e.compareDocumentPosition)return e==t||!!(16&e.compareDocumentPosition(t));for(;t&&e!=t;)t=t.parentNode;return t==e},goog.dom.compareNodeOrder=function(e,t){if(e==t)return 0;if(e.compareDocumentPosition)return 2&e.compareDocumentPosition(t)?1:-1;if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(9)){if(e.nodeType==goog.dom.NodeType.DOCUMENT)return-1;if(t.nodeType==goog.dom.NodeType.DOCUMENT)return 1}if("sourceIndex"in e||e.parentNode&&"sourceIndex"in e.parentNode){var o=e.nodeType==goog.dom.NodeType.ELEMENT,n=t.nodeType==goog.dom.NodeType.ELEMENT;if(o&&n)return e.sourceIndex-t.sourceIndex;var i=e.parentNode,r=t.parentNode;return i==r?goog.dom.compareSiblingOrder_(e,t):!o&&goog.dom.contains(i,t)?-1*goog.dom.compareParentsDescendantNodeIe_(e,t):!n&&goog.dom.contains(r,e)?goog.dom.compareParentsDescendantNodeIe_(t,e):(o?e.sourceIndex:i.sourceIndex)-(n?t.sourceIndex:r.sourceIndex)}return(o=(n=goog.dom.getOwnerDocument(e)).createRange()).selectNode(e),o.collapse(!0),(e=n.createRange()).selectNode(t),e.collapse(!0),o.compareBoundaryPoints(goog.global.Range.START_TO_END,e)},goog.dom.compareParentsDescendantNodeIe_=function(e,t){var o=e.parentNode;if(o==t)return-1;for(;t.parentNode!=o;)t=t.parentNode;return goog.dom.compareSiblingOrder_(t,e)},goog.dom.compareSiblingOrder_=function(e,t){for(;t=t.previousSibling;)if(t==e)return-1;return 1},goog.dom.findCommonAncestor=function(e){var t,o=arguments.length;if(!o)return null;if(1==o)return arguments[0];var n=[],i=1/0;for(t=0;t<o;t++){for(var r=[],l=arguments[t];l;)r.unshift(l),l=l.parentNode;n.push(r),i=Math.min(i,r.length)}for(r=null,t=0;t<i;t++){l=n[0][t];for(var s=1;s<o;s++)if(l!=n[s][t])return r;r=l}return r},goog.dom.getOwnerDocument=function(e){return goog.asserts.assert(e,"Node cannot be null or undefined."),e.nodeType==goog.dom.NodeType.DOCUMENT?e:e.ownerDocument||e.document},goog.dom.getFrameContentDocument=function(e){return e.contentDocument||e.contentWindow.document},goog.dom.getFrameContentWindow=function(e){try{return e.contentWindow||(e.contentDocument?goog.dom.getWindow(e.contentDocument):null)}catch(e){}return null},goog.dom.setTextContent=function(e,t){if(goog.asserts.assert(null!=e,"goog.dom.setTextContent expects a non-null value for node"),"textContent"in e)e.textContent=t;else if(e.nodeType==goog.dom.NodeType.TEXT)e.data=t;else if(e.firstChild&&e.firstChild.nodeType==goog.dom.NodeType.TEXT){for(;e.lastChild!=e.firstChild;)e.removeChild(e.lastChild);e.firstChild.data=t}else{goog.dom.removeChildren(e);var o=goog.dom.getOwnerDocument(e);e.appendChild(o.createTextNode(String(t)))}},goog.dom.getOuterHtml=function(e){if(goog.asserts.assert(null!==e,"goog.dom.getOuterHtml expects a non-null value for element"),"outerHTML"in e)return e.outerHTML;var t=goog.dom.getOwnerDocument(e);return(t=goog.dom.createElement_(t,"DIV")).appendChild(e.cloneNode(!0)),t.innerHTML},goog.dom.findNode=function(e,t){var o=[];return goog.dom.findNodes_(e,t,o,!0)?o[0]:void 0},goog.dom.findNodes=function(e,t){var o=[];return goog.dom.findNodes_(e,t,o,!1),o},goog.dom.findNodes_=function(e,t,o,n){if(null!=e)for(e=e.firstChild;e;){if(t(e)&&(o.push(e),n)||goog.dom.findNodes_(e,t,o,n))return!0;e=e.nextSibling}return!1},goog.dom.TAGS_TO_IGNORE_={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},goog.dom.PREDEFINED_TAG_VALUES_={IMG:" ",BR:"\n"},goog.dom.isFocusableTabIndex=function(e){return goog.dom.hasSpecifiedTabIndex_(e)&&goog.dom.isTabIndexFocusable_(e)},goog.dom.setFocusableTabIndex=function(e,t){t?e.tabIndex=0:(e.tabIndex=-1,e.removeAttribute("tabIndex"))},goog.dom.isFocusable=function(e){var t;return(t=goog.dom.nativelySupportsFocus_(e)?!e.disabled&&(!goog.dom.hasSpecifiedTabIndex_(e)||goog.dom.isTabIndexFocusable_(e)):goog.dom.isFocusableTabIndex(e))&&goog.userAgent.IE?goog.dom.hasNonZeroBoundingRect_(e):t},goog.dom.hasSpecifiedTabIndex_=function(e){return goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("9")?(e=e.getAttributeNode("tabindex"),goog.isDefAndNotNull(e)&&e.specified):e.hasAttribute("tabindex")},goog.dom.isTabIndexFocusable_=function(e){return e=e.tabIndex,goog.isNumber(e)&&0<=e&&32768>e},goog.dom.nativelySupportsFocus_=function(e){return"A"==e.tagName||"INPUT"==e.tagName||"TEXTAREA"==e.tagName||"SELECT"==e.tagName||"BUTTON"==e.tagName},goog.dom.hasNonZeroBoundingRect_=function(e){return e=!goog.isFunction(e.getBoundingClientRect)||goog.userAgent.IE&&null==e.parentElement?{height:e.offsetHeight,width:e.offsetWidth}:e.getBoundingClientRect(),goog.isDefAndNotNull(e)&&0<e.height&&0<e.width},goog.dom.getTextContent=function(e){if(goog.dom.BrowserFeature.CAN_USE_INNER_TEXT&&null!==e&&"innerText"in e)e=goog.string.canonicalizeNewlines(e.innerText);else{var t=[];goog.dom.getTextContent_(e,t,!0),e=t.join("")}return e=(e=e.replace(/ \xAD /g," ").replace(/\xAD/g,"")).replace(/\u200B/g,""),goog.dom.BrowserFeature.CAN_USE_INNER_TEXT||(e=e.replace(/ +/g," "))," "!=e&&(e=e.replace(/^\s*/,"")),e},goog.dom.getRawTextContent=function(e){var t=[];return goog.dom.getTextContent_(e,t,!1),t.join("")},goog.dom.getTextContent_=function(e,t,o){if(!(e.nodeName in goog.dom.TAGS_TO_IGNORE_))if(e.nodeType==goog.dom.NodeType.TEXT)o?t.push(String(e.nodeValue).replace(/(\r\n|\r|\n)/g,"")):t.push(e.nodeValue);else if(e.nodeName in goog.dom.PREDEFINED_TAG_VALUES_)t.push(goog.dom.PREDEFINED_TAG_VALUES_[e.nodeName]);else for(e=e.firstChild;e;)goog.dom.getTextContent_(e,t,o),e=e.nextSibling},goog.dom.getNodeTextLength=function(e){return goog.dom.getTextContent(e).length},goog.dom.getNodeTextOffset=function(e,t){t=t||goog.dom.getOwnerDocument(e).body;for(var o=[];e&&e!=t;){for(var n=e;n=n.previousSibling;)o.unshift(goog.dom.getTextContent(n));e=e.parentNode}return goog.string.trimLeft(o.join("")).replace(/ +/g," ").length},goog.dom.getNodeAtOffset=function(e,t,o){e=[e];for(var n=0,i=null;0<e.length&&n<t;)if(!((i=e.pop()).nodeName in goog.dom.TAGS_TO_IGNORE_))if(i.nodeType==goog.dom.NodeType.TEXT){var r=i.nodeValue.replace(/(\r\n|\r|\n)/g,"").replace(/ +/g," ");n+=r.length}else if(i.nodeName in goog.dom.PREDEFINED_TAG_VALUES_)n+=goog.dom.PREDEFINED_TAG_VALUES_[i.nodeName].length;else for(r=i.childNodes.length-1;0<=r;r--)e.push(i.childNodes[r]);return goog.isObject(o)&&(o.remainder=i?i.nodeValue.length+t-n-1:0,o.node=i),i},goog.dom.isNodeList=function(e){if(e&&"number"==typeof e.length){if(goog.isObject(e))return"function"==typeof e.item||"string"==typeof e.item;if(goog.isFunction(e))return"function"==typeof e.item}return!1},goog.dom.getAncestorByTagNameAndClass=function(e,t,o,n){if(!t&&!o)return null;var i=t?String(t).toUpperCase():null;return goog.dom.getAncestor(e,function(e){return(!i||e.nodeName==i)&&(!o||goog.isString(e.className)&&goog.array.contains(e.className.split(/\s+/),o))},!0,n)},goog.dom.getAncestorByClass=function(e,t,o){return goog.dom.getAncestorByTagNameAndClass(e,null,t,o)},goog.dom.getAncestor=function(e,t,o,n){for(e&&!o&&(e=e.parentNode),o=0;e&&(null==n||o<=n);){if(goog.asserts.assert("parentNode"!=e.name),t(e))return e;e=e.parentNode,o++}return null},goog.dom.getActiveElement=function(e){try{return e&&e.activeElement}catch(e){}return null},goog.dom.getPixelRatio=function(){var e=goog.dom.getWindow();return goog.isDef(e.devicePixelRatio)?e.devicePixelRatio:e.matchMedia?goog.dom.matchesPixelRatio_(3)||goog.dom.matchesPixelRatio_(2)||goog.dom.matchesPixelRatio_(1.5)||goog.dom.matchesPixelRatio_(1)||.75:1},goog.dom.matchesPixelRatio_=function(e){return goog.dom.getWindow().matchMedia("(min-resolution: "+e+"dppx),(min--moz-device-pixel-ratio: "+e+"),(min-resolution: "+96*e+"dpi)").matches?e:0},goog.dom.getCanvasContext2D=function(e){return e.getContext("2d")},goog.dom.DomHelper=function(e){this.document_=e||goog.global.document||document},goog.dom.DomHelper.prototype.getDomHelper=goog.dom.getDomHelper,goog.dom.DomHelper.prototype.setDocument=function(e){this.document_=e},goog.dom.DomHelper.prototype.getDocument=function(){return this.document_},goog.dom.DomHelper.prototype.getElement=function(e){return goog.dom.getElementHelper_(this.document_,e)},goog.dom.DomHelper.prototype.getRequiredElement=function(e){return goog.dom.getRequiredElementHelper_(this.document_,e)},goog.dom.DomHelper.prototype.$=goog.dom.DomHelper.prototype.getElement,goog.dom.DomHelper.prototype.getElementsByTagName=function(e,t){return(t||this.document_).getElementsByTagName(String(e))},goog.dom.DomHelper.prototype.getElementsByTagNameAndClass=function(e,t,o){return goog.dom.getElementsByTagNameAndClass_(this.document_,e,t,o)},goog.dom.DomHelper.prototype.getElementsByClass=function(e,t){return goog.dom.getElementsByClass(e,t||this.document_)},goog.dom.DomHelper.prototype.getElementByClass=function(e,t){return goog.dom.getElementByClass(e,t||this.document_)},goog.dom.DomHelper.prototype.getRequiredElementByClass=function(e,t){return goog.dom.getRequiredElementByClass(e,t||this.document_)},goog.dom.DomHelper.prototype.$$=goog.dom.DomHelper.prototype.getElementsByTagNameAndClass,goog.dom.DomHelper.prototype.setProperties=goog.dom.setProperties,goog.dom.DomHelper.prototype.getViewportSize=function(e){return goog.dom.getViewportSize(e||this.getWindow())},goog.dom.DomHelper.prototype.getDocumentHeight=function(){return goog.dom.getDocumentHeight_(this.getWindow())},goog.dom.DomHelper.prototype.createDom=function(e,t,o){return goog.dom.createDom_(this.document_,arguments)},goog.dom.DomHelper.prototype.$dom=goog.dom.DomHelper.prototype.createDom,goog.dom.DomHelper.prototype.createElement=function(e){return goog.dom.createElement_(this.document_,e)},goog.dom.DomHelper.prototype.createTextNode=function(e){return this.document_.createTextNode(String(e))},goog.dom.DomHelper.prototype.createTable=function(e,t,o){return goog.dom.createTable_(this.document_,e,t,!!o)},goog.dom.DomHelper.prototype.safeHtmlToNode=function(e){return goog.dom.safeHtmlToNode_(this.document_,e)},goog.dom.DomHelper.prototype.isCss1CompatMode=function(){return goog.dom.isCss1CompatMode_(this.document_)},goog.dom.DomHelper.prototype.getWindow=function(){return goog.dom.getWindow_(this.document_)},goog.dom.DomHelper.prototype.getDocumentScrollElement=function(){return goog.dom.getDocumentScrollElement_(this.document_)},goog.dom.DomHelper.prototype.getDocumentScroll=function(){return goog.dom.getDocumentScroll_(this.document_)},goog.dom.DomHelper.prototype.getActiveElement=function(e){return goog.dom.getActiveElement(e||this.document_)},goog.dom.DomHelper.prototype.appendChild=goog.dom.appendChild,goog.dom.DomHelper.prototype.append=goog.dom.append,goog.dom.DomHelper.prototype.canHaveChildren=goog.dom.canHaveChildren,goog.dom.DomHelper.prototype.removeChildren=goog.dom.removeChildren,goog.dom.DomHelper.prototype.insertSiblingBefore=goog.dom.insertSiblingBefore,goog.dom.DomHelper.prototype.insertSiblingAfter=goog.dom.insertSiblingAfter,goog.dom.DomHelper.prototype.insertChildAt=goog.dom.insertChildAt,goog.dom.DomHelper.prototype.removeNode=goog.dom.removeNode,goog.dom.DomHelper.prototype.replaceNode=goog.dom.replaceNode,goog.dom.DomHelper.prototype.flattenElement=goog.dom.flattenElement,goog.dom.DomHelper.prototype.getChildren=goog.dom.getChildren,goog.dom.DomHelper.prototype.getFirstElementChild=goog.dom.getFirstElementChild,goog.dom.DomHelper.prototype.getLastElementChild=goog.dom.getLastElementChild,goog.dom.DomHelper.prototype.getNextElementSibling=goog.dom.getNextElementSibling,goog.dom.DomHelper.prototype.getPreviousElementSibling=goog.dom.getPreviousElementSibling,goog.dom.DomHelper.prototype.getNextNode=goog.dom.getNextNode,goog.dom.DomHelper.prototype.getPreviousNode=goog.dom.getPreviousNode,goog.dom.DomHelper.prototype.isNodeLike=goog.dom.isNodeLike,goog.dom.DomHelper.prototype.isElement=goog.dom.isElement,goog.dom.DomHelper.prototype.isWindow=goog.dom.isWindow,goog.dom.DomHelper.prototype.getParentElement=goog.dom.getParentElement,goog.dom.DomHelper.prototype.contains=goog.dom.contains,goog.dom.DomHelper.prototype.compareNodeOrder=goog.dom.compareNodeOrder,goog.dom.DomHelper.prototype.findCommonAncestor=goog.dom.findCommonAncestor,goog.dom.DomHelper.prototype.getOwnerDocument=goog.dom.getOwnerDocument,goog.dom.DomHelper.prototype.getFrameContentDocument=goog.dom.getFrameContentDocument,goog.dom.DomHelper.prototype.getFrameContentWindow=goog.dom.getFrameContentWindow,goog.dom.DomHelper.prototype.setTextContent=goog.dom.setTextContent,goog.dom.DomHelper.prototype.getOuterHtml=goog.dom.getOuterHtml,goog.dom.DomHelper.prototype.findNode=goog.dom.findNode,goog.dom.DomHelper.prototype.findNodes=goog.dom.findNodes,goog.dom.DomHelper.prototype.isFocusableTabIndex=goog.dom.isFocusableTabIndex,goog.dom.DomHelper.prototype.setFocusableTabIndex=goog.dom.setFocusableTabIndex,goog.dom.DomHelper.prototype.isFocusable=goog.dom.isFocusable,goog.dom.DomHelper.prototype.getTextContent=goog.dom.getTextContent,goog.dom.DomHelper.prototype.getNodeTextLength=goog.dom.getNodeTextLength,goog.dom.DomHelper.prototype.getNodeTextOffset=goog.dom.getNodeTextOffset,goog.dom.DomHelper.prototype.getNodeAtOffset=goog.dom.getNodeAtOffset,goog.dom.DomHelper.prototype.isNodeList=goog.dom.isNodeList,goog.dom.DomHelper.prototype.getAncestorByTagNameAndClass=goog.dom.getAncestorByTagNameAndClass,goog.dom.DomHelper.prototype.getAncestorByClass=goog.dom.getAncestorByClass,goog.dom.DomHelper.prototype.getAncestor=goog.dom.getAncestor,goog.dom.DomHelper.prototype.getCanvasContext2D=goog.dom.getCanvasContext2D,goog.dom.vendor={},goog.dom.vendor.getVendorJsPrefix=function(){return goog.userAgent.WEBKIT?"Webkit":goog.userAgent.GECKO?"Moz":goog.userAgent.IE?"ms":goog.userAgent.OPERA?"O":null},goog.dom.vendor.getVendorPrefix=function(){return goog.userAgent.WEBKIT?"-webkit":goog.userAgent.GECKO?"-moz":goog.userAgent.IE?"-ms":goog.userAgent.OPERA?"-o":null},goog.dom.vendor.getPrefixedPropertyName=function(e,t){if(t&&e in t)return e;var o=goog.dom.vendor.getVendorJsPrefix();return o?(e=(o=o.toLowerCase())+goog.string.toTitleCase(e),!goog.isDef(t)||e in t?e:null):null},goog.dom.vendor.getPrefixedEventType=function(e){return((goog.dom.vendor.getVendorJsPrefix()||"")+e).toLowerCase()},goog.html.legacyconversions={},goog.html.legacyconversions.safeHtmlFromString=function(e){return goog.html.legacyconversions.reportCallback_(),goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(e,null)},goog.html.legacyconversions.safeStyleFromString=function(e){return goog.html.legacyconversions.reportCallback_(),goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(e)},goog.html.legacyconversions.safeStyleSheetFromString=function(e){return goog.html.legacyconversions.reportCallback_(),goog.html.SafeStyleSheet.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(e)},goog.html.legacyconversions.safeUrlFromString=function(e){return goog.html.legacyconversions.reportCallback_(),goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(e)},goog.html.legacyconversions.trustedResourceUrlFromString=function(e){return goog.html.legacyconversions.reportCallback_(),goog.html.TrustedResourceUrl.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(e)},goog.html.legacyconversions.reportCallback_=goog.nullFunction,goog.html.legacyconversions.setReportCallback=function(e){goog.html.legacyconversions.reportCallback_=e},goog.style={},goog.style.setStyle=function(e,t,o){if(goog.isString(t))goog.style.setStyle_(e,o,t);else for(var n in t)goog.style.setStyle_(e,t[n],n)},goog.style.setStyle_=function(e,t,o){(o=goog.style.getVendorJsStyleName_(e,o))&&(e.style[o]=t)},goog.style.styleNameCache_={},goog.style.getVendorJsStyleName_=function(e,t){var o=goog.style.styleNameCache_[t];if(!o){var n=goog.string.toCamelCase(t);o=n,void 0===e.style[n]&&(n=goog.dom.vendor.getVendorJsPrefix()+goog.string.toTitleCase(n),void 0!==e.style[n]&&(o=n)),goog.style.styleNameCache_[t]=o}return o},goog.style.getVendorStyleName_=function(e,t){var o=goog.string.toCamelCase(t);return void 0===e.style[o]&&(o=goog.dom.vendor.getVendorJsPrefix()+goog.string.toTitleCase(o),void 0!==e.style[o])?goog.dom.vendor.getVendorPrefix()+"-"+t:t},goog.style.getStyle=function(e,t){var o=e.style[goog.string.toCamelCase(t)];return void 0!==o?o:e.style[goog.style.getVendorJsStyleName_(e,t)]||""},goog.style.getComputedStyle=function(e,t){var o=goog.dom.getOwnerDocument(e);return o.defaultView&&o.defaultView.getComputedStyle&&(e=o.defaultView.getComputedStyle(e,null))&&(e[t]||e.getPropertyValue(t))||""},goog.style.getCascadedStyle=function(e,t){return e.currentStyle?e.currentStyle[t]:null},goog.style.getStyle_=function(e,t){return goog.style.getComputedStyle(e,t)||goog.style.getCascadedStyle(e,t)||e.style&&e.style[t]},goog.style.getComputedBoxSizing=function(e){return goog.style.getStyle_(e,"boxSizing")||goog.style.getStyle_(e,"MozBoxSizing")||goog.style.getStyle_(e,"WebkitBoxSizing")||null},goog.style.getComputedPosition=function(e){return goog.style.getStyle_(e,"position")},goog.style.getBackgroundColor=function(e){return goog.style.getStyle_(e,"backgroundColor")},goog.style.getComputedOverflowX=function(e){return goog.style.getStyle_(e,"overflowX")},goog.style.getComputedOverflowY=function(e){return goog.style.getStyle_(e,"overflowY")},goog.style.getComputedZIndex=function(e){return goog.style.getStyle_(e,"zIndex")},goog.style.getComputedTextAlign=function(e){return goog.style.getStyle_(e,"textAlign")},goog.style.getComputedCursor=function(e){return goog.style.getStyle_(e,"cursor")},goog.style.getComputedTransform=function(e){var t=goog.style.getVendorStyleName_(e,"transform");return goog.style.getStyle_(e,t)||goog.style.getStyle_(e,"transform")},goog.style.setPosition=function(e,t,o){if(t instanceof goog.math.Coordinate){var n=t.x;t=t.y}else n=t,t=o;e.style.left=goog.style.getPixelStyleValue_(n,!1),e.style.top=goog.style.getPixelStyleValue_(t,!1)},goog.style.getPosition=function(e){return new goog.math.Coordinate(e.offsetLeft,e.offsetTop)},goog.style.getClientViewportElement=function(e){return e=e?goog.dom.getOwnerDocument(e):goog.dom.getDocument(),!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9)||goog.dom.getDomHelper(e).isCss1CompatMode()?e.documentElement:e.body},goog.style.getViewportPageOffset=function(e){var t=e.body;return e=e.documentElement,new goog.math.Coordinate(t.scrollLeft||e.scrollLeft,t.scrollTop||e.scrollTop)},goog.style.getBoundingClientRect_=function(e){try{var t=e.getBoundingClientRect()}catch(e){return{left:0,top:0,right:0,bottom:0}}return goog.userAgent.IE&&e.ownerDocument.body&&(e=e.ownerDocument,t.left-=e.documentElement.clientLeft+e.body.clientLeft,t.top-=e.documentElement.clientTop+e.body.clientTop),t},goog.style.getOffsetParent=function(e){if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(8))return goog.asserts.assert(e&&"offsetParent"in e),e.offsetParent;var t=goog.dom.getOwnerDocument(e),o=goog.style.getStyle_(e,"position"),n="fixed"==o||"absolute"==o;for(e=e.parentNode;e&&e!=t;e=e.parentNode)if(e.nodeType==goog.dom.NodeType.DOCUMENT_FRAGMENT&&e.host&&(e=e.host),o=goog.style.getStyle_(e,"position"),!(n=n&&"static"==o&&e!=t.documentElement&&e!=t.body)&&(e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight||"fixed"==o||"absolute"==o||"relative"==o))return e;return null},goog.style.getVisibleRectForElement=function(e){for(var t=new goog.math.Box(0,1/0,1/0,0),o=goog.dom.getDomHelper(e),n=o.getDocument().body,i=o.getDocument().documentElement,r=o.getDocumentScrollElement();e=goog.style.getOffsetParent(e);)if(!(goog.userAgent.IE&&0==e.clientWidth||goog.userAgent.WEBKIT&&0==e.clientHeight&&e==n)&&e!=n&&e!=i&&"visible"!=goog.style.getStyle_(e,"overflow")){var l=goog.style.getPageOffset(e),s=goog.style.getClientLeftTop(e);l.x+=s.x,l.y+=s.y,t.top=Math.max(t.top,l.y),t.right=Math.min(t.right,l.x+e.clientWidth),t.bottom=Math.min(t.bottom,l.y+e.clientHeight),t.left=Math.max(t.left,l.x)}return n=r.scrollLeft,r=r.scrollTop,t.left=Math.max(t.left,n),t.top=Math.max(t.top,r),o=o.getViewportSize(),t.right=Math.min(t.right,n+o.width),t.bottom=Math.min(t.bottom,r+o.height),0<=t.top&&0<=t.left&&t.bottom>t.top&&t.right>t.left?t:null},goog.style.getContainerOffsetToScrollInto=function(e,t,o){var n=t||goog.dom.getDocumentScrollElement(),i=goog.style.getPageOffset(e),r=goog.style.getPageOffset(n),l=goog.style.getBorderBox(n);return n==goog.dom.getDocumentScrollElement()?(t=i.x-n.scrollLeft,i=i.y-n.scrollTop,goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(10)&&(t+=l.left,i+=l.top)):(t=i.x-r.x-l.left,i=i.y-r.y-l.top),l=goog.style.getSizeWithDisplay_(e),e=n.clientWidth-l.width,l=n.clientHeight-l.height,r=n.scrollLeft,n=n.scrollTop,o?(r+=t-e/2,n+=i-l/2):(r+=Math.min(t,Math.max(t-e,0)),n+=Math.min(i,Math.max(i-l,0))),new goog.math.Coordinate(r,n)},goog.style.scrollIntoContainerView=function(e,t,o){t=t||goog.dom.getDocumentScrollElement(),e=goog.style.getContainerOffsetToScrollInto(e,t,o),t.scrollLeft=e.x,t.scrollTop=e.y},goog.style.getClientLeftTop=function(e){return new goog.math.Coordinate(e.clientLeft,e.clientTop)},goog.style.getPageOffset=function(e){var t=goog.dom.getOwnerDocument(e);goog.asserts.assertObject(e,"Parameter is required");var o=new goog.math.Coordinate(0,0);return e==goog.style.getClientViewportElement(t)?o:(e=goog.style.getBoundingClientRect_(e),t=goog.dom.getDomHelper(t).getDocumentScroll(),o.x=e.left+t.x,o.y=e.top+t.y,o)},goog.style.getPageOffsetLeft=function(e){return goog.style.getPageOffset(e).x},goog.style.getPageOffsetTop=function(e){return goog.style.getPageOffset(e).y},goog.style.getFramedPageOffset=function(e,t){var o=new goog.math.Coordinate(0,0),n=goog.dom.getWindow(goog.dom.getOwnerDocument(e));if(!goog.reflect.canAccessProperty(n,"parent"))return o;do{var i=n==t?goog.style.getPageOffset(e):goog.style.getClientPositionForElement_(goog.asserts.assert(e));o.x+=i.x,o.y+=i.y}while(n&&n!=t&&n!=n.parent&&(e=n.frameElement)&&(n=n.parent));return o},goog.style.translateRectForAnotherFrame=function(e,t,o){if(t.getDocument()!=o.getDocument()){var n=t.getDocument().body;o=goog.style.getFramedPageOffset(n,o.getWindow()),o=goog.math.Coordinate.difference(o,goog.style.getPageOffset(n)),!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9)||t.isCss1CompatMode()||(o=goog.math.Coordinate.difference(o,t.getDocumentScroll())),e.left+=o.x,e.top+=o.y}},goog.style.getRelativePosition=function(e,t){return e=goog.style.getClientPosition(e),t=goog.style.getClientPosition(t),new goog.math.Coordinate(e.x-t.x,e.y-t.y)},goog.style.getClientPositionForElement_=function(e){return e=goog.style.getBoundingClientRect_(e),new goog.math.Coordinate(e.left,e.top)},goog.style.getClientPosition=function(e){return goog.asserts.assert(e),e.nodeType==goog.dom.NodeType.ELEMENT?goog.style.getClientPositionForElement_(e):(e=e.changedTouches?e.changedTouches[0]:e,new goog.math.Coordinate(e.clientX,e.clientY))},goog.style.setPageOffset=function(e,t,o){var n=goog.style.getPageOffset(e);t instanceof goog.math.Coordinate&&(o=t.y,t=t.x),t=goog.asserts.assertNumber(t)-n.x,goog.style.setPosition(e,e.offsetLeft+t,e.offsetTop+(Number(o)-n.y))},goog.style.setSize=function(e,t,o){if(t instanceof goog.math.Size)o=t.height,t=t.width;else if(null==o)throw Error("missing height argument");goog.style.setWidth(e,t),goog.style.setHeight(e,o)},goog.style.getPixelStyleValue_=function(e,t){return"number"==typeof e&&(e=(t?Math.round(e):e)+"px"),e},goog.style.setHeight=function(e,t){e.style.height=goog.style.getPixelStyleValue_(t,!0)},goog.style.setWidth=function(e,t){e.style.width=goog.style.getPixelStyleValue_(t,!0)},goog.style.getSize=function(e){return goog.style.evaluateWithTemporaryDisplay_(goog.style.getSizeWithDisplay_,e)},goog.style.evaluateWithTemporaryDisplay_=function(e,t){if("none"!=goog.style.getStyle_(t,"display"))return e(t);var o=t.style,n=o.display,i=o.visibility,r=o.position;return o.visibility="hidden",o.position="absolute",o.display="inline",e=e(t),o.display=n,o.position=r,o.visibility=i,e},goog.style.getSizeWithDisplay_=function(e){var t=e.offsetWidth,o=e.offsetHeight,n=goog.userAgent.WEBKIT&&!t&&!o;return goog.isDef(t)&&!n||!e.getBoundingClientRect?new goog.math.Size(t,o):(e=goog.style.getBoundingClientRect_(e),new goog.math.Size(e.right-e.left,e.bottom-e.top))},goog.style.getTransformedSize=function(e){return e.getBoundingClientRect?(e=goog.style.evaluateWithTemporaryDisplay_(goog.style.getBoundingClientRect_,e),new goog.math.Size(e.right-e.left,e.bottom-e.top)):null},goog.style.getBounds=function(e){var t=goog.style.getPageOffset(e);return e=goog.style.getSize(e),new goog.math.Rect(t.x,t.y,e.width,e.height)},goog.style.toCamelCase=function(e){return goog.string.toCamelCase(String(e))},goog.style.toSelectorCase=function(e){return goog.string.toSelectorCase(e)},goog.style.getOpacity=function(e){goog.asserts.assert(e);var t=e.style;return e="","opacity"in t?e=t.opacity:"MozOpacity"in t?e=t.MozOpacity:"filter"in t&&(t=t.filter.match(/alpha\(opacity=([\d.]+)\)/))&&(e=String(t[1]/100)),""==e?e:Number(e)},goog.style.setOpacity=function(e,t){goog.asserts.assert(e),"opacity"in(e=e.style)?e.opacity=t:"MozOpacity"in e?e.MozOpacity=t:"filter"in e&&(e.filter=""===t?"":"alpha(opacity="+100*Number(t)+")")},goog.style.setTransparentBackgroundImage=function(e,t){e=e.style,goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?e.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+t+'", sizingMethod="crop")':(e.backgroundImage="url("+t+")",e.backgroundPosition="top left",e.backgroundRepeat="no-repeat")},goog.style.clearTransparentBackgroundImage=function(e){"filter"in(e=e.style)?e.filter="":e.backgroundImage="none"},goog.style.showElement=function(e,t){goog.style.setElementShown(e,t)},goog.style.setElementShown=function(e,t){e.style.display=t?"":"none"},goog.style.isElementShown=function(e){return"none"!=e.style.display},goog.style.installStyles=function(e,t){return goog.style.installSafeStyleSheet(goog.html.legacyconversions.safeStyleSheetFromString(e),t)},goog.style.installSafeStyleSheet=function(e,t){var o=(t=goog.dom.getDomHelper(t)).getDocument();if(goog.userAgent.IE&&o.createStyleSheet){var n=o.createStyleSheet();goog.style.setSafeStyleSheet(n,e)}else(o=t.getElementsByTagNameAndClass("HEAD")[0])||(n=t.getElementsByTagNameAndClass("BODY")[0],o=t.createDom("HEAD"),n.parentNode.insertBefore(o,n)),n=t.createDom("STYLE"),goog.style.setSafeStyleSheet(n,e),t.appendChild(o,n);return n},goog.style.uninstallStyles=function(e){goog.dom.removeNode(e.ownerNode||e.owningElement||e)},goog.style.setStyles=function(e,t){goog.style.setSafeStyleSheet(e,goog.html.legacyconversions.safeStyleSheetFromString(t))},goog.style.setSafeStyleSheet=function(e,t){t=goog.html.SafeStyleSheet.unwrap(t),goog.userAgent.IE&&goog.isDef(e.cssText)?e.cssText=t:e.innerHTML=t},goog.style.setPreWrap=function(e){e=e.style,goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?(e.whiteSpace="pre",e.wordWrap="break-word"):e.whiteSpace=goog.userAgent.GECKO?"-moz-pre-wrap":"pre-wrap"},goog.style.setInlineBlock=function(e){(e=e.style).position="relative",goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?(e.zoom="1",e.display="inline"):e.display="inline-block"},goog.style.isRightToLeft=function(e){return"rtl"==goog.style.getStyle_(e,"direction")},goog.style.unselectableStyle_=goog.userAgent.GECKO?"MozUserSelect":goog.userAgent.WEBKIT||goog.userAgent.EDGE?"WebkitUserSelect":null,goog.style.isUnselectable=function(e){return goog.style.unselectableStyle_?"none"==e.style[goog.style.unselectableStyle_].toLowerCase():!(!goog.userAgent.IE&&!goog.userAgent.OPERA)&&"on"==e.getAttribute("unselectable")},goog.style.setUnselectable=function(e,t,o){o=o?null:e.getElementsByTagName("*");var n=goog.style.unselectableStyle_;if(n){if(t=t?"none":"",e.style&&(e.style[n]=t),o){e=0;for(var i;i=o[e];e++)i.style&&(i.style[n]=t)}}else if((goog.userAgent.IE||goog.userAgent.OPERA)&&(t=t?"on":"",e.setAttribute("unselectable",t),o))for(e=0;i=o[e];e++)i.setAttribute("unselectable",t)},goog.style.getBorderBoxSize=function(e){return new goog.math.Size(e.offsetWidth,e.offsetHeight)},goog.style.setBorderBoxSize=function(e,t){var o=goog.dom.getOwnerDocument(e),n=goog.dom.getDomHelper(o).isCss1CompatMode();!goog.userAgent.IE||goog.userAgent.isVersionOrHigher("10")||n&&goog.userAgent.isVersionOrHigher("8")?goog.style.setBoxSizingSize_(e,t,"border-box"):(o=e.style,n?(n=goog.style.getPaddingBox(e),e=goog.style.getBorderBox(e),o.pixelWidth=t.width-e.left-n.left-n.right-e.right,o.pixelHeight=t.height-e.top-n.top-n.bottom-e.bottom):(o.pixelWidth=t.width,o.pixelHeight=t.height))},goog.style.getContentBoxSize=function(e){var t=goog.dom.getOwnerDocument(e),o=goog.userAgent.IE&&e.currentStyle;return o&&goog.dom.getDomHelper(t).isCss1CompatMode()&&"auto"!=o.width&&"auto"!=o.height&&!o.boxSizing?(t=goog.style.getIePixelValue_(e,o.width,"width","pixelWidth"),e=goog.style.getIePixelValue_(e,o.height,"height","pixelHeight"),new goog.math.Size(t,e)):(o=goog.style.getBorderBoxSize(e),t=goog.style.getPaddingBox(e),e=goog.style.getBorderBox(e),new goog.math.Size(o.width-e.left-t.left-t.right-e.right,o.height-e.top-t.top-t.bottom-e.bottom))},goog.style.setContentBoxSize=function(e,t){var o=goog.dom.getOwnerDocument(e),n=goog.dom.getDomHelper(o).isCss1CompatMode();!goog.userAgent.IE||goog.userAgent.isVersionOrHigher("10")||n&&goog.userAgent.isVersionOrHigher("8")?goog.style.setBoxSizingSize_(e,t,"content-box"):(o=e.style,n?(o.pixelWidth=t.width,o.pixelHeight=t.height):(n=goog.style.getPaddingBox(e),e=goog.style.getBorderBox(e),o.pixelWidth=t.width+e.left+n.left+n.right+e.right,o.pixelHeight=t.height+e.top+n.top+n.bottom+e.bottom))},goog.style.setBoxSizingSize_=function(e,t,o){e=e.style,goog.userAgent.GECKO?e.MozBoxSizing=o:goog.userAgent.WEBKIT?e.WebkitBoxSizing=o:e.boxSizing=o,e.width=Math.max(t.width,0)+"px",e.height=Math.max(t.height,0)+"px"},goog.style.getIePixelValue_=function(e,t,o,n){if(/^\d+px?$/.test(t))return parseInt(t,10);var i=e.style[o],r=e.runtimeStyle[o];return e.runtimeStyle[o]=e.currentStyle[o],e.style[o]=t,t=e.style[n],e.style[o]=i,e.runtimeStyle[o]=r,+t},goog.style.getIePixelDistance_=function(e,t){return(t=goog.style.getCascadedStyle(e,t))?goog.style.getIePixelValue_(e,t,"left","pixelLeft"):0},goog.style.getBox_=function(e,t){if(goog.userAgent.IE){var o=goog.style.getIePixelDistance_(e,t+"Left"),n=goog.style.getIePixelDistance_(e,t+"Right"),i=goog.style.getIePixelDistance_(e,t+"Top");return e=goog.style.getIePixelDistance_(e,t+"Bottom"),new goog.math.Box(i,n,e,o)}return o=goog.style.getComputedStyle(e,t+"Left"),n=goog.style.getComputedStyle(e,t+"Right"),i=goog.style.getComputedStyle(e,t+"Top"),e=goog.style.getComputedStyle(e,t+"Bottom"),new goog.math.Box(parseFloat(i),parseFloat(n),parseFloat(e),parseFloat(o))},goog.style.getPaddingBox=function(e){return goog.style.getBox_(e,"padding")},goog.style.getMarginBox=function(e){return goog.style.getBox_(e,"margin")},goog.style.ieBorderWidthKeywords_={thin:2,medium:4,thick:6},goog.style.getIePixelBorder_=function(e,t){return"none"==goog.style.getCascadedStyle(e,t+"Style")?0:(t=goog.style.getCascadedStyle(e,t+"Width"))in goog.style.ieBorderWidthKeywords_?goog.style.ieBorderWidthKeywords_[t]:goog.style.getIePixelValue_(e,t,"left","pixelLeft")},goog.style.getBorderBox=function(e){if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(9)){var t=goog.style.getIePixelBorder_(e,"borderLeft"),o=goog.style.getIePixelBorder_(e,"borderRight"),n=goog.style.getIePixelBorder_(e,"borderTop");return e=goog.style.getIePixelBorder_(e,"borderBottom"),new goog.math.Box(n,o,e,t)}return t=goog.style.getComputedStyle(e,"borderLeftWidth"),o=goog.style.getComputedStyle(e,"borderRightWidth"),n=goog.style.getComputedStyle(e,"borderTopWidth"),e=goog.style.getComputedStyle(e,"borderBottomWidth"),new goog.math.Box(parseFloat(n),parseFloat(o),parseFloat(e),parseFloat(t))},goog.style.getFontFamily=function(e){var t=goog.dom.getOwnerDocument(e),o="";if(t.body.createTextRange&&goog.dom.contains(t,e)){(t=t.body.createTextRange()).moveToElementText(e);try{o=t.queryCommandValue("FontName")}catch(e){o=""}}return o||(o=goog.style.getStyle_(e,"fontFamily")),1<(e=o.split(",")).length&&(o=e[0]),goog.string.stripQuotes(o,"\"'")},goog.style.lengthUnitRegex_=/[^\d]+$/,goog.style.getLengthUnits=function(e){return(e=e.match(goog.style.lengthUnitRegex_))&&e[0]||null},goog.style.ABSOLUTE_CSS_LENGTH_UNITS_={cm:1,in:1,mm:1,pc:1,pt:1},goog.style.CONVERTIBLE_RELATIVE_CSS_UNITS_={em:1,ex:1},goog.style.getFontSize=function(e){var t=goog.style.getStyle_(e,"fontSize"),o=goog.style.getLengthUnits(t);if(t&&"px"==o)return parseInt(t,10);if(goog.userAgent.IE){if(String(o)in goog.style.ABSOLUTE_CSS_LENGTH_UNITS_)return goog.style.getIePixelValue_(e,t,"left","pixelLeft");if(e.parentNode&&e.parentNode.nodeType==goog.dom.NodeType.ELEMENT&&String(o)in goog.style.CONVERTIBLE_RELATIVE_CSS_UNITS_)return e=e.parentNode,o=goog.style.getStyle_(e,"fontSize"),goog.style.getIePixelValue_(e,t==o?"1em":t,"left","pixelLeft")}return o=goog.dom.createDom("SPAN",{style:"visibility:hidden;position:absolute;line-height:0;padding:0;margin:0;border:0;height:1em;"}),goog.dom.appendChild(e,o),t=o.offsetHeight,goog.dom.removeNode(o),t},goog.style.parseStyleAttribute=function(e){var t={};return goog.array.forEach(e.split(/\s*;\s*/),function(e){var o=e.match(/\s*([\w-]+)\s*:(.+)/);o&&(e=o[1],o=goog.string.trim(o[2]),t[goog.string.toCamelCase(e.toLowerCase())]=o)}),t},goog.style.toStyleAttribute=function(e){var t=[];return goog.object.forEach(e,function(e,o){t.push(goog.string.toSelectorCase(o),":",e,";")}),t.join("")},goog.style.setFloat=function(e,t){e.style[goog.userAgent.IE?"styleFloat":"cssFloat"]=t},goog.style.getFloat=function(e){return e.style[goog.userAgent.IE?"styleFloat":"cssFloat"]||""},goog.style.getScrollbarWidth=function(e){var t=goog.dom.createElement("DIV");return e&&(t.className=e),t.style.cssText="overflow:auto;position:absolute;top:0;width:100px;height:100px",e=goog.dom.createElement("DIV"),goog.style.setSize(e,"200px","200px"),t.appendChild(e),goog.dom.appendChild(goog.dom.getDocument().body,t),e=t.offsetWidth-t.clientWidth,goog.dom.removeNode(t),e},goog.style.MATRIX_TRANSLATION_REGEX_=/matrix\([0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, ([0-9\.\-]+)p?x?, ([0-9\.\-]+)p?x?\)/,goog.style.getCssTranslation=function(e){return(e=goog.style.getComputedTransform(e))&&(e=e.match(goog.style.MATRIX_TRANSLATION_REGEX_))?new goog.math.Coordinate(parseFloat(e[1]),parseFloat(e[2])):new goog.math.Coordinate(0,0)},goog.events.EventHandler=function(e){goog.Disposable.call(this),this.handler_=e,this.keys_={}},goog.inherits(goog.events.EventHandler,goog.Disposable),goog.events.EventHandler.typeArray_=[],goog.events.EventHandler.prototype.listen=function(e,t,o,n){return this.listen_(e,t,o,n)},goog.events.EventHandler.prototype.listenWithScope=function(e,t,o,n,i){return this.listen_(e,t,o,n,i)},goog.events.EventHandler.prototype.listen_=function(e,t,o,n,i){goog.isArray(t)||(t&&(goog.events.EventHandler.typeArray_[0]=t.toString()),t=goog.events.EventHandler.typeArray_);for(var r=0;r<t.length;r++){var l=goog.events.listen(e,t[r],o||this.handleEvent,n||!1,i||this.handler_||this);if(!l)break;this.keys_[l.key]=l}return this},goog.events.EventHandler.prototype.listenOnce=function(e,t,o,n){return this.listenOnce_(e,t,o,n)},goog.events.EventHandler.prototype.listenOnceWithScope=function(e,t,o,n,i){return this.listenOnce_(e,t,o,n,i)},goog.events.EventHandler.prototype.listenOnce_=function(e,t,o,n,i){if(goog.isArray(t))for(var r=0;r<t.length;r++)this.listenOnce_(e,t[r],o,n,i);else{if(!(e=goog.events.listenOnce(e,t,o||this.handleEvent,n,i||this.handler_||this)))return this;this.keys_[e.key]=e}return this},goog.events.EventHandler.prototype.listenWithWrapper=function(e,t,o,n){return this.listenWithWrapper_(e,t,o,n)},goog.events.EventHandler.prototype.listenWithWrapperAndScope=function(e,t,o,n,i){return this.listenWithWrapper_(e,t,o,n,i)},goog.events.EventHandler.prototype.listenWithWrapper_=function(e,t,o,n,i){return t.listen(e,o,n,i||this.handler_||this,this),this},goog.events.EventHandler.prototype.getListenerCount=function(){var e,t=0;for(e in this.keys_)Object.prototype.hasOwnProperty.call(this.keys_,e)&&t++;return t},goog.events.EventHandler.prototype.unlisten=function(e,t,o,n,i){if(goog.isArray(t))for(var r=0;r<t.length;r++)this.unlisten(e,t[r],o,n,i);else(e=goog.events.getListener(e,t,o||this.handleEvent,n,i||this.handler_||this))&&(goog.events.unlistenByKey(e),delete this.keys_[e.key]);return this},goog.events.EventHandler.prototype.unlistenWithWrapper=function(e,t,o,n,i){return t.unlisten(e,o,n,i||this.handler_||this,this),this},goog.events.EventHandler.prototype.removeAll=function(){goog.object.forEach(this.keys_,function(e,t){this.keys_.hasOwnProperty(t)&&goog.events.unlistenByKey(e)},this),this.keys_={}},goog.events.EventHandler.prototype.disposeInternal=function(){goog.events.EventHandler.superClass_.disposeInternal.call(this),this.removeAll()},goog.events.EventHandler.prototype.handleEvent=function(e){throw Error("EventHandler.handleEvent not implemented")},goog.events.EventTarget=function(){goog.Disposable.call(this),this.eventTargetListeners_=new goog.events.ListenerMap(this),this.actualEventTarget_=this,this.parentEventTarget_=null},goog.inherits(goog.events.EventTarget,goog.Disposable),goog.events.Listenable.addImplementation(goog.events.EventTarget),goog.events.EventTarget.MAX_ANCESTORS_=1e3,goog.events.EventTarget.prototype.getParentEventTarget=function(){return this.parentEventTarget_},goog.events.EventTarget.prototype.setParentEventTarget=function(e){this.parentEventTarget_=e},goog.events.EventTarget.prototype.addEventListener=function(e,t,o,n){goog.events.listen(this,e,t,o,n)},goog.events.EventTarget.prototype.removeEventListener=function(e,t,o,n){goog.events.unlisten(this,e,t,o,n)},goog.events.EventTarget.prototype.dispatchEvent=function(e){this.assertInitialized_();var t=this.getParentEventTarget();if(t)for(var o=[],n=1;t;t=t.getParentEventTarget())o.push(t),goog.asserts.assert(++n<goog.events.EventTarget.MAX_ANCESTORS_,"infinite loop");return goog.events.EventTarget.dispatchEventInternal_(this.actualEventTarget_,e,o)},goog.events.EventTarget.prototype.disposeInternal=function(){goog.events.EventTarget.superClass_.disposeInternal.call(this),this.removeAllListeners(),this.parentEventTarget_=null},goog.events.EventTarget.prototype.listen=function(e,t,o,n){return this.assertInitialized_(),this.eventTargetListeners_.add(String(e),t,!1,o,n)},goog.events.EventTarget.prototype.listenOnce=function(e,t,o,n){return this.eventTargetListeners_.add(String(e),t,!0,o,n)},goog.events.EventTarget.prototype.unlisten=function(e,t,o,n){return this.eventTargetListeners_.remove(String(e),t,o,n)},goog.events.EventTarget.prototype.unlistenByKey=function(e){return this.eventTargetListeners_.removeByKey(e)},goog.events.EventTarget.prototype.removeAllListeners=function(e){return this.eventTargetListeners_?this.eventTargetListeners_.removeAll(e):0},goog.events.EventTarget.prototype.fireListeners=function(e,t,o){if(!(e=this.eventTargetListeners_.listeners[String(e)]))return!0;e=e.concat();for(var n=!0,i=0;i<e.length;++i){var r=e[i];if(r&&!r.removed&&r.capture==t){var l=r.listener,s=r.handler||r.src;r.callOnce&&this.unlistenByKey(r),n=!1!==l.call(s,o)&&n}}return n&&0!=o.returnValue_},goog.events.EventTarget.prototype.getListeners=function(e,t){return this.eventTargetListeners_.getListeners(String(e),t)},goog.events.EventTarget.prototype.getListener=function(e,t,o,n){return this.eventTargetListeners_.getListener(String(e),t,o,n)},goog.events.EventTarget.prototype.hasListener=function(e,t){return e=goog.isDef(e)?String(e):void 0,this.eventTargetListeners_.hasListener(e,t)},goog.events.EventTarget.prototype.setTargetForTesting=function(e){this.actualEventTarget_=e},goog.events.EventTarget.prototype.assertInitialized_=function(){goog.asserts.assert(this.eventTargetListeners_,"Event target is not initialized. Did you call the superclass (goog.events.EventTarget) constructor?")},goog.events.EventTarget.dispatchEventInternal_=function(e,t,o){var n=t.type||t;if(goog.isString(t))t=new goog.events.Event(t,e);else if(t instanceof goog.events.Event)t.target=t.target||e;else{var i=t;t=new goog.events.Event(n,e),goog.object.extend(t,i)}if(i=!0,o)for(var r=o.length-1;!t.propagationStopped_&&0<=r;r--){var l=t.currentTarget=o[r];i=l.fireListeners(n,!0,t)&&i}if(t.propagationStopped_||(i=(l=t.currentTarget=e).fireListeners(n,!0,t)&&i,t.propagationStopped_||(i=l.fireListeners(n,!1,t)&&i)),o)for(r=0;!t.propagationStopped_&&r<o.length;r++)i=(l=t.currentTarget=o[r]).fireListeners(n,!1,t)&&i;return i},goog.ui={},goog.ui.IdGenerator=function(){},goog.addSingletonGetter(goog.ui.IdGenerator),goog.ui.IdGenerator.prototype.nextId_=0,goog.ui.IdGenerator.prototype.getNextUniqueId=function(){return":"+(this.nextId_++).toString(36)},goog.ui.Component=function(e){goog.events.EventTarget.call(this),this.dom_=e||goog.dom.getDomHelper(),this.rightToLeft_=goog.ui.Component.defaultRightToLeft_,this.id_=null,this.inDocument_=!1,this.element_=null,this.googUiComponentHandler_=void 0,this.childIndex_=this.children_=this.parent_=this.model_=null,this.wasDecorated_=!1},goog.inherits(goog.ui.Component,goog.events.EventTarget),goog.ui.Component.ALLOW_DETACHED_DECORATION=!1,goog.ui.Component.prototype.idGenerator_=goog.ui.IdGenerator.getInstance(),goog.ui.Component.DEFAULT_BIDI_DIR=0,goog.ui.Component.defaultRightToLeft_=1!=goog.ui.Component.DEFAULT_BIDI_DIR&&(-1==goog.ui.Component.DEFAULT_BIDI_DIR||null),goog.ui.Component.EventType={BEFORE_SHOW:"beforeshow",SHOW:"show",HIDE:"hide",DISABLE:"disable",ENABLE:"enable",HIGHLIGHT:"highlight",UNHIGHLIGHT:"unhighlight",ACTIVATE:"activate",DEACTIVATE:"deactivate",SELECT:"select",UNSELECT:"unselect",CHECK:"check",UNCHECK:"uncheck",FOCUS:"focus",BLUR:"blur",OPEN:"open",CLOSE:"close",ENTER:"enter",LEAVE:"leave",ACTION:"action",CHANGE:"change"},goog.ui.Component.Error={NOT_SUPPORTED:"Method not supported",DECORATE_INVALID:"Invalid element to decorate",ALREADY_RENDERED:"Component already rendered",PARENT_UNABLE_TO_BE_SET:"Unable to set parent component",CHILD_INDEX_OUT_OF_BOUNDS:"Child component index out of bounds",NOT_OUR_CHILD:"Child is not in parent component",NOT_IN_DOCUMENT:"Operation not supported while component is not in document",STATE_INVALID:"Invalid component state"},goog.ui.Component.State={ALL:255,DISABLED:1,HOVER:2,ACTIVE:4,SELECTED:8,CHECKED:16,FOCUSED:32,OPENED:64},goog.ui.Component.getStateTransitionEvent=function(e,t){switch(e){case goog.ui.Component.State.DISABLED:return t?goog.ui.Component.EventType.DISABLE:goog.ui.Component.EventType.ENABLE;case goog.ui.Component.State.HOVER:return t?goog.ui.Component.EventType.HIGHLIGHT:goog.ui.Component.EventType.UNHIGHLIGHT;case goog.ui.Component.State.ACTIVE:return t?goog.ui.Component.EventType.ACTIVATE:goog.ui.Component.EventType.DEACTIVATE;case goog.ui.Component.State.SELECTED:return t?goog.ui.Component.EventType.SELECT:goog.ui.Component.EventType.UNSELECT;case goog.ui.Component.State.CHECKED:return t?goog.ui.Component.EventType.CHECK:goog.ui.Component.EventType.UNCHECK;case goog.ui.Component.State.FOCUSED:return t?goog.ui.Component.EventType.FOCUS:goog.ui.Component.EventType.BLUR;case goog.ui.Component.State.OPENED:return t?goog.ui.Component.EventType.OPEN:goog.ui.Component.EventType.CLOSE}throw Error(goog.ui.Component.Error.STATE_INVALID)},goog.ui.Component.setDefaultRightToLeft=function(e){goog.ui.Component.defaultRightToLeft_=e},goog.ui.Component.prototype.getId=function(){return this.id_||(this.id_=this.idGenerator_.getNextUniqueId())},goog.ui.Component.prototype.setId=function(e){this.parent_&&this.parent_.childIndex_&&(goog.object.remove(this.parent_.childIndex_,this.id_),goog.object.add(this.parent_.childIndex_,e,this)),this.id_=e},goog.ui.Component.prototype.getElement=function(){return this.element_},goog.ui.Component.prototype.getElementStrict=function(){var e=this.element_;return goog.asserts.assert(e,"Can not call getElementStrict before rendering/decorating."),e},goog.ui.Component.prototype.setElementInternal=function(e){this.element_=e},goog.ui.Component.prototype.getElementsByClass=function(e){return this.element_?this.dom_.getElementsByClass(e,this.element_):[]},goog.ui.Component.prototype.getElementByClass=function(e){return this.element_?this.dom_.getElementByClass(e,this.element_):null},goog.ui.Component.prototype.getRequiredElementByClass=function(e){var t=this.getElementByClass(e);return goog.asserts.assert(t,"Expected element in component with class: %s",e),t},goog.ui.Component.prototype.getHandler=function(){return this.googUiComponentHandler_||(this.googUiComponentHandler_=new goog.events.EventHandler(this)),this.googUiComponentHandler_},goog.ui.Component.prototype.setParent=function(e){if(this==e)throw Error(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);if(e&&this.parent_&&this.id_&&this.parent_.getChild(this.id_)&&this.parent_!=e)throw Error(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);this.parent_=e,goog.ui.Component.superClass_.setParentEventTarget.call(this,e)},goog.ui.Component.prototype.getParent=function(){return this.parent_},goog.ui.Component.prototype.setParentEventTarget=function(e){if(this.parent_&&this.parent_!=e)throw Error(goog.ui.Component.Error.NOT_SUPPORTED);goog.ui.Component.superClass_.setParentEventTarget.call(this,e)},goog.ui.Component.prototype.getDomHelper=function(){return this.dom_},goog.ui.Component.prototype.isInDocument=function(){return this.inDocument_},goog.ui.Component.prototype.createDom=function(){this.element_=this.dom_.createElement("DIV")},goog.ui.Component.prototype.render=function(e){this.render_(e)},goog.ui.Component.prototype.renderBefore=function(e){this.render_(e.parentNode,e)},goog.ui.Component.prototype.render_=function(e,t){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.element_||this.createDom(),e?e.insertBefore(this.element_,t||null):this.dom_.getDocument().body.appendChild(this.element_),this.parent_&&!this.parent_.isInDocument()||this.enterDocument()},goog.ui.Component.prototype.decorate=function(e){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);if(!e||!this.canDecorate(e))throw Error(goog.ui.Component.Error.DECORATE_INVALID);this.wasDecorated_=!0;var t=goog.dom.getOwnerDocument(e);this.dom_&&this.dom_.getDocument()==t||(this.dom_=goog.dom.getDomHelper(e)),this.decorateInternal(e),goog.ui.Component.ALLOW_DETACHED_DECORATION&&!goog.dom.contains(t,e)||this.enterDocument()},goog.ui.Component.prototype.canDecorate=function(e){return!0},goog.ui.Component.prototype.wasDecorated=function(){return this.wasDecorated_},goog.ui.Component.prototype.decorateInternal=function(e){this.element_=e},goog.ui.Component.prototype.enterDocument=function(){this.inDocument_=!0,this.forEachChild(function(e){!e.isInDocument()&&e.getElement()&&e.enterDocument()})},goog.ui.Component.prototype.exitDocument=function(){this.forEachChild(function(e){e.isInDocument()&&e.exitDocument()}),this.googUiComponentHandler_&&this.googUiComponentHandler_.removeAll(),this.inDocument_=!1},goog.ui.Component.prototype.disposeInternal=function(){this.inDocument_&&this.exitDocument(),this.googUiComponentHandler_&&(this.googUiComponentHandler_.dispose(),delete this.googUiComponentHandler_),this.forEachChild(function(e){e.dispose()}),!this.wasDecorated_&&this.element_&&goog.dom.removeNode(this.element_),this.parent_=this.model_=this.element_=this.childIndex_=this.children_=null,goog.ui.Component.superClass_.disposeInternal.call(this)},goog.ui.Component.prototype.makeId=function(e){return this.getId()+"."+e},goog.ui.Component.prototype.makeIds=function(e){var t,o={};for(t in e)o[t]=this.makeId(e[t]);return o},goog.ui.Component.prototype.getModel=function(){return this.model_},goog.ui.Component.prototype.setModel=function(e){this.model_=e},goog.ui.Component.prototype.getFragmentFromId=function(e){return e.substring(this.getId().length+1)},goog.ui.Component.prototype.getElementByFragment=function(e){if(!this.inDocument_)throw Error(goog.ui.Component.Error.NOT_IN_DOCUMENT);return this.dom_.getElement(this.makeId(e))},goog.ui.Component.prototype.addChild=function(e,t){this.addChildAt(e,this.getChildCount(),t)},goog.ui.Component.prototype.addChildAt=function(e,t,o){if(goog.asserts.assert(!!e,"Provided element must not be null."),e.inDocument_&&(o||!this.inDocument_))throw Error(goog.ui.Component.Error.ALREADY_RENDERED);if(0>t||t>this.getChildCount())throw Error(goog.ui.Component.Error.CHILD_INDEX_OUT_OF_BOUNDS);this.childIndex_&&this.children_||(this.childIndex_={},this.children_=[]),e.getParent()==this?(goog.object.set(this.childIndex_,e.getId(),e),goog.array.remove(this.children_,e)):goog.object.add(this.childIndex_,e.getId(),e),e.setParent(this),goog.array.insertAt(this.children_,e,t),e.inDocument_&&this.inDocument_&&e.getParent()==this?(t=(o=this.getContentElement()).childNodes[t]||null)!=e.getElement()&&o.insertBefore(e.getElement(),t):o?(this.element_||this.createDom(),t=this.getChildAt(t+1),e.render_(this.getContentElement(),t?t.element_:null)):this.inDocument_&&!e.inDocument_&&e.element_&&e.element_.parentNode&&e.element_.parentNode.nodeType==goog.dom.NodeType.ELEMENT&&e.enterDocument()},goog.ui.Component.prototype.getContentElement=function(){return this.element_},goog.ui.Component.prototype.isRightToLeft=function(){return null==this.rightToLeft_&&(this.rightToLeft_=goog.style.isRightToLeft(this.inDocument_?this.element_:this.dom_.getDocument().body)),this.rightToLeft_},goog.ui.Component.prototype.setRightToLeft=function(e){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.rightToLeft_=e},goog.ui.Component.prototype.hasChildren=function(){return!!this.children_&&0!=this.children_.length},goog.ui.Component.prototype.getChildCount=function(){return this.children_?this.children_.length:0},goog.ui.Component.prototype.getChildIds=function(){var e=[];return this.forEachChild(function(t){e.push(t.getId())}),e},goog.ui.Component.prototype.getChild=function(e){return this.childIndex_&&e&&goog.object.get(this.childIndex_,e)||null},goog.ui.Component.prototype.getChildAt=function(e){return this.children_&&this.children_[e]||null},goog.ui.Component.prototype.forEachChild=function(e,t){this.children_&&goog.array.forEach(this.children_,e,t)},goog.ui.Component.prototype.indexOfChild=function(e){return this.children_&&e?goog.array.indexOf(this.children_,e):-1},goog.ui.Component.prototype.removeChild=function(e,t){if(e){var o=goog.isString(e)?e:e.getId();e=this.getChild(o),o&&e&&(goog.object.remove(this.childIndex_,o),goog.array.remove(this.children_,e),t&&(e.exitDocument(),e.element_&&goog.dom.removeNode(e.element_)),e.setParent(null))}if(!e)throw Error(goog.ui.Component.Error.NOT_OUR_CHILD);return e},goog.ui.Component.prototype.removeChildAt=function(e,t){return this.removeChild(this.getChildAt(e),t)},goog.ui.Component.prototype.removeChildren=function(e){for(var t=[];this.hasChildren();)t.push(this.removeChildAt(0,e));return t},goog.a11y={},goog.a11y.aria={},goog.a11y.aria.Role={ALERT:"alert",ALERTDIALOG:"alertdialog",APPLICATION:"application",ARTICLE:"article",BANNER:"banner",BUTTON:"button",CHECKBOX:"checkbox",COLUMNHEADER:"columnheader",COMBOBOX:"combobox",COMPLEMENTARY:"complementary",CONTENTINFO:"contentinfo",DEFINITION:"definition",DIALOG:"dialog",DIRECTORY:"directory",DOCUMENT:"document",FORM:"form",GRID:"grid",GRIDCELL:"gridcell",GROUP:"group",HEADING:"heading",IMG:"img",LINK:"link",LIST:"list",LISTBOX:"listbox",LISTITEM:"listitem",LOG:"log",MAIN:"main",MARQUEE:"marquee",MATH:"math",MENU:"menu",MENUBAR:"menubar",MENU_ITEM:"menuitem",MENU_ITEM_CHECKBOX:"menuitemcheckbox",MENU_ITEM_RADIO:"menuitemradio",NAVIGATION:"navigation",NOTE:"note",OPTION:"option",PRESENTATION:"presentation",PROGRESSBAR:"progressbar",RADIO:"radio",RADIOGROUP:"radiogroup",REGION:"region",ROW:"row",ROWGROUP:"rowgroup",ROWHEADER:"rowheader",SCROLLBAR:"scrollbar",SEARCH:"search",SEPARATOR:"separator",SLIDER:"slider",SPINBUTTON:"spinbutton",STATUS:"status",TAB:"tab",TAB_LIST:"tablist",TAB_PANEL:"tabpanel",TEXTBOX:"textbox",TEXTINFO:"textinfo",TIMER:"timer",TOOLBAR:"toolbar",TOOLTIP:"tooltip",TREE:"tree",TREEGRID:"treegrid",TREEITEM:"treeitem"},goog.a11y.aria.State={ACTIVEDESCENDANT:"activedescendant",ATOMIC:"atomic",AUTOCOMPLETE:"autocomplete",BUSY:"busy",CHECKED:"checked",CONTROLS:"controls",DESCRIBEDBY:"describedby",DISABLED:"disabled",DROPEFFECT:"dropeffect",EXPANDED:"expanded",FLOWTO:"flowto",GRABBED:"grabbed",HASPOPUP:"haspopup",HIDDEN:"hidden",INVALID:"invalid",LABEL:"label",LABELLEDBY:"labelledby",LEVEL:"level",LIVE:"live",MULTILINE:"multiline",MULTISELECTABLE:"multiselectable",ORIENTATION:"orientation",OWNS:"owns",POSINSET:"posinset",PRESSED:"pressed",READONLY:"readonly",RELEVANT:"relevant",REQUIRED:"required",SELECTED:"selected",SETSIZE:"setsize",SORT:"sort",VALUEMAX:"valuemax",VALUEMIN:"valuemin",VALUENOW:"valuenow",VALUETEXT:"valuetext"},goog.a11y.aria.AutoCompleteValues={INLINE:"inline",LIST:"list",BOTH:"both",NONE:"none"},goog.a11y.aria.DropEffectValues={COPY:"copy",MOVE:"move",LINK:"link",EXECUTE:"execute",POPUP:"popup",NONE:"none"},goog.a11y.aria.LivePriority={OFF:"off",POLITE:"polite",ASSERTIVE:"assertive"},goog.a11y.aria.OrientationValues={VERTICAL:"vertical",HORIZONTAL:"horizontal"},goog.a11y.aria.RelevantValues={ADDITIONS:"additions",REMOVALS:"removals",TEXT:"text",ALL:"all"},goog.a11y.aria.SortValues={ASCENDING:"ascending",DESCENDING:"descending",NONE:"none",OTHER:"other"},goog.a11y.aria.CheckedValues={TRUE:"true",FALSE:"false",MIXED:"mixed",UNDEFINED:"undefined"},goog.a11y.aria.ExpandedValues={TRUE:"true",FALSE:"false",UNDEFINED:"undefined"},goog.a11y.aria.GrabbedValues={TRUE:"true",FALSE:"false",UNDEFINED:"undefined"},goog.a11y.aria.InvalidValues={FALSE:"false",TRUE:"true",GRAMMAR:"grammar",SPELLING:"spelling"},goog.a11y.aria.PressedValues={TRUE:"true",FALSE:"false",MIXED:"mixed",UNDEFINED:"undefined"},goog.a11y.aria.SelectedValues={TRUE:"true",FALSE:"false",UNDEFINED:"undefined"},goog.a11y.aria.datatables={},goog.a11y.aria.datatables.getDefaultValuesMap=function(){return goog.a11y.aria.DefaultStateValueMap_||(goog.a11y.aria.DefaultStateValueMap_=goog.object.create(goog.a11y.aria.State.ATOMIC,!1,goog.a11y.aria.State.AUTOCOMPLETE,"none",goog.a11y.aria.State.DROPEFFECT,"none",goog.a11y.aria.State.HASPOPUP,!1,goog.a11y.aria.State.LIVE,"off",goog.a11y.aria.State.MULTILINE,!1,goog.a11y.aria.State.MULTISELECTABLE,!1,goog.a11y.aria.State.ORIENTATION,"vertical",goog.a11y.aria.State.READONLY,!1,goog.a11y.aria.State.RELEVANT,"additions text",goog.a11y.aria.State.REQUIRED,!1,goog.a11y.aria.State.SORT,"none",goog.a11y.aria.State.BUSY,!1,goog.a11y.aria.State.DISABLED,!1,goog.a11y.aria.State.HIDDEN,!1,goog.a11y.aria.State.INVALID,"false")),goog.a11y.aria.DefaultStateValueMap_},goog.a11y.aria.ARIA_PREFIX_="aria-",goog.a11y.aria.ROLE_ATTRIBUTE_="role",goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_=goog.object.createSet("A AREA BUTTON HEAD INPUT LINK MENU META OPTGROUP OPTION PROGRESS STYLE SELECT SOURCE TEXTAREA TITLE TRACK".split(" ")),goog.a11y.aria.CONTAINER_ROLES_=[goog.a11y.aria.Role.COMBOBOX,goog.a11y.aria.Role.GRID,goog.a11y.aria.Role.GROUP,goog.a11y.aria.Role.LISTBOX,goog.a11y.aria.Role.MENU,goog.a11y.aria.Role.MENUBAR,goog.a11y.aria.Role.RADIOGROUP,goog.a11y.aria.Role.ROW,goog.a11y.aria.Role.ROWGROUP,goog.a11y.aria.Role.TAB_LIST,goog.a11y.aria.Role.TEXTBOX,goog.a11y.aria.Role.TOOLBAR,goog.a11y.aria.Role.TREE,goog.a11y.aria.Role.TREEGRID];goog.a11y.aria.setRole=function(e,t){t?(goog.asserts.ENABLE_ASSERTS&&goog.asserts.assert(goog.object.containsValue(goog.a11y.aria.Role,t),"No such ARIA role "+t),e.setAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_,t)):goog.a11y.aria.removeRole(e)},goog.a11y.aria.getRole=function(e){return e.getAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_)||null},goog.a11y.aria.removeRole=function(e){e.removeAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_)},goog.a11y.aria.setState=function(e,t,o){goog.isArray(o)&&(o=o.join(" "));var n=goog.a11y.aria.getAriaAttributeName_(t);""===o||null==o?t in(o=goog.a11y.aria.datatables.getDefaultValuesMap())?e.setAttribute(n,o[t]):e.removeAttribute(n):e.setAttribute(n,o)},goog.a11y.aria.toggleState=function(e,t){var o=goog.a11y.aria.getState(e,t);goog.string.isEmptyOrWhitespace(goog.string.makeSafe(o))||"true"==o||"false"==o?goog.a11y.aria.setState(e,t,"true"==o?"false":"true"):goog.a11y.aria.removeState(e,t)},goog.a11y.aria.removeState=function(e,t){e.removeAttribute(goog.a11y.aria.getAriaAttributeName_(t))},goog.a11y.aria.getState=function(e,t){return null==(e=e.getAttribute(goog.a11y.aria.getAriaAttributeName_(t)))||null==e?"":String(e)},goog.a11y.aria.getActiveDescendant=function(e){var t=goog.a11y.aria.getState(e,goog.a11y.aria.State.ACTIVEDESCENDANT);return goog.dom.getOwnerDocument(e).getElementById(t)},goog.a11y.aria.setActiveDescendant=function(e,t){var o="";t&&(o=t.id,goog.asserts.assert(o,"The active element should have an id.")),goog.a11y.aria.setState(e,goog.a11y.aria.State.ACTIVEDESCENDANT,o)},goog.a11y.aria.getLabel=function(e){return goog.a11y.aria.getState(e,goog.a11y.aria.State.LABEL)},goog.a11y.aria.setLabel=function(e,t){goog.a11y.aria.setState(e,goog.a11y.aria.State.LABEL,t)},goog.a11y.aria.assertRoleIsSetInternalUtil=function(e,t){goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_[e.tagName]||(e=goog.a11y.aria.getRole(e),goog.asserts.assert(null!=e,"The element ARIA role cannot be null."),goog.asserts.assert(goog.array.contains(t,e),'Non existing or incorrect role set for element.The role set is "'+e+'". The role should be any of "'+t+'". Check the ARIA specification for more details http://www.w3.org/TR/wai-aria/roles.'))},goog.a11y.aria.getStateBoolean=function(e,t){return e=e.getAttribute(goog.a11y.aria.getAriaAttributeName_(t)),goog.asserts.assert(goog.isBoolean(e)||null==e||"true"==e||"false"==e),null==e?e:goog.isBoolean(e)?e:"true"==e},goog.a11y.aria.getStateNumber=function(e,t){return e=e.getAttribute(goog.a11y.aria.getAriaAttributeName_(t)),goog.asserts.assert(!(null!=e&&isNaN(Number(e))||goog.isBoolean(e))),null==e?null:Number(e)},goog.a11y.aria.getStateString=function(e,t){return e=e.getAttribute(goog.a11y.aria.getAriaAttributeName_(t)),goog.asserts.assert((null==e||goog.isString(e))&&(""==e||isNaN(Number(e)))&&"true"!=e&&"false"!=e),null==e||""==e?null:e},goog.a11y.aria.getStringArrayStateInternalUtil=function(e,t){return e=e.getAttribute(goog.a11y.aria.getAriaAttributeName_(t)),goog.a11y.aria.splitStringOnWhitespace_(e)},goog.a11y.aria.hasState=function(e,t){return e.hasAttribute(goog.a11y.aria.getAriaAttributeName_(t))},goog.a11y.aria.isContainerRole=function(e){return e=goog.a11y.aria.getRole(e),goog.array.contains(goog.a11y.aria.CONTAINER_ROLES_,e)},goog.a11y.aria.splitStringOnWhitespace_=function(e){return e?e.split(/\s+/):[]},goog.a11y.aria.getAriaAttributeName_=function(e){return goog.asserts.ENABLE_ASSERTS&&(goog.asserts.assert(e,"ARIA attribute cannot be empty."),goog.asserts.assert(goog.object.containsValue(goog.a11y.aria.State,e),"No such ARIA attribute "+e)),goog.a11y.aria.ARIA_PREFIX_+e},goog.events.KeyCodes={WIN_KEY_FF_LINUX:0,MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS_SIGN:43,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,FF_SEMICOLON:59,FF_EQUALS:61,FF_DASH:173,QUESTION_MARK:63,AT_SIGN:64,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SCROLL_LOCK:145,FIRST_MEDIA_KEY:166,LAST_MEDIA_KEY:183,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,TILDE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,MAC_WK_CMD_LEFT:91,MAC_WK_CMD_RIGHT:93,WIN_IME:229,VK_NONAME:252,PHANTOM:255},goog.events.KeyCodes.isTextModifyingKeyEvent=function(e){if(e.altKey&&!e.ctrlKey||e.metaKey||e.keyCode>=goog.events.KeyCodes.F1&&e.keyCode<=goog.events.KeyCodes.F12)return!1;switch(e.keyCode){case goog.events.KeyCodes.ALT:case goog.events.KeyCodes.CAPS_LOCK:case goog.events.KeyCodes.CONTEXT_MENU:case goog.events.KeyCodes.CTRL:case goog.events.KeyCodes.DOWN:case goog.events.KeyCodes.END:case goog.events.KeyCodes.ESC:case goog.events.KeyCodes.HOME:case goog.events.KeyCodes.INSERT:case goog.events.KeyCodes.LEFT:case goog.events.KeyCodes.MAC_FF_META:case goog.events.KeyCodes.META:case goog.events.KeyCodes.NUMLOCK:case goog.events.KeyCodes.NUM_CENTER:case goog.events.KeyCodes.PAGE_DOWN:case goog.events.KeyCodes.PAGE_UP:case goog.events.KeyCodes.PAUSE:case goog.events.KeyCodes.PHANTOM:case goog.events.KeyCodes.PRINT_SCREEN:case goog.events.KeyCodes.RIGHT:case goog.events.KeyCodes.SCROLL_LOCK:case goog.events.KeyCodes.SHIFT:case goog.events.KeyCodes.UP:case goog.events.KeyCodes.VK_NONAME:case goog.events.KeyCodes.WIN_KEY:case goog.events.KeyCodes.WIN_KEY_RIGHT:return!1;case goog.events.KeyCodes.WIN_KEY_FF_LINUX:return!goog.userAgent.GECKO;default:return e.keyCode<goog.events.KeyCodes.FIRST_MEDIA_KEY||e.keyCode>goog.events.KeyCodes.LAST_MEDIA_KEY}},goog.events.KeyCodes.firesKeyPressEvent=function(e,t,o,n,i,r){if(!(goog.userAgent.IE||goog.userAgent.EDGE||goog.userAgent.WEBKIT&&goog.userAgent.isVersionOrHigher("525")))return!0;if(goog.userAgent.MAC&&i)return goog.events.KeyCodes.isCharacterKey(e);if(i&&!n)return!1;if(goog.isNumber(t)&&(t=goog.events.KeyCodes.normalizeKeyCode(t)),i=t==goog.events.KeyCodes.CTRL||t==goog.events.KeyCodes.ALT||goog.userAgent.MAC&&t==goog.events.KeyCodes.META,r=t==goog.events.KeyCodes.SHIFT&&(n||r),(!o||goog.userAgent.MAC)&&i||goog.userAgent.MAC&&r)return!1;if((goog.userAgent.WEBKIT||goog.userAgent.EDGE)&&n&&o)switch(e){case goog.events.KeyCodes.BACKSLASH:case goog.events.KeyCodes.OPEN_SQUARE_BRACKET:case goog.events.KeyCodes.CLOSE_SQUARE_BRACKET:case goog.events.KeyCodes.TILDE:case goog.events.KeyCodes.SEMICOLON:case goog.events.KeyCodes.DASH:case goog.events.KeyCodes.EQUALS:case goog.events.KeyCodes.COMMA:case goog.events.KeyCodes.PERIOD:case goog.events.KeyCodes.SLASH:case goog.events.KeyCodes.APOSTROPHE:case goog.events.KeyCodes.SINGLE_QUOTE:return!1}if(goog.userAgent.IE&&n&&t==e)return!1;switch(e){case goog.events.KeyCodes.ENTER:return!0;case goog.events.KeyCodes.ESC:return!(goog.userAgent.WEBKIT||goog.userAgent.EDGE)}return goog.events.KeyCodes.isCharacterKey(e)},goog.events.KeyCodes.isCharacterKey=function(e){if(e>=goog.events.KeyCodes.ZERO&&e<=goog.events.KeyCodes.NINE||e>=goog.events.KeyCodes.NUM_ZERO&&e<=goog.events.KeyCodes.NUM_MULTIPLY||e>=goog.events.KeyCodes.A&&e<=goog.events.KeyCodes.Z||(goog.userAgent.WEBKIT||goog.userAgent.EDGE)&&0==e)return!0;switch(e){case goog.events.KeyCodes.SPACE:case goog.events.KeyCodes.PLUS_SIGN:case goog.events.KeyCodes.QUESTION_MARK:case goog.events.KeyCodes.AT_SIGN:case goog.events.KeyCodes.NUM_PLUS:case goog.events.KeyCodes.NUM_MINUS:case goog.events.KeyCodes.NUM_PERIOD:case goog.events.KeyCodes.NUM_DIVISION:case goog.events.KeyCodes.SEMICOLON:case goog.events.KeyCodes.FF_SEMICOLON:case goog.events.KeyCodes.DASH:case goog.events.KeyCodes.EQUALS:case goog.events.KeyCodes.FF_EQUALS:case goog.events.KeyCodes.COMMA:case goog.events.KeyCodes.PERIOD:case goog.events.KeyCodes.SLASH:case goog.events.KeyCodes.APOSTROPHE:case goog.events.KeyCodes.SINGLE_QUOTE:case goog.events.KeyCodes.OPEN_SQUARE_BRACKET:case goog.events.KeyCodes.BACKSLASH:case goog.events.KeyCodes.CLOSE_SQUARE_BRACKET:return!0;default:return!1}},goog.events.KeyCodes.normalizeKeyCode=function(e){return goog.userAgent.GECKO?goog.events.KeyCodes.normalizeGeckoKeyCode(e):goog.userAgent.MAC&&goog.userAgent.WEBKIT?goog.events.KeyCodes.normalizeMacWebKitKeyCode(e):e},goog.events.KeyCodes.normalizeGeckoKeyCode=function(e){switch(e){case goog.events.KeyCodes.FF_EQUALS:return goog.events.KeyCodes.EQUALS;case goog.events.KeyCodes.FF_SEMICOLON:return goog.events.KeyCodes.SEMICOLON;case goog.events.KeyCodes.FF_DASH:return goog.events.KeyCodes.DASH;case goog.events.KeyCodes.MAC_FF_META:return goog.events.KeyCodes.META;case goog.events.KeyCodes.WIN_KEY_FF_LINUX:return goog.events.KeyCodes.WIN_KEY;default:return e}},goog.events.KeyCodes.normalizeMacWebKitKeyCode=function(e){switch(e){case goog.events.KeyCodes.MAC_WK_CMD_RIGHT:return goog.events.KeyCodes.META;default:return e}},goog.events.KeyHandler=function(e,t){goog.events.EventTarget.call(this),e&&this.attach(e,t)},goog.inherits(goog.events.KeyHandler,goog.events.EventTarget),goog.events.KeyHandler.prototype.element_=null,goog.events.KeyHandler.prototype.keyPressKey_=null,goog.events.KeyHandler.prototype.keyDownKey_=null,goog.events.KeyHandler.prototype.keyUpKey_=null,goog.events.KeyHandler.prototype.lastKey_=-1,goog.events.KeyHandler.prototype.keyCode_=-1,goog.events.KeyHandler.prototype.altKey_=!1,goog.events.KeyHandler.EventType={KEY:"key"},goog.events.KeyHandler.safariKey_={3:goog.events.KeyCodes.ENTER,12:goog.events.KeyCodes.NUMLOCK,63232:goog.events.KeyCodes.UP,63233:goog.events.KeyCodes.DOWN,63234:goog.events.KeyCodes.LEFT,63235:goog.events.KeyCodes.RIGHT,63236:goog.events.KeyCodes.F1,63237:goog.events.KeyCodes.F2,63238:goog.events.KeyCodes.F3,63239:goog.events.KeyCodes.F4,63240:goog.events.KeyCodes.F5,63241:goog.events.KeyCodes.F6,63242:goog.events.KeyCodes.F7,63243:goog.events.KeyCodes.F8,63244:goog.events.KeyCodes.F9,63245:goog.events.KeyCodes.F10,63246:goog.events.KeyCodes.F11,63247:goog.events.KeyCodes.F12,63248:goog.events.KeyCodes.PRINT_SCREEN,63272:goog.events.KeyCodes.DELETE,63273:goog.events.KeyCodes.HOME,63275:goog.events.KeyCodes.END,63276:goog.events.KeyCodes.PAGE_UP,63277:goog.events.KeyCodes.PAGE_DOWN,63289:goog.events.KeyCodes.NUMLOCK,63302:goog.events.KeyCodes.INSERT},goog.events.KeyHandler.keyIdentifier_={Up:goog.events.KeyCodes.UP,Down:goog.events.KeyCodes.DOWN,Left:goog.events.KeyCodes.LEFT,Right:goog.events.KeyCodes.RIGHT,Enter:goog.events.KeyCodes.ENTER,F1:goog.events.KeyCodes.F1,F2:goog.events.KeyCodes.F2,F3:goog.events.KeyCodes.F3,F4:goog.events.KeyCodes.F4,F5:goog.events.KeyCodes.F5,F6:goog.events.KeyCodes.F6,F7:goog.events.KeyCodes.F7,F8:goog.events.KeyCodes.F8,F9:goog.events.KeyCodes.F9,F10:goog.events.KeyCodes.F10,F11:goog.events.KeyCodes.F11,F12:goog.events.KeyCodes.F12,"U+007F":goog.events.KeyCodes.DELETE,Home:goog.events.KeyCodes.HOME,End:goog.events.KeyCodes.END,PageUp:goog.events.KeyCodes.PAGE_UP,PageDown:goog.events.KeyCodes.PAGE_DOWN,Insert:goog.events.KeyCodes.INSERT},goog.events.KeyHandler.USES_KEYDOWN_=goog.userAgent.IE||goog.userAgent.EDGE||goog.userAgent.WEBKIT&&goog.userAgent.isVersionOrHigher("525"),goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_=goog.userAgent.MAC&&goog.userAgent.GECKO,goog.events.KeyHandler.prototype.handleKeyDown_=function(e){(goog.userAgent.WEBKIT||goog.userAgent.EDGE)&&(this.lastKey_==goog.events.KeyCodes.CTRL&&!e.ctrlKey||this.lastKey_==goog.events.KeyCodes.ALT&&!e.altKey||goog.userAgent.MAC&&this.lastKey_==goog.events.KeyCodes.META&&!e.metaKey)&&this.resetState(),-1==this.lastKey_&&(e.ctrlKey&&e.keyCode!=goog.events.KeyCodes.CTRL?this.lastKey_=goog.events.KeyCodes.CTRL:e.altKey&&e.keyCode!=goog.events.KeyCodes.ALT?this.lastKey_=goog.events.KeyCodes.ALT:e.metaKey&&e.keyCode!=goog.events.KeyCodes.META&&(this.lastKey_=goog.events.KeyCodes.META)),goog.events.KeyHandler.USES_KEYDOWN_&&!goog.events.KeyCodes.firesKeyPressEvent(e.keyCode,this.lastKey_,e.shiftKey,e.ctrlKey,e.altKey,e.metaKey)?this.handleEvent(e):(this.keyCode_=goog.events.KeyCodes.normalizeKeyCode(e.keyCode),goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_&&(this.altKey_=e.altKey))},goog.events.KeyHandler.prototype.resetState=function(){this.keyCode_=this.lastKey_=-1},goog.events.KeyHandler.prototype.handleKeyup_=function(e){this.resetState(),this.altKey_=e.altKey},goog.events.KeyHandler.prototype.handleEvent=function(e){var t=e.getBrowserEvent(),o=t.altKey;if(goog.userAgent.IE&&e.type==goog.events.EventType.KEYPRESS)var n=this.keyCode_,i=n!=goog.events.KeyCodes.ENTER&&n!=goog.events.KeyCodes.ESC?t.keyCode:0;else(goog.userAgent.WEBKIT||goog.userAgent.EDGE)&&e.type==goog.events.EventType.KEYPRESS?(n=this.keyCode_,i=0<=t.charCode&&63232>t.charCode&&goog.events.KeyCodes.isCharacterKey(n)?t.charCode:0):goog.userAgent.OPERA&&!goog.userAgent.WEBKIT?(n=this.keyCode_,i=goog.events.KeyCodes.isCharacterKey(n)?t.keyCode:0):(n=t.keyCode||this.keyCode_,i=t.charCode||0,goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_&&(o=this.altKey_),goog.userAgent.MAC&&i==goog.events.KeyCodes.QUESTION_MARK&&n==goog.events.KeyCodes.WIN_KEY&&(n=goog.events.KeyCodes.SLASH));var r=n=goog.events.KeyCodes.normalizeKeyCode(n);n?63232<=n&&n in goog.events.KeyHandler.safariKey_?r=goog.events.KeyHandler.safariKey_[n]:25==n&&e.shiftKey&&(r=9):t.keyIdentifier&&t.keyIdentifier in goog.events.KeyHandler.keyIdentifier_&&(r=goog.events.KeyHandler.keyIdentifier_[t.keyIdentifier]),e=r==this.lastKey_,this.lastKey_=r,(t=new goog.events.KeyEvent(r,i,e,t)).altKey=o,this.dispatchEvent(t)},goog.events.KeyHandler.prototype.getElement=function(){return this.element_},goog.events.KeyHandler.prototype.attach=function(e,t){this.keyUpKey_&&this.detach(),this.element_=e,this.keyPressKey_=goog.events.listen(this.element_,goog.events.EventType.KEYPRESS,this,t),this.keyDownKey_=goog.events.listen(this.element_,goog.events.EventType.KEYDOWN,this.handleKeyDown_,t,this),this.keyUpKey_=goog.events.listen(this.element_,goog.events.EventType.KEYUP,this.handleKeyup_,t,this)},goog.events.KeyHandler.prototype.detach=function(){this.keyPressKey_&&(goog.events.unlistenByKey(this.keyPressKey_),goog.events.unlistenByKey(this.keyDownKey_),goog.events.unlistenByKey(this.keyUpKey_),this.keyUpKey_=this.keyDownKey_=this.keyPressKey_=null),this.element_=null,this.keyCode_=this.lastKey_=-1},goog.events.KeyHandler.prototype.disposeInternal=function(){goog.events.KeyHandler.superClass_.disposeInternal.call(this),this.detach()},goog.events.KeyEvent=function(e,t,o,n){goog.events.BrowserEvent.call(this,n),this.type=goog.events.KeyHandler.EventType.KEY,this.keyCode=e,this.charCode=t,this.repeat=o},goog.inherits(goog.events.KeyEvent,goog.events.BrowserEvent),goog.dom.classlist={},goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST=!1,goog.dom.classlist.get=function(e){return goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList?e.classList:(e=e.className,goog.isString(e)&&e.match(/\S+/g)||[])},goog.dom.classlist.set=function(e,t){e.className=t},goog.dom.classlist.contains=function(e,t){return goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList?e.classList.contains(t):goog.array.contains(goog.dom.classlist.get(e),t)},goog.dom.classlist.add=function(e,t){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList?e.classList.add(t):goog.dom.classlist.contains(e,t)||(e.className+=0<e.className.length?" "+t:t)},goog.dom.classlist.addAll=function(e,t){if(goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList)goog.array.forEach(t,function(t){goog.dom.classlist.add(e,t)});else{var o={};for(var n in goog.array.forEach(goog.dom.classlist.get(e),function(e){o[e]=!0}),goog.array.forEach(t,function(e){o[e]=!0}),e.className="",o)e.className+=0<e.className.length?" "+n:n}},goog.dom.classlist.remove=function(e,t){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList?e.classList.remove(t):goog.dom.classlist.contains(e,t)&&(e.className=goog.array.filter(goog.dom.classlist.get(e),function(e){return e!=t}).join(" "))},goog.dom.classlist.removeAll=function(e,t){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||e.classList?goog.array.forEach(t,function(t){goog.dom.classlist.remove(e,t)}):e.className=goog.array.filter(goog.dom.classlist.get(e),function(e){return!goog.array.contains(t,e)}).join(" ")},goog.dom.classlist.enable=function(e,t,o){o?goog.dom.classlist.add(e,t):goog.dom.classlist.remove(e,t)},goog.dom.classlist.enableAll=function(e,t,o){(o?goog.dom.classlist.addAll:goog.dom.classlist.removeAll)(e,t)},goog.dom.classlist.swap=function(e,t,o){return!!goog.dom.classlist.contains(e,t)&&(goog.dom.classlist.remove(e,t),goog.dom.classlist.add(e,o),!0)},goog.dom.classlist.toggle=function(e,t){var o=!goog.dom.classlist.contains(e,t);return goog.dom.classlist.enable(e,t,o),o},goog.dom.classlist.addRemove=function(e,t,o){goog.dom.classlist.remove(e,t),goog.dom.classlist.add(e,o)},goog.ui.registry={},goog.ui.registry.getDefaultRenderer=function(e){for(var t;e&&(t=goog.getUid(e),!(t=goog.ui.registry.defaultRenderers_[t]));)e=e.superClass_?e.superClass_.constructor:null;return t?goog.isFunction(t.getInstance)?t.getInstance():new t:null},goog.ui.registry.setDefaultRenderer=function(e,t){if(!goog.isFunction(e))throw Error("Invalid component class "+e);if(!goog.isFunction(t))throw Error("Invalid renderer class "+t);e=goog.getUid(e),goog.ui.registry.defaultRenderers_[e]=t},goog.ui.registry.getDecoratorByClassName=function(e){return e in goog.ui.registry.decoratorFunctions_?goog.ui.registry.decoratorFunctions_[e]():null},goog.ui.registry.setDecoratorByClassName=function(e,t){if(!e)throw Error("Invalid class name "+e);if(!goog.isFunction(t))throw Error("Invalid decorator function "+t);goog.ui.registry.decoratorFunctions_[e]=t},goog.ui.registry.getDecorator=function(e){goog.asserts.assert(e);for(var t=goog.dom.classlist.get(e),o=0,n=t.length;o<n;o++)if(e=goog.ui.registry.getDecoratorByClassName(t[o]))return e;return null},goog.ui.registry.reset=function(){goog.ui.registry.defaultRenderers_={},goog.ui.registry.decoratorFunctions_={}},goog.ui.registry.defaultRenderers_={},goog.ui.registry.decoratorFunctions_={},goog.ui.ContainerRenderer=function(e){this.ariaRole_=e},goog.addSingletonGetter(goog.ui.ContainerRenderer),goog.ui.ContainerRenderer.getCustomRenderer=function(e,t){return(e=new e).getCssClass=function(){return t},e},goog.ui.ContainerRenderer.CSS_CLASS="goog-container",goog.ui.ContainerRenderer.prototype.getAriaRole=function(){return this.ariaRole_},goog.ui.ContainerRenderer.prototype.enableTabIndex=function(e,t){e&&(e.tabIndex=t?0:-1)},goog.ui.ContainerRenderer.prototype.createDom=function(e){return e.getDomHelper().createDom("DIV",this.getClassNames(e).join(" "))},goog.ui.ContainerRenderer.prototype.getContentElement=function(e){return e},goog.ui.ContainerRenderer.prototype.canDecorate=function(e){return"DIV"==e.tagName},goog.ui.ContainerRenderer.prototype.decorate=function(e,t){t.id&&e.setId(t.id);var o=this.getCssClass(),n=!1,i=goog.dom.classlist.get(t);return i&&goog.array.forEach(i,function(t){t==o?n=!0:t&&this.setStateFromClassName(e,t,o)},this),n||goog.dom.classlist.add(t,o),this.decorateChildren(e,this.getContentElement(t)),t},goog.ui.ContainerRenderer.prototype.setStateFromClassName=function(e,t,o){t==o+"-disabled"?e.setEnabled(!1):t==o+"-horizontal"?e.setOrientation(goog.ui.Container.Orientation.HORIZONTAL):t==o+"-vertical"&&e.setOrientation(goog.ui.Container.Orientation.VERTICAL)},goog.ui.ContainerRenderer.prototype.decorateChildren=function(e,t,o){if(t){o=o||t.firstChild;for(var n;o&&o.parentNode==t;){if(n=o.nextSibling,o.nodeType==goog.dom.NodeType.ELEMENT){var i=this.getDecoratorForChild(o);i&&(i.setElementInternal(o),e.isEnabled()||i.setEnabled(!1),e.addChild(i),i.decorate(o))}else o.nodeValue&&""!=goog.string.trim(o.nodeValue)||t.removeChild(o);o=n}}},goog.ui.ContainerRenderer.prototype.getDecoratorForChild=function(e){return goog.ui.registry.getDecorator(e)},goog.ui.ContainerRenderer.prototype.initializeDom=function(e){e=e.getElement(),goog.asserts.assert(e,"The container DOM element cannot be null."),goog.style.setUnselectable(e,!0,goog.userAgent.GECKO),goog.userAgent.IE&&(e.hideFocus=!0);var t=this.getAriaRole();t&&goog.a11y.aria.setRole(e,t)},goog.ui.ContainerRenderer.prototype.getKeyEventTarget=function(e){return e.getElement()},goog.ui.ContainerRenderer.prototype.getCssClass=function(){return goog.ui.ContainerRenderer.CSS_CLASS},goog.ui.ContainerRenderer.prototype.getClassNames=function(e){var t=this.getCssClass(),o=e.getOrientation()==goog.ui.Container.Orientation.HORIZONTAL;return o=[t,o?t+"-horizontal":t+"-vertical"],e.isEnabled()||o.push(t+"-disabled"),o},goog.ui.ContainerRenderer.prototype.getDefaultOrientation=function(){return goog.ui.Container.Orientation.VERTICAL},goog.ui.ControlRenderer=function(){},goog.addSingletonGetter(goog.ui.ControlRenderer),goog.tagUnsealableClass(goog.ui.ControlRenderer),goog.ui.ControlRenderer.getCustomRenderer=function(e,t){return(e=new e).getCssClass=function(){return t},e},goog.ui.ControlRenderer.CSS_CLASS="goog-control",goog.ui.ControlRenderer.IE6_CLASS_COMBINATIONS=[],goog.ui.ControlRenderer.TOGGLE_ARIA_STATE_MAP_=goog.object.create(goog.a11y.aria.Role.BUTTON,goog.a11y.aria.State.PRESSED,goog.a11y.aria.Role.CHECKBOX,goog.a11y.aria.State.CHECKED,goog.a11y.aria.Role.MENU_ITEM,goog.a11y.aria.State.SELECTED,goog.a11y.aria.Role.MENU_ITEM_CHECKBOX,goog.a11y.aria.State.CHECKED,goog.a11y.aria.Role.MENU_ITEM_RADIO,goog.a11y.aria.State.CHECKED,goog.a11y.aria.Role.RADIO,goog.a11y.aria.State.CHECKED,goog.a11y.aria.Role.TAB,goog.a11y.aria.State.SELECTED,goog.a11y.aria.Role.TREEITEM,goog.a11y.aria.State.SELECTED),goog.ui.ControlRenderer.prototype.getAriaRole=function(){},goog.ui.ControlRenderer.prototype.createDom=function(e){return e.getDomHelper().createDom("DIV",this.getClassNames(e).join(" "),e.getContent())},goog.ui.ControlRenderer.prototype.getContentElement=function(e){return e},goog.ui.ControlRenderer.prototype.enableClassName=function(e,t,o){if(e=e.getElement?e.getElement():e){var n=[t];goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")&&(n=this.getAppliedCombinedClassNames_(goog.dom.classlist.get(e),t)).push(t),goog.dom.classlist.enableAll(e,n,o)}},goog.ui.ControlRenderer.prototype.enableExtraClassName=function(e,t,o){this.enableClassName(e,t,o)},goog.ui.ControlRenderer.prototype.canDecorate=function(e){return!0},goog.ui.ControlRenderer.prototype.decorate=function(e,t){t.id&&e.setId(t.id);var o=this.getContentElement(t);o&&o.firstChild?e.setContentInternal(o.firstChild.nextSibling?goog.array.clone(o.childNodes):o.firstChild):e.setContentInternal(null);var n=0,i=this.getCssClass(),r=this.getStructuralCssClass(),l=!1,s=!1,a=!1,g=goog.array.toArray(goog.dom.classlist.get(t));if(goog.array.forEach(g,function(e){l||e!=i?s||e!=r?n|=this.getStateFromClass(e):s=!0:(l=!0,r==i&&(s=!0)),this.getStateFromClass(e)==goog.ui.Component.State.DISABLED&&(goog.asserts.assertElement(o),goog.dom.isFocusableTabIndex(o)&&goog.dom.setFocusableTabIndex(o,!1))},this),e.setStateInternal(n),l||(g.push(i),r==i&&(s=!0)),s||g.push(r),(e=e.getExtraClassNames())&&g.push.apply(g,e),goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")){var c=this.getAppliedCombinedClassNames_(g);0<c.length&&(g.push.apply(g,c),a=!0)}return l&&s&&!e&&!a||goog.dom.classlist.set(t,g.join(" ")),t},goog.ui.ControlRenderer.prototype.initializeDom=function(e){e.isRightToLeft()&&this.setRightToLeft(e.getElement(),!0),e.isEnabled()&&this.setFocusable(e,e.isVisible())},goog.ui.ControlRenderer.prototype.setAriaRole=function(e,t){(t=t||this.getAriaRole())&&(goog.asserts.assert(e,"The element passed as a first parameter cannot be null."),t!=goog.a11y.aria.getRole(e)&&goog.a11y.aria.setRole(e,t))},goog.ui.ControlRenderer.prototype.setAriaStates=function(e,t){goog.asserts.assert(e),goog.asserts.assert(t);var o=e.getAriaLabel();goog.isDefAndNotNull(o)&&this.setAriaLabel(t,o),e.isVisible()||goog.a11y.aria.setState(t,goog.a11y.aria.State.HIDDEN,!e.isVisible()),e.isEnabled()||this.updateAriaState(t,goog.ui.Component.State.DISABLED,!e.isEnabled()),e.isSupportedState(goog.ui.Component.State.SELECTED)&&this.updateAriaState(t,goog.ui.Component.State.SELECTED,e.isSelected()),e.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(t,goog.ui.Component.State.CHECKED,e.isChecked()),e.isSupportedState(goog.ui.Component.State.OPENED)&&this.updateAriaState(t,goog.ui.Component.State.OPENED,e.isOpen())},goog.ui.ControlRenderer.prototype.setAriaLabel=function(e,t){goog.a11y.aria.setLabel(e,t)},goog.ui.ControlRenderer.prototype.setAllowTextSelection=function(e,t){goog.style.setUnselectable(e,!t,!goog.userAgent.IE&&!goog.userAgent.OPERA)},goog.ui.ControlRenderer.prototype.setRightToLeft=function(e,t){this.enableClassName(e,this.getStructuralCssClass()+"-rtl",t)},goog.ui.ControlRenderer.prototype.isFocusable=function(e){var t;return!(!e.isSupportedState(goog.ui.Component.State.FOCUSED)||!(t=e.getKeyEventTarget()))&&goog.dom.isFocusableTabIndex(t)},goog.ui.ControlRenderer.prototype.setFocusable=function(e,t){var o;if(e.isSupportedState(goog.ui.Component.State.FOCUSED)&&(o=e.getKeyEventTarget())){if(!t&&e.isFocused()){try{o.blur()}catch(e){}e.isFocused()&&e.handleBlur(null)}goog.dom.isFocusableTabIndex(o)!=t&&goog.dom.setFocusableTabIndex(o,t)}},goog.ui.ControlRenderer.prototype.setVisible=function(e,t){goog.style.setElementShown(e,t),e&&goog.a11y.aria.setState(e,goog.a11y.aria.State.HIDDEN,!t)},goog.ui.ControlRenderer.prototype.setState=function(e,t,o){var n=e.getElement();if(n){var i=this.getClassForState(t);i&&this.enableClassName(e,i,o),this.updateAriaState(n,t,o)}},goog.ui.ControlRenderer.prototype.updateAriaState=function(e,t,o){goog.ui.ControlRenderer.ariaAttributeMap_||(goog.ui.ControlRenderer.ariaAttributeMap_=goog.object.create(goog.ui.Component.State.DISABLED,goog.a11y.aria.State.DISABLED,goog.ui.Component.State.SELECTED,goog.a11y.aria.State.SELECTED,goog.ui.Component.State.CHECKED,goog.a11y.aria.State.CHECKED,goog.ui.Component.State.OPENED,goog.a11y.aria.State.EXPANDED)),goog.asserts.assert(e,"The element passed as a first parameter cannot be null."),(t=goog.ui.ControlRenderer.getAriaStateForAriaRole_(e,goog.ui.ControlRenderer.ariaAttributeMap_[t]))&&goog.a11y.aria.setState(e,t,o)},goog.ui.ControlRenderer.getAriaStateForAriaRole_=function(e,t){return(e=goog.a11y.aria.getRole(e))?(e=goog.ui.ControlRenderer.TOGGLE_ARIA_STATE_MAP_[e]||t,goog.ui.ControlRenderer.isAriaState_(t)?e:t):t},goog.ui.ControlRenderer.isAriaState_=function(e){return e==goog.a11y.aria.State.CHECKED||e==goog.a11y.aria.State.SELECTED},goog.ui.ControlRenderer.prototype.setContent=function(e,t){var o=this.getContentElement(e);o&&(goog.dom.removeChildren(o),t&&(goog.isString(t)?goog.dom.setTextContent(o,t):(e=function(e){if(e){var t=goog.dom.getOwnerDocument(o);o.appendChild(goog.isString(e)?t.createTextNode(e):e)}},goog.isArray(t)?goog.array.forEach(t,e):!goog.isArrayLike(t)||"nodeType"in t?e(t):goog.array.forEach(goog.array.clone(t),e))))},goog.ui.ControlRenderer.prototype.getKeyEventTarget=function(e){return e.getElement()},goog.ui.ControlRenderer.prototype.getCssClass=function(){return goog.ui.ControlRenderer.CSS_CLASS},goog.ui.ControlRenderer.prototype.getIe6ClassCombinations=function(){return[]},goog.ui.ControlRenderer.prototype.getStructuralCssClass=function(){return this.getCssClass()},goog.ui.ControlRenderer.prototype.getClassNames=function(e){var t=this.getCssClass(),o=[t],n=this.getStructuralCssClass();return n!=t&&o.push(n),t=this.getClassNamesForState(e.getState()),o.push.apply(o,t),(e=e.getExtraClassNames())&&o.push.apply(o,e),goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")&&o.push.apply(o,this.getAppliedCombinedClassNames_(o)),o},goog.ui.ControlRenderer.prototype.getAppliedCombinedClassNames_=function(e,t){var o=[];return t&&(e=goog.array.concat(e,[t])),goog.array.forEach(this.getIe6ClassCombinations(),function(n){!goog.array.every(n,goog.partial(goog.array.contains,e))||t&&!goog.array.contains(n,t)||o.push(n.join("_"))}),o},goog.ui.ControlRenderer.prototype.getClassNamesForState=function(e){for(var t=[];e;){var o=e&-e;t.push(this.getClassForState(o)),e&=~o}return t},goog.ui.ControlRenderer.prototype.getClassForState=function(e){return this.classByState_||this.createClassByStateMap_(),this.classByState_[e]},goog.ui.ControlRenderer.prototype.getStateFromClass=function(e){return this.stateByClass_||this.createStateByClassMap_(),e=parseInt(this.stateByClass_[e],10),isNaN(e)?0:e},goog.ui.ControlRenderer.prototype.createClassByStateMap_=function(){var e=this.getStructuralCssClass(),t=!goog.string.contains(goog.string.normalizeWhitespace(e)," ");goog.asserts.assert(t,"ControlRenderer has an invalid css class: '"+e+"'"),this.classByState_=goog.object.create(goog.ui.Component.State.DISABLED,e+"-disabled",goog.ui.Component.State.HOVER,e+"-hover",goog.ui.Component.State.ACTIVE,e+"-active",goog.ui.Component.State.SELECTED,e+"-selected",goog.ui.Component.State.CHECKED,e+"-checked",goog.ui.Component.State.FOCUSED,e+"-focused",goog.ui.Component.State.OPENED,e+"-open")},goog.ui.ControlRenderer.prototype.createStateByClassMap_=function(){this.classByState_||this.createClassByStateMap_(),this.stateByClass_=goog.object.transpose(this.classByState_)},goog.ui.Control=function(e,t,o){goog.ui.Component.call(this,o),this.renderer_=t||goog.ui.registry.getDefaultRenderer(this.constructor),this.setContentInternal(goog.isDef(e)?e:null),this.ariaLabel_=null},goog.inherits(goog.ui.Control,goog.ui.Component),goog.tagUnsealableClass(goog.ui.Control),goog.ui.Control.registerDecorator=goog.ui.registry.setDecoratorByClassName,goog.ui.Control.getDecorator=goog.ui.registry.getDecorator,goog.ui.Control.prototype.content_=null,goog.ui.Control.prototype.state_=0,goog.ui.Control.prototype.supportedStates_=goog.ui.Component.State.DISABLED|goog.ui.Component.State.HOVER|goog.ui.Component.State.ACTIVE|goog.ui.Component.State.FOCUSED,goog.ui.Control.prototype.autoStates_=goog.ui.Component.State.ALL,goog.ui.Control.prototype.statesWithTransitionEvents_=0,goog.ui.Control.prototype.visible_=!0,goog.ui.Control.prototype.extraClassNames_=null,goog.ui.Control.prototype.handleMouseEvents_=!0,goog.ui.Control.prototype.allowTextSelection_=!1,goog.ui.Control.prototype.preferredAriaRole_=null,goog.ui.Control.prototype.isHandleMouseEvents=function(){return this.handleMouseEvents_},goog.ui.Control.prototype.setHandleMouseEvents=function(e){this.isInDocument()&&e!=this.handleMouseEvents_&&this.enableMouseEventHandling_(e),this.handleMouseEvents_=e},goog.ui.Control.prototype.getKeyEventTarget=function(){return this.renderer_.getKeyEventTarget(this)},goog.ui.Control.prototype.getKeyHandler=function(){return this.keyHandler_||(this.keyHandler_=new goog.events.KeyHandler)},goog.ui.Control.prototype.getRenderer=function(){return this.renderer_},goog.ui.Control.prototype.setRenderer=function(e){if(this.isInDocument())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.getElement()&&this.setElementInternal(null),this.renderer_=e},goog.ui.Control.prototype.getExtraClassNames=function(){return this.extraClassNames_},goog.ui.Control.prototype.addClassName=function(e){e&&(this.extraClassNames_?goog.array.contains(this.extraClassNames_,e)||this.extraClassNames_.push(e):this.extraClassNames_=[e],this.renderer_.enableExtraClassName(this,e,!0))},goog.ui.Control.prototype.removeClassName=function(e){e&&this.extraClassNames_&&goog.array.remove(this.extraClassNames_,e)&&(0==this.extraClassNames_.length&&(this.extraClassNames_=null),this.renderer_.enableExtraClassName(this,e,!1))},goog.ui.Control.prototype.enableClassName=function(e,t){t?this.addClassName(e):this.removeClassName(e)},goog.ui.Control.prototype.createDom=function(){var e=this.renderer_.createDom(this);this.setElementInternal(e),this.renderer_.setAriaRole(e,this.getPreferredAriaRole()),this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(e,!1),this.isVisible()||this.renderer_.setVisible(e,!1)},goog.ui.Control.prototype.getPreferredAriaRole=function(){return this.preferredAriaRole_},goog.ui.Control.prototype.setPreferredAriaRole=function(e){this.preferredAriaRole_=e},goog.ui.Control.prototype.getAriaLabel=function(){return this.ariaLabel_},goog.ui.Control.prototype.setAriaLabel=function(e){this.ariaLabel_=e;var t=this.getElement();t&&this.renderer_.setAriaLabel(t,e)},goog.ui.Control.prototype.getContentElement=function(){return this.renderer_.getContentElement(this.getElement())},goog.ui.Control.prototype.canDecorate=function(e){return this.renderer_.canDecorate(e)},goog.ui.Control.prototype.decorateInternal=function(e){e=this.renderer_.decorate(this,e),this.setElementInternal(e),this.renderer_.setAriaRole(e,this.getPreferredAriaRole()),this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(e,!1),this.visible_="none"!=e.style.display},goog.ui.Control.prototype.enterDocument=function(){if(goog.ui.Control.superClass_.enterDocument.call(this),this.renderer_.setAriaStates(this,this.getElementStrict()),this.renderer_.initializeDom(this),this.supportedStates_&~goog.ui.Component.State.DISABLED&&(this.isHandleMouseEvents()&&this.enableMouseEventHandling_(!0),this.isSupportedState(goog.ui.Component.State.FOCUSED))){var e=this.getKeyEventTarget();if(e){var t=this.getKeyHandler();t.attach(e),this.getHandler().listen(t,goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent).listen(e,goog.events.EventType.FOCUS,this.handleFocus).listen(e,goog.events.EventType.BLUR,this.handleBlur)}}},goog.ui.Control.prototype.enableMouseEventHandling_=function(e){var t=this.getHandler(),o=this.getElement();e?(t.listen(o,goog.events.EventType.MOUSEOVER,this.handleMouseOver).listen(o,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).listen(o,goog.events.EventType.MOUSEUP,this.handleMouseUp).listen(o,goog.events.EventType.MOUSEOUT,this.handleMouseOut),this.handleContextMenu!=goog.nullFunction&&t.listen(o,goog.events.EventType.CONTEXTMENU,this.handleContextMenu),goog.userAgent.IE&&(goog.userAgent.isVersionOrHigher(9)||t.listen(o,goog.events.EventType.DBLCLICK,this.handleDblClick),this.ieMouseEventSequenceSimulator_||(this.ieMouseEventSequenceSimulator_=new goog.ui.Control.IeMouseEventSequenceSimulator_(this),this.registerDisposable(this.ieMouseEventSequenceSimulator_)))):(t.unlisten(o,goog.events.EventType.MOUSEOVER,this.handleMouseOver).unlisten(o,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).unlisten(o,goog.events.EventType.MOUSEUP,this.handleMouseUp).unlisten(o,goog.events.EventType.MOUSEOUT,this.handleMouseOut),this.handleContextMenu!=goog.nullFunction&&t.unlisten(o,goog.events.EventType.CONTEXTMENU,this.handleContextMenu),goog.userAgent.IE&&(goog.userAgent.isVersionOrHigher(9)||t.unlisten(o,goog.events.EventType.DBLCLICK,this.handleDblClick),goog.dispose(this.ieMouseEventSequenceSimulator_),this.ieMouseEventSequenceSimulator_=null))},goog.ui.Control.prototype.exitDocument=function(){goog.ui.Control.superClass_.exitDocument.call(this),this.keyHandler_&&this.keyHandler_.detach(),this.isVisible()&&this.isEnabled()&&this.renderer_.setFocusable(this,!1)},goog.ui.Control.prototype.disposeInternal=function(){goog.ui.Control.superClass_.disposeInternal.call(this),this.keyHandler_&&(this.keyHandler_.dispose(),delete this.keyHandler_),delete this.renderer_,this.ieMouseEventSequenceSimulator_=this.extraClassNames_=this.content_=null},goog.ui.Control.prototype.getContent=function(){return this.content_},goog.ui.Control.prototype.setContent=function(e){this.renderer_.setContent(this.getElement(),e),this.setContentInternal(e)},goog.ui.Control.prototype.setContentInternal=function(e){this.content_=e},goog.ui.Control.prototype.getCaption=function(){var e=this.getContent();return e?(e=goog.isString(e)?e:goog.isArray(e)?goog.array.map(e,goog.dom.getRawTextContent).join(""):goog.dom.getTextContent(e),goog.string.collapseBreakingSpaces(e)):""},goog.ui.Control.prototype.setCaption=function(e){this.setContent(e)},goog.ui.Control.prototype.setRightToLeft=function(e){goog.ui.Control.superClass_.setRightToLeft.call(this,e);var t=this.getElement();t&&this.renderer_.setRightToLeft(t,e)},goog.ui.Control.prototype.isAllowTextSelection=function(){return this.allowTextSelection_},goog.ui.Control.prototype.setAllowTextSelection=function(e){this.allowTextSelection_=e;var t=this.getElement();t&&this.renderer_.setAllowTextSelection(t,e)},goog.ui.Control.prototype.isVisible=function(){return this.visible_},goog.ui.Control.prototype.setVisible=function(e,t){return!!(t||this.visible_!=e&&this.dispatchEvent(e?goog.ui.Component.EventType.SHOW:goog.ui.Component.EventType.HIDE))&&((t=this.getElement())&&this.renderer_.setVisible(t,e),this.isEnabled()&&this.renderer_.setFocusable(this,e),this.visible_=e,!0)},goog.ui.Control.prototype.isEnabled=function(){return!this.hasState(goog.ui.Component.State.DISABLED)},goog.ui.Control.prototype.isParentDisabled_=function(){var e=this.getParent();return!!e&&"function"==typeof e.isEnabled&&!e.isEnabled()},goog.ui.Control.prototype.setEnabled=function(e){!this.isParentDisabled_()&&this.isTransitionAllowed(goog.ui.Component.State.DISABLED,!e)&&(e||(this.setActive(!1),this.setHighlighted(!1)),this.isVisible()&&this.renderer_.setFocusable(this,e),this.setState(goog.ui.Component.State.DISABLED,!e,!0))},goog.ui.Control.prototype.isHighlighted=function(){return this.hasState(goog.ui.Component.State.HOVER)},goog.ui.Control.prototype.setHighlighted=function(e){this.isTransitionAllowed(goog.ui.Component.State.HOVER,e)&&this.setState(goog.ui.Component.State.HOVER,e)},goog.ui.Control.prototype.isActive=function(){return this.hasState(goog.ui.Component.State.ACTIVE)},goog.ui.Control.prototype.setActive=function(e){this.isTransitionAllowed(goog.ui.Component.State.ACTIVE,e)&&this.setState(goog.ui.Component.State.ACTIVE,e)},goog.ui.Control.prototype.isSelected=function(){return this.hasState(goog.ui.Component.State.SELECTED)},goog.ui.Control.prototype.setSelected=function(e){this.isTransitionAllowed(goog.ui.Component.State.SELECTED,e)&&this.setState(goog.ui.Component.State.SELECTED,e)},goog.ui.Control.prototype.isChecked=function(){return this.hasState(goog.ui.Component.State.CHECKED)},goog.ui.Control.prototype.setChecked=function(e){this.isTransitionAllowed(goog.ui.Component.State.CHECKED,e)&&this.setState(goog.ui.Component.State.CHECKED,e)},goog.ui.Control.prototype.isFocused=function(){return this.hasState(goog.ui.Component.State.FOCUSED)},goog.ui.Control.prototype.setFocused=function(e){this.isTransitionAllowed(goog.ui.Component.State.FOCUSED,e)&&this.setState(goog.ui.Component.State.FOCUSED,e)},goog.ui.Control.prototype.isOpen=function(){return this.hasState(goog.ui.Component.State.OPENED)},goog.ui.Control.prototype.setOpen=function(e){this.isTransitionAllowed(goog.ui.Component.State.OPENED,e)&&this.setState(goog.ui.Component.State.OPENED,e)},goog.ui.Control.prototype.getState=function(){return this.state_},goog.ui.Control.prototype.hasState=function(e){return!!(this.state_&e)},goog.ui.Control.prototype.setState=function(e,t,o){o||e!=goog.ui.Component.State.DISABLED?this.isSupportedState(e)&&t!=this.hasState(e)&&(this.renderer_.setState(this,e,t),this.state_=t?this.state_|e:this.state_&~e):this.setEnabled(!t)},goog.ui.Control.prototype.setStateInternal=function(e){this.state_=e},goog.ui.Control.prototype.isSupportedState=function(e){return!!(this.supportedStates_&e)},goog.ui.Control.prototype.setSupportedState=function(e,t){if(this.isInDocument()&&this.hasState(e)&&!t)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);!t&&this.hasState(e)&&this.setState(e,!1),this.supportedStates_=t?this.supportedStates_|e:this.supportedStates_&~e},goog.ui.Control.prototype.isAutoState=function(e){return!!(this.autoStates_&e)&&this.isSupportedState(e)},goog.ui.Control.prototype.setAutoStates=function(e,t){this.autoStates_=t?this.autoStates_|e:this.autoStates_&~e},goog.ui.Control.prototype.isDispatchTransitionEvents=function(e){return!!(this.statesWithTransitionEvents_&e)&&this.isSupportedState(e)},goog.ui.Control.prototype.setDispatchTransitionEvents=function(e,t){this.statesWithTransitionEvents_=t?this.statesWithTransitionEvents_|e:this.statesWithTransitionEvents_&~e},goog.ui.Control.prototype.isTransitionAllowed=function(e,t){return this.isSupportedState(e)&&this.hasState(e)!=t&&(!(this.statesWithTransitionEvents_&e)||this.dispatchEvent(goog.ui.Component.getStateTransitionEvent(e,t)))&&!this.isDisposed()},goog.ui.Control.prototype.handleMouseOver=function(e){!goog.ui.Control.isMouseEventWithinElement_(e,this.getElement())&&this.dispatchEvent(goog.ui.Component.EventType.ENTER)&&this.isEnabled()&&this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!0)},goog.ui.Control.prototype.handleMouseOut=function(e){!goog.ui.Control.isMouseEventWithinElement_(e,this.getElement())&&this.dispatchEvent(goog.ui.Component.EventType.LEAVE)&&(this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!1),this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!1))},goog.ui.Control.prototype.handleContextMenu=goog.nullFunction,goog.ui.Control.isMouseEventWithinElement_=function(e,t){return!!e.relatedTarget&&goog.dom.contains(t,e.relatedTarget)},goog.ui.Control.prototype.handleMouseDown=function(e){this.isEnabled()&&(this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!0),e.isMouseActionButton()&&(this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!0),this.renderer_&&this.renderer_.isFocusable(this)&&this.getKeyEventTarget().focus())),!this.isAllowTextSelection()&&e.isMouseActionButton()&&e.preventDefault()},goog.ui.Control.prototype.handleMouseUp=function(e){this.isEnabled()&&(this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!0),this.isActive()&&this.performActionInternal(e)&&this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!1))},goog.ui.Control.prototype.handleDblClick=function(e){this.isEnabled()&&this.performActionInternal(e)},goog.ui.Control.prototype.performActionInternal=function(e){this.isAutoState(goog.ui.Component.State.CHECKED)&&this.setChecked(!this.isChecked()),this.isAutoState(goog.ui.Component.State.SELECTED)&&this.setSelected(!0),this.isAutoState(goog.ui.Component.State.OPENED)&&this.setOpen(!this.isOpen());var t=new goog.events.Event(goog.ui.Component.EventType.ACTION,this);return e&&(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.platformModifierKey=e.platformModifierKey),this.dispatchEvent(t)},goog.ui.Control.prototype.handleFocus=function(e){this.isAutoState(goog.ui.Component.State.FOCUSED)&&this.setFocused(!0)},goog.ui.Control.prototype.handleBlur=function(e){this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!1),this.isAutoState(goog.ui.Component.State.FOCUSED)&&this.setFocused(!1)},goog.ui.Control.prototype.handleKeyEvent=function(e){return!!(this.isVisible()&&this.isEnabled()&&this.handleKeyEventInternal(e))&&(e.preventDefault(),e.stopPropagation(),!0)},goog.ui.Control.prototype.handleKeyEventInternal=function(e){return e.keyCode==goog.events.KeyCodes.ENTER&&this.performActionInternal(e)},goog.ui.registry.setDefaultRenderer(goog.ui.Control,goog.ui.ControlRenderer),goog.ui.registry.setDecoratorByClassName(goog.ui.ControlRenderer.CSS_CLASS,function(){return new goog.ui.Control(null)}),goog.ui.Control.IeMouseEventSequenceSimulator_=function(e){goog.Disposable.call(this),this.control_=e,this.clickExpected_=!1,this.handler_=new goog.events.EventHandler(this),this.registerDisposable(this.handler_),e=this.control_.getElementStrict(),this.handler_.listen(e,goog.events.EventType.MOUSEDOWN,this.handleMouseDown_).listen(e,goog.events.EventType.MOUSEUP,this.handleMouseUp_).listen(e,goog.events.EventType.CLICK,this.handleClick_)},goog.inherits(goog.ui.Control.IeMouseEventSequenceSimulator_,goog.Disposable),goog.ui.Control.IeMouseEventSequenceSimulator_.SYNTHETIC_EVENTS_=!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9),goog.ui.Control.IeMouseEventSequenceSimulator_.prototype.handleMouseDown_=function(){this.clickExpected_=!1},goog.ui.Control.IeMouseEventSequenceSimulator_.prototype.handleMouseUp_=function(){this.clickExpected_=!0},goog.ui.Control.IeMouseEventSequenceSimulator_.makeLeftMouseEvent_=function(e,t){if(!goog.ui.Control.IeMouseEventSequenceSimulator_.SYNTHETIC_EVENTS_)return e.button=goog.events.BrowserEvent.MouseButton.LEFT,e.type=t,e;var o=document.createEvent("MouseEvents");return o.initMouseEvent(t,e.bubbles,e.cancelable,e.view||null,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,goog.events.BrowserEvent.MouseButton.LEFT,e.relatedTarget||null),o},goog.ui.Control.IeMouseEventSequenceSimulator_.prototype.handleClick_=function(e){if(this.clickExpected_)this.clickExpected_=!1;else{var t=e.getBrowserEvent(),o=t.button,n=t.type,i=goog.ui.Control.IeMouseEventSequenceSimulator_.makeLeftMouseEvent_(t,goog.events.EventType.MOUSEDOWN);this.control_.handleMouseDown(new goog.events.BrowserEvent(i,e.currentTarget)),i=goog.ui.Control.IeMouseEventSequenceSimulator_.makeLeftMouseEvent_(t,goog.events.EventType.MOUSEUP),this.control_.handleMouseUp(new goog.events.BrowserEvent(i,e.currentTarget)),goog.ui.Control.IeMouseEventSequenceSimulator_.SYNTHETIC_EVENTS_||(t.button=o,t.type=n)}},goog.ui.Control.IeMouseEventSequenceSimulator_.prototype.disposeInternal=function(){this.control_=null,goog.ui.Control.IeMouseEventSequenceSimulator_.superClass_.disposeInternal.call(this)},goog.ui.Container=function(e,t,o){goog.ui.Component.call(this,o),this.renderer_=t||goog.ui.ContainerRenderer.getInstance(),this.orientation_=e||this.renderer_.getDefaultOrientation()},goog.inherits(goog.ui.Container,goog.ui.Component),goog.tagUnsealableClass(goog.ui.Container),goog.ui.Container.EventType={AFTER_SHOW:"aftershow",AFTER_HIDE:"afterhide"},goog.ui.Container.Orientation={HORIZONTAL:"horizontal",VERTICAL:"vertical"},goog.ui.Container.prototype.keyEventTarget_=null,goog.ui.Container.prototype.keyHandler_=null,goog.ui.Container.prototype.renderer_=null,goog.ui.Container.prototype.orientation_=null,goog.ui.Container.prototype.visible_=!0,goog.ui.Container.prototype.enabled_=!0,goog.ui.Container.prototype.focusable_=!0,goog.ui.Container.prototype.highlightedIndex_=-1,goog.ui.Container.prototype.openItem_=null,goog.ui.Container.prototype.mouseButtonPressed_=!1,goog.ui.Container.prototype.allowFocusableChildren_=!1,goog.ui.Container.prototype.openFollowsHighlight_=!0,goog.ui.Container.prototype.childElementIdMap_=null,goog.ui.Container.prototype.getKeyEventTarget=function(){return this.keyEventTarget_||this.renderer_.getKeyEventTarget(this)},goog.ui.Container.prototype.setKeyEventTarget=function(e){if(!this.focusable_)throw Error("Can't set key event target for container that doesn't support keyboard focus!");var t=this.getKeyEventTarget(),o=this.isInDocument();this.keyEventTarget_=e;var n=this.getKeyEventTarget();o&&(this.keyEventTarget_=t,this.enableFocusHandling_(!1),this.keyEventTarget_=e,this.getKeyHandler().attach(n),this.enableFocusHandling_(!0))},goog.ui.Container.prototype.getKeyHandler=function(){return this.keyHandler_||(this.keyHandler_=new goog.events.KeyHandler(this.getKeyEventTarget()))},goog.ui.Container.prototype.getRenderer=function(){return this.renderer_},goog.ui.Container.prototype.setRenderer=function(e){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.renderer_=e},goog.ui.Container.prototype.createDom=function(){this.setElementInternal(this.renderer_.createDom(this))},goog.ui.Container.prototype.getContentElement=function(){return this.renderer_.getContentElement(this.getElement())},goog.ui.Container.prototype.canDecorate=function(e){return this.renderer_.canDecorate(e)},goog.ui.Container.prototype.decorateInternal=function(e){this.setElementInternal(this.renderer_.decorate(this,e)),"none"==e.style.display&&(this.visible_=!1)},goog.ui.Container.prototype.enterDocument=function(){goog.ui.Container.superClass_.enterDocument.call(this),this.forEachChild(function(e){e.isInDocument()&&this.registerChildId_(e)},this);var e=this.getElement();this.renderer_.initializeDom(this),this.setVisible(this.visible_,!0),this.getHandler().listen(this,goog.ui.Component.EventType.ENTER,this.handleEnterItem).listen(this,goog.ui.Component.EventType.HIGHLIGHT,this.handleHighlightItem).listen(this,goog.ui.Component.EventType.UNHIGHLIGHT,this.handleUnHighlightItem).listen(this,goog.ui.Component.EventType.OPEN,this.handleOpenItem).listen(this,goog.ui.Component.EventType.CLOSE,this.handleCloseItem).listen(e,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).listen(goog.dom.getOwnerDocument(e),goog.events.EventType.MOUSEUP,this.handleDocumentMouseUp).listen(e,[goog.events.EventType.MOUSEDOWN,goog.events.EventType.MOUSEUP,goog.events.EventType.MOUSEOVER,goog.events.EventType.MOUSEOUT,goog.events.EventType.CONTEXTMENU],this.handleChildMouseEvents),this.isFocusable()&&this.enableFocusHandling_(!0)},goog.ui.Container.prototype.enableFocusHandling_=function(e){var t=this.getHandler(),o=this.getKeyEventTarget();e?t.listen(o,goog.events.EventType.FOCUS,this.handleFocus).listen(o,goog.events.EventType.BLUR,this.handleBlur).listen(this.getKeyHandler(),goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent):t.unlisten(o,goog.events.EventType.FOCUS,this.handleFocus).unlisten(o,goog.events.EventType.BLUR,this.handleBlur).unlisten(this.getKeyHandler(),goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent)},goog.ui.Container.prototype.exitDocument=function(){this.setHighlightedIndex(-1),this.openItem_&&this.openItem_.setOpen(!1),this.mouseButtonPressed_=!1,goog.ui.Container.superClass_.exitDocument.call(this)},goog.ui.Container.prototype.disposeInternal=function(){goog.ui.Container.superClass_.disposeInternal.call(this),this.keyHandler_&&(this.keyHandler_.dispose(),this.keyHandler_=null),this.renderer_=this.openItem_=this.childElementIdMap_=this.keyEventTarget_=null},goog.ui.Container.prototype.handleEnterItem=function(e){return!0},goog.ui.Container.prototype.handleHighlightItem=function(e){var t=this.indexOfChild(e.target);if(-1<t&&t!=this.highlightedIndex_){var o=this.getHighlighted();o&&o.setHighlighted(!1),this.highlightedIndex_=t,o=this.getHighlighted(),this.isMouseButtonPressed()&&o.setActive(!0),this.openFollowsHighlight_&&this.openItem_&&o!=this.openItem_&&(o.isSupportedState(goog.ui.Component.State.OPENED)?o.setOpen(!0):this.openItem_.setOpen(!1))}t=this.getElement(),goog.asserts.assert(t,"The DOM element for the container cannot be null."),null!=e.target.getElement()&&goog.a11y.aria.setState(t,goog.a11y.aria.State.ACTIVEDESCENDANT,e.target.getElement().id)},goog.ui.Container.prototype.handleUnHighlightItem=function(e){e.target==this.getHighlighted()&&(this.highlightedIndex_=-1),e=this.getElement(),goog.asserts.assert(e,"The DOM element for the container cannot be null."),goog.a11y.aria.removeState(e,goog.a11y.aria.State.ACTIVEDESCENDANT)},goog.ui.Container.prototype.handleOpenItem=function(e){(e=e.target)&&e!=this.openItem_&&e.getParent()==this&&(this.openItem_&&this.openItem_.setOpen(!1),this.openItem_=e)},goog.ui.Container.prototype.handleCloseItem=function(e){e.target==this.openItem_&&(this.openItem_=null);var t=this.getElement(),o=e.target.getElement();t&&e.target.isHighlighted()&&o&&goog.a11y.aria.setActiveDescendant(t,o)},goog.ui.Container.prototype.handleMouseDown=function(e){this.enabled_&&this.setMouseButtonPressed(!0);var t=this.getKeyEventTarget();t&&goog.dom.isFocusableTabIndex(t)?t.focus():e.preventDefault()},goog.ui.Container.prototype.handleDocumentMouseUp=function(e){this.setMouseButtonPressed(!1)},goog.ui.Container.prototype.handleChildMouseEvents=function(e){var t=this.getOwnerControl(e.target);if(t)switch(e.type){case goog.events.EventType.MOUSEDOWN:t.handleMouseDown(e);break;case goog.events.EventType.MOUSEUP:t.handleMouseUp(e);break;case goog.events.EventType.MOUSEOVER:t.handleMouseOver(e);break;case goog.events.EventType.MOUSEOUT:t.handleMouseOut(e);break;case goog.events.EventType.CONTEXTMENU:t.handleContextMenu(e)}},goog.ui.Container.prototype.getOwnerControl=function(e){if(this.childElementIdMap_)for(var t=this.getElement();e&&e!==t;){var o=e.id;if(o in this.childElementIdMap_)return this.childElementIdMap_[o];e=e.parentNode}return null},goog.ui.Container.prototype.handleFocus=function(e){},goog.ui.Container.prototype.handleBlur=function(e){this.setHighlightedIndex(-1),this.setMouseButtonPressed(!1),this.openItem_&&this.openItem_.setOpen(!1)},goog.ui.Container.prototype.handleKeyEvent=function(e){return!(!this.isEnabled()||!this.isVisible()||0==this.getChildCount()&&!this.keyEventTarget_||!this.handleKeyEventInternal(e))&&(e.preventDefault(),e.stopPropagation(),!0)},goog.ui.Container.prototype.handleKeyEventInternal=function(e){var t=this.getHighlighted();if(t&&"function"==typeof t.handleKeyEvent&&t.handleKeyEvent(e)||this.openItem_&&this.openItem_!=t&&"function"==typeof this.openItem_.handleKeyEvent&&this.openItem_.handleKeyEvent(e))return!0;if(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)return!1;switch(e.keyCode){case goog.events.KeyCodes.ESC:if(!this.isFocusable())return!1;this.getKeyEventTarget().blur();break;case goog.events.KeyCodes.HOME:this.highlightFirst();break;case goog.events.KeyCodes.END:this.highlightLast();break;case goog.events.KeyCodes.UP:if(this.orientation_!=goog.ui.Container.Orientation.VERTICAL)return!1;this.highlightPrevious();break;case goog.events.KeyCodes.LEFT:if(this.orientation_!=goog.ui.Container.Orientation.HORIZONTAL)return!1;this.isRightToLeft()?this.highlightNext():this.highlightPrevious();break;case goog.events.KeyCodes.DOWN:if(this.orientation_!=goog.ui.Container.Orientation.VERTICAL)return!1;this.highlightNext();break;case goog.events.KeyCodes.RIGHT:if(this.orientation_!=goog.ui.Container.Orientation.HORIZONTAL)return!1;this.isRightToLeft()?this.highlightPrevious():this.highlightNext();break;default:return!1}return!0},goog.ui.Container.prototype.registerChildId_=function(e){var t=e.getElement();t=t.id||(t.id=e.getId()),this.childElementIdMap_||(this.childElementIdMap_={}),this.childElementIdMap_[t]=e},goog.ui.Container.prototype.addChild=function(e,t){goog.asserts.assertInstanceof(e,goog.ui.Control,"The child of a container must be a control"),goog.ui.Container.superClass_.addChild.call(this,e,t)},goog.ui.Container.prototype.addChildAt=function(e,t,o){goog.asserts.assertInstanceof(e,goog.ui.Control),e.setDispatchTransitionEvents(goog.ui.Component.State.HOVER,!0),e.setDispatchTransitionEvents(goog.ui.Component.State.OPENED,!0),!this.isFocusable()&&this.isFocusableChildrenAllowed()||e.setSupportedState(goog.ui.Component.State.FOCUSED,!1),e.setHandleMouseEvents(!1);var n=e.getParent()==this?this.indexOfChild(e):-1;goog.ui.Container.superClass_.addChildAt.call(this,e,t,o),e.isInDocument()&&this.isInDocument()&&this.registerChildId_(e),this.updateHighlightedIndex_(n,t)},goog.ui.Container.prototype.updateHighlightedIndex_=function(e,t){-1==e&&(e=this.getChildCount()),e==this.highlightedIndex_?this.highlightedIndex_=Math.min(this.getChildCount()-1,t):e>this.highlightedIndex_&&t<=this.highlightedIndex_?this.highlightedIndex_++:e<this.highlightedIndex_&&t>this.highlightedIndex_&&this.highlightedIndex_--},goog.ui.Container.prototype.removeChild=function(e,t){if(e=goog.isString(e)?this.getChild(e):e,goog.asserts.assertInstanceof(e,goog.ui.Control),e){var o=this.indexOfChild(e);-1!=o&&(o==this.highlightedIndex_?(e.setHighlighted(!1),this.highlightedIndex_=-1):o<this.highlightedIndex_&&this.highlightedIndex_--),(o=e.getElement())&&o.id&&this.childElementIdMap_&&goog.object.remove(this.childElementIdMap_,o.id)}return(e=goog.ui.Container.superClass_.removeChild.call(this,e,t)).setHandleMouseEvents(!0),e},goog.ui.Container.prototype.getOrientation=function(){return this.orientation_},goog.ui.Container.prototype.setOrientation=function(e){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.orientation_=e},goog.ui.Container.prototype.isVisible=function(){return this.visible_},goog.ui.Container.prototype.setVisible=function(e,t){if(t||this.visible_!=e&&this.dispatchEvent(e?goog.ui.Component.EventType.SHOW:goog.ui.Component.EventType.HIDE)){this.visible_=e;var o=this.getElement();return o&&(goog.style.setElementShown(o,e),this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),this.enabled_&&this.visible_),t||this.dispatchEvent(this.visible_?goog.ui.Container.EventType.AFTER_SHOW:goog.ui.Container.EventType.AFTER_HIDE)),!0}return!1},goog.ui.Container.prototype.isEnabled=function(){return this.enabled_},goog.ui.Container.prototype.setEnabled=function(e){this.enabled_!=e&&this.dispatchEvent(e?goog.ui.Component.EventType.ENABLE:goog.ui.Component.EventType.DISABLE)&&(e?(this.enabled_=!0,this.forEachChild(function(e){e.wasDisabled?delete e.wasDisabled:e.setEnabled(!0)})):(this.forEachChild(function(e){e.isEnabled()?e.setEnabled(!1):e.wasDisabled=!0}),this.enabled_=!1,this.setMouseButtonPressed(!1)),this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),e&&this.visible_))},goog.ui.Container.prototype.isFocusable=function(){return this.focusable_},goog.ui.Container.prototype.setFocusable=function(e){e!=this.focusable_&&this.isInDocument()&&this.enableFocusHandling_(e),this.focusable_=e,this.enabled_&&this.visible_&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),e)},goog.ui.Container.prototype.isFocusableChildrenAllowed=function(){return this.allowFocusableChildren_},goog.ui.Container.prototype.setFocusableChildrenAllowed=function(e){this.allowFocusableChildren_=e},goog.ui.Container.prototype.isOpenFollowsHighlight=function(){return this.openFollowsHighlight_},goog.ui.Container.prototype.setOpenFollowsHighlight=function(e){this.openFollowsHighlight_=e},goog.ui.Container.prototype.getHighlightedIndex=function(){return this.highlightedIndex_},goog.ui.Container.prototype.setHighlightedIndex=function(e){(e=this.getChildAt(e))?e.setHighlighted(!0):-1<this.highlightedIndex_&&this.getHighlighted().setHighlighted(!1)},goog.ui.Container.prototype.setHighlighted=function(e){this.setHighlightedIndex(this.indexOfChild(e))},goog.ui.Container.prototype.getHighlighted=function(){return this.getChildAt(this.highlightedIndex_)},goog.ui.Container.prototype.highlightFirst=function(){this.highlightHelper(function(e,t){return(e+1)%t},this.getChildCount()-1)},goog.ui.Container.prototype.highlightLast=function(){this.highlightHelper(function(e,t){return 0>--e?t-1:e},0)},goog.ui.Container.prototype.highlightNext=function(){this.highlightHelper(function(e,t){return(e+1)%t},this.highlightedIndex_)},goog.ui.Container.prototype.highlightPrevious=function(){this.highlightHelper(function(e,t){return 0>--e?t-1:e},this.highlightedIndex_)},goog.ui.Container.prototype.highlightHelper=function(e,t){t=0>t?this.indexOfChild(this.openItem_):t;var o=this.getChildCount();t=e.call(this,t,o);for(var n=0;n<=o;){var i=this.getChildAt(t);if(i&&this.canHighlightItem(i))return this.setHighlightedIndexFromKeyEvent(t),!0;n++,t=e.call(this,t,o)}return!1},goog.ui.Container.prototype.canHighlightItem=function(e){return e.isVisible()&&e.isEnabled()&&e.isSupportedState(goog.ui.Component.State.HOVER)},goog.ui.Container.prototype.setHighlightedIndexFromKeyEvent=function(e){this.setHighlightedIndex(e)},goog.ui.Container.prototype.getOpenItem=function(){return this.openItem_},goog.ui.Container.prototype.isMouseButtonPressed=function(){return this.mouseButtonPressed_},goog.ui.Container.prototype.setMouseButtonPressed=function(e){this.mouseButtonPressed_=e},goog.ui.MenuHeaderRenderer=function(){goog.ui.ControlRenderer.call(this)},goog.inherits(goog.ui.MenuHeaderRenderer,goog.ui.ControlRenderer),goog.addSingletonGetter(goog.ui.MenuHeaderRenderer),goog.ui.MenuHeaderRenderer.CSS_CLASS="goog-menuheader",goog.ui.MenuHeaderRenderer.prototype.getCssClass=function(){return goog.ui.MenuHeaderRenderer.CSS_CLASS},goog.ui.MenuHeader=function(e,t,o){goog.ui.Control.call(this,e,o||goog.ui.MenuHeaderRenderer.getInstance(),t),this.setSupportedState(goog.ui.Component.State.DISABLED,!1),this.setSupportedState(goog.ui.Component.State.HOVER,!1),this.setSupportedState(goog.ui.Component.State.ACTIVE,!1),this.setSupportedState(goog.ui.Component.State.FOCUSED,!1),this.setStateInternal(goog.ui.Component.State.DISABLED)},goog.inherits(goog.ui.MenuHeader,goog.ui.Control),goog.ui.registry.setDecoratorByClassName(goog.ui.MenuHeaderRenderer.CSS_CLASS,function(){return new goog.ui.MenuHeader(null)}),goog.ui.MenuItemRenderer=function(){goog.ui.ControlRenderer.call(this),this.classNameCache_=[]},goog.inherits(goog.ui.MenuItemRenderer,goog.ui.ControlRenderer),goog.addSingletonGetter(goog.ui.MenuItemRenderer),goog.ui.MenuItemRenderer.CSS_CLASS="goog-menuitem",goog.ui.MenuItemRenderer.CompositeCssClassIndex_={HOVER:0,CHECKBOX:1,CONTENT:2},goog.ui.MenuItemRenderer.prototype.getCompositeCssClass_=function(e){var t=this.classNameCache_[e];if(!t){switch(e){case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.HOVER:t=this.getStructuralCssClass()+"-highlight";break;case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX:t=this.getStructuralCssClass()+"-checkbox";break;case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT:t=this.getStructuralCssClass()+"-content"}this.classNameCache_[e]=t}return t},goog.ui.MenuItemRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.MENU_ITEM},goog.ui.MenuItemRenderer.prototype.createDom=function(e){var t=e.getDomHelper().createDom("DIV",this.getClassNames(e).join(" "),this.createContent(e.getContent(),e.getDomHelper()));return this.setEnableCheckBoxStructure(e,t,e.isSupportedState(goog.ui.Component.State.SELECTED)||e.isSupportedState(goog.ui.Component.State.CHECKED)),t},goog.ui.MenuItemRenderer.prototype.getContentElement=function(e){return e&&e.firstChild},goog.ui.MenuItemRenderer.prototype.decorate=function(e,t){return goog.asserts.assert(t),this.hasContentStructure(t)||t.appendChild(this.createContent(t.childNodes,e.getDomHelper())),goog.dom.classlist.contains(t,"goog-option")&&(e.setCheckable(!0),this.setCheckable(e,t,!0)),goog.ui.MenuItemRenderer.superClass_.decorate.call(this,e,t)},goog.ui.MenuItemRenderer.prototype.setContent=function(e,t){var o=this.getContentElement(e),n=this.hasCheckBoxStructure(e)?o.firstChild:null;goog.ui.MenuItemRenderer.superClass_.setContent.call(this,e,t),n&&!this.hasCheckBoxStructure(e)&&o.insertBefore(n,o.firstChild||null)},goog.ui.MenuItemRenderer.prototype.hasContentStructure=function(e){e=goog.dom.getFirstElementChild(e);var t=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT);return!!e&&goog.dom.classlist.contains(e,t)},goog.ui.MenuItemRenderer.prototype.createContent=function(e,t){var o=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT);return t.createDom("DIV",o,e)},goog.ui.MenuItemRenderer.prototype.setSelectable=function(e,t,o){e&&t&&this.setEnableCheckBoxStructure(e,t,o)},goog.ui.MenuItemRenderer.prototype.setCheckable=function(e,t,o){e&&t&&this.setEnableCheckBoxStructure(e,t,o)},goog.ui.MenuItemRenderer.prototype.hasCheckBoxStructure=function(e){if(e=this.getContentElement(e)){e=e.firstChild;var t=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX);return!!e&&goog.dom.isElement(e)&&goog.dom.classlist.contains(e,t)}return!1},goog.ui.MenuItemRenderer.prototype.setEnableCheckBoxStructure=function(e,t,o){this.setAriaRole(t,e.getPreferredAriaRole()),this.setAriaStates(e,t),o!=this.hasCheckBoxStructure(t)&&(goog.dom.classlist.enable(t,"goog-option",o),t=this.getContentElement(t),o?(o=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX),t.insertBefore(e.getDomHelper().createDom("DIV",o),t.firstChild||null)):t.removeChild(t.firstChild))},goog.ui.MenuItemRenderer.prototype.getClassForState=function(e){switch(e){case goog.ui.Component.State.HOVER:return this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.HOVER);case goog.ui.Component.State.CHECKED:case goog.ui.Component.State.SELECTED:return"goog-option-selected";default:return goog.ui.MenuItemRenderer.superClass_.getClassForState.call(this,e)}},goog.ui.MenuItemRenderer.prototype.getStateFromClass=function(e){var t=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.HOVER);switch(e){case"goog-option-selected":return goog.ui.Component.State.CHECKED;case t:return goog.ui.Component.State.HOVER;default:return goog.ui.MenuItemRenderer.superClass_.getStateFromClass.call(this,e)}},goog.ui.MenuItemRenderer.prototype.getCssClass=function(){return goog.ui.MenuItemRenderer.CSS_CLASS},goog.ui.MenuItem=function(e,t,o,n){goog.ui.Control.call(this,e,n||goog.ui.MenuItemRenderer.getInstance(),o),this.setValue(t)},goog.inherits(goog.ui.MenuItem,goog.ui.Control),goog.tagUnsealableClass(goog.ui.MenuItem),goog.ui.MenuItem.MNEMONIC_WRAPPER_CLASS_="goog-menuitem-mnemonic-separator",goog.ui.MenuItem.ACCELERATOR_CLASS="goog-menuitem-accel",goog.ui.MenuItem.prototype.getValue=function(){var e=this.getModel();return null!=e?e:this.getCaption()},goog.ui.MenuItem.prototype.setValue=function(e){this.setModel(e)},goog.ui.MenuItem.prototype.setSupportedState=function(e,t){switch(goog.ui.MenuItem.superClass_.setSupportedState.call(this,e,t),e){case goog.ui.Component.State.SELECTED:this.setSelectableInternal_(t);break;case goog.ui.Component.State.CHECKED:this.setCheckableInternal_(t)}},goog.ui.MenuItem.prototype.setSelectable=function(e){this.setSupportedState(goog.ui.Component.State.SELECTED,e)},goog.ui.MenuItem.prototype.setSelectableInternal_=function(e){this.isChecked()&&!e&&this.setChecked(!1);var t=this.getElement();t&&this.getRenderer().setSelectable(this,t,e)},goog.ui.MenuItem.prototype.setCheckable=function(e){this.setSupportedState(goog.ui.Component.State.CHECKED,e)},goog.ui.MenuItem.prototype.setCheckableInternal_=function(e){var t=this.getElement();t&&this.getRenderer().setCheckable(this,t,e)},goog.ui.MenuItem.prototype.getCaption=function(){var e=this.getContent();if(goog.isArray(e)){var t=goog.ui.MenuItem.ACCELERATOR_CLASS,o=goog.ui.MenuItem.MNEMONIC_WRAPPER_CLASS_;return e=goog.array.map(e,function(e){return goog.dom.isElement(e)&&(goog.dom.classlist.contains(e,t)||goog.dom.classlist.contains(e,o))?"":goog.dom.getRawTextContent(e)}).join(""),goog.string.collapseBreakingSpaces(e)}return goog.ui.MenuItem.superClass_.getCaption.call(this)},goog.ui.MenuItem.prototype.getAccelerator=function(){var e=this.getDomHelper(),t=this.getContent();return goog.isArray(t)&&(t=goog.array.find(t,function(e){return goog.dom.classlist.contains(e,goog.ui.MenuItem.ACCELERATOR_CLASS)}))?e.getTextContent(t):null},goog.ui.MenuItem.prototype.handleMouseUp=function(e){var t=this.getParent();if(t){var o=t.openingCoords;if(t.openingCoords=null,o&&goog.isNumber(e.clientX)&&(t=new goog.math.Coordinate(e.clientX,e.clientY),goog.math.Coordinate.equals(o,t)))return}goog.ui.MenuItem.superClass_.handleMouseUp.call(this,e)},goog.ui.MenuItem.prototype.handleKeyEventInternal=function(e){return!(e.keyCode!=this.getMnemonic()||!this.performActionInternal(e))||goog.ui.MenuItem.superClass_.handleKeyEventInternal.call(this,e)},goog.ui.MenuItem.prototype.setMnemonic=function(e){this.mnemonicKey_=e},goog.ui.MenuItem.prototype.getMnemonic=function(){return this.mnemonicKey_},goog.ui.registry.setDecoratorByClassName(goog.ui.MenuItemRenderer.CSS_CLASS,function(){return new goog.ui.MenuItem(null)}),goog.ui.MenuItem.prototype.getPreferredAriaRole=function(){return this.isSupportedState(goog.ui.Component.State.CHECKED)?goog.a11y.aria.Role.MENU_ITEM_CHECKBOX:this.isSupportedState(goog.ui.Component.State.SELECTED)?goog.a11y.aria.Role.MENU_ITEM_RADIO:goog.ui.MenuItem.superClass_.getPreferredAriaRole.call(this)},goog.ui.MenuItem.prototype.getParent=function(){return goog.ui.Control.prototype.getParent.call(this)},goog.ui.MenuItem.prototype.getParentEventTarget=function(){return goog.ui.Control.prototype.getParentEventTarget.call(this)},goog.ui.MenuSeparatorRenderer=function(){goog.ui.ControlRenderer.call(this)},goog.inherits(goog.ui.MenuSeparatorRenderer,goog.ui.ControlRenderer),goog.addSingletonGetter(goog.ui.MenuSeparatorRenderer),goog.ui.MenuSeparatorRenderer.CSS_CLASS="goog-menuseparator",goog.ui.MenuSeparatorRenderer.prototype.createDom=function(e){return e.getDomHelper().createDom("DIV",this.getCssClass())},goog.ui.MenuSeparatorRenderer.prototype.decorate=function(e,t){if(t.id&&e.setId(t.id),"HR"==t.tagName){var o=t;t=this.createDom(e),goog.dom.insertSiblingBefore(t,o),goog.dom.removeNode(o)}else goog.dom.classlist.add(t,this.getCssClass());return t},goog.ui.MenuSeparatorRenderer.prototype.setContent=function(e,t){},goog.ui.MenuSeparatorRenderer.prototype.getCssClass=function(){return goog.ui.MenuSeparatorRenderer.CSS_CLASS},goog.ui.Separator=function(e,t){goog.ui.Control.call(this,null,e||goog.ui.MenuSeparatorRenderer.getInstance(),t),this.setSupportedState(goog.ui.Component.State.DISABLED,!1),this.setSupportedState(goog.ui.Component.State.HOVER,!1),this.setSupportedState(goog.ui.Component.State.ACTIVE,!1),this.setSupportedState(goog.ui.Component.State.FOCUSED,!1),this.setStateInternal(goog.ui.Component.State.DISABLED)},goog.inherits(goog.ui.Separator,goog.ui.Control),goog.ui.Separator.prototype.enterDocument=function(){goog.ui.Separator.superClass_.enterDocument.call(this);var e=this.getElement();goog.asserts.assert(e,"The DOM element for the separator cannot be null."),goog.a11y.aria.setRole(e,"separator")},goog.ui.registry.setDecoratorByClassName(goog.ui.MenuSeparatorRenderer.CSS_CLASS,function(){return new goog.ui.Separator}),goog.ui.MenuRenderer=function(e){goog.ui.ContainerRenderer.call(this,e||goog.a11y.aria.Role.MENU)},goog.inherits(goog.ui.MenuRenderer,goog.ui.ContainerRenderer),goog.addSingletonGetter(goog.ui.MenuRenderer),goog.ui.MenuRenderer.CSS_CLASS="goog-menu",goog.ui.MenuRenderer.prototype.canDecorate=function(e){return"UL"==e.tagName||goog.ui.MenuRenderer.superClass_.canDecorate.call(this,e)},goog.ui.MenuRenderer.prototype.getDecoratorForChild=function(e){return"HR"==e.tagName?new goog.ui.Separator:goog.ui.MenuRenderer.superClass_.getDecoratorForChild.call(this,e)},goog.ui.MenuRenderer.prototype.containsElement=function(e,t){return goog.dom.contains(e.getElement(),t)},goog.ui.MenuRenderer.prototype.getCssClass=function(){return goog.ui.MenuRenderer.CSS_CLASS},goog.ui.MenuRenderer.prototype.initializeDom=function(e){goog.ui.MenuRenderer.superClass_.initializeDom.call(this,e),e=e.getElement(),goog.asserts.assert(e,"The menu DOM element cannot be null."),goog.a11y.aria.setState(e,goog.a11y.aria.State.HASPOPUP,"true")},goog.ui.MenuSeparator=function(e){goog.ui.Separator.call(this,goog.ui.MenuSeparatorRenderer.getInstance(),e)},goog.inherits(goog.ui.MenuSeparator,goog.ui.Separator),goog.ui.registry.setDecoratorByClassName(goog.ui.MenuSeparatorRenderer.CSS_CLASS,function(){return new goog.ui.Separator}),goog.ui.Menu=function(e,t){goog.ui.Container.call(this,goog.ui.Container.Orientation.VERTICAL,t||goog.ui.MenuRenderer.getInstance(),e),this.setFocusable(!1)},goog.inherits(goog.ui.Menu,goog.ui.Container),goog.tagUnsealableClass(goog.ui.Menu),goog.ui.Menu.EventType={BEFORE_SHOW:goog.ui.Component.EventType.BEFORE_SHOW,SHOW:goog.ui.Component.EventType.SHOW,BEFORE_HIDE:goog.ui.Component.EventType.HIDE,HIDE:goog.ui.Component.EventType.HIDE},goog.ui.Menu.CSS_CLASS=goog.ui.MenuRenderer.CSS_CLASS,goog.ui.Menu.prototype.allowAutoFocus_=!0,goog.ui.Menu.prototype.allowHighlightDisabled_=!1,goog.ui.Menu.prototype.getCssClass=function(){return this.getRenderer().getCssClass()},goog.ui.Menu.prototype.containsElement=function(e){if(this.getRenderer().containsElement(this,e))return!0;for(var t=0,o=this.getChildCount();t<o;t++){var n=this.getChildAt(t);if("function"==typeof n.containsElement&&n.containsElement(e))return!0}return!1},goog.ui.Menu.prototype.addItem=function(e){this.addChild(e,!0)},goog.ui.Menu.prototype.addItemAt=function(e,t){this.addChildAt(e,t,!0)},goog.ui.Menu.prototype.removeItem=function(e){(e=this.removeChild(e,!0))&&e.dispose()},goog.ui.Menu.prototype.removeItemAt=function(e){(e=this.removeChildAt(e,!0))&&e.dispose()},goog.ui.Menu.prototype.getItemAt=function(e){return this.getChildAt(e)},goog.ui.Menu.prototype.getItemCount=function(){return this.getChildCount()},goog.ui.Menu.prototype.getItems=function(){var e=[];return this.forEachChild(function(t){e.push(t)}),e},goog.ui.Menu.prototype.setPosition=function(e,t){var o=this.isVisible();o||goog.style.setElementShown(this.getElement(),!0),goog.style.setPageOffset(this.getElement(),e,t),o||goog.style.setElementShown(this.getElement(),!1)},goog.ui.Menu.prototype.getPosition=function(){return this.isVisible()?goog.style.getPageOffset(this.getElement()):null},goog.ui.Menu.prototype.setAllowAutoFocus=function(e){(this.allowAutoFocus_=e)&&this.setFocusable(!0)},goog.ui.Menu.prototype.getAllowAutoFocus=function(){return this.allowAutoFocus_},goog.ui.Menu.prototype.setAllowHighlightDisabled=function(e){this.allowHighlightDisabled_=e},goog.ui.Menu.prototype.getAllowHighlightDisabled=function(){return this.allowHighlightDisabled_},goog.ui.Menu.prototype.setVisible=function(e,t,o){return(t=goog.ui.Menu.superClass_.setVisible.call(this,e,t))&&e&&this.isInDocument()&&this.allowAutoFocus_&&this.getKeyEventTarget().focus(),e&&o&&goog.isNumber(o.clientX)?this.openingCoords=new goog.math.Coordinate(o.clientX,o.clientY):this.openingCoords=null,t},goog.ui.Menu.prototype.handleEnterItem=function(e){return this.allowAutoFocus_&&this.getKeyEventTarget().focus(),goog.ui.Menu.superClass_.handleEnterItem.call(this,e)},goog.ui.Menu.prototype.highlightNextPrefix=function(e){var t=new RegExp("^"+goog.string.regExpEscape(e),"i");return this.highlightHelper(function(e,o){var n=0>e?0:e,i=!1;do{++e==o&&(e=0,i=!0);var r=this.getChildAt(e).getCaption();if(r&&r.match(t))return e}while(!i||e!=n);return this.getHighlightedIndex()},this.getHighlightedIndex())},goog.ui.Menu.prototype.canHighlightItem=function(e){return(this.allowHighlightDisabled_||e.isEnabled())&&e.isVisible()&&e.isSupportedState(goog.ui.Component.State.HOVER)},goog.ui.Menu.prototype.decorateInternal=function(e){this.decorateContent(e),goog.ui.Menu.superClass_.decorateInternal.call(this,e)},goog.ui.Menu.prototype.handleKeyEventInternal=function(e){var t=goog.ui.Menu.superClass_.handleKeyEventInternal.call(this,e);return t||this.forEachChild(function(o){!t&&o.getMnemonic&&o.getMnemonic()==e.keyCode&&(this.isEnabled()&&this.setHighlighted(o),t=o.handleKeyEvent(e))},this),t},goog.ui.Menu.prototype.setHighlightedIndex=function(e){goog.ui.Menu.superClass_.setHighlightedIndex.call(this,e),(e=this.getChildAt(e))&&goog.style.scrollIntoContainerView(e.getElement(),this.getElement())},goog.ui.Menu.prototype.decorateContent=function(e){for(var t=this.getRenderer(),o=(e=this.getDomHelper().getElementsByTagNameAndClass("DIV",t.getCssClass()+"-content",e)).length,n=0;n<o;n++)t.decorateChildren(this,e[n])},Blockly.ContextMenu={},Blockly.ContextMenu.currentBlock=null,Blockly.ContextMenu.show=function(e,t){if(Blockly.WidgetDiv.show(Blockly.ContextMenu,null),t.length){for(var o=new goog.ui.Menu,n=0;n<t.length;n++){var i=t[n],r=new goog.ui.MenuItem(i.text);o.addItem(r),r.setEnabled(i.enabled),i.enabled&&goog.events.listen(r,goog.ui.Component.EventType.ACTION,i.callback)}goog.events.listen(o,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide),t=goog.dom.getViewportSize(),n=goog.style.getViewportPageOffset(document),o.render(Blockly.WidgetDiv.DIV),o.setAllowAutoFocus(!0),o=o.getElement(),Blockly.addClass_(o,"blocklyContextMenu"),o=goog.style.getSize(o),i=e.clientX+n.x,r=e.clientY+n.y,e.clientY+o.height>=t.height&&(r-=o.height),Blockly.RTL?o.width>=e.clientX&&(i+=o.width):e.clientX+o.width>=t.width&&(i-=o.width),Blockly.WidgetDiv.position(i,r,t,n),Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()},Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu),Blockly.ContextMenu.currentBlock=null},Blockly.ContextMenu.optionToDom_=function(e){var t=Blockly.createSvgElement("g",{class:"blocklyMenuDiv"},null);Blockly.createSvgElement("rect",{height:Blockly.ContextMenu.Y_HEIGHT},t);var o=Blockly.createSvgElement("text",{class:"blocklyMenuText",x:Blockly.ContextMenu.X_PADDING,y:15},t);return e=document.createTextNode(e),o.appendChild(e),t},Blockly.ContextMenu.callbackFactory=function(e,t){return function(){var o=Blockly.Xml.domToBlock(e.blockSpace,t),n=e.getRelativeToSurfaceXY();n.x=Blockly.RTL?n.x-Blockly.SNAP_RADIUS:n.x+Blockly.SNAP_RADIUS,n.y+=2*Blockly.SNAP_RADIUS,o.moveBy(n.x,n.y),o.select()}},Blockly.Field=function(e){this.sourceBlock_=null,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:-12,height:16},this.fieldGroup_),this.textElement_=Blockly.createSvgElement("text",{class:"blocklyText"},this.fieldGroup_),this.size_={height:25,width:0},this.setText(e),this.visible_=!0},Blockly.Field.prototype.getFieldHelperOptions_=function(e){return this.sourceBlock_&&this.sourceBlock_.outputConnection&&this.sourceBlock_.outputConnection.targetConnection&&this.sourceBlock_.outputConnection.targetConnection.getFieldHelperOptions(e)},Blockly.Field.prototype.getParentEditor_=function(){return this.sourceBlock_.blockSpace.blockSpaceEditor},Blockly.Field.prototype.getRootSVGElement_=function(){return this.getParentEditor_().svg_},Blockly.Field.NBSP=" ",Blockly.Field.prototype.EDITABLE=!0,Blockly.Field.prototype.init=function(e){if(this.sourceBlock_)throw"Field has already been initialized once.";this.sourceBlock_=e,this.updateEditable(),e.getSvgRoot().appendChild(this.fieldGroup_),this.mouseDownWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mousedown",this,this.onMouseDown_),this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.clickWrapper_=Blockly.bindEvent_(this.fieldGroup_,"click",this,this.onClick_),this.setText(null)},Blockly.Field.prototype.dispose=function(){this.mouseDownWrapper_&&(Blockly.unbindEvent_(this.mouseDownWrapper_),this.mouseDownWrapper_=null),this.mouseUpWrapper_&&(Blockly.unbindEvent_(this.mouseUpWrapper_),this.mouseUpWrapper_=null),this.clickWrapper_&&(Blockly.unbindEvent_(this.clickWrapper_),this.clickWrapper_=null),this.sourceBlock_=null,goog.dom.removeNode(this.fieldGroup_),this.borderRect_=this.textElement_=this.fieldGroup_=null},Blockly.Field.prototype.updateEditable=function(){this.EDITABLE&&(this.sourceBlock_.isEditable()?(Blockly.addClass_(this.fieldGroup_,"blocklyEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyNoNEditableText"),this.fieldGroup_.style.cursor=this.CURSOR):(Blockly.addClass_(this.fieldGroup_,"blocklyNonEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyEditableText"),this.fieldGroup_.style.cursor=""))},Blockly.Field.prototype.isVisible=function(){return this.visible_},Blockly.Field.prototype.setVisible=function(e){this.visible_=e,this.getRootElement().style.display=e?"block":"none"},Blockly.Field.prototype.getRootElement=function(){return this.fieldGroup_},Blockly.Field.prototype.updateWidth_=function(){var e=this.textElement_.getComputedTextLength&&document.body.contains(this.textElement_)?this.textElement_.getComputedTextLength():1;this.borderRect_&&this.borderRect_.setAttribute("width",e+Blockly.BlockSvg.SEP_SPACE_X),this.size_.width=e},Blockly.Field.prototype.getSize=function(){return this.size_.width||this.updateWidth_(),this.size_},Blockly.Field.prototype.getBufferY=function(){return 0},Blockly.Field.prototype.getText=function(){return this.text_},Blockly.Field.prototype.setText=function(e){null!==e&&e!==this.text_&&(this.text_=e,goog.dom.removeChildren(this.textElement_),(e=e.replace(/\s/g,Blockly.Field.NBSP))||(e=Blockly.Field.NBSP),e=document.createTextNode(e),this.textElement_.appendChild(e),this.size_.width=0,this.refreshRender())},Blockly.Field.prototype.refreshRender=function(){this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours(),this.sourceBlock_.blockSpace.fireChangeEvent())},Blockly.Field.prototype.getValue=function(){return this.getText()},Blockly.Field.prototype.setValue=function(e){this.setText(e)},Blockly.Field.prototype.isKeyboardInputField_=function(){return!1},Blockly.Field.prototype.showEditorOnClick_=function(){return!(!this.isKeyboardInputField_()||!goog.userAgent.ANDROID&&!goog.userAgent.MOBILE)},Blockly.Field.prototype.onMouseDown_=function(e){this.showEditorOnClick_()&&e.stopPropagation()},Blockly.Field.prototype.onMouseUp_=function(e){this.showEditorOnClick_()||Blockly.isRightButton(e)||Blockly.Block.isFreelyDragging()||this.sourceBlock_.isEditable()&&this.showEditor_()},Blockly.Field.prototype.onClick_=function(e){this.showEditorOnClick_()&&(Blockly.isRightButton(e)||this.sourceBlock_.isEditable()&&this.showEditor_())},Blockly.Field.prototype.setTooltip=function(){},Blockly.Field.prototype.positionWidgetDiv=function(){},Blockly.Field.prototype.handleBlockSpaceScrolled=function(){this.sourceBlock_&&this.positionWidgetDiv()},Blockly.Field.prototype.showWidgetDiv_=function(){if(Blockly.WidgetDiv.show(this,this.generateWidgetDisposeHandler_()),this.sourceBlock_&&this.sourceBlock_.blockSpace&&this.sourceBlock_.blockSpace.events){var e=this.sourceBlock_.blockSpace.events;this.blockSpaceScrolledListenKey_||(this.blockSpaceScrolledListenKey_=e.listen(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_SCROLLED,this.handleBlockSpaceScrolled.bind(this)))}},Blockly.Field.prototype.generateWidgetDisposeHandler_=function(){return function(){this.blockSpaceScrolledListenKey_&&this.sourceBlock_&&this.sourceBlock_.blockSpace&&this.sourceBlock_.blockSpace.events&&(this.sourceBlock_.blockSpace.events.unlistenByKey(this.blockSpaceScrolledListenKey_),this.blockSpaceScrolledListenKey_=null)}.bind(this)},Blockly.Tooltip={},Blockly.Tooltip.visible=!1,Blockly.Tooltip.mouseOutPid_=0,Blockly.Tooltip.showPid_=0,Blockly.Tooltip.lastXY_={x:0,y:0},Blockly.Tooltip.element_=null,Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.svgGroup_=null,Blockly.Tooltip.svgText_=null,Blockly.Tooltip.svgBackground_=null,Blockly.Tooltip.svgShadow_=null,Blockly.Tooltip.OFFSET_X=0,Blockly.Tooltip.OFFSET_Y=10,Blockly.Tooltip.RADIUS_OK=10,Blockly.Tooltip.HOVER_MS=1e3,Blockly.Tooltip.MARGINS=5,Blockly.Tooltip.createDom=function(){var e=Blockly.createSvgElement("g",{class:"blocklyHidden"},null);return Blockly.Tooltip.svgGroup_=e,Blockly.Tooltip.svgShadow_=Blockly.createSvgElement("rect",{class:"blocklyTooltipShadow",x:2,y:2},e),Blockly.Tooltip.svgBackground_=Blockly.createSvgElement("rect",{class:"blocklyTooltipBackground"},e),Blockly.Tooltip.svgText_=Blockly.createSvgElement("text",{class:"blocklyTooltipText"},e),e},Blockly.Tooltip.bindMouseEvents=function(e){Blockly.bindEvent_(e,"mouseover",null,Blockly.Tooltip.onMouseOver_),Blockly.bindEvent_(e,"mouseout",null,Blockly.Tooltip.onMouseOut_),Blockly.bindEvent_(e,"mousemove",null,Blockly.Tooltip.onMouseMove_)},Blockly.Tooltip.onMouseOver_=function(e){for(e=e.target;!goog.isString(e.tooltip)&&!goog.isFunction(e.tooltip);)e=e.tooltip;Blockly.Tooltip.element_!=e&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=e),window.clearTimeout(Blockly.Tooltip.mouseOutPid_)},Blockly.Tooltip.onMouseOut_=function(){Blockly.Tooltip.mouseOutPid_=window.setTimeout(function(){Blockly.Tooltip.element_=null,Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.hide()},1),window.clearTimeout(Blockly.Tooltip.showPid_)},Blockly.Tooltip.onMouseMove_=function(e){Blockly.Tooltip.element_&&Blockly.Tooltip.element_.tooltip&&!Blockly.Block.isDragging()&&!Blockly.WidgetDiv.isVisible()&&(Blockly.Tooltip.visible?(e=Blockly.mouseToSvg(e),Math.sqrt(Math.pow(Blockly.Tooltip.lastXY_.x-e.x,2)+Math.pow(Blockly.Tooltip.lastXY_.y-e.y,2))>Blockly.Tooltip.RADIUS_OK&&Blockly.Tooltip.hide()):Blockly.Tooltip.poisonedElement_!=Blockly.Tooltip.element_&&(window.clearTimeout(Blockly.Tooltip.showPid_),Blockly.Tooltip.lastXY_=Blockly.mouseToSvg(e),Blockly.Tooltip.showPid_=window.setTimeout(Blockly.Tooltip.show_,Blockly.Tooltip.HOVER_MS)))},Blockly.Tooltip.hide=function(){Blockly.Tooltip.visible&&(Blockly.Tooltip.visible=!1,Blockly.Tooltip.svgGroup_&&(Blockly.Tooltip.svgGroup_.style.display="none")),window.clearTimeout(Blockly.Tooltip.showPid_)},Blockly.Tooltip.show_=function(){if(Blockly.Tooltip.poisonedElement_=Blockly.Tooltip.element_,Blockly.Tooltip.svgGroup_){goog.dom.removeChildren(Blockly.Tooltip.svgText_);var e=Blockly.Tooltip.element_.tooltip;goog.isFunction(e)&&(e=e()),e=e.split("\n");for(var t=0;t<e.length;t++){var o=Blockly.createSvgElement("tspan",{dy:"1em",x:Blockly.Tooltip.MARGINS},Blockly.Tooltip.svgText_),n=document.createTextNode(e[t]);o.appendChild(n)}if(Blockly.Tooltip.visible=!0,Blockly.Tooltip.svgGroup_.style.display="block",0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")?(Blockly.Tooltip.svgText_.style.display="inline",e={x:Blockly.Tooltip.svgText_.getBBox().x,y:Blockly.Tooltip.svgText_.getBBox().y,width:Blockly.Tooltip.svgText_.scrollWidth,height:Blockly.Tooltip.svgText_.scrollHeight}):e=Blockly.Tooltip.svgText_.getBBox(),t=2*Blockly.Tooltip.MARGINS+e.width,o=e.height,Blockly.Tooltip.svgBackground_.setAttribute("width",t),Blockly.Tooltip.svgBackground_.setAttribute("height",o),Blockly.Tooltip.svgShadow_.setAttribute("width",t),Blockly.Tooltip.svgShadow_.setAttribute("height",o),Blockly.RTL){o=e.width,n=0;for(var i;i=Blockly.Tooltip.svgText_.childNodes[n];n++)i.setAttribute("text-anchor","end"),i.setAttribute("x",o+Blockly.Tooltip.MARGINS)}o=Blockly.Tooltip.lastXY_.x,o=Blockly.RTL?o-(Blockly.Tooltip.OFFSET_X+t):o+Blockly.Tooltip.OFFSET_X,t=Blockly.Tooltip.lastXY_.y+Blockly.Tooltip.OFFSET_Y,n=Blockly.mainBlockSpaceEditor.svgSize(),t+e.height>n.height&&(t-=e.height+2*Blockly.Tooltip.OFFSET_Y),Blockly.RTL?o=Math.max(Blockly.Tooltip.MARGINS,o):o+e.width>n.width-2*Blockly.Tooltip.MARGINS&&(o=n.width-e.width-2*Blockly.Tooltip.MARGINS),Blockly.Tooltip.svgGroup_.setAttribute("transform","translate("+o+","+t+")")}},Blockly.FieldLabel=function(e,t){t=t||{},this.sourceBlock_=null,this.textElement_=Blockly.createSvgElement("text",{class:"blocklyText"},null);this.forceWidth_=(this.forceSize_=Object.prototype.hasOwnProperty.call(t,"fixedSize"))&&void 0!==t.fixedSize.width,this.fontSize_=t.fontSize,this.size_=this.forceSize_?t.fixedSize:{width:0,height:25},this.setText(e),this.fieldGroup_=this.textElement_},goog.inherits(Blockly.FieldLabel,Blockly.Field),Blockly.FieldLabel.prototype.EDITABLE=!1,Blockly.FieldLabel.prototype.init=function(e){if(this.sourceBlock_)throw"Text has already been initialized once.";this.sourceBlock_=e,e.getSvgRoot().appendChild(this.textElement_),this.textElement_.tooltip=this.sourceBlock_,this.sourceBlock_.blockSpace.blockSpaceEditor.disableTooltip||Blockly.Tooltip&&Blockly.Tooltip.bindMouseEvents(this.textElement_)},Blockly.FieldLabel.prototype.getSize=function(){return this.size_.width||this.forceWidth_||this.updateWidth_(),this.size_},Blockly.FieldLabel.prototype.getBufferY=function(){return this.fontSize_?(this.size_.height-this.fontSize_)/2:0},Blockly.FieldLabel.prototype.setText=function(e){null!==e&&e!==this.text_&&(this.text_=e,goog.dom.removeChildren(this.textElement_),(e=e.replace(/\s/g,Blockly.Field.NBSP))||(e=Blockly.Field.NBSP),e=document.createTextNode(e),this.textElement_.appendChild(e),this.fontSize_&&(this.textElement_.style.fontSize=this.fontSize_+"px"),this.forceWidth_||(this.size_.width=0),this.refreshRender())},Blockly.FieldLabel.prototype.dispose=function(){goog.dom.removeNode(this.textElement_),this.textElement_=null},Blockly.FieldLabel.prototype.getRootElement=function(){return this.textElement_},Blockly.FieldLabel.prototype.setTooltip=function(e){this.textElement_.tooltip=e},Blockly.Input=function(e,t,o,n,i){this.type=e,this.name=t,this.sourceBlock_=o,this.connection=n,this.titleRow=[],this.align=Blockly.ALIGN_LEFT,this.inline_=!1,this.visible_=!0,this.colour_={hue:null,saturation:null,value:null},this.statementTrailingSpace_=i||0},Blockly.Input.prototype.appendTitle=function(e,t){return e||t?(goog.isString(e)&&(e=new Blockly.FieldLabel(e)),this.sourceBlock_.svg_&&e.init(this.sourceBlock_),e.name=t,e.prefixTitle&&this.appendTitle(e.prefixTitle),this.titleRow.push(e),e.suffixTitle&&this.appendTitle(e.suffixTitle),this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours()),this):this},Blockly.Input.prototype.isVisible=function(){return this.visible_},Blockly.Input.prototype.setVisible=function(e){var t=[];if(this.visible_==e)return t;for(var o,n=(this.visible_=e)?"block":"none",i=0;o=this.titleRow[i];i++)o.setVisible(e);return this.connection&&(t=e?this.connection.unhideAll():this.connection.hideAll(),i=this.connection.targetBlock())&&(i.svg_.getRootElement().style.display=n,e||(i.rendered=!1)),t},Blockly.Input.prototype.setStrictCheck=function(e){if(!this.connection)throw"This input does not have a connection.";return this.connection.setStrictCheck(e),this},Blockly.Input.prototype.setCheck=function(e){if(!this.connection)throw"This input does not have a connection.";return this.connection.setCheck(e),this},Blockly.Input.prototype.addFieldHelper=function(e,t){if(this.type!==Blockly.INPUT_VALUE)throw"Only Value Inputs can be augmented with helpers";return this.connection.addFieldHelper(e,t),this},Blockly.Input.prototype.setAlign=function(e){return this.align=e,this.sourceBlock_.rendered&&this.sourceBlock_.render(),this},Blockly.Input.prototype.init=function(){for(var e=0;e<this.titleRow.length;e++)this.titleRow[e].init(this.sourceBlock_)},Blockly.Input.prototype.dispose=function(){for(var e,t=0;e=this.titleRow[t];t++)e.dispose();this.connection&&this.connection.dispose(),this.sourceBlock_=null},Blockly.Input.prototype.setInline=function(e){if(void 0===e&&(e=!0),this.inline_=e,this.type===Blockly.NEXT_STATEMENT&&e)throw"Can't inline next statement";return this},Blockly.Input.prototype.isInline=function(){return this.type!==Blockly.NEXT_STATEMENT&&(this.inline_||this.sourceBlock_.inputsInline)},Blockly.Input.prototype.setHSV=function(e,t,o){if(this.type!==Blockly.FUNCTIONAL_INPUT)throw"setColor only for functional inputs";return this.colour_={hue:e,saturation:t,value:o},this},Blockly.Input.prototype.getHexColour=function(){return Blockly.makeColour(this.colour_.hue,this.colour_.saturation,this.colour_.value)},Blockly.Input.prototype.getStatementTrailingSpace=function(){return this.statementTrailingSpace_},Blockly.Input.prototype.matchesBlock=function(e){return e.getColour()===this.colour_.hue&&e.getSaturation()===this.colour_.saturation&&e.getValue()===this.colour_.value},Blockly.Msg={},Blockly.Bubble=function(e,t,o,n,i,r,l,s){var a=Blockly.Bubble.ARROW_ANGLE;if(Blockly.RTL&&(a=-a),this.arrow_radians_=a/360*Math.PI*2,this.blockSpace_=e,this.content_=t,this.shape_=o,this.dragCanvas_=s,e.getBubbleCanvas().appendChild(this.createDom_(t,!(!r||!l))),this.setAnchorLocation(n,i),!r||!l){try{var g=t.getBBox()}catch(e){g=this.blockSpace_.getCanvas().getBBox()}r=g.width+2*Blockly.Bubble.BORDER_WIDTH,l=g.height+2*Blockly.Bubble.BORDER_WIDTH}this.setBubbleSize(r,l),this.positionBubble_(),this.renderArrow_(),this.rendered_=!0,e.isReadOnly()||(Blockly.bindEvent_(this.bubbleBack_,"mousedown",this,this.bubbleMouseDown_),this.resizeGroup_&&Blockly.bindEvent_(this.resizeGroup_,"mousedown",this,this.resizeMouseDown_))},Blockly.Bubble.BORDER_WIDTH=6,Blockly.Bubble.ARROW_THICKNESS=10,Blockly.Bubble.ARROW_ANGLE=20,Blockly.Bubble.ARROW_BEND=4,Blockly.Bubble.ANCHOR_RADIUS=8,Blockly.Bubble.onMouseUpWrapper_=null,Blockly.Bubble.onMouseMoveWrapper_=null,Blockly.Bubble.unbindDragEvents_=function(){Blockly.Bubble.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseUpWrapper_),Blockly.Bubble.onMouseUpWrapper_=null),Blockly.Bubble.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseMoveWrapper_),Blockly.Bubble.onMouseMoveWrapper_=null)},Blockly.Bubble.prototype.rendered_=!1,Blockly.Bubble.prototype.anchorX_=0,Blockly.Bubble.prototype.anchorY_=0,Blockly.Bubble.prototype.relativeLeft_=0,Blockly.Bubble.prototype.relativeTop_=0,Blockly.Bubble.prototype.width_=0,Blockly.Bubble.prototype.height_=0,Blockly.Bubble.prototype.autoLayout_=!0,Blockly.Bubble.prototype.createDom_=function(e,t){this.bubbleGroup_=Blockly.createSvgElement("g",{},null);var o=Blockly.createSvgElement("g",{filter:"url(#blocklyEmboss)"},this.bubbleGroup_);return this.bubbleArrow_=Blockly.createSvgElement("path",{},o),this.bubbleBack_=Blockly.createSvgElement("rect",{class:"blocklyDraggable",x:0,y:0,rx:Blockly.Bubble.BORDER_WIDTH,ry:Blockly.Bubble.BORDER_WIDTH},o),t?(this.resizeGroup_=Blockly.createSvgElement("g",{class:Blockly.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup_),t=2*Blockly.Bubble.BORDER_WIDTH,Blockly.createSvgElement("polygon",{points:"0,x x,x x,0".replace(/x/g,t.toString())},this.resizeGroup_),Blockly.createSvgElement("line",{class:"blocklyResizeLine",x1:t/3,y1:t-1,x2:t-1,y2:t/3},this.resizeGroup_),Blockly.createSvgElement("line",{class:"blocklyResizeLine",x1:2*t/3,y1:t-1,x2:t-1,y2:2*t/3},this.resizeGroup_)):this.resizeGroup_=null,this.bubbleGroup_.appendChild(e),this.bubbleGroup_},Blockly.Bubble.prototype.bubbleMouseDown_=function(e){this.promote_(),Blockly.Bubble.unbindDragEvents_(),Blockly.isRightButton(e)||Blockly.isTargetInput(e)||(this.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),this.dragDeltaX=Blockly.RTL?this.relativeLeft_+e.clientX:this.relativeLeft_-e.clientX,this.dragDeltaY=this.relativeTop_-e.clientY,Blockly.Bubble.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.Bubble.unbindDragEvents_),Blockly.Bubble.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.bubbleMouseMove_),this.blockSpace_.blockSpaceEditor.hideChaff(),e.stopPropagation())},Blockly.Bubble.prototype.bubbleMouseMove_=function(e){this.autoLayout_=!1,this.relativeLeft_=Blockly.RTL?this.dragDeltaX-e.clientX:this.dragDeltaX+e.clientX,this.relativeTop_=this.dragDeltaY+e.clientY,this.positionBubble_(),this.renderArrow_()},Blockly.Bubble.prototype.resizeMouseDown_=function(e){this.promote_(),Blockly.Bubble.unbindDragEvents_(),Blockly.isRightButton(e)||(this.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),this.resizeDeltaWidth=Blockly.RTL?this.width_+e.clientX:this.width_-e.clientX,this.resizeDeltaHeight=this.height_-e.clientY,Blockly.Bubble.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.Bubble.unbindDragEvents_),Blockly.Bubble.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.resizeMouseMove_),this.blockSpace_.blockSpaceEditor.hideChaff(),e.stopPropagation())},Blockly.Bubble.prototype.resizeMouseMove_=function(e){this.autoLayout_=!1;var t=this.resizeDeltaWidth,o=this.resizeDeltaHeight+e.clientY;t=Blockly.RTL?t-e.clientX:t+e.clientX,this.setBubbleSize(t,o),Blockly.RTL&&this.positionBubble_()},Blockly.Bubble.prototype.registerResizeEvent=function(e,t){Blockly.bindEvent_(this.bubbleGroup_,"resize",e,t)},Blockly.Bubble.prototype.promote_=function(){this.bubbleGroup_.parentNode.appendChild(this.bubbleGroup_)},Blockly.Bubble.prototype.setAnchorLocation=function(e,t){this.anchorX_=e,this.anchorY_=t,this.rendered_&&this.positionBubble_()},Blockly.Bubble.prototype.layoutBubble_=function(){var e=-this.width_/4,t=-this.height_-Blockly.BlockSvg.MIN_BLOCK_Y;if(this.blockSpace_.scrollbarPair){var o=this.blockSpace_.getMetrics();this.anchorX_+e<Blockly.BlockSvg.SEP_SPACE_X+o.viewLeft?e=Blockly.BlockSvg.SEP_SPACE_X+o.viewLeft-this.anchorX_:o.viewLeft+o.viewWidth<this.anchorX_+e+this.width_+Blockly.BlockSvg.SEP_SPACE_X+Blockly.Scrollbar.scrollbarThickness&&(e=o.viewLeft+o.viewWidth-this.anchorX_-this.width_-Blockly.BlockSvg.SEP_SPACE_X-Blockly.Scrollbar.scrollbarThickness),this.anchorY_+t<Blockly.BlockSvg.SEP_SPACE_Y+o.viewTop&&(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")?(this.shape_.style.display="inline",t={x:this.shape_.getBBox().x,y:this.shape_.getBBox().y,width:this.shape_.scrollWidth,height:this.shape_.scrollHeight}):t=this.shape_.getBBox(),t=t.height)}this.relativeLeft_=e,this.relativeTop_=t},Blockly.Bubble.prototype.positionBubble_=function(){this.bubbleGroup_.setAttribute("transform","translate("+(Blockly.RTL?this.anchorX_-this.relativeLeft_-this.width_:this.anchorX_+this.relativeLeft_)+", "+(this.relativeTop_+this.anchorY_)+")");var e=Blockly.convertCoordinates(Blockly.RTL?this.blockSpaceWidth_:0,0,this.content_,!1);this.dragCanvas_.setAttribute("transform","translate("+e.x+","+e.y+")")},Blockly.Bubble.prototype.getBubbleSize=function(){return{width:this.width_,height:this.height_}},Blockly.Bubble.prototype.setBubbleSize=function(e,t){var o=2*Blockly.Bubble.BORDER_WIDTH;e=Math.max(e,o+45),t=Math.max(t,o+Blockly.BlockSvg.TITLE_HEIGHT),this.width_=e,this.height_=t,this.bubbleBack_.setAttribute("width",e),this.bubbleBack_.setAttribute("height",t),this.resizeGroup_&&(Blockly.RTL?this.resizeGroup_.setAttribute("transform","translate("+2*Blockly.Bubble.BORDER_WIDTH+", "+(t-o)+") scale(-1 1)"):this.resizeGroup_.setAttribute("transform","translate("+(e-o)+", "+(t-o)+")")),this.rendered_&&(this.autoLayout_&&this.layoutBubble_(),this.positionBubble_(),this.renderArrow_()),Blockly.fireUiEvent(this.bubbleGroup_,"resize")},Blockly.Bubble.prototype.renderArrow_=function(){var e=[],t=this.width_/2,o=this.height_/2,n=-this.relativeLeft_,i=-this.relativeTop_;if(t==n&&o==i)e.push("M "+t+","+o);else{i-=o,n-=t,Blockly.RTL&&(n*=-1);var r=Math.sqrt(i*i+n*n),l=Math.acos(n/r);0>i&&(l=2*Math.PI-l);var s=l+Math.PI/2;s>2*Math.PI&&(s-=2*Math.PI);var a=Math.sin(s),g=Math.cos(s),c=this.getBubbleSize();s=(c.width+c.height)/Blockly.Bubble.ARROW_THICKNESS,s=Math.min(s,c.width,c.height)/2,n=t+(c=1-Blockly.Bubble.ANCHOR_RADIUS/r)*n,i=o+c*i,c=t+s*g;var u=o+s*a;t-=s*g,o-=s*a,(a=l+this.arrow_radians_)>2*Math.PI&&(a-=2*Math.PI),l=Math.sin(a)*r/Blockly.Bubble.ARROW_BEND,r=Math.cos(a)*r/Blockly.Bubble.ARROW_BEND,e.push("M"+c+","+u),e.push("C"+(c+r)+","+(u+l)+" "+n+","+i+" "+n+","+i),e.push("C"+n+","+i+" "+(t+r)+","+(o+l)+" "+t+","+o)}e.push("z"),this.bubbleArrow_.setAttribute("d",e.join(" "))},Blockly.Bubble.prototype.setColour=function(e){this.bubbleBack_.setAttribute("fill",e),this.bubbleArrow_.setAttribute("fill",e)},Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_(),goog.dom.removeNode(this.bubbleGroup_),this.shape_=this.content_=this.blockSpace_=this.bubbleGroup_=null},Blockly.Icon=function(e){this.block_=e},Blockly.Icon.RADIUS=8,Blockly.Icon.prototype.bubble_=null,Blockly.Icon.prototype.iconX_=0,Blockly.Icon.prototype.iconY_=0,Blockly.Icon.prototype.createIcon_=function(){this.iconGroup_=Blockly.createSvgElement("g",{},null),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEvent_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable()},Blockly.Icon.prototype.dispose=function(){goog.dom.removeNode(this.iconGroup_),this.iconGroup_=null,this.setVisible(!1),this.block_=null},Blockly.Icon.prototype.updateEditable=function(){this.block_.isEditable()&&!this.block_.isInFlyout?Blockly.addClass_(this.iconGroup_,"blocklyIconGroup"):Blockly.removeClass_(this.iconGroup_,"blocklyIconGroup")},Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_},Blockly.Icon.prototype.iconClick_=function(){this.block_.isEditable()&&!this.block_.isInFlyout&&this.setVisible(!this.isVisible())},Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getHexColour())},Blockly.Icon.prototype.renderIcon=function(e){if(this.block_.isCollapsed())return this.iconGroup_.setAttribute("display","none"),e;this.iconGroup_.setAttribute("display","block");var t=2*Blockly.Icon.RADIUS;return Blockly.RTL&&(e-=t),this.iconGroup_.setAttribute("transform","translate("+e+", 5)"),this.computeIconLocation(),Blockly.RTL?e-Blockly.BlockSvg.SEP_SPACE_X:e+(t+Blockly.BlockSvg.SEP_SPACE_X)},Blockly.Icon.prototype.setIconLocation=function(e,t){this.iconX_=e,this.iconY_=t,this.isVisible()&&this.bubble_.setAnchorLocation(e,t)},Blockly.Icon.prototype.computeIconLocation=function(){var e=this.block_.getRelativeToSurfaceXY(),t=Blockly.getRelativeXY(this.iconGroup_),o=e.x+t.x+Blockly.Icon.RADIUS;e=e.y+t.y+Blockly.Icon.RADIUS,o===this.iconX_&&e===this.iconY_||this.setIconLocation(o,e)},Blockly.Icon.prototype.getIconLocation=function(){return{x:this.iconX_,y:this.iconY_}},Blockly.Mutator=function(e){Blockly.Mutator.superClass_.constructor.call(this,null),this.quarkXml_=[];for(var t=0;t<e.length;t++){var o=goog.dom.createDom("block",{type:e[t]});this.quarkXml_[t]=o}},goog.inherits(Blockly.Mutator,Blockly.Icon),Blockly.Mutator.prototype.blockSpaceWidth_=0,Blockly.Mutator.prototype.blockSpaceHeight_=0,Blockly.Mutator.prototype.createIcon=function(){Blockly.Icon.prototype.createIcon_.call(this);var e=Blockly.Icon.RADIUS/2;Blockly.createSvgElement("rect",{class:"blocklyIconShield",width:4*e,height:4*e,rx:e,ry:e},this.iconGroup_),this.iconMark_=Blockly.createSvgElement("text",{class:"blocklyIconMark",x:Blockly.Icon.RADIUS,y:2*Blockly.Icon.RADIUS-4},this.iconGroup_),this.iconMark_.appendChild(document.createTextNode("★"))},Blockly.Mutator.prototype.createEditor_=function(){this.svgDialog_=Blockly.createSvgElement("svg",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null),this.svgBackground_=Blockly.createSvgElement("rect",{class:"blocklyMutatorBackground",height:"100%",width:"100%"},this.svgDialog_);var e=this,t=this.block_.blockSpace.blockSpaceEditor;return this.blockSpace_=new Blockly.BlockSpace(t,function(){return e.getFlyoutMetrics_()},null),this.blockSpace_.flyout_=new Blockly.Flyout(t),this.blockSpace_.flyout_.autoClose=!1,this.svgDialog_.appendChild(this.blockSpace_.flyout_.createDom()),this.svgDialog_.appendChild(this.blockSpace_.createDom()),this.svgDialog_},Blockly.Mutator.prototype.resizeBubble_=function(){var e=2*Blockly.Bubble.BORDER_WIDTH,t=this.blockSpace_.getCanvas().getBBox(),o=this.blockSpace_.flyout_.getMetrics_(),n=Blockly.RTL?-t.x:t.width+t.x;t=Math.max(t.height+3*e,o.contentHeight+20),n+=3*e,(Math.abs(this.blockSpaceWidth_-n)>e||Math.abs(this.blockSpaceHeight_-t)>e)&&(this.blockSpaceWidth_=n,this.blockSpaceHeight_=t,this.bubble_.setBubbleSize(n+e,t+e),this.svgDialog_.setAttribute("width",this.blockSpaceWidth_),this.svgDialog_.setAttribute("height",this.blockSpaceHeight_)),Blockly.RTL&&(e="translate("+this.blockSpaceWidth_+",0)",this.blockSpace_.getCanvas().setAttribute("transform",e)),e=Blockly.convertCoordinates(Blockly.RTL?this.blockSpaceWidth_:0,0,this.svgDialog_,!1),this.blockSpace_.getDragCanvas().setAttribute("transform","translate("+e.x+","+e.y+")")},Blockly.Mutator.prototype.setVisible=function(e){if(e!=this.isVisible())if(e){this.createEditor_(),this.bubble_=new Blockly.Bubble(this.block_.blockSpace,this.svgDialog_,this.block_.svg_.svgGroup_,this.iconX_,this.iconY_,null,null,this.blockSpace_.getDragCanvas());var t=this;this.blockSpace_.flyout_.init(this.blockSpace_,!1),this.blockSpace_.flyout_.show(this.quarkXml_),this.rootBlock_=this.block_.decompose(this.blockSpace_),e=this.rootBlock_.getDescendants();for(var o,n=0;o=e[n];n++)o.render();this.rootBlock_.setMovable(!1),this.rootBlock_.setDeletable(!1),e=2*this.blockSpace_.flyout_.CORNER_RADIUS,n=this.blockSpace_.flyout_.width_+e,Blockly.RTL&&(n=-n),this.rootBlock_.moveBy(n,e),this.block_.saveConnections&&(this.block_.saveConnections(this.rootBlock_),this.sourceListener_=Blockly.bindEvent_(this.block_.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this.block_,function(){t.block_.saveConnections(t.rootBlock_)})),this.resizeBubble_(),Blockly.bindEvent_(this.blockSpace_.getCanvas(),"blocklyBlockSpaceChange",this.block_,function(){t.blockSpaceChanged_()}),this.updateColour()}else this.svgBackground_=this.svgDialog_=null,this.blockSpace_.dispose(),this.rootBlock_=this.blockSpace_=null,this.bubble_.dispose(),this.bubble_=null,this.blockSpaceHeight_=this.blockSpaceWidth_=0,this.sourceListener_&&(Blockly.unbindEvent_(this.sourceListener_),this.sourceListener_=null)},Blockly.Mutator.prototype.blockSpaceChanged_=function(){if(this.blockSpace_){if(!Blockly.Block.isDragging())for(var e,t=this.blockSpace_.getTopBlocks(!1),o=0;e=t[o];o++){var n=e.getRelativeToSurfaceXY(),i=e.getHeightWidth();20>n.y+i.height&&e.moveBy(0,20-i.height-n.y)}this.rootBlock_.blockSpace==this.blockSpace_&&(t=this.block_.rendered,this.block_.rendered=!1,this.block_.compose(this.rootBlock_),this.block_.rendered=t,this.block_.rendered&&this.block_.render(),Blockly.Block.isDragging()||this.resizeBubble_(),this.block_.blockSpace.fireChangeEvent())}},Blockly.Mutator.prototype.getFlyoutMetrics_=function(){var e=0;return Blockly.RTL&&(e+=this.blockSpaceWidth_),{viewHeight:this.blockSpaceHeight_,viewWidth:this.blockSpaceWidth_,absoluteTop:0,absoluteLeft:e}},Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null,Blockly.Icon.prototype.dispose.call(this)},Blockly.Warning=function(e){Blockly.Warning.superClass_.constructor.call(this,e),this.createIcon_()},goog.inherits(Blockly.Warning,Blockly.Icon),Blockly.Warning.prototype.text_="",Blockly.Warning.prototype.createIcon_=function(){Blockly.Icon.prototype.createIcon_.call(this),Blockly.createSvgElement("path",{class:"blocklyIconShield",d:"M 2,15 Q -1,15 0.5,12 L 6.5,1.7 Q 8,-1 9.5,1.7 L 15.5,12 Q 17,15 14,15 z"},this.iconGroup_),this.iconMark_=Blockly.createSvgElement("text",{class:"blocklyIconMark",x:Blockly.Icon.RADIUS,y:2*Blockly.Icon.RADIUS-3},this.iconGroup_),this.iconMark_.appendChild(document.createTextNode("!"))},Blockly.Warning.prototype.textToDom_=function(e){var t=Blockly.createSvgElement("text",{class:"blocklyText",y:Blockly.Bubble.BORDER_WIDTH},null);e=e.split("\n");for(var o=0;o<e.length;o++){var n=Blockly.createSvgElement("tspan",{dy:"1em",x:Blockly.Bubble.BORDER_WIDTH},t),i=document.createTextNode(e[o]);n.appendChild(i)}return t},Blockly.Warning.prototype.setVisible=function(e){if(e!=this.isVisible())if(e){if(e=this.textToDom_(this.text_),this.bubble_=new Blockly.Bubble(this.block_.blockSpace,e,this.block_.svg_.svgGroup_,this.iconX_,this.iconY_,null,null),Blockly.RTL){if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){e.style.display="inline";var t=[e.getBBox().x,e.getBBox().y,e.scrollWidth,e.scrollHeight][2]}else t=e.getBBox().width;for(var o,n=0;o=e.childNodes[n];n++)o.setAttribute("text-anchor","end"),o.setAttribute("x",t+Blockly.Bubble.BORDER_WIDTH)}this.updateColour(),e=this.bubble_.getBubbleSize(),this.bubble_.setBubbleSize(e.width,e.height)}else this.bubble_.dispose(),this.foreignObject_=this.body_=this.bubble_=null},Blockly.Warning.prototype.bodyFocus_=function(){this.bubble_.promote_()},Blockly.Warning.prototype.setText=function(e){this.text_=e,this.isVisible()&&(this.setVisible(!1),this.setVisible(!0))},Blockly.Warning.prototype.dispose=function(){this.block_.warning=null,Blockly.Icon.prototype.dispose.call(this)},Blockly.uidCounter_=0,Blockly.Block=function(e,t,o){this.id=++Blockly.uidCounter_,this.htmlId=o,this.previousConnection=this.nextConnection=this.outputConnection=null,this.inputList=[],this.disabled=this.rendered=this.inputsInline=!1,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.userVisible_=this.editable_=this.movable_=this.deletable_=!0,this.currentlyHidden_=this.dragging_=this.collapsed_=this.nextConnectionDisabled_=!1,this.canDisconnectFromParent_=!0,this.editLabel_=null,this.blockSpace=e,this.isInFlyout=e.isFlyout,this.colourSaturation_=.45,this.colourValue_=.65,this.fillPattern_=null,this.blockSvgClass_=Blockly.BlockSvg,this.customOptions_={},this.beforeDispose=null,this.setRenderBlockSpace(e),t&&(this.type=t,(e=Blockly.Blocks[t])||(Blockly.fireUiEvent(window,"unknownBlock",{name:t}),e=Blockly.Blocks.unknown,this.appendDummyInput().appendTitle("unknown: "+t),console.warn('Warning: "'+t+'" is an unknown language block.')),goog.mixin(this,e)),goog.isFunction(this.init)&&this.init(),this.shouldHideIfInMainBlockSpace&&this.shouldHideIfInMainBlockSpace()&&this.blockSpace===Blockly.mainBlockSpace&&this.setCurrentlyHidden(!0),this.handleBlockLimitChanges(),this.blockEvents=new goog.events.EventTarget},Blockly.Block.EVENTS={AFTER_DISPOSED:"afterDisposed",AFTER_DROPPED:"afterDropped"},Blockly.Block.prototype.svg_=null,Blockly.Block.prototype.mutator=null,Blockly.Block.prototype.warning=null,Blockly.Block.prototype.init=null,Blockly.Block.prototype.onchange=null,Blockly.Block.prototype.handleBlockLimitChanges=function(){this.blockSpace&&this.blockSpace.blockSpaceEditor&&(Blockly.editBlocks?!this.isInFlyout:this.isInFlyout)&&this.blockSpace.blockSpaceEditor.blockLimits.events.listen("change",this.onBlockLimitChange.bind(this))},Blockly.Block.prototype.onBlockLimitChange=function(e){e.type===this.type&&this.svg_&&this.svg_.updateLimit(Blockly.editBlocks?e.limit:e.remaining)},Blockly.Block.prototype.setRenderBlockSpace=function(e){this.blockSpace=e,this.blockSpace.addTopBlock(this),goog.isFunction(this.onchange)&&Blockly.bindEvent_(this.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this,this.onchange)},Blockly.Block.prototype.getIcons=function(){var e=[];return this.mutator&&e.push(this.mutator),this.warning&&e.push(this.warning),e},Blockly.Block.prototype.initSvg=function(){if(this.svg_=new this.blockSvgClass_(this,this.customOptions_),this.svg_.init(),this.blockSpace.isReadOnly()||(Blockly.bindEvent_(this.svg_.getRootElement(),"mousedown",this,this.onMouseDown_),Blockly.bindEvent_(this.svg_.getRootElement(),"focus",this,this.select.bind(this,!1))),this.setCurrentlyHidden(this.currentlyHidden_),this.moveToFrontOfMainCanvas_(),this.setIsUnused(),this.miniFlyoutBlocks){this.miniFlyout=new Blockly.HorizontalFlyout(this.blockSpace.blockSpaceEditor),this.miniFlyout.targetBlockSpace_=this.blockSpace;var e=this.miniFlyout.createDom(!0);this.svg_.getRootElement().appendChild(e),this.miniFlyout.show(this.miniFlyoutBlocks),this.miniFlyout.softHide()}},Blockly.Block.prototype.initMiniFlyout=function(e){e=Blockly.Xml.textToDom(e).childNodes;for(var t=[],o=0;o<e.length;o++){var n=e[o];"block"===n.nodeName&&t.push(n)}this.miniFlyoutBlocks=t},Blockly.Block.prototype.getSvgRoot=function(){return this.svg_&&this.svg_.getRootElement()},Blockly.Block.DRAG_MODE_NOT_DRAGGING=0,Blockly.Block.DRAG_MODE_INSIDE_STICKY_RADIUS=1,Blockly.Block.DRAG_MODE_FREELY_DRAGGING=2,Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_NOT_DRAGGING,Blockly.Block.isDragging=function(){return Blockly.Block.dragMode_!==Blockly.Block.DRAG_MODE_NOT_DRAGGING},Blockly.Block.isFreelyDragging=function(){return Blockly.Block.dragMode_===Blockly.Block.DRAG_MODE_FREELY_DRAGGING},Blockly.Block.startDragging=function(){Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_INSIDE_STICKY_RADIUS},Blockly.Block.onMouseUpWrapper_=null,Blockly.Block.onMouseMoveWrapper_=null,Blockly.Block.terminateDrag_=function(){Blockly.Block.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Block.onMouseUpWrapper_),Blockly.Block.onMouseUpWrapper_=null),Blockly.Block.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Block.onMouseMoveWrapper_),Blockly.Block.onMouseMoveWrapper_=null);var e=Blockly.selected;if(Blockly.Block.isFreelyDragging()&&e){e.blockSpace.clearPickedUpBlockOrigin(),e.blockSpace.stopAutoScrolling();var t=e.getRelativeToSurfaceXY();e.moveConnections_(t.x-e.startDragX,t.y-e.startDragY),delete e.draggedBubbles_,e.setDragging_(!1),e.moveToFrontOfMainCanvas_(),e.render(),window.setTimeout(e.bumpNeighbours.bind(e),Blockly.BUMP_DELAY),e.blockSpace.blockSpaceEditor.bumpBlocksIntoBlockSpace(),e.blockSpace.scrollIntoView(e),Blockly.fireUiEvent(window,"resize")}e&&(e.blockSpace.fireChangeEvent(),e.blockSpace.blockSpaceEditor.setCursor(Blockly.Css.Cursor.OPEN)),Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_NOT_DRAGGING,e&&e.blockEvents.dispatchEvent(Blockly.Block.EVENTS.AFTER_DROPPED)},Blockly.Block.prototype.select=function(e){if(!this.svg_)throw"Block is not rendered.";Blockly.selected&&Blockly.selected.unselect(),Blockly.selected=this,this.svg_.addSelect(!this.parentBlock_),e&&this.svg_.addSpotlight(),Blockly.fireUiEvent(this.blockSpace.getCanvas(),"blocklySelectChange")},Blockly.Block.prototype.unselect=function(){if(Blockly.selected===this){if(!this.svg_)throw"Block is not rendered.";Blockly.BlockSpaceEditor.terminateDrag_(),Blockly.selected=null,this.svg_.removeSelect(),this.svg_.removeSpotlight(),Blockly.fireUiEvent(this.blockSpace.getCanvas(),"blocklySelectChange")}},Blockly.Block.prototype.isCopyable=function(){return!0},Blockly.Block.prototype.dispose=function(e,t){for(goog.isFunction(this.beforeDispose)&&this.beforeDispose(),this.rendered=!1,this.unplug(e),t&&this.svg_&&this.svg_.disposeUiEffect(),e=goog.bind(this.blockSpace.updateScrollableSize,this.blockSpace),this.blockSpace.removeTopBlock(this),this.blockSpace=null,Blockly.selected==this&&(Blockly.selected=null,Blockly.BlockSpaceEditor.terminateDrag_()),Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide(),t=this.childBlocks_.length-1;0<=t;t--)this.childBlocks_[t].dispose(!1);var o=this.getIcons();for(t=0;t<o.length;t++)o[t].dispose();for(t=0;t<this.inputList.length;t++)(o=this.inputList[t]).dispose();for(this.inputList=[],o=this.getConnections_(!0),t=0;t<o.length;t++){var n=o[t];n.targetConnection&&n.disconnect(),o[t].dispose()}this.svg_&&(this.svg_.dispose(),this.svg_=null),this.blockEvents.dispatchEvent(Blockly.Block.EVENTS.AFTER_DISPOSED),e()},Blockly.Block.prototype.unplug=function(e,t){if(t=t&&!!this.getParent(),this.outputConnection)this.outputConnection.targetConnection&&this.setParent(null);else{var o=null;this.previousConnection&&this.previousConnection.targetConnection&&(o=this.previousConnection.targetConnection,this.setParent(null)),e&&this.nextConnection&&this.nextConnection.targetConnection&&(e=this.nextConnection.targetConnection,this.nextConnection.targetBlock().setParent(null),o&&o.connect(e))}t&&this.moveBy(Blockly.SNAP_RADIUS*(Blockly.RTL?-1:1),2*Blockly.SNAP_RADIUS)},Blockly.Block.prototype.getRelativeToSurfaceXY=function(){var e=0,t=0;if(this.svg_){var o=this.svg_.getRootElement();do{var n=Blockly.getRelativeXY(o);e+=n.x,t+=n.y,n=(o=o.parentNode)==this.blockSpace.getCanvas()||o==this.blockSpace.getDragCanvas()}while(o&&!n)}return{x:e,y:t}},Blockly.Block.prototype.moveTo=function(e,t){var o=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+e+", "+t+")"),this.moveConnections_(e-o.x,t-o.y)},Blockly.Block.prototype.moveBy=function(e,t){var o=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+(o.x+e)+", "+(o.y+t)+")"),this.moveConnections_(e,t)},Blockly.Block.prototype.getBox=function(){var e=this.getHeightWidth(),t=this.getRelativeToSurfaceXY();return this.outputConnection&&(t.x-=Blockly.BlockSvg.TAB_WIDTH),new goog.math.Box(t.y,t.x+e.width,t.y+e.height,t.x)},Blockly.Block.prototype.getSvgPadding=function(){return this.svg_&&this.svg_.getPadding()},Blockly.Block.prototype.getHeightWidth=function(){try{var e=Blockly.ieVersion()&&10>=Blockly.ieVersion();if(e){var t=this.getSvgRoot().style.display;this.getSvgRoot().style.display="inline"}var o=goog.object.clone(this.getSvgRoot().getBBox());e&&(this.getSvgRoot().style.display=t)}catch(e){return{height:0,width:0}}return e=0,Blockly.BROKEN_CONTROL_POINTS&&(o.height-=10,this.nextConnection&&(o.height+=4),e=-5),0<o.height&&--o.height,o.height=Math.max(0,o.height+(o.y-e)),o},Blockly.Block.prototype.onMouseDown_=function(e){if(e.preventDefault(),"inputClickTarget"===(e.target.getAttribute&&e.target.getAttribute("class")))e.stopPropagation();else if(document.activeElement&&document.activeElement.blur&&document.activeElement.blur(),!this.isInFlyout){if(this.blockSpace.blockSpaceEditor.svgResize(),Blockly.BlockSpaceEditor.terminateDrag_(),this.select(),this.blockSpace.blockSpaceEditor.hideChaff(),Blockly.isRightButton(e))Blockly.editBlocks&&this.showContextMenu_(e);else{if(this.blockSpace.isMovementLocked()||!this.isMovable()||!this.canDisconnectFromParent())return;if(this.shouldCopyOnDrag()){var t=this.duplicate_();return t.setParentForCopyOnDrag(null),void t.onMouseDown_(e)}Blockly.removeAllRanges(),this.setIsUnused(!1),this.blockSpace.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),t=this.getRelativeToSurfaceXY(),this.startDragX=t.x,this.startDragY=t.y,void 0!==e.startDragMouseX_&&void 0!==e.startDragMouseY_?(this.startDragMouseX=e.startDragMouseX_,this.startDragMouseY=e.startDragMouseY_,e.startDragMouseX_=void 0,e.startDragMouseY_=void 0):(this.startDragMouseX=e.clientX,this.startDragMouseY=e.clientY),Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_INSIDE_STICKY_RADIUS,Blockly.Block.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUp_),Blockly.Block.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_),this.draggedBubbles_=[],t=this.getDescendants();for(var o,n=0;o=t[n];n++){o=o.getIcons();for(var i=0;i<o.length;i++){var r=o[i].getIconLocation();r.bubble=o[i],this.draggedBubbles_.push(r)}}}e.stopPropagation()}},Blockly.Block.prototype.onMouseUp_=function(e){var t=this.blockSpace;Blockly.BlockSpaceEditor.terminateDrag_(),Blockly.selected&&Blockly.highlightedConnection_?(Blockly.localConnection_.connect(Blockly.highlightedConnection_),this.svg_&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).sourceBlock_.svg_.connectionUiEffect(),t.trashcan&&t.trashcan.close()):Blockly.selected&&Blockly.selected.areBlockAndDescendantsDeletable()&&t.isDeleteArea(e.clientX,e.clientY,this.startDragMouseX)&&((e=t.trashcan)&&window.setTimeout(e.close.bind(e),100),Blockly.selected.dispose(!1,!0),Blockly.topLevelProcedureAutopopulate&&this.isFunctionDefinition()&&window.setTimeout(function(){t.blockSpaceEditor.updateFlyout()},0),Blockly.fireUiEvent(window,"resize")),Blockly.selected&&(Blockly.selected.setIsUnused(),getShadowBlocksInStack(Blockly.selected).forEach(function(e){var t=e.blockToShadow_(e.getRootBlock());e.shadowBlockValue_(t)})),Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null),t.hideDelete(),t.blockSpaceEditor.setCursor(Blockly.Css.Cursor.OPEN)},Blockly.Block.prototype.showHelp_=function(){var e=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;e&&window.open(e)},Blockly.Block.prototype.duplicate_=function(){var e=Blockly.Xml.blockToDom(this);Blockly.Xml.deleteNext(e),e=Blockly.Xml.domToBlock(this.blockSpace,e);var t=this.getRelativeToSurfaceXY(),o=this.shouldCopyOnDrag()?1:Blockly.SNAP_RADIUS;return t.x=Blockly.RTL?t.x-o:t.x+o,t.y+=2*o,e.moveBy(t.x,t.y),e},Blockly.Block.prototype.showContextMenu_=function(e){if(!this.blockSpace.isReadOnly()&&this.contextMenu){var t=this,o=[];if(this.isDeletable()&&!t.isInFlyout){var n={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){t.duplicate_()}};this.getDescendants().length>this.blockSpace.remainingCapacity()&&(n.enabled=!1),o.push(n),n={text:this.disabled?Blockly.Msg.ENABLE_BLOCK:Blockly.Msg.DISABLE_BLOCK,enabled:!this.getInheritedDisabled(),callback:function(){t.setDisabled(!t.disabled)}},o.push(n),n=this.getDescendants().length,t.nextConnection&&t.nextConnection.targetConnection&&(n-=this.nextConnection.targetBlock().getDescendants().length),n={text:1==n?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",n),enabled:!0,callback:function(){t.dispose(!0,!0)}},o.push(n)}Blockly.editBlocks&&(o.push({text:this.userVisible_?"Make Invisible to Users":"Make Visible to Users",enabled:!0,callback:function(){t.setUserVisible(!t.isUserVisible()),Blockly.ContextMenu.hide()}}),o.push({text:this.deletable_?"Make Undeletable to Users":"Make Deletable to Users",enabled:!0,callback:function(){t.setDeletable(!t.isDeletable()),Blockly.ContextMenu.hide()}}),o.push({text:this.movable_?"Make Immovable to Users":"Make Movable to Users",enabled:!0,callback:function(){t.setMovable(!t.isMovable()),Blockly.ContextMenu.hide()}}),o.push({text:this.nextConnectionDisabled_?"Enable Next Connection":"Disable Next Connection",enabled:!0,callback:function(){t.setNextConnectionDisabled(!t.nextConnectionDisabled_),Blockly.ContextMenu.hide()}}),o.push({text:this.editable_?"Make Uneditable":"Make editable",enabled:!0,callback:function(){t.setEditable(!t.isEditable()),Blockly.ContextMenu.hide()}}),o.push({text:this.canDisconnectFromParent_?"Lock to Parent Block":"Unlock from Parent Block",enabled:!0,callback:function(){t.setCanDisconnectFromParent(!t.canDisconnectFromParent_),Blockly.ContextMenu.hide()}}),n={text:"Set limit (current: "+(t.blockSpace.blockSpaceEditor.blockLimits.getLimit(t.type)||"none")+")",enabled:!0,callback:function(){t.blockSpace.blockSpaceEditor.blockLimits.setLimit(t.type,prompt("New Limit",t.blockSpace.blockSpaceEditor.blockLimits.getLimit(t.type)))}},o.push(n),this.getCustomContextMenuItems&&(o=o.concat(this.getCustomContextMenuItems()))),this.customContextMenu&&!t.isInFlyout&&this.customContextMenu(o),Blockly.ContextMenu.show(e,o),Blockly.ContextMenu.currentBlock=this}},Blockly.Block.prototype.getConnections_=function(e){var t=[];if((e||this.rendered)&&(this.outputConnection&&t.push(this.outputConnection),this.nextConnection&&t.push(this.nextConnection),this.previousConnection&&t.push(this.previousConnection),e||!this.collapsed_)){e=0;for(var o;o=this.inputList[e];e++)o.connection&&t.push(o.connection)}return t},Blockly.Block.prototype.getLeafConnections_=function(e){var t=this,o=[],n=[this.outputConnection,this.nextConnection,this.previousConnection];return this.inputList.forEach(function(e){n.push(e.connection)}),n.forEach(function(n){if(n){var i=n.targetBlock();i?i!==e&&(o=o.concat(i.getLeafConnections_(t))):o.push(n)}}),o},Blockly.Block.prototype.moveConnections_=function(e,t){if(this.rendered){var o,n=this.getConnections_(!1);for(o=0;o<n.length;o++)n[o].moveBy(e,t);for(n=this.getIcons(),o=0;o<n.length;o++)n[o].computeIconLocation();for(o=0;o<this.childBlocks_.length;o++)this.childBlocks_[o].moveConnections_(e,t)}},Blockly.Block.prototype.setDragging_=function(e){this.setDraggingHandleImmovable_(e,null)},Blockly.Block.prototype.getDragging=function(){return this.dragging_},Blockly.Block.prototype.setDraggingHandleImmovable_=function(e,t){e?(this.dragging_=!0,this.svg_.addDragging()):(this.dragging_=!1,this.svg_.removeDragging());for(var o=0;o<this.childBlocks_.length;o++){var n=this.childBlocks_[o];if(e&&null!==t&&!n.isMovable()){t(n);break}n.setDraggingHandleImmovable_(e,t)}},Blockly.Block.prototype.setCanDisconnectFromParent=function(e){this.canDisconnectFromParent_=e},Blockly.Block.prototype.canDisconnectFromParent=function(){return this.canDisconnectFromParent_},Blockly.Block.prototype.moveToDragCanvas_=function(){this.svg_&&this.blockSpace.moveElementToDragCanvas(this.svg_.getRootElement())},Blockly.Block.prototype.moveToFrontOfMainCanvas_=function(){this.svg_&&this.blockSpace.moveElementToMainCanvas(this.svg_.getRootElement())},Blockly.Block.prototype.moveBlockBeingDragged_=function(e,t,o){Blockly.removeAllRanges();var n=e-this.startDragMouseX,i=t-this.startDragMouseY;if(Blockly.Block.dragMode_==Blockly.Block.DRAG_MODE_INSIDE_STICKY_RADIUS&&Math.sqrt(Math.pow(n,2)+Math.pow(i,2))>Blockly.DRAG_RADIUS){Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_FREELY_DRAGGING;var r=this.generateReconnector_(this.previousConnection);o&&this.unplug(!0,!1),this.setParent(null),this.setDraggingHandleImmovable_(!0,r),this.moveToDragCanvas_(),this.blockSpace.recordPickedUpBlockOrigin(),this.blockSpace.recordDeleteAreas()}if(Blockly.Block.dragMode_==Blockly.Block.DRAG_MODE_FREELY_DRAGGING){for(o=this.startDragX+n,r=this.startDragY+i,this.svg_.getRootElement().setAttribute("transform","translate("+o+", "+r+")"),o=0;o<this.draggedBubbles_.length;o++)(r=this.draggedBubbles_[o]).bubble.setIconLocation(r.x+n,r.y+i);var l=this.getLeafConnections_(null),s=r=null,a=Blockly.SNAP_RADIUS;for(o=0;o<l.length;o++){var g=l[o],c=g.closest(a,n,i);c.connection&&(r=c.connection,s=g,a=c.radius)}n=null,Blockly.highlightedConnection_&&Blockly.highlightedConnection_!=r&&(Blockly.highlightedConnection_.unhighlight(),(n=Blockly.highlightedConnection_).sourceBlock_.pendingConnection(n,r),Blockly.highlightedConnection_=null,Blockly.localConnection_=null),r&&r!=Blockly.highlightedConnection_&&(r.highlight(),Blockly.highlightedConnection_=r,r.sourceBlock_.pendingConnection(n,r),Blockly.localConnection_=s),n=!this.areBlockAndDescendantsDeletable(),this.blockSpace.isDeleteArea(e,t,this.startDragMouseX,n)}},Blockly.Block.prototype.pendingConnection=function(){},Blockly.Block.prototype.onMouseMove_=function(e){"mousemove"==e.type&&1>=e.clientX&&0==e.clientY&&0==e.button||(this.moveBlockBeingDragged_(e.clientX,e.clientY,e.ctrlKey||e.metaKey),this.blockSpace.panIfOverEdge(this,e.clientX,e.clientY)),e.stopPropagation()},Blockly.Block.prototype.generateReconnector_=function(e){if(e&&e.targetConnection)var t=e.targetConnection;return function(e){e.previousConnection&&(e.setParent(null),t&&t.connect(e.previousConnection))}},Blockly.Block.prototype.bumpNeighbours=function(){if(!Blockly.Block.isDragging()&&Blockly.BUMP_UNCONNECTED){var e=this.getRootBlock();if(!e.isInFlyout)for(var t=this.getConnections_(!1),o=0;o<t.length;o++){var n=t[o];n.targetConnection&&n.isSuperior()&&n.targetBlock().bumpNeighbours();for(var i=n.neighbours_(Blockly.SNAP_RADIUS),r=0;r<i.length;r++){var l=i[r];if(!n.targetConnection||!l.targetConnection){var s=l.sourceBlock_.getRootBlock();if(s!==e){if(n.targetConnection&&!l.targetConnection)var a=!0;else!n.targetConnection&&l.targetConnection?a=!1:n.type!==l.type?a=n.isSuperior():a=(a=e.getRelativeToSurfaceXY().y)<(s=s.getRelativeToSurfaceXY().y);a?l.bumpAwayFrom_(n):n.bumpAwayFrom_(l)}}}}}},Blockly.Block.prototype.getParent=function(){return this.parentBlock_},Blockly.Block.prototype.getSurroundParent=function(){var e=this;do{var t=e;if(!(e=e.getParent()))return null}while(e.nextConnection&&e.nextConnection.targetBlock()==t);return e},Blockly.Block.prototype.getRootBlock=function(){var e=this;do{var t=e;e=t.parentBlock_}while(e);return t},Blockly.Block.prototype.getChildren=function(){return this.childBlocks_},Blockly.Block.prototype.setParent=function(e){var t,o=this.parentBlock_;if(this.parentBlock_){for(var n,i=this.parentBlock_.childBlocks_,r=0;n=i[r];r++)if(n==this){i.splice(r,1);break}i=this.getRelativeToSurfaceXY(),this.moveToFrontOfMainCanvas_(),this.svg_.getRootElement().setAttribute("transform","translate("+i.x+", "+i.y+")"),this.parentBlock_=null,this.previousConnection&&this.previousConnection.targetConnection&&this.previousConnection.disconnect(),this.outputConnection&&this.outputConnection.targetConnection&&this.outputConnection.disconnect()}else this.blockSpace.removeTopBlock(this),this.setIsUnused();if((this.parentBlock_=e)?(e.childBlocks_.push(this),i=this.getRelativeToSurfaceXY(),n=e.getRelativeToSurfaceXY(),this.svg_.getRootElement().setAttribute("transform","translate("+(i.x-n.x)+", "+(i.y-n.y)+")"),e.svg_&&this.svg_&&e.svg_.getRootElement().appendChild(this.svg_.getRootElement()),n=this.getRelativeToSurfaceXY(),this.moveConnections_(n.x-i.x,n.y-i.y)):this.blockSpace.addTopBlock(this),e&&e.miniFlyout&&"gamelab_allSpritesWithAnimation"===this.type){if(e.isMiniFlyoutOpen){i=e.miniFlyout.blockSpace_.topBlocks_;var l=e.getConnections_(!0).filter(function(e){return e.type===Blockly.INPUT_VALUE}).map(function(e){return e.targetBlock()});i.forEach(function(e,t){e.shadowBlockValue_(l[t])})}i=(i=getShadowBlocksInStack(e)).filter(function(t){return t.blockToShadow_(e)===this},this),this.setShadowBlocks(i),i.forEach(function(e){t=e.blockToShadow_(e.getRootBlock()),e.shadowBlockValue_(t)}),e.render()}else e&&e.getRootBlock().miniFlyout&&(i=getShadowBlocksInStack(this)).forEach(function(e){t=e.blockToShadow_(e.getRootBlock()),e.shadowBlockValue_(t)});o&&o.miniFlyout&&"gamelab_allSpritesWithAnimation"===this.type?(o.isMiniFlyoutOpen&&(i=o.miniFlyout.blockSpace_.topBlocks_,l=o.getConnections_(!0).filter(function(e){return e.type===Blockly.INPUT_VALUE}).map(function(e){return e.targetBlock()}),i.forEach(function(e,t){e.shadowBlockValue_(l[t])})),this.setShadowBlocks([]),(i=getShadowBlocksInStack(o)).forEach(function(e){t=e.blockToShadow_(e.getRootBlock()),e.shadowBlockValue_(t)})):o&&o.getRootBlock().miniFlyout&&(i=getShadowBlocksInStack(this)).forEach(function(e){t=e.blockToShadow_(e.getRootBlock()),e.shadowBlockValue_(t)})},Blockly.Block.prototype.shadowBlockValue_=function(e){if(this.blockToShadow_&&!this.getRootBlock().isCurrentlyBeingDragged())if(e&&"gamelab_allSpritesWithAnimation"===e.type){var t=e.inputList[0].titleRow[0],o=this.inputList[0].titleRow[1],n=this.inputList[0].titleRow[0];o.setText(t.previewElement_.getAttribute("xlink:href")),o.updateDimensions_(this.thumbnailSize,this.thumbnailSize),n.setText(this.shortString),e.addShadowBlock(this)}else o=this.inputList[0].titleRow[1],n=this.inputList[0].titleRow[0],o.setText(""),o.updateDimensions_(1,this.thumbnailSize),n.setText(this.longString)},Blockly.Block.prototype.addShadowBlock=function(e){this.shadowBlocks_||(this.shadowBlocks_=[]),-1===this.shadowBlocks_.indexOf(e)&&this.shadowBlocks_.push(e)},Blockly.Block.prototype.setShadowBlocks=function(e){this.shadowBlocks_=e},Blockly.Block.prototype.getShadowBlocks=function(){return this.shadowBlocks_||[]},Blockly.Block.prototype.getDescendants=function(){for(var e,t=[this],o=0;e=this.childBlocks_[o];o++)t=t.concat(e.getDescendants());return t},Blockly.Block.prototype.areBlockAndDescendantsDeletable=function(){var e=this.childBlocks_.some(function(e){return!e.areBlockAndDescendantsDeletable()});return this.isDeletable()&&!e},Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.blockSpace.isReadOnly()},Blockly.Block.prototype.setDeletable=function(e){this.deletable_=e,this.svg_&&this.svg_.grayOut(this.shouldBeGrayedOut())},Blockly.Block.prototype.shouldBeGrayedOut=function(){return Blockly.grayOutUndeletableBlocks&&!this.isDeletable()&&!this.blockSpace.isReadOnly()},Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.blockSpace.isReadOnly()},Blockly.Block.prototype.setMovable=function(e){this.movable_=e,this.svg_&&this.svg_.updateMovable()},Blockly.Block.prototype.isEditable=function(){return this.editable_&&!this.blockSpace.isReadOnly()},Blockly.Block.prototype.setEditable=function(e){var t,o;for(this.editable_=e,t=0;t<this.inputList.length;t++){var n=this.inputList[t];for(o=0;o<n.titleRow.length;o++){n.titleRow[o].updateEditable()}}for(o=this.getIcons(),t=0;t<o.length;t++)o[t].updateEditable();this.editLabel_&&this.editLabel_.setVisible(e)},Blockly.Block.prototype.isUserVisible=function(){return this.userVisible_},Blockly.Block.prototype.setUserVisible=function(e,t){(this.userVisible_=e)?this.svg_&&Blockly.removeClass_(this.svg_.svgGroup_,"userHidden"):this.svg_&&Blockly.addClass_(this.svg_.svgGroup_,"userHidden"),this.childBlocks_.forEach(function(o){o.setUserVisible(e,t)}),t&&e&&0===this.childBlocks_.length&&this.svg_&&this.render()},Blockly.Block.prototype.isNextConnectionDisabled=function(){return this.nextConnectionDisabled_},Blockly.Block.prototype.isFunctionDefinition=function(){return!!this.getProcedureInfo},Blockly.Block.prototype.setNextConnectionDisabled=function(e){(this.nextConnectionDisabled_=e)&&this.nextConnection&&this.nextConnection.targetConnection&&this.nextConnection.disconnect(),this.setNextStatement(!e)},Blockly.Block.prototype.isCurrentlyBeingDragged=function(){return Blockly.selected===this&&Blockly.Block.isDragging()},Blockly.Block.prototype.isCurrentlyHidden_=function(){return this.currentlyHidden_},Blockly.Block.prototype.setCurrentlyHidden=function(e){this.currentlyHidden_=e,this.svg_&&(this.svg_.setVisible(!e),e||this.refreshRender())},Blockly.Block.prototype.isVisible=function(){var e=(!this.parentBlock_||this.parentBlock_.isVisible())&&!this.isCurrentlyHidden_();return Blockly.editBlocks?e:e&&this.isUserVisible()},Blockly.Block.prototype.setHelpUrl=function(e){this.helpUrl=e},Blockly.Block.prototype.getHexColour=function(){return Blockly.makeColour(this.getColour(),this.getSaturation(),this.getValue())},Blockly.Block.prototype.getColour=function(){return this.colourHue_},Blockly.Block.prototype.getSaturation=function(){return this.colourSaturation_},Blockly.Block.prototype.getFillPattern=function(){return this.fillPattern_},Blockly.Block.prototype.isFramed=function(){return this.blockSvgClass_===Blockly.BlockSvgFramed},Blockly.Block.prototype.getValue=function(){return this.colourValue_},Blockly.Block.prototype.setColour=function(e){this.colourHue_=e,this.svg_&&this.svg_.updateColour();var t=this.getIcons();for(e=0;e<t.length;e++)t[e].updateColour();if(this.rendered){for(e=0;e<this.inputList.length;e++){var o=this.inputList[e];for(t=0;t<o.titleRow.length;t++){o.titleRow[t].setText(null)}}this.render()}},Blockly.Block.prototype.setFillPattern=function(e){this.fillPattern_=e},Blockly.Block.prototype.setFramed=function(e){this.blockSvgClass_=e?Blockly.BlockSvgFramed:Blockly.BlockSvg},Blockly.Block.prototype.isUnused=function(){return this.svg_.isUnused()||this.isCurrentlyBeingDragged()},Blockly.Block.prototype.setIsUnused=function(e){void 0===e&&(e=!(null===this.previousConnection&&null===this.outputConnection)&&this.isUserVisible()&&"functional_definition"!==this.type&&Blockly.mainBlockSpace&&Blockly.mainBlockSpace.isTopBlock(this)),Blockly.showUnusedBlocks&&e!==this.svg_.isUnused()&&(this.svg_.setIsUnused(e),this.childBlocks_.forEach(function(e){e.setIsUnused(!1)}))},Blockly.Block.prototype.setFunctional=function(e,t){this.blockSvgClass_=e?Blockly.BlockSvgFunctional:Blockly.BlockSvg,this.customOptions_=e?t:{}},Blockly.Block.prototype.setHSV=function(e,t,o){for(this.colourHue_=e,this.colourSaturation_=t,this.colourValue_=o,this.svg_&&this.svg_.updateColour(),t=this.getIcons(),e=0;e<t.length;e++)t[e].updateColour();if(this.rendered){for(e=0;e<this.inputList.length;e++)for(o=this.inputList[e],t=0;t<o.titleRow.length;t++){o.titleRow[t].setText(null)}this.render()}},Blockly.Block.prototype.setParentForCopyOnDrag=function(e){this.copyOnDrag_=e},Blockly.Block.prototype.shouldCopyOnDrag=function(){var e=this.getParent();return this.copyOnDrag_&&!!e&&e.type===this.copyOnDrag_},Blockly.Block.prototype.setBlockToShadow=function(e){this.blockToShadow_=e},Blockly.Block.prototype.getTitle_=function(e){for(var t,o=0;t=this.inputList[o];o++)for(var n,i=0;n=t.titleRow[i];i++)if(n.name===e)return n;return null},Blockly.Block.prototype.getTitles=function(){for(var e,t=[],o=0;e=this.inputList[o];o++)for(var n,i=0;n=e.titleRow[i];i++)t.push(n);return t},Blockly.Block.prototype.getTitleValue=function(e){return(e=this.getTitle_(e))?e.getValue():null},Blockly.Block.prototype.setTitleValue=function(e,t){var o=this.getTitle_(t);o?o.setValue(e):(this.appendDummyInput().appendTitle(new Blockly.FieldTextInput(e),t),console.warn('Unknown title: "'+t+'" not found.'))},Blockly.Block.prototype.setFieldConfig=function(e,t){var o=this.getTitle_(e);o?o.setConfig&&o.setConfig(t):console.warn('Unknown field: "'+e+'" not found.')},Blockly.Block.prototype.setTooltip=function(e){this.tooltip=e},Blockly.Block.prototype.setPreviousStatement=function(e,t){if(this.previousConnection){if(this.previousConnection.targetConnection)throw"Must disconnect previous statement before removing connection.";this.previousConnection.dispose(),this.previousConnection=null}if(e){if(this.outputConnection)throw"Remove output connection prior to adding previous connection.";void 0===t&&(t=null),this.previousConnection=new Blockly.Connection(this,Blockly.PREVIOUS_STATEMENT),this.previousConnection.setCheck(t)}this.refreshRender()},Blockly.Block.prototype.setNextStatement=function(e,t){if(this.nextConnection){if(this.nextConnection.targetConnection)throw"Must disconnect next statement before removing connection.";this.nextConnection.dispose(),this.nextConnection=null}e&&(void 0===t&&(t=null),this.nextConnection=new Blockly.Connection(this,Blockly.NEXT_STATEMENT),this.nextConnection.setCheck(t)),this.refreshRender()},Blockly.Block.prototype.setStrictOutput=function(e,t){this.setOutput(e,t,!0)},Blockly.Block.prototype.setOutput=function(e,t,o){if(this.outputConnection){if(this.outputConnection.targetConnection)throw"Must disconnect output value before removing connection.";this.outputConnection.dispose(),this.outputConnection=null}if(e){if(this.previousConnection)throw"Remove previous connection prior to adding output connection.";void 0===t&&(t=null),this.outputConnection=new Blockly.Connection(this,Blockly.OUTPUT_VALUE),this.outputConnection.setCheck(t,o)}this.refreshRender()},Blockly.Block.prototype.refreshRender=function(){this.rendered&&(this.render(),this.bumpNeighbours())},Blockly.Block.prototype.setFunctionalOutput=function(e,t){if(this.previousConnection){if(this.previousConnection.targetConnection)throw"Must disconnect output value before removing connection.";this.previousConnection.dispose(),this.previousConnection=null}if(e){if(this.previousConnection)throw"Remove previous connection prior to adding output connection.";void 0===t&&(t=null),this.previousConnection=new Blockly.Connection(this,Blockly.FUNCTIONAL_OUTPUT),this.previousConnection.setCheck(t)}this.refreshRender()},Blockly.Block.prototype.changeFunctionalOutput=function(e){this.setHSV.apply(this,Blockly.FunctionalTypeColors[e]),this.previousConnection=this.previousConnection||new Blockly.Connection(this,Blockly.FUNCTIONAL_OUTPUT),this.previousConnection.setCheck(e),this.refreshRender()},Blockly.Block.prototype.setInputsInline=function(e){this.inputsInline=e,this.rendered&&(this.render(),this.bumpNeighbours(),this.blockSpace.fireChangeEvent())},Blockly.Block.prototype.setDisabled=function(e){this.disabled!=e&&(this.disabled=e,this.svg_.updateDisabled(),this.blockSpace.fireChangeEvent())},Blockly.Block.prototype.getInheritedDisabled=function(){for(var e=this;e;){if(e.disabled)return!0;e=e.getSurroundParent()}return!1},Blockly.Block.prototype.isCollapsed=function(){return this.collapsed_},Blockly.Block.prototype.setCollapsed=function(e){if(this.collapsed_!=e){this.collapsed_=e;var t,o=[];for(t=0;t<this.inputList.length;t++)o=o.concat(this.inputList[t].setVisible(!e));if(e){for(e=this.getIcons(),t=0;t<e.length;t++)e[t].setVisible(!1);t=this.toString(Blockly.COLLAPSE_CHARS),this.appendDummyInput("_TEMP_COLLAPSED_INPUT").appendTitle(t)}else this.removeInput("_TEMP_COLLAPSED_INPUT");if(o.length||(o[0]=this),this.rendered){for(t=0;t<o.length;t++)o[t].render();this.bumpNeighbours()}}},Blockly.Block.prototype.toString=function(e){for(var t,o=[],n=0;t=this.inputList[n];n++){for(var i,r=0;i=t.titleRow[r];r++)o.push(i.getText());t.connection&&((t=t.connection.targetBlock())?o.push(t.toString()):o.push("?"))}return o=goog.string.trim(o.join(" "))||"???",e&&(o=goog.string.truncate(o,e)),o},Blockly.Block.prototype.appendValueInput=function(e){return this.appendInput_(Blockly.INPUT_VALUE,e)},Blockly.Block.prototype.appendStatementInput=function(e,t){return this.appendInput_(Blockly.NEXT_STATEMENT,e,t||0)},Blockly.Block.prototype.appendDummyInput=function(e){return this.appendInput_(Blockly.DUMMY_INPUT,e||"")},Blockly.Block.prototype.appendFunctionalInput=function(e){return this.appendInput_(Blockly.FUNCTIONAL_INPUT,e)},Blockly.Block.prototype.interpolateMsg=function(e){goog.asserts.assertString(e);var t=arguments.length-1;goog.asserts.assertNumber(t);var o,n=e.split(/(%\d)/);for(o=0;o<n.length;o+=2){var i=goog.string.trim(n[o]),r=n[o+1];if(r){var l=arguments[r=window.parseInt(r.charAt(1),10)];"function"==typeof l?(this.appendDummyInput().appendTitle(i),l()):this.appendValueInput(l[0]).setCheck(l[1]).setAlign(l[2]).appendTitle(i),arguments[r]=null}else i&&this.appendDummyInput().setAlign(t).appendTitle(i)}for(o=1;o<arguments.length-1;o++)goog.asserts.assert(null===arguments[o],'Input "%%s" not used in message: "%s"',o,e);this.setInputsInline(!e.match(/%1\s*$/))},Blockly.Block.prototype.appendInput_=function(e,t,o){o=o||0;var n=null;return e!==Blockly.INPUT_VALUE&&e!==Blockly.NEXT_STATEMENT&&e!==Blockly.FUNCTIONAL_INPUT||(n=new Blockly.Connection(this,e)),e=new Blockly.Input(e,t,this,n,o),this.inputList.push(e),this.rendered&&(this.render(),this.bumpNeighbours()),e},Blockly.Block.prototype.moveInputBefore=function(e,t){if(e==t)throw"Can't move \""+e+'" to itself.';for(var o,n=-1,i=-1,r=0;o=this.inputList[r];r++)if(o.name==e){if(n=r,-1!=i)break}else if(o.name==t&&(i=r,-1!=n))break;if(-1==n)throw'Named input "'+e+'" not found.';if(-1==i)throw'Reference input "'+e+'" not found.';this.inputList.splice(n,1),n<i&&i--,this.inputList.splice(i,0,o),this.rendered&&(this.render(),this.bumpNeighbours())},Blockly.Block.prototype.removeInput=function(e,t){for(var o,n=0;o=this.inputList[n];n++)if(o.name==e)return o.connection&&(o.connection===Blockly.highlightedConnection_&&(o.connection.unhighlight(),Blockly.highlightedConnection_=null),o.connection.targetConnection&&o.connection.targetBlock().setParent(null)),o.dispose(),this.inputList.splice(n,1),void(this.rendered&&(this.render(),this.bumpNeighbours()));t||goog.asserts.fail('Input "%s" not found.',e)},Blockly.Block.prototype.getInput=function(e){for(var t,o=0;t=this.inputList[o];o++)if(t.name==e)return t;return null},Blockly.Block.prototype.getInputTargetBlock=function(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()},Blockly.Block.prototype.attachBlockToInputName=function(e,t){if(!(t=this.getInput(t))||!t.connection)throw"Block has no input named "+name;e.previousConnection.connect(t.connection)},Blockly.Block.prototype.setMutator=function(e){this.mutator&&this.mutator!==e&&this.mutator.dispose(),e&&(e.block_=this,this.mutator=e,this.svg_&&e.createIcon())},Blockly.Block.prototype.setWarningText=function(e){if(!Blockly.Warning)throw"Warnings not supported.";this.isInFlyout&&(e=null);var t=!1;goog.isString(e)?(this.warning||(this.warning=new Blockly.Warning(this),t=!0),this.warning.setText(e)):this.warning&&(this.warning.dispose(),t=!0),t&&this.rendered&&(this.render(),this.bumpNeighbours())},Blockly.Block.prototype.setInputCount=function(e){this.inputCount=parseInt(e)},Blockly.Block.prototype.svgInitialized=function(){return!!this.svg_},Blockly.Block.prototype.render=function(e){if(!this.svg_)throw"Uninitialized block cannot be rendered.  Call block.initSvg()";this.blockSpace&&(this.svg_.render(e),this.miniFlyout&&this.miniFlyout.position_())},Blockly.Block.prototype.getSvgRenderer=function(){return this.svg_},Blockly.Block.prototype.getRootBlock=function(){for(var e,t=this;t;)e=t,t=t.getParent();return e},Blockly.Block.prototype.hasUnfilledFunctionalInput=function(){return this.inputList.some(function(e){return e.type===Blockly.FUNCTIONAL_INPUT&&e.connection&&!e.connection.targetBlock()})},Blockly.AngleHelper=function(e,t){t=t||{},this.lineColour_="#4d575f",this.strokeWidth_=3,this.arcColour_=t.arcColour||this.lineColour_,this.height_=t.height||150,this.width_=t.width||150,this.snapPoints_=t.snapPoints&&t.snapPoints.map(function(e){return Math.round(parseInt(e))}),this.onUpdate_=t.onUpdate,this.enableBackgroundRotation_=t.enableBackgroundRotation||!1,this.turnRight_="turnRight"===e,this.picker_={handleRadius:10,isDragging:!1,angle:t.angle||0,line:null,handle:null},this.background_={handleRadius:5,tickSpacing:15,isDragging:!1,angle:0,handle:null,line:null,ticks:[]},this.radius_=new goog.math.Vec2(Math.min(this.height_,this.width_)/2-this.picker_.handleRadius-this.strokeWidth_,0),this.center_=new goog.math.Vec2(this.width_/2,this.height_/2),this.picker_.handleCenter=this.enableBackgroundRotation_?this.center_.clone().add(new goog.math.Vec2(this.radius_.x-this.picker_.handleRadius,0)):this.center_.clone().add(this.radius_),this.picker_.handleCenter=goog.math.Vec2.rotateAroundPoint(this.picker_.handleCenter,this.center_,goog.math.toRadians(this.turnRight_?this.picker_.angle:-this.picker_.angle)),this.background_.handleCenter=this.center_.clone().add(new goog.math.Vec2(this.radius_.x+this.background_.handleRadius,0)),this.animationInterval_=this.rect_=this.svg_=this.arc_=null},Blockly.AngleHelper.prototype.animateAngleChange=function(e,t){var o=(t=t||200)/10,n=e-this.getAngle();t/=o=Math.min(Math.abs(n),o);var i=n/o;clearInterval(this.animationInterval_),this.animationInterval_=setInterval(function(){if(1>Math.abs(this.getAngle()-e))this.setAngle(e),clearInterval(this.animationInterval_);else{var t=this.getAngle()+i;this.setAngle(t,!0)}}.bind(this),t)},Blockly.AngleHelper.prototype.setAngle=function(e,t){this.picker_&&(this.picker_.angle=t?e:this.snap_(e),this.update_())},Blockly.AngleHelper.prototype.getAngle=function(){return this.picker_?this.picker_.angle:0},Blockly.AngleHelper.prototype.init=function(e){for(this.svg_=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1",height:this.height_+"px",width:this.width_+"px",style:"background: rgb(255, 255, 255);"},e),this.rect_=this.svg_.getBoundingClientRect(),this.mouseMoveWrapper_=Blockly.bindEvent_(this.svg_,"mousemove",this,this.updateDrag_),this.mouseUpWrapper_=Blockly.bindEvent_(this.svg_,"mouseup",this,this.stopDrag_),this.mouseDownWrapper_=Blockly.bindEvent_(this.svg_,"mousedown",this,this.startDrag_),this.background_.line=Blockly.createSvgElement("line",{stroke:this.lineColour_,"stroke-width":this.strokeWidth_,"stroke-linecap":"round","stroke-dasharray":"6 6","stroke-opacity":"0.5",x1:this.center_.x-this.radius_.x,x2:this.center_.x+this.radius_.x,y1:this.center_.y,y2:this.center_.y},this.svg_),this.enableBackgroundRotation_&&(this.background_.handle=Blockly.createSvgElement("circle",{cx:this.background_.handleCenter.x,cy:this.background_.handleCenter.y,fill:this.lineColour_,stroke:this.lineColour_,"stroke-width":1,r:this.background_.handleRadius,style:"cursor: pointer;"},this.svg_)),this.arc_=Blockly.createSvgElement("path",{stroke:this.arcColour_,fill:this.arcColour_,"fill-opacity":"0.3","stroke-width":this.strokeWidth_},this.svg_),e=0;360>e;e+=this.background_.tickSpacing)this.background_.ticks.push(Blockly.createSvgElement("line",{"stroke-linecap":"round","stroke-opacity":.3,stroke:this.lineColour_,x1:this.center_.x+this.radius_.x,y1:this.center_.y,x2:this.center_.x+this.radius_.x-(0==e%90?15:0==e%45?10:5),y2:this.center_.y,class:"blocklyAngleMarks",transform:"rotate("+e+", "+this.center_.x+", "+this.center_.y+")"},this.svg_));this.picker_.line=Blockly.createSvgElement("line",{stroke:this.lineColour_,"stroke-width":this.strokeWidth_,"stroke-linecap":"round",x1:this.center_.x,x2:this.picker_.handleCenter.x,y1:this.center_.y,y2:this.picker_.handleCenter.y},this.svg_),this.picker_.handle=Blockly.createSvgElement("circle",{cx:this.picker_.handleCenter.x,cy:this.picker_.handleCenter.y,fill:"#a69bc1",r:this.picker_.handleRadius,stroke:this.lineColour_,"stroke-width":this.strokeWidth_,style:"cursor: pointer;"},this.svg_),this.update_()},Blockly.AngleHelper.prototype.update_=function(){if(this.enableBackgroundRotation_){this.background_.line.setAttribute("transform","rotate("+this.background_.angle+", "+this.center_.x+", "+this.center_.y+")");for(var e=0;e<this.background_.ticks.length;e++)this.background_.ticks[e].setAttribute("transform","rotate("+(this.background_.tickSpacing*e+this.background_.angle)%360+", "+this.center_.x+", "+this.center_.y+")");this.picker_.handleCenter=this.center_.clone().add(new goog.math.Vec2(this.radius_.x-this.picker_.handleRadius,0))}else this.picker_.handleCenter=this.center_.clone().add(this.radius_);this.picker_.handleCenter=goog.math.Vec2.rotateAroundPoint(this.picker_.handleCenter,this.center_,goog.math.toRadians(this.background_.angle+(this.turnRight_?this.picker_.angle:-this.picker_.angle))),this.picker_.line.setAttribute("x2",this.picker_.handleCenter.x),this.picker_.line.setAttribute("y2",this.picker_.handleCenter.y),this.picker_.handle.setAttribute("cx",this.picker_.handleCenter.x),this.picker_.handle.setAttribute("cy",this.picker_.handleCenter.y),this.enableBackgroundRotation_&&(this.background_.handleCenter=goog.math.Vec2.rotateAroundPoint(this.center_.clone().add(new goog.math.Vec2(this.radius_.x+this.background_.handleRadius,0)),this.center_,goog.math.toRadians(this.background_.angle)),this.background_.handle.setAttribute("cx",this.background_.handleCenter.x),this.background_.handle.setAttribute("cy",this.background_.handleCenter.y)),this.arc_.setAttribute("d",Blockly.AngleHelper.describeArc(this.center_,20,this.background_.angle,this.background_.angle+(this.turnRight_?this.picker_.angle:-this.picker_.angle)))},Blockly.AngleHelper.prototype.startDrag_=function(e){e=new goog.math.Vec2(e.clientX-this.rect_.left,e.clientY-this.rect_.top),this.enableBackgroundRotation_&&goog.math.Vec2.distance(this.background_.handleCenter,e)<this.background_.handleRadius?this.background_.isDragging=!0:this.picker_.isDragging=!0},Blockly.AngleHelper.prototype.updateDrag_=function(e){var t=goog.math.angle(this.center_.x,this.center_.y,e.clientX-this.rect_.left,e.clientY-this.rect_.top);this.picker_.isDragging&&(t=goog.math.standardAngle(t-this.background_.angle),this.turnRight_||(t=goog.math.standardAngle(-t)),this.setAngle(t),this.onUpdate_)&&this.onUpdate_(),this.background_.isDragging&&(this.background_.angle=t,this.update_()),e.stopPropagation(),e.preventDefault()},Blockly.AngleHelper.prototype.stopDrag_=function(){this.picker_.isDragging=!1,this.background_.isDragging=!1},Blockly.AngleHelper.prototype.snap_=function(e){return this.snapPoints_?this.snapPoints_.reduce(function(t,o){return Math.abs(goog.math.angleDifference(o,e))<Math.abs(goog.math.angleDifference(t,e))?o:t}):Math.round(e)},Blockly.AngleHelper.prototype.dispose=function(){this.mouseDownWrapper_&&(Blockly.unbindEvent_(this.mouseDownWrapper_),this.mouseDownWrapper_=null),this.mouseUpWrapper_&&(Blockly.unbindEvent_(this.mouseUpWrapper_),this.mouseUpWrapper_=null),this.mouseMoveWrapper_&&(Blockly.unbindEvent_(this.mouseMoveWrapper_),this.mouseMoveWrapper_=null),goog.dom.removeNode(this.svg_),this.svg_=this.background_=this.picker_=this.arc_=null},Blockly.AngleHelper.describeArc=function(e,t,o,n){var i=e.clone().add(new goog.math.Vec2(t,0)),r=goog.math.Vec2.rotateAroundPoint(i,e,goog.math.toRadians(o));i=goog.math.Vec2.rotateAroundPoint(i,e,goog.math.toRadians(n));var l=180<Math.abs(o-n)?"1":"0";return o=0>n-o?"0":"1",["M",r.x.toFixed(2),r.y.toFixed(2),"A",t,t,0,l,o,i.x.toFixed(2),i.y.toFixed(2),"L",e.x,e.y].join(" ")},Blockly.BlockFieldHelper={ANGLE_HELPER:"Angle Helper"},Blockly.FieldTextInput=function(e,t){Blockly.FieldTextInput.superClass_.constructor.call(this,e),this.changeHandler_=t,this.angleHelper=null},goog.inherits(Blockly.FieldTextInput,Blockly.Field),Blockly.FieldTextInput.prototype.CURSOR="text",Blockly.FieldTextInput.ANGLE_HELPER_SIZE=150,Blockly.FieldTextInput.prototype.dispose=function(){this.angleHelper&&this.angleHelper.dispose(),Blockly.WidgetDiv.hideIfOwner(this),Blockly.FieldTextInput.superClass_.dispose.call(this)},Blockly.FieldTextInput.prototype.setText=function(e){if(null!==e){if(this.changeHandler_){var t=this.changeHandler_(e);null!=t&&(e=t)}Blockly.Field.prototype.setText.call(this,e)}},Blockly.FieldTextInput.prototype.shouldShowAngleHelper_=function(){return this.getFieldHelperOptions_(Blockly.BlockFieldHelper.ANGLE_HELPER)},Blockly.FieldTextInput.prototype.getAngleHelperDirection_=function(){var e=this.getFieldHelperOptions_(Blockly.BlockFieldHelper.ANGLE_HELPER);if(e.direction&&e.directionTitleName)throw"FieldTextInput should not have both a direction and a directionTitleName; please pass at most one of these options";return e.directionTitle?e.block.getTitleValue(e.directionTitle):e.direction?e.direction:"turnRight"},Blockly.FieldTextInput.prototype.showAngleHelper_=function(){var e=Blockly.WidgetDiv.DIV,t=goog.dom.createDom("div","blocklyFieldAngleTextInput");t.style.height=Blockly.FieldTextInput.ANGLE_HELPER_SIZE+"px",t.style.width=Blockly.FieldTextInput.ANGLE_HELPER_SIZE+"px",e.appendChild(t);var o=this.getFieldHelperOptions_(Blockly.BlockFieldHelper.ANGLE_HELPER);e=this.getAngleHelperDirection_(),o=o.block.getHexColour(),this.angleHelper=new Blockly.AngleHelper(e,{onUpdate:function(){var e=this.angleHelper.getAngle().toString();this.setText(e),Blockly.FieldTextInput.htmlInput_.value=e}.bind(this),arcColour:o,height:Blockly.FieldTextInput.ANGLE_HELPER_SIZE,width:Blockly.FieldTextInput.ANGLE_HELPER_SIZE,angle:parseInt(this.getValue()),enableBackgroundRotation:!0}),this.angleHelper.init(t)},Blockly.FieldTextInput.prototype.showEditor_=function(){this.showWidgetDiv_();var e=Blockly.WidgetDiv.DIV,t=goog.dom.createDom("input","blocklyHtmlInput");this.changeHandler_===Blockly.FieldTextInput.numberValidator||this.changeHandler_&&"clampedNumberValidator"===this.changeHandler_.validatorType?(t.setAttribute("type","number"),t.setAttribute("step","any")):this.changeHandler_===Blockly.FieldTextInput.nonnegativeIntegerValidator&&(t.setAttribute("type","number"),t.setAttribute("pattern","\\d*")),Blockly.FieldTextInput.htmlInput_=t,e.appendChild(t),t.value=t.defaultValue=this.text_,t.oldValue_=null,this.validate_(),this.resizeEditor_(),t.focus(),goog.userAgent.IPAD||goog.userAgent.IPHONE?t.setSelectionRange(0,9999):t.select(),t.onKeyUpWrapper_=Blockly.bindEvent_(t,"keydown",this,function(e){e.stopPropagation()}),t.onKeyUpWrapper_=Blockly.bindEvent_(t,"keyup",this,this.onHtmlInputChange_),t.onKeyPressWrapper_=Blockly.bindEvent_(t,"keypress",this,this.onHtmlInputChange_),e=this.sourceBlock_.blockSpace.getCanvas(),t.onBlockSpaceChangeWrapper_=Blockly.bindEvent_(e,"blocklyBlockSpaceChange",this,this.resizeEditor_),this.shouldShowAngleHelper_()&&this.showAngleHelper_()},Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(e){var t=Blockly.FieldTextInput.htmlInput_;13==e.keyCode?(Blockly.WidgetDiv.hide(),e.preventDefault()):27==e.keyCode?(this.setText(t.defaultValue),Blockly.WidgetDiv.hide()):(e=t.value)!==t.oldValue_?(t.oldValue_=e,this.setText(e),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render(),this.angleHelper&&this.angleHelper.animateAngleChange(parseInt(this.getText()))},Blockly.FieldTextInput.prototype.validate_=function(){var e=!0;goog.asserts.assertObject(Blockly.FieldTextInput.htmlInput_);var t=Blockly.FieldTextInput.htmlInput_;this.changeHandler_&&(e=this.changeHandler_(t.value)),null===e?Blockly.addClass_(t,"blocklyInvalidInput"):Blockly.removeClass_(t,"blocklyInvalidInput")},Blockly.FieldTextInput.prototype.resizeEditor_=function(){var e=Blockly.WidgetDiv.DIV;if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){this.fieldGroup_.style.display="inline";var t={x:this.fieldGroup_.getBBox().x,y:this.fieldGroup_.getBBox().y,width:this.fieldGroup_.scrollWidth,height:this.fieldGroup_.scrollHeight}}else t=this.fieldGroup_.getBBox();e.style.width=t.width+"px",this.positionWidgetDiv()},Blockly.FieldTextInput.prototype.positionWidgetDiv=function(){var e=Blockly.getAbsoluteXY_(this.borderRect_,this.getRootSVGElement_());if(Blockly.RTL){if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){this.borderRect_.style.display="inline";var t={x:this.borderRect_.getBBox().x,y:this.borderRect_.getBBox().y,width:this.borderRect_.scrollWidth,height:this.borderRect_.scrollHeight}}else t=this.borderRect_.getBBox();e.x+=t.width,e.x-=Blockly.WidgetDiv.DIV.offsetWidth}e.y+=1,goog.userAgent.WEBKIT&&(e.y-=3),t=goog.dom.getViewportSize();var o=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.position(e.x,e.y,t,o)},Blockly.FieldTextInput.prototype.generateWidgetDisposeHandler_=function(){var e=Blockly.FieldRectangularDropdown.superClass_.generateWidgetDisposeHandler_.call(this);return function(){e();var t=Blockly.FieldTextInput.htmlInput_,o=t.value;this.changeHandler_&&(null===(o=this.changeHandler_(o))&&(o=t.defaultValue)),this.setText(o),this.sourceBlock_.rendered&&this.sourceBlock_.render(),Blockly.unbindEvent_(t.onKeyUpWrapper_),Blockly.unbindEvent_(t.onKeyPressWrapper_),Blockly.unbindEvent_(t.onBlockSpaceChangeWrapper_),Blockly.FieldTextInput.htmlInput_=null,Blockly.WidgetDiv.DIV.style.width="auto"}.bind(this)},Blockly.FieldTextInput.prototype.isKeyboardInputField_=function(){return!0},Blockly.FieldTextInput.numberValidator=function(e){return e=(e=(e||"").replace(/O/gi,"0")).replace(/,/g,""),e=parseFloat(e||0),isNaN(e)?null:String(e)},Blockly.FieldTextInput.nonnegativeIntegerValidator=function(e){return(e=Blockly.FieldTextInput.numberValidator(e))&&(e=String(Math.max(0,Math.floor(e)))),e},Blockly.FieldTextInput.clampedNumberValidator=function(e,t){var o=function(o){return o=Blockly.FieldTextInput.numberValidator(o),isNaN(parseFloat(e))||(o=Math.max(e,o)),isNaN(parseFloat(t))||(o=Math.min(t,o)),String(o)};return o.validatorType="clampedNumberValidator",o},Blockly.FieldAngle=function(e,t){if(t)var o=this,n=function(e){return null!==(e=Blockly.FieldAngle.angleValidator.call(o,e))&&t.call(o,e),e};else n=Blockly.FieldAngle.angleValidator;this.symbol_=Blockly.createSvgElement("tspan",{},null),this.symbol_.appendChild(document.createTextNode("°")),Blockly.FieldAngle.superClass_.constructor.call(this,e,n)},goog.inherits(Blockly.FieldAngle,Blockly.FieldTextInput),Blockly.FieldAngle.HALF=50,Blockly.FieldAngle.RADIUS=Blockly.FieldAngle.HALF-1,Blockly.FieldAngle.prototype.dispose_=function(){var e=this;return function(){Blockly.FieldAngle.superClass_.dispose_.call(e)(),e.gauge_=null,e.clickWrapper_&&Blockly.unbindEvent_(e.clickWrapper_),e.moveWrapper1_&&Blockly.unbindEvent_(e.moveWrapper1_),e.moveWrapper2_&&Blockly.unbindEvent_(e.moveWrapper2_)}},Blockly.FieldAngle.prototype.showEditor_=function(){Blockly.FieldAngle.superClass_.showEditor_.call(this);var e=Blockly.WidgetDiv.DIV;if(e.firstChild){e=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1",height:2*Blockly.FieldAngle.HALF+"px",width:2*Blockly.FieldAngle.HALF+"px"},e);var t=Blockly.createSvgElement("circle",{cx:Blockly.FieldAngle.HALF,cy:Blockly.FieldAngle.HALF,r:Blockly.FieldAngle.RADIUS,class:"blocklyAngleCircle"},e);this.gauge_=Blockly.createSvgElement("path",{class:"blocklyAngleGuage"},e);for(var o=0;360>o;o+=15)Blockly.createSvgElement("line",{x1:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS,y1:Blockly.FieldAngle.HALF,x2:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS-(0==o%45?10:5),y2:Blockly.FieldAngle.HALF,class:"blocklyAngleMarks",transform:"rotate("+o+", "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF+")"},e);e.style.marginLeft="-35px",this.clickWrapper_=Blockly.bindEvent_(e,"click",this,Blockly.WidgetDiv.hide),this.moveWrapper1_=Blockly.bindEvent_(t,"mousemove",this,this.onMouseMove),this.moveWrapper2_=Blockly.bindEvent_(this.gauge_,"mousemove",this,this.onMouseMove),this.updateGraph()}},Blockly.FieldAngle.prototype.onMouseMove=function(e){var t=this.gauge_.ownerSVGElement.getBoundingClientRect(),o=e.clientX-t.left-Blockly.FieldAngle.HALF;e=e.clientY-t.top-Blockly.FieldAngle.HALF,t=Math.atan(-e/o),isNaN(t)||(t=t/Math.PI*180,0>o?t+=180:0<e&&(t+=360),t=String(Math.round(t)),Blockly.FieldTextInput.htmlInput_.value=t,this.setText(t))},Blockly.FieldAngle.prototype.setText=function(e){Blockly.FieldAngle.superClass_.setText.call(this,e),this.updateGraph(),Blockly.RTL?this.textElement_.insertBefore(this.symbol_,this.textElement_.firstChild):this.textElement_.appendChild(this.symbol_),this.size_.width=0},Blockly.FieldAngle.prototype.updateGraph=function(){if(this.gauge_){var e=Number(this.getText())/180*Math.PI;isNaN(e)?this.gauge_.setAttribute("d","M "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF):this.gauge_.setAttribute("d","M "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF+" h "+Blockly.FieldAngle.RADIUS+" A "+Blockly.FieldAngle.RADIUS+","+Blockly.FieldAngle.RADIUS+" 0 "+(e>Math.PI?1:0)+" 0 "+(Blockly.FieldAngle.HALF+Math.cos(e)*Blockly.FieldAngle.RADIUS)+","+(Blockly.FieldAngle.HALF+Math.sin(e)*-Blockly.FieldAngle.RADIUS)+" z")}},Blockly.FieldAngle.angleValidator=function(e){return null!==(e=Blockly.FieldTextInput.numberValidator(e))&&(0>(e%=360)&&(e+=360),e=String(e)),e};var CORNER_RADIUS=3,INNER_HEIGHT=17,Y_OFFSET=-13;function chooseNumberOfColumns(e){return Math.max(4,Math.floor(Math.sqrt(e)))}function getAllBehaviorPickerBlocks(){return Blockly.mainBlockSpace.getAllBlocks().filter(function(e){return"gamelab_behaviorPicker"===e.type})}function updateBehaviorPickerFields(e,t,o){if("gamelab_behaviorPicker"===e.type){var n=e.getFieldValue("BEHAVIOR");n===t&&-1<getAllBehaviorsIds().indexOf(t)?e.setTitleValue(t,"BEHAVIOR"):-1===getAllBehaviorsIds().indexOf(n)&&-1<getAllBehaviorsIds().indexOf(o)&&e.setTitleValue(o,"BEHAVIOR")}}function resetDeletedBehaviorPickerFields(e,t){"gamelab_behaviorPicker"===e.type&&e.getFieldValue("BEHAVIOR")===t&&e.setTitleValue(Blockly.FieldDropdown.NO_OPTIONS_MESSAGE,"BEHAVIOR")}function getAllBehaviorsIds(){return Blockly.mainBlockSpace.getAllBlocks().filter(function(e){return"behavior_definition"===e.type}).map(function(e){return e.getProcedureInfo().id})}Blockly.FieldButton=function(e,t,o,n){Blockly.FieldButton.superClass_.constructor.call(this,""),this.changeHandler_=n,this.buttonHandler_=t,this.borderRect_.setAttribute("height",INNER_HEIGHT+2),this.borderRect_.setAttribute("y",Y_OFFSET-1),this.buttonElement_=Blockly.createSvgElement("rect",{rx:CORNER_RADIUS,ry:CORNER_RADIUS,x:-Blockly.BlockSvg.SEP_SPACE_X/2+1,y:Y_OFFSET,height:INNER_HEIGHT},this.fieldGroup_),this.buttonElement_.style.fillOpacity=1,this.buttonElement_.style.fill=o,this.fieldGroup_.insertBefore(this.buttonElement_,this.textElement_),this.textElement_.style.fontSize="11pt",this.textElement_.style.fill="white",goog.isString(e)?this.setText(e):(this.textElement_.textContent="",this.textElement_.appendChild(e))},goog.inherits(Blockly.FieldButton,Blockly.Field),Blockly.FieldButton.prototype.CURSOR="pointer",Blockly.FieldButton.prototype.getValue=function(){return String(this.value_)},Blockly.FieldButton.prototype.setValue=function(e){if(this.value_!==e){if(this.changeHandler_){var t=this.changeHandler_(e);void 0!==t&&(e=t)}this.value_=e,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.blockSpace.fireChangeEvent()}},Blockly.FieldButton.prototype.showEditor_=function(){this.buttonHandler_&&this.buttonHandler_(this.setValue.bind(this))},Blockly.FieldButton.prototype.updateWidth_=function(){Blockly.FieldButton.superClass_.updateWidth_.call(this),this.buttonElement_&&this.buttonElement_.setAttribute("width",this.size_.width+Blockly.BlockSvg.SEP_SPACE_X-2)},goog.color={},goog.color.names={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},goog.color.parse=function(e){var t={};e=String(e);var o=goog.color.prependHashIfNecessaryHelper(e);if(goog.color.isValidHexColor_(o))return t.hex=goog.color.normalizeHex(o),t.type="hex",t;if((o=goog.color.isValidRgbColor_(e)).length)return t.hex=goog.color.rgbArrayToHex(o),t.type="rgb",t;if(goog.color.names&&(o=goog.color.names[e.toLowerCase()]))return t.hex=o,t.type="named",t;throw Error(e+" is not a valid color string")},goog.color.isValidColor=function(e){var t=goog.color.prependHashIfNecessaryHelper(e);return!!(goog.color.isValidHexColor_(t)||goog.color.isValidRgbColor_(e).length||goog.color.names&&goog.color.names[e.toLowerCase()])},goog.color.parseRgb=function(e){var t=goog.color.isValidRgbColor_(e);if(!t.length)throw Error(e+" is not a valid RGB color");return t},goog.color.hexToRgbStyle=function(e){return goog.color.rgbStyle_(goog.color.hexToRgb(e))},goog.color.hexTripletRe_=/#(.)(.)(.)/,goog.color.normalizeHex=function(e){if(!goog.color.isValidHexColor_(e))throw Error("'"+e+"' is not a valid hex color");return 4==e.length&&(e=e.replace(goog.color.hexTripletRe_,"#$1$1$2$2$3$3")),e.toLowerCase()},goog.color.hexToRgb=function(e){return e=goog.color.normalizeHex(e),[parseInt(e.substr(1,2),16),parseInt(e.substr(3,2),16),e=parseInt(e.substr(5,2),16)]},goog.color.rgbToHex=function(e,t,o){if(e=Number(e),t=Number(t),o=Number(o),e!=(255&e)||t!=(255&t)||o!=(255&o))throw Error('"('+e+","+t+","+o+'") is not a valid RGB color');return"#"+(e=goog.color.prependZeroIfNecessaryHelper(e.toString(16)))+(t=goog.color.prependZeroIfNecessaryHelper(t.toString(16)))+(o=goog.color.prependZeroIfNecessaryHelper(o.toString(16)))},goog.color.rgbArrayToHex=function(e){return goog.color.rgbToHex(e[0],e[1],e[2])},goog.color.rgbToHsl=function(e,t,o){e/=255,t/=255,o/=255;var n=Math.max(e,t,o),i=Math.min(e,t,o),r=0,l=0,s=.5*(n+i);return n!=i&&(n==e?r=60*(t-o)/(n-i):n==t?r=60*(o-e)/(n-i)+120:n==o&&(r=60*(e-t)/(n-i)+240),l=0<s&&.5>=s?(n-i)/(2*s):(n-i)/(2-2*s)),[Math.round(r+360)%360,l,s]},goog.color.rgbArrayToHsl=function(e){return goog.color.rgbToHsl(e[0],e[1],e[2])},goog.color.hueToRgb_=function(e,t,o){return 0>o?o+=1:1<o&&--o,1>6*o?e+6*(t-e)*o:1>2*o?t:2>3*o?e+(t-e)*(2/3-o)*6:e},goog.color.hslToRgb=function(e,t,o){if(e/=360,0==t)o=t=e=255*o;else{var n=.5>o?o*(1+t):o+t-t*o,i=2*o-n;o=255*goog.color.hueToRgb_(i,n,e+1/3),t=255*goog.color.hueToRgb_(i,n,e),e=255*goog.color.hueToRgb_(i,n,e-1/3)}return[Math.round(o),Math.round(t),Math.round(e)]},goog.color.hslArrayToRgb=function(e){return goog.color.hslToRgb(e[0],e[1],e[2])},goog.color.validHexColorRe_=/^#(?:[0-9a-f]{3}){1,2}$/i,goog.color.isValidHexColor_=function(e){return goog.color.validHexColorRe_.test(e)},goog.color.normalizedHexColorRe_=/^#[0-9a-f]{6}$/,goog.color.isNormalizedHexColor_=function(e){return goog.color.normalizedHexColorRe_.test(e)},goog.color.rgbColorRe_=/^(?:rgb)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2})\)$/i,goog.color.isValidRgbColor_=function(e){var t=e.match(goog.color.rgbColorRe_);if(t){e=Number(t[1]);var o=Number(t[2]);if(t=Number(t[3]),0<=e&&255>=e&&0<=o&&255>=o&&0<=t&&255>=t)return[e,o,t]}return[]},goog.color.prependZeroIfNecessaryHelper=function(e){return 1==e.length?"0"+e:e},goog.color.prependHashIfNecessaryHelper=function(e){return"#"==e.charAt(0)?e:"#"+e},goog.color.rgbStyle_=function(e){return"rgb("+e.join(",")+")"},goog.color.hsvToRgb=function(e,t,o){var n=0,i=0,r=0;if(0==t)r=i=n=o;else{var l=Math.floor(e/60),s=e/60-l;e=o*(1-t);var a=o*(1-t*s);switch(t=o*(1-t*(1-s)),l){case 1:n=a,i=o,r=e;break;case 2:n=e,i=o,r=t;break;case 3:n=e,i=a,r=o;break;case 4:n=t,i=e,r=o;break;case 5:n=o,i=e,r=a;break;case 6:case 0:n=o,i=t,r=e}}return[Math.floor(n),Math.floor(i),Math.floor(r)]},goog.color.rgbToHsv=function(e,t,o){var n=Math.max(Math.max(e,t),o),i=Math.min(Math.min(e,t),o);if(i==n)i=e=0;else{var r=n-i;i=r/n,0>(e=60*(e==n?(t-o)/r:t==n?2+(o-e)/r:4+(e-t)/r))&&(e+=360),360<e&&(e-=360)}return[e,i,n]},goog.color.rgbArrayToHsv=function(e){return goog.color.rgbToHsv(e[0],e[1],e[2])},goog.color.hsvArrayToRgb=function(e){return goog.color.hsvToRgb(e[0],e[1],e[2])},goog.color.hexToHsl=function(e){return e=goog.color.hexToRgb(e),goog.color.rgbToHsl(e[0],e[1],e[2])},goog.color.hslToHex=function(e,t,o){return goog.color.rgbArrayToHex(goog.color.hslToRgb(e,t,o))},goog.color.hslArrayToHex=function(e){return goog.color.rgbArrayToHex(goog.color.hslToRgb(e[0],e[1],e[2]))},goog.color.hexToHsv=function(e){return goog.color.rgbArrayToHsv(goog.color.hexToRgb(e))},goog.color.hsvToHex=function(e,t,o){return goog.color.rgbArrayToHex(goog.color.hsvToRgb(e,t,o))},goog.color.hsvArrayToHex=function(e){return goog.color.hsvToHex(e[0],e[1],e[2])},goog.color.hslDistance=function(e,t){var o=.5>=e[2]?e[1]*e[2]:e[1]*(1-e[2]),n=.5>=t[2]?t[1]*t[2]:t[1]*(1-t[2]);return(e[2]-t[2])*(e[2]-t[2])+o*o+n*n-2*o*n*Math.cos(2*(e[0]/360-t[0]/360)*Math.PI)},goog.color.blend=function(e,t,o){return o=goog.math.clamp(o,0,1),[Math.round(o*e[0]+(1-o)*t[0]),Math.round(o*e[1]+(1-o)*t[1]),Math.round(o*e[2]+(1-o)*t[2])]},goog.color.darken=function(e,t){return goog.color.blend([0,0,0],e,t)},goog.color.lighten=function(e,t){return goog.color.blend([255,255,255],e,t)},goog.color.highContrast=function(e,t){for(var o=[],n=0;n<t.length;n++)o.push({color:t[n],diff:goog.color.yiqBrightnessDiff_(t[n],e)+goog.color.colorDiff_(t[n],e)});return o.sort(function(e,t){return t.diff-e.diff}),o[0].color},goog.color.yiqBrightness_=function(e){return Math.round((299*e[0]+587*e[1]+114*e[2])/1e3)},goog.color.yiqBrightnessDiff_=function(e,t){return Math.abs(goog.color.yiqBrightness_(e)-goog.color.yiqBrightness_(t))},goog.color.colorDiff_=function(e,t){return Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1])+Math.abs(e[2]-t[2])},goog.iter={},goog.iter.StopIteration="StopIteration"in goog.global?goog.global.StopIteration:{message:"StopIteration",stack:""},goog.iter.Iterator=function(){},goog.iter.Iterator.prototype.next=function(){throw goog.iter.StopIteration},goog.iter.Iterator.prototype.__iterator__=function(e){return this},goog.iter.toIterator=function(e){if(e instanceof goog.iter.Iterator)return e;if("function"==typeof e.__iterator__)return e.__iterator__(!1);if(goog.isArrayLike(e)){var t=0,o=new goog.iter.Iterator;return o.next=function(){for(;;){if(t>=e.length)throw goog.iter.StopIteration;if(t in e)return e[t++];t++}},o}throw Error("Not implemented")},goog.iter.forEach=function(e,t,o){if(goog.isArrayLike(e))try{goog.array.forEach(e,t,o)}catch(e){if(e!==goog.iter.StopIteration)throw e}else{e=goog.iter.toIterator(e);try{for(;;)t.call(o,e.next(),void 0,e)}catch(e){if(e!==goog.iter.StopIteration)throw e}}},goog.iter.filter=function(e,t,o){var n=goog.iter.toIterator(e);return(e=new goog.iter.Iterator).next=function(){for(;;){var e=n.next();if(t.call(o,e,void 0,n))return e}},e},goog.iter.filterFalse=function(e,t,o){return goog.iter.filter(e,goog.functions.not(t),o)},goog.iter.range=function(e,t,o){var n=0,i=e,r=o||1;if(1<arguments.length&&(n=e,i=t),0==r)throw Error("Range step argument must not be zero");var l=new goog.iter.Iterator;return l.next=function(){if(0<r&&n>=i||0>r&&n<=i)throw goog.iter.StopIteration;var e=n;return n+=r,e},l},goog.iter.join=function(e,t){return goog.iter.toArray(e).join(t)},goog.iter.map=function(e,t,o){var n=goog.iter.toIterator(e);return(e=new goog.iter.Iterator).next=function(){var e=n.next();return t.call(o,e,void 0,n)},e},goog.iter.reduce=function(e,t,o,n){var i=o;return goog.iter.forEach(e,function(e){i=t.call(n,i,e)}),i},goog.iter.some=function(e,t,o){e=goog.iter.toIterator(e);try{for(;;)if(t.call(o,e.next(),void 0,e))return!0}catch(e){if(e!==goog.iter.StopIteration)throw e}return!1},goog.iter.every=function(e,t,o){e=goog.iter.toIterator(e);try{for(;;)if(!t.call(o,e.next(),void 0,e))return!1}catch(e){if(e!==goog.iter.StopIteration)throw e}return!0},goog.iter.chain=function(e){return goog.iter.chainFromIterable(arguments)},goog.iter.chainFromIterable=function(e){var t=goog.iter.toIterator(e);e=new goog.iter.Iterator;var o=null;return e.next=function(){for(;;){if(null==o){var e=t.next();o=goog.iter.toIterator(e)}try{return o.next()}catch(e){if(e!==goog.iter.StopIteration)throw e;o=null}}},e},goog.iter.dropWhile=function(e,t,o){var n=goog.iter.toIterator(e);e=new goog.iter.Iterator;var i=!0;return e.next=function(){for(;;){var e=n.next();if(!i||!t.call(o,e,void 0,n))return i=!1,e}},e},goog.iter.takeWhile=function(e,t,o){var n=goog.iter.toIterator(e);return(e=new goog.iter.Iterator).next=function(){var e=n.next();if(t.call(o,e,void 0,n))return e;throw goog.iter.StopIteration},e},goog.iter.toArray=function(e){if(goog.isArrayLike(e))return goog.array.toArray(e);e=goog.iter.toIterator(e);var t=[];return goog.iter.forEach(e,function(e){t.push(e)}),t},goog.iter.equals=function(e,t,o){e=goog.iter.zipLongest({},e,t);var n=o||goog.array.defaultCompareEquality;return goog.iter.every(e,function(e){return n(e[0],e[1])})},goog.iter.nextOrValue=function(e,t){try{return goog.iter.toIterator(e).next()}catch(e){if(e!=goog.iter.StopIteration)throw e;return t}},goog.iter.product=function(e){if(goog.array.some(arguments,function(e){return!e.length})||!arguments.length)return new goog.iter.Iterator;var t=new goog.iter.Iterator,o=arguments,n=goog.array.repeat(0,o.length);return t.next=function(){if(n){for(var e=goog.array.map(n,function(e,t){return o[t][e]}),t=n.length-1;0<=t;t--){if(goog.asserts.assert(n),n[t]<o[t].length-1){n[t]++;break}if(0==t){n=null;break}n[t]=0}return e}throw goog.iter.StopIteration},t},goog.iter.cycle=function(e){var t=goog.iter.toIterator(e),o=[],n=0;e=new goog.iter.Iterator;var i=!1;return e.next=function(){var e=null;if(!i)try{return e=t.next(),o.push(e),e}catch(e){if(e!=goog.iter.StopIteration||goog.array.isEmpty(o))throw e;i=!0}return e=o[n],n=(n+1)%o.length,e},e},goog.iter.count=function(e,t){var o=e||0,n=goog.isDef(t)?t:1;return(e=new goog.iter.Iterator).next=function(){var e=o;return o+=n,e},e},goog.iter.repeat=function(e){var t=new goog.iter.Iterator;return t.next=goog.functions.constant(e),t},goog.iter.accumulate=function(e){var t=goog.iter.toIterator(e),o=0;return(e=new goog.iter.Iterator).next=function(){return o+=t.next()},e},goog.iter.zip=function(e){var t=arguments,o=new goog.iter.Iterator;if(0<t.length){var n=goog.array.map(t,goog.iter.toIterator);o.next=function(){return goog.array.map(n,function(e){return e.next()})}}return o},goog.iter.zipLongest=function(e,t){var o=goog.array.slice(arguments,1),n=new goog.iter.Iterator;if(0<o.length){var i=goog.array.map(o,goog.iter.toIterator);n.next=function(){var t=!1,o=goog.array.map(i,function(o){try{var n=o.next();t=!0}catch(t){if(t!==goog.iter.StopIteration)throw t;n=e}return n});if(!t)throw goog.iter.StopIteration;return o}}return n},goog.iter.compress=function(e,t){var o=goog.iter.toIterator(t);return goog.iter.filter(e,function(){return!!o.next()})},goog.iter.GroupByIterator_=function(e,t){this.iterator=goog.iter.toIterator(e),this.keyFunc=t||goog.functions.identity},goog.inherits(goog.iter.GroupByIterator_,goog.iter.Iterator),goog.iter.GroupByIterator_.prototype.next=function(){for(;this.currentKey==this.targetKey;)this.currentValue=this.iterator.next(),this.currentKey=this.keyFunc(this.currentValue);return this.targetKey=this.currentKey,[this.currentKey,this.groupItems_(this.targetKey)]},goog.iter.GroupByIterator_.prototype.groupItems_=function(e){for(var t=[];this.currentKey==e;){t.push(this.currentValue);try{this.currentValue=this.iterator.next()}catch(e){if(e!==goog.iter.StopIteration)throw e;break}this.currentKey=this.keyFunc(this.currentValue)}return t},goog.iter.groupBy=function(e,t){return new goog.iter.GroupByIterator_(e,t)},goog.iter.starMap=function(e,t,o){var n=goog.iter.toIterator(e);return(e=new goog.iter.Iterator).next=function(){var e=goog.iter.toArray(n.next());return t.apply(o,goog.array.concat(e,void 0,n))},e},goog.iter.tee=function(e,t){var o=goog.iter.toIterator(e);e=goog.isNumber(t)?t:2;var n=goog.array.map(goog.array.range(e),function(){return[]});return goog.array.map(n,function(e){var t=new goog.iter.Iterator;return t.next=function(){return goog.array.isEmpty(e)&&function(){var e=o.next();goog.array.forEach(n,function(t){t.push(e)})}(),goog.asserts.assert(!goog.array.isEmpty(e)),e.shift()},t})},goog.iter.enumerate=function(e,t){return goog.iter.zip(goog.iter.count(t),e)},goog.iter.limit=function(e,t){goog.asserts.assert(goog.math.isInt(t)&&0<=t);var o=goog.iter.toIterator(e);e=new goog.iter.Iterator;var n=t;return e.next=function(){if(0<n--)return o.next();throw goog.iter.StopIteration},e},goog.iter.consume=function(e,t){for(goog.asserts.assert(goog.math.isInt(t)&&0<=t),e=goog.iter.toIterator(e);0<t--;)goog.iter.nextOrValue(e,null);return e},goog.iter.slice=function(e,t,o){return goog.asserts.assert(goog.math.isInt(t)&&0<=t),e=goog.iter.consume(e,t),goog.isNumber(o)&&(goog.asserts.assert(goog.math.isInt(o)&&o>=t),e=goog.iter.limit(e,o-t)),e},goog.iter.hasDuplicates_=function(e){var t=[];return goog.array.removeDuplicates(e,t),e.length!=t.length},goog.iter.permutations=function(e,t){return e=goog.iter.toArray(e),t=goog.isNumber(t)?t:e.length,t=goog.array.repeat(e,t),t=goog.iter.product.apply(void 0,t),goog.iter.filter(t,function(e){return!goog.iter.hasDuplicates_(e)})},goog.iter.combinations=function(e,t){function o(e){return n[e]}var n=goog.iter.toArray(e);e=goog.iter.range(n.length),t=goog.iter.permutations(e,t);var i=goog.iter.filter(t,function(e){return goog.array.isSorted(e)});return(t=new goog.iter.Iterator).next=function(){return goog.array.map(i.next(),o)},t},goog.iter.combinationsWithReplacement=function(e,t){function o(e){return n[e]}var n=goog.iter.toArray(e);e=goog.array.range(n.length),t=goog.array.repeat(e,t),t=goog.iter.product.apply(void 0,t);var i=goog.iter.filter(t,function(e){return goog.array.isSorted(e)});return(t=new goog.iter.Iterator).next=function(){return goog.array.map(i.next(),o)},t},goog.dom.TagWalkType={START_TAG:1,OTHER:0,END_TAG:-1},goog.dom.TagIterator=function(e,t,o,n,i){this.reversed=!!t,this.node=null,this.tagType=goog.dom.TagWalkType.OTHER,this.started_=!1,this.constrained=!o,e&&this.setPosition(e,n),this.depth=null!=i?i:this.tagType||0,this.reversed&&(this.depth*=-1)},goog.inherits(goog.dom.TagIterator,goog.iter.Iterator),goog.dom.TagIterator.prototype.setPosition=function(e,t,o){(this.node=e)&&(goog.isNumber(t)?this.tagType=t:this.tagType=this.node.nodeType!=goog.dom.NodeType.ELEMENT?goog.dom.TagWalkType.OTHER:this.reversed?goog.dom.TagWalkType.END_TAG:goog.dom.TagWalkType.START_TAG),goog.isNumber(o)&&(this.depth=o)},goog.dom.TagIterator.prototype.copyFrom=function(e){this.node=e.node,this.tagType=e.tagType,this.depth=e.depth,this.reversed=e.reversed,this.constrained=e.constrained},goog.dom.TagIterator.prototype.clone=function(){return new goog.dom.TagIterator(this.node,this.reversed,!this.constrained,this.tagType,this.depth)},goog.dom.TagIterator.prototype.skipTag=function(){var e=this.reversed?goog.dom.TagWalkType.END_TAG:goog.dom.TagWalkType.START_TAG;this.tagType==e&&(this.tagType=-1*e,this.depth+=this.tagType*(this.reversed?-1:1))},goog.dom.TagIterator.prototype.restartTag=function(){var e=this.reversed?goog.dom.TagWalkType.START_TAG:goog.dom.TagWalkType.END_TAG;this.tagType==e&&(this.tagType=-1*e,this.depth+=this.tagType*(this.reversed?-1:1))},goog.dom.TagIterator.prototype.next=function(){if(this.started_){if(!this.node||this.constrained&&0==this.depth)throw goog.iter.StopIteration;var e=this.node,t=this.reversed?goog.dom.TagWalkType.END_TAG:goog.dom.TagWalkType.START_TAG;if(this.tagType==t){var o=this.reversed?e.lastChild:e.firstChild;o?this.setPosition(o):this.setPosition(e,-1*t)}else(o=this.reversed?e.previousSibling:e.nextSibling)?this.setPosition(o):this.setPosition(e.parentNode,-1*t);this.depth+=this.tagType*(this.reversed?-1:1)}else this.started_=!0;if(e=this.node,!this.node)throw goog.iter.StopIteration;return e},goog.dom.TagIterator.prototype.isStarted=function(){return this.started_},goog.dom.TagIterator.prototype.isStartTag=function(){return this.tagType==goog.dom.TagWalkType.START_TAG},goog.dom.TagIterator.prototype.isEndTag=function(){return this.tagType==goog.dom.TagWalkType.END_TAG},goog.dom.TagIterator.prototype.isNonElement=function(){return this.tagType==goog.dom.TagWalkType.OTHER},goog.dom.TagIterator.prototype.equals=function(e){return e.node==this.node&&(!this.node||e.tagType==this.tagType)},goog.dom.TagIterator.prototype.splice=function(e){var t=this.node;this.restartTag(),this.reversed=!this.reversed,goog.dom.TagIterator.prototype.next.call(this),this.reversed=!this.reversed;for(var o=goog.isArrayLike(arguments[0])?arguments[0]:arguments,n=o.length-1;0<=n;n--)goog.dom.insertSiblingAfter(o[n],t);goog.dom.removeNode(t)},goog.dom.NodeIterator=function(e,t,o,n){goog.dom.TagIterator.call(this,e,t,o,null,n)},goog.inherits(goog.dom.NodeIterator,goog.dom.TagIterator),goog.dom.NodeIterator.prototype.next=function(){do{goog.dom.NodeIterator.superClass_.next.call(this)}while(this.isEndTag());return this.node},goog.ui.PaletteRenderer=function(){goog.ui.ControlRenderer.call(this)},goog.inherits(goog.ui.PaletteRenderer,goog.ui.ControlRenderer),goog.addSingletonGetter(goog.ui.PaletteRenderer),goog.ui.PaletteRenderer.cellId_=0,goog.ui.PaletteRenderer.CSS_CLASS="goog-palette",goog.ui.PaletteRenderer.prototype.createDom=function(e){var t=this.getClassNames(e);return e=e.getDomHelper().createDom("DIV",t?t.join(" "):null,this.createGrid(e.getContent(),e.getSize(),e.getDomHelper())),goog.a11y.aria.setRole(e,goog.a11y.aria.Role.GRID),e},goog.ui.PaletteRenderer.prototype.createGrid=function(e,t,o){for(var n=[],i=0,r=0;i<t.height;i++){for(var l=[],s=0;s<t.width;s++){var a=e&&e[r++];l.push(this.createCell(a,o))}n.push(this.createRow(l,o))}return this.createTable(n,o)},goog.ui.PaletteRenderer.prototype.createTable=function(e,t){return(e=t.createDom("TABLE",this.getCssClass()+"-table",t.createDom("TBODY",this.getCssClass()+"-body",e))).cellSpacing="0",e.cellPadding="0",e},goog.ui.PaletteRenderer.prototype.createRow=function(e,t){return e=t.createDom("TR",this.getCssClass()+"-row",e),goog.a11y.aria.setRole(e,goog.a11y.aria.Role.ROW),e},goog.ui.PaletteRenderer.prototype.createCell=function(e,t){return e=t.createDom("TD",{class:this.getCssClass()+"-cell",id:this.getCssClass()+"-cell-"+goog.ui.PaletteRenderer.cellId_++},e),goog.a11y.aria.setRole(e,goog.a11y.aria.Role.GRIDCELL),goog.a11y.aria.setState(e,goog.a11y.aria.State.SELECTED,!1),goog.dom.getTextContent(e)||goog.a11y.aria.getLabel(e)||(t=this.findAriaLabelForCell_(e))&&goog.a11y.aria.setLabel(e,t),e},goog.ui.PaletteRenderer.prototype.findAriaLabelForCell_=function(e){e=new goog.dom.NodeIterator(e);for(var t,o="";!o&&(t=goog.iter.nextOrValue(e,null));)t.nodeType==goog.dom.NodeType.ELEMENT&&(o=goog.a11y.aria.getLabel(t)||t.title);return o},goog.ui.PaletteRenderer.prototype.canDecorate=function(e){return!1},goog.ui.PaletteRenderer.prototype.decorate=function(e,t){return null},goog.ui.PaletteRenderer.prototype.setContent=function(e,t){if(e){var o=goog.dom.getElementsByTagNameAndClass("TBODY",this.getCssClass()+"-body",e)[0];if(o){var n=0;if(goog.array.forEach(o.rows,function(e){goog.array.forEach(e.cells,function(e){if(goog.dom.removeChildren(e),t){var o=t[n++];o&&goog.dom.appendChild(e,o)}})}),n<t.length){for(var i=[],r=goog.dom.getDomHelper(e),l=o.rows[0].cells.length;n<t.length;){var s=t[n++];i.push(this.createCell(s,r)),i.length==l&&(s=this.createRow(i,r),goog.dom.appendChild(o,s),i.length=0)}if(0<i.length){for(;i.length<l;)i.push(this.createCell("",r));s=this.createRow(i,r),goog.dom.appendChild(o,s)}}}goog.style.setUnselectable(e,!0,goog.userAgent.GECKO)}},goog.ui.PaletteRenderer.prototype.getContainingItem=function(e,t){for(e=e.getElement();t&&t.nodeType==goog.dom.NodeType.ELEMENT&&t!=e;){if("TD"==t.tagName&&goog.dom.classlist.contains(t,this.getCssClass()+"-cell"))return t.firstChild;t=t.parentNode}return null},goog.ui.PaletteRenderer.prototype.highlightCell=function(e,t,o){t&&(t=this.getCellForItem(t),goog.asserts.assert(t),goog.dom.classlist.enable(t,this.getCssClass()+"-cell-hover",o),o?goog.a11y.aria.setState(e.getElementStrict(),goog.a11y.aria.State.ACTIVEDESCENDANT,t.id):t.id==goog.a11y.aria.getState(e.getElementStrict(),goog.a11y.aria.State.ACTIVEDESCENDANT)&&goog.a11y.aria.removeState(e.getElementStrict(),goog.a11y.aria.State.ACTIVEDESCENDANT))},goog.ui.PaletteRenderer.prototype.getCellForItem=function(e){return e?e.parentNode:null},goog.ui.PaletteRenderer.prototype.selectCell=function(e,t,o){t&&(e=t.parentNode,goog.dom.classlist.enable(e,this.getCssClass()+"-cell-selected",o),goog.a11y.aria.setState(e,goog.a11y.aria.State.SELECTED,o))},goog.ui.PaletteRenderer.prototype.getCssClass=function(){return goog.ui.PaletteRenderer.CSS_CLASS},goog.ui.SelectionModel=function(e){goog.events.EventTarget.call(this),this.items_=[],this.addItems(e)},goog.inherits(goog.ui.SelectionModel,goog.events.EventTarget),goog.tagUnsealableClass(goog.ui.SelectionModel),goog.ui.SelectionModel.prototype.selectedItem_=null,goog.ui.SelectionModel.prototype.selectionHandler_=null,goog.ui.SelectionModel.prototype.getSelectionHandler=function(){return this.selectionHandler_},goog.ui.SelectionModel.prototype.setSelectionHandler=function(e){this.selectionHandler_=e},goog.ui.SelectionModel.prototype.getItemCount=function(){return this.items_.length},goog.ui.SelectionModel.prototype.indexOfItem=function(e){return e?goog.array.indexOf(this.items_,e):-1},goog.ui.SelectionModel.prototype.getFirst=function(){return this.items_[0]},goog.ui.SelectionModel.prototype.getLast=function(){return this.items_[this.items_.length-1]},goog.ui.SelectionModel.prototype.getItemAt=function(e){return this.items_[e]||null},goog.ui.SelectionModel.prototype.addItems=function(e){e&&(goog.array.forEach(e,function(e){this.selectItem_(e,!1)},this),goog.array.extend(this.items_,e))},goog.ui.SelectionModel.prototype.addItem=function(e){this.addItemAt(e,this.getItemCount())},goog.ui.SelectionModel.prototype.addItemAt=function(e,t){e&&(this.selectItem_(e,!1),goog.array.insertAt(this.items_,e,t))},goog.ui.SelectionModel.prototype.removeItem=function(e){e&&goog.array.remove(this.items_,e)&&e==this.selectedItem_&&(this.selectedItem_=null,this.dispatchEvent(goog.events.EventType.SELECT))},goog.ui.SelectionModel.prototype.removeItemAt=function(e){this.removeItem(this.getItemAt(e))},goog.ui.SelectionModel.prototype.getSelectedItem=function(){return this.selectedItem_},goog.ui.SelectionModel.prototype.getItems=function(){return goog.array.clone(this.items_)},goog.ui.SelectionModel.prototype.setSelectedItem=function(e){e!=this.selectedItem_&&(this.selectItem_(this.selectedItem_,!1),this.selectedItem_=e,this.selectItem_(e,!0)),this.dispatchEvent(goog.events.EventType.SELECT)},goog.ui.SelectionModel.prototype.getSelectedIndex=function(){return this.indexOfItem(this.selectedItem_)},goog.ui.SelectionModel.prototype.setSelectedIndex=function(e){this.setSelectedItem(this.getItemAt(e))},goog.ui.SelectionModel.prototype.clear=function(){goog.array.clear(this.items_),this.selectedItem_=null},goog.ui.SelectionModel.prototype.disposeInternal=function(){goog.ui.SelectionModel.superClass_.disposeInternal.call(this),delete this.items_,this.selectedItem_=null},goog.ui.SelectionModel.prototype.selectItem_=function(e,t){e&&("function"==typeof this.selectionHandler_?this.selectionHandler_(e,t):"function"==typeof e.setSelected&&e.setSelected(t))},goog.ui.Palette=function(e,t,o){goog.ui.Control.call(this,e,t||goog.ui.PaletteRenderer.getInstance(),o),this.setAutoStates(goog.ui.Component.State.CHECKED|goog.ui.Component.State.SELECTED|goog.ui.Component.State.OPENED,!1),this.currentCellControl_=new goog.ui.Palette.CurrentCell_,this.currentCellControl_.setParentEventTarget(this),this.lastHighlightedIndex_=-1},goog.inherits(goog.ui.Palette,goog.ui.Control),goog.tagUnsealableClass(goog.ui.Palette),goog.ui.Palette.EventType={AFTER_HIGHLIGHT:goog.events.getUniqueId("afterhighlight")},goog.ui.Palette.prototype.size_=null,goog.ui.Palette.prototype.highlightedIndex_=-1,goog.ui.Palette.prototype.selectionModel_=null,goog.ui.Palette.prototype.disposeInternal=function(){goog.ui.Palette.superClass_.disposeInternal.call(this),this.selectionModel_&&(this.selectionModel_.dispose(),this.selectionModel_=null),this.size_=null,this.currentCellControl_.dispose()},goog.ui.Palette.prototype.setContentInternal=function(e){goog.ui.Palette.superClass_.setContentInternal.call(this,e),this.adjustSize_(),this.selectionModel_?(this.selectionModel_.clear(),this.selectionModel_.addItems(e)):(this.selectionModel_=new goog.ui.SelectionModel(e),this.selectionModel_.setSelectionHandler(goog.bind(this.selectItem_,this)),this.getHandler().listen(this.selectionModel_,goog.events.EventType.SELECT,this.handleSelectionChange)),this.highlightedIndex_=-1},goog.ui.Palette.prototype.getCaption=function(){return""},goog.ui.Palette.prototype.setCaption=function(e){},goog.ui.Palette.prototype.handleMouseOver=function(e){goog.ui.Palette.superClass_.handleMouseOver.call(this,e);var t=this.getRenderer().getContainingItem(this,e.target);t&&e.relatedTarget&&goog.dom.contains(t,e.relatedTarget)||t!=this.getHighlightedItem()&&this.setHighlightedItem(t)},goog.ui.Palette.prototype.handleMouseDown=function(e){goog.ui.Palette.superClass_.handleMouseDown.call(this,e),this.isActive()&&((e=this.getRenderer().getContainingItem(this,e.target))!=this.getHighlightedItem()&&this.setHighlightedItem(e))},goog.ui.Palette.prototype.performActionInternal=function(e){var t=this.getHighlightedItem();return!!t&&(e&&this.shouldSelectHighlightedItem_(e)&&this.setSelectedItem(t),goog.ui.Palette.superClass_.performActionInternal.call(this,e))},goog.ui.Palette.prototype.shouldSelectHighlightedItem_=function(e){return!this.getSelectedItem()||("mouseup"!=e.type||!!this.getRenderer().getContainingItem(this,e.target))},goog.ui.Palette.prototype.handleKeyEvent=function(e){var t=this.getContent();t=t?t.length:0;var o=this.size_.width;if(0==t||!this.isEnabled())return!1;if(e.keyCode==goog.events.KeyCodes.ENTER||e.keyCode==goog.events.KeyCodes.SPACE)return this.performActionInternal(e);if(e.keyCode==goog.events.KeyCodes.HOME)return this.setHighlightedIndex(0),!0;if(e.keyCode==goog.events.KeyCodes.END)return this.setHighlightedIndex(t-1),!0;var n=0>this.highlightedIndex_?this.getSelectedIndex():this.highlightedIndex_;switch(e.keyCode){case goog.events.KeyCodes.LEFT:return-1!=n&&0!=n||(n=t),this.setHighlightedIndex(n-1),e.preventDefault(),!0;case goog.events.KeyCodes.RIGHT:return n==t-1&&(n=-1),this.setHighlightedIndex(n+1),e.preventDefault(),!0;case goog.events.KeyCodes.UP:if(-1==n&&(n=t+o-1),n>=o)return this.setHighlightedIndex(n-o),e.preventDefault(),!0;break;case goog.events.KeyCodes.DOWN:if(-1==n&&(n=-o),n<t-o)return this.setHighlightedIndex(n+o),e.preventDefault(),!0}return!1},goog.ui.Palette.prototype.handleSelectionChange=function(e){},goog.ui.Palette.prototype.getSize=function(){return this.size_},goog.ui.Palette.prototype.setSize=function(e,t){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.size_=goog.isNumber(e)?new goog.math.Size(e,t):e,this.adjustSize_()},goog.ui.Palette.prototype.getHighlightedIndex=function(){return this.highlightedIndex_},goog.ui.Palette.prototype.getHighlightedItem=function(){var e=this.getContent();return e&&e[this.highlightedIndex_]},goog.ui.Palette.prototype.getHighlightedCellElement_=function(){return this.getRenderer().getCellForItem(this.getHighlightedItem())},goog.ui.Palette.prototype.setHighlightedIndex=function(e){e!=this.highlightedIndex_&&(this.highlightIndex_(this.highlightedIndex_,!1),this.lastHighlightedIndex_=this.highlightedIndex_,this.highlightedIndex_=e,this.highlightIndex_(e,!0),this.dispatchEvent(goog.ui.Palette.EventType.AFTER_HIGHLIGHT))},goog.ui.Palette.prototype.setHighlightedItem=function(e){var t=this.getContent();this.setHighlightedIndex(t&&e?goog.array.indexOf(t,e):-1)},goog.ui.Palette.prototype.getSelectedIndex=function(){return this.selectionModel_?this.selectionModel_.getSelectedIndex():-1},goog.ui.Palette.prototype.getSelectedItem=function(){return this.selectionModel_?this.selectionModel_.getSelectedItem():null},goog.ui.Palette.prototype.setSelectedIndex=function(e){this.selectionModel_&&this.selectionModel_.setSelectedIndex(e)},goog.ui.Palette.prototype.setSelectedItem=function(e){this.selectionModel_&&this.selectionModel_.setSelectedItem(e)},goog.ui.Palette.prototype.highlightIndex_=function(e,t){if(this.getElement()){var o=this.getContent();if(o&&0<=e&&e<o.length){var n=this.getHighlightedCellElement_();this.currentCellControl_.getElement()!=n&&this.currentCellControl_.setElementInternal(n),this.currentCellControl_.tryHighlight(t)&&this.getRenderer().highlightCell(this,o[e],t)}}},goog.ui.Palette.prototype.setHighlighted=function(e){e&&-1==this.highlightedIndex_?this.setHighlightedIndex(-1<this.lastHighlightedIndex_?this.lastHighlightedIndex_:0):e||this.setHighlightedIndex(-1),goog.ui.Palette.superClass_.setHighlighted.call(this,e)},goog.ui.Palette.prototype.selectItem_=function(e,t){this.getElement()&&this.getRenderer().selectCell(this,e,t)},goog.ui.Palette.prototype.adjustSize_=function(){var e=this.getContent();e?this.size_&&this.size_.width?(e=Math.ceil(e.length/this.size_.width),(!goog.isNumber(this.size_.height)||this.size_.height<e)&&(this.size_.height=e)):(e=Math.ceil(Math.sqrt(e.length)),this.size_=new goog.math.Size(e,e)):this.size_=new goog.math.Size(0,0)},goog.ui.Palette.CurrentCell_=function(){goog.ui.Control.call(this,null),this.setDispatchTransitionEvents(goog.ui.Component.State.HOVER,!0)},goog.inherits(goog.ui.Palette.CurrentCell_,goog.ui.Control),goog.ui.Palette.CurrentCell_.prototype.tryHighlight=function(e){return this.setHighlighted(e),this.isHighlighted()==e},goog.ui.ColorPalette=function(e,t,o){this.colors_=e||[],goog.ui.Palette.call(this,null,t||goog.ui.PaletteRenderer.getInstance(),o),this.setColors(this.colors_)},goog.inherits(goog.ui.ColorPalette,goog.ui.Palette),goog.tagUnsealableClass(goog.ui.ColorPalette),goog.ui.ColorPalette.prototype.normalizedColors_=null,goog.ui.ColorPalette.prototype.labels_=null,goog.ui.ColorPalette.prototype.getColors=function(){return this.colors_},goog.ui.ColorPalette.prototype.setColors=function(e,t){this.colors_=e,this.labels_=t||null,this.normalizedColors_=null,this.setContent(this.createColorNodes())},goog.ui.ColorPalette.prototype.getSelectedColor=function(){var e=this.getSelectedItem();return e?(e=goog.style.getStyle(e,"background-color"),goog.ui.ColorPalette.parseColor_(e)):null},goog.ui.ColorPalette.prototype.setSelectedColor=function(e){e=goog.ui.ColorPalette.parseColor_(e),this.normalizedColors_||(this.normalizedColors_=goog.array.map(this.colors_,function(e){return goog.ui.ColorPalette.parseColor_(e)})),this.setSelectedIndex(e?goog.array.indexOf(this.normalizedColors_,e):-1)},goog.ui.ColorPalette.prototype.createColorNodes=function(){return goog.array.map(this.colors_,function(e,t){var o=this.getDomHelper().createDom("DIV",{class:this.getRenderer().getCssClass()+"-colorswatch",style:"background-color:"+e});return o.title=this.labels_&&this.labels_[t]?this.labels_[t]:"#"==e.charAt(0)?"RGB ("+goog.color.hexToRgb(e).join(", ")+")":e,o},this)},goog.ui.ColorPalette.parseColor_=function(e){if(e)try{return goog.color.parse(e).hex}catch(e){}return null},goog.ui.ColorPicker=function(e,t){goog.ui.Component.call(this,e),this.colorPalette_=t||null,this.getHandler().listen(this,goog.ui.Component.EventType.ACTION,this.onColorPaletteAction_)},goog.inherits(goog.ui.ColorPicker,goog.ui.Component),goog.ui.ColorPicker.DEFAULT_NUM_COLS=5,goog.ui.ColorPicker.EventType={CHANGE:"change"},goog.ui.ColorPicker.prototype.focusable_=!0,goog.ui.ColorPicker.prototype.getColors=function(){return this.colorPalette_?this.colorPalette_.getColors():null},goog.ui.ColorPicker.prototype.setColors=function(e){this.colorPalette_?this.colorPalette_.setColors(e):this.createColorPalette_(e)},goog.ui.ColorPicker.prototype.addColors=function(e){this.setColors(e)},goog.ui.ColorPicker.prototype.setSize=function(e){this.colorPalette_||this.createColorPalette_([]),this.colorPalette_.setSize(e)},goog.ui.ColorPicker.prototype.getSize=function(){return this.colorPalette_?this.colorPalette_.getSize():null},goog.ui.ColorPicker.prototype.setColumnCount=function(e){this.setSize(e)},goog.ui.ColorPicker.prototype.getSelectedIndex=function(){return this.colorPalette_?this.colorPalette_.getSelectedIndex():-1},goog.ui.ColorPicker.prototype.setSelectedIndex=function(e){this.colorPalette_&&this.colorPalette_.setSelectedIndex(e)},goog.ui.ColorPicker.prototype.getSelectedColor=function(){return this.colorPalette_?this.colorPalette_.getSelectedColor():null},goog.ui.ColorPicker.prototype.setSelectedColor=function(e){this.colorPalette_&&this.colorPalette_.setSelectedColor(e)},goog.ui.ColorPicker.prototype.isFocusable=function(){return this.focusable_},goog.ui.ColorPicker.prototype.setFocusable=function(e){this.focusable_=e,this.colorPalette_&&this.colorPalette_.setSupportedState(goog.ui.Component.State.FOCUSED,e)},goog.ui.ColorPicker.prototype.canDecorate=function(e){return!1},goog.ui.ColorPicker.prototype.enterDocument=function(){goog.ui.ColorPicker.superClass_.enterDocument.call(this),this.colorPalette_&&this.colorPalette_.render(this.getElement()),this.getElement().unselectable="on"},goog.ui.ColorPicker.prototype.disposeInternal=function(){goog.ui.ColorPicker.superClass_.disposeInternal.call(this),this.colorPalette_&&(this.colorPalette_.dispose(),this.colorPalette_=null)},goog.ui.ColorPicker.prototype.focus=function(){this.colorPalette_&&this.colorPalette_.getElement().focus()},goog.ui.ColorPicker.prototype.onColorPaletteAction_=function(e){e.stopPropagation(),this.dispatchEvent(goog.ui.ColorPicker.EventType.CHANGE)},goog.ui.ColorPicker.prototype.createColorPalette_=function(e){(e=new goog.ui.ColorPalette(e,null,this.getDomHelper())).setSize(goog.ui.ColorPicker.DEFAULT_NUM_COLS),e.setSupportedState(goog.ui.Component.State.FOCUSED,this.focusable_),this.addChild(e),this.colorPalette_=e,this.isInDocument()&&this.colorPalette_.render(this.getElement())},goog.ui.ColorPicker.createSimpleColorGrid=function(e){return(e=new goog.ui.ColorPicker(e)).setSize(7),e.setColors(goog.ui.ColorPicker.SIMPLE_GRID_COLORS),e},goog.ui.ColorPicker.SIMPLE_GRID_COLORS="#ffffff #cccccc #c0c0c0 #999999 #666666 #333333 #000000 #ffcccc #ff6666 #ff0000 #cc0000 #990000 #660000 #330000 #ffcc99 #ff9966 #ff9900 #ff6600 #cc6600 #993300 #663300 #ffff99 #ffff66 #ffcc66 #ffcc33 #cc9933 #996633 #663333 #ffffcc #ffff33 #ffff00 #ffcc00 #999900 #666600 #333300 #99ff99 #66ff99 #33ff33 #33cc00 #009900 #006600 #003300 #99ffff #33ffff #66cccc #00cccc #339999 #336666 #003333 #ccffff #66ffff #33ccff #3366ff #3333ff #000099 #000066 #ccccff #9999ff #6666cc #6633ff #6600cc #333399 #330099 #ffccff #ff99ff #cc66cc #cc33cc #993399 #663366 #330033".split(" "),Blockly.FieldColour=function(e,t,o){o=o||{},Blockly.FieldColour.superClass_.constructor.call(this,"   "),this.changeHandler_=t,this.colours_=o.colours,this.columns_=o.columns,this.borderRect_.style.fillOpacity=1,this.setValue(e)},goog.inherits(Blockly.FieldColour,Blockly.Field),Blockly.FieldColour.prototype.CURSOR="pointer",Blockly.FieldColour.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this),Blockly.FieldColour.superClass_.dispose.call(this)},Blockly.FieldColour.prototype.getValue=function(){return this.colour_},Blockly.FieldColour.prototype.setValue=function(e){this.colour_=e,this.borderRect_.style.fill=e,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.blockSpace.fireChangeEvent()},Blockly.FieldColour.COLOURS=goog.ui.ColorPicker.SIMPLE_GRID_COLORS,Blockly.FieldColour.COLUMNS=7,Blockly.FieldColour.prototype.showEditor_=function(){this.showWidgetDiv_();var e=Blockly.WidgetDiv.DIV,t=new goog.ui.ColorPicker;t.setSize(this.columns_||Blockly.FieldColour.COLUMNS),t.setColors(this.colours_||Blockly.FieldColour.COLOURS),t.render(e),t.setSelectedColor(this.getValue()),this.positionWidgetDiv();var o=this;Blockly.FieldColour.changeEventKey_=goog.events.listen(t,goog.ui.ColorPicker.EventType.CHANGE,function(e){if(e=e.target.getSelectedColor()||"#000000",Blockly.WidgetDiv.hide(),o.changeHandler_){var t=o.changeHandler_(e);void 0!==t&&(e=t)}null!==e&&o.setValue(e)})},Blockly.FieldColour.prototype.positionWidgetDiv=function(){var e=Blockly.getAbsoluteXY_(this.borderRect_,this.getRootSVGElement_());if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){this.borderRect_.style.display="inline";var t={x:this.borderRect_.getBBox().x,y:this.borderRect_.getBBox().y,width:this.borderRect_.scrollWidth,height:this.borderRect_.scrollHeight}}else t=this.borderRect_.getBBox();Blockly.RTL&&(e.x+=t.width),e.y+=t.height-1,t=Blockly.WidgetDiv.DIV,Blockly.RTL&&t&&(e.x-=t.offsetWidth),t=goog.dom.getViewportSize();var o=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.position(e.x,e.y,t,o)},Blockly.FieldColour.prototype.generateWidgetDisposeHandler_=function(){var e=Blockly.FieldRectangularDropdown.superClass_.generateWidgetDisposeHandler_.call(this);return function(){e(),Blockly.FieldColour.changeEventKey_&&goog.events.unlistenByKey(Blockly.FieldColour.changeEventKey_)}.bind(this)},Blockly.ImageDimensionCache={},Blockly.ImageDimensionCache.imageDimensions_={},Blockly.ImageDimensionCache.IMAGE_LOADING_WIDTH=40,Blockly.ImageDimensionCache.IMAGE_LOADING_HEIGHT=40,Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate=function(e,t){var o=Blockly.ImageDimensionCache.getCachedDimensions(e);return o||(Blockly.ImageDimensionCache.getDimensionsAsync(e,t),{width:Blockly.ImageDimensionCache.IMAGE_LOADING_WIDTH,height:Blockly.ImageDimensionCache.IMAGE_LOADING_HEIGHT})},Blockly.ImageDimensionCache.getCachedDimensions=function(e){return Blockly.ImageDimensionCache.imageDimensions_[e]},Blockly.ImageDimensionCache.storeDimensions=function(e,t,o){Blockly.ImageDimensionCache.imageDimensions_[e]={width:t,height:o}},Blockly.ImageDimensionCache.getDimensionsAsync=function(e,t){var o=new Image;o.onload=function(){Blockly.ImageDimensionCache.storeDimensions(e,o.width,o.height),t(o.width,o.height)},o.src=e},Blockly.FieldImage=function(e,t,o){if(!t&&!o){var n=this;t=(o=Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate(e,function(e,t){n.isDestroyed_()||n.updateDimensions_(e,t)})).width,o=o.height}this.initializeWithImage_(e,t,o)},goog.inherits(Blockly.FieldImage,Blockly.Field),Blockly.FieldImage.prototype.isDestroyed_=function(){return!this.imageElement_},Blockly.FieldImage.IMAGE_LOADING_WIDTH=40,Blockly.FieldImage.IMAGE_LOADING_HEIGHT=40,Blockly.FieldImage.IMAGE_OFFSET_Y=6-Blockly.BlockSvg.TITLE_HEIGHT,Blockly.FieldImage.BELOW_IMAGE_PADDING=10,Blockly.FieldImage.prototype.initializeWithImage_=function(e,t,o){this.sourceBlock_=null,o=Number(o),t=Number(t),this.size_={height:o+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:t},this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.imageElement_=Blockly.createSvgElement("image",{height:o+"px",width:t+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y},this.fieldGroup_),this.setText(e),goog.userAgent.GECKO&&(this.clickRectElement_=Blockly.createSvgElement("rect",{height:o+"px",width:t+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y,"fill-opacity":0},this.fieldGroup_))},Blockly.FieldImage.prototype.updateDimensions_=function(e,t){this.size_={height:t+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:e},this.imageElement_.setAttribute("width",e+"px"),this.imageElement_.setAttribute("height",t+"px"),this.clickRectElement_&&(this.clickRectElement_.setAttribute("width",e+"px"),this.clickRectElement_.setAttribute("height",t+"px")),this.refreshRender()},Blockly.FieldImage.prototype.clickRectElement_=null,Blockly.FieldImage.prototype.EDITABLE=!1,Blockly.FieldImage.prototype.init=function(e){if(this.sourceBlock_)throw"Image has already been initialized once.";this.sourceBlock_=e,e.getSvgRoot().appendChild(this.fieldGroup_),(e=this.getClickTarget()).tooltip=this.sourceBlock_,Blockly.Tooltip&&Blockly.Tooltip.bindMouseEvents(e)},Blockly.FieldImage.prototype.dispose=function(){goog.dom.removeNode(this.fieldGroup_),this.clickRectElement_=this.imageElement_=this.fieldGroup_=null},Blockly.FieldImage.prototype.getClickTarget=function(){return this.clickRectElement_||this.imageElement_},Blockly.FieldImage.prototype.setTooltip=function(e){this.getClickTarget().tooltip=e},Blockly.FieldImage.prototype.getText=function(){return this.src_},Blockly.FieldImage.prototype.setText=function(e){null!==e&&(this.src_=e,this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(e)?e:""))},Blockly.FieldRectangularDropdown=function(e,t){this.menuGenerator_=e,e=this.getOptions(),this.buttons_=t,t=e[0],this.value_=t[Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX],t=t[Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX],this.size_={width:Blockly.FieldImage.IMAGE_LOADING_WIDTH,height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT},this.buildDOMElements_(),this.updatePreviewData_(t)},goog.inherits(Blockly.FieldRectangularDropdown,Blockly.Field),Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX=0,Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX=1,Blockly.FieldRectangularDropdown.BORDER_MARGIN=2,Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER=2,Blockly.FieldRectangularDropdown.MENU_CSS_CLASS="blocklyRectangularDropdownMenu",Blockly.FieldRectangularDropdown.BORDER_OFFSET_X=-Blockly.FieldRectangularDropdown.BORDER_MARGIN,Blockly.FieldRectangularDropdown.BORDER_OFFSET_Y=Blockly.FieldImage.IMAGE_OFFSET_Y-Blockly.FieldRectangularDropdown.BORDER_MARGIN,Blockly.FieldRectangularDropdown.BORDER_RECTANGLE_RADIUS=4,Blockly.FieldRectangularDropdown.BORDER_EXTRA_ARROW_WIDTH=30,Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_WIDTH=20,Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_HEIGHT=23,Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_X_OFFSET_FROM_PREVIEW_RIGHT=Blockly.FieldRectangularDropdown.BORDER_EXTRA_ARROW_WIDTH/2-Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_WIDTH/2,Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_Y_OFFSET_FROM_PREVIEW_MIDDLE=-Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_HEIGHT/2-4,Blockly.FieldRectangularDropdown.CHECKMARK_OVERHANG=0,Blockly.FieldRectangularDropdown.DOWN_ARROW_CHARACTER="▼",Blockly.FieldRectangularDropdown.UP_ARROW_CHARACTER="▲",Blockly.FieldRectangularDropdown.prototype.CURSOR="pointer",Blockly.FieldRectangularDropdown.prototype.EDITABLE=!0,Blockly.FieldRectangularDropdown.prototype.getOptions=function(){return goog.isFunction(this.menuGenerator_)?this.menuGenerator_.call(this):this.menuGenerator_},Blockly.FieldRectangularDropdown.prototype.buildDOMElements_=function(){this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.dropdownBorderRectElement_=Blockly.createSvgElement("rect",{rx:Blockly.FieldRectangularDropdown.BORDER_RECTANGLE_RADIUS,ry:Blockly.FieldRectangularDropdown.BORDER_RECTANGLE_RADIUS,x:Blockly.FieldRectangularDropdown.BORDER_OFFSET_X,y:Blockly.FieldRectangularDropdown.BORDER_OFFSET_Y,height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT,class:"fieldRectangularDropdownBackdrop"},this.fieldGroup_),this.addPreviewElementTo_(this.fieldGroup_),this.createDropdownArrow_(),this.clickRectElement_=Blockly.createSvgElement("rect",{height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT+"px",width:Blockly.FieldImage.IMAGE_LOADING_WIDTH+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y,"fill-opacity":0},this.fieldGroup_)},Blockly.FieldRectangularDropdown.prototype.addPreviewElementTo_=function(){throw Error("FieldRectangularDropdown.prototype.addPreviewElementTo_ not implemented")},Blockly.FieldRectangularDropdown.prototype.createDropdownArrow_=function(){this.dropdownArrowText_=Blockly.createSvgElement("text",{class:"blocklyText"},this.fieldGroup_),this.arrowCharacter_=Blockly.createSvgElement("tspan",{class:"blocklyArrow blocklyRectangularDropdownArrow"},this.dropdownArrowText_),this.arrowCharacter_.appendChild(document.createTextNode(Blockly.FieldRectangularDropdown.DOWN_ARROW_CHARACTER))},Blockly.FieldRectangularDropdown.prototype.updatePreviewData_=function(){throw Error("FieldRectangularDropdown.prototype.updatePreviewData_ not implemented")},Blockly.FieldRectangularDropdown.prototype.updateDimensions_=function(e,t){this.previewSize_={width:e,height:t};var o=t+2*Blockly.FieldRectangularDropdown.BORDER_MARGIN,n=e+2*Blockly.FieldRectangularDropdown.BORDER_MARGIN+Blockly.FieldRectangularDropdown.BORDER_EXTRA_ARROW_WIDTH;this.updatePreviewDimensions_(e,t),this.clickRectElement_.setAttribute("width",n+"px"),this.clickRectElement_.setAttribute("height",o+"px"),this.dropdownBorderRectElement_.setAttribute("width",n+"px"),this.dropdownBorderRectElement_.setAttribute("height",o+"px"),t=t/2-Blockly.FieldImage.IMAGE_OFFSET_Y,this.dropdownArrowText_.setAttribute("x",e+Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_X_OFFSET_FROM_PREVIEW_RIGHT),this.dropdownArrowText_.setAttribute("y",t+Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_Y_OFFSET_FROM_PREVIEW_MIDDLE),this.size_={height:o+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:n},this.refreshRender()},Blockly.FieldRectangularDropdown.prototype.updatePreviewDimensions_=function(){throw Error("FieldRectangularDropdown.prototype.updatePreviewDimensions_ not implemented")},Blockly.FieldRectangularDropdown.prototype.createDropdownPreviewElement_=function(){throw Error("FieldRectangularDropdown.prototype.updatePreviewDimensions_ not implemented")},Blockly.FieldRectangularDropdown.prototype.pointArrowUp_=function(){this.setArrowDirection_(!0)},Blockly.FieldRectangularDropdown.prototype.pointArrowDown_=function(){this.setArrowDirection_(!1)},Blockly.FieldRectangularDropdown.prototype.setArrowDirection_=function(e){this.arrowCharacter_.firstChild.nodeValue=e?Blockly.FieldRectangularDropdown.UP_ARROW_CHARACTER:Blockly.FieldRectangularDropdown.DOWN_ARROW_CHARACTER},Blockly.FieldRectangularDropdown.prototype.showMenu_=function(){if(this.showWidgetDiv_(),this.menu_=this.createMenuWithChoices_(this.getOptions()),goog.events.listen(this.menu_,goog.ui.Component.EventType.ACTION,this.generateMenuItemSelectedHandler_()),this.buttons_){var e=this.menu_.getChildCount(),t=chooseNumberOfColumns(e),o=e%t;for(e=0,0<o&&(e=t-o),t=0;t<e;t++)this.addBlankMenuItem_();for(t=0;t<this.buttons_.length;t++)this.addMenuButton_(this.buttons_[t])}this.addPositionAndShowMenu(this.menu_),this.pointArrowUp_()},Blockly.FieldRectangularDropdown.prototype.addBlankMenuItem_=function(){var e=document.createElement("div");e.style.width=this.previewSize_.width+"px",e.style.height=this.previewSize_.height+"px",(e=new goog.ui.MenuItem(e)).setEnabled(!1),this.menu_.addItem(e)},Blockly.FieldRectangularDropdown.prototype.addMenuButton_=function(e){var t=new goog.ui.Button(e.text);this.menuButtonListenKey_=goog.events.listen(t,goog.ui.Component.EventType.ACTION,e.action),this.menu_.addItem(t)},Blockly.FieldRectangularDropdown.prototype.hideMenu_=function(){this.menuButtonListenKey_&&goog.events.unlistenByKey(this.menuButtonListenKey_),this.pointArrowDown_()},Blockly.FieldRectangularDropdown.prototype.menuAlreadyShowing_=function(){return this.menu_&&Blockly.WidgetDiv.isOwner(this)&&Blockly.WidgetDiv.isVisible()},Blockly.FieldRectangularDropdown.prototype.createMenuWithChoices_=function(e){for(var t=new goog.ui.Menu,o=0;o<e.length;o++){var n=e[o][Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX],i=n===this.value_,r=this.createDropdownPreviewElement_(e[o][Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX]);(r=new goog.ui.MenuItem(r)).setValue(n),n=1===chooseNumberOfColumns(e.length),i&&n?t.addItemAt(r,0):t.addItem(r)}return t},Blockly.FieldRectangularDropdown.prototype.generateMenuItemSelectedHandler_=function(){var e=this;return function(t){if((t=t.target)&&(null!=(t=t.getValue())&&(e.setValue(t),this.sourceBlock_))){var o=this.getPreviewDataForValue_(t),n=this.sourceBlock_.getRootBlock();if(n.miniFlyout){t=n.miniFlyout.blockSpace_.topBlocks_;var i=n.getConnections_().filter(function(e){return e.type===Blockly.INPUT_VALUE}).map(function(e){return e.targetBlock()}).indexOf(this.sourceBlock_);-1!==i&&t[i].inputList[0].titleRow[1].setText(o);var r=[];this.sourceBlock_.getShadowBlocks().forEach(function(e){var t=e.inputList[0]&&e.inputList[0].titleRow[1];t&&e.getRootBlock()===n&&(t.setText(o),r.push(e))}),this.sourceBlock_.setShadowBlocks(r)}}Blockly.WidgetDiv.hideIfOwner(e)}.bind(this)},Blockly.FieldRectangularDropdown.prototype.generateWidgetDisposeHandler_=function(){var e=Blockly.FieldRectangularDropdown.superClass_.generateWidgetDisposeHandler_.call(this);return function(){e(),this.hideMenu_()}.bind(this)},Blockly.FieldRectangularDropdown.prototype.addPositionAndShowMenu=function(e){var t=Blockly.WidgetDiv.DIV;t.style.visibility="hidden",e.render(t),e.setAllowAutoFocus(!0);var o=e.getElement();Blockly.addClass_(o,"blocklyDropdownMenu"),Blockly.addClass_(o,Blockly.FieldRectangularDropdown.MENU_CSS_CLASS),Blockly.addClass_(o,"goog-menu-noaccel");var n=this.calculateBackdropColourWithoutAlpha_();o.style.borderColor=n,o.style.background=n,1<(e=chooseNumberOfColumns(e.getChildCount()))&&(o.style.width=(this.previewSize_.width+4)*e+4+"px",Blockly.addClass_(o,"blocklyGridDropdownMenu")),this.positionWidgetDiv(),t.style.visibility="visible"},Blockly.FieldRectangularDropdown.prototype.positionWidgetDiv=function(){var e=goog.style.getSize(this.menu_.getElement()),t=chooseNumberOfColumns(this.menu_.getChildCount()),o=this.calculateMenuPosition_(this.previewElement_,1<t),n=goog.dom.getViewportSize();o.x+e.width>n.width&&(o.x-=e.width-e.width/t),o.y+e.height>n.height&&(o.y-=e.height+e.height/Math.ceil(this.menu_.getChildCount()/t)),e=goog.style.getViewportPageOffset(document),Blockly.WidgetDiv.position(o.x,o.y,n,e)},Blockly.FieldRectangularDropdown.prototype.calculateMenuPosition_=function(e,t){return e={x:(e=Blockly.getAbsoluteXY_(e,this.getRootSVGElement_())).x-Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER,y:e.y-Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER},t&&(e.y+=this.previewSize_.height+Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER),e},Blockly.FieldRectangularDropdown.prototype.getValue=function(){return this.value_},Blockly.FieldRectangularDropdown.prototype.setValue=function(e){this.getPreviewDataForValue_(e)&&(this.value_=e),this.refreshPreview_(),this.sourceBlock_&&this.sourceBlock_.blockSpace.fireChangeEvent()},Blockly.FieldRectangularDropdown.prototype.refreshPreview_=function(){this.updatePreviewData_(this.getCurrentPreviewData_())},Blockly.FieldRectangularDropdown.prototype.getCurrentPreviewData_=function(){return this.getPreviewDataForValue_(this.value_)},Blockly.FieldRectangularDropdown.prototype.getPreviewDataForValue_=function(e){for(var t=this.getOptions(),o=0;o<t.length;o++)if(t[o][Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX]==e)return t[o][Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX];return null},Blockly.FieldRectangularDropdown.prototype.onAnimationsChanged=function(){this.refreshPreview_()},Blockly.FieldRectangularDropdown.prototype.init=function(e){if(this.sourceBlock_)throw"Field has already been initialized once.";this.sourceBlock_=e,this.sourceBlock_.blockSpace.events.listen(Blockly.BlockSpace.EVENTS.ANIMATIONS_CHANGED,this.onAnimationsChanged,!1,this),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.mouseUpWrapper_=Blockly.bindEvent_(this.getClickTarget(),"mouseup",this,this.onMouseUp_),this.mouseDownWrapper_=Blockly.bindEvent_(this.getClickTarget(),"mousedown",this,this.onMouseDown_),this.updateDropdownArrowColour_()},Blockly.FieldRectangularDropdown.prototype.updateDropdownArrowColour_=function(){if(!this.sourceBlock_)throw"Cannot update dropdown arrow colour before added to block";this.arrowCharacter_.style.fill=this.sourceBlock_.getHexColour()},Blockly.FieldRectangularDropdown.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this),this.mouseDownWrapper_&&(Blockly.unbindEvent_(this.mouseDownWrapper_),this.mouseDownWrapper_=null),Blockly.FieldRectangularDropdown.superClass_.dispose.call(this)},Blockly.FieldRectangularDropdown.prototype.onMouseUp_=function(e){this.doNotOpenEditorNextMouseUp_?this.doNotOpenEditorNextMouseUp_=!1:Blockly.isRightButton(e)||Blockly.Block.isFreelyDragging()||!this.sourceBlock_.isEditable()||this.showMenu_()},Blockly.FieldRectangularDropdown.prototype.onMouseDown_=function(){this.menuAlreadyShowing_()&&(this.doNotOpenEditorNextMouseUp_=!0)},Blockly.FieldRectangularDropdown.prototype.getClickTarget=function(){return this.clickRectElement_},Blockly.FieldRectangularDropdown.prototype.sendClickRectToFront_=function(){this.fieldGroup_.appendChild(this.clickRectElement_)},Blockly.FieldRectangularDropdown.prototype.calculateBackdropColourWithoutAlpha_=function(){var e=this.sourceBlock_.getHexColour();return Blockly.mixColoursWithForegroundOpacity("#ffffff",e,.6)},Blockly.FieldColourDropdown=function(e,t,o){e=this.convertColourChoicesToTuples_(e),Blockly.FieldColourDropdown.superClass_.constructor.call(this,e),this.updateDimensions_(t,o)},goog.inherits(Blockly.FieldColourDropdown,Blockly.FieldRectangularDropdown),Blockly.FieldColourDropdown.prototype.convertColourChoicesToTuples_=function(e){for(var t=[],o=0;o<e.length;o++){var n=e[o],i=[];i[Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX]=n,i[Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX]=n,t.push(i)}return t},Blockly.FieldColourDropdown.prototype.addPreviewElementTo_=function(e){this.previewElement_=Blockly.createSvgElement("rect",{y:Blockly.FieldImage.IMAGE_OFFSET_Y,height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT+"px",width:Blockly.FieldImage.IMAGE_LOADING_WIDTH+"px"},e)},Blockly.FieldColourDropdown.prototype.createDropdownPreviewElement_=function(e){var t=document.createElement("div");return t.style.backgroundColor=e,t.style.width=this.previewSize_.width+"px",t.style.height=this.previewSize_.height+"px",t},Blockly.FieldColourDropdown.prototype.updatePreviewData_=function(e){this.previewElement_.setAttribute("fill",e)},Blockly.FieldColourDropdown.prototype.updatePreviewDimensions_=function(e,t){this.previewElement_.setAttribute("width",e+"px"),this.previewElement_.setAttribute("height",t+"px")},Blockly.FieldDropdown=function(e,t,o){this.menuGenerator_=e||[[Blockly.FieldDropdown.NO_OPTIONS_MESSAGE,Blockly.FieldDropdown.NO_OPTIONS_MESSAGE]],this.changeHandler_=t,this.alwaysCallChangeHandler_=!!o,this.trimOptions_(),e=this.getOptions()[0],this.value_=e[1],this.arrow_=Blockly.createSvgElement("tspan",{class:"blocklyArrow"},null),this.arrow_.appendChild(document.createTextNode(Blockly.RTL?"▼ ":" ▼")),Blockly.FieldDropdown.superClass_.constructor.call(this,e[0])},goog.inherits(Blockly.FieldDropdown,Blockly.Field),Blockly.FieldDropdown.CHECKMARK_OVERHANG=25,Blockly.FieldDropdown.NO_OPTIONS_MESSAGE="uninitialized",Blockly.FieldDropdown.prototype.CURSOR="pointer",Blockly.FieldDropdown.prototype.showEditor_=function(e){this.showWidgetDiv_();var t=this;this.menu_=new goog.ui.Menu;for(var o=this.getOptions(),n=0;n<o.length;n++){var i=o[n][1],r=new goog.ui.MenuItem(o[n][0]);r.setValue(i),r.setCheckable(!0),this.menu_.addItem(r),r.setChecked(i===this.value_)}goog.events.listen(this.menu_,goog.ui.Component.EventType.ACTION,function(e){if(e=e.target){if(e=e.getValue(),t.changeHandler_&&!t.alwaysCallChangeHandler_){var o=t.changeHandler_(e);void 0!==o&&(e=o)}null!==e&&t.setValue(e)}Blockly.WidgetDiv.hideIfOwner(t)}),(o=e||Blockly.WidgetDiv.DIV).style.visibility="hidden",this.menu_.render(o),this.menu_.setAllowAutoFocus(!0),n=this.menu_.getElement(),Blockly.addClass_(n,"blocklyDropdownMenu"),Blockly.addClass_(n,"goog-menu-noaccel"),(e||n).style.borderColor="hsla("+this.sourceBlock_.getColour()+", "+100*this.sourceBlock_.getSaturation()+"%, "+100*this.sourceBlock_.getValue()+"%, 0.5)",n.style.overflowY="auto",n.style["max-height"]="265px",this.positionWidgetDiv(),o.style.visibility="visible"},Blockly.FieldDropdown.prototype.positionWidgetDiv=function(){var e=goog.dom.getViewportSize(),t=goog.style.getViewportPageOffset(document),o=Blockly.getAbsoluteXY_(this.borderRect_,this.getRootSVGElement_()),n=this.borderRect_.getBBox(),i=goog.style.getSize(this.menu_.getElement());o.y=o.y+i.height+n.height>=e.height+t.y?o.y-i.height:o.y+n.height,Blockly.RTL?o.x<t.x&&(o.x=t.x+Blockly.FieldDropdown.CHECKMARK_OVERHANG):(o.x-=Blockly.FieldDropdown.CHECKMARK_OVERHANG,o.x>e.width+t.x-i.width&&(o.x=e.width+t.x-i.width)),Blockly.isIOS()&&(o.y-=t.y),Blockly.WidgetDiv.position(o.x,o.y,e,t)},Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixTitle=this.prefixTitle=null;var e=this.menuGenerator_;if(goog.isArray(e)&&!(2>e.length)){var t=e.map(function(e){return e[0]}),o=Blockly.shortestStringLength(t),n=Blockly.commonWordPrefix(t,o),i=Blockly.commonWordSuffix(t,o);if((n||i)&&!(o<=n+i)){for(n&&(this.prefixTitle=t[0].substring(0,n-1)),i&&(this.suffixTitle=t[0].substr(1-i)),t=[],o=0;o<e.length;o++){var r=e[o][0],l=e[o][1];r=r.substring(n,r.length-i),t[o]=[r,l]}this.menuGenerator_=t}}},Blockly.FieldDropdown.prototype.getOptions=function(){return goog.isFunction(this.menuGenerator_)?this.menuGenerator_.call(this):this.menuGenerator_},Blockly.FieldDropdown.prototype.getValue=function(){return this.value_},Blockly.FieldDropdown.prototype.setValue=function(e){if(this.alwaysCallChangeHandler_&&this.changeHandler_){var t=this.changeHandler_(e);void 0!==t&&(e=t)}this.value_=e,t=this.getOptions();for(var o=0;o<t.length;o++)if(t[o][1]==e)return void this.setText(t[o][0]);this.setText(e)},Blockly.FieldDropdown.prototype.setToFirstValue_=function(){this.setValue(this.getOptions()[0][1])},Blockly.FieldDropdown.prototype.setConfig=function(e){this.config=e;var t=Blockly.printerRangeToNumbers(e);if(0!==t.length||(t=(e||"").split(","),0!==(t=goog.array.map(t,function(e){return e.trim()})).length)){var o={};goog.array.forEach(this.getOptions(),function(e){o[e[1]]=e[0]}),this.menuGenerator_=goog.array.map(t,function(e){var t=o[e];return t?[t.toString(),e.toString()]:[e.toString(),e.toString()]}),this.setToFirstValue_()}},Blockly.FieldDropdown.prototype.setText=function(e){this.sourceBlock_&&(this.arrow_.style.fill=this.sourceBlock_.getHexColour()),null!==e&&(this.text_=e,goog.dom.removeChildren(this.textElement_),(e=e.replace(/\s/g,Blockly.Field.NBSP))||(e=Blockly.Field.NBSP),e=document.createTextNode(e),this.textElement_.appendChild(e),Blockly.RTL?this.textElement_.insertBefore(this.arrow_,this.textElement_.firstChild):this.textElement_.appendChild(this.arrow_),this.size_.width=0,this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours(),this.sourceBlock_.blockSpace.fireChangeEvent()))},Blockly.FieldDropdown.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this),Blockly.FieldDropdown.superClass_.dispose.call(this)},Blockly.FieldAngleDropdown=function(e){this.angleHelper=null,this.direction=e.direction,this.directionTitleName=e.directionTitleName,Blockly.FieldAngleDropdown.superClass_.constructor.call(this,e.menuGenerator,e.opt_changeHandler)},goog.inherits(Blockly.FieldAngleDropdown,Blockly.FieldDropdown),Blockly.FieldAngleDropdown.prototype.getAngleDirection_=function(){if(this.direction&&this.directionTitleName)throw"FieldAngleDropdown should not have both a direction and a directionTitleName; please pass at most one of these options";return this.directionTitleName?this.sourceBlock_.getTitleValue(this.directionTitleName):this.direction?this.direction:"turnRight"},Blockly.FieldAngleDropdown.prototype.showEditor_=function(){var e=Blockly.WidgetDiv.DIV,t=goog.dom.createDom("div","blocklyFieldAngleDropdown");e.appendChild(t),Blockly.FieldAngleDropdown.superClass_.showEditor_.call(this,t);var o=this.menu_.getElement();o=goog.style.getSize(o),o=Math.max(o.height,150),t.style.height=o+"px";var n=goog.dom.createDom("div");return t.appendChild(n),this.angleHelper=new Blockly.AngleHelper(this.getAngleDirection_(),{onUpdate:function(){this.setValue(this.angleHelper.getAngle().toString()),this.menu_.getItems().forEach(function(e){e.setChecked(e.getValue()===this.value_)},this)}.bind(this),snapPoints:this.getOptions().map(function(e){return parseInt(e[1])}),arcColour:this.sourceBlock_.getHexColour(),height:o,width:150,angle:parseInt(this.getValue()),enableBackgroundRotation:!0}),this.angleHelper.init(n),goog.events.listen(this.menu_,goog.ui.Component.EventType.HIGHLIGHT,function(e){(e=e.target)&&(e=e.getValue(),this.angleHelper.animateAngleChange(parseInt(e)))}.bind(this)),e},Blockly.FieldAngleDropdown.prototype.dispose=function(){this.angleHelper&&this.angleHelper.dispose(),Blockly.FieldAngleDropdown.superClass_.dispose.call(this)},Blockly.FieldAngleTextInput=function(e,t){this.direction=t.direction,this.directionTitle=t.directionTitle,Blockly.FieldAngleTextInput.superClass_.constructor.call(this,e,Blockly.FieldTextInput.numberValidator)},goog.inherits(Blockly.FieldAngleTextInput,Blockly.FieldTextInput),Blockly.FieldAngleTextInput.prototype.getFieldHelperOptions_=function(e){if(e===Blockly.BlockFieldHelper.ANGLE_HELPER)return{direction:this.direction,directionTitle:this.directionTitle,block:this.sourceBlock_}},Blockly.FieldIcon=function(){Blockly.FieldIcon.superClass_.constructor.apply(this,arguments),Blockly.addClass_(this.fieldGroup_,"blocklyIconGroup"),Blockly.addClass_(this.borderRect_,"blocklyIconShield")},goog.inherits(Blockly.FieldIcon,Blockly.Field),Blockly.FieldIcon.prototype.EDITABLE=!1,Blockly.FieldIcon.prototype.showEditor_=function(){},Blockly.FieldIcon.prototype.setReadOnly=function(){Blockly.addClass_(this.fieldGroup_,"readonly")},Blockly.FieldImageDropdown=function(e,t,o,n){this.width_=t,this.height_=o,this.menuGenerator_=e,Blockly.FieldImageDropdown.superClass_.constructor.call(this,e,n),this.hasForcedDimensions_()&&this.updateDimensions_(this.width_,this.height_)},goog.inherits(Blockly.FieldImageDropdown,Blockly.FieldRectangularDropdown),Blockly.FieldImageDropdown.prototype.hasForcedDimensions_=function(){return!!this.width_},Blockly.FieldImageDropdown.prototype.addPreviewElementTo_=function(e){this.previewElement_=Blockly.createSvgElement("image",{height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT+"px",width:Blockly.FieldImage.IMAGE_LOADING_WIDTH+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y},e)},Blockly.FieldImageDropdown.prototype.updatePreviewData_=function(e){this.previewElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e),this.hasForcedDimensions_()||this.getUpdatedDimensions_(e)},Blockly.FieldImageDropdown.prototype.createDropdownPreviewElement_=function(e){return this.hasForcedDimensions_()?this.createAutoSizedDropdownPreviewElement_(e,this.width_,this.height_):this.createImageDropdownPreviewElement_(e)},Blockly.FieldImageDropdown.prototype.createAutoSizedDropdownPreviewElement_=function(e,t,o){var n=document.createElement("div");return n.style.backgroundImage="url('"+e+"')",n.style.backgroundSize="contain",n.style.backgroundRepeat="no-repeat",n.style.backgroundPosition="50% 50%",n.style.width=t+"px",n.style.height=o+"px",n},Blockly.FieldImageDropdown.prototype.createImageDropdownPreviewElement_=function(e){var t=document.createElement("img");return t.setAttribute("src",e),t},Blockly.FieldImageDropdown.prototype.getUpdatedDimensions_=function(e){var t=this;e=Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate(e,function(e,o){t.updateDimensions_(e,o)}),this.updateDimensions_(e.width,e.height)},Blockly.FieldImageDropdown.prototype.updatePreviewDimensions_=function(e,t){this.previewElement_.setAttribute("width",e+"px"),this.previewElement_.setAttribute("height",t+"px")},Blockly.BlockLimits=function(){this.limits_={},this.events=new goog.events.EventTarget},Blockly.BlockLimits.prototype.setLimit=function(e,t){this.limits_[e]={count:void 0,limit:t},this.updateCount(e,0)},Blockly.BlockLimits.prototype.updateBlockTotals=function(e){var t=Blockly.aggregateCounts(e);goog.object.forEach(this.limits_,function(e,o){this.updateCount(o,t[o]||0)}.bind(this))},Blockly.BlockLimits.prototype.updateCount=function(e,t){var o=this.limits_[e],n=t!==o.count;o.count=t,n&&this.events.fireListeners("change",!1,{type:e,limit:o.limit,remaining:o.limit-o.count})},Blockly.BlockLimits.prototype.getLimit=function(e){return this.limits_[e]?this.limits_[e].limit:void 0},Blockly.BlockLimits.prototype.hasBlockLimits=function(){return 0<Object.keys(this.limits_).length},Blockly.BlockLimits.prototype.canAddBlocks=function(e){return e=Blockly.aggregateCounts(e),goog.object.every(e,function(e,t){return this.blockTypeWithinLimits(t,e)},this)},Blockly.BlockLimits.prototype.blockTypeWithinLimits=function(e,t){return void 0===t&&(t=1),!(e=this.limits_[e])||e.limit-e.count>=t},Blockly.BlockLimits.prototype.blockLimitExceeded=function(){return goog.object.findKey(this.limits_,function(e){return e.count>e.limit})},Blockly.Flyout=function(e,t){var o=this;this.blockSpaceEditor_=e,this.blockSpace_=new Blockly.BlockSpace(e,function(){return o.getMetrics_()},function(e){return o.setMetrics_(e)}),this.blockSpace_.isFlyout=!0,this.static_=t,this.changeWrapper_=null,this.height_=this.width_=0,this.buttons_=[],this.listeners_=[],this.enabled_=!0,this.flyoutButtonBackground_=null},Blockly.Flyout.configure=function(e,t){Blockly.Flyout.config[e]=t},Blockly.Flyout.config={},Blockly.Flyout.prototype.autoClose=!0,Blockly.Flyout.prototype.CORNER_RADIUS=8,Blockly.Flyout.prototype.onResizeWrapper_=null,Blockly.Flyout.prototype.createStaticToolboxDom=function(){return this.createDom(!1,!0)},Blockly.Flyout.prototype.createDom=function(e,t){return this.svgGroup_=Blockly.createSvgElement("g",{class:"svgFlyoutGroup"},null),this.svgBackground_=Blockly.createSvgElement("path",{class:"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.blockSpace_.createDom(t)),e||(this.trashcan=new Blockly.Trashcan(this),this.svgTrashcan_=this.trashcan.createDom(),this.svgTrashcan_.setAttribute("style","display: none; pointer-events: none"),this.svgTrashcan_.setAttribute("transform","translate(0, 20)"),this.svgGroup_.appendChild(this.svgTrashcan_)),this.svgGroup_},Blockly.Flyout.prototype.dispose=function(){this.hide(),this.onResizeWrapper_&&(Blockly.unbindEvent_(this.onResizeWrapper_),this.onResizeWrapper_=null),this.changeWrapper_&&(Blockly.unbindEvent_(this.changeWrapper_),this.changeWrapper_=null),this.blockSpace_.dispose(),this.blockSpace_=null,this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null),this.flyoutButtonBackground_=this.targetBlockSpace_=this.svgBackground_=null},Blockly.Flyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;var e=this.height_-2*this.CORNER_RADIUS,t=this.width_;try{if(Blockly.isMsie()||Blockly.isTrident()){this.blockSpace_.getCanvas().style.display="inline";var o={x:this.blockSpace_.getCanvas().getBBox().x,y:this.blockSpace_.getCanvas().getBBox().y,width:this.blockSpace_.getCanvas().scrollWidth,height:this.blockSpace_.getCanvas().scrollHeight}}else o=this.blockSpace_.getCanvas().getBBox()}catch(e){o={height:0,y:0}}return{viewHeight:e,viewWidth:t,contentHeight:o.height+o.y,viewTop:this.blockSpace_.getScrollOffsetY(),contentTop:0,absoluteTop:this.CORNER_RADIUS,absoluteLeft:0}},Blockly.Flyout.prototype.getHeight=function(){return this.height_},Blockly.Flyout.prototype.setMetrics_=function(e){var t=this.getMetrics_();null!==t&&(goog.isNumber(e.y)&&(this.blockSpace_.yOffsetFromView=-t.contentHeight*e.y-t.contentTop),e=this.blockSpace_.yOffsetFromView+t.absoluteTop,this.blockSpace_.getCanvas().setAttribute("transform","translate(0,"+e+")"))},Blockly.Flyout.prototype.init=function(e,t){this.targetBlockSpace_=e,t&&(this.blockSpace_.scrollbarPair=new Blockly.ScrollbarPair(this.blockSpace_,!1,!0)),this.hide(),this.onResizeWrapper_=Blockly.bindEvent_(window,goog.events.EventType.RESIZE,this,this.position_),this.position_(),this.changeWrapper_=Blockly.bindEvent_(this.targetBlockSpace_.getCanvas(),"blocklyBlockSpaceChange",this,this.onBlockSpaceChange_)},Blockly.Flyout.prototype.position_=function(){if(this.isVisible()){var e=this.targetBlockSpace_.customFlyoutMetrics_?this.targetBlockSpace_.customFlyoutMetrics_():this.targetBlockSpace_.getMetrics();if(e){var t=this.width_-this.CORNER_RADIUS;Blockly.RTL&&(t*=-1);var o=["M "+(Blockly.RTL?this.width_:0)+",0"];o.push("h",t),o.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,Blockly.RTL?0:1,Blockly.RTL?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),o.push("v",Math.max(0,e.viewHeight-2*this.CORNER_RADIUS)),o.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,Blockly.RTL?0:1,Blockly.RTL?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),o.push("h",-t),o.push("z"),this.svgBackground_.setAttribute("d",o.join(" ")),t=e.absoluteLeft,o=e.absoluteTop,Blockly.RTL?(t=this.static_?0:-this.width_,t+=e.viewWidth):this.static_&&(t-=this.width_),this.svgGroup_.setAttribute("transform","translate("+t+","+o+")"),this.height_=e.viewHeight,this.blockSpace_.updateScrollableSize(),this.svgTrashcan_&&this.svgTrashcan_.setAttribute("transform","translate("+Math.round(this.width_/2-35)+", 20)")}}},Blockly.Flyout.prototype.isVisible=function(){return"block"==this.svgGroup_.style.display},Blockly.Flyout.prototype.hide=function(e){if(this.isVisible()){var t;for(this.svgGroup_.style.display="none",this.blockSpace_.unbindBeginPanDragHandler(),t=0;t<this.listeners_.length;t++)Blockly.unbindEvent_(this.listeners_[t]);for(this.listeners_.splice(0),this.reflowWrapper_&&(Blockly.unbindEvent_(this.reflowWrapper_),this.reflowWrapper_=null),this.blockSpace_.getTopBlocks(!1).forEach(function(t){t.rendered&&t!==e&&t.dispose(!1,!1,!0)}),t=0;t<this.buttons_.length;t++)goog.dom.removeNode(this.buttons_[t]);goog.dom.removeNode(goog.dom.getElementByClass("createFunction",this.blockSpace_.svgGroup_)),this.buttons_.splice(0)}},Blockly.Flyout.prototype.layoutBlock_=function(e,t,o){var n=e.getHeightWidth();e.moveBy(t.x,t.y),t.y+=n.height+o},Blockly.Flyout.prototype.layoutXmlToBlocks_=function(e,t,o,n){for(var i,r=0;i=e[r];r++)i.tagName&&"BLOCK"===i.tagName.toUpperCase()&&(t.push(Blockly.Xml.domToBlock(this.blockSpace_,i)),o.push(3*n))},Blockly.Flyout.prototype.show=function(e){this.hide(),this.svgGroup_.style.display="block";var t=this.CORNER_RADIUS,o=Blockly.RTL?this.width_:t+Blockly.BlockSvg.TAB_WIDTH,n={x:o,y:t};this.blockSpace_.bindBeginPanDragHandler(this.svgBackground_),this.blockSpace_.bindScrollOnWheelHandler(this.svgGroup_);var i=[],r=[];this.minFlyoutWidth_=0;var l=e&&e[0];if(l===Blockly.Variables.NAME_TYPE)this.layoutXmlToBlocks_(e.slice(1),i,r,t),Blockly.Variables.flyoutCategory(i,r,t,this.blockSpace_,Blockly.Variables.DEFAULT_CATEGORY,!0);else if(l===Blockly.Procedures.NAME_TYPE||Blockly.topLevelProcedureAutopopulate)Blockly.functionEditor&&!Blockly.functionEditor.isOpen()&&this.addButtonToFlyout_(n,Blockly.Msg.FUNCTION_CREATE,this.createFunction_),Blockly.disableProcedureAutopopulate&&this.layoutXmlToBlocks_(e.slice(1),i,r,t),Blockly.topLevelProcedureAutopopulate&&this.layoutXmlToBlocks_(e,i,r,t),Blockly.mainBlockSpace&&Blockly.Procedures.flyoutCategory(i,r,t,this.blockSpace_,function(e){return!e.isFunctionalVariable&&"behavior_definition"!==e.type});else if(l===Blockly.Procedures.NAME_TYPE_FUNCTIONAL_VARIABLE)Blockly.functionEditor&&!Blockly.functionEditor.isOpen()&&this.addButtonToFlyout_(n,Blockly.Msg.FUNCTIONAL_VARIABLE_CREATE,this.createFunctionalVariable_),Blockly.Procedures.flyoutCategory(i,r,t,this.blockSpace_,function(e){return e.isFunctionalVariable});else if("Behavior"===l||Blockly.topLevelProcedureAutopopulate)("Behavior"===l||Blockly.disableProcedureAutopopulate)&&this.layoutXmlToBlocks_(e.slice(1),i,r,t),Blockly.topLevelProcedureAutopopulate?this.layoutXmlToBlocks_(e,i,r,t):Blockly.Flyout.config[l]&&Blockly.Flyout.config[l].initialize(this,n),Blockly.mainBlockSpace&&Blockly.Procedures.flyoutCategory(i,r,t,this.blockSpace_,function(e){return"behavior_definition"===e.type});else if(goog.isString(l)){var s=!0,a=Blockly.Flyout.config[l];a&&(s=a.addDefaultVar,a.initialize(this,n)),this.layoutXmlToBlocks_(e.slice(1),i,r,t),Blockly.Variables.flyoutCategory(i,r,t,this.blockSpace_,l,s)}else this.layoutXmlToBlocks_(e,i,r,t);if(Blockly.RTL){for(l=[],e=0;e<i.length;e++)0>o-(t=(t=i[e]).getHeightWidth()).width&&(o=this.width_),o-=t.width+r[e]/2,l.push(o);o=l.indexOf(Math.min.apply(Math,l)),o=l[o]+r[o],e=this.targetBlockSpace_.getMetrics().viewWidth,n.x=e-o,this.width_=o=n.x}for(e=0;e<i.length;e++){for(l=(t=i[e]).getDescendants(),s=0;a=l[s];s++)a.isInFlyout=!0;t.render(!0),this.layoutBlock_(t,n,r[e],o),l=Blockly.createSvgElement("rect",{"fill-opacity":0},null),this.blockSpace_.getCanvas().insertBefore(l,t.getSvgRoot()),t.flyoutRect_=l,this.buttons_[e]=l,s=t.getSvgRoot(),this.autoClose?this.listeners_.push(Blockly.bindEvent_(s,"mousedown",null,this.createBlockFunc_(t))):this.listeners_.push(Blockly.bindEvent_(s,"mousedown",null,this.blockMouseDown_(t))),this.listeners_.push(Blockly.bindEvent_(s,"mouseover",t.svg_,t.svg_.addSelectNoMove)),this.listeners_.push(Blockly.bindEvent_(s,"mouseout",t.svg_,t.svg_.removeSelect)),this.listeners_.push(Blockly.bindEvent_(l,"mousedown",null,this.createBlockFunc_(t))),this.listeners_.push(Blockly.bindEvent_(l,"mouseover",t.svg_,t.svg_.addSelectNoMove)),this.listeners_.push(Blockly.bindEvent_(l,"mouseout",t.svg_,t.svg_.removeSelect))}this.width_=0,this.reflow(),this.blockSpace_.resizeHeight(),this.filterForCapacity_(),this.updateBlockLimitTotals_(),Blockly.fireUiEvent(window,"resize"),this.reflowWrapper_=Blockly.bindEvent_(this.blockSpace_.getCanvas(),"blocklyBlockSpaceChange",this,this.reflow),this.blockSpace_.fireChangeEvent()},Blockly.Flyout.prototype.setMaxWidth=function(e){this.maxWidth_=e,this.reflow(),this.blockSpace_.resizeWidth(e)},Blockly.Flyout.prototype.addButtonToFlyout_=function(e,t,o){var n=Blockly.createSvgElement("g",{class:"createFunction"},this.blockSpace_.svgGroup_),i=Blockly.createSvgElement("rect",{fill:"#ddd",stroke:"none",height:50,x:-17,y:-25},n),r=Blockly.createSvgElement("rect",{rx:5,ry:5,fill:"orange",stroke:"white"},n),l=Blockly.createSvgElement("text",{x:5,y:5,class:"blocklyText"},n);l.textContent=t,t=l.getBoundingClientRect(),this.minFlyoutWidth_=t.width+10,i.setAttribute("width",t.width+10),r.setAttribute("width",t.width+10),r.setAttribute("height",t.height+10),r.setAttribute("y",5-t.height-1),n.setAttribute("transform","translate(17, 25)"),Blockly.bindEvent_(r,"mousedown",this,o),Blockly.bindEvent_(l,"mousedown",this,o),e.y+=40,this.flyoutButtonBackground_=i},Blockly.Flyout.prototype.reflow=function(){var e,t=this.minFlyoutWidth_||0,o=this.CORNER_RADIUS,n=this.blockSpace_.getTopBlocks(!1);for(e=0;e<n.length;e++){var i=n[e],r=i.getHeightWidth();t=Math.max(t,r.width)}if(t+=o+Blockly.BlockSvg.TAB_WIDTH+o/2+Blockly.Scrollbar.scrollbarThickness,this.maxWidth_&&(t=Math.min(t,this.maxWidth_)),this.width_!=t){for(e=0;e<n.length;e++){r=(i=n[e]).getHeightWidth();var l=i.getRelativeToSurfaceXY();if(Blockly.RTL){var s=t-o-Blockly.BlockSvg.TAB_WIDTH-l.x;i.moveBy(s,0),l.x+=s}i.flyoutRect_&&(i.flyoutRect_.setAttribute("width",r.width),i.flyoutRect_.setAttribute("height",r.height),i.flyoutRect_.setAttribute("x",Blockly.RTL?l.x-r.width:l.x),i.flyoutRect_.setAttribute("y",l.y))}this.flyoutButtonBackground_&&this.flyoutButtonBackground_.setAttribute("width",Math.max(0,t-15)),this.width_=t,Blockly.fireUiEvent(window,"resize")}},Blockly.Flyout.prototype.blockMouseDown_=function(e){var t=this;return function(o){t.enabled_&&(Blockly.BlockSpaceEditor.terminateDrag_(),t.blockSpace_.blockSpaceEditor.hideChaff(),Blockly.isRightButton(o)||(Blockly.removeAllRanges(),t.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),Blockly.Flyout.startDragMouseX_=o.clientX,Blockly.Flyout.startDragMouseY_=o.clientY,Blockly.Flyout.startBlock_=e,Blockly.Flyout.startFlyout_=t,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.BlockSpaceEditor.terminateDrag_),Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,t.onMouseMove_)),o.stopPropagation())}},Blockly.Flyout.prototype.onMouseMove_=function(e){"mousemove"==e.type&&1>=e.clientX&&0==e.clientY&&0==e.button?e.stopPropagation():(Blockly.removeAllRanges(),Math.sqrt(Math.pow(e.clientX-Blockly.Flyout.startDragMouseX_,2)+Math.pow(e.clientY-Blockly.Flyout.startDragMouseY_,2))>Blockly.DRAG_RADIUS&&(e.startDragMouseX_=Blockly.Flyout.startDragMouseX_,e.startDragMouseY_=Blockly.Flyout.startDragMouseY_,Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(e)))},Blockly.Flyout.prototype.createFunction_=function(){Blockly.functionEditor.openWithNewFunction()},Blockly.Flyout.prototype.createFunctionalVariable_=function(){Blockly.contractEditor.openWithNewVariable()},Blockly.Flyout.prototype.createBlockFunc_=function(e){var t=this;return function(o){if(t.enabled_&&!Blockly.isRightButton(o)&&!e.disabled){var n=t.targetBlockSpace_;if(!n.isReadOnly()){var i=Blockly.Xml.blockToDom(e);Blockly.Block.startDragging(),i=Blockly.Xml.domToBlock(n,i);var r=e.getSvgRoot();if(!r)throw"originBlock is not rendered.";r=Blockly.getSvgXY_(r,e.blockSpace.blockSpaceEditor.svg_);var l=i.getSvgRoot();if(!l)throw"block is not rendered.";l=Blockly.getSvgXY_(l,i.blockSpace.blockSpaceEditor.svg_),i.moveBy(r.x-l.x,r.y-l.y),i.blockToShadow_&&(r="",e.inputList[0]&&e.inputList[0].titleRow[1]&&(r=e.inputList[0].titleRow[1].src_),""!=r&&(i.inputList[0].titleRow[0].setText(i.shortString),i.inputList[0].titleRow[1].setText(e.inputList[0].titleRow[1].src_),i.inputList[0].titleRow[1].updateDimensions_(i.thumbnailSize,i.thumbnailSize))),t.autoClose?(t.hide(e),i.blockEvents.listenOnce(Blockly.Block.EVENTS.AFTER_DROPPED,function(){e.dispose(!1,!1)})):t.filterForCapacity_(),Blockly.topLevelProcedureAutopopulate&&i.isFunctionDefinition()&&i.blockEvents.listenOnce(Blockly.Block.EVENTS.AFTER_DROPPED,function(){window.setTimeout(function(){n.blockSpaceEditor.updateFlyout()},0)}),i.onMouseDown_(o)}}}},Blockly.Flyout.prototype.onBlockSpaceChange_=function(){this.filterForCapacity_(),this.updateBlockLimitTotals_()},Blockly.Flyout.prototype.filterForCapacity_=function(){for(var e,t=this.targetBlockSpace_.remainingCapacity(),o=this.blockSpace_.getTopBlocks(!1),n=0;e=o[n];n++){var i=e.getDescendants().length>t;e.setDisabled(i)}},Blockly.Flyout.prototype.updateBlockLimitTotals_=function(){var e=this.blockSpaceEditor_.blockSpace.getAllBlocks();e=(e=goog.array.filter(e,function(e){return e.isUserVisible()&&!e.getRootBlock().isUnused()})).map(function(e){return e.type}),this.blockSpaceEditor_.blockLimits.updateBlockTotals(e)},Blockly.Flyout.terminateDrag_=function(){Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),Blockly.Flyout.onMouseUpWrapper_=null),Blockly.Flyout.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveWrapper_),Blockly.Flyout.onMouseMoveWrapper_=null),Blockly.Flyout.startDragMouseX_=0,Blockly.Flyout.startDragMouseY_=0,Blockly.Flyout.startBlock_=null,Blockly.Flyout.startFlyout_=null},Blockly.Flyout.prototype.setEnabled=function(e){this.enabled_=e},Blockly.Flyout.prototype.getRect=function(){var e=Blockly.getSvgXY_(this.svgGroup_).x;return Blockly.RTL||(e-=1e7),new goog.math.Rect(e,-1e7,1e7+this.width_,this.height_+2e7)},Blockly.Flyout.prototype.getAllBlocks=function(){return this.blockSpace_.getAllBlocks()},goog.events.FocusHandler=function(e){goog.events.EventTarget.call(this),this.element_=e,e=goog.userAgent.IE?"focusout":"blur",this.listenKeyIn_=goog.events.listen(this.element_,goog.userAgent.IE?"focusin":"focus",this,!goog.userAgent.IE),this.listenKeyOut_=goog.events.listen(this.element_,e,this,!goog.userAgent.IE)},goog.inherits(goog.events.FocusHandler,goog.events.EventTarget),goog.events.FocusHandler.EventType={FOCUSIN:"focusin",FOCUSOUT:"focusout"},goog.events.FocusHandler.prototype.handleEvent=function(e){var t=e.getBrowserEvent();(t=new goog.events.BrowserEvent(t)).type="focusin"==e.type||"focus"==e.type?goog.events.FocusHandler.EventType.FOCUSIN:goog.events.FocusHandler.EventType.FOCUSOUT,this.dispatchEvent(t)},goog.events.FocusHandler.prototype.disposeInternal=function(){goog.events.FocusHandler.superClass_.disposeInternal.call(this),goog.events.unlistenByKey(this.listenKeyIn_),goog.events.unlistenByKey(this.listenKeyOut_),delete this.element_},goog.structs={},goog.structs.getCount=function(e){return e.getCount&&"function"==typeof e.getCount?e.getCount():goog.isArrayLike(e)||goog.isString(e)?e.length:goog.object.getCount(e)},goog.structs.getValues=function(e){if(e.getValues&&"function"==typeof e.getValues)return e.getValues();if(goog.isString(e))return e.split("");if(goog.isArrayLike(e)){for(var t=[],o=e.length,n=0;n<o;n++)t.push(e[n]);return t}return goog.object.getValues(e)},goog.structs.getKeys=function(e){if(e.getKeys&&"function"==typeof e.getKeys)return e.getKeys();if(!e.getValues||"function"!=typeof e.getValues){if(goog.isArrayLike(e)||goog.isString(e)){var t=[];e=e.length;for(var o=0;o<e;o++)t.push(o);return t}return goog.object.getKeys(e)}},goog.structs.contains=function(e,t){return e.contains&&"function"==typeof e.contains?e.contains(t):e.containsValue&&"function"==typeof e.containsValue?e.containsValue(t):goog.isArrayLike(e)||goog.isString(e)?goog.array.contains(e,t):goog.object.containsValue(e,t)},goog.structs.isEmpty=function(e){return e.isEmpty&&"function"==typeof e.isEmpty?e.isEmpty():goog.isArrayLike(e)||goog.isString(e)?goog.array.isEmpty(e):goog.object.isEmpty(e)},goog.structs.clear=function(e){e.clear&&"function"==typeof e.clear?e.clear():goog.isArrayLike(e)?goog.array.clear(e):goog.object.clear(e)},goog.structs.forEach=function(e,t,o){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,o);else if(goog.isArrayLike(e)||goog.isString(e))goog.array.forEach(e,t,o);else for(var n=goog.structs.getKeys(e),i=goog.structs.getValues(e),r=i.length,l=0;l<r;l++)t.call(o,i[l],n&&n[l],e)},goog.structs.filter=function(e,t,o){if("function"==typeof e.filter)return e.filter(t,o);if(goog.isArrayLike(e)||goog.isString(e))return goog.array.filter(e,t,o);var n=goog.structs.getKeys(e),i=goog.structs.getValues(e),r=i.length;if(n)for(var l={},s=0;s<r;s++)t.call(o,i[s],n[s],e)&&(l[n[s]]=i[s]);else for(l=[],s=0;s<r;s++)t.call(o,i[s],void 0,e)&&l.push(i[s]);return l},goog.structs.map=function(e,t,o){if("function"==typeof e.map)return e.map(t,o);if(goog.isArrayLike(e)||goog.isString(e))return goog.array.map(e,t,o);var n=goog.structs.getKeys(e),i=goog.structs.getValues(e),r=i.length;if(n)for(var l={},s=0;s<r;s++)l[n[s]]=t.call(o,i[s],n[s],e);else for(l=[],s=0;s<r;s++)l[s]=t.call(o,i[s],void 0,e);return l},goog.structs.some=function(e,t,o){if("function"==typeof e.some)return e.some(t,o);if(goog.isArrayLike(e)||goog.isString(e))return goog.array.some(e,t,o);for(var n=goog.structs.getKeys(e),i=goog.structs.getValues(e),r=i.length,l=0;l<r;l++)if(t.call(o,i[l],n&&n[l],e))return!0;return!1},goog.structs.every=function(e,t,o){if("function"==typeof e.every)return e.every(t,o);if(goog.isArrayLike(e)||goog.isString(e))return goog.array.every(e,t,o);for(var n=goog.structs.getKeys(e),i=goog.structs.getValues(e),r=i.length,l=0;l<r;l++)if(!t.call(o,i[l],n&&n[l],e))return!1;return!0},goog.structs.Collection=function(){},goog.structs.Map=function(e,t){this.map_={},this.keys_=[],this.version_=this.count_=0;var o=arguments.length;if(1<o){if(o%2)throw Error("Uneven number of arguments");for(var n=0;n<o;n+=2)this.set(arguments[n],arguments[n+1])}else e&&this.addAll(e)},goog.structs.Map.prototype.getCount=function(){return this.count_},goog.structs.Map.prototype.getValues=function(){this.cleanupKeysArray_();for(var e=[],t=0;t<this.keys_.length;t++)e.push(this.map_[this.keys_[t]]);return e},goog.structs.Map.prototype.getKeys=function(){return this.cleanupKeysArray_(),this.keys_.concat()},goog.structs.Map.prototype.containsKey=function(e){return goog.structs.Map.hasKey_(this.map_,e)},goog.structs.Map.prototype.containsValue=function(e){for(var t=0;t<this.keys_.length;t++){var o=this.keys_[t];if(goog.structs.Map.hasKey_(this.map_,o)&&this.map_[o]==e)return!0}return!1},goog.structs.Map.prototype.equals=function(e,t){if(this===e)return!0;if(this.count_!=e.getCount())return!1;t=t||goog.structs.Map.defaultEquals,this.cleanupKeysArray_();for(var o,n=0;o=this.keys_[n];n++)if(!t(this.get(o),e.get(o)))return!1;return!0},goog.structs.Map.defaultEquals=function(e,t){return e===t},goog.structs.Map.prototype.isEmpty=function(){return 0==this.count_},goog.structs.Map.prototype.clear=function(){this.map_={},this.version_=this.count_=this.keys_.length=0},goog.structs.Map.prototype.remove=function(e){return!!goog.structs.Map.hasKey_(this.map_,e)&&(delete this.map_[e],this.count_--,this.version_++,this.keys_.length>2*this.count_&&this.cleanupKeysArray_(),!0)},goog.structs.Map.prototype.cleanupKeysArray_=function(){if(this.count_!=this.keys_.length){for(var e=0,t=0;e<this.keys_.length;){var o=this.keys_[e];goog.structs.Map.hasKey_(this.map_,o)&&(this.keys_[t++]=o),e++}this.keys_.length=t}if(this.count_!=this.keys_.length){var n={};for(t=e=0;e<this.keys_.length;)o=this.keys_[e],goog.structs.Map.hasKey_(n,o)||(this.keys_[t++]=o,n[o]=1),e++;this.keys_.length=t}},goog.structs.Map.prototype.get=function(e,t){return goog.structs.Map.hasKey_(this.map_,e)?this.map_[e]:t},goog.structs.Map.prototype.set=function(e,t){goog.structs.Map.hasKey_(this.map_,e)||(this.count_++,this.keys_.push(e),this.version_++),this.map_[e]=t},goog.structs.Map.prototype.addAll=function(e){if(e instanceof goog.structs.Map){var t=e.getKeys();e=e.getValues()}else t=goog.object.getKeys(e),e=goog.object.getValues(e);for(var o=0;o<t.length;o++)this.set(t[o],e[o])},goog.structs.Map.prototype.forEach=function(e,t){for(var o=this.getKeys(),n=0;n<o.length;n++){var i=o[n],r=this.get(i);e.call(t,r,i,this)}},goog.structs.Map.prototype.clone=function(){return new goog.structs.Map(this)},goog.structs.Map.prototype.transpose=function(){for(var e=new goog.structs.Map,t=0;t<this.keys_.length;t++){var o=this.keys_[t];e.set(this.map_[o],o)}return e},goog.structs.Map.prototype.toObject=function(){this.cleanupKeysArray_();for(var e={},t=0;t<this.keys_.length;t++){var o=this.keys_[t];e[o]=this.map_[o]}return e},goog.structs.Map.prototype.getKeyIterator=function(){return this.__iterator__(!0)},goog.structs.Map.prototype.getValueIterator=function(){return this.__iterator__(!1)},goog.structs.Map.prototype.__iterator__=function(e){this.cleanupKeysArray_();var t=0,o=this.version_,n=this,i=new goog.iter.Iterator;return i.next=function(){if(o!=n.version_)throw Error("The map has changed since the iterator was created");if(t>=n.keys_.length)throw goog.iter.StopIteration;var i=n.keys_[t++];return e?i:n.map_[i]},i},goog.structs.Map.hasKey_=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},goog.structs.Set=function(e){this.map_=new goog.structs.Map,e&&this.addAll(e)},goog.structs.Set.getKey_=function(e){var t=typeof e;return"object"==t&&e||"function"==t?"o"+goog.getUid(e):t.substr(0,1)+e},goog.structs.Set.prototype.getCount=function(){return this.map_.getCount()},goog.structs.Set.prototype.add=function(e){this.map_.set(goog.structs.Set.getKey_(e),e)},goog.structs.Set.prototype.addAll=function(e){for(var t=(e=goog.structs.getValues(e)).length,o=0;o<t;o++)this.add(e[o])},goog.structs.Set.prototype.removeAll=function(e){for(var t=(e=goog.structs.getValues(e)).length,o=0;o<t;o++)this.remove(e[o])},goog.structs.Set.prototype.remove=function(e){return this.map_.remove(goog.structs.Set.getKey_(e))},goog.structs.Set.prototype.clear=function(){this.map_.clear()},goog.structs.Set.prototype.isEmpty=function(){return this.map_.isEmpty()},goog.structs.Set.prototype.contains=function(e){return this.map_.containsKey(goog.structs.Set.getKey_(e))},goog.structs.Set.prototype.containsAll=function(e){return goog.structs.every(e,this.contains,this)},goog.structs.Set.prototype.intersection=function(e){var t=new goog.structs.Set;e=goog.structs.getValues(e);for(var o=0;o<e.length;o++){var n=e[o];this.contains(n)&&t.add(n)}return t},goog.structs.Set.prototype.difference=function(e){var t=this.clone();return t.removeAll(e),t},goog.structs.Set.prototype.getValues=function(){return this.map_.getValues()},goog.structs.Set.prototype.clone=function(){return new goog.structs.Set(this)},goog.structs.Set.prototype.equals=function(e){return this.getCount()==goog.structs.getCount(e)&&this.isSubsetOf(e)},goog.structs.Set.prototype.isSubsetOf=function(e){var t=goog.structs.getCount(e);return!(this.getCount()>t)&&(!(e instanceof goog.structs.Set)&&5<t&&(e=new goog.structs.Set(e)),goog.structs.every(this,function(t){return goog.structs.contains(e,t)}))},goog.structs.Set.prototype.__iterator__=function(e){return this.map_.__iterator__(!1)},goog.debug.LOGGING_ENABLED=goog.DEBUG,goog.debug.FORCE_SLOPPY_STACKS=!1,goog.debug.catchErrors=function(e,t,o){var n=(o=o||goog.global).onerror,i=!!t;goog.userAgent.WEBKIT&&!goog.userAgent.isVersionOrHigher("535.3")&&(i=!i),o.onerror=function(t,o,r,l,s){return n&&n(t,o,r,l,s),e({message:t,fileName:o,line:r,col:l,error:s}),i}},goog.debug.expose=function(e,t){if(void 0===e)return"undefined";if(null==e)return"NULL";var o,n=[];for(o in e)if(t||!goog.isFunction(e[o])){var i=o+" = ";try{i+=e[o]}catch(e){i+="*** "+e+" ***"}n.push(i)}return n.join("\n")},goog.debug.deepExpose=function(e,t){var o=[],n=function(e,i,r){var l=i+"  ";r=new goog.structs.Set(r);try{if(goog.isDef(e))if(goog.isNull(e))o.push("NULL");else if(goog.isString(e))o.push('"'+e.replace(/\n/g,"\n"+i)+'"');else if(goog.isFunction(e))o.push(String(e).replace(/\n/g,"\n"+i));else if(goog.isObject(e))if(r.contains(e))o.push("*** reference loop detected ***");else{for(var s in r.add(e),o.push("{"),e)!t&&goog.isFunction(e[s])||(o.push("\n"),o.push(l),o.push(s+" = "),n(e[s],l,r));o.push("\n"+i+"}")}else o.push(e);else o.push("undefined")}catch(e){o.push("*** "+e+" ***")}};return n(e,"",new goog.structs.Set),o.join("")},goog.debug.exposeArray=function(e){for(var t=[],o=0;o<e.length;o++)goog.isArray(e[o])?t.push(goog.debug.exposeArray(e[o])):t.push(e[o]);return"[ "+t.join(", ")+" ]"},goog.debug.exposeException=function(e,t){return e=goog.debug.exposeExceptionAsHtml(e,t),goog.html.SafeHtml.unwrap(e)},goog.debug.exposeExceptionAsHtml=function(e,t){try{var o=goog.debug.normalizeErrorObject(e),n=goog.debug.createViewSourceUrl_(o.fileName);return goog.html.SafeHtml.concat(goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces("Message: "+o.message+"\nUrl: "),goog.html.SafeHtml.create("a",{href:n,target:"_new"},o.fileName),goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces("\nLine: "+o.lineNumber+"\n\nBrowser stack:\n"+o.stack+"-> [end]\n\nJS stack traversal:\n"+goog.debug.getStacktrace(t)+"-> "))}catch(e){return goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces("Exception trying to expose exception! You win, we lose. "+e)}},goog.debug.createViewSourceUrl_=function(e){return goog.isDefAndNotNull(e)||(e=""),/^https?:\/\//i.test(e)?(e=goog.html.SafeUrl.sanitize(e),goog.html.uncheckedconversions.safeUrlFromStringKnownToSatisfyTypeContract(goog.string.Const.from("view-source scheme plus HTTP/HTTPS URL"),"view-source:"+goog.html.SafeUrl.unwrap(e))):goog.html.SafeUrl.fromConstant(goog.string.Const.from("sanitizedviewsrc"))},goog.debug.normalizeErrorObject=function(e){var t=goog.getObjectByName("window.location.href");if(goog.isString(e))return{message:e,name:"Unknown error",lineNumber:"Not available",fileName:t,stack:"Not available"};var o=!1;try{var n=e.lineNumber||e.line||"Not available"}catch(e){n="Not available",o=!0}try{var i=e.fileName||e.filename||e.sourceURL||goog.global.$googDebugFname||t}catch(e){i="Not available",o=!0}return!o&&e.lineNumber&&e.fileName&&e.stack&&e.message&&e.name?e:{message:e.message||"Not available",name:e.name||"UnknownError",lineNumber:n,fileName:i,stack:e.stack||"Not available"}},goog.debug.enhanceError=function(e,t){if(e instanceof Error||(e=Error(e),Error.captureStackTrace&&Error.captureStackTrace(e,goog.debug.enhanceError)),e.stack||(e.stack=goog.debug.getStacktrace(goog.debug.enhanceError)),t){for(var o=0;e["message"+o];)++o;e["message"+o]=String(t)}return e},goog.debug.getStacktraceSimple=function(e){if(!goog.debug.FORCE_SLOPPY_STACKS){var t=goog.debug.getNativeStackTrace_(goog.debug.getStacktraceSimple);if(t)return t}t=[];for(var o=arguments.callee.caller,n=0;o&&(!e||n<e);){t.push(goog.debug.getFunctionName(o)),t.push("()\n");try{o=o.caller}catch(e){t.push("[exception trying to get caller]\n");break}if(++n>=goog.debug.MAX_STACK_DEPTH){t.push("[...long stack...]");break}}return e&&n>=e?t.push("[...reached max depth limit...]"):t.push("[end]"),t.join("")},goog.debug.MAX_STACK_DEPTH=50,goog.debug.getNativeStackTrace_=function(e){var t=Error();if(Error.captureStackTrace)return Error.captureStackTrace(t,e),String(t.stack);try{throw t}catch(e){t=e}return(e=t.stack)?String(e):null},goog.debug.getStacktrace=function(e){var t;return goog.debug.FORCE_SLOPPY_STACKS||(t=goog.debug.getNativeStackTrace_(e||goog.debug.getStacktrace)),t||(t=goog.debug.getStacktraceHelper_(e||arguments.callee.caller,[])),t},goog.debug.getStacktraceHelper_=function(e,t){var o=[];if(goog.array.contains(t,e))o.push("[...circular reference...]");else if(e&&t.length<goog.debug.MAX_STACK_DEPTH){o.push(goog.debug.getFunctionName(e)+"(");for(var n=e.arguments,i=0;n&&i<n.length;i++){0<i&&o.push(", ");var r=n[i];switch(typeof r){case"object":r=r?"object":"null";break;case"string":break;case"number":r=String(r);break;case"boolean":r=r?"true":"false";break;case"function":r=(r=goog.debug.getFunctionName(r))?r:"[fn]";break;default:r=typeof r}40<r.length&&(r=r.substr(0,40)+"..."),o.push(r)}t.push(e),o.push(")\n");try{o.push(goog.debug.getStacktraceHelper_(e.caller,t))}catch(e){o.push("[exception trying to get caller]\n")}}else e?o.push("[...long stack...]"):o.push("[end]");return o.join("")},goog.debug.setFunctionResolver=function(e){goog.debug.fnNameResolver_=e},goog.debug.getFunctionName=function(e){if(goog.debug.fnNameCache_[e])return goog.debug.fnNameCache_[e];if(goog.debug.fnNameResolver_){var t=goog.debug.fnNameResolver_(e);if(t)return goog.debug.fnNameCache_[e]=t}return e=String(e),goog.debug.fnNameCache_[e]||(t=/function ([^\(]+)/.exec(e),goog.debug.fnNameCache_[e]=t?t[1]:"[Anonymous]"),goog.debug.fnNameCache_[e]},goog.debug.makeWhitespaceVisible=function(e){return e.replace(/ /g,"[_]").replace(/\f/g,"[f]").replace(/\n/g,"[n]\n").replace(/\r/g,"[r]").replace(/\t/g,"[t]")},goog.debug.runtimeType=function(e){return e instanceof Function?e.displayName||e.name||"unknown type name":e instanceof Object?e.constructor.displayName||e.constructor.name||Object.prototype.toString.call(e):null===e?"null":typeof e},goog.debug.fnNameCache_={},goog.debug.LogRecord=function(e,t,o,n,i){this.reset(e,t,o,n,i)},goog.debug.LogRecord.prototype.sequenceNumber_=0,goog.debug.LogRecord.prototype.exception_=null,goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS=!0,goog.debug.LogRecord.nextSequenceNumber_=0,goog.debug.LogRecord.prototype.reset=function(e,t,o,n,i){goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS&&(this.sequenceNumber_="number"==typeof i?i:goog.debug.LogRecord.nextSequenceNumber_++),this.time_=n||goog.now(),this.level_=e,this.msg_=t,this.loggerName_=o,delete this.exception_},goog.debug.LogRecord.prototype.getLoggerName=function(){return this.loggerName_},goog.debug.LogRecord.prototype.getException=function(){return this.exception_},goog.debug.LogRecord.prototype.setException=function(e){this.exception_=e},goog.debug.LogRecord.prototype.setLoggerName=function(e){this.loggerName_=e},goog.debug.LogRecord.prototype.getLevel=function(){return this.level_},goog.debug.LogRecord.prototype.setLevel=function(e){this.level_=e},goog.debug.LogRecord.prototype.getMessage=function(){return this.msg_},goog.debug.LogRecord.prototype.setMessage=function(e){this.msg_=e},goog.debug.LogRecord.prototype.getMillis=function(){return this.time_},goog.debug.LogRecord.prototype.setMillis=function(e){this.time_=e},goog.debug.LogRecord.prototype.getSequenceNumber=function(){return this.sequenceNumber_},goog.debug.LogBuffer=function(){goog.asserts.assert(goog.debug.LogBuffer.isBufferingEnabled(),"Cannot use goog.debug.LogBuffer without defining goog.debug.LogBuffer.CAPACITY."),this.clear()},goog.debug.LogBuffer.getInstance=function(){return goog.debug.LogBuffer.instance_||(goog.debug.LogBuffer.instance_=new goog.debug.LogBuffer),goog.debug.LogBuffer.instance_},goog.debug.LogBuffer.CAPACITY=0,goog.debug.LogBuffer.prototype.addRecord=function(e,t,o){var n=(this.curIndex_+1)%goog.debug.LogBuffer.CAPACITY;return this.curIndex_=n,this.isFull_?((n=this.buffer_[n]).reset(e,t,o),n):(this.isFull_=n==goog.debug.LogBuffer.CAPACITY-1,this.buffer_[n]=new goog.debug.LogRecord(e,t,o))},goog.debug.LogBuffer.isBufferingEnabled=function(){return 0<goog.debug.LogBuffer.CAPACITY},goog.debug.LogBuffer.prototype.clear=function(){this.buffer_=Array(goog.debug.LogBuffer.CAPACITY),this.curIndex_=-1,this.isFull_=!1},goog.debug.LogBuffer.prototype.forEachRecord=function(e){var t=this.buffer_;if(t[0]){var o=this.curIndex_,n=this.isFull_?o:-1;do{e(t[n=(n+1)%goog.debug.LogBuffer.CAPACITY])}while(n!=o)}},goog.debug.Logger=function(e){this.name_=e,this.handlers_=this.children_=this.level_=this.parent_=null},goog.debug.Logger.ROOT_LOGGER_NAME="",goog.debug.Logger.ENABLE_HIERARCHY=!0,goog.debug.Logger.ENABLE_HIERARCHY||(goog.debug.Logger.rootHandlers_=[]),goog.debug.Logger.Level=function(e,t){this.name=e,this.value=t},goog.debug.Logger.Level.prototype.toString=function(){return this.name},goog.debug.Logger.Level.OFF=new goog.debug.Logger.Level("OFF",1/0),goog.debug.Logger.Level.SHOUT=new goog.debug.Logger.Level("SHOUT",1200),goog.debug.Logger.Level.SEVERE=new goog.debug.Logger.Level("SEVERE",1e3),goog.debug.Logger.Level.WARNING=new goog.debug.Logger.Level("WARNING",900),goog.debug.Logger.Level.INFO=new goog.debug.Logger.Level("INFO",800),goog.debug.Logger.Level.CONFIG=new goog.debug.Logger.Level("CONFIG",700),goog.debug.Logger.Level.FINE=new goog.debug.Logger.Level("FINE",500),goog.debug.Logger.Level.FINER=new goog.debug.Logger.Level("FINER",400),goog.debug.Logger.Level.FINEST=new goog.debug.Logger.Level("FINEST",300),goog.debug.Logger.Level.ALL=new goog.debug.Logger.Level("ALL",0),goog.debug.Logger.Level.PREDEFINED_LEVELS=[goog.debug.Logger.Level.OFF,goog.debug.Logger.Level.SHOUT,goog.debug.Logger.Level.SEVERE,goog.debug.Logger.Level.WARNING,goog.debug.Logger.Level.INFO,goog.debug.Logger.Level.CONFIG,goog.debug.Logger.Level.FINE,goog.debug.Logger.Level.FINER,goog.debug.Logger.Level.FINEST,goog.debug.Logger.Level.ALL],goog.debug.Logger.Level.predefinedLevelsCache_=null,goog.debug.Logger.Level.createPredefinedLevelsCache_=function(){goog.debug.Logger.Level.predefinedLevelsCache_={};for(var e,t=0;e=goog.debug.Logger.Level.PREDEFINED_LEVELS[t];t++)goog.debug.Logger.Level.predefinedLevelsCache_[e.value]=e,goog.debug.Logger.Level.predefinedLevelsCache_[e.name]=e},goog.debug.Logger.Level.getPredefinedLevel=function(e){return goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_(),goog.debug.Logger.Level.predefinedLevelsCache_[e]||null},goog.debug.Logger.Level.getPredefinedLevelByValue=function(e){if(goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_(),e in goog.debug.Logger.Level.predefinedLevelsCache_)return goog.debug.Logger.Level.predefinedLevelsCache_[e];for(var t=0;t<goog.debug.Logger.Level.PREDEFINED_LEVELS.length;++t){var o=goog.debug.Logger.Level.PREDEFINED_LEVELS[t];if(o.value<=e)return o}return null},goog.debug.Logger.getLogger=function(e){return goog.debug.LogManager.getLogger(e)},goog.debug.Logger.logToProfilers=function(e){goog.global.console&&(goog.global.console.timeStamp?goog.global.console.timeStamp(e):goog.global.console.markTimeline&&goog.global.console.markTimeline(e)),goog.global.msWriteProfilerMark&&goog.global.msWriteProfilerMark(e)},goog.debug.Logger.prototype.getName=function(){return this.name_},goog.debug.Logger.prototype.addHandler=function(e){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?(this.handlers_||(this.handlers_=[]),this.handlers_.push(e)):(goog.asserts.assert(!this.name_,"Cannot call addHandler on a non-root logger when goog.debug.Logger.ENABLE_HIERARCHY is false."),goog.debug.Logger.rootHandlers_.push(e)))},goog.debug.Logger.prototype.removeHandler=function(e){if(goog.debug.LOGGING_ENABLED){var t=goog.debug.Logger.ENABLE_HIERARCHY?this.handlers_:goog.debug.Logger.rootHandlers_;return!!t&&goog.array.remove(t,e)}return!1},goog.debug.Logger.prototype.getParent=function(){return this.parent_},goog.debug.Logger.prototype.getChildren=function(){return this.children_||(this.children_={}),this.children_},goog.debug.Logger.prototype.setLevel=function(e){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?this.level_=e:(goog.asserts.assert(!this.name_,"Cannot call setLevel() on a non-root logger when goog.debug.Logger.ENABLE_HIERARCHY is false."),goog.debug.Logger.rootLevel_=e))},goog.debug.Logger.prototype.getLevel=function(){return goog.debug.LOGGING_ENABLED?this.level_:goog.debug.Logger.Level.OFF},goog.debug.Logger.prototype.getEffectiveLevel=function(){return goog.debug.LOGGING_ENABLED?goog.debug.Logger.ENABLE_HIERARCHY?this.level_?this.level_:this.parent_?this.parent_.getEffectiveLevel():(goog.asserts.fail("Root logger has no level set."),null):goog.debug.Logger.rootLevel_:goog.debug.Logger.Level.OFF},goog.debug.Logger.prototype.isLoggable=function(e){return goog.debug.LOGGING_ENABLED&&e.value>=this.getEffectiveLevel().value},goog.debug.Logger.prototype.log=function(e,t,o){goog.debug.LOGGING_ENABLED&&this.isLoggable(e)&&(goog.isFunction(t)&&(t=t()),this.doLogRecord_(this.getLogRecord(e,t,o)))},goog.debug.Logger.prototype.getLogRecord=function(e,t,o){return e=goog.debug.LogBuffer.isBufferingEnabled()?goog.debug.LogBuffer.getInstance().addRecord(e,t,this.name_):new goog.debug.LogRecord(e,String(t),this.name_),o&&e.setException(o),e},goog.debug.Logger.prototype.shout=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SHOUT,e,t)},goog.debug.Logger.prototype.severe=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SEVERE,e,t)},goog.debug.Logger.prototype.warning=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.WARNING,e,t)},goog.debug.Logger.prototype.info=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.INFO,e,t)},goog.debug.Logger.prototype.config=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.CONFIG,e,t)},goog.debug.Logger.prototype.fine=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINE,e,t)},goog.debug.Logger.prototype.finer=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINER,e,t)},goog.debug.Logger.prototype.finest=function(e,t){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINEST,e,t)},goog.debug.Logger.prototype.logRecord=function(e){goog.debug.LOGGING_ENABLED&&this.isLoggable(e.getLevel())&&this.doLogRecord_(e)},goog.debug.Logger.prototype.doLogRecord_=function(e){if(goog.debug.Logger.logToProfilers("log:"+e.getMessage()),goog.debug.Logger.ENABLE_HIERARCHY)for(var t=this;t;)t.callPublish_(e),t=t.getParent();else{t=0;for(var o;o=goog.debug.Logger.rootHandlers_[t++];)o(e)}},goog.debug.Logger.prototype.callPublish_=function(e){if(this.handlers_)for(var t,o=0;t=this.handlers_[o];o++)t(e)},goog.debug.Logger.prototype.setParent_=function(e){this.parent_=e},goog.debug.Logger.prototype.addChild_=function(e,t){this.getChildren()[e]=t},goog.debug.LogManager={},goog.debug.LogManager.loggers_={},goog.debug.LogManager.rootLogger_=null,goog.debug.LogManager.initialize=function(){goog.debug.LogManager.rootLogger_||(goog.debug.LogManager.rootLogger_=new goog.debug.Logger(goog.debug.Logger.ROOT_LOGGER_NAME),goog.debug.LogManager.loggers_[goog.debug.Logger.ROOT_LOGGER_NAME]=goog.debug.LogManager.rootLogger_,goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG))},goog.debug.LogManager.getLoggers=function(){return goog.debug.LogManager.loggers_},goog.debug.LogManager.getRoot=function(){return goog.debug.LogManager.initialize(),goog.debug.LogManager.rootLogger_},goog.debug.LogManager.getLogger=function(e){return goog.debug.LogManager.initialize(),goog.debug.LogManager.loggers_[e]||goog.debug.LogManager.createLogger_(e)},goog.debug.LogManager.createFunctionForCatchErrors=function(e){return function(t){(e||goog.debug.LogManager.getRoot()).severe("Error: "+t.message+" ("+t.fileName+" @ Line: "+t.line+")")}},goog.debug.LogManager.createLogger_=function(e){var t=new goog.debug.Logger(e);if(goog.debug.Logger.ENABLE_HIERARCHY){var o=e.lastIndexOf("."),n=e.substr(0,o);o=e.substr(o+1),(n=goog.debug.LogManager.getLogger(n)).addChild_(o,t),t.setParent_(n)}return goog.debug.LogManager.loggers_[e]=t},goog.log={},goog.log.ENABLED=goog.debug.LOGGING_ENABLED,goog.log.ROOT_LOGGER_NAME=goog.debug.Logger.ROOT_LOGGER_NAME,goog.log.Logger=goog.debug.Logger,goog.log.Level=goog.debug.Logger.Level,goog.log.LogRecord=goog.debug.LogRecord,goog.log.getLogger=function(e,t){return goog.log.ENABLED?(e=goog.debug.LogManager.getLogger(e),t&&e&&e.setLevel(t),e):null},goog.log.addHandler=function(e,t){goog.log.ENABLED&&e&&e.addHandler(t)},goog.log.removeHandler=function(e,t){return!(!goog.log.ENABLED||!e)&&e.removeHandler(t)},goog.log.log=function(e,t,o,n){goog.log.ENABLED&&e&&e.log(t,o,n)},goog.log.error=function(e,t,o){goog.log.ENABLED&&e&&e.severe(t,o)},goog.log.warning=function(e,t,o){goog.log.ENABLED&&e&&e.warning(t,o)},goog.log.info=function(e,t,o){goog.log.ENABLED&&e&&e.info(t,o)},goog.log.fine=function(e,t,o){goog.log.ENABLED&&e&&e.fine(t,o)},goog.Thenable=function(){},goog.Thenable.prototype.then=function(e,t,o){},goog.Thenable.IMPLEMENTED_BY_PROP="$goog_Thenable",goog.Thenable.addImplementation=function(e){e.prototype.then=e.prototype.then,COMPILED?e.prototype[goog.Thenable.IMPLEMENTED_BY_PROP]=!0:e.prototype.$goog_Thenable=!0},goog.Thenable.isImplementedBy=function(e){if(!e)return!1;try{return COMPILED?!!e[goog.Thenable.IMPLEMENTED_BY_PROP]:!!e.$goog_Thenable}catch(e){return!1}},goog.async.FreeList=function(e,t,o){this.limit_=o,this.create_=e,this.reset_=t,this.occupants_=0,this.head_=null},goog.async.FreeList.prototype.get=function(){if(0<this.occupants_){this.occupants_--;var e=this.head_;this.head_=e.next,e.next=null}else e=this.create_();return e},goog.async.FreeList.prototype.put=function(e){this.reset_(e),this.occupants_<this.limit_&&(this.occupants_++,e.next=this.head_,this.head_=e)},goog.async.FreeList.prototype.occupants=function(){return this.occupants_},goog.async.WorkQueue=function(){this.workTail_=this.workHead_=null},goog.async.WorkQueue.DEFAULT_MAX_UNUSED=100,goog.async.WorkQueue.freelist_=new goog.async.FreeList(function(){return new goog.async.WorkItem},function(e){e.reset()},goog.async.WorkQueue.DEFAULT_MAX_UNUSED),goog.async.WorkQueue.prototype.add=function(e,t){var o=this.getUnusedItem_();o.set(e,t),this.workTail_?this.workTail_.next=o:(goog.asserts.assert(!this.workHead_),this.workHead_=o),this.workTail_=o},goog.async.WorkQueue.prototype.remove=function(){var e=null;return this.workHead_&&(e=this.workHead_,this.workHead_=this.workHead_.next,this.workHead_||(this.workTail_=null),e.next=null),e},goog.async.WorkQueue.prototype.returnUnused=function(e){goog.async.WorkQueue.freelist_.put(e)},goog.async.WorkQueue.prototype.getUnusedItem_=function(){return goog.async.WorkQueue.freelist_.get()},goog.async.WorkItem=function(){this.next=this.scope=this.fn=null},goog.async.WorkItem.prototype.set=function(e,t){this.fn=e,this.scope=t,this.next=null},goog.async.WorkItem.prototype.reset=function(){this.next=this.scope=this.fn=null},goog.async.throwException=function(e){goog.global.setTimeout(function(){throw e},0)},goog.async.nextTick=function(e,t,o){var n=e;t&&(n=goog.bind(e,t)),n=goog.async.nextTick.wrapCallback_(n),goog.isFunction(goog.global.setImmediate)&&(o||goog.async.nextTick.useSetImmediate_())?goog.global.setImmediate(n):(goog.async.nextTick.setImmediate_||(goog.async.nextTick.setImmediate_=goog.async.nextTick.getSetImmediateEmulator_()),goog.async.nextTick.setImmediate_(n))},goog.async.nextTick.useSetImmediate_=function(){return!(goog.global.Window&&goog.global.Window.prototype&&!goog.labs.userAgent.browser.isEdge()&&goog.global.Window.prototype.setImmediate==goog.global.setImmediate)},goog.async.nextTick.getSetImmediateEmulator_=function(){var e=goog.global.MessageChannel;if(void 0===e&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!goog.labs.userAgent.engine.isPresto()&&(e=function(){var e=document.createElement("IFRAME");e.style.display="none",e.src="",document.documentElement.appendChild(e);var t=e.contentWindow;(e=t.document).open(),e.write(""),e.close();var o="callImmediate"+Math.random(),n="file:"==t.location.protocol?"*":t.location.protocol+"//"+t.location.host;e=goog.bind(function(e){"*"!=n&&e.origin!=n||e.data!=o||this.port1.onmessage()},this),t.addEventListener("message",e,!1),this.port1={},this.port2={postMessage:function(){t.postMessage(o,n)}}}),void 0!==e&&!goog.labs.userAgent.browser.isIE()){var t=new e,o={},n=o;return t.port1.onmessage=function(){if(goog.isDef(o.next)){var e=(o=o.next).cb;o.cb=null,e()}},function(e){n.next={cb:e},n=n.next,t.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(e){var t=document.createElement("SCRIPT");t.onreadystatechange=function(){t.onreadystatechange=null,t.parentNode.removeChild(t),t=null,e(),e=null},document.documentElement.appendChild(t)}:function(e){goog.global.setTimeout(e,0)}},goog.async.nextTick.wrapCallback_=goog.functions.identity,goog.debug.entryPointRegistry.register(function(e){goog.async.nextTick.wrapCallback_=e}),goog.async.run=function(e,t){goog.async.run.schedule_||goog.async.run.initializeRunner_(),goog.async.run.workQueueScheduled_||(goog.async.run.schedule_(),goog.async.run.workQueueScheduled_=!0),goog.async.run.workQueue_.add(e,t)},goog.async.run.initializeRunner_=function(){if(-1!=String(goog.global.Promise).indexOf("[native code]")){var e=goog.global.Promise.resolve(void 0);goog.async.run.schedule_=function(){e.then(goog.async.run.processWorkQueue)}}else goog.async.run.schedule_=function(){goog.async.nextTick(goog.async.run.processWorkQueue)}},goog.async.run.forceNextTick=function(e){goog.async.run.schedule_=function(){goog.async.nextTick(goog.async.run.processWorkQueue),e&&e(goog.async.run.processWorkQueue)}},goog.async.run.workQueueScheduled_=!1,goog.async.run.workQueue_=new goog.async.WorkQueue,goog.DEBUG&&(goog.async.run.resetQueue=function(){goog.async.run.workQueueScheduled_=!1,goog.async.run.workQueue_=new goog.async.WorkQueue}),goog.async.run.processWorkQueue=function(){for(var e;e=goog.async.run.workQueue_.remove();){try{e.fn.call(e.scope)}catch(e){goog.async.throwException(e)}goog.async.run.workQueue_.returnUnused(e)}goog.async.run.workQueueScheduled_=!1},goog.promise={},goog.promise.Resolver=function(){},goog.Promise=function(e,t){if(this.state_=goog.Promise.State_.PENDING,this.result_=void 0,this.callbackEntriesTail_=this.callbackEntries_=this.parent_=null,this.executing_=!1,0<goog.Promise.UNHANDLED_REJECTION_DELAY?this.unhandledRejectionId_=0:0==goog.Promise.UNHANDLED_REJECTION_DELAY&&(this.hadUnhandledRejection_=!1),goog.Promise.LONG_STACK_TRACES&&(this.stack_=[],this.addStackTrace_(Error("created")),this.currentStep_=0),e!=goog.nullFunction)try{var o=this;e.call(t,function(e){o.resolve_(goog.Promise.State_.FULFILLED,e)},function(e){if(goog.DEBUG&&!(e instanceof goog.Promise.CancellationError))try{if(e instanceof Error)throw e;throw Error("Promise rejected.")}catch(e){}o.resolve_(goog.Promise.State_.REJECTED,e)})}catch(e){this.resolve_(goog.Promise.State_.REJECTED,e)}},goog.Promise.LONG_STACK_TRACES=!1,goog.Promise.UNHANDLED_REJECTION_DELAY=0,goog.Promise.State_={PENDING:0,BLOCKED:1,FULFILLED:2,REJECTED:3},goog.Promise.CallbackEntry_=function(){this.next=this.context=this.onRejected=this.onFulfilled=this.child=null,this.always=!1},goog.Promise.CallbackEntry_.prototype.reset=function(){this.context=this.onRejected=this.onFulfilled=this.child=null,this.always=!1},goog.Promise.DEFAULT_MAX_UNUSED=100,goog.Promise.freelist_=new goog.async.FreeList(function(){return new goog.Promise.CallbackEntry_},function(e){e.reset()},goog.Promise.DEFAULT_MAX_UNUSED),goog.Promise.getCallbackEntry_=function(e,t,o){var n=goog.Promise.freelist_.get();return n.onFulfilled=e,n.onRejected=t,n.context=o,n},goog.Promise.returnEntry_=function(e){goog.Promise.freelist_.put(e)},goog.Promise.resolve=function(e){if(e instanceof goog.Promise)return e;var t=new goog.Promise(goog.nullFunction);return t.resolve_(goog.Promise.State_.FULFILLED,e),t},goog.Promise.reject=function(e){return new goog.Promise(function(t,o){o(e)})},goog.Promise.resolveThen_=function(e,t,o){goog.Promise.maybeThen_(e,t,o,null)||goog.async.run(goog.partial(t,e))},goog.Promise.race=function(e){return new goog.Promise(function(t,o){e.length||t(void 0);for(var n,i=0;i<e.length;i++)n=e[i],goog.Promise.resolveThen_(n,t,o)})},goog.Promise.all=function(e){return new goog.Promise(function(t,o){var n=e.length,i=[];if(n)for(var r,l=function(e,o){n--,i[e]=o,0==n&&t(i)},s=function(e){o(e)},a=0;a<e.length;a++)r=e[a],goog.Promise.resolveThen_(r,goog.partial(l,a),s);else t(i)})},goog.Promise.allSettled=function(e){return new goog.Promise(function(t,o){var n=e.length,i=[];if(n){o=function(e,o,r){n--,i[e]=o?{fulfilled:!0,value:r}:{fulfilled:!1,reason:r},0==n&&t(i)};for(var r,l=0;l<e.length;l++)r=e[l],goog.Promise.resolveThen_(r,goog.partial(o,l,!0),goog.partial(o,l,!1))}else t(i)})},goog.Promise.firstFulfilled=function(e){return new goog.Promise(function(t,o){var n=e.length,i=[];if(n)for(var r,l=function(e){t(e)},s=function(e,t){n--,i[e]=t,0==n&&o(i)},a=0;a<e.length;a++)r=e[a],goog.Promise.resolveThen_(r,l,goog.partial(s,a));else t(void 0)})},goog.Promise.withResolver=function(){var e,t,o=new goog.Promise(function(o,n){e=o,t=n});return new goog.Promise.Resolver_(o,e,t)},goog.Promise.prototype.then=function(e,t,o){return null!=e&&goog.asserts.assertFunction(e,"opt_onFulfilled should be a function."),null!=t&&goog.asserts.assertFunction(t,"opt_onRejected should be a function. Did you pass opt_context as the second argument instead of the third?"),goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("then")),this.addChildPromise_(goog.isFunction(e)?e:null,goog.isFunction(t)?t:null,o)},goog.Thenable.addImplementation(goog.Promise),goog.Promise.prototype.thenVoid=function(e,t,o){null!=e&&goog.asserts.assertFunction(e,"opt_onFulfilled should be a function."),null!=t&&goog.asserts.assertFunction(t,"opt_onRejected should be a function. Did you pass opt_context as the second argument instead of the third?"),goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("then")),this.addCallbackEntry_(goog.Promise.getCallbackEntry_(e||goog.nullFunction,t||null,o))},goog.Promise.prototype.thenAlways=function(e,t){return goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("thenAlways")),(e=goog.Promise.getCallbackEntry_(e,e,t)).always=!0,this.addCallbackEntry_(e),this},goog.Promise.prototype.thenCatch=function(e,t){return goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("thenCatch")),this.addChildPromise_(null,e,t)},goog.Promise.prototype.cancel=function(e){this.state_==goog.Promise.State_.PENDING&&goog.async.run(function(){var t=new goog.Promise.CancellationError(e);this.cancelInternal_(t)},this)},goog.Promise.prototype.cancelInternal_=function(e){this.state_==goog.Promise.State_.PENDING&&(this.parent_?(this.parent_.cancelChild_(this,e),this.parent_=null):this.resolve_(goog.Promise.State_.REJECTED,e))},goog.Promise.prototype.cancelChild_=function(e,t){if(this.callbackEntries_){for(var o=0,n=null,i=null,r=this.callbackEntries_;r&&(r.always||(o++,r.child==e&&(n=r),!(n&&1<o)));r=r.next)n||(i=r);n&&(this.state_==goog.Promise.State_.PENDING&&1==o?this.cancelInternal_(t):(i?this.removeEntryAfter_(i):this.popEntry_(),this.executeCallback_(n,goog.Promise.State_.REJECTED,t)))}},goog.Promise.prototype.addCallbackEntry_=function(e){this.hasEntry_()||this.state_!=goog.Promise.State_.FULFILLED&&this.state_!=goog.Promise.State_.REJECTED||this.scheduleCallbacks_(),this.queueEntry_(e)},goog.Promise.prototype.addChildPromise_=function(e,t,o){var n=goog.Promise.getCallbackEntry_(null,null,null);return n.child=new goog.Promise(function(i,r){n.onFulfilled=e?function(t){try{var n=e.call(o,t);i(n)}catch(e){r(e)}}:i,n.onRejected=t?function(e){try{var n=t.call(o,e);!goog.isDef(n)&&e instanceof goog.Promise.CancellationError?r(e):i(n)}catch(e){r(e)}}:r}),n.child.parent_=this,this.addCallbackEntry_(n),n.child},goog.Promise.prototype.unblockAndFulfill_=function(e){goog.asserts.assert(this.state_==goog.Promise.State_.BLOCKED),this.state_=goog.Promise.State_.PENDING,this.resolve_(goog.Promise.State_.FULFILLED,e)},goog.Promise.prototype.unblockAndReject_=function(e){goog.asserts.assert(this.state_==goog.Promise.State_.BLOCKED),this.state_=goog.Promise.State_.PENDING,this.resolve_(goog.Promise.State_.REJECTED,e)},goog.Promise.prototype.resolve_=function(e,t){this.state_==goog.Promise.State_.PENDING&&(this===t&&(e=goog.Promise.State_.REJECTED,t=new TypeError("Promise cannot resolve to itself")),this.state_=goog.Promise.State_.BLOCKED,goog.Promise.maybeThen_(t,this.unblockAndFulfill_,this.unblockAndReject_,this)||(this.result_=t,this.state_=e,this.parent_=null,this.scheduleCallbacks_(),e!=goog.Promise.State_.REJECTED||t instanceof goog.Promise.CancellationError||goog.Promise.addUnhandledRejection_(this,t)))},goog.Promise.maybeThen_=function(e,t,o,n){if(e instanceof goog.Promise)return e.thenVoid(t,o,n),!0;if(goog.Thenable.isImplementedBy(e))return e.then(t,o,n),!0;if(goog.isObject(e))try{var i=e.then;if(goog.isFunction(i))return goog.Promise.tryThen_(e,i,t,o,n),!0}catch(e){return o.call(n,e),!0}return!1},goog.Promise.tryThen_=function(e,t,o,n,i){var r=!1,l=function(e){r||(r=!0,n.call(i,e))};try{t.call(e,function(e){r||(r=!0,o.call(i,e))},l)}catch(e){l(e)}},goog.Promise.prototype.scheduleCallbacks_=function(){this.executing_||(this.executing_=!0,goog.async.run(this.executeCallbacks_,this))},goog.Promise.prototype.hasEntry_=function(){return!!this.callbackEntries_},goog.Promise.prototype.queueEntry_=function(e){goog.asserts.assert(null!=e.onFulfilled),this.callbackEntriesTail_?this.callbackEntriesTail_.next=e:this.callbackEntries_=e,this.callbackEntriesTail_=e},goog.Promise.prototype.popEntry_=function(){var e=null;return this.callbackEntries_&&(e=this.callbackEntries_,this.callbackEntries_=e.next,e.next=null),this.callbackEntries_||(this.callbackEntriesTail_=null),null!=e&&goog.asserts.assert(null!=e.onFulfilled),e},goog.Promise.prototype.removeEntryAfter_=function(e){goog.asserts.assert(this.callbackEntries_),goog.asserts.assert(null!=e),e.next==this.callbackEntriesTail_&&(this.callbackEntriesTail_=e),e.next=e.next.next},goog.Promise.prototype.executeCallbacks_=function(){for(var e;e=this.popEntry_();)goog.Promise.LONG_STACK_TRACES&&this.currentStep_++,this.executeCallback_(e,this.state_,this.result_);this.executing_=!1},goog.Promise.prototype.executeCallback_=function(e,t,o){if(t==goog.Promise.State_.REJECTED&&e.onRejected&&!e.always&&this.removeUnhandledRejection_(),e.child)e.child.parent_=null,goog.Promise.invokeCallback_(e,t,o);else try{e.always?e.onFulfilled.call(e.context):goog.Promise.invokeCallback_(e,t,o)}catch(e){goog.Promise.handleRejection_.call(null,e)}goog.Promise.returnEntry_(e)},goog.Promise.invokeCallback_=function(e,t,o){t==goog.Promise.State_.FULFILLED?e.onFulfilled.call(e.context,o):e.onRejected&&e.onRejected.call(e.context,o)},goog.Promise.prototype.addStackTrace_=function(e){if(goog.Promise.LONG_STACK_TRACES&&goog.isString(e.stack)){var t=e.stack.split("\n",4)[3];e=e.message,e+=Array(11-e.length).join(" "),this.stack_.push(e+t)}},goog.Promise.prototype.appendLongStack_=function(e){if(goog.Promise.LONG_STACK_TRACES&&e&&goog.isString(e.stack)&&this.stack_.length){for(var t=["Promise trace:"],o=this;o;o=o.parent_){for(var n=this.currentStep_;0<=n;n--)t.push(o.stack_[n]);t.push("Value: ["+(o.state_==goog.Promise.State_.REJECTED?"REJECTED":"FULFILLED")+"] <"+String(o.result_)+">")}e.stack+="\n\n"+t.join("\n")}},goog.Promise.prototype.removeUnhandledRejection_=function(){if(0<goog.Promise.UNHANDLED_REJECTION_DELAY)for(var e=this;e&&e.unhandledRejectionId_;e=e.parent_)goog.global.clearTimeout(e.unhandledRejectionId_),e.unhandledRejectionId_=0;else if(0==goog.Promise.UNHANDLED_REJECTION_DELAY)for(e=this;e&&e.hadUnhandledRejection_;e=e.parent_)e.hadUnhandledRejection_=!1},goog.Promise.addUnhandledRejection_=function(e,t){0<goog.Promise.UNHANDLED_REJECTION_DELAY?e.unhandledRejectionId_=goog.global.setTimeout(function(){e.appendLongStack_(t),goog.Promise.handleRejection_.call(null,t)},goog.Promise.UNHANDLED_REJECTION_DELAY):0==goog.Promise.UNHANDLED_REJECTION_DELAY&&(e.hadUnhandledRejection_=!0,goog.async.run(function(){e.hadUnhandledRejection_&&(e.appendLongStack_(t),goog.Promise.handleRejection_.call(null,t))}))},goog.Promise.handleRejection_=goog.async.throwException,goog.Promise.setUnhandledRejectionHandler=function(e){goog.Promise.handleRejection_=e},goog.Promise.CancellationError=function(e){goog.debug.Error.call(this,e)},goog.inherits(goog.Promise.CancellationError,goog.debug.Error),goog.Promise.CancellationError.prototype.name="cancel",goog.Promise.Resolver_=function(e,t,o){this.promise=e,this.resolve=t,this.reject=o},goog.Timer=function(e,t){goog.events.EventTarget.call(this),this.interval_=e||1,this.timerObject_=t||goog.Timer.defaultTimerObject,this.boundTick_=goog.bind(this.tick_,this),this.last_=goog.now()},goog.inherits(goog.Timer,goog.events.EventTarget),goog.Timer.MAX_TIMEOUT_=2147483647,goog.Timer.INVALID_TIMEOUT_ID_=-1,goog.Timer.prototype.enabled=!1,goog.Timer.defaultTimerObject=goog.global,goog.Timer.intervalScale=.8,goog.Timer.prototype.timer_=null,goog.Timer.prototype.getInterval=function(){return this.interval_},goog.Timer.prototype.setInterval=function(e){this.interval_=e,this.timer_&&this.enabled?(this.stop(),this.start()):this.timer_&&this.stop()},goog.Timer.prototype.tick_=function(){if(this.enabled){var e=goog.now()-this.last_;0<e&&e<this.interval_*goog.Timer.intervalScale?this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_-e):(this.timer_&&(this.timerObject_.clearTimeout(this.timer_),this.timer_=null),this.dispatchTick(),this.enabled&&(this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_),this.last_=goog.now()))}},goog.Timer.prototype.dispatchTick=function(){this.dispatchEvent(goog.Timer.TICK)},goog.Timer.prototype.start=function(){this.enabled=!0,this.timer_||(this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_),this.last_=goog.now())},goog.Timer.prototype.stop=function(){this.enabled=!1,this.timer_&&(this.timerObject_.clearTimeout(this.timer_),this.timer_=null)},goog.Timer.prototype.disposeInternal=function(){goog.Timer.superClass_.disposeInternal.call(this),this.stop(),delete this.timerObject_},goog.Timer.TICK="tick",goog.Timer.callOnce=function(e,t,o){if(goog.isFunction(e))o&&(e=goog.bind(e,o));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=goog.bind(e.handleEvent,e)}return Number(t)>goog.Timer.MAX_TIMEOUT_?goog.Timer.INVALID_TIMEOUT_ID_:goog.Timer.defaultTimerObject.setTimeout(e,t||0)},goog.Timer.clear=function(e){goog.Timer.defaultTimerObject.clearTimeout(e)},goog.Timer.promise=function(e,t){var o=null;return new goog.Promise(function(n,i){(o=goog.Timer.callOnce(function(){n(t)},e))==goog.Timer.INVALID_TIMEOUT_ID_&&i(Error("Failed to schedule timer."))}).thenCatch(function(e){throw goog.Timer.clear(o),e})},goog.string.StringBuffer=function(e,t){null!=e&&this.append.apply(this,arguments)},goog.string.StringBuffer.prototype.buffer_="",goog.string.StringBuffer.prototype.set=function(e){this.buffer_=""+e},goog.string.StringBuffer.prototype.append=function(e,t,o){if(this.buffer_+=String(e),null!=t)for(var n=1;n<arguments.length;n++)this.buffer_+=arguments[n];return this},goog.string.StringBuffer.prototype.clear=function(){this.buffer_=""},goog.string.StringBuffer.prototype.getLength=function(){return this.buffer_.length},goog.string.StringBuffer.prototype.toString=function(){return this.buffer_},goog.ui.tree={},goog.ui.tree.BaseNode=function(e,t,o){goog.ui.Component.call(this,o),this.config_=t||goog.ui.tree.BaseNode.defaultConfig,this.html_=goog.html.SafeHtml.htmlEscapePreservingNewlines(e),this.expanded_=this.selected_=!1,this.toolTip_=null,this.afterLabelHtml_=goog.html.SafeHtml.EMPTY,this.isUserCollapsible_=!0,this.depth_=-1},goog.inherits(goog.ui.tree.BaseNode,goog.ui.Component),goog.ui.tree.BaseNode.EventType={BEFORE_EXPAND:"beforeexpand",EXPAND:"expand",BEFORE_COLLAPSE:"beforecollapse",COLLAPSE:"collapse"},goog.ui.tree.BaseNode.allNodes={},goog.ui.tree.BaseNode.prototype.disposeInternal=function(){goog.ui.tree.BaseNode.superClass_.disposeInternal.call(this),this.tree&&(this.tree.removeNode(this),this.tree=null),this.setElementInternal(null)},goog.ui.tree.BaseNode.prototype.initAccessibility=function(){var e=this.getElement();if(e){var t=this.getLabelElement();if(t&&!t.id&&(t.id=this.getId()+".label"),goog.a11y.aria.setRole(e,"treeitem"),goog.a11y.aria.setState(e,"selected",!1),goog.a11y.aria.setState(e,"expanded",!1),goog.a11y.aria.setState(e,"level",this.getDepth()),t&&goog.a11y.aria.setState(e,"labelledby",t.id),(e=this.getIconElement())&&goog.a11y.aria.setRole(e,"presentation"),(e=this.getExpandIconElement())&&goog.a11y.aria.setRole(e,"presentation"),(e=this.getChildrenElement())&&(goog.a11y.aria.setRole(e,"group"),e.hasChildNodes()))for(e=this.getChildCount(),t=1;t<=e;t++){var o=this.getChildAt(t-1).getElement();goog.asserts.assert(o,"The child element cannot be null"),goog.a11y.aria.setState(o,"setsize",e),goog.a11y.aria.setState(o,"posinset",t)}}},goog.ui.tree.BaseNode.prototype.createDom=function(){var e=this.getDomHelper().safeHtmlToNode(this.toSafeHtml());this.setElementInternal(e)},goog.ui.tree.BaseNode.prototype.enterDocument=function(){goog.ui.tree.BaseNode.superClass_.enterDocument.call(this),goog.ui.tree.BaseNode.allNodes[this.getId()]=this,this.initAccessibility()},goog.ui.tree.BaseNode.prototype.exitDocument=function(){goog.ui.tree.BaseNode.superClass_.exitDocument.call(this),delete goog.ui.tree.BaseNode.allNodes[this.getId()]},goog.ui.tree.BaseNode.prototype.addChildAt=function(e,t,o){goog.asserts.assert(!e.getParent()),goog.asserts.assertInstanceof(e,goog.ui.tree.BaseNode),o=this.getChildAt(t-1);var n=this.getChildAt(t);if(goog.ui.tree.BaseNode.superClass_.addChildAt.call(this,e,t),e.previousSibling_=o,e.nextSibling_=n,o?o.nextSibling_=e:this.firstChild_=e,n?n.previousSibling_=e:this.lastChild_=e,(t=this.getTree())&&e.setTreeInternal(t),e.setDepth_(this.getDepth()+1),this.getElement()&&(this.updateExpandIcon(),this.getExpanded())){t=this.getChildrenElement(),e.getElement()||e.createDom();var i=e.getElement(),r=n&&n.getElement();t.insertBefore(i,r),this.isInDocument()&&e.enterDocument(),n||(o?o.updateExpandIcon():(goog.style.setElementShown(t,!0),this.setExpanded(this.getExpanded())))}},goog.ui.tree.BaseNode.prototype.add=function(e,t){return goog.asserts.assert(!t||t.getParent()==this,"Can only add nodes before siblings"),e.getParent()&&e.getParent().removeChild(e),this.addChildAt(e,t?this.indexOfChild(t):this.getChildCount()),e},goog.ui.tree.BaseNode.prototype.removeChild=function(e,t){var o=this.getTree();if(((t=o?o.getSelectedItem():null)==e||e.contains(t))&&(o.hasFocus()?(this.select(),goog.Timer.callOnce(this.onTimeoutSelect_,10,this)):this.select()),goog.ui.tree.BaseNode.superClass_.removeChild.call(this,e),this.lastChild_==e&&(this.lastChild_=e.previousSibling_),this.firstChild_==e&&(this.firstChild_=e.nextSibling_),e.previousSibling_&&(e.previousSibling_.nextSibling_=e.nextSibling_),e.nextSibling_&&(e.nextSibling_.previousSibling_=e.previousSibling_),t=e.isLastSibling(),e.tree=null,e.depth_=-1,o&&(o.removeNode(e),this.isInDocument())){if(o=this.getChildrenElement(),e.isInDocument()){var n=e.getElement();o.removeChild(n),e.exitDocument()}t&&(t=this.getLastChild())&&t.updateExpandIcon(),this.hasChildren()||(o.style.display="none",this.updateExpandIcon(),this.updateIcon_())}return e},goog.ui.tree.BaseNode.prototype.remove=goog.ui.tree.BaseNode.prototype.removeChild,goog.ui.tree.BaseNode.prototype.onTimeoutSelect_=function(){this.select()},goog.ui.tree.BaseNode.prototype.getTree=goog.abstractMethod,goog.ui.tree.BaseNode.prototype.getDepth=function(){var e=this.depth_;return 0>e&&(e=this.computeDepth_(),this.setDepth_(e)),e},goog.ui.tree.BaseNode.prototype.computeDepth_=function(){var e=this.getParent();return e?e.getDepth()+1:0},goog.ui.tree.BaseNode.prototype.setDepth_=function(e){if(e!=this.depth_){this.depth_=e;var t=this.getRowElement();if(t){var o=this.getPixelIndent_()+"px";this.isRightToLeft()?t.style.paddingRight=o:t.style.paddingLeft=o}this.forEachChild(function(t){t.setDepth_(e+1)})}},goog.ui.tree.BaseNode.prototype.contains=function(e){for(;e;){if(e==this)return!0;e=e.getParent()}return!1},goog.ui.tree.BaseNode.EMPTY_CHILDREN_=[],goog.ui.tree.BaseNode.prototype.getChildren=function(){var e=[];return this.forEachChild(function(t){e.push(t)}),e},goog.ui.tree.BaseNode.prototype.getFirstChild=function(){return this.getChildAt(0)},goog.ui.tree.BaseNode.prototype.getLastChild=function(){return this.getChildAt(this.getChildCount()-1)},goog.ui.tree.BaseNode.prototype.getPreviousSibling=function(){return this.previousSibling_},goog.ui.tree.BaseNode.prototype.getNextSibling=function(){return this.nextSibling_},goog.ui.tree.BaseNode.prototype.isLastSibling=function(){return!this.nextSibling_},goog.ui.tree.BaseNode.prototype.isSelected=function(){return this.selected_},goog.ui.tree.BaseNode.prototype.select=function(){var e=this.getTree();e&&e.setSelectedItem(this)},goog.ui.tree.BaseNode.prototype.deselect=goog.nullFunction,goog.ui.tree.BaseNode.prototype.setSelectedInternal=function(e){if(this.selected_!=e){this.selected_=e,this.updateRow();var t=this.getElement();t&&(goog.a11y.aria.setState(t,"selected",e),e&&(e=this.getTree().getElement(),goog.asserts.assert(e,"The DOM element for the tree cannot be null"),goog.a11y.aria.setState(e,"activedescendant",this.getId())))}},goog.ui.tree.BaseNode.prototype.getExpanded=function(){return this.expanded_},goog.ui.tree.BaseNode.prototype.setExpandedInternal=function(e){this.expanded_=e},goog.ui.tree.BaseNode.prototype.setExpanded=function(e){var t=e!=this.expanded_;if(!t||this.dispatchEvent(e?goog.ui.tree.BaseNode.EventType.BEFORE_EXPAND:goog.ui.tree.BaseNode.EventType.BEFORE_COLLAPSE)){this.expanded_=e;var o=this.getTree(),n=this.getElement();if(this.hasChildren()){if(!e&&o&&this.contains(o.getSelectedItem())&&this.select(),n){if((o=this.getChildrenElement())&&(goog.style.setElementShown(o,e),e&&this.isInDocument()&&!o.hasChildNodes())){var i=[];this.forEachChild(function(e){i.push(e.toSafeHtml())}),goog.dom.safe.setInnerHtml(o,goog.html.SafeHtml.concat(i)),this.forEachChild(function(e){e.enterDocument()})}this.updateExpandIcon()}}else(o=this.getChildrenElement())&&goog.style.setElementShown(o,!1);n&&(this.updateIcon_(),goog.a11y.aria.setState(n,"expanded",e)),t&&this.dispatchEvent(e?goog.ui.tree.BaseNode.EventType.EXPAND:goog.ui.tree.BaseNode.EventType.COLLAPSE)}},goog.ui.tree.BaseNode.prototype.toggle=function(){this.setExpanded(!this.getExpanded())},goog.ui.tree.BaseNode.prototype.expand=function(){this.setExpanded(!0)},goog.ui.tree.BaseNode.prototype.collapse=function(){this.setExpanded(!1)},goog.ui.tree.BaseNode.prototype.collapseChildren=function(){this.forEachChild(function(e){e.collapseAll()})},goog.ui.tree.BaseNode.prototype.collapseAll=function(){this.collapseChildren(),this.collapse()},goog.ui.tree.BaseNode.prototype.expandChildren=function(){this.forEachChild(function(e){e.expandAll()})},goog.ui.tree.BaseNode.prototype.expandAll=function(){this.expandChildren(),this.expand()},goog.ui.tree.BaseNode.prototype.reveal=function(){var e=this.getParent();e&&(e.setExpanded(!0),e.reveal())},goog.ui.tree.BaseNode.prototype.setIsUserCollapsible=function(e){(this.isUserCollapsible_=e)||this.expand(),this.getElement()&&this.updateExpandIcon()},goog.ui.tree.BaseNode.prototype.isUserCollapsible=function(){return this.isUserCollapsible_},goog.ui.tree.BaseNode.prototype.toSafeHtml=function(){var e=this.getTree(),t=!e.getShowLines()||e==this.getParent()&&!e.getShowRootLines()?this.config_.cssChildrenNoLines:this.config_.cssChildren;e=this.getExpanded()&&this.hasChildren(),t={class:t,style:this.getLineStyle()};var o=[];return e&&this.forEachChild(function(e){o.push(e.toSafeHtml())}),e=goog.html.SafeHtml.create("div",t,o),goog.html.SafeHtml.create("div",{class:this.config_.cssItem,id:this.getId()},[this.getRowSafeHtml(),e])},goog.ui.tree.BaseNode.prototype.getPixelIndent_=function(){return Math.max(0,(this.getDepth()-1)*this.config_.indentWidth)},goog.ui.tree.BaseNode.prototype.getRowSafeHtml=function(){var e={};e["padding-"+(this.isRightToLeft()?"right":"left")]=this.getPixelIndent_()+"px",e={class:this.getRowClassName(),style:e};var t=[this.getExpandIconSafeHtml(),this.getIconSafeHtml(),this.getLabelSafeHtml()];return goog.html.SafeHtml.create("div",e,t)},goog.ui.tree.BaseNode.prototype.getRowClassName=function(){var e=this.isSelected()?" "+this.config_.cssSelectedRow:"";return this.config_.cssTreeRow+e},goog.ui.tree.BaseNode.prototype.getLabelSafeHtml=function(){var e=goog.html.SafeHtml.create("span",{class:this.config_.cssItemLabel,title:this.getToolTip()||null},this.getSafeHtml());return goog.html.SafeHtml.concat(e,goog.html.SafeHtml.create("span",{},this.getAfterLabelSafeHtml()))},goog.ui.tree.BaseNode.prototype.getAfterLabelHtml=function(){return goog.html.SafeHtml.unwrap(this.getAfterLabelSafeHtml())},goog.ui.tree.BaseNode.prototype.getAfterLabelSafeHtml=function(){return this.afterLabelHtml_},goog.ui.tree.BaseNode.prototype.setAfterLabelSafeHtml=function(e){this.afterLabelHtml_=e;var t=this.getAfterLabelElement();t&&goog.dom.safe.setInnerHtml(t,e)},goog.ui.tree.BaseNode.prototype.getIconSafeHtml=function(){return goog.html.SafeHtml.create("span",{style:{display:"inline-block"},class:this.getCalculatedIconClass()})},goog.ui.tree.BaseNode.prototype.getCalculatedIconClass=goog.abstractMethod,goog.ui.tree.BaseNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span",{type:"expand",style:{display:"inline-block"},class:this.getExpandIconClass()})},goog.ui.tree.BaseNode.prototype.getExpandIconClass=function(){var e=this.getTree(),t=!e.getShowLines()||e==this.getParent()&&!e.getShowRootLines(),o=this.config_,n=new goog.string.StringBuffer;if(n.append(o.cssTreeIcon," ",o.cssExpandTreeIcon," "),this.hasChildren()){var i=0;switch(e.getShowExpandIcons()&&this.isUserCollapsible_&&(i=this.getExpanded()?2:1),t||(i=this.isLastSibling()?i+4:i+8),i){case 1:n.append(o.cssExpandTreeIconPlus);break;case 2:n.append(o.cssExpandTreeIconMinus);break;case 4:n.append(o.cssExpandTreeIconL);break;case 5:n.append(o.cssExpandTreeIconLPlus);break;case 6:n.append(o.cssExpandTreeIconLMinus);break;case 8:n.append(o.cssExpandTreeIconT);break;case 9:n.append(o.cssExpandTreeIconTPlus);break;case 10:n.append(o.cssExpandTreeIconTMinus);break;default:n.append(o.cssExpandTreeIconBlank)}}else t?n.append(o.cssExpandTreeIconBlank):this.isLastSibling()?n.append(o.cssExpandTreeIconL):n.append(o.cssExpandTreeIconT);return n.toString()},goog.ui.tree.BaseNode.prototype.getLineStyle=function(){var e=this.getExpanded()&&this.hasChildren();return goog.html.SafeStyle.create({"background-position":this.getBackgroundPosition(),display:e?null:"none"})},goog.ui.tree.BaseNode.prototype.getBackgroundPosition=function(){return(this.isLastSibling()?"-100":(this.getDepth()-1)*this.config_.indentWidth)+"px 0"},goog.ui.tree.BaseNode.prototype.getElement=function(){var e=goog.ui.tree.BaseNode.superClass_.getElement.call(this);return e||(e=this.getDomHelper().getElement(this.getId()),this.setElementInternal(e)),e},goog.ui.tree.BaseNode.prototype.getRowElement=function(){var e=this.getElement();return e?e.firstChild:null},goog.ui.tree.BaseNode.prototype.getExpandIconElement=function(){var e=this.getRowElement();return e?e.firstChild:null},goog.ui.tree.BaseNode.prototype.getIconElement=function(){var e=this.getRowElement();return e?e.childNodes[1]:null},goog.ui.tree.BaseNode.prototype.getLabelElement=function(){var e=this.getRowElement();return e&&e.lastChild?e.lastChild.previousSibling:null},goog.ui.tree.BaseNode.prototype.getAfterLabelElement=function(){var e=this.getRowElement();return e?e.lastChild:null},goog.ui.tree.BaseNode.prototype.getChildrenElement=function(){var e=this.getElement();return e?e.lastChild:null},goog.ui.tree.BaseNode.prototype.setIconClass=function(e){this.iconClass_=e,this.isInDocument()&&this.updateIcon_()},goog.ui.tree.BaseNode.prototype.getIconClass=function(){return this.iconClass_},goog.ui.tree.BaseNode.prototype.setExpandedIconClass=function(e){this.expandedIconClass_=e,this.isInDocument()&&this.updateIcon_()},goog.ui.tree.BaseNode.prototype.getExpandedIconClass=function(){return this.expandedIconClass_},goog.ui.tree.BaseNode.prototype.setText=function(e){this.setSafeHtml(goog.html.SafeHtml.htmlEscape(e))},goog.ui.tree.BaseNode.prototype.getText=function(){return goog.string.unescapeEntities(goog.html.SafeHtml.unwrap(this.html_))},goog.ui.tree.BaseNode.prototype.setSafeHtml=function(e){this.html_=e;var t=this.getLabelElement();t&&goog.dom.safe.setInnerHtml(t,e),(e=this.getTree())&&e.setNode(this)},goog.ui.tree.BaseNode.prototype.getHtml=function(){return goog.html.SafeHtml.unwrap(this.getSafeHtml())},goog.ui.tree.BaseNode.prototype.getSafeHtml=function(){return this.html_},goog.ui.tree.BaseNode.prototype.setToolTip=function(e){this.toolTip_=e;var t=this.getLabelElement();t&&(t.title=e)},goog.ui.tree.BaseNode.prototype.getToolTip=function(){return this.toolTip_},goog.ui.tree.BaseNode.prototype.updateRow=function(){var e=this.getRowElement();e&&(e.className=this.getRowClassName())},goog.ui.tree.BaseNode.prototype.updateExpandIcon=function(){var e=this.getExpandIconElement();e&&(e.className=this.getExpandIconClass()),(e=this.getChildrenElement())&&(e.style.backgroundPosition=this.getBackgroundPosition())},goog.ui.tree.BaseNode.prototype.updateIcon_=function(){this.getIconElement().className=this.getCalculatedIconClass()},goog.ui.tree.BaseNode.prototype.onMouseDown=function(e){"expand"==e.target.getAttribute("type")&&this.hasChildren()?this.isUserCollapsible_&&this.toggle():(this.select(),this.updateRow())},goog.ui.tree.BaseNode.prototype.onClick_=goog.events.Event.preventDefault,goog.ui.tree.BaseNode.prototype.onDoubleClick_=function(e){"expand"==e.target.getAttribute("type")&&this.hasChildren()||this.isUserCollapsible_&&this.toggle()},goog.ui.tree.BaseNode.prototype.onKeyDown=function(e){var t=!0;switch(e.keyCode){case goog.events.KeyCodes.RIGHT:if(e.altKey)break;this.hasChildren()&&(this.getExpanded()?this.getFirstChild().select():this.setExpanded(!0));break;case goog.events.KeyCodes.LEFT:if(e.altKey)break;if(this.hasChildren()&&this.getExpanded()&&this.isUserCollapsible_)this.setExpanded(!1);else{var o=this.getParent(),n=this.getTree();o&&(n.getShowRootNode()||o!=n)&&o.select()}break;case goog.events.KeyCodes.DOWN:(o=this.getNextShownNode())&&o.select();break;case goog.events.KeyCodes.UP:(o=this.getPreviousShownNode())&&o.select();break;default:t=!1}return t&&(e.preventDefault(),(n=this.getTree())&&n.clearTypeAhead()),t},goog.ui.tree.BaseNode.prototype.getLastShownDescendant=function(){return this.getExpanded()&&this.hasChildren()?this.getLastChild().getLastShownDescendant():this},goog.ui.tree.BaseNode.prototype.getNextShownNode=function(){if(this.hasChildren()&&this.getExpanded())return this.getFirstChild();for(var e,t=this;t!=this.getTree();){if(null!=(e=t.getNextSibling()))return e;t=t.getParent()}return null},goog.ui.tree.BaseNode.prototype.getPreviousShownNode=function(){var e=this.getPreviousSibling();if(null!=e)return e.getLastShownDescendant();e=this.getParent();var t=this.getTree();return!t.getShowRootNode()&&e==t||this==t?null:e},goog.ui.tree.BaseNode.prototype.getClientData=goog.ui.tree.BaseNode.prototype.getModel,goog.ui.tree.BaseNode.prototype.setClientData=goog.ui.tree.BaseNode.prototype.setModel,goog.ui.tree.BaseNode.prototype.getConfig=function(){return this.config_},goog.ui.tree.BaseNode.prototype.setTreeInternal=function(e){this.tree!=e&&(this.tree=e,e.setNode(this),this.forEachChild(function(t){t.setTreeInternal(e)}))},goog.ui.tree.BaseNode.defaultConfig={indentWidth:19,cssRoot:"goog-tree-root goog-tree-item",cssHideRoot:"goog-tree-hide-root",cssItem:"goog-tree-item",cssChildren:"goog-tree-children",cssChildrenNoLines:"goog-tree-children-nolines",cssTreeRow:"goog-tree-row",cssItemLabel:"goog-tree-item-label",cssTreeIcon:"goog-tree-icon",cssExpandTreeIcon:"goog-tree-expand-icon",cssExpandTreeIconPlus:"goog-tree-expand-icon-plus",cssExpandTreeIconMinus:"goog-tree-expand-icon-minus",cssExpandTreeIconTPlus:"goog-tree-expand-icon-tplus",cssExpandTreeIconTMinus:"goog-tree-expand-icon-tminus",cssExpandTreeIconLPlus:"goog-tree-expand-icon-lplus",cssExpandTreeIconLMinus:"goog-tree-expand-icon-lminus",cssExpandTreeIconT:"goog-tree-expand-icon-t",cssExpandTreeIconL:"goog-tree-expand-icon-l",cssExpandTreeIconBlank:"goog-tree-expand-icon-blank",cssExpandedFolderIcon:"goog-tree-expanded-folder-icon",cssCollapsedFolderIcon:"goog-tree-collapsed-folder-icon",cssFileIcon:"goog-tree-file-icon",cssExpandedRootIcon:"goog-tree-expanded-folder-icon",cssCollapsedRootIcon:"goog-tree-collapsed-folder-icon",cssSelectedRow:"selected"},goog.ui.tree.TreeNode=function(e,t,o){goog.ui.tree.BaseNode.call(this,e,t,o)},goog.inherits(goog.ui.tree.TreeNode,goog.ui.tree.BaseNode),goog.ui.tree.TreeNode.prototype.getTree=function(){if(this.tree)return this.tree;var e=this.getParent();return e&&(e=e.getTree())?(this.setTreeInternal(e),e):null},goog.ui.tree.TreeNode.prototype.getCalculatedIconClass=function(){var e=this.getExpanded(),t=this.getExpandedIconClass();if(e&&t)return t;if(t=this.getIconClass(),!e&&t)return t;if(t=this.getConfig(),this.hasChildren()){if(e&&t.cssExpandedFolderIcon)return t.cssTreeIcon+" "+t.cssExpandedFolderIcon;if(!e&&t.cssCollapsedFolderIcon)return t.cssTreeIcon+" "+t.cssCollapsedFolderIcon}else if(t.cssFileIcon)return t.cssTreeIcon+" "+t.cssFileIcon;return""},goog.structs.Trie=function(e){this.value_=void 0,this.childNodes_={},e&&this.setAll(e)},goog.structs.Trie.prototype.set=function(e,t){this.setOrAdd_(e,t,!1)},goog.structs.Trie.prototype.add=function(e,t){this.setOrAdd_(e,t,!0)},goog.structs.Trie.prototype.setOrAdd_=function(e,t,o){for(var n=this,i=0;i<e.length;i++){var r=e.charAt(i);n.childNodes_[r]||(n.childNodes_[r]=new goog.structs.Trie),n=n.childNodes_[r]}if(o&&void 0!==n.value_)throw Error('The collection already contains the key "'+e+'"');n.value_=t},goog.structs.Trie.prototype.setAll=function(e){var t=goog.structs.getKeys(e);e=goog.structs.getValues(e);for(var o=0;o<t.length;o++)this.set(t[o],e[o])},goog.structs.Trie.prototype.getChildNode_=function(e){for(var t=this,o=0;o<e.length;o++){var n=e.charAt(o);if(!(t=t.childNodes_[n]))return}return t},goog.structs.Trie.prototype.get=function(e){return(e=this.getChildNode_(e))?e.value_:void 0},goog.structs.Trie.prototype.getKeyAndPrefixes=function(e,t){var o=this,n={};for(t=t||0,void 0!==o.value_&&(n[t]=o.value_);t<e.length;t++){var i=e.charAt(t);if(!(i in o.childNodes_))break;void 0!==(o=o.childNodes_[i]).value_&&(n[t]=o.value_)}return n},goog.structs.Trie.prototype.getValues=function(){var e=[];return this.getValuesInternal_(e),e},goog.structs.Trie.prototype.getValuesInternal_=function(e){for(var t in void 0!==this.value_&&e.push(this.value_),this.childNodes_)this.childNodes_[t].getValuesInternal_(e)},goog.structs.Trie.prototype.getKeys=function(e){var t=[];if(e){for(var o=this,n=0;n<e.length;n++){var i=e.charAt(n);if(!o.childNodes_[i])return[];o=o.childNodes_[i]}o.getKeysInternal_(e,t)}else this.getKeysInternal_("",t);return t},goog.structs.Trie.prototype.getKeysInternal_=function(e,t){for(var o in void 0!==this.value_&&t.push(e),this.childNodes_)this.childNodes_[o].getKeysInternal_(e+o,t)};goog.structs.Trie.prototype.containsKey=function(e){return void 0!==this.get(e)},goog.structs.Trie.prototype.containsPrefix=function(e){return 0==e.length?!this.isEmpty():!!this.getChildNode_(e)},goog.structs.Trie.prototype.containsValue=function(e){if(this.value_===e)return!0;for(var t in this.childNodes_)if(this.childNodes_[t].containsValue(e))return!0;return!1},goog.structs.Trie.prototype.clear=function(){this.childNodes_={},this.value_=void 0},goog.structs.Trie.prototype.remove=function(e){for(var t=this,o=[],n=0;n<e.length;n++){var i=e.charAt(n);if(!t.childNodes_[i])throw Error('The collection does not have the key "'+e+'"');o.push([t,i]),t=t.childNodes_[i]}for(e=t.value_,delete t.value_;0<o.length&&(t=(i=o.pop())[0],i=i[1],t.childNodes_[i].isEmpty());)delete t.childNodes_[i];return e},goog.structs.Trie.prototype.clone=function(){return new goog.structs.Trie(this)},goog.structs.Trie.prototype.getCount=function(){return goog.structs.getCount(this.getValues())},goog.structs.Trie.prototype.isEmpty=function(){return void 0===this.value_&&goog.object.isEmpty(this.childNodes_)},goog.ui.tree.TypeAhead=function(){this.nodeMap_=new goog.structs.Trie,this.buffer_="",this.matchingNodes_=this.matchingLabels_=null,this.matchingNodeIndex_=this.matchingLabelIndex_=0},goog.ui.tree.TypeAhead.Offset={DOWN:1,UP:-1},goog.ui.tree.TypeAhead.prototype.handleNavigation=function(e){var t=!1;switch(e.keyCode){case goog.events.KeyCodes.DOWN:case goog.events.KeyCodes.UP:e.ctrlKey&&(this.jumpTo_(e.keyCode==goog.events.KeyCodes.DOWN?goog.ui.tree.TypeAhead.Offset.DOWN:goog.ui.tree.TypeAhead.Offset.UP),t=!0);break;case goog.events.KeyCodes.BACKSPACE:t=!0,0<(e=this.buffer_.length-1)?(this.buffer_=this.buffer_.substring(0,e),this.jumpToLabel_(this.buffer_)):0==e?this.buffer_="":t=!1;break;case goog.events.KeyCodes.ESC:this.buffer_="",t=!0}return t},goog.ui.tree.TypeAhead.prototype.handleTypeAheadChar=function(e){var t=!1;return e.ctrlKey||e.altKey||(e=String.fromCharCode(e.charCode||e.keyCode).toLowerCase(),goog.string.isUnicodeChar(e)&&(" "!=e||this.buffer_)&&(this.buffer_+=e,t=this.jumpToLabel_(this.buffer_))),t},goog.ui.tree.TypeAhead.prototype.setNodeInMap=function(e){var t=e.getText();if(t&&!goog.string.isEmptyOrWhitespace(goog.string.makeSafe(t))){t=t.toLowerCase();var o=this.nodeMap_.get(t);o?o.push(e):this.nodeMap_.set(t,[e])}},goog.ui.tree.TypeAhead.prototype.removeNodeFromMap=function(e){var t=e.getText();if(t&&!goog.string.isEmptyOrWhitespace(goog.string.makeSafe(t))){t=t.toLowerCase();var o=this.nodeMap_.get(t);if(o){for(var n=e.getChildCount(),i=0;i<n;i++)this.removeNodeFromMap(e.getChildAt(i));goog.array.remove(o,e),o.length||this.nodeMap_.remove(t)}}},goog.ui.tree.TypeAhead.prototype.jumpToLabel_=function(e){var t=!1;return(e=this.nodeMap_.getKeys(e))&&e.length&&(this.matchingLabelIndex_=this.matchingNodeIndex_=0,t=this.nodeMap_.get(e[0]),t=this.selectMatchingNode_(t))&&(this.matchingLabels_=e),t},goog.ui.tree.TypeAhead.prototype.jumpTo_=function(e){var t=!1,o=this.matchingLabels_;if(o){t=null;var n=!1;if(this.matchingNodes_){var i=this.matchingNodeIndex_+e;0<=i&&i<this.matchingNodes_.length?(this.matchingNodeIndex_=i,t=this.matchingNodes_):n=!0}t||(0<=(i=this.matchingLabelIndex_+e)&&i<o.length&&(this.matchingLabelIndex_=i),o.length>this.matchingLabelIndex_&&(t=this.nodeMap_.get(o[this.matchingLabelIndex_])),t&&t.length&&n&&(this.matchingNodeIndex_=e==goog.ui.tree.TypeAhead.Offset.UP?t.length-1:0)),(t=this.selectMatchingNode_(t))&&(this.matchingLabels_=o)}return t},goog.ui.tree.TypeAhead.prototype.selectMatchingNode_=function(e){if(e){if(this.matchingNodeIndex_<e.length){var t=e[this.matchingNodeIndex_];this.matchingNodes_=e}t&&(t.reveal(),t.select())}return!!t},goog.ui.tree.TypeAhead.prototype.clear=function(){this.buffer_=""},goog.ui.tree.TreeControl=function(e,t,o){if(goog.ui.tree.BaseNode.call(this,e,t,o),this.setExpandedInternal(!0),this.setSelectedInternal(!0),this.selectedItem_=this,this.typeAhead_=new goog.ui.tree.TypeAhead,this.focusHandler_=this.keyHandler_=null,this.logger_=goog.log.getLogger("this"),this.focused_=!1,this.focusedNode_=null,this.showRootLines_=this.showRootNode_=this.showExpandIcons_=this.showLines_=!0,goog.userAgent.IE)try{document.execCommand("BackgroundImageCache",!1,!0)}catch(e){goog.log.warning(this.logger_,"Failed to enable background image cache")}},goog.inherits(goog.ui.tree.TreeControl,goog.ui.tree.BaseNode),goog.ui.tree.TreeControl.prototype.getTree=function(){return this},goog.ui.tree.TreeControl.prototype.getDepth=function(){return 0},goog.ui.tree.TreeControl.prototype.reveal=function(){},goog.ui.tree.TreeControl.prototype.handleFocus_=function(e){this.focused_=!0,goog.dom.classlist.add(goog.asserts.assert(this.getElement()),"focused"),this.selectedItem_&&this.selectedItem_.select()},goog.ui.tree.TreeControl.prototype.handleBlur_=function(e){this.focused_=!1,goog.dom.classlist.remove(goog.asserts.assert(this.getElement()),"focused")},goog.ui.tree.TreeControl.prototype.hasFocus=function(){return this.focused_},goog.ui.tree.TreeControl.prototype.getExpanded=function(){return!this.showRootNode_||goog.ui.tree.TreeControl.superClass_.getExpanded.call(this)},goog.ui.tree.TreeControl.prototype.setExpanded=function(e){this.showRootNode_?goog.ui.tree.TreeControl.superClass_.setExpanded.call(this,e):this.setExpandedInternal(e)},goog.ui.tree.TreeControl.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.EMPTY},goog.ui.tree.TreeControl.prototype.getIconElement=function(){var e=this.getRowElement();return e?e.firstChild:null},goog.ui.tree.TreeControl.prototype.getExpandIconElement=function(){return null},goog.ui.tree.TreeControl.prototype.updateExpandIcon=function(){},goog.ui.tree.TreeControl.prototype.getRowClassName=function(){return goog.ui.tree.TreeControl.superClass_.getRowClassName.call(this)+(this.showRootNode_?"":" "+this.getConfig().cssHideRoot)},goog.ui.tree.TreeControl.prototype.getCalculatedIconClass=function(){var e=this.getExpanded(),t=this.getExpandedIconClass();return e&&t?t:(t=this.getIconClass(),!e&&t?t:(t=this.getConfig(),e&&t.cssExpandedRootIcon?t.cssTreeIcon+" "+t.cssExpandedRootIcon:!e&&t.cssCollapsedRootIcon?t.cssTreeIcon+" "+t.cssCollapsedRootIcon:""))},goog.ui.tree.TreeControl.prototype.setSelectedItem=function(e){if(this.selectedItem_!=e){var t=!1;this.selectedItem_&&(t=this.selectedItem_==this.focusedNode_,this.selectedItem_.setSelectedInternal(!1)),(this.selectedItem_=e)&&(e.setSelectedInternal(!0),t&&e.select()),this.dispatchEvent(goog.events.EventType.CHANGE)}},goog.ui.tree.TreeControl.prototype.getSelectedItem=function(){return this.selectedItem_},goog.ui.tree.TreeControl.prototype.setShowLines=function(e){this.showLines_!=e&&(this.showLines_=e,this.isInDocument()&&this.updateLinesAndExpandIcons_())},goog.ui.tree.TreeControl.prototype.getShowLines=function(){return this.showLines_},goog.ui.tree.TreeControl.prototype.updateLinesAndExpandIcons_=function(){var e=this,t=e.getShowLines(),o=e.getShowRootLines();!function n(i){var r=i.getChildrenElement();if(r){var l=!t||e==i.getParent()&&!o?i.getConfig().cssChildrenNoLines:i.getConfig().cssChildren;r.className=l,(r=i.getExpandIconElement())&&(r.className=i.getExpandIconClass())}i.forEachChild(n)}(this)},goog.ui.tree.TreeControl.prototype.setShowRootLines=function(e){this.showRootLines_!=e&&(this.showRootLines_=e,this.isInDocument()&&this.updateLinesAndExpandIcons_())},goog.ui.tree.TreeControl.prototype.getShowRootLines=function(){return this.showRootLines_},goog.ui.tree.TreeControl.prototype.setShowExpandIcons=function(e){this.showExpandIcons_!=e&&(this.showExpandIcons_=e,this.isInDocument()&&this.updateLinesAndExpandIcons_())},goog.ui.tree.TreeControl.prototype.getShowExpandIcons=function(){return this.showExpandIcons_},goog.ui.tree.TreeControl.prototype.setShowRootNode=function(e){if(this.showRootNode_!=e){if(this.showRootNode_=e,this.isInDocument()){var t=this.getRowElement();t&&(t.className=this.getRowClassName())}!e&&this.getSelectedItem()==this&&this.getFirstChild()&&this.setSelectedItem(this.getFirstChild())}},goog.ui.tree.TreeControl.prototype.getShowRootNode=function(){return this.showRootNode_},goog.ui.tree.TreeControl.prototype.initAccessibility=function(){goog.ui.tree.TreeControl.superClass_.initAccessibility.call(this);var e=this.getElement();goog.asserts.assert(e,"The DOM element for the tree cannot be null."),goog.a11y.aria.setRole(e,"tree"),goog.a11y.aria.setState(e,"labelledby",this.getLabelElement().id)},goog.ui.tree.TreeControl.prototype.enterDocument=function(){goog.ui.tree.TreeControl.superClass_.enterDocument.call(this);var e=this.getElement();e.className=this.getConfig().cssRoot,e.setAttribute("hideFocus","true"),this.attachEvents_(),this.initAccessibility()},goog.ui.tree.TreeControl.prototype.exitDocument=function(){goog.ui.tree.TreeControl.superClass_.exitDocument.call(this),this.detachEvents_()},goog.ui.tree.TreeControl.prototype.attachEvents_=function(){var e=this.getElement();e.tabIndex=0;var t=this.keyHandler_=new goog.events.KeyHandler(e),o=this.focusHandler_=new goog.events.FocusHandler(e);this.getHandler().listen(o,goog.events.FocusHandler.EventType.FOCUSOUT,this.handleBlur_).listen(o,goog.events.FocusHandler.EventType.FOCUSIN,this.handleFocus_).listen(t,goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent).listen(e,goog.events.EventType.MOUSEDOWN,this.handleMouseEvent_).listen(e,goog.events.EventType.CLICK,this.handleMouseEvent_).listen(e,goog.events.EventType.DBLCLICK,this.handleMouseEvent_)},goog.ui.tree.TreeControl.prototype.detachEvents_=function(){this.keyHandler_.dispose(),this.keyHandler_=null,this.focusHandler_.dispose(),this.focusHandler_=null},goog.ui.tree.TreeControl.prototype.handleMouseEvent_=function(e){goog.log.fine(this.logger_,"Received event "+e.type);var t=this.getNodeFromEvent_(e);if(t)switch(e.type){case goog.events.EventType.MOUSEDOWN:t.onMouseDown(e);break;case goog.events.EventType.CLICK:t.onClick_(e);break;case goog.events.EventType.DBLCLICK:t.onDoubleClick_(e)}},goog.ui.tree.TreeControl.prototype.handleKeyEvent=function(e){var t;return(t=this.typeAhead_.handleNavigation(e)||this.selectedItem_&&this.selectedItem_.onKeyDown(e)||this.typeAhead_.handleTypeAheadChar(e))&&e.preventDefault(),t},goog.ui.tree.TreeControl.prototype.getNodeFromEvent_=function(e){for(var t=e.target;null!=t;){if(e=goog.ui.tree.BaseNode.allNodes[t.id])return e;if(t==this.getElement())break;t=t.parentNode}return null},goog.ui.tree.TreeControl.prototype.createNode=function(e){return new goog.ui.tree.TreeNode(e||goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())},goog.ui.tree.TreeControl.prototype.setNode=function(e){this.typeAhead_.setNodeInMap(e)},goog.ui.tree.TreeControl.prototype.removeNode=function(e){this.typeAhead_.removeNodeFromMap(e)},goog.ui.tree.TreeControl.prototype.clearTypeAhead=function(){this.typeAhead_.clear()},goog.ui.tree.TreeControl.defaultConfig=goog.ui.tree.BaseNode.defaultConfig,Blockly.Toolbox=function(e){this.blockSpaceEditor_=e,this.createDom(this.blockSpaceEditor_.svg_)},Blockly.Toolbox.prototype.width=0,Blockly.Toolbox.CONFIG_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"},Blockly.Toolbox.prototype.createDom=function(e){this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv"),this.HtmlDiv.setAttribute("dir",Blockly.RTL?"RTL":"LTR"),goog.dom.insertSiblingBefore(this.HtmlDiv,e),this.trashcanHolder=Blockly.createSvgElement("svg",{id:"trashcanHolder",width:70,height:90,style:"display: none; position: absolute"},this.HtmlDiv),this.trashcan=new Blockly.Trashcan(this),this.svgTrashcan=this.trashcan.createDom(),this.svgTrashcan.setAttribute("transform","translate(0, 10)"),this.trashcanHolder.appendChild(this.svgTrashcan),this.flyout_=new Blockly.Flyout(this.blockSpaceEditor_),e.appendChild(this.flyout_.createDom(!0)),Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(e){Blockly.fireUiEvent(window,"resize"),Blockly.isRightButton(e)||e.target==this.HtmlDiv?this.blockSpaceEditor_.hideChaff(!1):this.blockSpaceEditor_.hideChaff(!0)})},Blockly.Toolbox.prototype.init=function(e,t){Blockly.Toolbox.CONFIG_.cleardotPath=Blockly.assetUrl("media/1x1.gif"),Blockly.Toolbox.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(Blockly.RTL?"Rtl":"Ltr");var o=new Blockly.Toolbox.TreeControl(this,"root",Blockly.Toolbox.CONFIG_);this.tree_=o,o.setShowRootNode(!1),o.setShowLines(!1),o.setShowExpandIcons(!1),o.setSelectedItem(null),this.HtmlDiv.style.display="block",this.flyout_.init(e,!0),this.populate_(),o.render(this.HtmlDiv),goog.events.listen(window,goog.events.EventType.RESIZE,goog.partial(this.position_,t),!1,this),this.position_(t),this.enabled=!0},Blockly.Toolbox.prototype.position_=function(e){var t=this.HtmlDiv,o=goog.style.getBorderBox(e.svg_),n=e.svgSize();Blockly.RTL?t.style.right=o.right+"px":t.style.marginLeft=o.left,t.style.height=n.height+"px",this.width=t.offsetWidth,Blockly.RTL||--this.width,e.hideTrashRect_||(e.svgBackground_.setAttribute("x",Blockly.RTL?n.width-t.offsetWidth:0),e.svgBackground_.setAttribute("width",t.offsetWidth),e.svgBackground_.setAttribute("height",n.height)),e=t.offsetWidth,t=this.trashcanHolder.getAttribute("width"),this.trashcanHolder.style.left=Math.round(e/2-t/2)+"px"},Blockly.Toolbox.prototype.populate_=function(){var e=this.tree_;if(e.blocks=[],function t(o,n){for(var i,r=0;i=o.childNodes[r];r++)if(i.tagName){var l=i.tagName.toUpperCase();if("CATEGORY"===l){(l=e.createNode(i.getAttribute("name"))).blocks=[],n.add(l);var s=i.getAttribute("custom");s&&(l.blocks[0]=s),t(i,l)}else"BLOCK"===l&&n.blocks.push(i)}}(Blockly.languageTree,this.tree_),e.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,"resize")},Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)},Blockly.Toolbox.prototype.getRect=function(){var e=-1e7;return Blockly.RTL&&(e=Blockly.mainBlockSpaceEditor.svgSize().width-this.width),new goog.math.Rect(e,-1e7,1e7+this.width,2e7)},Blockly.Toolbox.TreeControl=function(e,t,o,n){goog.ui.tree.TreeControl.call(this,t,o,n),this.toolbox_=e},goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl),Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){if(Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this),goog.events.BrowserFeature.TOUCH_ENABLED||"onpointerdown"in window||"onmspointerdown"in window){var e=this.getElement(),t=this.handleTouchEvent_.bind(this);Blockly.bindEvent_(e,goog.events.EventType.TOUCHSTART,this,t),Blockly.bindEvent_(e,goog.events.EventType.POINTERDOWN,this,t),Blockly.bindEvent_(e,goog.events.EventType.MSPOINTERDOWN,this,t)}},Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(e){if(!this.touchRateLimited){this.touchRateLimited=!0,setTimeout(function(){this.touchRateLimited=!1}.bind(this)),e.preventDefault();var t=this.getNodeFromEvent_(e);!t||e.type!==goog.events.EventType.TOUCHSTART&&e.type!==goog.events.EventType.POINTERDOWN&&e.type!==goog.events.EventType.MSPOINTERDOWN||(e.stopImmediatePropagation(),window.setTimeout(function(){t.onMouseDown(e)},1))}},Blockly.Toolbox.TreeControl.prototype.createNode=function(e){return new Blockly.Toolbox.TreeNode(this.toolbox_,e||"",this.getConfig(),this.getDomHelper())},Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(e){this.selectedItem_!=e&&(goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,e),e&&e.blocks&&e.blocks.length?this.toolbox_.flyout_.show(e.blocks):this.toolbox_.flyout_.hide())},Blockly.Toolbox.TreeNode=function(e,t,o,n){goog.ui.tree.TreeNode.call(this,t,o,n),t=function(){Blockly.fireUiEvent(window,"resize")},this.toolbox_=e,goog.events.listen(this.toolbox_.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,t),goog.events.listen(this.toolbox_.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,t)},goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode),Blockly.Toolbox.TreeNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span")},Blockly.Toolbox.TreeNode.prototype.getExpandIconElement=function(){return null},Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(e){this.toolbox_.enabled&&(this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select(),this.updateRow(),e.stopPropagation())},Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(){},Blockly.Variables={},Blockly.Variables.NAME_TYPE="VARIABLE",Blockly.Variables.NAME_TYPE_LOCAL="LOCALVARIABLE",Blockly.Variables.DEFAULT_CATEGORY="Default",Blockly.Variables.allVariables=function(e,t){if(t&&t!==Blockly.Variables.DEFAULT_CATEGORY&&Blockly.valueTypeTabShapeMap&&void 0===Blockly.valueTypeTabShapeMap[t])throw Error('Variable category must be "Default" or a strict type');if(e)var o=(e=Array.isArray(e)?e:[e]).reduce(function(e,t){return e.concat(t.getDescendants())},[]);else{if(!Blockly.mainBlockSpace)return[];o=Blockly.mainBlockSpace.getAllBlocks()}e={};for(var n=0;n<o.length;n++)if(o[n].getVars)for(var i=t?o[n].getVars()[t]||[]:Blockly.Variables.allVariablesFromBlock(o[n]),r=0;r<i.length;r++){var l=i[r];l&&(e[Blockly.Names.PREFIX_+l.toLowerCase()]=l)}for(var s in t=[],e)t.push(e[s]);return t},Blockly.Variables.allVariablesFromBlock=function(e){if(!e.getVars)return[];var t=e.getVars();return Object.keys(t).reduce(function(e,o){return e.concat(t[o])},[])},Blockly.Variables.getVars=function(e){var t={};return t[e||Blockly.Variables.DEFAULT_CATEGORY]=[this.getTitleValue("VAR")],t},Blockly.Variables.renameVariable=function(e,t,o){if(t!==e&&t){o=o.getAllBlocks({shareMainModal:!1});for(var n=0;n<o.length;n++){var i=o[n].renameVar;i&&i.call(o[n],e,t)}Blockly.FunctionEditor.allFunctionEditors.forEach(function(o){o.isOpen()&&(o.renameParameter(e,t),o.refreshParamsEverywhere())})}},Blockly.Variables.deleteVariable=function(e,t){t=t.getAllBlocks({shareMainModal:!1});for(var o=0;o<t.length;o++){var n=t[o].removeVar;n&&n.call(t[o],e)}Blockly.FunctionEditor.allFunctionEditors.forEach(function(t){t.isOpen()&&(t.removeParameter(e),t.refreshParamsEverywhere())})},Blockly.Variables.flyoutCategory=function(e,t,o,n,i,r){var l=Blockly.Variables.allVariables(null,i);l.sort(goog.string.caseInsensitiveCompare),r&&l.unshift(null),r=void 0;for(var s=0;s<l.length;s++)if(l[s]!==r){var a=Blockly.Variables.getGetter(n,i);a&&a.initSvg();var g=Blockly.Variables.getSetter(n,i);g&&g.initSvg(),null===l[s]&&(a||g)?r=(a||g).getVars(i)[0]:(a&&a.setTitleValue(l[s],"VAR"),g&&g.setTitleValue(l[s],"VAR")),g&&e.push(g),a&&e.push(a),a&&g?t.push(o,3*o):t.push(2*o)}},Blockly.Variables.getters={Default:"variables_get"},Blockly.Variables.getGetter=function(e,t){return(t=Blockly.Variables.getters[t])&&Blockly.Blocks[t]?new Blockly.Block(e,t):null},Blockly.Variables.registerGetter=function(e,t){Blockly.Variables.getters[e]=t},Blockly.Variables.setters={Default:"variables_set"},Blockly.Variables.getSetter=function(e,t){return(t=Blockly.Variables.setters[t])&&Blockly.Blocks[t]?new Blockly.Block(e,t):null},Blockly.Variables.registerSetter=function(e,t){Blockly.Variables.setters[e]=t},Blockly.Variables.generateUniqueName=function(e){if(e)return Blockly.Variables.generateUniqueNameFromBase_(e);var t="";if((e=Blockly.Variables.allVariables()).length){e.sort(goog.string.caseInsensitiveCompare);for(var o,n,i=0,r="i";!t;){for(o=0,n=!1;o<e.length&&!n;)e[o].toLowerCase()==r&&(n=!0),o++;n?("z"===r[0]?(i++,r="a"):"l"==(r=String.fromCharCode(r.charCodeAt(0)+1))[0]&&(r=String.fromCharCode(r.charCodeAt(0)+1)),0<i&&(r+=i)):t=r}}else t="i";return t},Blockly.Variables.generateUniqueNameFromBase_=function(e){var t=Blockly.Variables.allVariables();if(-1===t.indexOf(e))return e;var o=1,n=/^([^\d]*)(\d+)$/.exec(e);n&&(e=n[1],o=parseInt(n[2],10)+1);do{if(n=e+o.toString(),-1===t.indexOf(n))return n}while(o++)},Blockly.FieldVariable=function(e,t,o,n,i){if(this.category=n||Blockly.Variables.DEFAULT_CATEGORY,this.categoryName=i||Blockly.Msg.VARIABLE,t===Blockly.FieldParameter.dropdownChange)n=t;else if(t){var r=this;n=function(e){var o=r.dropdownChange(e);return e=void 0===o?e:null===o?r.getValue():o,t.call(r,e),o}}else n=this.dropdownChange;Blockly.FieldVariable.superClass_.constructor.call(this,o||Blockly.FieldVariable.dropdownCreate,n),e?this.setValue(e):this.setValue(Blockly.Variables.generateUniqueName())},goog.inherits(Blockly.FieldVariable,Blockly.FieldDropdown),Blockly.FieldVariable.prototype.getValue=function(){return this.getText()},Blockly.FieldVariable.prototype.setValue=function(e){this.value_=e,this.setText(e)},Blockly.FieldVariable.dropdownCreate=function(){var e=Blockly.Variables.allVariables(null,this.category),t=this.getText();t&&-1==e.indexOf(t)&&e.push(t),e.sort(goog.string.caseInsensitiveCompare),e.push(Blockly.Msg.RENAME_ALL.replace("%1",t)),e.push(Blockly.Msg.RENAME_THIS.replace("%1",this.categoryName)),t=[];for(var o=0;o<e.length;o++)t[o]=[e[o],e[o]];return t},Blockly.FieldVariable.prototype.dropdownChange=function(e){if(e===Blockly.Msg.RENAME_ALL.replace("%1",this.getText())){var t=this.getText();return this.getParentEditor_().hideChaff(),Blockly.FieldVariable.modalPromptName(Blockly.Msg.RENAME_VARIABLE_TITLE.replace("%1",t),Blockly.Msg.CONFIRM_RENAME_VARIABLE,t,function(e){Blockly.Variables.renameVariable(t,e,this.sourceBlock_.blockSpace)}.bind(this)),null}if(e===Blockly.Msg.RENAME_THIS.replace("%1",this.categoryName))return this.getParentEditor_().hideChaff(),Blockly.FieldVariable.modalPromptName(Blockly.Msg.NEW_VARIABLE_TITLE,Blockly.Msg.CONFIRM_CREATE_VARIABLE,"",function(e){e&&this.setText(e)}.bind(this)),null},Blockly.FieldVariable.modalPromptName=function(e,t,o,n){Blockly.showSimpleDialog({bodyText:e,prompt:!0,promptPrefill:o,cancelText:t,confirmText:Blockly.Msg.CANCEL,onConfirm:null,onCancel:n})},Blockly.FieldVariable.removeExtraWhitespace=function(e){return e.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"")},Blockly.FieldParameter=function(e){Blockly.FieldParameter.superClass_.constructor.call(this,e,Blockly.FieldParameter.dropdownChange,Blockly.FieldParameter.dropdownCreate)},goog.inherits(Blockly.FieldParameter,Blockly.FieldVariable),Blockly.FieldParameter.dropdownCreate=function(){for(var e=[Blockly.Msg.RENAME_PARAMETER,Blockly.Msg.DELETE_PARAMETER],t=[],o=0;o<e.length;o++)t[o]=[e[o],e[o]];return t},Blockly.FieldParameter.dropdownChange=function(e){var t=this.getText();return e===Blockly.Msg.RENAME_PARAMETER?(this.getParentEditor_().hideChaff(),Blockly.FieldVariable.modalPromptName(Blockly.Msg.RENAME_PARAMETER_TITLE.replace("%1",t),Blockly.Msg.CONFIRM_RENAME_VARIABLE,t,function(e){Blockly.Variables.renameVariable(t,e,this.sourceBlock_.blockSpace)}.bind(this))):e===Blockly.Msg.DELETE_PARAMETER&&Blockly.showSimpleDialog({bodyText:Blockly.Msg.DELETE_PARAMETER_TITLE.replace("%1",t),cancelText:Blockly.Msg.DELETE,isDangerCancel:!0,confirmText:Blockly.Msg.KEEP,onConfirm:null,onCancel:function(){Blockly.Variables.deleteVariable(t,this.sourceBlock_.blockSpace)}.bind(this)}),null},Blockly.BlockSpaceEditor=function(e,t){(t=t||{}).getMetrics&&(this.getBlockSpaceMetrics_=t.getMetrics),t.setMetrics&&(this.setBlockSpaceMetrics_=t.setMetrics),t.hideTrashRect&&(this.hideTrashRect_=t.hideTrashRect),t.disableTooltip&&(this.disableTooltip=t.disableTooltip),t.disableEventBindings&&(this.disableEventBindings=t.disableEventBindings),this.readOnly_=!!t.readOnly,this.noScrolling_=!!t.noScrolling,this.inline_=!!t.inline,this.movementLocked_=!1,this.blockSpace=new Blockly.BlockSpace(this,goog.bind(this.getBlockSpaceMetrics_,this),goog.bind(this.setBlockSpaceMetrics_,this),e),this.blockLimits=new Blockly.BlockLimits,this.createDom_(e),this.init_()},Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK=!1,Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_TOP=2,Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_LEFT=2,Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_BOTTOM=2,Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_RIGHT=2,Blockly.BlockSpaceEditor.BUMP_PADDING_TOP=15,Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT=15,Blockly.BlockSpaceEditor.BUMP_PADDING_BOTTOM=25,Blockly.BlockSpaceEditor.BUMP_PADDING_RIGHT=25,Blockly.BlockSpaceEditor.BUMP_DEBUG=!1,Blockly.BlockSpaceEditor.SCROLL_DRAG_DEBUG=!1,Blockly.BlockSpaceEditor.prototype.populateSVGEffects_=function(e){if(!goog.dom.getElement("blocklySvgDefsGlobal")){e=Blockly.createSvgElement("svg",{id:"blocklyFilters",width:0,height:0,style:"display: block"},e),e=Blockly.createSvgElement("defs",{id:"blocklySvgDefsGlobal"},e);var t=Blockly.createSvgElement("filter",{id:"blocklyEmboss"},e);Blockly.createSvgElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:1,result:"blur"},t);var o=Blockly.createSvgElement("feSpecularLighting",{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},t);Blockly.createSvgElement("fePointLight",{x:-5e3,y:-1e4,z:2e4},o),Blockly.createSvgElement("feComposite",{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},t),Blockly.createSvgElement("feComposite",{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},t),t=Blockly.createSvgElement("filter",{id:"blocklyTrashcanShadowFilter",height:"150%",y:"-20%"},e),Blockly.createSvgElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2,result:"blur"},t),Blockly.createSvgElement("feOffset",{in:"blur",dx:1,dy:1,result:"offsetBlur"},t),t=Blockly.createSvgElement("feMerge",{},t),Blockly.createSvgElement("feMergeNode",{in:"offsetBlur"},t),Blockly.createSvgElement("feMergeNode",{in:"SourceGraphic"},t),t=Blockly.createSvgElement("filter",{id:"blocklyShadowFilter"},e),Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},t),t=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",width:10,height:10},e),Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},t),Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},t),t=Blockly.createSvgElement("filter",{id:"blocklyTypeHintFilter"},e),Blockly.createSvgElement("feConvolveMatrix",{order:"5,5",kernelMatrix:"0 0 0 0 0 0 0 0 0.5 1 0.5 1 1 1 1 0 0 0 0 0 0 0 0 0.5 1"},t)}},Blockly.BlockSpaceEditor.prototype.createDom_=function(e){e.setAttribute("dir","LTR"),this.populateSVGEffects_(e);var t=["blocklySvg"];this.inline_&&t.push("inline"),this.readOnly_&&t.push("readOnlyBlockSpace"),this.svg_=t=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1",class:t.join(" ")},null),e.appendChild(t),goog.events.listen(t,"selectstart",function(){return!1}),this.defs_=Blockly.createSvgElement("defs",{id:"blocklySvgDefs"},t),this.blockSpace.maxBlocks=Blockly.maxBlocks,this.hideTrashRect_||this.isReadOnly()||!Blockly.hasCategories||(this.svgBackground_=Blockly.createSvgElement("rect",{id:"toolboxRect",class:"blocklyToolboxBackground"},this.svg_)),t.appendChild(this.blockSpace.createDom()),this.isReadOnly()||(this.addToolboxOrFlyout_(),this.addChangeListener(this.bumpBlocksIfNotDragging)),this.setEnableToolbox=function(e){this.isReadOnly()||(this.flyout_?this.flyout_.setEnabled(e):this.toolbox&&(this.toolbox.enabled=e))},this.disableTooltip||t.appendChild(Blockly.Tooltip.createDom()),this.svgResize(),Blockly.WidgetDiv.DIV||(Blockly.WidgetDiv.DIV=goog.dom.createDom("div","blocklyWidgetDiv"),Blockly.WidgetDiv.DIV.style.direction=Blockly.RTL?"rtl":"ltr",document.body.appendChild(Blockly.WidgetDiv.DIV))},Blockly.BlockSpaceEditor.prototype.addToSvgDefs=function(e){this.defs_.appendChild(e)},Blockly.BlockSpaceEditor.prototype.addToolboxOrFlyout_=function(){Blockly.hasCategories?this.toolbox=new Blockly.Toolbox(this):this.addFlyout_()},Blockly.BlockSpaceEditor.prototype.addFlyout_=function(){var e=this.flyout_=new Blockly.Flyout(this,!0),t=e.createStaticToolboxDom();e.init(this.blockSpace,!0),e.autoClose=!1,goog.dom.insertSiblingBefore(t,this.blockSpace.svgGroup_)},Blockly.BlockSpaceEditor.prototype.getDeleteAreas=function(){var e=[];return this.flyout_&&goog.array.extend(e,this.flyout_.getRect()),this.toolbox&&goog.array.extend(e,this.toolbox.getRect()),e},Blockly.BlockSpaceEditor.prototype.bumpBlocksIfNotDragging=function(){Blockly.Block.isDragging()||this.bumpBlocksIntoBlockSpace()},Blockly.BlockSpaceEditor.prototype.bumpBlocksIntoBlockSpace=function(){var e=this.blockSpace.getMetrics();if(e){if(!Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK){e=this.blockSpace.getScrollableSize(e);var t=Blockly.BlockSpaceEditor.BUMP_PADDING_TOP,o=Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT,n=e.height-Blockly.BlockSpaceEditor.BUMP_PADDING_BOTTOM,i=e.width-Blockly.BlockSpaceEditor.BUMP_PADDING_RIGHT,r=i-o,l=n-t}this.blockSpace.getTopBlocks(!1,!1).forEach(function(e){if(e.isVisible()&&!e.isCurrentlyBeingDragged()){if(!Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK){var s=e.getHeightWidth();if(s.width>r||s.height>l)return}if(Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK){var a=this.blockSpace.getScrollableBox().expand(-Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_TOP,-Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_RIGHT,-Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_BOTTOM,-Blockly.BlockSpaceEditor.ENTIRE_BUMP_PADDING_LEFT),g=e.getBox(),c=Blockly.getBoxOverflow(a,g),u=Math.max(0,c.left),h=Math.max(0,c.right);s=Math.max(0,c.top);var p=Math.max(0,c.bottom)}else p=e.getRelativeToSurfaceXY(),u=Math.max(0,o-p.x),h=Math.max(0,p.x-i),s=Math.max(0,t-p.y),p=Math.max(0,p.y-n);u=u||-h,s=s||-p,Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK&&(Blockly.isBoxWiderThan(g,a)&&(u=c.left),Blockly.isBoxTallerThan(g,a)&&(s=c.top)),(c=u||s)&&e.moveBy(u,s),Blockly.BlockSpaceEditor.BUMP_DEBUG&&Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK&&(s=e.getBox(),this.blockSpace.drawDebugBox("block box"+e.id,g,c?"red":"green"),this.blockSpace.drawDebugBox("block after"+e.id,s,"purple"),this.blockSpace.drawDebugBox("block space box"+e.id,a,"blue"))}},this)}},Blockly.BlockSpaceEditor.prototype.init_=function(){this.detectBrokenControlPoints(),this.blockSpace.bindBeginPanDragHandler(this.svg_,goog.bind(this.hideChaff,this)),this.blockSpace.bindScrollOnWheelHandler(this.svg_),Blockly.bindEvent_(Blockly.WidgetDiv.DIV,"contextmenu",null,Blockly.blockContextMenu),this.disableEventBindings||Blockly.documentEventsBound_||(Blockly.bindEvent_(window,"resize",this,this.svgResize),Blockly.bindEvent_(document,"keydown",this,this.onKeyDown_),Blockly.bindEvent_(document,"copy",this,this.onCutCopy_),Blockly.bindEvent_(document,"cut",this,this.onCutCopy_),Blockly.bindEvent_(document,"paste",this,this.onPaste_),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")},!1),Blockly.documentEventsBound_=!0),Blockly.languageTree&&!this.isReadOnly()&&(Blockly.hasCategories?this.toolbox.init(this.blockSpace,this):(this.flyout_.init(this.blockSpace,!0),this.updateFlyout())),this.noScrolling_||!Blockly.hasVerticalScrollbars&&!Blockly.hasHorizontalScrollbars||(this.blockSpace.scrollbarPair=new Blockly.ScrollbarPair(this.blockSpace,Blockly.hasHorizontalScrollbars,Blockly.hasVerticalScrollbars),this.blockSpace.scrollbarPair.resize())},Blockly.BlockSpaceEditor.prototype.updateFlyout=function(){this.flyout_&&Blockly.languageTree&&(this.flyout_.show(Blockly.languageTree.childNodes),this.svgResize())},Blockly.BlockSpaceEditor.prototype.getAllFlyoutBlocks=function(){return this.flyout_?this.flyout_.getAllBlocks():[]},Blockly.BlockSpaceEditor.prototype.detectBrokenControlPoints=function(){if(goog.userAgent.WEBKIT){var e=Blockly.createSvgElement("g",{},this.svg_);Blockly.createSvgElement("path",{d:"M 0,50 C 75,-25 75,50 125,0 Z"},e),Blockly.isMsie()||Blockly.isTrident()?(e.style.display="inline",e.bBox_={x:e.getBBox().x,y:e.getBBox().y,width:e.scrollWidth,height:e.scrollHeight}):e.bBox_=e.getBBox(),50<e.bBox_.height&&(Blockly.BROKEN_CONTROL_POINTS=!0),this.svg_.removeChild(e)}},Blockly.BlockSpaceEditor.prototype.svgSize=function(){return{width:this.svg_.cachedWidth_,height:this.svg_.cachedHeight_}},Blockly.BlockSpaceEditor.prototype.svgResize=function(){var e=this.svg_,t=window.getComputedStyle(e),o=0;t&&(o=(parseInt(t.borderLeftWidth,10)||0)+(parseInt(t.borderRightWidth,10)||0)),t=e.parentNode;var n=this.getWorkspaceTopOffset();o=t.clientWidth-o,t=t.clientHeight-n,e.cachedWidth_!=o&&(e.setAttribute("width",o+"px"),e.cachedWidth_=o,this.flyout_&&(this.flyout_.setMaxWidth(o/2.5),this.flyout_.blockSpace_.resizeHeight())),e.cachedHeight_!=t&&(e.setAttribute("height",t+"px"),e.cachedHeight_=t),this.blockSpace.scrollbarPair?this.blockSpace.scrollbarPair.resize():this.setBlockSpaceMetricsNoScroll_()},Blockly.BlockSpaceEditor.prototype.getWorkspaceTopOffset=function(){var e=this.svg_,t=e.parentNode,o=window.getComputedStyle(t);return o=o&&parseInt(o.borderTopWidth,10)||0,goog.style.getPageOffsetTop(e)-(goog.style.getPageOffsetTop(t)+o)},Blockly.BlockSpaceEditor.prototype.appendSVGChild=function(e){this.svg_.appendChild(e)},Blockly.BlockSpaceEditor.prototype.getSVGElement=function(){return this.svg_},Blockly.BlockSpaceEditor.prototype.getBlockSpaceWidth=function(){var e=this.blockSpace.getMetrics();return e?e.viewWidth:0},Blockly.BlockSpaceEditor.prototype.getToolboxWidth=function(){var e=0,t=this.flyout_||this.toolbox&&this.toolbox.flyout_;return t&&(t=t.blockSpace_.getMetrics())&&(e=t.viewWidth),this.toolbox&&(e+=this.toolbox.HtmlDiv.getBoundingClientRect().width),e},Blockly.BlockSpaceEditor.prototype.setCursor=function(e){Blockly.Css.setCursor(e,this.svg_)},Blockly.BlockSpaceEditor.prototype.onKeyDown_=function(e){if(!Blockly.isTargetInput(e))if(9==e.keyCode||27==e.keyCode)this.hideChaff();else if(8==e.keyCode||46==e.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(this.hideChaff(),Blockly.selected.dispose(!0,!0))}finally{e.preventDefault()}else(e.altKey||e.ctrlKey||e.metaKey)&&Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isCopyable()&&(this.hideChaff(),67!=e.keyCode&&88!=e.keyCode||Blockly.BlockSpaceEditor.copy_(Blockly.selected))},Blockly.BlockSpaceEditor.prototype.onCutCopy_=function(e){Blockly.selected&&!window.getSelection().toString()&&(e.clipboardData.setData("text/xml",Blockly.clipboard_),e.preventDefault(),"cut"===e.type&&Blockly.selected.dispose(!0,!0))},Blockly.BlockSpaceEditor.prototype.onPaste_=function(e){try{var t=Blockly.Xml.textToDom(e.clipboardData.getData("text/xml")||e.clipboardData.getData("text/plain"));Blockly.focusedBlockSpace.paste(t)}catch(e){if(!/did not obtain a valid XML tree/.test(e))throw e}},Blockly.BlockSpaceEditor.terminateDrag_=function(){Blockly.Block.terminateDrag_(),Blockly.Flyout.terminateDrag_()},Blockly.BlockSpaceEditor.copy_=function(e){var t=Blockly.Xml.blockToDom(e);Blockly.Xml.deleteNext(t),e=e.getRelativeToSurfaceXY(),t.setAttribute("x",Blockly.RTL?-e.x:e.x),t.setAttribute("y",e.y),Blockly.clipboard_="<xml>"+Blockly.Xml.domToText(t)+"</xml>"},Blockly.BlockSpaceEditor.showContextMenu_=function(e){if(!this.isReadOnly()){var t=[];if(Blockly.collapse){for(var o=!1,n=!1,i=this.getTopBlocks(!1),r=0;r<i.length;r++)i[r].isCollapsed()?o=!0:n=!0;(n={enabled:n}).text=Blockly.Msg.COLLAPSE_ALL,n.callback=function(){for(var e=0;e<i.length;e++)i[e].setCollapsed(!0)},t.push(n),(o={enabled:o}).text=Blockly.Msg.EXPAND_ALL,o.callback=function(){for(var e=0;e<i.length;e++)i[e].setCollapsed(!1)},t.push(o)}(o={enabled:!1}).text=Blockly.Msg.HELP,o.callback=function(){},t.push(o),Blockly.ContextMenu.show(e,t)}},Blockly.BlockSpaceEditor.prototype.hideChaff=function(e){Blockly.Tooltip.hide(),Blockly.WidgetDiv.hide(),this.toolbox&&!e&&this.toolbox.flyout_&&this.toolbox.flyout_.autoClose&&this.toolbox.clearSelection()},Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_=function(){var e=this.svgSize(),t=0;(this.toolbox||this.flyout_)&&(t=this.toolbox?this.toolbox.width:this.flyout_.width_),e.width-=t;try{var o=this.getCanvasBBox(this.blockSpace.getCanvas()),n=Blockly.svgRectToRect(o);this.blockSpace.pickedUpBlockOrigin_&&n.boundingRect(this.blockSpace.pickedUpBlockOrigin_)}catch(e){return null}t=Blockly.RTL?0:t,o=this.blockSpace.getScrollOffsetX();var i=e.width;return{viewHeight:e=e.height,viewWidth:i,viewTop:this.blockSpace.getScrollOffsetY(),viewLeft:o,contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,absoluteTop:0,absoluteLeft:t}},Blockly.BlockSpaceEditor.prototype.getCanvasBBox=function(e){return Blockly.isMsie()||Blockly.isTrident()?(e.style.display="inline",{x:e.getBBox().x,y:e.getBBox().y,width:e.scrollWidth,height:e.scrollHeight}):e.getBBox()},Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_=function(e){if(!this.blockSpace.scrollbarPair)throw"Attempt to set editor's scroll position without scrollbars.";var t=this.getBlockSpaceMetrics_(),o=this.blockSpace.getScrollableSize(t);goog.isNumber(e.x)&&(this.blockSpace.xOffsetFromView=-o.width*e.x),goog.isNumber(e.y)&&(this.blockSpace.yOffsetFromView=-o.height*e.y),o="translate("+(e=this.blockSpace.xOffsetFromView+t.absoluteLeft)+","+(t=this.blockSpace.yOffsetFromView+t.absoluteTop)+")",this.blockSpace.getCanvas().setAttribute("transform",o),this.blockSpace.getBubbleCanvas().setAttribute("transform",o),t=Blockly.convertCoordinates(e,t,this.svg_,!1),this.blockSpace.getDragCanvas().setAttribute("transform","translate("+t.x+","+t.y+")")},Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetricsNoScroll_=function(){var e=this.getBlockSpaceMetrics_();if(e){var t="translate("+e.absoluteLeft+","+e.absoluteTop+")";this.blockSpace.getCanvas().setAttribute("transform",t),this.blockSpace.getBubbleCanvas().setAttribute("transform",t),e=Blockly.convertCoordinates(e.absoluteLeft,e.absoluteTop,this.svg_,!1),this.blockSpace.getDragCanvas().setAttribute("transform","translate("+e.x+","+e.y+")")}},Blockly.BlockSpaceEditor.prototype.addChangeListener=function(e){return Blockly.bindEvent_(this.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this,e)},Blockly.BlockSpaceEditor.prototype.addUnusedBlocksHelpListener=function(e){return Blockly.bindEvent_(this.blockSpace.getCanvas(),Blockly.BlockSvgUnused.UNUSED_BLOCK_HELP_EVENT,this,e)},Blockly.BlockSpaceEditor.prototype.isReadOnly=function(){return Blockly.readOnly||this.readOnly_},Blockly.BlockSpaceEditor.prototype.lockMovement=function(){this.movementLocked_=!0},Blockly.BlockSpaceEditor.prototype.unlockMovement=function(){this.movementLocked_=!1},Blockly.BlockSpaceEditor.prototype.isMovementLocked=function(){return this.movementLocked_},Blockly.BlockSpaceEditor.prototype.shouldHavePadding=function(){return!this.inline_},Blockly.removeChangeListener=function(e){Blockly.unbindEvent_(e)},Blockly.HorizontalFlyout=function(){Blockly.Flyout.apply(this,arguments),this.autoClose=!1,this.height_=10,this.customYOffset=this.flyoutRows=0},goog.inherits(Blockly.HorizontalFlyout,Blockly.Flyout),Blockly.HorizontalFlyout.prototype.show=function(){var e=this.targetBlockSpace_.getMetrics();this.width_=Math.max(0,e.viewWidth-2*this.CORNER_RADIUS),Blockly.HorizontalFlyout.superClass_.show.apply(this,arguments)},Blockly.HorizontalFlyout.prototype.hide=function(){this.height_=10,this.flyoutRows=0,Blockly.HorizontalFlyout.superClass_.hide.apply(this,arguments)},Blockly.HorizontalFlyout.prototype.setVisibility=function(e){e?this.softShow():this.softHide()},Blockly.HorizontalFlyout.prototype.softHide=function(){Blockly.addClass_(this.svgGroup_,"hiddenFlyout")},Blockly.HorizontalFlyout.prototype.softShow=function(){Blockly.removeClass_(this.svgGroup_,"hiddenFlyout")},Blockly.HorizontalFlyout.prototype.position_=function(){if(this.isVisible()){var e=this.customMetrics?this.customMetrics():this.targetBlockSpace_.getMetrics();if(e){var t=this.height_-this.CORNER_RADIUS,o=Math.max(0,e.viewWidth-2*this.CORNER_RADIUS),n=["M 0,0"];n.push("v",t),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,0,this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("h",o),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,0,this.CORNER_RADIUS,-this.CORNER_RADIUS),n.push("v",-t),n.push("z"),this.svgBackground_.setAttribute("d",n.join(" ")),this.width_=o,this.svgGroup_.setAttribute("transform","translate("+e.absoluteLeft+","+(e.absoluteTop-this.height_+this.customYOffset)+")"),this.scrollbar_&&this.scrollbar_.resize(),this.svgBackground_.style.pointerEvents=this.scrollbar_?"initial":"none"}}},Blockly.HorizontalFlyout.prototype.getYPosition=function(){return this.customYOffset||0},Blockly.HorizontalFlyout.prototype.layoutBlock_=function(e,t,o,n){var i=e.getHeightWidth();(Blockly.RTL&&0>t.x-i.width||!Blockly.RTL&&t.x+i.width>this.width_)&&(this.flyoutRows++,t.y+=i.height+o/2,t.x=n),e.moveBy(t.x,t.y),e=i.width+o/2,Blockly.RTL&&(e=-e),t.x+=e,this.minFlyoutWidth_=t.x+o,this.height_=t.y+i.height+o/2},Blockly.HorizontalFlyout.prototype.reflow=function(){},goog.structs.LinkedMap=function(e,t,o){this.maxCount_=e||null,this.cache_=!!t,this.evictionCallback_=o,this.map_=new goog.structs.Map,this.head_=new goog.structs.LinkedMap.Node_("",void 0),this.head_.next=this.head_.prev=this.head_},goog.structs.LinkedMap.prototype.findAndMoveToTop_=function(e){return(e=this.map_.get(e))&&this.cache_&&(e.remove(),this.insert_(e)),e},goog.structs.LinkedMap.prototype.get=function(e,t){return(e=this.findAndMoveToTop_(e))?e.value:t},goog.structs.LinkedMap.prototype.peekValue=function(e,t){return(e=this.map_.get(e))?e.value:t},goog.structs.LinkedMap.prototype.set=function(e,t){var o=this.findAndMoveToTop_(e);o?o.value=t:(o=new goog.structs.LinkedMap.Node_(e,t),this.map_.set(e,o),this.insert_(o))},goog.structs.LinkedMap.prototype.peek=function(){return this.head_.next.value},goog.structs.LinkedMap.prototype.peekLast=function(){return this.head_.prev.value},goog.structs.LinkedMap.prototype.shift=function(){return this.popNode_(this.head_.next)},goog.structs.LinkedMap.prototype.pop=function(){return this.popNode_(this.head_.prev)},goog.structs.LinkedMap.prototype.remove=function(e){return!!(e=this.map_.get(e))&&(this.removeNode(e),!0)},goog.structs.LinkedMap.prototype.removeNode=function(e){e.remove(),this.map_.remove(e.key)},goog.structs.LinkedMap.prototype.getCount=function(){return this.map_.getCount()},goog.structs.LinkedMap.prototype.isEmpty=function(){return this.map_.isEmpty()},goog.structs.LinkedMap.prototype.setEvictionCallback=function(e){this.evictionCallback_=e},goog.structs.LinkedMap.prototype.setMaxCount=function(e){this.maxCount_=e||null,null!=this.maxCount_&&this.truncate_(this.maxCount_)},goog.structs.LinkedMap.prototype.getKeys=function(){return this.map(function(e,t){return t})},goog.structs.LinkedMap.prototype.getValues=function(){return this.map(function(e,t){return e})},goog.structs.LinkedMap.prototype.contains=function(e){return this.some(function(t){return t==e})},goog.structs.LinkedMap.prototype.containsKey=function(e){return this.map_.containsKey(e)},goog.structs.LinkedMap.prototype.clear=function(){this.truncate_(0)},goog.structs.LinkedMap.prototype.forEach=function(e,t){for(var o=this.head_.next;o!=this.head_;o=o.next)e.call(t,o.value,o.key,this)},goog.structs.LinkedMap.prototype.map=function(e,t){for(var o=[],n=this.head_.next;n!=this.head_;n=n.next)o.push(e.call(t,n.value,n.key,this));return o},goog.structs.LinkedMap.prototype.some=function(e,t){for(var o=this.head_.next;o!=this.head_;o=o.next)if(e.call(t,o.value,o.key,this))return!0;return!1},goog.structs.LinkedMap.prototype.every=function(e,t){for(var o=this.head_.next;o!=this.head_;o=o.next)if(!e.call(t,o.value,o.key,this))return!1;return!0},goog.structs.LinkedMap.prototype.insert_=function(e){this.cache_?(e.next=this.head_.next,e.prev=this.head_,this.head_.next=e,e.next.prev=e):(e.prev=this.head_.prev,e.next=this.head_,this.head_.prev=e,e.prev.next=e),null!=this.maxCount_&&this.truncate_(this.maxCount_)},goog.structs.LinkedMap.prototype.truncate_=function(e){for(;this.getCount()>e;){var t=this.cache_?this.head_.prev:this.head_.next;this.removeNode(t),this.evictionCallback_&&this.evictionCallback_(t.key,t.value)}},goog.structs.LinkedMap.prototype.popNode_=function(e){return this.head_!=e&&this.removeNode(e),e.value},goog.structs.LinkedMap.Node_=function(e,t){this.key=e,this.value=t},goog.structs.LinkedMap.Node_.prototype.remove=function(){this.prev.next=this.next,this.next.prev=this.prev,delete this.prev,delete this.next},FRAME_MARGIN_SIDE=15,FRAME_MARGIN_TOP=10,FRAME_HEADER_HEIGHT=25,Blockly.FunctionEditor=function(e,t,o,n,i){this.created_=!1,this.orderedParamIDsToBlocks_=new goog.structs.LinkedMap,this.modalBlockSpace=this.onResizeWrapper_=this.modalBackground_=this.frameText_=this.frameInner_=this.frameBase_=this.flyout_=this.contractDiv_=this.deleteButton_=this.closeButton_=this.container_=this.functionDefinitionBlock=null,this.msgOverrides_=e||{},t&&(this.definitionBlockType=t),this.parameterBlockTypes=o||{},this.disableParamEditing=n||!1,this.paramTypes=i||[],Blockly.FunctionEditor.allFunctionEditors.push(this)},Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT,Blockly.FunctionEditor.BLOCK_LAYOUT_TOP_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_TOP,Blockly.FunctionEditor.DELETE_BUTTON_MARGIN=25,Blockly.FunctionEditor.CLOSE_BUTTON_OVERHANG=14,Blockly.FunctionEditor.RTL_CLOSE_BUTTON_OFFSET=5,Blockly.FunctionEditor.BUTTON_TOP_OFFSET=-22,Blockly.FunctionEditor.allFunctionEditors=[],Blockly.FunctionEditor.prototype.getMsg=function(e){return this.msgOverrides_[e]||Blockly.Msg[e]},Blockly.FunctionEditor.prototype.paramEditingDisabled=function(){return Blockly.disableParamEditing||this.disableParamEditing},Blockly.FunctionEditor.prototype.definitionBlockType="procedures_defnoreturn",Blockly.FunctionEditor.prototype.defaultParameterBlockType="parameters_get",Blockly.FunctionEditor.prototype.autoOpenFunction=function(e){this.autoOpenWithLevelConfiguration({autoOpenFunction:e})},Blockly.FunctionEditor.prototype.autoOpenWithLevelConfiguration=function(e){e.autoOpenFunction&&this.openAndEditFunction(e.autoOpenFunction)},Blockly.FunctionEditor.prototype.openEditorForCallBlock_=function(e){var t=e.getTitleValue("NAME");this.openEditorForFunction(e,t)},Blockly.FunctionEditor.prototype.openEditorForFunction=function(e,t){e.blockSpace.blockSpaceEditor.hideChaff(),this.hideIfOpen(),this.openAndEditFunction(t)},Blockly.FunctionEditor.prototype.openAndEditFunction=function(e){if(!(e=Blockly.mainBlockSpace.findFunction(e)))throw Error("Can't find definition block to edit");var t=e.getTitleValue("NAME");this.show(),this.setupUIForBlock_(e),this.functionDefinitionBlock=this.moveToModalBlockSpace(e),this.functionDefinitionBlock.setMovable(!1),this.functionDefinitionBlock.setDeletable(!1),this.functionDefinitionBlock.setEditable(!1),this.populateParamToolbox_(),this.setupUIAfterBlockInEditor_(),this.container_.querySelector("#functionNameText").value=t,this.container_.querySelector("#functionDescriptionText").value=this.functionDefinitionBlock.description_||"",this.deleteButton_.setVisible(e.userCreated),Blockly.fireUiEvent(window,"function_editor_opened")},Blockly.FunctionEditor.prototype.setupUIForBlock_=function(){},Blockly.FunctionEditor.prototype.setupUIAfterBlockInEditor_=function(){},Blockly.FunctionEditor.prototype.populateParamToolbox_=function(){this.orderedParamIDsToBlocks_.clear(),this.addParamsFromProcedure_(),this.resetParamIDs_(),this.refreshParamsEverywhere()},Blockly.FunctionEditor.prototype.addParamsFromProcedure_=function(){for(var e=this.functionDefinitionBlock.getProcedureInfo(),t=0;t<e.parameterNames.length;t++)e.parameterTypes?this.addParameter(e.parameterNames[t],e.parameterTypes[t]):this.addParameter(e.parameterNames[t])},Blockly.FunctionEditor.prototype.getParamNameType=function(e){var t=this.orderedParamIDsToBlocks_.get(e);if(!t)throw"Block not found for ID "+e;return this.paramNameTypeFromXML_(t)},Blockly.FunctionEditor.prototype.paramNameTypeFromXML_=function(e){var t={};return t.name=e.firstElementChild.textContent,t.type=e.childNodes[1].textContent,t},Blockly.FunctionEditor.prototype.openWithNewFunction=function(){this.ensureCreated_();var e=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:this.definitionBlockType}));e.userCreated=!0,this.openAndEditFunction(e.getTitleValue("NAME"))},Blockly.FunctionEditor.prototype.bindToolboxHandlers_=function(){var e=this.container_.querySelector("#paramAddText"),t=this.container_.querySelector("#paramAddType"),o=this.container_.querySelector("#paramAddButton");this.paramEditingDisabled()||(Blockly.bindEvent_(o,"click",this,goog.bind(this.addParamFromInputField_,this,e,t)),Blockly.bindEvent_(e,"keydown",this,function(o){o.keyCode===goog.events.KeyCodes.ENTER&&this.addParamFromInputField_(e,t)}))},Blockly.FunctionEditor.prototype.addParamFromInputField_=function(e,t){var o=e.value;e.value="",this.addParameter(o,t&&t.value),this.refreshParamsEverywhere()},Blockly.FunctionEditor.prototype.addParameter=function(e,t){this.orderedParamIDsToBlocks_.set(goog.events.getUniqueId("parameter"),this.newParameterBlock(e,t))},Blockly.FunctionEditor.prototype.getParameterBlockType=function(e){return this.parameterBlockTypes[e]||this.defaultParameterBlockType},Blockly.FunctionEditor.prototype.newParameterBlock=function(e,t){var o=this.getParameterBlockType(t);o=Blockly.createSvgElement("block",{type:o});var n=Blockly.createSvgElement("title",{name:"VAR"},o);return t&&Blockly.createSvgElement("mutation",{output:t},o),n.textContent=e,o},Blockly.FunctionEditor.prototype.renameParameter=function(e,t){this.orderedParamIDsToBlocks_.forEach(function(o){o.firstElementChild&&o.firstElementChild.textContent===e&&(o.firstElementChild.textContent=t)}),this.forEachParameterGetBlock(e,function(e){e.setTitleValue(t,"VAR")})},Blockly.FunctionEditor.prototype.changeParameterTypeInFlyoutXML=function(e,t){this.orderedParamIDsToBlocks_.forEach(function(o){o.firstElementChild&&o.firstElementChild.textContent===e&&(o.childNodes[1].firstElementChild.textContent=t)})},Blockly.FunctionEditor.prototype.removeParameter=function(e){var t=[];this.orderedParamIDsToBlocks_.forEach(function(o,n){o.firstElementChild&&o.firstElementChild.textContent===e&&t.push(n)}),t.forEach(function(e){this.orderedParamIDsToBlocks_.remove(e)},this),this.forEachParameterGetBlock(e,function(e){e.dispose(!0,!1)}),this.refreshParamsEverywhere()},Blockly.FunctionEditor.prototype.refreshParamsEverywhere=function(){this.refreshParamsInFlyout_(),this.refreshParamsOnFunction_()},Blockly.FunctionEditor.prototype.refreshParamsInFlyout_=function(){this.flyout_.show(this.orderedParamIDsToBlocks_.getValues())},Blockly.FunctionEditor.prototype.resetParamIDs_=function(){var e=this.paramsAsParallelArrays_();e.paramIDs=null,this.functionDefinitionBlock.updateParamsFromArrays(e.paramNames,e.paramIDs,e.paramTypes)},Blockly.FunctionEditor.prototype.refreshParamsOnFunction_=function(){var e=this.paramsAsParallelArrays_();this.functionDefinitionBlock.updateParamsFromArrays(e.paramNames,e.paramIDs,e.paramTypes)},Blockly.FunctionEditor.prototype.paramsAsParallelArrays_=function(){var e=[],t=[],o=[];return this.orderedParamIDsToBlocks_.forEach(function(n,i){e.push(n.firstElementChild.textContent),t.push(i),1<n.childNodes.length&&(n=n.childNodes[1],o.push(n.getAttribute("output")||n.textContent))},this),{paramNames:e,paramIDs:t,paramTypes:o}},Blockly.FunctionEditor.prototype.forEachParameterGetBlock=function(e,t){this.functionDefinitionBlock&&this.functionDefinitionBlock.getDescendants().forEach(function(o){"parameters_get"==o.type&&Blockly.Names.equals(e,o.getTitleValue("VAR"))&&t(o)})},Blockly.FunctionEditor.prototype.show=function(){this.ensureCreated_(),this.position_(),goog.style.setElementShown(this.container_,!0),goog.style.setElementShown(this.modalBackground_,!0),Blockly.focusedBlockSpace=this.modalBlockSpace,Blockly.selected&&Blockly.selected.unselect()},Blockly.FunctionEditor.prototype.isOpen=function(){return this.isCreated()&&goog.style.isElementShown(this.container_)},Blockly.FunctionEditor.prototype.isCreated=function(){return!!this.container_},Blockly.FunctionEditor.prototype.ensureCreated_=function(){this.isCreated()||this.create_()},Blockly.FunctionEditor.prototype.onClose=function(){this.hideIfOpen()},Blockly.FunctionEditor.prototype.hideIfOpen=function(){this.isOpen()&&(this.hideAndRestoreBlocks_(),this.modalBlockSpace.clear())},Blockly.FunctionEditor.prototype.hideAndRestoreBlocks_=function(){var e=this.functionDefinitionBlock;this.functionDefinitionBlock=null,this.moveToMainBlockSpace_(e),this.container_.querySelector("#functionNameText").value="",this.container_.querySelector("#functionDescriptionText").value="",this.container_.querySelector("#paramAddText")&&(this.container_.querySelector("#paramAddText").value=""),goog.style.setElementShown(this.container_,!1),goog.style.setElementShown(this.modalBackground_,!1),Blockly.focusedBlockSpace=Blockly.mainBlockSpace,Blockly.fireUiEvent(window,"function_editor_closed")},Blockly.FunctionEditor.prototype.moveToMainBlockSpace_=function(e){e.setMovable(!0),e.setDeletable(!0);var t=Blockly.Xml.blockToDom(e);e.dispose(!1,!1,!0),Blockly.Xml.domToBlock(Blockly.mainBlockSpace,t).setCurrentlyHidden(!0)},Blockly.FunctionEditor.prototype.moveToModalBlockSpace=function(e){var t=Blockly.Xml.blockToDom(e);return e.dispose(!1,!1,!0),(e=Blockly.Xml.domToBlock(this.modalBlockSpace,t)).moveTo(Blockly.RTL?this.modalBlockSpace.getMetrics().viewWidth-Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN:Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,Blockly.FunctionEditor.BLOCK_LAYOUT_TOP_MARGIN),e.setCurrentlyHidden(!1),e.setUserVisible(!0,!0),e},Blockly.FunctionEditor.prototype.create_=function(){function e(e){var t=e.target.value;if((e=/\)|\(/g).test(t)&&(t=t.replace(e,""),this.container_.querySelector("#functionNameText").value=t),this.functionDefinitionBlock.setTitleValue(t,"NAME"),this.functionDefinitionBlock.userCreated&&"behavior_definition"===this.functionDefinitionBlock.type&&(this.functionDefinitionBlock.getTitle_("NAME").id=t),Blockly.Blocks.gamelab_behaviorPicker){var o=this.functionDefinitionBlock.getTitle_("NAME").id;getAllBehaviorPickerBlocks().forEach(function(e){updateBehaviorPickerFields(e,o,t)})}}function t(e){this.functionDefinitionBlock.description_=e.target.value}if(this.created_)throw"Attempting to re-create already created Function Editor";this.container_=document.createElement("div"),this.container_.setAttribute("id","modalContainer"),goog.dom.insertSiblingAfter(this.container_,Blockly.mainBlockSpaceEditor.svg_),this.container_.style.top=Blockly.mainBlockSpaceEditor.getWorkspaceTopOffset()+"px";var o=this;this.modalBlockSpaceEditor=new Blockly.BlockSpaceEditor(this.container_,{getMetrics:function(){var e=Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_.call(this);return e?(e.absoluteLeft+=FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH+1,e.absoluteTop+=o.getBlockSpaceEditorToScreenTop_(),e.viewWidth-=2*(FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH),e.viewHeight-=FRAME_MARGIN_TOP+Blockly.Bubble.BORDER_WIDTH+o.getWindowBorderChromeHeight(),e):null},setMetrics:function(e){Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_.call(this,e),o.contractDiv_&&(o.resizeUIComponents_(),o.layOutBlockSpaceItems_())},hideTrashRect:!0}),this.modalBlockSpace=this.modalBlockSpaceEditor.blockSpace,this.modalBlockSpace.customFlyoutMetrics_=Blockly.mainBlockSpace.getMetrics,this.modalBlockSpace.bindBeginPanDragHandler(this.container_,goog.bind(function(){this.modalBlockSpaceEditor.hideChaff()},this)),this.modalBlockSpace.bindScrollOnWheelHandler(this.container_),Blockly.modalBlockSpace=this.modalBlockSpace,Blockly.modalBlockSpaceEditor=this.modalBlockSpaceEditor;var n=Blockly.createSvgElement("clipPath",{id:"modalBlockCanvasClipRect"});this.modalBlockSpaceEditor.addToSvgDefs(n),this.modalBlockSpace.getClippingGroup().setAttribute("clip-path","url(#modalBlockCanvasClipRect)"),this.clipPathRect_=Blockly.createSvgElement("rect",{x:0,y:0,width:1,height:1},n),this.modalBlockSpaceEditor.addChangeListener(Blockly.mainBlockSpace.fireChangeEvent),this.modalBackground_=Blockly.createSvgElement("g",{class:"modalBackground"}),Blockly.mainBlockSpaceEditor.appendSVGChild(this.modalBackground_),this.addCloseButton_(),this.addDeleteButton_(),this.addEditorFrame_(),this.createContractDom_(),this.createParameterEditor_(),this.setupParametersToolbox_(),this.resizeUIComponents_(),this.bindToolboxHandlers_(),Blockly.bindEvent_(this.container_,"mousedown",this,function(e){e.target===e.currentTarget&&(this.modalBlockSpaceEditor.hideChaff(),Blockly.selected&&Blockly.selected.unselect())}),Blockly.bindEvent_(goog.dom.getDocument().body,"keyup",this,function(e){e.keyCode===goog.events.KeyCodes.ESC&&this.onClose()}),Blockly.bindEvent_(this.container_.querySelector("#modalEditorClose"),"mousedown",this,this.onClose),Blockly.bindEvent_(this.container_.querySelector("#functionNameText"),"input",this,e),Blockly.bindEvent_(this.container_.querySelector("#functionNameText"),"keydown",this,e),Blockly.bindEvent_(this.contractDiv_,"mousedown",null,function(){Blockly.selected&&Blockly.selected.unselect()}),Blockly.bindEvent_(this.container_.querySelector("#functionDescriptionText"),"input",this,t),Blockly.bindEvent_(this.container_.querySelector("#functionDescriptionText"),"keydown",this,t),this.onResizeWrapper_=Blockly.bindEvent_(window,goog.events.EventType.RESIZE,this,this.position_),this.modalBlockSpaceEditor.svgResize()},Blockly.FunctionEditor.prototype.resizeUIComponents_=function(){var e=this.modalBlockSpace.getMetrics();this.resizeFrame_(e),this.positionClippingRects_(e),this.positionSizeContractDom_(e.viewWidth),this.positionCloseButton_(e),this.positionDeleteButton_(e)},Blockly.FunctionEditor.prototype.resizeFrame_=function(e){var t=e.viewWidth,o=e.viewHeight;e=e.absoluteTop-this.getBlockSpaceEditorToScreenTop_(),this.modalBackground_.setAttribute("transform","translate(0,"+e+")"),this.frameBase_.setAttribute("width",t+2*Blockly.Bubble.BORDER_WIDTH),this.frameBase_.setAttribute("height",o+2*Blockly.Bubble.BORDER_WIDTH+FRAME_HEADER_HEIGHT),this.frameInner_.setAttribute("width",t),this.frameInner_.setAttribute("height",o),Blockly.RTL&&(this.frameBase_.setAttribute("x",FRAME_MARGIN_SIDE),this.frameInner_.setAttribute("x",FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH+1),this.frameText_.setAttribute("x",t-2*FRAME_MARGIN_SIDE))},Blockly.FunctionEditor.prototype.positionClippingRects_=function(e){var t=e.viewWidth,o=e.viewHeight;this.clipPathRect_.setAttribute("x",e.absoluteLeft),this.clipPathRect_.setAttribute("y",e.absoluteTop),this.clipPathRect_.setAttribute("width",t),this.clipPathRect_.setAttribute("height",o),this.frameClipDiv_.style.left=e.absoluteLeft+"px",this.frameClipDiv_.style.top=e.absoluteTop+"px",this.frameClipDiv_.style.width=t+"px",this.frameClipDiv_.style.height=o+"px"},Blockly.FunctionEditor.prototype.positionSizeContractDom_=function(e){this.contractDiv_.style.left=this.modalBlockSpace.xOffsetFromView+"px",this.contractDiv_.style.top=this.getContractDomTopY_()+"px",this.contractDiv_.style.width=e+"px",this.positionFlyout_(0)},Blockly.FunctionEditor.prototype.positionCloseButton_=function(e){this.closeButton_.setAttribute("transform","translate("+(Blockly.RTL?Blockly.FunctionEditor.RTL_CLOSE_BUTTON_OFFSET:e.absoluteLeft+e.viewWidth+Blockly.FunctionEditor.CLOSE_BUTTON_OVERHANG-this.closeButton_.firstElementChild.getAttribute("width"))+","+(e.absoluteTop+Blockly.FunctionEditor.BUTTON_TOP_OFFSET)+")")},Blockly.FunctionEditor.prototype.positionDeleteButton_=function(e){var t=this.closeButton_.firstElementChild.getAttribute("width"),o=this.deleteButton_.getButtonWidth();o=e.absoluteLeft+e.viewWidth+(Blockly.FunctionEditor.CLOSE_BUTTON_OVERHANG-t)-o-Blockly.FunctionEditor.DELETE_BUTTON_MARGIN,t=Blockly.FunctionEditor.RTL_CLOSE_BUTTON_OFFSET+t+Blockly.FunctionEditor.DELETE_BUTTON_MARGIN,this.deleteButton_.renderAt(Blockly.RTL?t:o,e.absoluteTop+Blockly.FunctionEditor.BUTTON_TOP_OFFSET)},Blockly.FunctionEditor.prototype.getBlockSpaceEditorToScreenTop_=function(){return this.getWindowBorderChromeHeight()},Blockly.FunctionEditor.prototype.getWindowBorderChromeHeight=function(){return FRAME_MARGIN_TOP+Blockly.Bubble.BORDER_WIDTH+FRAME_HEADER_HEIGHT},Blockly.FunctionEditor.prototype.getContractDivHeight=function(){return this.contractDiv_?this.contractDiv_.getBoundingClientRect().height:0},Blockly.FunctionEditor.prototype.readyToBeLaidOut_=function(){return this.functionDefinitionBlock&&this.functionDefinitionBlock.svgInitialized()&&this.isOpen()},Blockly.FunctionEditor.prototype.positionFlyout_=function(e){return e+=this.flyout_.getHeight(),this.flyout_.customYOffset=e+this.modalBlockSpace.yOffsetFromView,this.flyout_.position_(),e},Blockly.FunctionEditor.prototype.layOutBlockSpaceItems_=function(){if(this.readyToBeLaidOut_()){var e=Blockly.RTL?this.modalBlockSpace.getMetrics().viewWidth-Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN:Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,t=this.getContractDivHeight();t=this.positionFlyout_(t),t+=Blockly.FunctionEditor.BLOCK_LAYOUT_TOP_MARGIN,this.functionDefinitionBlock.moveTo(e,t)}},Blockly.FunctionEditor.prototype.addCloseButton_=function(){this.closeButton_=Blockly.createSvgElement("g",{id:"modalEditorClose",filter:"url(#blocklyTrashcanShadowFilter)"});var e=Blockly.createSvgElement("rect",{rx:12,ry:12,fill:"#7665a0",stroke:"white","stroke-width":"2.5"},this.closeButton_),t=Blockly.createSvgElement("text",{x:7,y:7,class:"blocklyText"},this.closeButton_);t.textContent=this.getMsg("CLOSE"),this.modalBlockSpaceEditor.appendSVGChild(this.closeButton_),t=t.getBoundingClientRect(),e.setAttribute("width",t.width+14),e.setAttribute("height",t.height+7),e.setAttribute("y",7-t.height-1)},Blockly.FunctionEditor.prototype.addDeleteButton_=function(){this.deleteButton_=new Blockly.SvgTextButton(this.modalBlockSpaceEditor.getSVGElement(),this.getMsg("DELETE"),this.onDeletePressed.bind(this))},Blockly.FunctionEditor.prototype.onDeletePressed=function(){var e=this.functionDefinitionBlock.getProcedureInfo().name,t=this.getMsg("CONFIRM_DELETE_FUNCTION_MESSAGE").replace("%1",e);Blockly.showSimpleDialog({bodyText:t,cancelText:this.getMsg("DELETE"),isDangerCancel:!0,confirmText:this.getMsg("KEEP"),onConfirm:null,onCancel:this.onDeleteConfirmed.bind(this,e)})},Blockly.FunctionEditor.prototype.onDeleteConfirmed=function(e){this.hideIfOpen();var t=Blockly.mainBlockSpace.findFunction(e);Blockly.mainBlockSpace.findFunctionExamples(e).concat(t).forEach(function(e){e.dispose(!1,!1,!0)}),Blockly.Blocks.gamelab_behaviorPicker&&getAllBehaviorPickerBlocks().forEach(function(t){resetDeletedBehaviorPickerFields(t,e)})},Blockly.FunctionEditor.prototype.setupParametersToolbox_=function(){this.flyout_=new Blockly.HorizontalFlyout(this.modalBlockSpaceEditor);var e=this.flyout_.createDom();this.modalBlockSpace.getClippingGroup().insertBefore(e,this.modalBlockSpace.svgBlockCanvas_),this.flyout_.init(this.modalBlockSpace,!1)},Blockly.FunctionEditor.prototype.addEditorFrame_=function(){var e=Blockly.modalBlockSpace.getMetrics().absoluteLeft-FRAME_MARGIN_SIDE-Blockly.Bubble.BORDER_WIDTH-1;e=this.modalBlockSpace.isReadOnly()?0:e,this.frameBase_=Blockly.createSvgElement("rect",{x:e+FRAME_MARGIN_SIDE,y:0+FRAME_MARGIN_TOP,fill:"hsl(94, 73%, 35%)",rx:Blockly.Bubble.BORDER_WIDTH,ry:Blockly.Bubble.BORDER_WIDTH},this.modalBackground_),this.frameInner_=Blockly.createSvgElement("rect",{x:e+FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH,y:0+FRAME_MARGIN_TOP+Blockly.Bubble.BORDER_WIDTH+FRAME_HEADER_HEIGHT,fill:"#ffffff"},this.modalBackground_),this.frameText_=Blockly.createSvgElement("text",{x:e+FRAME_MARGIN_SIDE+16,y:0+FRAME_MARGIN_TOP+22,class:"blocklyText",style:"font-size: 12pt"},this.modalBackground_),this.frameText_.textContent=this.getMsg("FUNCTION_HEADER")},Blockly.FunctionEditor.prototype.position_=function(){if(this.isOpen()){var e=this.modalBlockSpace.getMetrics();this.resizeFrame_(e),this.positionSizeContractDom_(e.viewWidth),this.layOutBlockSpaceItems_(),this.modalBlockSpaceEditor.svgResize()}},Blockly.FunctionEditor.prototype.getContractDomTopY_=function(){return this.modalBlockSpace.yOffsetFromView},Blockly.FunctionEditor.prototype.createParameterEditor_=function(){if(!this.paramEditingDisabled()){if(0<this.paramTypes.length)var e=this.paramTypes.map(function(e){return goog.dom.createDom("OPTION",null,e)}),t=goog.dom.createDom("SELECT",{id:"paramAddType",style:"pointer-events: auto; margin: 0; width: 100px;"},e);e=goog.dom.createDom("DIV",null,this.getMsg("FUNCTION_PARAMETERS_LABEL")),t=goog.dom.createDom("DIV",null,goog.dom.createDom("INPUT",{id:"paramAddText",type:"text",style:"width: 200px;"})," ",t,goog.dom.createDom("BUTTON",{id:"paramAddButton",class:"btn no-mc"},this.getMsg("ADD_PARAMETER")));var o=this.container_.querySelector("#paramEditingArea");goog.dom.removeChildren(o),goog.dom.appendChild(o,e),goog.dom.appendChild(o,t)}},Blockly.FunctionEditor.prototype.createFrameClipDiv_=function(){var e=goog.dom.createDom("div");return e.style.position="absolute",e.style.overflow="hidden",e.style.pointerEvents="none",e},Blockly.FunctionEditor.prototype.createContractDom_=function(){this.contractDiv_=goog.dom.createDom("DIV","blocklyToolboxDiv paramToolbox blocklyText flyoutColorGray innerModalDiv",goog.dom.createDom("DIV",null,this.getMsg("FUNCTION_NAME_LABEL")),goog.dom.createDom("DIV",null,goog.dom.createDom("INPUT",{id:"functionNameText",type:"text"})),goog.dom.createDom("DIV",null,this.getMsg("FUNCTION_DESCRIPTION_LABEL")),goog.dom.createDom("DIV",null,goog.dom.createDom("TEXTAREA",{id:"functionDescriptionText",rows:"2"})),goog.dom.createDom("DIV",{style:"margin: 0;",id:"paramEditingArea"})),Blockly.RTL&&this.contractDiv_.setAttribute("dir","RTL"),this.contractDiv_.style.display="block",this.frameClipDiv_=this.createFrameClipDiv_(),this.frameClipDiv_.insertBefore(this.contractDiv_,this.frameClipDiv_.firstChild),this.container_.insertBefore(this.frameClipDiv_,this.container_.firstChild)},Blockly.BlockValueType={NONE:"None",STRING:"String",NUMBER:"Number",IMAGE:"Image",BOOLEAN:"Boolean",FUNCTION:"Function",COLOUR:"Colour",ARRAY:"Array",SPRITE:"Sprite",BEHAVIOR:"Behavior",LOCATION:"Location"},Blockly.FunctionalBlockUtils={};var typesToColors={};typesToColors[Blockly.BlockValueType.NONE]=[0,0,0],typesToColors[Blockly.BlockValueType.NUMBER]=[192,1,.99],typesToColors[Blockly.BlockValueType.STRING]=[180,1,.6],typesToColors[Blockly.BlockValueType.IMAGE]=[285,1,.8],typesToColors[Blockly.BlockValueType.BOOLEAN]=[90,1,.4],Blockly.FunctionalTypeColors=typesToColors,Blockly.FunctionalBlockUtils.initTitledFunctionalBlock=function(e,t,o,n,i){i=i||{},e.setFunctional(!0,{headerHeight:30}),e.setHSV.apply(e,Blockly.FunctionalTypeColors[o]);var r={fixedSize:{height:35},fontSize:i.titleFontSize};for(e.appendDummyInput().appendTitle(new Blockly.FieldLabel(t,r)).setAlign(Blockly.ALIGN_CENTRE),t=0;t<n.length;t++){r=n[t];var l=e.appendFunctionalInput(r.name);l.setInline(0<t&&!i.verticallyStackInputs),l.setHSV.apply(l,Blockly.FunctionalTypeColors[r.type]),l.setCheck(r.type),l.setAlign(Blockly.ALIGN_CENTRE)}o===Blockly.BlockValueType.NONE?e.setFunctionalOutput(!1):e.setFunctionalOutput(!0,o)},Blockly.FunctionalBlockUtils.installStringPicker=function(e,t,o){var n=o.values;o=o.blockName,e.Blocks[o]={init:function(){this.setFunctional(!0,{headerHeight:0,rowBuffer:3}),this.setHSV.apply(this,Blockly.FunctionalTypeColors[Blockly.BlockValueType.STRING]),this.appendDummyInput().appendTitle(new Blockly.FieldLabel('"')).appendTitle(new e.FieldDropdown(n),"VAL").appendTitle(new Blockly.FieldLabel('"')).setAlign(Blockly.ALIGN_CENTRE),this.setFunctionalOutput(!0,e.BlockValueType.STRING)}},t[o]=function(){return e.JavaScript.quote_(this.getTitleValue("VAL"))}},goog.dom.classes={},goog.dom.classes.set=function(e,t){e.className=t},goog.dom.classes.get=function(e){return e=e.className,goog.isString(e)&&e.match(/\S+/g)||[]},goog.dom.classes.add=function(e,t){var o=goog.dom.classes.get(e),n=goog.array.slice(arguments,1),i=o.length+n.length;return goog.dom.classes.add_(o,n),goog.dom.classes.set(e,o.join(" ")),o.length==i},goog.dom.classes.remove=function(e,t){var o=goog.dom.classes.get(e),n=goog.array.slice(arguments,1),i=goog.dom.classes.getDifference_(o,n);return goog.dom.classes.set(e,i.join(" ")),i.length==o.length-n.length},goog.dom.classes.add_=function(e,t){for(var o=0;o<t.length;o++)goog.array.contains(e,t[o])||e.push(t[o])},goog.dom.classes.getDifference_=function(e,t){return goog.array.filter(e,function(e){return!goog.array.contains(t,e)})},goog.dom.classes.swap=function(e,t,o){for(var n=goog.dom.classes.get(e),i=!1,r=0;r<n.length;r++)n[r]==t&&(goog.array.splice(n,r--,1),i=!0);return i&&(n.push(o),goog.dom.classes.set(e,n.join(" "))),i},goog.dom.classes.addRemove=function(e,t,o){var n=goog.dom.classes.get(e);goog.isString(t)?goog.array.remove(n,t):goog.isArray(t)&&(n=goog.dom.classes.getDifference_(n,t)),goog.isString(o)&&!goog.array.contains(n,o)?n.push(o):goog.isArray(o)&&goog.dom.classes.add_(n,o),goog.dom.classes.set(e,n.join(" "))},goog.dom.classes.has=function(e,t){return goog.array.contains(goog.dom.classes.get(e),t)},goog.dom.classes.enable=function(e,t,o){o?goog.dom.classes.add(e,t):goog.dom.classes.remove(e,t)},goog.dom.classes.toggle=function(e,t){var o=!goog.dom.classes.has(e,t);return goog.dom.classes.enable(e,t,o),o};var NO_RESULT_TEXT="",SUCCESS_TEXT="Matches definition.",RESULT_TEXT_TOP_MARGIN=14,EMPTY_EXAMPLE_INPUT_WIDTH=40;Blockly.ExampleView=function(e,t,o){this.domParent_=e,this.svgParent_=t,this.contractEditor_=o,this.block_=null,this.horizontalLine=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR,height:2},this.svgParent_),Blockly.svgIgnoreMouseEvents(this.horizontalLine),this.grayBackdrop=Blockly.createSvgElement("rect",{fill:"#DDD"},this.svgParent_,{belowExisting:!0}),this.grayBackdrop.style.pointerEvents="none",Blockly.svgIgnoreMouseEvents(this.grayBackdrop),this.testExampleButton=this.initializeTestButton_("Test","run26",this.testExample_.bind(this)),this.resetExampleButton=this.initializeTestButton_("Reset","reset26",this.reset.bind(this)),goog.dom.classes.add(this.resetExampleButton,"resetButton"),goog.dom.append(this.domParent_,this.testExampleButton),goog.dom.append(this.domParent_,this.resetExampleButton),this.resultText=goog.dom.createDom("div","example-result-text"),Blockly.svgIgnoreMouseEvents(this.resultText),this.resultText.textContent=NO_RESULT_TEXT,goog.dom.append(this.domParent_,this.resultText),this.refreshTestingUI(!1)},Blockly.ExampleView.prototype.initializeTestButton_=function(e,t,o){var n=goog.dom.createDom("button","testButton launch blocklyLaunch exampleAreaButton"),i=goog.dom.createDom("div");return i.textContent=e,(e=goog.dom.createDom("img",t)).setAttribute("src",Blockly.assetUrl("media/1x1.gif")),goog.dom.append(n,e),goog.dom.append(n,i),Blockly.bindEvent_(n,"click",null,o),n},Blockly.ExampleView.prototype.getBlock=function(){return this.block_},Blockly.ExampleView.prototype.testExample_=function(){this.contractEditor_.resetExampleViews();var e=this.contractEditor_.testExample(this.block_,!0);this.setResult(e||SUCCESS_TEXT),this.refreshTestingUI(!0)},Blockly.ExampleView.prototype.reset=function(){goog.style.isElementShown(this.resetExampleButton)&&(this.contractEditor_.resetExample(this.block_),this.resultText.textContent=NO_RESULT_TEXT,this.refreshTestingUI(!1))},Blockly.ExampleView.prototype.setResult=function(e){this.resultText.textContent=e||SUCCESS_TEXT,this.refreshTestingUI(!1)},Blockly.ExampleView.prototype.refreshTestingUI=function(e){goog.style.setElementShown(this.resultText,Blockly.showExampleTestButtons),goog.style.setElementShown(this.testExampleButton,Blockly.showExampleTestButtons&&!e),goog.style.setElementShown(this.resetExampleButton,Blockly.showExampleTestButtons&&e)},Blockly.ExampleView.prototype.placeExampleAndGetNewY=function(e,t,o,n,i,r,l,s){this.block_=e;var a=t;if(a+=i/=2,!e.isCurrentlyBeingDragged()){var g=e.getInput(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);if(g.type===Blockly.FUNCTIONAL_INPUT){var c=g.extraSpace,u=EMPTY_EXAMPLE_INPUT_WIDTH,h=e.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);h&&(u=h.getHeightWidth().width),g.extraSpace=o-u,g.extraSpace!==c&&e.render(!0)}e.moveTo(n,a)}a+=e.getHeightWidth().height,a+=i;var p=l+i;return[this.testExampleButton,this.resetExampleButton].forEach(function(e){e.style.top=a-s+"px",e.style.left=p+"px"}),e=Math.max(this.resetExampleButton.offsetWidth,this.testExampleButton.offsetWidth),o=Math.max(this.resetExampleButton.offsetHeight,this.testExampleButton.offsetHeight),this.resultText.style.top=a+RESULT_TEXT_TOP_MARGIN-s+"px",this.resultText.style.left=i+(p+e)+"px",a+=o,a+=i,this.horizontalLine.setAttribute("transform","translate(0,"+a+")"),this.horizontalLine.setAttribute("width",r),this.grayBackdrop.setAttribute("transform","translate(0,"+t+")"),this.grayBackdrop.setAttribute("width",l),this.grayBackdrop.setAttribute("height",a-t),a},Blockly.ExampleView.prototype.dispose=function(){goog.dom.removeNode(this.horizontalLine),goog.dom.removeNode(this.grayBackdrop),goog.dom.removeNode(this.testExampleButton),goog.dom.removeNode(this.resetExampleButton),goog.dom.removeNode(this.resultText)};var DOWN_TRIANGLE_CHARACTER="▼",RIGHT_TRIANGLE_CHARACTER="▶",DARK_GRAY_HEX="#898989",DEFAULT_HEADER_HEIGHT=25;Blockly.ContractEditorSectionView=function(e,t){this.headerText_=t.headerText,this.onCollapseCallback_=t.onCollapseCallback,this.placeContentCallback=t.placeContentCallback,this.headerHeight=t.headerHeight||DEFAULT_HEADER_HEIGHT,this.sectionNumber_=Object.prototype.hasOwnProperty.call(t,"sectionNumber")?t.sectionNumber:null,this.highlightBox_=t.highlightBox||null,this.completelyHidden_=this.highlighted_=!1,this.header_=new Blockly.SvgHeader(e,{headerText:this.textForCurrentState_(),onMouseDown:goog.bind(this.toggleCollapse,this),backgroundColor:DARK_GRAY_HEX}),this.collapsed_=!1,this.showHeader_=!0},Blockly.ContractEditorSectionView.prototype.setHeaderColor=function(e){this.header_.setColor(e)},Blockly.ContractEditorSectionView.prototype.textForCurrentState_=function(){if(!this.onCollapseCallback_)return this.headerText_;var e=(this.collapsed_?RIGHT_TRIANGLE_CHARACTER:DOWN_TRIANGLE_CHARACTER)+" ";return null!==this.sectionNumber_&&(e+=this.sectionNumber_+". "),e+this.headerText_},Blockly.ContractEditorSectionView.prototype.setHidden=function(e){(this.completelyHidden_=e)&&this.setCollapsed(!0),this.refreshHeaderText_()},Blockly.ContractEditorSectionView.prototype.removeSectionNumber=function(){this.sectionNumber_=null,this.refreshHeaderText_()},Blockly.ContractEditorSectionView.prototype.toggleCollapse=function(){this.setCollapsed(!this.collapsed_)},Blockly.ContractEditorSectionView.prototype.setCollapsed=function(e){this.collapsed_=e,this.header_.showSeparator(e),this.onCollapseCallback_&&this.onCollapseCallback_(this.collapsed_),this.refreshHeaderText_()},Blockly.ContractEditorSectionView.prototype.isCollapsed=function(){return this.collapsed_},Blockly.ContractEditorSectionView.prototype.refreshHeaderText_=function(){this.header_.setText(this.textForCurrentState_())},Blockly.ContractEditorSectionView.prototype.setHighlighted=function(e){this.highlighted_=e},Blockly.ContractEditorSectionView.prototype.setHeaderVisible=function(e){this.showHeader_=e},Blockly.ContractEditorSectionView.prototype.placeAndGetNewY=function(e,t){if(this.completelyHidden_)return this.header_.setVisible(!1),e;var o=e;return this.header_.setVisible(this.showHeader_),this.showHeader_&&(this.header_.setPositionSize(e,t,this.headerHeight),e+=this.headerHeight),this.collapsed_||(e=this.placeAndGetNewYInnerSegment_(e)),this.highlighted_&&this.highlightBox_.setPositionSize(o,t,e-o),e},Blockly.ContractEditorSectionView.prototype.placeAndGetNewYInnerSegment_=function(e){return this.placeContentCallback&&(e=this.placeContentCallback(e)),e};var FUNCTION_BLOCK_VERTICAL_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_TOP,FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT;Blockly.ContractDefinitionSection=function(e){this.definitionTableGroup=Blockly.createSvgElement("g",{},e),this.grayDefinitionBackground=Blockly.createSvgElement("rect",{fill:"#DDD"},this.definitionTableGroup),Blockly.svgIgnoreMouseEvents(this.grayDefinitionBackground),this.verticalDefinitionMidline=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR},this.definitionTableGroup),this.verticalDefinitionMidline.setAttribute("width",2),Blockly.svgIgnoreMouseEvents(this.verticalDefinitionMidline),this.horizontalDefinitionTopLine=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR},this.definitionTableGroup),this.horizontalDefinitionTopLine.setAttribute("height",2),Blockly.svgIgnoreMouseEvents(this.horizontalDefinitionTopLine),this.horizontalDefinitionBottomLine=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR},this.definitionTableGroup),this.horizontalDefinitionBottomLine.setAttribute("height",2),Blockly.svgIgnoreMouseEvents(this.horizontalDefinitionBottomLine)},Blockly.ContractDefinitionSection.prototype.handleCollapse=function(e){this.definitionTableGroup.style.display=e?"none":"block"},Blockly.ContractDefinitionSection.prototype.placeContent=function(e,t,o,n){if(!n)return e;var i=e;n.isVariable()?this.definitionTableGroup.style.display="none":(this.definitionTableGroup.style.display="block",this.horizontalDefinitionTopLine.setAttribute("transform","translate(0,"+i+")"),this.verticalDefinitionMidline.setAttribute("transform","translate("+t+","+i+")"),this.grayDefinitionBackground.setAttribute("transform","translate(0,"+e+")"),this.horizontalDefinitionTopLine.setAttribute("width",o)),e+=FUNCTION_BLOCK_VERTICAL_MARGIN;var r=n.isVariable()?FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN:FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN+t;return n.moveTo(r,e),e+=n.getHeightWidth().height,e+=FUNCTION_BLOCK_VERTICAL_MARGIN,n.isVariable()||(this.horizontalDefinitionBottomLine.setAttribute("transform","translate(0,"+e+")"),this.horizontalDefinitionBottomLine.setAttribute("width",o),this.verticalDefinitionMidline.setAttribute("height",e-i),this.grayDefinitionBackground.setAttribute("height",e-i),this.grayDefinitionBackground.setAttribute("width",t)),e};var TEXT_PADDING_LEFT="10",SEPARATOR_LINE_HEIGHT=2;Blockly.SvgHeader=function(e,t){var o=(t=t||{backgroundColor:"#000",headerText:"Default Header"}).onMouseDown?"":"pointer-events: none;";this.svgGroup_=Blockly.createSvgElement("g",{style:o},e,{belowExisting:!0}),this.rectangleElement_=Blockly.createSvgElement("rect",{fill:t.backgroundColor,style:o},this.svgGroup_),this.separatorElement_=Blockly.createSvgElement("rect",{fill:"#FFF",style:o+"opacity:.3;"},this.svgGroup_),this.textElement_=Blockly.createSvgElement("text",{class:"contractEditorHeaderText",style:o},this.svgGroup_),t.headerText&&(this.textElement_.textContent=t.headerText),t.onMouseDown&&Blockly.bindEvent_(this.svgGroup_,"click",null,t.onMouseDown)},Blockly.SvgHeader.prototype.showSeparator=function(e){goog.style.setElementShown(this.separatorElement_,e)},Blockly.SvgHeader.prototype.setColor=function(e){this.rectangleElement_.setAttribute("fill",e)},Blockly.SvgHeader.prototype.setPositionSize=function(e,t,o){this.svgGroup_.setAttribute("transform","translate(0,"+e+")"),this.rectangleElement_.setAttribute("width",t+2),this.separatorElement_.setAttribute("width",t),this.separatorElement_.setAttribute("height",SEPARATOR_LINE_HEIGHT),this.separatorElement_.setAttribute("transform","translate(0,"+(o-1)+")"),this.rectangleElement_.setAttribute("height",o),this.textElement_.setAttribute("x",TEXT_PADDING_LEFT),e=o/2,t=this.textElement_.getBBox().height/3,this.textElement_.setAttribute("y",e+t)},Blockly.SvgHeader.prototype.setText=function(e){this.textElement_.textContent=e},Blockly.SvgHeader.prototype.setVisible=function(e){goog.style.setElementShown(this.svgGroup_,e)},Blockly.SvgHeader.prototype.removeSelf=function(){goog.dom.removeNode(this.svgGroup_)},Blockly.SvgTextButton=function(e,t,o){e=Blockly.createSvgElement("g",{class:"svgTextButton",filter:"url(#blocklyTrashcanShadowFilter)"},e),this.buttonRect=Blockly.createSvgElement("rect",{rx:12,ry:12,fill:"#7665a0",stroke:"white","stroke-width":"2.5"},e);var n=Blockly.createSvgElement("text",{x:7,y:7,class:"blocklyText"},e);n.textContent=t,t=n.getBoundingClientRect(),this.buttonRect.setAttribute("width",t.width+14),this.buttonRectHeight=t.height+7,this.buttonRect.setAttribute("height",this.buttonRectHeight),this.buttonRectYOffset=7-t.height-1,this.buttonRect.setAttribute("y",this.buttonRectYOffset),Blockly.bindEvent_(e,"click",null,o),this.svgGroup_=e},Blockly.SvgTextButton.prototype.renderAt=function(e,t){return this.svgGroup_.setAttribute("transform","translate("+e+","+t+")"),t+this.buttonRectHeight},Blockly.SvgTextButton.prototype.setVisible=function(e){goog.style.setElementShown(this.svgGroup_,e)},Blockly.SvgTextButton.prototype.getButtonWidth=function(){return parseInt(this.buttonRect.getAttribute("width"),10)},Blockly.SvgHighlightBox=function(e,t){var o=(t=t||{}).color||"#000";t=t.thickness||"30",this.svgGroup_=Blockly.createSvgElement("g",{style:"pointer-events: none;"},e),this.highlightRectangle_=Blockly.createSvgElement("rect",{fill:"none","stroke-width":t,stroke:o},this.svgGroup_)},Blockly.SvgHighlightBox.prototype.setPositionSize=function(e,t,o){this.svgGroup_.setAttribute("transform","translate(0,"+e+")"),this.highlightRectangle_.setAttribute("width",t),this.highlightRectangle_.setAttribute("height",o)},Blockly.TypeDropdown=function(e){this.buttonColorSquareDiv_=this.selectComponent_=null,this.onTypeChanged_=e.onTypeChanged,this.typeChoices_=e.typeChoices,this.type_=e.type,this.changeListenerKey_=null},Blockly.TypeDropdown.prototype.render=function(e){e=this.renderSelectComponent_(e),this.buttonColorSquareDiv_=this.createColorSquareDiv(),goog.dom.appendChild(e.getElement(),this.buttonColorSquareDiv_),this.setSquareIconColor(this.type_,this.buttonColorSquareDiv_),this.attachListeners_(e),this.selectComponent_=e,this.setType_(this.type_)},Blockly.TypeDropdown.prototype.setType_=function(e){this.type_=e,this.setSquareIconColor(this.type_,this.buttonColorSquareDiv_)},Blockly.TypeDropdown.prototype.renderSelectComponent_=function(e){var t=this.createSelect_();return t.render(e),t},Blockly.TypeDropdown.prototype.createSelect_=function(){var e=new goog.ui.Select(null,null,goog.ui.FlatMenuButtonRenderer.getInstance(),null,new Blockly.CustomCssClassMenuRenderer("colored-type-dropdown"));return this.typeChoices_.forEach(function(t){var o=new goog.ui.MenuItem(t);e.addItem(o);var n=this.createColorSquareDiv();goog.dom.insertChildAt(o.getElement(),n,0),this.setSquareIconColor(t,n)},this),e.setValue(this.type_),e},Blockly.TypeDropdown.prototype.createColorSquareDiv=function(){return goog.dom.createDom("div","color-square-icon")},Blockly.TypeDropdown.prototype.attachListeners_=function(e){this.changeListenerKey_=goog.events.listen(e,goog.ui.Component.EventType.CHANGE,goog.bind(this.selectChanged_,this))},Blockly.TypeDropdown.prototype.selectChanged_=function(e){e=e.target.getContent(),this.setType_(e),this.onTypeChanged_(e)},Blockly.TypeDropdown.prototype.setSquareIconColor=function(e,t){e=Blockly.FunctionalTypeColors[e],e=goog.color.hsvToHex(e[0],e[1],255*e[2]),t.style.background=e},Blockly.TypeDropdown.prototype.dispose=function(){goog.events.unlistenByKey(this.changeListenerKey_),this.selectComponent_.dispose()},Blockly.DomainNameInput=function(e){this.onNameChanged=e.onNameChanged,this.onEnterPressed=e.onEnterPressed,this.name=e.name,this.eventsToUnbind_=[],this.inputElement_=null},Blockly.DomainNameInput.prototype.render=function(e){var t=goog.dom.createDom("input");t.type="text",t.style.width="200px",t.style.placeholder=Blockly.Msg.FUNCTIONAL_NAME_LABEL,this.name&&(t.value=this.name),e.appendChild(t),this.eventsToUnbind_.push(Blockly.bindEvent_(t,"input",this,this.onInputChange_)),this.eventsToUnbind_.push(Blockly.bindEvent_(t,"keydown",this,this.onInputChange_)),this.inputElement_=t},Blockly.DomainNameInput.prototype.onInputChange_=function(e){this.onNameChanged&&this.onNameChanged(e.target.value)},Blockly.DomainNameInput.prototype.dispose=function(){this.eventsToUnbind_.forEach(function(e){Blockly.unbindEvent_(e)}),goog.array.clear(this.eventsToUnbind_),goog.dom.removeNode(this.inputElement_)},Blockly.XButton=function(e){this.onButtonPressed=e.onButtonPressed,this.eventsToUnbind_=[],this.buttonElement_=null},Blockly.XButton.prototype.render=function(e){var t=goog.dom.createDom("button");t.className="btn",t.textContent="Remove",t.style.marginRight="-10px",e.appendChild(t),this.eventsToUnbind_.push(Blockly.bindEvent_(t,"click",this,goog.bind(function(){this.onButtonPressed&&this.onButtonPressed()},this))),this.buttonElement_=t},Blockly.XButton.prototype.dispose=function(){this.eventsToUnbind_.forEach(function(e){Blockly.unbindEvent_(e)}),goog.array.clear(this.eventsToUnbind_),goog.dom.removeNode(this.buttonElement_)},Blockly.DomainEditor=function(e){this.options=e,this.nameInput_=this.typeDropdown_=this.editorDom_=null},Blockly.DomainEditor.prototype.getParamID=function(){return this.options.paramID},Blockly.DomainEditor.prototype.render=function(e){var t=goog.dom.createDom("div"),o=new Blockly.TypeDropdown({onTypeChanged:this.options.onTypeChanged,typeChoices:this.options.typeChoices,type:this.options.type}),n=new Blockly.DomainNameInput({onNameChanged:this.options.onNameChanged,name:this.options.name}),i=new Blockly.XButton({onButtonPressed:this.options.onRemovePress});n.render(t),o.render(t),i.render(t),e.appendChild(t),this.editorDom_=t,this.typeDropdown_=o,this.nameInput_=n},Blockly.DomainEditor.prototype.dispose=function(){this.nameInput_.dispose(),this.typeDropdown_.dispose(),goog.dom.removeNode(this.editorDom_)},Blockly.CustomCssClassMenuRenderer=function(e){this.customCssClass_=e,Blockly.CustomCssClassMenuRenderer.superClass_.constructor.call(this)},goog.inherits(Blockly.CustomCssClassMenuRenderer,goog.ui.MenuRenderer),goog.addSingletonGetter(Blockly.CustomCssClassMenuRenderer),Blockly.CustomCssClassMenuRenderer.prototype.getCssClass=function(){return goog.ui.MenuRenderer.CSS_CLASS+" "+this.customCssClass_},goog.ui.ButtonSide={NONE:0,START:1,END:2,BOTH:3},goog.ui.ButtonRenderer=function(){goog.ui.ControlRenderer.call(this)},goog.inherits(goog.ui.ButtonRenderer,goog.ui.ControlRenderer),goog.addSingletonGetter(goog.ui.ButtonRenderer),goog.ui.ButtonRenderer.CSS_CLASS="goog-button",goog.ui.ButtonRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.BUTTON},goog.ui.ButtonRenderer.prototype.updateAriaState=function(e,t,o){switch(t){case goog.ui.Component.State.SELECTED:case goog.ui.Component.State.CHECKED:goog.asserts.assert(e,"The button DOM element cannot be null."),goog.a11y.aria.setState(e,goog.a11y.aria.State.PRESSED,o);break;default:case goog.ui.Component.State.OPENED:case goog.ui.Component.State.DISABLED:goog.ui.ButtonRenderer.superClass_.updateAriaState.call(this,e,t,o)}},goog.ui.ButtonRenderer.prototype.createDom=function(e){var t=goog.ui.ButtonRenderer.superClass_.createDom.call(this,e);this.setTooltip(t,e.getTooltip());var o=e.getValue();return o&&this.setValue(t,o),e.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(t,goog.ui.Component.State.CHECKED,e.isChecked()),t},goog.ui.ButtonRenderer.prototype.decorate=function(e,t){return t=goog.ui.ButtonRenderer.superClass_.decorate.call(this,e,t),e.setValueInternal(this.getValue(t)),e.setTooltipInternal(this.getTooltip(t)),e.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(t,goog.ui.Component.State.CHECKED,e.isChecked()),t},goog.ui.ButtonRenderer.prototype.getValue=goog.nullFunction,goog.ui.ButtonRenderer.prototype.setValue=goog.nullFunction,goog.ui.ButtonRenderer.prototype.getTooltip=function(e){return e.title},goog.ui.ButtonRenderer.prototype.setTooltip=function(e,t){e&&(t?e.title=t:e.removeAttribute("title"))},goog.ui.ButtonRenderer.prototype.setCollapsed=function(e,t){var o=e.isRightToLeft(),n=this.getStructuralCssClass()+"-collapse-left",i=this.getStructuralCssClass()+"-collapse-right";e.enableClassName(o?i:n,!!(t&goog.ui.ButtonSide.START)),e.enableClassName(o?n:i,!!(t&goog.ui.ButtonSide.END))},goog.ui.ButtonRenderer.prototype.getCssClass=function(){return goog.ui.ButtonRenderer.CSS_CLASS},goog.dom.InputType={BUTTON:"button",CHECKBOX:"checkbox",COLOR:"color",DATE:"date",DATETIME:"datetime",DATETIME_LOCAL:"datetime-local",EMAIL:"email",FILE:"file",HIDDEN:"hidden",IMAGE:"image",MENU:"menu",MONTH:"month",NUMBER:"number",PASSWORD:"password",RADIO:"radio",RANGE:"range",RESET:"reset",SEARCH:"search",SELECT_MULTIPLE:"select-multiple",SELECT_ONE:"select-one",SUBMIT:"submit",TEL:"tel",TEXT:"text",TEXTAREA:"textarea",TIME:"time",URL:"url",WEEK:"week"},goog.ui.NativeButtonRenderer=function(){goog.ui.ButtonRenderer.call(this)},goog.inherits(goog.ui.NativeButtonRenderer,goog.ui.ButtonRenderer),goog.addSingletonGetter(goog.ui.NativeButtonRenderer),goog.ui.NativeButtonRenderer.prototype.getAriaRole=function(){},goog.ui.NativeButtonRenderer.prototype.createDom=function(e){return this.setUpNativeButton_(e),e.getDomHelper().createDom("BUTTON",{class:this.getClassNames(e).join(" "),disabled:!e.isEnabled(),title:e.getTooltip()||"",value:e.getValue()||""},e.getCaption()||"")},goog.ui.NativeButtonRenderer.prototype.canDecorate=function(e){return"BUTTON"==e.tagName||"INPUT"==e.tagName&&(e.type==goog.dom.InputType.BUTTON||e.type==goog.dom.InputType.SUBMIT||e.type==goog.dom.InputType.RESET)},goog.ui.NativeButtonRenderer.prototype.decorate=function(e,t){if(this.setUpNativeButton_(e),t.disabled){var o=goog.asserts.assertString(this.getClassForState(goog.ui.Component.State.DISABLED));goog.dom.classlist.add(t,o)}return goog.ui.NativeButtonRenderer.superClass_.decorate.call(this,e,t)},goog.ui.NativeButtonRenderer.prototype.initializeDom=function(e){e.getHandler().listen(e.getElement(),goog.events.EventType.CLICK,e.performActionInternal)},goog.ui.NativeButtonRenderer.prototype.setAllowTextSelection=goog.nullFunction,goog.ui.NativeButtonRenderer.prototype.setRightToLeft=goog.nullFunction,goog.ui.NativeButtonRenderer.prototype.isFocusable=function(e){return e.isEnabled()},goog.ui.NativeButtonRenderer.prototype.setFocusable=goog.nullFunction,goog.ui.NativeButtonRenderer.prototype.setState=function(e,t,o){goog.ui.NativeButtonRenderer.superClass_.setState.call(this,e,t,o),(e=e.getElement())&&t==goog.ui.Component.State.DISABLED&&(e.disabled=o)},goog.ui.NativeButtonRenderer.prototype.getValue=function(e){return e.value},goog.ui.NativeButtonRenderer.prototype.setValue=function(e,t){e&&(e.value=t)},goog.ui.NativeButtonRenderer.prototype.updateAriaState=goog.nullFunction,goog.ui.NativeButtonRenderer.prototype.setUpNativeButton_=function(e){e.setHandleMouseEvents(!1),e.setAutoStates(goog.ui.Component.State.ALL,!1),e.setSupportedState(goog.ui.Component.State.FOCUSED,!1)},goog.ui.Button=function(e,t,o){goog.ui.Control.call(this,e,t||goog.ui.NativeButtonRenderer.getInstance(),o)},goog.inherits(goog.ui.Button,goog.ui.Control),goog.tagUnsealableClass(goog.ui.Button),goog.ui.Button.Side=goog.ui.ButtonSide,goog.ui.Button.prototype.getValue=function(){return this.value_},goog.ui.Button.prototype.setValue=function(e){this.value_=e,this.getRenderer().setValue(this.getElement(),e)},goog.ui.Button.prototype.setValueInternal=function(e){this.value_=e},goog.ui.Button.prototype.getTooltip=function(){return this.tooltip_},goog.ui.Button.prototype.setTooltip=function(e){this.tooltip_=e,this.getRenderer().setTooltip(this.getElement(),e)},goog.ui.Button.prototype.setTooltipInternal=function(e){this.tooltip_=e},goog.ui.Button.prototype.setCollapsed=function(e){this.getRenderer().setCollapsed(this,e)},goog.ui.Button.prototype.disposeInternal=function(){goog.ui.Button.superClass_.disposeInternal.call(this),delete this.value_,delete this.tooltip_},goog.ui.Button.prototype.enterDocument=function(){if(goog.ui.Button.superClass_.enterDocument.call(this),this.isSupportedState(goog.ui.Component.State.FOCUSED)){var e=this.getKeyEventTarget();e&&this.getHandler().listen(e,goog.events.EventType.KEYUP,this.handleKeyEventInternal)}},goog.ui.Button.prototype.handleKeyEventInternal=function(e){return e.keyCode==goog.events.KeyCodes.ENTER&&e.type==goog.events.KeyHandler.EventType.KEY||e.keyCode==goog.events.KeyCodes.SPACE&&e.type==goog.events.EventType.KEYUP?this.performActionInternal(e):e.keyCode==goog.events.KeyCodes.SPACE},goog.ui.registry.setDecoratorByClassName(goog.ui.ButtonRenderer.CSS_CLASS,function(){return new goog.ui.Button(null)}),goog.ui.INLINE_BLOCK_CLASSNAME="goog-inline-block",goog.ui.FlatButtonRenderer=function(){goog.ui.ButtonRenderer.call(this)},goog.inherits(goog.ui.FlatButtonRenderer,goog.ui.ButtonRenderer),goog.addSingletonGetter(goog.ui.FlatButtonRenderer),goog.ui.FlatButtonRenderer.CSS_CLASS="goog-flat-button",goog.ui.FlatButtonRenderer.prototype.createDom=function(e){var t=this.getClassNames(e);return t={class:goog.ui.INLINE_BLOCK_CLASSNAME+" "+t.join(" ")},t=e.getDomHelper().createDom("DIV",t,e.getContent()),this.setTooltip(t,e.getTooltip()),t},goog.ui.FlatButtonRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.BUTTON},goog.ui.FlatButtonRenderer.prototype.canDecorate=function(e){return"DIV"==e.tagName},goog.ui.FlatButtonRenderer.prototype.decorate=function(e,t){return goog.asserts.assert(t),goog.dom.classlist.add(t,goog.ui.INLINE_BLOCK_CLASSNAME),goog.ui.FlatButtonRenderer.superClass_.decorate.call(this,e,t)},goog.ui.FlatButtonRenderer.prototype.getValue=function(e){return""},goog.ui.FlatButtonRenderer.prototype.getCssClass=function(){return goog.ui.FlatButtonRenderer.CSS_CLASS},goog.ui.registry.setDecoratorByClassName(goog.ui.FlatButtonRenderer.CSS_CLASS,function(){return new goog.ui.Button(null,goog.ui.FlatButtonRenderer.getInstance())}),goog.style.bidi={},goog.style.bidi.getScrollLeft=function(e){var t=goog.style.isRightToLeft(e);return t&&goog.userAgent.GECKO?-e.scrollLeft:!t||goog.userAgent.EDGE_OR_IE&&goog.userAgent.isVersionOrHigher("8")||"visible"==goog.style.getComputedOverflowX(e)?e.scrollLeft:e.scrollWidth-e.clientWidth-e.scrollLeft},goog.style.bidi.getOffsetStart=function(e){var t=e.offsetLeft,o=e.offsetParent;if(o||"fixed"!=goog.style.getComputedPosition(e)||(o=goog.dom.getOwnerDocument(e).documentElement),!o)return t;if(goog.userAgent.GECKO){var n=goog.style.getBorderBox(o);t+=n.left}else goog.userAgent.isDocumentModeOrHigher(8)&&!goog.userAgent.isDocumentModeOrHigher(9)&&(t-=(n=goog.style.getBorderBox(o)).left);return goog.style.isRightToLeft(o)?o.clientWidth-(t+e.offsetWidth):t},goog.style.bidi.setScrollOffset=function(e,t){t=Math.max(t,0),goog.style.isRightToLeft(e)?goog.userAgent.GECKO?e.scrollLeft=-t:goog.userAgent.EDGE_OR_IE&&goog.userAgent.isVersionOrHigher("8")?e.scrollLeft=t:e.scrollLeft=e.scrollWidth-t-e.clientWidth:e.scrollLeft=t},goog.style.bidi.setPosition=function(e,t,o,n){goog.isNull(o)||(e.style.top=o+"px"),n?(e.style.right=t+"px",e.style.left=""):(e.style.left=t+"px",e.style.right="")},goog.positioning={},goog.positioning.CornerBit={BOTTOM:1,CENTER:2,RIGHT:4,FLIP_RTL:8},goog.positioning.Corner={TOP_LEFT:0,TOP_RIGHT:goog.positioning.CornerBit.RIGHT,BOTTOM_LEFT:goog.positioning.CornerBit.BOTTOM,BOTTOM_RIGHT:goog.positioning.CornerBit.BOTTOM|goog.positioning.CornerBit.RIGHT,TOP_START:goog.positioning.CornerBit.FLIP_RTL,TOP_END:goog.positioning.CornerBit.FLIP_RTL|goog.positioning.CornerBit.RIGHT,BOTTOM_START:goog.positioning.CornerBit.BOTTOM|goog.positioning.CornerBit.FLIP_RTL,BOTTOM_END:goog.positioning.CornerBit.BOTTOM|goog.positioning.CornerBit.RIGHT|goog.positioning.CornerBit.FLIP_RTL,TOP_CENTER:goog.positioning.CornerBit.CENTER,BOTTOM_CENTER:goog.positioning.CornerBit.BOTTOM|goog.positioning.CornerBit.CENTER},goog.positioning.Overflow={IGNORE:0,ADJUST_X:1,FAIL_X:2,ADJUST_Y:4,FAIL_Y:8,RESIZE_WIDTH:16,RESIZE_HEIGHT:32,ADJUST_X_EXCEPT_OFFSCREEN:65,ADJUST_Y_EXCEPT_OFFSCREEN:132},goog.positioning.OverflowStatus={NONE:0,ADJUSTED_X:1,ADJUSTED_Y:2,WIDTH_ADJUSTED:4,HEIGHT_ADJUSTED:8,FAILED_LEFT:16,FAILED_RIGHT:32,FAILED_TOP:64,FAILED_BOTTOM:128,FAILED_OUTSIDE_VIEWPORT:256},goog.positioning.OverflowStatus.FAILED=goog.positioning.OverflowStatus.FAILED_LEFT|goog.positioning.OverflowStatus.FAILED_RIGHT|goog.positioning.OverflowStatus.FAILED_TOP|goog.positioning.OverflowStatus.FAILED_BOTTOM|goog.positioning.OverflowStatus.FAILED_OUTSIDE_VIEWPORT,goog.positioning.OverflowStatus.FAILED_HORIZONTAL=goog.positioning.OverflowStatus.FAILED_LEFT|goog.positioning.OverflowStatus.FAILED_RIGHT,goog.positioning.OverflowStatus.FAILED_VERTICAL=goog.positioning.OverflowStatus.FAILED_TOP|goog.positioning.OverflowStatus.FAILED_BOTTOM,goog.positioning.positionAtAnchor=function(e,t,o,n,i,r,l,s,a){goog.asserts.assert(o);var g=goog.positioning.getOffsetParentPageOffset(o),c=goog.positioning.getVisiblePart_(e);if(goog.style.translateRectForAnotherFrame(c,goog.dom.getDomHelper(e),goog.dom.getDomHelper(o)),e=goog.positioning.getEffectiveCorner(e,t),t=c.left,e&goog.positioning.CornerBit.RIGHT?t+=c.width:e&goog.positioning.CornerBit.CENTER&&(t+=c.width/2),c=new goog.math.Coordinate(t,c.top+(e&goog.positioning.CornerBit.BOTTOM?c.height:0)),c=goog.math.Coordinate.difference(c,g),i&&(c.x+=(e&goog.positioning.CornerBit.RIGHT?-1:1)*i.x,c.y+=(e&goog.positioning.CornerBit.BOTTOM?-1:1)*i.y),l)if(a)var u=a;else(u=goog.style.getVisibleRectForElement(o))&&(u.top-=g.y,u.right-=g.x,u.bottom-=g.y,u.left-=g.x);return goog.positioning.positionAtCoordinate(c,o,n,r,u,l,s)},goog.positioning.getOffsetParentPageOffset=function(e){if(e=e.offsetParent){var t="HTML"==e.tagName||"BODY"==e.tagName;if(!t||"static"!=goog.style.getComputedPosition(e)){var o=goog.style.getPageOffset(e);t||(o=goog.math.Coordinate.difference(o,new goog.math.Coordinate(goog.style.bidi.getScrollLeft(e),e.scrollTop)))}}return o||new goog.math.Coordinate},goog.positioning.getVisiblePart_=function(e){var t=goog.style.getBounds(e);return(e=goog.style.getVisibleRectForElement(e))&&t.intersection(goog.math.Rect.createFromBox(e)),t},goog.positioning.positionAtCoordinate=function(e,t,o,n,i,r,l){e=e.clone();var s=goog.positioning.getEffectiveCorner(t,o);return o=goog.style.getSize(t),l=l?l.clone():o.clone(),(e=goog.positioning.getPositionAtCoordinate(e,l,s,n,i,r)).status&goog.positioning.OverflowStatus.FAILED?e.status:(goog.style.setPosition(t,e.rect.getTopLeft()),l=e.rect.getSize(),goog.math.Size.equals(o,l)||goog.style.setBorderBoxSize(t,l),e.status)},goog.positioning.getPositionAtCoordinate=function(e,t,o,n,i,r){e=e.clone(),t=t.clone();var l=goog.positioning.OverflowStatus.NONE;return(n||o!=goog.positioning.Corner.TOP_LEFT)&&(o&goog.positioning.CornerBit.RIGHT?e.x-=t.width+(n?n.right:0):o&goog.positioning.CornerBit.CENTER?e.x-=t.width/2:n&&(e.x+=n.left),o&goog.positioning.CornerBit.BOTTOM?e.y-=t.height+(n?n.bottom:0):n&&(e.y+=n.top)),r&&(l=i?goog.positioning.adjustForViewport_(e,t,i,r):goog.positioning.OverflowStatus.FAILED_OUTSIDE_VIEWPORT),(o=new goog.math.Rect(0,0,0,0)).left=e.x,o.top=e.y,o.width=t.width,o.height=t.height,{rect:o,status:l}},goog.positioning.adjustForViewport_=function(e,t,o,n){var i=goog.positioning.OverflowStatus.NONE,r=goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN,l=goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;return(n&r)==r&&(e.x<o.left||e.x>=o.right)&&(n&=~goog.positioning.Overflow.ADJUST_X),(n&l)==l&&(e.y<o.top||e.y>=o.bottom)&&(n&=~goog.positioning.Overflow.ADJUST_Y),e.x<o.left&&n&goog.positioning.Overflow.ADJUST_X&&(e.x=o.left,i|=goog.positioning.OverflowStatus.ADJUSTED_X),n&goog.positioning.Overflow.RESIZE_WIDTH&&(r=e.x,e.x<o.left&&(e.x=o.left,i|=goog.positioning.OverflowStatus.WIDTH_ADJUSTED),e.x+t.width>o.right&&(t.width=Math.min(o.right-e.x,r+t.width-o.left),t.width=Math.max(t.width,0),i|=goog.positioning.OverflowStatus.WIDTH_ADJUSTED)),e.x+t.width>o.right&&n&goog.positioning.Overflow.ADJUST_X&&(e.x=Math.max(o.right-t.width,o.left),i|=goog.positioning.OverflowStatus.ADJUSTED_X),n&goog.positioning.Overflow.FAIL_X&&(i|=(e.x<o.left?goog.positioning.OverflowStatus.FAILED_LEFT:0)|(e.x+t.width>o.right?goog.positioning.OverflowStatus.FAILED_RIGHT:0)),e.y<o.top&&n&goog.positioning.Overflow.ADJUST_Y&&(e.y=o.top,i|=goog.positioning.OverflowStatus.ADJUSTED_Y),n&goog.positioning.Overflow.RESIZE_HEIGHT&&(r=e.y,e.y<o.top&&(e.y=o.top,i|=goog.positioning.OverflowStatus.HEIGHT_ADJUSTED),e.y+t.height>o.bottom&&(t.height=Math.min(o.bottom-e.y,r+t.height-o.top),t.height=Math.max(t.height,0),i|=goog.positioning.OverflowStatus.HEIGHT_ADJUSTED)),e.y+t.height>o.bottom&&n&goog.positioning.Overflow.ADJUST_Y&&(e.y=Math.max(o.bottom-t.height,o.top),i|=goog.positioning.OverflowStatus.ADJUSTED_Y),n&goog.positioning.Overflow.FAIL_Y&&(i|=(e.y<o.top?goog.positioning.OverflowStatus.FAILED_TOP:0)|(e.y+t.height>o.bottom?goog.positioning.OverflowStatus.FAILED_BOTTOM:0)),i},goog.positioning.getEffectiveCorner=function(e,t){return(t&goog.positioning.CornerBit.FLIP_RTL&&goog.style.isRightToLeft(e)?t^goog.positioning.CornerBit.RIGHT:t)&~goog.positioning.CornerBit.FLIP_RTL},goog.positioning.flipCornerHorizontal=function(e){return e^goog.positioning.CornerBit.RIGHT},goog.positioning.flipCornerVertical=function(e){return e^goog.positioning.CornerBit.BOTTOM},goog.positioning.flipCorner=function(e){return e^goog.positioning.CornerBit.BOTTOM^goog.positioning.CornerBit.RIGHT},goog.positioning.AbstractPosition=function(){},goog.positioning.AbstractPosition.prototype.reposition=function(e,t,o,n){},goog.positioning.AnchoredPosition=function(e,t,o){this.element=e,this.corner=t,this.overflow_=o},goog.inherits(goog.positioning.AnchoredPosition,goog.positioning.AbstractPosition),goog.positioning.AnchoredPosition.prototype.reposition=function(e,t,o,n){goog.positioning.positionAtAnchor(this.element,this.corner,e,t,void 0,o,this.overflow_)},goog.positioning.AnchoredViewportPosition=function(e,t,o,n){goog.positioning.AnchoredPosition.call(this,e,t),this.lastResortOverflow_=o?goog.positioning.Overflow.ADJUST_X|goog.positioning.Overflow.ADJUST_Y:goog.positioning.Overflow.IGNORE,this.overflowConstraint_=n||void 0},goog.inherits(goog.positioning.AnchoredViewportPosition,goog.positioning.AnchoredPosition),goog.positioning.AnchoredViewportPosition.prototype.getOverflowConstraint=function(){return this.overflowConstraint_},goog.positioning.AnchoredViewportPosition.prototype.setOverflowConstraint=function(e){this.overflowConstraint_=e},goog.positioning.AnchoredViewportPosition.prototype.getLastResortOverflow=function(){return this.lastResortOverflow_},goog.positioning.AnchoredViewportPosition.prototype.setLastResortOverflow=function(e){this.lastResortOverflow_=e},goog.positioning.AnchoredViewportPosition.prototype.reposition=function(e,t,o,n){var i=goog.positioning.positionAtAnchor(this.element,this.corner,e,t,null,o,goog.positioning.Overflow.FAIL_X|goog.positioning.Overflow.FAIL_Y,n,this.overflowConstraint_);if(i&goog.positioning.OverflowStatus.FAILED){var r=this.adjustCorner(i,this.corner);t=this.adjustCorner(i,t),(i=goog.positioning.positionAtAnchor(this.element,r,e,t,null,o,goog.positioning.Overflow.FAIL_X|goog.positioning.Overflow.FAIL_Y,n,this.overflowConstraint_))&goog.positioning.OverflowStatus.FAILED&&(r=this.adjustCorner(i,r),t=this.adjustCorner(i,t),goog.positioning.positionAtAnchor(this.element,r,e,t,null,o,this.getLastResortOverflow(),n,this.overflowConstraint_))}},goog.positioning.AnchoredViewportPosition.prototype.adjustCorner=function(e,t){return e&goog.positioning.OverflowStatus.FAILED_HORIZONTAL&&(t=goog.positioning.flipCornerHorizontal(t)),e&goog.positioning.OverflowStatus.FAILED_VERTICAL&&(t=goog.positioning.flipCornerVertical(t)),t},goog.positioning.MenuAnchoredPosition=function(e,t,o,n){goog.positioning.AnchoredViewportPosition.call(this,e,t,o||n),(o||n)&&this.setLastResortOverflow(goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN|(n?goog.positioning.Overflow.RESIZE_HEIGHT:goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN))},goog.inherits(goog.positioning.MenuAnchoredPosition,goog.positioning.AnchoredViewportPosition),goog.ui.CustomButtonRenderer=function(){goog.ui.ButtonRenderer.call(this)},goog.inherits(goog.ui.CustomButtonRenderer,goog.ui.ButtonRenderer),goog.addSingletonGetter(goog.ui.CustomButtonRenderer),goog.ui.CustomButtonRenderer.CSS_CLASS="goog-custom-button",goog.ui.CustomButtonRenderer.prototype.createDom=function(e){var t=this.getClassNames(e);return t={class:goog.ui.INLINE_BLOCK_CLASSNAME+" "+t.join(" ")},t=e.getDomHelper().createDom("DIV",t,this.createButton(e.getContent(),e.getDomHelper())),this.setTooltip(t,e.getTooltip()),t},goog.ui.CustomButtonRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.BUTTON},goog.ui.CustomButtonRenderer.prototype.getContentElement=function(e){return e&&e.firstChild&&e.firstChild.firstChild},goog.ui.CustomButtonRenderer.prototype.createButton=function(e,t){return t.createDom("DIV",goog.ui.INLINE_BLOCK_CLASSNAME+" "+this.getCssClass()+"-outer-box",t.createDom("DIV",goog.ui.INLINE_BLOCK_CLASSNAME+" "+this.getCssClass()+"-inner-box",e))},goog.ui.CustomButtonRenderer.prototype.canDecorate=function(e){return"DIV"==e.tagName},goog.ui.CustomButtonRenderer.prototype.hasBoxStructure=function(e,t){t=e.getDomHelper().getFirstElementChild(t);var o=this.getCssClass()+"-outer-box";return!!(t&&goog.dom.classlist.contains(t,o)&&(e=e.getDomHelper().getFirstElementChild(t),t=this.getCssClass()+"-inner-box",e&&goog.dom.classlist.contains(e,t)))},goog.ui.CustomButtonRenderer.prototype.decorate=function(e,t){return goog.asserts.assert(t),goog.ui.CustomButtonRenderer.trimTextNodes_(t,!0),goog.ui.CustomButtonRenderer.trimTextNodes_(t,!1),this.hasBoxStructure(e,t)||t.appendChild(this.createButton(t.childNodes,e.getDomHelper())),goog.dom.classlist.addAll(t,[goog.ui.INLINE_BLOCK_CLASSNAME,this.getCssClass()]),goog.ui.CustomButtonRenderer.superClass_.decorate.call(this,e,t)},goog.ui.CustomButtonRenderer.prototype.getCssClass=function(){return goog.ui.CustomButtonRenderer.CSS_CLASS},goog.ui.CustomButtonRenderer.trimTextNodes_=function(e,t){if(e)for(var o,n=t?e.firstChild:e.lastChild;n&&n.parentNode==e&&(o=t?n.nextSibling:n.previousSibling,n.nodeType==goog.dom.NodeType.TEXT);){var i=n.nodeValue;if(""!=goog.string.trim(i)){n.nodeValue=t?goog.string.trimLeft(i):goog.string.trimRight(i);break}e.removeChild(n),n=o}},goog.ui.MenuButtonRenderer=function(){goog.ui.CustomButtonRenderer.call(this)},goog.inherits(goog.ui.MenuButtonRenderer,goog.ui.CustomButtonRenderer),goog.addSingletonGetter(goog.ui.MenuButtonRenderer),goog.ui.MenuButtonRenderer.CSS_CLASS="goog-menu-button",goog.ui.MenuButtonRenderer.prototype.getContentElement=function(e){return goog.ui.MenuButtonRenderer.superClass_.getContentElement.call(this,e&&e.firstChild)},goog.ui.MenuButtonRenderer.prototype.decorate=function(e,t){var o=goog.dom.getElementsByTagNameAndClass("*",goog.ui.MenuRenderer.CSS_CLASS,t)[0];if(o){goog.style.setElementShown(o,!1),goog.dom.appendChild(goog.dom.getOwnerDocument(o).body,o);var n=new goog.ui.Menu;n.decorate(o),e.setMenu(n)}return goog.ui.MenuButtonRenderer.superClass_.decorate.call(this,e,t)},goog.ui.MenuButtonRenderer.prototype.createButton=function(e,t){return goog.ui.MenuButtonRenderer.superClass_.createButton.call(this,[this.createCaption(e,t),this.createDropdown(t)],t)},goog.ui.MenuButtonRenderer.prototype.createCaption=function(e,t){return goog.ui.MenuButtonRenderer.wrapCaption(e,this.getCssClass(),t)},goog.ui.MenuButtonRenderer.wrapCaption=function(e,t,o){return o.createDom("DIV",goog.ui.INLINE_BLOCK_CLASSNAME+" "+t+"-caption",e)},goog.ui.MenuButtonRenderer.prototype.createDropdown=function(e){return e.createDom("DIV",goog.ui.INLINE_BLOCK_CLASSNAME+" "+this.getCssClass()+"-dropdown"," ")},goog.ui.MenuButtonRenderer.prototype.getCssClass=function(){return goog.ui.MenuButtonRenderer.CSS_CLASS},goog.userAgent.product={},goog.userAgent.product.ASSUME_FIREFOX=!1,goog.userAgent.product.ASSUME_IPHONE=!1,goog.userAgent.product.ASSUME_IPAD=!1,goog.userAgent.product.ASSUME_ANDROID=!1,goog.userAgent.product.ASSUME_CHROME=!1,goog.userAgent.product.ASSUME_SAFARI=!1,goog.userAgent.product.PRODUCT_KNOWN_=goog.userAgent.ASSUME_IE||goog.userAgent.ASSUME_EDGE||goog.userAgent.ASSUME_OPERA||goog.userAgent.product.ASSUME_FIREFOX||goog.userAgent.product.ASSUME_IPHONE||goog.userAgent.product.ASSUME_IPAD||goog.userAgent.product.ASSUME_ANDROID||goog.userAgent.product.ASSUME_CHROME||goog.userAgent.product.ASSUME_SAFARI,goog.userAgent.product.OPERA=goog.userAgent.OPERA,goog.userAgent.product.IE=goog.userAgent.IE,goog.userAgent.product.EDGE=goog.userAgent.EDGE,goog.userAgent.product.FIREFOX=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_FIREFOX:goog.labs.userAgent.browser.isFirefox(),goog.userAgent.product.isIphoneOrIpod_=function(){return goog.labs.userAgent.platform.isIphone()||goog.labs.userAgent.platform.isIpod()},goog.userAgent.product.IPHONE=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_IPHONE:goog.userAgent.product.isIphoneOrIpod_(),goog.userAgent.product.IPAD=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_IPAD:goog.labs.userAgent.platform.isIpad(),goog.userAgent.product.ANDROID=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_ANDROID:goog.labs.userAgent.browser.isAndroidBrowser(),goog.userAgent.product.CHROME=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_CHROME:goog.labs.userAgent.browser.isChrome(),goog.userAgent.product.isSafariDesktop_=function(){return goog.labs.userAgent.browser.isSafari()&&!goog.labs.userAgent.platform.isIos()},goog.userAgent.product.SAFARI=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_SAFARI:goog.userAgent.product.isSafariDesktop_(),goog.ui.MenuButton=function(e,t,o,n,i){goog.ui.Button.call(this,e,o||goog.ui.MenuButtonRenderer.getInstance(),n),this.setSupportedState(goog.ui.Component.State.OPENED,!0),this.menuPosition_=new goog.positioning.MenuAnchoredPosition(null,goog.positioning.Corner.BOTTOM_START),t&&this.setMenu(t),this.menuMargin_=null,this.timer_=new goog.Timer(500),!goog.userAgent.product.IPHONE&&!goog.userAgent.product.IPAD||goog.userAgent.isVersionOrHigher("533.17.9")||this.setFocusablePopupMenu(!0),this.menuRenderer_=i||goog.ui.MenuRenderer.getInstance()},goog.inherits(goog.ui.MenuButton,goog.ui.Button),goog.tagUnsealableClass(goog.ui.MenuButton),goog.ui.MenuButton.prototype.isFocusablePopupMenu_=!1,goog.ui.MenuButton.prototype.renderMenuAsSibling_=!1,goog.ui.MenuButton.prototype.selectFirstOnEnterOrSpace_=!1,goog.ui.MenuButton.prototype.enterDocument=function(){goog.ui.MenuButton.superClass_.enterDocument.call(this),this.attachKeyDownEventListener_(!0),this.menu_&&this.attachMenuEventListeners_(this.menu_,!0),goog.a11y.aria.setState(this.getElementStrict(),goog.a11y.aria.State.HASPOPUP,!!this.menu_)},goog.ui.MenuButton.prototype.exitDocument=function(){if(goog.ui.MenuButton.superClass_.exitDocument.call(this),this.attachKeyDownEventListener_(!1),this.menu_){this.setOpen(!1),this.menu_.exitDocument(),this.attachMenuEventListeners_(this.menu_,!1);var e=this.menu_.getElement();e&&goog.dom.removeNode(e)}},goog.ui.MenuButton.prototype.disposeInternal=function(){goog.ui.MenuButton.superClass_.disposeInternal.call(this),this.menu_&&(this.menu_.dispose(),delete this.menu_),delete this.positionElement_,this.timer_.dispose()},goog.ui.MenuButton.prototype.handleMouseDown=function(e){goog.ui.MenuButton.superClass_.handleMouseDown.call(this,e),this.isActive()&&(this.setOpen(!this.isOpen(),e),this.menu_&&this.menu_.setMouseButtonPressed(this.isOpen()))},goog.ui.MenuButton.prototype.handleMouseUp=function(e){goog.ui.MenuButton.superClass_.handleMouseUp.call(this,e),this.menu_&&!this.isActive()&&this.menu_.setMouseButtonPressed(!1)},goog.ui.MenuButton.prototype.performActionInternal=function(e){return this.setActive(!1),!0},goog.ui.MenuButton.prototype.handleDocumentMouseDown=function(e){this.menu_&&this.menu_.isVisible()&&!this.containsElement(e.target)&&this.setOpen(!1)},goog.ui.MenuButton.prototype.containsElement=function(e){return e&&goog.dom.contains(this.getElement(),e)||this.menu_&&this.menu_.containsElement(e)||!1},goog.ui.MenuButton.prototype.handleKeyEventInternal=function(e){if(e.keyCode==goog.events.KeyCodes.SPACE){if(e.preventDefault(),e.type!=goog.events.EventType.KEYUP)return!0}else if(e.type!=goog.events.KeyHandler.EventType.KEY)return!1;if(this.menu_&&this.menu_.isVisible()){var t=e.keyCode==goog.events.KeyCodes.ENTER||e.keyCode==goog.events.KeyCodes.SPACE,o=this.menu_.handleKeyEvent(e);return e.keyCode==goog.events.KeyCodes.ESC||t?(this.setOpen(!1),!0):o}return(e.keyCode==goog.events.KeyCodes.DOWN||e.keyCode==goog.events.KeyCodes.UP||e.keyCode==goog.events.KeyCodes.SPACE||e.keyCode==goog.events.KeyCodes.ENTER)&&(this.setOpen(!0,e),!0)},goog.ui.MenuButton.prototype.handleMenuAction=function(e){this.setOpen(!1)},goog.ui.MenuButton.prototype.handleMenuBlur=function(e){this.isActive()||this.setOpen(!1)},goog.ui.MenuButton.prototype.handleBlur=function(e){this.isFocusablePopupMenu()||this.setOpen(!1),goog.ui.MenuButton.superClass_.handleBlur.call(this,e)},goog.ui.MenuButton.prototype.getMenu=function(){return this.menu_||this.setMenu(new goog.ui.Menu(this.getDomHelper(),this.menuRenderer_)),this.menu_||null},goog.ui.MenuButton.prototype.setMenu=function(e){var t=this.menu_;return e!=t&&(t&&(this.setOpen(!1),this.isInDocument()&&this.attachMenuEventListeners_(t,!1),delete this.menu_),this.isInDocument()&&goog.a11y.aria.setState(this.getElementStrict(),goog.a11y.aria.State.HASPOPUP,!!e),e&&(this.menu_=e,e.setParent(this),e.setVisible(!1),e.setAllowAutoFocus(this.isFocusablePopupMenu()),this.isInDocument()&&this.attachMenuEventListeners_(e,!0))),t},goog.ui.MenuButton.prototype.setMenuPosition=function(e){e&&(this.menuPosition_=e,this.positionElement_=e.element)},goog.ui.MenuButton.prototype.setPositionElement=function(e){this.positionElement_=e,this.positionMenu()},goog.ui.MenuButton.prototype.setMenuMargin=function(e){this.menuMargin_=e},goog.ui.MenuButton.prototype.setSelectFirstOnEnterOrSpace=function(e){this.selectFirstOnEnterOrSpace_=e},goog.ui.MenuButton.prototype.addItem=function(e){this.getMenu().addChild(e,!0)},goog.ui.MenuButton.prototype.addItemAt=function(e,t){this.getMenu().addChildAt(e,t,!0)},goog.ui.MenuButton.prototype.removeItem=function(e){(e=this.getMenu().removeChild(e,!0))&&e.dispose()},goog.ui.MenuButton.prototype.removeItemAt=function(e){(e=this.getMenu().removeChildAt(e,!0))&&e.dispose()},goog.ui.MenuButton.prototype.getItemAt=function(e){return this.menu_?this.menu_.getChildAt(e):null},goog.ui.MenuButton.prototype.getItemCount=function(){return this.menu_?this.menu_.getChildCount():0},goog.ui.MenuButton.prototype.setVisible=function(e,t){return(e=goog.ui.MenuButton.superClass_.setVisible.call(this,e,t))&&!this.isVisible()&&this.setOpen(!1),e},goog.ui.MenuButton.prototype.setEnabled=function(e){goog.ui.MenuButton.superClass_.setEnabled.call(this,e),this.isEnabled()||this.setOpen(!1)},goog.ui.MenuButton.prototype.isAlignMenuToStart=function(){var e=this.menuPosition_.corner;return e==goog.positioning.Corner.BOTTOM_START||e==goog.positioning.Corner.TOP_START},goog.ui.MenuButton.prototype.setAlignMenuToStart=function(e){this.menuPosition_.corner=e?goog.positioning.Corner.BOTTOM_START:goog.positioning.Corner.BOTTOM_END},goog.ui.MenuButton.prototype.setScrollOnOverflow=function(e){this.menuPosition_.setLastResortOverflow&&this.menuPosition_.setLastResortOverflow(goog.positioning.Overflow.ADJUST_X|(e?goog.positioning.Overflow.RESIZE_HEIGHT:goog.positioning.Overflow.ADJUST_Y))},goog.ui.MenuButton.prototype.isScrollOnOverflow=function(){return this.menuPosition_.getLastResortOverflow&&!!(this.menuPosition_.getLastResortOverflow()&goog.positioning.Overflow.RESIZE_HEIGHT)},goog.ui.MenuButton.prototype.isFocusablePopupMenu=function(){return this.isFocusablePopupMenu_},goog.ui.MenuButton.prototype.setFocusablePopupMenu=function(e){this.isFocusablePopupMenu_=e},goog.ui.MenuButton.prototype.setRenderMenuAsSibling=function(e){this.renderMenuAsSibling_=e},goog.ui.MenuButton.prototype.showMenu=function(){this.setOpen(!0)},goog.ui.MenuButton.prototype.hideMenu=function(){this.setOpen(!1)},goog.ui.MenuButton.prototype.setOpen=function(e,t){if(goog.ui.MenuButton.superClass_.setOpen.call(this,e),this.menu_&&this.hasState(goog.ui.Component.State.OPENED)==e){if(e){if(!this.menu_.isInDocument())if(this.renderMenuAsSibling_){var o=goog.dom.getNextElementSibling(this.getElement());o?this.menu_.renderBefore(o):this.menu_.render(this.getElement().parentNode)}else this.menu_.render();this.viewportBox_=goog.style.getVisibleRectForElement(this.getElement()),this.buttonRect_=goog.style.getBounds(this.getElement()),this.positionMenu(),o=!!t&&(t.keyCode==goog.events.KeyCodes.ENTER||t.keyCode==goog.events.KeyCodes.SPACE),t&&(t.keyCode==goog.events.KeyCodes.DOWN||t.keyCode==goog.events.KeyCodes.UP)||o&&this.selectFirstOnEnterOrSpace_?this.menu_.highlightFirst():this.menu_.setHighlightedIndex(-1)}else this.setActive(!1),this.menu_.setMouseButtonPressed(!1),(o=this.getElement())&&(goog.a11y.aria.setState(o,goog.a11y.aria.State.ACTIVEDESCENDANT,""),goog.a11y.aria.setState(o,goog.a11y.aria.State.OWNS,"")),goog.isDefAndNotNull(this.originalSize_)&&(this.originalSize_=void 0,(o=this.menu_.getElement())&&goog.style.setSize(o,"",""));this.menu_.setVisible(e,!1,t),this.isDisposed()||this.attachPopupListeners_(e)}this.menu_&&this.menu_.getElement()&&goog.a11y.aria.removeState(this.menu_.getElementStrict(),goog.a11y.aria.State.HIDDEN)},goog.ui.MenuButton.prototype.invalidateMenuSize=function(){this.originalSize_=void 0},goog.ui.MenuButton.prototype.positionMenu=function(){if(this.menu_.isInDocument()){var e=this.positionElement_||this.getElement(),t=this.menuPosition_;this.menuPosition_.element=e,e=this.menu_.getElement(),this.menu_.isVisible()||(e.style.visibility="hidden",goog.style.setElementShown(e,!0)),!this.originalSize_&&this.isScrollOnOverflow()&&(this.originalSize_=goog.style.getSize(e));var o=goog.positioning.flipCornerVertical(t.corner);t.reposition(e,o,this.menuMargin_,this.originalSize_),this.menu_.isVisible()||(goog.style.setElementShown(e,!1),e.style.visibility="visible")}},goog.ui.MenuButton.prototype.onTick_=function(e){e=goog.style.getBounds(this.getElement());var t=goog.style.getVisibleRectForElement(this.getElement());goog.math.Rect.equals(this.buttonRect_,e)&&goog.math.Box.equals(this.viewportBox_,t)||(this.buttonRect_=e,this.viewportBox_=t,this.positionMenu())},goog.ui.MenuButton.prototype.attachMenuEventListeners_=function(e,t){var o=this.getHandler();(t=t?o.listen:o.unlisten).call(o,e,goog.ui.Component.EventType.ACTION,this.handleMenuAction),t.call(o,e,goog.ui.Component.EventType.CLOSE,this.handleCloseItem),t.call(o,e,goog.ui.Component.EventType.HIGHLIGHT,this.handleHighlightItem),t.call(o,e,goog.ui.Component.EventType.UNHIGHLIGHT,this.handleUnHighlightItem)},goog.ui.MenuButton.prototype.attachKeyDownEventListener_=function(e){var t=this.getHandler();(e?t.listen:t.unlisten).call(t,this.getElement(),goog.events.EventType.KEYDOWN,this.handleKeyDownEvent_)},goog.ui.MenuButton.prototype.handleHighlightItem=function(e){(e=e.target.getElement())&&this.setAriaActiveDescendant_(e)},goog.ui.MenuButton.prototype.handleKeyDownEvent_=function(e){this.isSupportedState(goog.ui.Component.State.FOCUSED)&&this.getKeyEventTarget()&&this.menu_&&this.menu_.isVisible()&&e.stopPropagation()},goog.ui.MenuButton.prototype.handleUnHighlightItem=function(e){this.menu_.getHighlighted()||(e=this.getElement(),goog.asserts.assert(e,"The menu button DOM element cannot be null."),goog.a11y.aria.setState(e,goog.a11y.aria.State.ACTIVEDESCENDANT,""),goog.a11y.aria.setState(e,goog.a11y.aria.State.OWNS,""))},goog.ui.MenuButton.prototype.handleCloseItem=function(e){if(this.isOpen()&&e.target instanceof goog.ui.MenuItem){var t=(e=e.target).getElement();e.isVisible()&&e.isHighlighted()&&null!=t&&this.setAriaActiveDescendant_(t)}},goog.ui.MenuButton.prototype.setAriaActiveDescendant_=function(e){var t=this.getElement();if(goog.asserts.assert(t,"The menu button DOM element cannot be null."),!(e=goog.a11y.aria.getActiveDescendant(e)||e).id){var o=goog.ui.IdGenerator.getInstance();e.id=o.getNextUniqueId()}goog.a11y.aria.setActiveDescendant(t,e),goog.a11y.aria.setState(t,goog.a11y.aria.State.OWNS,e.id)},goog.ui.MenuButton.prototype.attachPopupListeners_=function(e){var t=this.getHandler(),o=e?t.listen:t.unlisten;o.call(t,this.getDomHelper().getDocument(),goog.events.EventType.MOUSEDOWN,this.handleDocumentMouseDown,!0),this.isFocusablePopupMenu()&&o.call(t,this.menu_,goog.ui.Component.EventType.BLUR,this.handleMenuBlur),o.call(t,this.timer_,goog.Timer.TICK,this.onTick_),e?this.timer_.start():this.timer_.stop()},goog.ui.registry.setDecoratorByClassName(goog.ui.MenuButtonRenderer.CSS_CLASS,function(){return new goog.ui.MenuButton(null)}),goog.ui.FlatMenuButtonRenderer=function(){goog.ui.FlatButtonRenderer.call(this)},goog.inherits(goog.ui.FlatMenuButtonRenderer,goog.ui.FlatButtonRenderer),goog.addSingletonGetter(goog.ui.FlatMenuButtonRenderer),goog.ui.FlatMenuButtonRenderer.CSS_CLASS="goog-flat-menu-button",goog.ui.FlatMenuButtonRenderer.prototype.createDom=function(e){var t=this.getClassNames(e);return t={class:goog.ui.INLINE_BLOCK_CLASSNAME+" "+t.join(" ")},t=e.getDomHelper().createDom("DIV",t,[this.createCaption(e.getContent(),e.getDomHelper()),this.createDropdown(e.getDomHelper())]),this.setTooltip(t,e.getTooltip()),t},goog.ui.FlatMenuButtonRenderer.prototype.getContentElement=function(e){return e&&e.firstChild},goog.ui.FlatMenuButtonRenderer.prototype.decorate=function(e,t){var o=goog.dom.getElementsByTagNameAndClass("*",goog.ui.MenuRenderer.CSS_CLASS,t)[0];if(o){goog.style.setElementShown(o,!1),e.getDomHelper().getDocument().body.appendChild(o);var n=new goog.ui.Menu;n.decorate(o),e.setMenu(n)}return goog.dom.getElementsByTagNameAndClass("*",this.getCssClass()+"-caption",t)[0]||t.appendChild(this.createCaption(t.childNodes,e.getDomHelper())),goog.dom.getElementsByTagNameAndClass("*",this.getCssClass()+"-dropdown",t)[0]||t.appendChild(this.createDropdown(e.getDomHelper())),goog.ui.FlatMenuButtonRenderer.superClass_.decorate.call(this,e,t)},goog.ui.FlatMenuButtonRenderer.prototype.createCaption=function(e,t){return t.createDom("DIV",goog.ui.INLINE_BLOCK_CLASSNAME+" "+this.getCssClass()+"-caption",e)},goog.ui.FlatMenuButtonRenderer.prototype.createDropdown=function(e){return e.createDom("DIV",{class:goog.ui.INLINE_BLOCK_CLASSNAME+" "+this.getCssClass()+"-dropdown","aria-hidden":!0}," ")},goog.ui.FlatMenuButtonRenderer.prototype.getCssClass=function(){return goog.ui.FlatMenuButtonRenderer.CSS_CLASS},goog.ui.registry.setDecoratorByClassName(goog.ui.FlatMenuButtonRenderer.CSS_CLASS,function(){return new goog.ui.MenuButton(null,null,goog.ui.FlatMenuButtonRenderer.getInstance())}),goog.ui.Option=function(e,t,o){goog.ui.MenuItem.call(this,e,t,o),this.setSelectable(!0)},goog.inherits(goog.ui.Option,goog.ui.MenuItem),goog.ui.Option.prototype.performActionInternal=function(e){return this.dispatchEvent(goog.ui.Component.EventType.ACTION)},goog.ui.registry.setDecoratorByClassName("goog-option",function(){return new goog.ui.Option(null)}),goog.ui.Select=function(e,t,o,n,i){goog.ui.MenuButton.call(this,e,t,o,n,i||new goog.ui.MenuRenderer(goog.a11y.aria.Role.LISTBOX)),this.defaultCaption_=this.getContent(),this.initialAriaLabel_=null,this.setPreferredAriaRole(goog.a11y.aria.Role.LISTBOX)},goog.inherits(goog.ui.Select,goog.ui.MenuButton),goog.tagUnsealableClass(goog.ui.Select),goog.ui.Select.prototype.selectionModel_=null,goog.ui.Select.prototype.enterDocument=function(){goog.ui.Select.superClass_.enterDocument.call(this),this.updateCaption(),this.listenToSelectionModelEvents_()},goog.ui.Select.prototype.decorateInternal=function(e){goog.ui.Select.superClass_.decorateInternal.call(this,e),(e=this.getCaption())?this.setDefaultCaption(e):this.getSelectedItem()||this.setSelectedIndex(0)},goog.ui.Select.prototype.disposeInternal=function(){goog.ui.Select.superClass_.disposeInternal.call(this),this.selectionModel_&&(this.selectionModel_.dispose(),this.selectionModel_=null),this.defaultCaption_=null},goog.ui.Select.prototype.handleMenuAction=function(e){this.setSelectedItem(e.target),goog.ui.Select.superClass_.handleMenuAction.call(this,e),e.stopPropagation(),this.dispatchEvent(goog.ui.Component.EventType.ACTION)},goog.ui.Select.prototype.handleSelectionChange=function(e){e=this.getSelectedItem(),goog.ui.Select.superClass_.setValue.call(this,e&&e.getValue()),this.updateCaption()},goog.ui.Select.prototype.setMenu=function(e){var t=goog.ui.Select.superClass_.setMenu.call(this,e);return e!=t&&(this.selectionModel_&&this.selectionModel_.clear(),e&&(this.selectionModel_?e.forEachChild(function(e,t){this.setCorrectAriaRole_(e),this.selectionModel_.addItem(e)},this):this.createSelectionModel_(e))),t},goog.ui.Select.prototype.getDefaultCaption=function(){return this.defaultCaption_},goog.ui.Select.prototype.setDefaultCaption=function(e){this.defaultCaption_=e,this.updateCaption()},goog.ui.Select.prototype.addItem=function(e){this.setCorrectAriaRole_(e),goog.ui.Select.superClass_.addItem.call(this,e),this.selectionModel_?this.selectionModel_.addItem(e):this.createSelectionModel_(this.getMenu()),this.updateAriaActiveDescendant_()},goog.ui.Select.prototype.addItemAt=function(e,t){this.setCorrectAriaRole_(e),goog.ui.Select.superClass_.addItemAt.call(this,e,t),this.selectionModel_?this.selectionModel_.addItemAt(e,t):this.createSelectionModel_(this.getMenu())},goog.ui.Select.prototype.removeItem=function(e){goog.ui.Select.superClass_.removeItem.call(this,e),this.selectionModel_&&this.selectionModel_.removeItem(e)},goog.ui.Select.prototype.removeItemAt=function(e){goog.ui.Select.superClass_.removeItemAt.call(this,e),this.selectionModel_&&this.selectionModel_.removeItemAt(e)},goog.ui.Select.prototype.setSelectedItem=function(e){if(this.selectionModel_){var t=this.getSelectedItem();this.selectionModel_.setSelectedItem(e),e!=t&&this.dispatchEvent(goog.ui.Component.EventType.CHANGE)}},goog.ui.Select.prototype.setSelectedIndex=function(e){this.selectionModel_&&this.setSelectedItem(this.selectionModel_.getItemAt(e))},goog.ui.Select.prototype.setValue=function(e){if(goog.isDefAndNotNull(e)&&this.selectionModel_)for(var t,o=0;t=this.selectionModel_.getItemAt(o);o++)if(t&&"function"==typeof t.getValue&&t.getValue()==e)return void this.setSelectedItem(t);this.setSelectedItem(null)},goog.ui.Select.prototype.getValue=function(){var e=this.getSelectedItem();return e?e.getValue():null},goog.ui.Select.prototype.getSelectedItem=function(){return this.selectionModel_?this.selectionModel_.getSelectedItem():null},goog.ui.Select.prototype.getSelectedIndex=function(){return this.selectionModel_?this.selectionModel_.getSelectedIndex():-1},goog.ui.Select.prototype.getSelectionModel=function(){return this.selectionModel_},goog.ui.Select.prototype.createSelectionModel_=function(e){this.selectionModel_=new goog.ui.SelectionModel,e&&e.forEachChild(function(e,t){this.setCorrectAriaRole_(e),this.selectionModel_.addItem(e)},this),this.listenToSelectionModelEvents_()},goog.ui.Select.prototype.listenToSelectionModelEvents_=function(){this.selectionModel_&&this.getHandler().listen(this.selectionModel_,goog.events.EventType.SELECT,this.handleSelectionChange)},goog.ui.Select.prototype.updateCaption=function(){var e=this.getSelectedItem();this.setContent(e?e.getCaption():this.defaultCaption_);var t=this.getRenderer().getContentElement(this.getElement());t&&this.getDomHelper().isElement(t)&&(null==this.initialAriaLabel_&&(this.initialAriaLabel_=goog.a11y.aria.getLabel(t)),e=e?e.getElement():null,goog.a11y.aria.setLabel(t,e?goog.a11y.aria.getLabel(e):this.initialAriaLabel_),this.updateAriaActiveDescendant_())},goog.ui.Select.prototype.updateAriaActiveDescendant_=function(){var e=this.getRenderer();if(e&&(e=e.getContentElement(this.getElement()))){var t=this.getElementStrict();if(e.id||(e.id=goog.ui.IdGenerator.getInstance().getNextUniqueId()),goog.a11y.aria.setRole(e,goog.a11y.aria.Role.OPTION),goog.a11y.aria.setState(t,goog.a11y.aria.State.ACTIVEDESCENDANT,e.id),this.selectionModel_){t=this.selectionModel_.getItems(),goog.a11y.aria.setState(e,goog.a11y.aria.State.SETSIZE,this.getNumMenuItems_(t));var o=this.selectionModel_.getSelectedIndex();goog.a11y.aria.setState(e,goog.a11y.aria.State.POSINSET,0<=o?this.getNumMenuItems_(goog.array.slice(t,0,o+1)):0)}}},goog.ui.Select.prototype.getNumMenuItems_=function(e){return goog.array.count(e,function(e){return e instanceof goog.ui.MenuItem})},goog.ui.Select.prototype.setCorrectAriaRole_=function(e){e.setPreferredAriaRole(e instanceof goog.ui.MenuItem?goog.a11y.aria.Role.OPTION:goog.a11y.aria.Role.SEPARATOR)},goog.ui.Select.prototype.setOpen=function(e,t){goog.ui.Select.superClass_.setOpen.call(this,e,t),this.isOpen()?this.getMenu().setHighlightedIndex(this.getSelectedIndex()):this.updateAriaActiveDescendant_()},goog.ui.registry.setDecoratorByClassName("goog-select",function(){return new goog.ui.Select(null)}),goog.ui.decorate=function(e){var t=goog.ui.registry.getDecorator(e);return t&&t.decorate(e),t};var EXAMPLE_BLOCK_MARGIN_BELOW=20,EXAMPLE_BLOCK_MARGIN_LEFT=Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,EXAMPLE_BLOCK_SECTION_MARGIN_BELOW=10,HEADER_HEIGHT=30,DEFAULT_EXAMPLE_CALL_SECTION_WIDTH=100,MARGIN_BLOCK_TO_CALL_SLOT=13,YELLOW_HEX="#ffa400",HIGHLIGHT_BOX_WIDTH=10,USER_TYPE_CHOICES=[Blockly.BlockValueType.NUMBER,Blockly.BlockValueType.STRING,Blockly.BlockValueType.IMAGE,Blockly.BlockValueType.BOOLEAN],CONTRACT_SECTION_NAME="contract",EXAMPLES_SECTION_NAME="examples",DEFINITION_SECTION_NAME="definition",HIGHLIGHT_CONFIG_SUFFIX="Highlight",COLLAPSE_CONFIG_SUFFIX="Collapse",DISABLE_EXAMPLES_CONFIG_NAME="disableExamples";Blockly.ContractEditor=function(e){Blockly.ContractEditor.superClass_.constructor.call(this),this.disableExamples_=e[DISABLE_EXAMPLES_CONFIG_NAME],this.outputTypeSelector=null,this.exampleBlocks=[],this.domainEditors_=[],this.definitionSectionView_=this.examplesSectionView_=this.contractSectionView_=null,this.allSections_=new goog.structs.LinkedMap,this.autoOpenConfig_=null,this.testHandler_=function(e){return"Block ID is "+e.id},this.testResetHandler_=function(){},this.customFailureCloseHandler_=function(){return!1},this.exampleViews_=[]},goog.inherits(Blockly.ContractEditor,Blockly.FunctionEditor),Blockly.ContractEditor.EXAMPLE_BLOCK_TYPE="functional_example",Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME="ACTUAL",Blockly.ContractEditor.DEFAULT_OUTPUT_TYPE=Blockly.BlockValueType.NUMBER,Blockly.ContractEditor.DEFAULT_PARAMETER_TYPE=Blockly.BlockValueType.NUMBER,Blockly.ContractEditor.GRID_LINE_COLOR="#5b6770",Blockly.ContractEditor.prototype.definitionBlockType="functional_definition",Blockly.ContractEditor.prototype.parameterBlockType="functional_parameters_get",Blockly.ContractEditor.prototype.create_=function(){Blockly.ContractEditor.superClass_.create_.call(this);var e=this.modalBlockSpace.svgBlockCanvas_,t=new Blockly.SvgHighlightBox(e,{color:YELLOW_HEX,thickness:HIGHLIGHT_BOX_WIDTH});this.contractSectionView_=new Blockly.ContractEditorSectionView(e,{sectionNumber:1,headerHeight:HEADER_HEIGHT,onCollapseCallback:goog.bind(function(e){this.contractDiv_.style.display=e?"none":"block",this.position_()},this),placeContentCallback:goog.bind(function(e){return e+this.getContractDivHeight()},this),highlightBox:t,headerText:"Contract and Purpose Statement"}),this.hiddenExampleBlocks_=[],this.exampleAreaDiv=goog.dom.createDom("div","exampleAreaDiv innerModalDiv"),this.addExampleButton=goog.dom.createDom("button","exampleAreaButton btn"),this.addExampleButton.textContent="Add Example",Blockly.bindEvent_(this.addExampleButton,"click",this,this.addNewExampleBlock_),goog.dom.append(this.exampleAreaDiv,this.addExampleButton),this.exampleAreaDiv.style.display="block",this.exampleAreaDiv.style.position="absolute",goog.dom.insertChildAt(this.frameClipDiv_,this.exampleAreaDiv,0),this.callText=goog.dom.createDom("div","callResultText"),this.callText.textContent="Call",Blockly.svgIgnoreMouseEvents(this.callText),goog.dom.appendChild(this.exampleAreaDiv,this.callText),this.resultText=goog.dom.createDom("div","callResultText"),this.resultText.textContent="Result",goog.dom.appendChild(this.exampleAreaDiv,this.resultText),Blockly.svgIgnoreMouseEvents(this.resultText),this.examplesTableGroup=Blockly.createSvgElement("g",{},e),this.topHorizontalLine=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR},this.examplesTableGroup),this.topHorizontalLine.setAttribute("height",2),Blockly.svgIgnoreMouseEvents(this.topHorizontalLine),this.verticalExampleMidline=Blockly.createSvgElement("rect",{fill:Blockly.ContractEditor.GRID_LINE_COLOR},this.examplesTableGroup),this.verticalExampleMidline.setAttribute("width",2),this.examplesSectionView_=new Blockly.ContractEditorSectionView(e,{sectionNumber:2,headerHeight:HEADER_HEIGHT,headerText:"Examples",placeContentCallback:this.onPlaceExampleContent.bind(this),highlightBox:t,onCollapseCallback:goog.bind(function(e){this.exampleAreaDiv.style.display=e?"none":"block",this.examplesTableGroup.style.display=e?"none":"block",this.hiddenExampleBlocks_=this.setBlockSubsetVisibility(!e,goog.bind(this.isBlockInExampleArea,this),this.hiddenExampleBlocks_),this.position_()},this)}),this.hiddenDefinitionBlocks_=[],this.definitionSectionLogic_=new Blockly.ContractDefinitionSection(e),this.definitionSectionView_=new Blockly.ContractEditorSectionView(e,{sectionNumber:3,headerHeight:HEADER_HEIGHT,headerText:"Definition",onCollapseCallback:goog.bind(function(e){this.flyout_.setVisibility(!e),e||this.refreshParamsInFlyout_(),this.hiddenDefinitionBlocks_=this.setBlockSubsetVisibility(!e,goog.bind(this.isBlockInFunctionArea,this),this.hiddenDefinitionBlocks_),this.definitionSectionLogic_.handleCollapse(e),this.position_()},this),highlightBox:t,placeContentCallback:goog.bind(function(e){return this.flyout_&&(e=this.positionFlyout_(e)),this.definitionSectionLogic_.placeContent(e,this.getVerticalMidlineOffset_(),this.getFullWidth(),this.functionDefinitionBlock)},this)}),this.allSections_.set(CONTRACT_SECTION_NAME,this.contractSectionView_),this.allSections_.set(EXAMPLES_SECTION_NAME,this.examplesSectionView_),this.allSections_.set(DEFINITION_SECTION_NAME,this.definitionSectionView_)},Blockly.ContractEditor.prototype.autoOpenWithLevelConfiguration=function(e){this.autoOpenConfig_=e,Blockly.ContractEditor.superClass_.autoOpenWithLevelConfiguration.call(this,e)},Blockly.ContractEditor.prototype.setBlockSubsetVisibility=function(e,t,o){var n=[];return e?o.forEach(function(e){e.setCurrentlyHidden(!1)},this):this.modalBlockSpace.getTopBlocks().filter(t).forEach(function(e){n.push(e),e.setCurrentlyHidden(!0)},this),n},Blockly.ContractEditor.prototype.isBlockInFunctionArea=function(e){return this.isVisibleInEditor_(e)&&!this.isBlockInExampleArea(e)},Blockly.ContractEditor.prototype.isBlockInExampleArea=function(e){return this.isAnExampleBlockInEditor_(e)||e!==this.functionDefinitionBlock&&this.isVisibleInEditor_(e)&&e.getRelativeToSurfaceXY().y<this.getFlyoutTopPosition()},Blockly.ContractEditor.prototype.isVisibleInEditor_=function(e){return e.blockSpace===this.modalBlockSpace&&e.isVisible()},Blockly.ContractEditor.prototype.getFlyoutTopPosition=function(){return this.flyout_.getYPosition()-this.flyout_.getHeight()},Blockly.ContractEditor.prototype.isAnExampleBlockInEditor_=function(e){return goog.array.contains(this.exampleBlocks,e)},Blockly.ContractEditor.prototype.hideAndRestoreBlocks_=function(){Blockly.ContractEditor.superClass_.hideAndRestoreBlocks_.call(this),goog.array.clone(this.exampleBlocks).forEach(function(e){this.moveToMainBlockSpace_(e)},this),goog.array.clear(this.exampleBlocks),this.domainEditors_.forEach(function(e){e.dispose()},this),goog.array.clear(this.domainEditors_),this.outputTypeSelector.dispose(),this.outputTypeSelector=null},Blockly.ContractEditor.prototype.openAndEditFunction=function(e){Blockly.ContractEditor.superClass_.openAndEditFunction.call(this,e),this.addRangeEditor_(),this.updateFrameColorForType_(this.functionDefinitionBlock.getOutputType()),this.functionDefinitionBlock.setDeletable(!1),this.moveExampleBlocksToModal_(e),this.setupAfterExampleBlocksAdded_(),this.position_(),this.resetParamIDs_(),this.refreshParamsEverywhere()},Blockly.ContractEditor.prototype.setSectionHighlighted=function(e){this.allSections_.forEach(function(t){t.setHighlighted(t===e)},this)},Blockly.ContractEditor.prototype.addNewExampleBlock_=function(){this.addNewExampleBlockForFunction_(this.functionDefinitionBlock),this.refreshBlockInputTypes_()},Blockly.ContractEditor.prototype.addNewExampleBlockForFunction_=function(e){e=this.createExampleBlock_(e),this.addExampleBlockFromMainBlockSpace(e),this.position_()},Blockly.ContractEditor.prototype.moveExampleBlocksToModal_=function(e){Blockly.mainBlockSpace.findFunctionExamples(e).forEach(function(e){this.addExampleBlockFromMainBlockSpace(e)},this)},Blockly.ContractEditor.prototype.registerTestHandler=function(e){this.testHandler_=e},Blockly.ContractEditor.prototype.registerTestResetHandler=function(e){this.testResetHandler_=e},Blockly.ContractEditor.prototype.registerTestsFailedOnCloseHandler=function(e){this.customFailureCloseHandler_=e},Blockly.ContractEditor.prototype.addExampleBlockFromMainBlockSpace=function(e){(e=this.moveToModalBlockSpace(e)).getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME).setCanDisconnectFromParent(!1),this.exampleBlocks.push(e),e.blockEvents.listen(Blockly.Block.EVENTS.AFTER_DROPPED,function(){this.layOutBlockSpaceItems_(),this.modalBlockSpace.updateScrollableSize()}.bind(this)),e.blockEvents.listenOnce(Blockly.Block.EVENTS.AFTER_DISPOSED,this.removeExampleBlock_.bind(this,e),!1,this)},Blockly.ContractEditor.prototype.refreshBlockInputTypes_=function(){this.setBlockInputsToType_(this.currentFunctionDefinitionType_())},Blockly.ContractEditor.prototype.setBlockInputsToType_=function(e){this.exampleBlocks.concat(this.functionDefinitionBlock).forEach(function(t){t.updateInputsToType(e)},this)},Blockly.ContractEditor.prototype.currentFunctionDefinitionType_=function(){return this.functionDefinitionBlock.outputType_},Blockly.ContractEditor.prototype.removeExampleBlock_=function(e){goog.array.remove(this.exampleBlocks,e),this.position_()},Blockly.ContractEditor.prototype.openWithNewVariable=function(){this.openWithNewFunction(!0)},Blockly.ContractEditor.prototype.openWithNewFunction=function(e){this.ensureCreated_();var t=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:this.definitionBlockType}));if(t.updateOutputType(Blockly.ContractEditor.DEFAULT_OUTPUT_TYPE),t.userCreated=!0,e)t.convertToVariable();else for(e=0;e<Blockly.defaultNumExampleBlocks;e++)this.addNewExampleBlockForFunction_(t);this.openAndEditFunction(t.getTitleValue("NAME"))},Blockly.ContractEditor.prototype.createExampleBlock_=function(e){var t=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:Blockly.ContractEditor.EXAMPLE_BLOCK_TYPE}));return e=Blockly.Procedures.createCallerFromDefinition(Blockly.mainBlockSpace,e),t.attachBlockToInputName(e,Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME),t},Blockly.ContractEditor.prototype.getFullWidth=function(){return this.modalBlockSpace.getMetrics().viewWidth},Blockly.ContractEditor.prototype.layOutBlockSpaceItems_=function(){if(this.readyToBeLaidOut_()){var e=this.getFullWidth(),t=this.contractSectionView_.placeAndGetNewY(0,e);t=this.examplesSectionView_.placeAndGetNewY(t,e),this.definitionSectionView_.placeAndGetNewY(t,e)}},Blockly.ContractEditor.prototype.createContractDom_=function(){var e=goog.dom.createDom("DIV",null,goog.dom.createDom("SPAN",{id:"domain-label"},Blockly.Msg.FUNCTIONAL_DOMAIN_LABEL)," ",goog.dom.createDom("SPAN",{id:"domain-hint",class:"contract-type-hint"},"(the domain is the type of input)")),t=goog.dom.createDom("DIV",null,goog.dom.createDom("SPAN",{id:"outputTypeTitle"},Blockly.Msg.FUNCTIONAL_RANGE_LABEL)," ",goog.dom.createDom("SPAN",{id:"range-hint",class:"contract-type-hint"},"(the range is the type of output)"));t=goog.dom.createDom("DIV",{id:"range-area",style:"margin: 0;"},t,goog.dom.createDom("SPAN",{id:"outputTypeDropdown"}));var o=goog.dom.createDom("DIV",{id:"description-area",style:"margin: 0px;"},goog.dom.createDom("DIV",null,Blockly.Msg.FUNCTIONAL_DESCRIPTION_LABEL),goog.dom.createDom("DIV",null,goog.dom.createDom("TEXTAREA",{id:"functionDescriptionText",rows:"2"})));this.contractDiv_=goog.dom.createDom("DIV","blocklyToolboxDiv paramToolbox blocklyText contractEditor flyoutColorGray innerModalDiv",goog.dom.createDom("DIV",null,Blockly.Msg.FUNCTIONAL_NAME_LABEL),goog.dom.createDom("DIV",null,goog.dom.createDom("INPUT",{id:"functionNameText",type:"text"})),e,goog.dom.createDom("DIV",{id:"domain-area",style:"margin: 0;"}),goog.dom.createDom("DIV",{class:"clear",style:"margin: 0;"}),goog.dom.createDom("BUTTON",{id:"paramAddButton",class:"btn"},"Add Domain"),goog.dom.createDom("DIV",{class:"clear",style:"margin: 0;"}),t,o),Blockly.RTL&&this.contractDiv_.setAttribute("dir","RTL"),e=this.modalBlockSpace.getMetrics(),this.contractDiv_.style.left=e.absoluteLeft+"px",this.contractDiv_.style.top=e.absoluteTop+"px",this.contractDiv_.style.width=e.viewWidth+"px",this.contractDiv_.style.display="block",this.frameClipDiv_=this.createFrameClipDiv_(),this.frameClipDiv_.insertBefore(this.contractDiv_,this.frameClipDiv_.firstChild),this.container_.insertBefore(this.frameClipDiv_,this.container_.firstChild),this.initializeAddButton_()},Blockly.ContractEditor.prototype.createParameterEditor_=function(){},Blockly.ContractEditor.prototype.bindToolboxHandlers_=function(){},Blockly.ContractEditor.prototype.chromeBottomToContractDivDistance_=function(){return this.isShowingHeaders_()?HEADER_HEIGHT:0},Blockly.ContractEditor.prototype.getContractDomTopY_=function(){return this.chromeBottomToContractDivDistance_()+this.modalBlockSpace.yOffsetFromView},Blockly.ContractEditor.prototype.setupUIForBlock_=function(e){e=e.isVariable(),this.frameText_.textContent=e?Blockly.Msg.FUNCTIONAL_VARIABLE_HEADER:Blockly.Msg.CONTRACT_EDITOR_HEADER,goog.dom.setTextContent(goog.dom.getElement("outputTypeTitle"),e?Blockly.Msg.FUNCTIONAL_VARIABLE_TYPE:Blockly.Msg.FUNCTIONAL_RANGE_LABEL),goog.style.setElementShown(goog.dom.getElement("domain-area"),!e),goog.style.setElementShown(goog.dom.getElement("domain-label"),!e),goog.style.setElementShown(goog.dom.getElement("paramAddButton"),!e),goog.style.setElementShown(goog.dom.getElement("description-area"),!e),goog.style.setElementShown(goog.dom.getElement("range-hint"),!e),goog.style.setElementShown(goog.dom.getElement("domain-hint"),!e)},Blockly.ContractEditor.prototype.setupAfterExampleBlocksAdded_=function(){this.refreshBlockInputTypes_(),this.functionDefinitionBlock.isVariable()?this.setupSectionsForVariable_():this.setupSectionsForContract_(this.autoOpenConfig_),this.autoOpenConfig_=null},Blockly.ContractEditor.prototype.setupSectionsForVariable_=function(){this.contractSectionView_.setHidden(!1),this.contractSectionView_.setHeaderVisible(!1),this.examplesSectionView_.setHidden(!0),this.definitionSectionView_.setHidden(!1),this.definitionSectionView_.setHeaderVisible(!1)},Blockly.ContractEditor.prototype.setupSectionsForContract_=function(e){this.allSections_.forEach(function(t,o){e?(e[o+HIGHLIGHT_CONFIG_SUFFIX]&&this.setSectionHighlighted(t),t.setCollapsed(e[o+COLLAPSE_CONFIG_SUFFIX])):(t.setHighlighted(!1),t.setHidden(!1),t.setHeaderVisible(!0),t.setCollapsed(t.isCollapsed()))},this),this.disableExamples_&&(this.contractSectionView_.removeSectionNumber(),this.definitionSectionView_.removeSectionNumber(),this.examplesSectionView_.setHidden(!0))},Blockly.ContractEditor.prototype.isShowingHeaders_=function(){return!this.isEditingVariable()},Blockly.ContractEditor.prototype.isEditingVariable=function(){return this.functionDefinitionBlock&&this.functionDefinitionBlock.isVariable()},Blockly.ContractEditor.prototype.addParameter=function(e,t){var o=goog.events.getUniqueId("parameter");this.orderedParamIDsToBlocks_.set(o,this.newParameterBlock(e,t)),this.addDomainEditorForParamID_(o)},Blockly.ContractEditor.prototype.addDomainEditorForParamID_=function(e){var t=this.getParamNameType(e);(e=new Blockly.DomainEditor({paramID:e,name:t.name,type:t.type,onRemovePress:goog.bind(this.removeContractParameter_,this,e),onTypeChanged:goog.bind(this.changeParameterType_,this,e),onNameChanged:goog.bind(this.changeParameterName_,this,e),typeChoices:USER_TYPE_CHOICES})).render(goog.dom.getElement("domain-area")),this.domainEditors_.push(e)},Blockly.ContractEditor.prototype.removeContractParameter_=function(e){this.orderedParamIDsToBlocks_.remove(e),this.refreshParamsEverywhere(),goog.array.removeIf(this.domainEditors_,function(t){return t.getParamID()===e&&(t.dispose(),!0)},this),this.position_()},Blockly.ContractEditor.prototype.newParameterBlock=function(e,t){t=t||Blockly.ContractEditor.DEFAULT_PARAMETER_TYPE;var o=Blockly.createSvgElement("block",{type:this.parameterBlockType});return Blockly.createSvgElement("title",{name:"VAR"},o).textContent=e,t&&(e=Blockly.createSvgElement("mutation",{},o),Blockly.createSvgElement("outputtype",{},e).textContent=t),o},Blockly.ContractEditor.prototype.addParamsFromProcedure_=function(){for(var e=this.functionDefinitionBlock.getProcedureInfo(),t=0;t<e.parameterNames.length;t++)this.addParameter(e.parameterNames[t],e.parameterTypes[t])},Blockly.ContractEditor.prototype.addRangeEditor_=function(){this.outputTypeSelector=new Blockly.TypeDropdown({onTypeChanged:goog.bind(this.outputTypeChanged_,this),typeChoices:USER_TYPE_CHOICES,type:this.functionDefinitionBlock.getOutputType()||Blockly.ContractEditor.DEFAULT_OUTPUT_TYPE}),this.outputTypeSelector.render(this.getOutputTypeDropdownElement_())},Blockly.ContractEditor.prototype.outputTypeChanged_=function(e){this.updateFrameColorForType_(e),this.functionDefinitionBlock&&(this.setBlockInputsToType_(Blockly.BlockValueType.NONE),this.functionDefinitionBlock.updateOutputType(e),this.modalBlockSpace.events.dispatchEvent(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE),this.refreshBlockInputTypes_(),this.modalBlockSpace.events.dispatchEvent(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE))},Blockly.ContractEditor.prototype.updateFrameColorForType_=function(e){e=Blockly.FunctionalTypeColors[e];var t=goog.color.hsvToHex(e[0],e[1],255*e[2]);this.setFrameColor_(t),this.allSections_.forEach(function(e){e.setHeaderColor(t)},this)},Blockly.ContractEditor.prototype.setFrameColor_=function(e){this.frameBase_.style.fill=e},Blockly.ContractEditor.prototype.getOutputTypeDropdownElement_=function(){return goog.dom.getElement("outputTypeDropdown")},Blockly.ContractEditor.prototype.initializeAddButton_=function(){var e=goog.dom.getElement("paramAddButton");Blockly.bindEvent_(e,"mousedown",this,goog.bind(function(){this.addParameter(Blockly.Variables.generateUniqueName()),this.refreshParamsEverywhere()},this))},Blockly.ContractEditor.prototype.changeParameterType_=function(e,t){e=this.getParamNameType(e).name,this.functionDefinitionBlock.changeParamType(e,t),this.changeParameterTypeInFlyoutXML(e,t),this.refreshParamsEverywhere()},Blockly.ContractEditor.prototype.changeParameterName_=function(e,t){e=this.getParamNameType(e).name,Blockly.Variables.renameVariable(e,t,Blockly.modalBlockSpace)},Blockly.ContractEditor.prototype.getVerticalMidlineOffset_=function(){return Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN+this.getMaxExampleCallBlockWidth_()+MARGIN_BLOCK_TO_CALL_SLOT},Blockly.ContractEditor.prototype.getMaxExampleCallBlockWidth_=function(){return this.exampleBlocks.reduce(function(e,t){return(t=t.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME))?(t=t.getHeightWidth().width,Math.max(e,t)):e},DEFAULT_EXAMPLE_CALL_SECTION_WIDTH)},Blockly.ContractEditor.prototype.resetExampleViews=function(){this.exampleViews_.forEach(function(e){e.reset()})},Blockly.ContractEditor.prototype.testExample=function(e,t){return e=this.testHandler_(e,t),this.functionDefinitionBlock.getInput("STACK").connection.isConnected()?e:Blockly.Msg.DEFINE_FUNCTION_FOR_EXAMPLE},Blockly.ContractEditor.prototype.resetExample=function(e){this.testResetHandler_(e)},Blockly.ContractEditor.prototype.updateExampleResult=function(e,t){this.exampleViews_.some(function(o){if(o.getBlock()===e)return o.setResult(t),!0})},Blockly.ContractEditor.prototype.onPlaceExampleContent=function(e){var t=this.getMaxExampleCallBlockWidth_(),o=this.modalBlockSpace.getMetrics();this.exampleAreaDiv.style.left=this.modalBlockSpace.xOffsetFromView+"px",this.exampleAreaDiv.style.top=this.modalBlockSpace.yOffsetFromView+e+"px",this.exampleAreaDiv.style.width=o.viewWidth+"px",o=EXAMPLE_BLOCK_SECTION_MARGIN_BELOW/2;var n=e,i=this.getVerticalMidlineOffset_(),r=n;this.verticalExampleMidline.setAttribute("transform","translate("+i+","+n+")");var l=0<this.exampleBlocks.length;l&&(n+=o,this.callText.style.top=n-e+"px",this.callText.style.left=Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN+"px",this.resultText.style.top=n-e+"px",this.resultText.style.left=i+Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN+"px",n+=this.callText.offsetHeight,n+=o,this.topHorizontalLine.setAttribute("transform","translate(0,"+n+")"),this.topHorizontalLine.setAttribute("width",this.getFullWidth()),this.exampleBlocks.forEach(goog.bind(function(o,r){if(!(this.exampleViews_.length>r)){var l=new Blockly.ExampleView(this.exampleAreaDiv,this.examplesTableGroup,this);this.exampleViews_.push(l)}n=this.exampleViews_[r].placeExampleAndGetNewY(o,n,t,Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,EXAMPLE_BLOCK_MARGIN_BELOW,this.getFullWidth(),i,e)},this)));for(var s=this.exampleBlocks.length;s<this.exampleViews_.length;s++)this.exampleViews_[s].dispose();return this.exampleViews_.length=this.exampleBlocks.length,this.verticalExampleMidline.style.display=l?"block":"none",this.topHorizontalLine.style.display=l?"block":"none",this.callText.style.display=l?"block":"none",this.resultText.style.display=l?"block":"none",this.verticalExampleMidline.setAttribute("height",n-r),n+=o,this.addExampleButton.style.top=n-e+"px",this.addExampleButton.style.left=Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN+"px",n+=this.addExampleButton.offsetHeight,n+=EXAMPLE_BLOCK_SECTION_MARGIN_BELOW,this.exampleAreaDiv.style.height=n-e+"px",n},Blockly.ContractEditor.prototype.onClose=function(){if(this.isOpen()){var e=!0;this.exampleViews_.forEach(function(t){var o=this.testExample(t.getBlock(),!1);t.setResult(o),t.refreshTestingUI(!1),e=e&&!o}.bind(this)),!e&&this.customFailureCloseHandler_()||this.hideIfOpen()}},Blockly.Generator={},Blockly.Generator.NAME_TYPE="generated_function",Blockly.Generator.languages={},Blockly.Generator.get=function(e){if(!(e in Blockly.Generator.languages)){var t=new Blockly.CodeGenerator(e);Blockly.Generator.languages[e]=t}return Blockly.Generator.languages[e]},Blockly.Generator.blocksToCode=function(e,t,o){var n=[];(e=Blockly.Generator.get(e)).init(t);for(var i,r=0;i=t[r];r++){var l=e.blockToCode(i,o);l instanceof Array&&(l=l[0]),l&&(i.outputConnection&&e.scrubNakedValue&&(l=e.scrubNakedValue(l)),i.isUnused()&&(l="/*\n"+l+"*/\n"),n.push(l))}return n=n.join("\n"),(n=(n=(n=e.finish(n)).replace(/^\s+\n/,"")).replace(/\n\s+$/,"\n")).replace(/[ \t]+\n/g,"\n")},Blockly.Generator.xmlToCode=function(e,t){return t=Blockly.Generator.xmlToBlocks(e,t),Blockly.Generator.blocksToCode(e,t)},Blockly.Generator.xmlToBlocks=function(e,t){return e=document.createElement("div"),Blockly.BlockSpace.createReadOnlyBlockSpace(e,t,{disableEventBindings:!0}).getTopBlocks(!0)},Blockly.Generator.blockSpaceToCode=function(e,t,o){if(t){"string"==typeof t&&(t=[t]);var n=goog.array.filter(Blockly.mainBlockSpace.getTopBlocks(!0),function(e){return goog.array.contains(t,e.type)},this)}else n=Blockly.mainBlockSpace.getTopBlocks(!0);return Blockly.Generator.blocksToCode(e,n,o)},Blockly.Generator.prefixLines=function(e,t){return t+e.replace(/\n(.)/g,"\n"+t+"$1")},Blockly.CodeGenerator=function(e){this.name_=e,this.RESERVED_WORDS_=""},Blockly.CodeGenerator.prototype.blockToCode=function(e,t){if(!e)return"";if(e.disabled||null!=t&&!t&&!e.isUserVisible())return e=e.nextConnection&&e.nextConnection.targetBlock(),this.blockToCode(e,t);var o=this[e.type];return(o=o?o.call(e):Blockly.Generator.prefixLines("Unknown block: "+e.type+"\n","// "))instanceof Array?[this.scrub_(e,o[0],t),o[1]]:this.scrub_(e,o,t)},Blockly.CodeGenerator.prototype.valueToCode=function(e,t,o){if(isNaN(o))throw'Expecting valid order from block "'+e.type+'".';if(!(e=e.getInputTargetBlock(t)))return"";var n=this.blockToCode(e);if(""===n)return"";if(!(n instanceof Array))throw'Expecting tuple from value block "'+e.type+'".';if(t=n[0],n=n[1],isNaN(n))throw'Expecting valid order from value block "'+e.type+'".';return t&&o<=n&&(t="("+t+")"),t},Blockly.CodeGenerator.prototype.statementToCode=function(e,t){if(e=e.getInputTargetBlock(t),t=this.blockToCode(e),!goog.isString(t))throw'Expecting code from statement block "'+e.type+'".';return t&&(t=Blockly.Generator.prefixLines(t,"  ")),t},Blockly.CodeGenerator.prototype.addReservedWords=function(e){this.RESERVED_WORDS_+=e+","},Blockly.Names=function(e){if(this.reservedDict_={},e){e=e.split(",");for(var t=0;t<e.length;t++)this.reservedDict_[Blockly.Names.PREFIX_+e[t]]=!0}this.reset()},Blockly.Names.PREFIX_="$_",Blockly.Names.prototype.reset=function(){this.db_={},this.dbSpecificType_={},this.dbReverse_={}},Blockly.Names.prototype.getName=function(e,t,o){var n=Blockly.Names.PREFIX_+e.toLowerCase()+"_"+t;return n in this.db_?this.db_[n]:(e=this.getDistinctName(e,t),this.db_[n]=e,o&&(this.dbSpecificType_[n]=o),e)},Blockly.Names.prototype.checkSpecificType=function(e,t,o){return(e=Blockly.Names.PREFIX_+e.toLowerCase()+"_"+t)in this.dbSpecificType_&&this.dbSpecificType_[e]===o},Blockly.Names.prototype.getDistinctName=function(e){e=this.safeName_(e);for(var t="";this.dbReverse_[Blockly.Names.PREFIX_+e+t]||Blockly.Names.PREFIX_+e+t in this.reservedDict_;)t=t?t+1:2;return e+=t,this.dbReverse_[Blockly.Names.PREFIX_+e]=!0,e},Blockly.Names.prototype.safeName_=function(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),-1!="0123456789".indexOf(e[0])&&(e="my_"+e)):e="unnamed",e},Blockly.Names.equals=function(e,t){return e.toLowerCase()==t.toLowerCase()},Blockly.Procedures={},Blockly.Procedures.NAME_TYPE="PROCEDURE",Blockly.Procedures.NAME_TYPE_FUNCTIONAL_VARIABLE="FUNCTIONAL_VARIABLE",Blockly.Procedures.DEFINITION_BLOCK_TYPES=["procedures_defnoreturn","procedures_defreturn","functional_definition"],Blockly.Procedures.PROCEDURAL_TO_FUNCTIONAL_CALL_TYPE="procedural_to_functional_call",Blockly.Procedures.allProcedures=function(){var e=[],t=[],o=[],n=[];return Blockly.mainBlockSpace.getAllBlocks().forEach(function(i){if(i.getProcedureInfo){var r=i.getProcedureInfo();switch(i.type){case"functional_definition":o.push(r),"start_blocks"===Blockly.editBlocks&&((i=goog.object.clone(r)).callType=Blockly.Procedures.PROCEDURAL_TO_FUNCTIONAL_CALL_TYPE,o.push(i));break;case"procedures_defreturn":e.push(r);break;case"procedures_defnoreturn":t.push(r);break;default:n.push(r)}}}),t.sort(Blockly.Procedures.procedureInfoSort_),e.sort(Blockly.Procedures.procedureInfoSort_),o.sort(Blockly.Procedures.procedureInfoSort_),n.sort(Blockly.Procedures.procedureInfoSort_),goog.array.concat(t,e,o,n)},Blockly.Procedures.procedureInfoSort_=function(e,t){return(e=e.name.toLowerCase())>(t=t.name.toLowerCase())?1:e<t?-1:0},Blockly.Procedures.findLegalName=function(e,t){if(t.isInFlyout)return e;for(;!Blockly.Procedures.isLegalName(e,t.blockSpace,t);){var o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2],10)+1):e+"2"}return e},Blockly.Procedures.isLegalName=function(e,t,o){return!t.getAllBlocks().filter(function(e){return e!==o}).some(function(t){return t.getProcedureInfo&&Blockly.Names.equals(t.getProcedureInfo().name,e)})},Blockly.Procedures.rename=function(e){e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,""),e=Blockly.Procedures.findLegalName(e,this.sourceBlock_);for(var t=this.sourceBlock_.blockSpace.getAllBlocks().concat(this.sourceBlock_.blockSpace.blockSpaceEditor.getAllFlyoutBlocks()),o=0;o<t.length;o++){var n=t[o].renameProcedure;n&&n.call(t[o],this.text_,e,this.sourceBlock_.userCreated)}return this.sourceBlock_.blockSpace.blockSpaceEditor.svgResize(),e},Blockly.Procedures.flyoutCategory=function(e,t,o,n,i){if(!Blockly.functionEditor&&!Blockly.disableProcedureAutopopulate&&!Blockly.topLevelProcedureAutopopulate){if(Blockly.Blocks.procedures_defnoreturn){var r=new Blockly.Block(n,"procedures_defnoreturn");r.initSvg(),e.push(r),t.push(2*o)}Blockly.Blocks.procedures_defreturn&&((r=new Blockly.Block(n,"procedures_defreturn")).initSvg(),e.push(r),t.push(2*o)),Blockly.Blocks.procedures_ifreturn&&((r=new Blockly.Block(n,"procedures_ifreturn")).initSvg(),e.push(r),t.push(2*o)),t.length&&(t[t.length-1]=3*o)}Blockly.Procedures.allProcedures().forEach(function(r){if(!i||i(r)){var l=Blockly.Procedures.createCallerBlock(n,r);e.push(l),t.push(2*o),Blockly.editBlocks&&(r=Blockly.Procedures.createFunctionPassingBlock(n,r),e.push(r),t.push(2*o))}})},Blockly.Procedures.createCallerFromDefinition=function(e,t){return Blockly.Procedures.createCallerBlock(e,t.getProcedureInfo())},Blockly.Procedures.createCallerBlock=function(e,t){var o="gamelab_behavior_get"===t.callType?"VAR":"NAME";(e=new Blockly.Block(e,t.callType)).setTitleValue(t.name,o),e.getTitle_(o).id=t.id,o=[];for(var n=0;n<t.parameterNames.length;n++)o[n]="ARG"+n;return e.setProcedureParameters(t.parameterNames,o,t.parameterTypes),e.initSvg(),e},Blockly.Procedures.createFunctionPassingBlock=function(e,t){return(e=new Blockly.Block(e,"functional_pass")).setTitleValue(t.name,"NAME"),e.initSvg(),e},Blockly.Procedures.getCallers=function(e,t){return t.getAllBlocks().filter(function(t){return t.getCallName&&Blockly.Names.equals(e,t.getCallName())})},Blockly.Procedures.disposeCallers=function(e,t){Blockly.Procedures.getCallers(e,t).forEach(function(e){e.dispose(!0,!1)})},Blockly.Procedures.mutateCallers=function(e,t,o,n,i){Blockly.Procedures.getCallers(e,t).forEach(function(e){e.setProcedureParameters(o,n,i)},this)},Blockly.Procedures.getDefinition=function(e,t){return goog.array.find(t.getAllBlocks(),function(t){return t.getProcedureInfo&&Blockly.Names.equals(t.getProcedureInfo().name,e)})},goog.cssom={},goog.cssom.CssRuleType={STYLE:1,IMPORT:3,MEDIA:4,FONT_FACE:5,PAGE:6,NAMESPACE:7},goog.cssom.getAllCssText=function(e){return goog.cssom.getAllCss_(e||document.styleSheets,!0)},goog.cssom.getAllCssStyleRules=function(e){return goog.cssom.getAllCss_(e||document.styleSheets,!1)},goog.cssom.getCssRulesFromStyleSheet=function(e){var t=null;try{t=e.cssRules||e.rules}catch(t){if(15==t.code)throw t.styleSheet=e,t}return t},goog.cssom.getAllCssStyleSheets=function(e,t){var o=[];if(e=e||document.styleSheets,t=!!goog.isDef(t)&&t,e.imports&&e.imports.length)for(var n=0,i=e.imports.length;n<i;n++)goog.array.extend(o,goog.cssom.getAllCssStyleSheets(e.imports[n]));else if(e.length)for(n=0,i=e.length;n<i;n++)goog.array.extend(o,goog.cssom.getAllCssStyleSheets(e[n]));else{var r=goog.cssom.getCssRulesFromStyleSheet(e);if(r&&r.length){n=0,i=r.length;for(var l;n<i;n++)(l=r[n]).styleSheet&&goog.array.extend(o,goog.cssom.getAllCssStyleSheets(l.styleSheet))}}return!(e.type||e.rules||e.cssRules)||e.disabled&&!t||o.push(e),o},goog.cssom.getCssTextFromCssRule=function(e){var t="";return e.cssText?t=e.cssText:e.style&&e.style.cssText&&e.selectorText&&(t=e.style.cssText.replace(/\s*-closure-parent-stylesheet:\s*\[object\];?\s*/gi,"").replace(/\s*-closure-rule-index:\s*[\d]+;?\s*/gi,""),t=e.selectorText+" { "+t+" }"),t},goog.cssom.getCssRuleIndexInParentStyleSheet=function(e,t){if(e.style&&e.style["-closure-rule-index"])return e.style["-closure-rule-index"];if(!(t=t||goog.cssom.getParentStyleSheet(e)))throw Error("Cannot find a parentStyleSheet.");if((t=goog.cssom.getCssRulesFromStyleSheet(t))&&t.length)for(var o=0,n=t.length;o<n;o++)if(t[o]==e)return o;return-1},goog.cssom.getParentStyleSheet=function(e){return e.parentStyleSheet||e.style&&e.style["-closure-parent-stylesheet"]},goog.cssom.replaceCssRule=function(e,t,o,n){if(!(o=o||goog.cssom.getParentStyleSheet(e)))throw Error("Cannot proceed without the parentStyleSheet.");if(!(0<=(e=0<=Number(n)?Number(n):goog.cssom.getCssRuleIndexInParentStyleSheet(e,o))))throw Error("Cannot proceed without the index of the cssRule.");goog.cssom.removeCssRule(o,e),goog.cssom.addCssRule(o,t,e)},goog.cssom.addCssRule=function(e,t,o){if((null==o||0>o)&&(o=goog.cssom.getCssRulesFromStyleSheet(e).length),e.insertRule)e.insertRule(t,o);else{if(3!=(t=/^([^\{]+)\{([^\{]+)\}/.exec(t)).length)throw Error("Your CSSRule appears to be ill-formatted.");e.addRule(t[1],t[2],o)}},goog.cssom.removeCssRule=function(e,t){e.deleteRule?e.deleteRule(t):e.removeRule(t)},goog.cssom.addCssText=function(e,t){var o=t||goog.dom.getDomHelper(),n=o.getDocument();return(t=o.createElement("STYLE")).type="text/css",o.getElementsByTagName("HEAD")[0].appendChild(t),t.styleSheet?t.styleSheet.cssText=e:(e=n.createTextNode(e),t.appendChild(e)),t},goog.cssom.getFileNameFromStyleSheet=function(e){return(e=e.href)?/([^\/\?]+)[^\/]*$/.exec(e)[1]:null},goog.cssom.getAllCss_=function(e,t){for(var o=[],n=goog.cssom.getAllCssStyleSheets(e),i=0;e=n[i];i++){var r=goog.cssom.getCssRulesFromStyleSheet(e);if(r&&r.length)for(var l,s=0,a=0,g=r.length;a<g;a++)l=r[a],t&&!l.href?(l=goog.cssom.getCssTextFromCssRule(l),o.push(l)):l.href||(l.style&&(l.parentStyleSheet||(l.style["-closure-parent-stylesheet"]=e),l.style["-closure-rule-index"]=t?void 0:s),o.push(l)),t||s++}return t?o.join(" "):o},Blockly.Css={},Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed"},Blockly.Css.currentCursor_="",Blockly.Css.styleSheet_=null,Blockly.Css.inject=function(e){var t=Blockly.Css.CONTENT.join("\n");t=t.replace(/%CONTAINER_ID%/g,e.id).replace(/%TREE_PATH%/g,Blockly.assetUrl("media/tree.png")).replace(/%CURSOR_OPEN_PATH%/g,Blockly.assetUrl("media/handopen.cur")).replace(/%CURSOR_CLOSED_PATH%/g,Blockly.assetUrl("media/handclosed.cur")),Blockly.Css.styleSheet_=goog.cssom.addCssText(t).sheet},Blockly.Css.setCursor=function(e,t){Blockly.readOnly||Blockly.Css.currentCursor_===e||(Blockly.Css.currentCursor_=e,t&&(e==Blockly.Css.Cursor.OPEN?Blockly.removeClass_(t.parentNode,"dragging"):Blockly.addClass_(t.parentNode,"dragging")))},Blockly.Css.CONTENT=[".blocklyFieldAngleTextInput {","  border: 1px solid #ccc;","  margin-top: -10px;","}",".blocklyFieldAngleDropdown {","  box-shadow: 4px 4px 6px #bbb;","  border-style: solid;","  border-width: 1px;","}",".blocklyFieldAngleDropdown > div {","  float: left;","}",".blocklyFieldAngleDropdown .goog-menu {","  box-shadow: none;","  border-style: none;","}",".blocklyFieldAngleDropdown .goog-menu::after {","  content: '';","  border-left: 1px solid #949ca2;","  position: absolute;","  height: 80%;","  right: 0;","  top: 10%;","}",".blocklyLimit rect {"," fill: #a69bc1;","}",".blocklyLimit.overLimit rect {"," fill: #daa53a;","}",".blocklyLimit .blocklyText {"," font-size: 10pt;"," fill: #fff;","}",".blocklyUnused .blocklyLimit rect {"," fill: #c6cacd;","}",".blocklyUnused .blocklyLimit .blocklyText {"," fill: #5b6770","}",".blocklyUnused .blocklyPath, .blocklyUnused .blocklyPathDark, .blocklyUnused .blocklyPathLight, .blocklyUnused .blocklyEditableText {"," opacity: 0.25;","}",".blocklyUnused .blocklyUnusedFrame {"," transition: opacity 2s;"," opacity: 0.8;","}",".blocklyUnused .blocklyUnusedFrame .blocklyText {"," fill: #000;","}",".blocklyUnused .blocklyUnusedFrame.hidden {"," opacity: 0;"," visibility: hidden","}",".blocklyUnused .blocklyHelp {"," cursor: default;","}",".blocklyUnused .blocklyHelp .blocklyText {"," fill: #fff;"," font-size: 10pt;"," text-anchor: middle;"," dominant-baseline: central;","}",".blocklyDraggable {","  cursor: url(%CURSOR_OPEN_PATH%) 8 5, auto;","}",".dragging, .dragging .blocklySvg, .dragging .blocklyDraggable {","  cursor: url(%CURSOR_CLOSED_PATH%) 7 3, auto !important;","}","#%CONTAINER_ID% {","  border: 1px solid #ddd;","}","#%CONTAINER_ID% .userHidden {","  display: none;","}","#%CONTAINER_ID% .hiddenFlyout, #blocklyDragCanvas .hiddenFlyout, .readOnlyBlockSpace .hiddenFlyout {","  display: none !important;","}","#%CONTAINER_ID%.edit .userHidden {","  display: inline;","  fill-opacity: 0.5;","}","#%CONTAINER_ID%.edit .userHidden .blocklyPath {","  fill-opacity: 0.5;","}","#%CONTAINER_ID%.edit .userHidden .blocklyPathDark, #%CONTAINER_ID%.edit .userHidden .blocklyPathLight {","  display: none;","}",".blocklySvg {","  cursor: default;","  background-color: #fff;","  overflow: hidden;","}",".blocklySvg.inline {","  vertical-align: top;","}","g.blocklyDraggable {","  -ms-touch-action: none;","  touch-action: none;","}",".blocklyWidgetDiv {","  position: absolute;","  display: none;","  z-index: 999;","}",".blocklyResizeSE {","  fill: #aaa;","  cursor: se-resize;","}",".blocklyResizeSW {","  fill: #aaa;","  cursor: sw-resize;","}",".blocklyResizeLine {","  stroke-width: 1;","  stroke: #888;","}",".blocklyHighlightedConnectionPath {","  stroke-width: 4px;","  stroke: #fc3;","  fill: none;","}",".blocklyPathLight {","  fill: none;","  stroke-width: 2;","  stroke-linecap: round;","}",".blocklyTypeHint {","  fill: none;","  stroke-width: 5;","}",".blocklySelected>.blocklyTypeHint, .blocklyUnused .blocklyTypeHint {","  display: none;","}",".blocklySpotlight>.blocklyPath {","  fill: #fc3;","}",".blocklySelected>.blocklyPath {","  stroke-width: 3px;","  stroke: #fc3;","}",".blocklySelected>.blocklyPathLight {","  display: none;","}",".blocklyUndeletable>.blocklyEditableText>rect {","  fill-opacity: 1.0;","  fill: #ffdb74;","}","#blocklyDragCanvas {","  display: none;","  pointer-events: none;","  position: absolute;","  top: -1px;","  left: -1px;","  border: 1px solid #fff;","  z-index: 10;","  direction: ltr;","}","#blocklyDragCanvas.isDragging {","  display: block;","}",".blocklyDragging>.blocklyPath,",".blocklyDragging>.blocklyPathLight {","  fill-opacity: 0.8;","  stroke-opacity: 0.8;","}",".blocklyDragging>.blocklyPathDark {","  display: none;","}",".blocklyDisabled>.blocklyPath {","  fill-opacity: 0.50;","  stroke-opacity: 0.50;","}",".blocklyDisabled>.blocklyPathLight,",".blocklyDisabled>.blocklyPathDark {","  display: none;","}",".blocklyText {","  cursor: pointer;","  font-family: sans-serif;","  font-size: 11pt;","  fill: #fff;","}",".innerModalDiv {","  pointer-events: none !important;","}",".innerModalDiv .goog-flat-menu-button,",".innerModalDiv textarea,",".innerModalDiv input,",".innerModalDiv button {","  pointer-events: auto;","}",".flyoutColorGray {","  background-color: #DDD;","}",".contractEditor #paramAddButton {","  margin-top: 3px;","  margin-left: 10px;","  margin-bottom: 4px;","}",".contractEditorHeaderText {","  cursor: pointer;","  font-size: 12pt;","  fill: #fff;","}",".contract-type-hint {","  color: #898989;","  font-size: 11px;","}",".exampleAreaDiv {","  pointer-events: none;","}",".callResultText {","  color: #000;","  position: absolute;","}",".exampleAreaButton {","  pointer-events: initial;","  position: absolute;","}",".core-clearfix {","  overflow: auto;","}",".testButton {","  padding: 3px 0 !important;","  min-width: 95px !important;","}",".resetButton {","  border: 1px solid #0094ca !important;","  background-color: #0094ca !important;","}",".example-result-text {","  position: absolute;","  font-size: 16px;","}",".color-square-icon {","  float: left;","  width: 21px;","  height: 18px;","  margin-right: 9px !important;","  margin-left: 6px !important;","}",".goog-menuitem .color-square-icon {","  margin-left: -3px !important;","  margin-top: 2px !important;","}",".blocklyNonEditableText>text {","  pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {","  fill: #fff;","  fill-opacity: 0.6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {","  fill: #000;","}",".blocklyEditableText:hover>rect {","  stroke-width: 2;","  stroke: #fff;","}","/*"," * Don't allow users to select text.  It gets annoying when trying to"," * drag a block and selected text moves instead."," */",".blocklySvg text {","  -moz-user-select: none;","  -webkit-user-select: none;","  user-select: none;","  cursor: inherit;","}",".blocklyHidden {","  display: none;","}",".blocklyFieldDropdown:not(.blocklyHidden) {","  display: block;","}",".blocklyTooltipBackground {","  fill: #ffffc7;","  stroke-width: 1px;","  stroke: #d8d8d8;","}",".blocklyTooltipShadow,",".blocklyContextMenuShadow,",".blocklyDropdownMenuShadow {","  fill: #bbb;","  filter: url(#blocklyShadowFilter);","}",".blocklyTooltipText {","  font-family: sans-serif;","  font-size: 9pt;","  fill: #000;","}","#modalEditorClose:hover>rect {","  fill: #0094ca;","}",".svgTextButton:hover>rect {","  fill: #0094ca;","}",".blocklyIconShield {","  fill: #00c;","  stroke-width: 1px;","  stroke: #ccc;","}",".blocklyIconGroup:not(.readonly):hover>.blocklyIconShield {","  fill: #00f;","  stroke: #fff;","  cursor: pointer;","}",".blocklyIconGroup:not(.readonly):hover>.blocklyIconMark {","  fill: #fff;","  cursor: pointer;","}",".blocklyIconGroup>.blocklyText {","  font-size:9pt;","  cursor: pointer;","}",".blocklyIconGroup.readonly>.blocklyText {","  cursor: default;","}",".blocklyIconMark {","  font-family: sans-serif;","  font-size: 9pt;","  font-weight: bold;","  fill: #ccc;","  text-anchor: middle;","}",".blocklyWarningBody {","}",".blocklyMinimalBody {","  margin: 0;","  padding: 0;","}",".blocklyHtmlInput {","  font-family: sans-serif;","  font-size: 11pt;","  border: none;","  outline: none;","  width: 100%;","  -moz-appearance: textfield;","}",".blocklyHtmlInput::-webkit-inner-spin-button, .blocklyHtmlInput::-webkit-outer-spin-button {","  -webkit-appearance: none;","}",".blocklyContextMenuBackground,",".blocklyMutatorBackground {","  fill: #fff;","  stroke-width: 1;","  stroke: #ddd;","}",".newFunctionDiv {","  position: absolute;","  top: 120px;","  left: 600px;","}","#modalContainer .goog-flat-menu-button-caption {","  color: #555555;","  margin-left: 1px;","  margin-right: 0;","  min-width: 55px;","}",".blocklyContextMenuOptions>.blocklyMenuDiv,",".blocklyContextMenuOptions>.blocklyMenuDivDisabled,",".blocklyDropdownMenuOptions>.blocklyMenuDiv {","  fill: #fff;","}",".blocklyContextMenuOptions>.blocklyMenuDiv:hover>rect,",".blocklyDropdownMenuOptions>.blocklyMenuDiv:hover>rect {","  fill: #57e;","}",".blocklyMenuSelected>rect {","  fill: #57e;","}",".blocklyMenuText {","  cursor: pointer !important;","  font-family: sans-serif;","  font-size: 15px; /* All context menu sizes are based on pixels. */","  fill: #000;","}",".blocklyContextMenuOptions>.blocklyMenuDiv:hover>.blocklyMenuText,",".blocklyDropdownMenuOptions>.blocklyMenuDiv:hover>.blocklyMenuText {","  fill: #fff;","}",".blocklyMenuSelected>.blocklyMenuText {","  fill: #fff;","}",".blocklyMenuDivDisabled>.blocklyMenuText {","  fill: #ccc;","}",".blocklyFlyoutBackground {","  fill: #ddd;","  fill-opacity: 0.8;","}",".blocklyToolboxBackground {","  fill: #ddd;","}",".blocklyBackground {","  fill: #666;","}",".blocklyScrollbarBackground {","  fill: #fff;","  stroke-width: 1;","  stroke: #e4e4e4;","}",".blocklyScrollbarKnob {","  fill: #ccc;","}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {","  fill: #bbb;","}",".blocklyInvalidInput {","  background: #faa;","}",".blocklyAngleCircle {","  stroke: #444;","  stroke-width: 1;","  fill: #ddd;","  fill-opacity: 0.8;","}",".blocklyAngleMarks {","  stroke: #444;","  stroke-width: 1;","}",".blocklyAngleGuage {","  fill: #d00;","  fill-opacity: 0.8;  ","}",".blocklyContextMenu {","  border-radius: 4px;","}",".blocklyDropdownMenu {","  padding: 0 !important;","  position: relative !important;","}",".blocklyRectangularDropdownMenu .goog-menuitem {","  height: 100%;","  padding: 0 !important;","  border-radius: 5px;","  margin-bottom: 4px !important;","}",".fieldRectangularDropdownBackdrop {","  fill: #fff;","  fill-opacity: 0.6;","}",".blocklyRectangularDropdownArrow {","  fill: #7965a1;","  font-size: 20px !important;","}",".blocklyRectangularDropdownMenu .goog-menuitem-highlight, .goog-menuitem-hover {","  border-color: #7965a1 !important;","  border-style: dotted !important;","  border-width: 0px !important;","  margin: -4px -4px 0 !important;","  border-width: 4px !important;","  border-style: solid !important;","  padding-bottom: 0px !important;","  padding-top: 0px !important;","}",".colored-type-dropdown .goog-menuitem-content {","  color: #555555;","  float: left;","}",".colored-type-dropdown > .goog-menuitem {","  padding: 0px 40px 2px 13px;","}",".goog-menu {","  box-shadow: 4px 4px 6px #bbb;","  border-width: 2px;","}",".goog-menuitem {","  height: 20px;","  padding-top: 0;","  padding-bottom: 0;","}",".goog-menuitem-highlight,",".goog-menuitem-hover {","  border-width: 0;","  background-color: #57e;","}",".goog-menuitem-highlight .goog-menuitem-content {","  color: #fff;","}",".goog-option-selected .goog-menuitem-checkbox:before {",'  content: "✓";',"}",".goog-menuitem-checkbox {",'  background: ""',"}",".blocklyRectangularDropdownMenu img {","  -webkit-border-radius: 5px;","  -moz-border-radius: 5px;","  border-radius: 5px;","}",".blocklyRectangularDropdownMenu {","  border-radius: 5px;","  box-shadow: none !important;","}",".goog-option-selected .goog-menuitem-checkbox,",".goog-option-selected .goog-menuitem-icon {","}","/* Category tree in Toolbox. */",".blocklyToolboxDiv {","  display: none;","  overflow-x: visible;","  overflow-y: auto;","  position: absolute;","}",".blocklyTreeRoot {","  padding: 4px 0;","}",".blocklyTreeRoot:focus {","  outline: none;","}",".blocklyTreeRow {","  line-height: 22px;","  height: 22px;","  padding-right: 1em;","  white-space: nowrap;","}",'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {',"  padding-right: 0;","  padding-left: 1em !important;","}",".blocklyTreeRow:hover {","  background-color: #e4e4e4;","}",".blocklyTreeIcon {","  height: 16px;","  width: 16px;","  vertical-align: middle;","  background-image: url(%TREE_PATH%);","}",".blocklyTreeIconClosedLtr {","  background-position: -32px -1px;","}",".blocklyTreeIconClosedRtl {","  background-position: 0px -1px;","}",".blocklyTreeIconOpen {","  background-position: -16px -1px;","}",".blocklyTreeIconNone {","  background-position: -48px -1px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedLtr {","  background-position: -32px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedRtl {","  background-position: 0px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconOpen {","  background-position: -16px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconNone {","  background-position: -48px -17px;","}",".blocklyTreeLabel {","  cursor: pointer;","  font-family: sans-serif;","  font-size: 16px;","  padding: 0 3px;","  vertical-align: middle;","  -moz-user-select: none;","  -webkit-user-select: none;","  -ms-user-select: none;","  user-select: none;","}",".blocklyTreeSelected {","  background-color: #57e !important;","}",".blocklyTreeSelected .blocklyTreeLabel {","  color: #fff;","}",".blocklyArrow {","  font-size: 80%;","}",".paramToolbox {","  padding: 0 0 5px 0;","  pointer-events: auto;","}",".paramToolbox input, .paramToolbox textarea {","  box-sizing: border-box;","  width: 100%;","  margin: 0;","  resize: none;","}",".paramToolbox input, .paramToolbox button {","  height: 30px;","  margin: 0;","}",".paramToolbox div {","  margin: 4px 10px;","}","#modalContainer {","  position: absolute;","  width: 100%;","  bottom: 0;","}","#modalContainer > svg {","  position: absolute;","  top: 0;","  left: 0;","  background: transparent;","  pointer-events: none;","}","#modalContainer > svg * {","  pointer-events: visiblePainted;","}","/*"," * Copyright 2007 The Closure Library Authors. All Rights Reserved."," *"," * Use of this source code is governed by the Apache License, Version 2.0."," * See the COPYING file for details."," */","/* Author: pupius@google.com (Daniel Pupius) */","/*"," Styles to make the colorpicker look like the old gmail color picker"," NOTE: without CSS scoping this will override styles defined in palette.css","*/",".goog-palette {","  outline: none;","  cursor: pointer;","}",".goog-palette-table {","  border: 1px solid #666;","  border-collapse: collapse;","}",".goog-palette-cell {","  height: 25px;","  width: 25px;","  margin: 0;","  border: 0;","  text-align: center;","  vertical-align: middle;","  border-right: 1px solid #666;","  font-size: 1px;","}",".goog-palette-colorswatch {","  position: relative;","  height: 25px;","  width: 25px;","  border: 1px solid #666;","}",".goog-palette-cell-hover .goog-palette-colorswatch {","  border: 1px solid #FFF;","}",".goog-palette-cell-selected .goog-palette-colorswatch {","  border: 1px solid #000;","  color: #fff;","}",".goog-menu {","  background: #fff;","  border-color: #ccc #666 #666 #ccc;","  border-style: solid;","  border-width: 1px;","  cursor: pointer;","  font: normal 13px Arial, sans-serif;","  margin: 0;","  outline: none;","  padding: 4px 0;","  position: absolute;","  z-index: 20000;","}",".goog-menuitem {","  color: #000;","  font: normal 13px Arial, sans-serif;","  list-style: none;","  margin: 0;","  padding: 4px 7em 4px 28px;","  white-space: nowrap;","}",".goog-menuitem.goog-menuitem-rtl {","  padding-left: 7em;","  padding-right: 28px;","}",".goog-menu-nocheckbox .goog-menuitem,",".goog-menu-noicon .goog-menuitem {","  padding-left: 12px;","}",".goog-menu-noaccel .goog-menuitem:not(.goog-menuitem-rtl) {","  padding-right: 20px;","}",".goog-menu-noaccel .goog-menuitem.goog-menuitem-rtl {","  padding-left: 20px;","}",".goog-menuitem-content {","  color: #000;","  font-size: 15px;","}",".goog-menuitem-disabled .goog-menuitem-accel,",".goog-menuitem-disabled .goog-menuitem-content {","  color: #ccc !important;","}",".goog-menuitem-disabled .goog-menuitem-icon {","  opacity: 0.3;","  -moz-opacity: 0.3;","  filter: alpha(opacity=30);","}",".goog-menuitem-highlight,",".goog-menuitem-hover {","  background-color: #d6e9f8;","  border-color: #d6e9f8;","  border-style: dotted;","  border-width: 1px 0;","  padding-bottom: 3px;","  padding-top: 3px;","}",".goog-menuitem-checkbox,",".goog-menuitem-icon {","  background-repeat: no-repeat;","  height: 16px;","  left: 6px;","  position: absolute;","  right: auto;","  vertical-align: middle;","  width: 16px;","}",".goog-menuitem-rtl .goog-menuitem-checkbox,",".goog-menuitem-rtl .goog-menuitem-icon {","  left: auto;","  right: 6px;","}",".goog-option-selected .goog-menuitem-checkbox,",".goog-option-selected .goog-menuitem-icon {","}",".goog-menuitem-accel {","  color: #999;","  direction: ltr;","  left: auto;","  padding: 0 6px;","  position: absolute;","  right: 0;","  text-align: right;","}",".goog-menuitem-rtl .goog-menuitem-accel {","  left: 0;","  right: auto;","  text-align: left;","}",".goog-menuitem-mnemonic-hint {","  text-decoration: underline;","}",".goog-menuitem-mnemonic-separator {","  color: #999;","  font-size: 12px;","  padding-left: 4px;","}",".goog-menuseparator {","  border-top: 1px solid #ccc;","  margin: 4px 0;","  padding: 0;","}",".goog-flat-menu-button {","  background-color: #fff;","  border: 1px solid #c9c9c9;","  color: #333;","  cursor: default;","  font: normal 95%;","  list-style: none;","  margin: 0 2px;","  outline: none;","  padding: 1px 4px;","  position: relative;","  text-decoration: none;","  vertical-align: middle;","}",".goog-flat-menu-button-disabled * {","  border-color: #ccc;","  color: #999;","  cursor: pointer;","}",".goog-flat-menu-button-hover {","  border-color: #9cf #69e #69e #7af !important; /* Hover border wins. */","}",".goog-flat-menu-button-active {","  background-color: #bbb;","  background-position: bottom left;","}",".goog-flat-menu-button-focused {","  border-color: #bbb;","}",".goog-flat-menu-button-caption {","  padding-right: 10px;","  vertical-align: top;","}",".goog-flat-menu-button-dropdown {","  /* Client apps may override the URL at which they serve the sprite. */","  background: url(https://ssl.gstatic.com/editor/editortoolbar.png) no-repeat -388px 0;","  position: absolute;","  right: 2px;","  top: 0;","  vertical-align: top;","  width: 7px;","}",".goog-inline-block {","  position: relative;","  display: -moz-inline-box; /* Ignored by FF3 and later. */","  display: inline-block;","}",""],Blockly.WidgetDiv={},Blockly.WidgetDiv.DIV=null,Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.show=function(e,t){Blockly.WidgetDiv.hide(),Blockly.WidgetDiv.owner_=e,Blockly.WidgetDiv.dispose_=t,Blockly.WidgetDiv.DIV.style.display="block"},Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_},Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.dispose_=null,goog.dom.removeChildren(Blockly.WidgetDiv.DIV))},Blockly.WidgetDiv.hideIfOwner=function(e){Blockly.WidgetDiv.isOwner(e)&&Blockly.WidgetDiv.hide()},Blockly.WidgetDiv.isOwner=function(e){return Blockly.WidgetDiv.owner_==e},Blockly.WidgetDiv.position=function(e,t,o,n){t<n.y&&(t=n.y),Blockly.RTL?e>o.width+n.x&&(e=o.width+n.x):e<n.x&&(e=n.x),Blockly.WidgetDiv.DIV.style.left=e+"px",Blockly.WidgetDiv.DIV.style.top=t+"px"},Blockly.inject=function(e,t,o){if(!goog.dom.contains(document,e))throw"Error: container is not in current document.";t&&goog.mixin(Blockly,Blockly.parseOptions_(t)),goog.ui.Component.setDefaultRightToLeft(Blockly.RTL),Blockly.Css.inject(e),o&&(Blockly.audioPlayer=o,Blockly.registerUISounds_(Blockly.audioPlayer)),Blockly.mainBlockSpaceEditor=new Blockly.BlockSpaceEditor(e),Blockly.mainBlockSpace=Blockly.mainBlockSpaceEditor.blockSpace,Blockly.fireUiEvent(document,Blockly.BlockSpace.EVENTS.MAIN_BLOCK_SPACE_CREATED),Blockly.useModalFunctionEditor?Blockly.functionEditor=new Blockly.FunctionEditor:Blockly.useContractEditor&&(Blockly.functionEditor=new Blockly.ContractEditor({disableExamples:t&&t.disableExamples}),Blockly.contractEditor=Blockly.functionEditor),Blockly.focusedBlockSpace=Blockly.mainBlockSpace},Blockly.parseOptions_=function(e){var t,o,n,i=!!e.readOnly,r=!!e.showUnusedBlocks;if(i)var l=n=o=t=!1,s=null;else(s=e.toolbox)?("string"!=typeof s&&"undefined"==typeof XSLTProcessor&&(s=s.outerHTML),"string"==typeof s&&(s=Blockly.Xml.textToDom(s)),t=!!s.getElementsByTagName("category").length):(s=null,t=!1),void 0===(o=e.trashcan)&&(o=t),void 0===(n=e.collapse)&&(n=t),void 0===(l=e.grayOutUndeletableBlocks)&&(l=!1);e.scrollbars&&(e.hasVerticalScrollbars=!0,e.hasHorizontalScrollbars=!0);var a=e.topLevelProcedureAutopopulate||!1;return a&&t&&(console.warn("Don't use topLevelProcedureAutopopulate with a categorized toolbox"),a=!1),{RTL:!!e.rtl,collapse:n,readOnly:i,showUnusedBlocks:r,maxBlocks:e.maxBlocks||1/0,assetUrl:e.assetUrl||function(e){return"./"+e},hasCategories:t,hasHorizontalScrollbars:e.hasHorizontalScrollbars,hasVerticalScrollbars:e.hasVerticalScrollbars,customSimpleDialog:e.customSimpleDialog,hasTrashcan:o,varsInGlobals:e.varsInGlobals||!1,languageTree:s,disableIfElseEditing:e.disableIfElseEditing||!1,disableParamEditing:e.disableParamEditing||!1,disableVariableEditing:e.disableVariableEditing||!1,disableProcedureAutopopulate:e.disableProcedureAutopopulate||!1,topLevelProcedureAutopopulate:a,useModalFunctionEditor:e.useModalFunctionEditor||!1,useContractEditor:e.useContractEditor||!1,disableExamples:e.disableExamples||!1,defaultNumExampleBlocks:e.defaultNumExampleBlocks||0,grayOutUndeletableBlocks:l,editBlocks:e.editBlocks||!1,showExampleTestButtons:e.showExampleTestButtons||!1,valueTypeTabShapeMap:e.valueTypeTabShapeMap||{},typeHints:e.typeHints||!1}},Blockly.registerUISounds_=function(e){e.register({id:"click",mp3:Blockly.assetUrl("media/click.mp3"),wav:Blockly.assetUrl("media/click.wav"),ogg:Blockly.assetUrl("media/click.ogg")}),e.register({id:"delete",mp3:Blockly.assetUrl("media/delete.mp3"),wav:Blockly.assetUrl("media/delete.wav"),ogg:Blockly.assetUrl("media/delete.ogg")})},goog.memoize=function(e,t){var o=t||goog.memoize.simpleSerializer;return function(){if(goog.memoize.ENABLE_MEMOIZE){var t=this||goog.global;t=t[goog.memoize.CACHE_PROPERTY_]||(t[goog.memoize.CACHE_PROPERTY_]={});var n=o(goog.getUid(e),arguments);return t.hasOwnProperty(n)?t[n]:t[n]=e.apply(this,arguments)}return e.apply(this,arguments)}},goog.memoize.ENABLE_MEMOIZE=!0,goog.memoize.clearCache=function(e){e[goog.memoize.CACHE_PROPERTY_]={}},goog.memoize.CACHE_PROPERTY_="closure_memoize_cache_",goog.memoize.simpleSerializer=function(e,t){e=[e];for(var o=t.length-1;0<=o;--o)e.push(typeof t[o],t[o]);return e.join("\v")},Blockly.utils={},Blockly.addClass_=function(e,t){var o=e.getAttribute("class")||"";Blockly.stringContainsClass_(o,t)||(o&&(o+=" "),e.setAttribute("class",o+t))},Blockly.elementHasClass_=function(e,t){return Blockly.stringContainsClass_(e.getAttribute("class")||"",t)},Blockly.stringContainsClass_=function(e,t){return-1!==(" "+e+" ").indexOf(" "+t+" ")},Blockly.removeClass_=function(e,t){var o=e.getAttribute("class");if(-1!=(" "+o+" ").indexOf(" "+t+" ")){o=o.split(/\s+/);for(var n=0;n<o.length;n++)o[n]&&o[n]!=t||(o.splice(n,1),n--);o.length?e.setAttribute("class",o.join(" ")):e.removeAttribute("class")}},Blockly.bindEvent_=function(e,t,o,n,i){i=!!i;var r=[];if(!e.addEventListener)throw"Element is not a DOM node with addEventListener.";var l=function(){n.apply(o,arguments)},s=Blockly.bindEvent_.TOUCH_MAP[t];return s?(window.navigator.pointerEnabled||window.navigator.msPointerEnabled||(e.addEventListener(t,l,i),r.push([e,t,l,i])),l=function(e){if(e.target&&e.target.style){var t=e.target.style;t.touchAction?t.touchAction="none":t.msTouchAction&&(t.msTouchAction="none")}t=e.changedTouches||[e];for(var i=0;i<t.length;++i)e.clientX=t[i].clientX,e.clientY=t[i].clientY,n.apply(o,arguments)},e.addEventListener(s,l,i),r.push([e,s,l,i])):(e.addEventListener(t,l,i),r.push([e,t,l,i])),r},Blockly.bindEvent_.TOUCH_MAP={},window.navigator.pointerEnabled?Blockly.bindEvent_.TOUCH_MAP={mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"}:window.navigator.msPointerEnabled?Blockly.bindEvent_.TOUCH_MAP={mousedown:"MSPointerDown",mousemove:"MSPointerMove",mouseup:"MSPointerUp"}:("ontouchstart"in document.documentElement||0<navigator.maxTouchPoints)&&(Blockly.bindEvent_.TOUCH_MAP={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"}),Blockly.unbindEvent_=function(e){for(;e.length;){var t=e.pop(),o=t[2];t[0].removeEventListener(t[1],o,t[3])}return o},Blockly.fireUiEvent=function(e,t,o){o=o||{};var n=document;if(n.createEvent)n=n.createEvent("UIEvents"),goog.object.extend(n,o),n.initEvent(t,!0,!0),e.dispatchEvent(n);else{if(!n.createEventObject)throw"FireEvent: No event creation mechanism.";n=n.createEventObject(),goog.object.extend(n,o),e.fireEvent("on"+t,n)}},Blockly.noEvent=function(e){e.preventDefault(),e.stopPropagation()},Blockly.getRelativeXY=function(e){var t={x:0,y:0},o=e.getAttribute("x");return o&&(t.x=parseFloat(o)),(o=e.getAttribute("y"))&&(t.y=parseFloat(o)),(e=(e=e.getAttribute("transform"))&&e.match(/translate\(\s*([-\d.]+)([ ,]\s*([-\d.]+)\s*\))?/))&&(t.x+=parseFloat(e[1]),e[3]&&(t.y+=parseFloat(e[3]))),t},Blockly.getSvgXY_=function(e,t){var o=0,n=0;t=t||Blockly.topMostSVGParent(e);do{var i=Blockly.getRelativeXY(e);o+=i.x,n+=i.y,e=e.parentNode}while(e&&e!==t);return{x:o,y:n}},Blockly.getAbsoluteXY_=function(e,t){var o=Blockly.getSvgXY_(e,t);return Blockly.convertCoordinates(o.x,o.y,t||Blockly.topMostSVGParent(e),!1)},Blockly.topMostSVGParent=function(e){for(var t=null;e;)"svg"===e.tagName&&(t=e),e=goog.dom.getParentElement(e);return t||Blockly.mainBlockSpaceEditor.getSVGElement()},Blockly.createSvgElement=function(e,t,o,n){for(var i in n=n||{},e=document.createElementNS(Blockly.SVG_NS,e),t)e.setAttribute(i,t[i]);return document.body.runtimeStyle&&(e.runtimeStyle=e.currentStyle=e.style),o&&(n.belowExisting?goog.dom.insertChildAt(o,e,0):goog.dom.appendChild(o,e)),e},Blockly.isRightButton=function(e){return 2==e.button||e.ctrlKey},Blockly.convertCoordinates=function(e,t,o,n){n&&(e-=window.pageXOffset,t-=window.pageYOffset);var i=o.createSVGPoint();return i.x=e,i.y=t,(e=o.getScreenCTM())||(e=o.getBoundingClientRect(),e=o.createSVGMatrix(e.left,e.top)),n&&(e=e.inverse()),o=i.matrixTransform(e),n||(goog.userAgent.IPAD||goog.userAgent.IPHONE)&&!goog.userAgent.isVersionOrHigher(538)||(o.x+=window.pageXOffset,o.y+=window.pageYOffset),o},Blockly.mouseToSvg=function(e,t){return Blockly.mouseCoordinatesToSvg(e.clientX,e.clientY,t||Blockly.topMostSVGParent(e.target))},Blockly.mouseCoordinatesToSvg=function(e,t,o){return Blockly.convertCoordinates(e+window.pageXOffset,t+window.pageYOffset,o,!0)},Blockly.svgCoordinatesToViewport=function(e,t){return t=t.getMetrics(),new goog.math.Coordinate(e.x-t.absoluteLeft,e.y-t.absoluteTop)},Blockly.viewportCoordinateToBlockSpace=function(e,t){return t=t.getViewportBox(),new goog.math.Coordinate(e.x+t.left,e.y+t.top)},Blockly.shortestStringLength=function(e){if(!e.length)return 0;for(var t=e[0].length,o=1;o<e.length;o++)t=Math.min(t,e[o].length);return t},Blockly.commonWordPrefix=function(e,t){if(!e.length)return 0;if(1==e.length)return e[0].length;var o=0;t=t||Blockly.shortestStringLength(e);for(var n,i,r=0;r<t;r++){for(i=e[0][r],n=1;n<e.length;n++)if(i!=e[n][r])return o;" "==i&&(o=r+1)}for(n=1;n<e.length;n++)if((i=e[n][r])&&" "!=i)return o;return t},Blockly.commonWordSuffix=function(e,t){if(!e.length)return 0;if(1==e.length)return e[0].length;var o=0;t=t||Blockly.shortestStringLength(e);for(var n,i,r=0;r<t;r++){for(i=e[0].substr(-r-1,1),n=1;n<e.length;n++)if(i!=e[n].substr(-r-1,1))return o;" "==i&&(o=r+1)}for(n=1;n<e.length;n++)if((i=e[n].charAt(e[n].length-r-1))&&" "!=i)return o;return t},Blockly.isNumber=function(e){return!!e.match(/^\s*-?\d+(\.\d+)?\s*$/)},Blockly.isMsie=function(){return 0<=window.navigator.userAgent.indexOf("MSIE")},Blockly.isTrident=function(){return 0<=window.navigator.userAgent.indexOf("Trident")},Blockly.isIOS=function(){return/iP(hone|od|ad)/.test(navigator.platform)},Blockly.ieVersion=function(){return document.documentMode},Blockly.mixColoursWithForegroundOpacity=function(e,t,o){return e=goog.color.hexToRgb(e),t=goog.color.hexToRgb(t),goog.color.rgbToHex(Math.round(t[0]*(1-o)+e[0]*o),Math.round(t[1]*(1-o)+e[1]*o),Math.round(t[2]*(1-o)+e[2]*o))},Blockly.printerRangeToNumbers=function(e){e=e.replace(/ /g,"").split(",");for(var t=[],o=/^(\d+)-(\d+)$/,n=/^(\d+)$/,i=0;i<e.length;i++){var r=e[i],l=o.exec(r);r=n.exec(r),l?(l=goog.array.range(Number(l[1]),Number(l[2])+1),t=t.concat(l)):r&&t.push(Number(r[1]))}return t},Blockly.getUID=function(){return goog.events.getUniqueId("blocklyUID")},Blockly.isTargetInput=function(e){return"textarea"==e.target.type||"text"==e.target.type||"tel"==e.target.type},Blockly.blockContextMenu=function(e){Blockly.isTargetInput(e)||e.preventDefault()},Blockly.getNormalizedWheelDeltaY=function(e){return(e=e.deltaY||-e.wheelDeltaY)?(goog.userAgent.GECKO&&(e*=10),e):null},Blockly.getBoxOverflow=function(e,t){return new goog.math.Box(Math.max(0,e.top-t.top),Math.max(0,t.right-e.right),Math.max(0,t.bottom-e.bottom),Math.max(0,e.left-t.left))},Blockly.getPointBoxOverflow=function(e,t){return new goog.math.Box(e.top-t.y,t.x-e.right,t.y-e.bottom,e.left-t.x)},Blockly.isBoxWiderThan=function(e,t){return Blockly.getBoxWidth(e)>Blockly.getBoxWidth(t)},Blockly.isBoxTallerThan=function(e,t){return Blockly.getBoxHeight(e)>Blockly.getBoxHeight(t)},Blockly.getBoxWidth=function(e){return e.right-e.left},Blockly.getBoxHeight=function(e){return e.bottom-e.top},Blockly.numberWithin=function(e,t,o,n){return n?e>=t&&e<=o:e>t&&e<o},Blockly.svgRectToRect=function(e){return new goog.math.Rect(e.x,e.y,e.width,e.height)},Blockly.showSimpleDialog=function(e){Blockly.customSimpleDialog&&Blockly.customSimpleDialog(e)},Blockly.BOX_DIRECTIONS=["top","right","bottom","left"],Blockly.addToNonZeroSides=function(e,t){Blockly.BOX_DIRECTIONS.forEach(function(o){0!==e[o]&&(e[o]+=t)})},Blockly.svgIgnoreMouseEvents=function(e){e.style.pointerEvents="none"},Blockly.fireTestClickSequence=function(e){Blockly.fireTestMouseEvent(e,"mousedown"),Blockly.fireTestMouseEvent(e,"mouseup"),Blockly.fireTestMouseEvent(e,"click")},Blockly.fireTestMouseEvent=function(e,t){if(!document.createEvent)throw"fireTestMouseEvent is only for testing in browsers with createEvent";e.dispatchEvent(Blockly.makeTestMouseEvent(t))},Blockly.makeTestMouseEvent=function(e){var t=document.createEvent("MouseEvents");return t.initMouseEvent(e,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),t},Blockly.findEmptyContainerBlock=function(e){for(var t=0;t<e.length;t++){var o=e[t];if(Blockly.findEmptyInput(o,Blockly.NEXT_STATEMENT))return o}return null},Blockly.findEmptyInput=function(e,t){return goog.array.find(e.inputList,function(e){return e.type===t&&!e.connection.targetConnection})},Blockly.aggregateCounts=function(e){return e.reduce(function(e,t){return e[t]=(e[t]||0)+1,e},{})},Blockly.Blocks.colour={},Blockly.Blocks.colour_picker={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_PICKER_HELPURL),this.appendDummyInput().appendTitle(new Blockly.FieldColour("#ff0000"),"COLOUR"),this.setOutput(!0,Blockly.BlockValueType.COLOUR),this.setTooltip(Blockly.Msg.COLOUR_PICKER_TOOLTIP)}},Blockly.Blocks.colour_random={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_RANDOM_HELPURL),this.appendDummyInput().appendTitle(Blockly.Msg.COLOUR_RANDOM_TITLE),this.setOutput(!0,Blockly.BlockValueType.COLOUR),this.setTooltip(Blockly.Msg.COLOUR_RANDOM_TOOLTIP)}},Blockly.Blocks.colour_rgb={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL),this.appendValueInput("RED").setCheck(Blockly.BlockValueType.NUMBER).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_RGB_TITLE).appendTitle(Blockly.Msg.COLOUR_RGB_RED),this.appendValueInput("GREEN").setCheck(Blockly.BlockValueType.NUMBER).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_RGB_GREEN),this.appendValueInput("BLUE").setCheck(Blockly.BlockValueType.NUMBER).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_RGB_BLUE),this.setOutput(!0,Blockly.BlockValueType.COLOUR),this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP)}},Blockly.Blocks.colour_blend={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL),this.appendValueInput("COLOUR1").setCheck(Blockly.BlockValueType.COLOUR).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_BLEND_TITLE).appendTitle(Blockly.Msg.COLOUR_BLEND_COLOUR1),this.appendValueInput("COLOUR2").setCheck(Blockly.BlockValueType.COLOUR).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_BLEND_COLOUR2),this.appendValueInput("RATIO").setCheck(Blockly.BlockValueType.NUMBER).setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.COLOUR_BLEND_RATIO),this.setOutput(!0,Blockly.BlockValueType.COLOUR),this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP)}},Blockly.Blocks.functionalExamples={},Blockly.Blocks.functional_example={shouldHideIfInMainBlockSpace:function(){return!0},isCopyable:function(){return!1},init:function(){this.setHSV(0,0,.49),this.setFunctional(!0,{headerHeight:0,rowBuffer:3}),this.setFunctionalOutput(!1),this.appendFunctionalInput("ACTUAL").setAlign(Blockly.ALIGN_CENTRE),this.appendFunctionalInput("EXPECTED").setAlign(Blockly.ALIGN_CENTRE).setInline(!0),this.setTooltip(Blockly.Msg.EXAMPLE_DESCRIPTION)},mutationToDom:function(){},domToMutation:function(){},updateOutputType:function(e){this.outputType_=e,this.changeFunctionalOutput(this.outputType_)},updateInputsToType:function(e){this.updateInputType_(this.getInput("EXPECTED"),e),this.updateInputType_(this.getInput("ACTUAL"),e),this.render()},updateInputType_:function(e,t){e.setHSV.apply(e,Blockly.FunctionalTypeColors[t]),e.setCheck(t)}},Blockly.Blocks.variables={},Blockly.Blocks.variables_get={init:function(){var e=new Blockly.FieldLabel(Blockly.Msg.VARIABLES_GET_ITEM);e.EDITABLE=!0,this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL),this.setHSV(312,.32,.62),this.appendDummyInput().appendTitle(Blockly.Msg.VARIABLES_GET_TITLE).appendTitle(Blockly.disableVariableEditing?e:new Blockly.FieldVariable(Blockly.Msg.VARIABLES_GET_ITEM),"VAR").appendTitle(Blockly.Msg.VARIABLES_GET_TAIL),this.setOutput(!0),this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP)},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")},removeVar:function(e){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.dispose(!0,!0)},contextMenuType_:"variables_set",customContextMenu:function(e){var t={enabled:!0},o=this.getTitleValue("VAR");t.text=Blockly.Msg.VARIABLES_GET_CREATE_SET.replace("%1",o),(o=goog.dom.createDom("title",null,o)).setAttribute("name","VAR"),(o=goog.dom.createDom("block",null,o)).setAttribute("type",this.contextMenuType_),t.callback=Blockly.ContextMenu.callbackFactory(this,o),e.push(t)}},Blockly.Blocks.variables_set={init:function(){var e=new Blockly.FieldLabel(Blockly.Msg.VARIABLES_SET_ITEM);e.EDITABLE=!0,this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL),this.setHSV(312,.32,.62),this.appendValueInput("VALUE").appendTitle(Blockly.Msg.VARIABLES_SET_TITLE).appendTitle(Blockly.disableVariableEditing?e:new Blockly.FieldVariable(Blockly.Msg.VARIABLES_SET_ITEM),"VAR").appendTitle(Blockly.Msg.VARIABLES_SET_TAIL),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP)},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")},contextMenuMsg_:Blockly.Msg.VARIABLES_SET_CREATE_GET,contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu},Blockly.Blocks.parameters_get={init:function(){var e=new Blockly.FieldLabel(Blockly.Msg.VARIABLES_GET_ITEM);e.EDITABLE=!0,this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL),this.setHSV(7,.8,.95),this.appendDummyInput().appendTitle(Blockly.Msg.VARIABLES_GET_TITLE).appendTitle(Blockly.disableVariableEditing?e:new Blockly.FieldParameter(Blockly.Msg.VARIABLES_GET_ITEM),"VAR").appendTitle(Blockly.Msg.VARIABLES_GET_TAIL),this.setOutput(!0),this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP)},mutationToDom:function(){var e=this.outputConnection.getCheck();if(e&&1===e.length){var t=document.createElement("mutation");return t.setAttribute("output",e[0]),t}},domToMutation:function(e){(e=e.getAttribute("output"))&&(this.setColour(null),this.outputConnection.setCheck(e,!!Blockly.valueTypeTabShapeMap[e]))},renameVar:function(e,t){Blockly.FunctionEditor.allFunctionEditors.forEach(function(o){o.isOpen()&&(o.renameParameter(e,t),o.refreshParamsEverywhere())})},removeVar:Blockly.Blocks.variables_get.removeVar},Blockly.Blocks.functionalParameters={},Blockly.Blocks.functional_parameters_get={init:function(){var e=new Blockly.FieldLabel(Blockly.Msg.VARIABLES_GET_ITEM);e.EDITABLE=!0,this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL),this.setHSV(312,.32,.62),this.setFunctional(!0),this.appendDummyInput().appendTitle(Blockly.Msg.VARIABLES_GET_TITLE).appendTitle(e,"VAR").appendTitle(Blockly.Msg.VARIABLES_GET_TAIL).setAlign(Blockly.ALIGN_CENTRE),this.setFunctionalOutput(!0),this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP)},renameVar:function(e,t){if(Blockly.functionEditor){var o=this.getTitle_("VAR");o.getText()===e&&o.setText(t)}},removeVar:Blockly.Blocks.variables_get.removeVar,mutationToDom:function(){var e=document.createElement("mutation");if(this.description_){var t=document.createElement("description");t.textContent=this.description_,e.appendChild(t)}return this.outputType_&&((t=document.createElement("outputtype")).textContent=this.outputType_,e.appendChild(t)),e},domToMutation:function(e){for(var t,o=0;t=e.childNodes[o];o++){var n=t.nodeName.toLowerCase();"description"===n?this.description_=t.textContent:"outputtype"===n&&(this.outputType_=t.textContent,this.changeFunctionalOutput(this.outputType_))}}},Blockly.Blocks.procedures={},Blockly.Block.createProcedureDefinitionBlock=function(e){(e=e||{}).overrides=e.overrides||{};var t={shouldHideIfInMainBlockSpace:function(){return Blockly.useModalFunctionEditor},init:function(){var t=!Blockly.disableParamEditing&&!Blockly.useModalFunctionEditor;this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.setHSV(94,.84,.6);var o=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,this);this.appendDummyInput().appendTitle(t?"":" ").appendTitle(new Blockly.FieldTextInput(o,Blockly.Procedures.rename),"NAME").appendTitle("","PARAMS"),this.appendStatementInput("STACK").appendTitle(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),t&&this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"])),this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setFramed(this.blockSpace===Blockly.mainBlockSpace&&!this.blockSpace.isReadOnly()),this.parameterNames_=[],this.parameterTypes_=[],e.initPostScript&&e.initPostScript(this)},updateParams_:function(){for(var e=!1,t={},o=0;o<this.parameterNames_.length;o++){if(t["arg_"+this.parameterNames_[o].toLowerCase()]){e=!0;break}t["arg_"+this.parameterNames_[o].toLowerCase()]=!0}e?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null),e="",this.parameterNames_.length&&(e=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.parameterNames_.join(", ")),this.setTitleValue(e,"PARAMS")},mutationToDom:function(){for(var e=document.createElement("mutation"),t=0;t<this.parameterNames_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.parameterNames_[t]),this.parameterTypes_&&this.parameterTypes_[t]&&o.setAttribute("type",this.parameterTypes_[t]),e.appendChild(o)}return this.description_&&((t=document.createElement("description")).textContent=this.description_,e.appendChild(t)),e},domToMutation:function(e){this.parameterNames_=[];for(var t,o=0;t=e.childNodes[o];o++){var n=t.nodeName.toLowerCase();"arg"===n?(this.parameterNames_.push(t.getAttribute("name")),(t=t.getAttribute("type"))&&(this.parameterTypes_||(this.parameterTypes_=[]),this.parameterTypes_[this.parameterNames_.length-1]=t)):"description"===n&&(this.description_=t.textContent)}this.updateParams_()},decompose:function(e){var t=new Blockly.Block(e,"procedures_mutatorcontainer");t.initSvg();for(var o=t.getInput("STACK").connection,n=0;n<this.parameterNames_.length;n++){var i=new Blockly.Block(e,"procedures_mutatorarg");i.initSvg(),i.setTitleValue(this.parameterNames_[n],"NAME"),i.setTitleValue(this.parameterTypes_[n],"TYPE"),i.oldLocation=n,o.connect(i.previousConnection),o=i.nextConnection}return Blockly.Procedures.mutateCallers(this.getTitleValue("NAME"),this.blockSpace,this.parameterNames_,null),t},compose:function(e){e=e.getInputTargetBlock("STACK");for(var t=[],o=[],n=[];e;)t.push(e.getTitleValue("NAME")),o.push(e.getTitleValue("TYPE")),n.push(e.id),e=e.nextConnection&&e.nextConnection.targetBlock();this.updateParamsFromArrays(t,n,o)},updateParamsFromArrays:function(e,t,o){this.parameterNames_=goog.array.clone(e),this.parameterTypes_=goog.array.clone(o),this.paramIds_=t?goog.array.clone(t):null,this.updateParams_(),this.updateCallerParams_()},updateCallerParams_:function(){Blockly.Procedures.mutateCallers(this.getTitleValue("NAME"),this.blockSpace,this.parameterNames_,this.paramIds_,this.parameterTypes_)},dispose:function(e,t,o){if(!o){var n=this.getTitleValue("NAME");Blockly.Procedures.disposeCallers(n,this.blockSpace)}Blockly.Block.prototype.dispose.apply(this,arguments)},getProcedureInfo:function(){return{name:this.getTitleValue("NAME"),id:this.getTitle_("NAME").id,parameterNames:this.parameterNames_,parameterIDs:this.paramIds_,parameterTypes:this.parameterTypes_,type:this.type,callType:this.callType_}},getVars:function(){return{Default:this.parameterNames_}},renameVar:function(e,t){var o,n=!1;for(o=0;o<this.parameterNames_.length;o++)Blockly.Names.equals(e,this.parameterNames_[o])&&(this.parameterNames_[o]=t,n=!0);if(n&&(this.updateParams_(),this.mutator&&this.mutator.isVisible()))for(n=this.mutator.blockSpace_.getAllBlocks(),o=0;o<n.length;o++){var i=n[o];"procedures_mutatorarg"==i.type&&Blockly.Names.equals(e,i.getTitleValue("NAME"))&&i.setTitleValue(t,"NAME")}},removeVar:function(e){-1<(e=this.parameterNames_.indexOf(e))&&(this.parameterNames_.splice(e,1),this.parameterTypes_&&this.parameterTypes_.splice(e,1),this.updateParams_())},customContextMenu:function(e){var t={enabled:!0},o=this.getTitleValue("NAME");t.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",o);var n,i=goog.dom.createDom("mutation");for(i.setAttribute("name",o),n=0;n<this.parameterNames_.length;n++)(o=goog.dom.createDom("arg")).setAttribute("name",this.parameterNames_[n]),i.appendChild(o);for((i=goog.dom.createDom("block",null,i)).setAttribute("type",this.callType_),t.callback=Blockly.ContextMenu.callbackFactory(this,i),e.push(t),n=0;n<this.parameterNames_.length;n++)t={enabled:!0},o=this.parameterNames_[n],t.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",o),(i=goog.dom.createDom("title",null,o)).setAttribute("name","VAR"),(i=goog.dom.createDom("block",null,i)).setAttribute("type","variables_get"),t.callback=Blockly.ContextMenu.callbackFactory(this,i),e.push(t)},userCreated:!1,shouldBeGrayedOut:function(){return!1},callType_:"procedures_callnoreturn"};return goog.object.extend(t,e.overrides),t},Blockly.Blocks.procedures_defnoreturn=Blockly.Block.createProcedureDefinitionBlock(),Blockly.Blocks.procedures_defreturn={shouldHideIfInMainBlockSpace:function(){return Blockly.useModalFunctionEditor},init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL),this.setHSV(94,.84,.6);var e=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,this);this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendTitle(new Blockly.FieldTextInput(e,Blockly.Procedures.rename),"NAME").appendTitle("","PARAMS"),this.appendStatementInput("STACK").appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_DO),this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"])),this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP),this.setFramed(this.blockSpace===Blockly.mainBlockSpace&&!this.blockSpace.isReadOnly()),this.parameterNames_=[]},updateParams_:Blockly.Blocks.procedures_defnoreturn.updateParams_,updateCallerParams_:Blockly.Blocks.procedures_defnoreturn.updateCallerParams_,updateParamsFromArrays:Blockly.Blocks.procedures_defnoreturn.updateParamsFromArrays,mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,dispose:Blockly.Blocks.procedures_defnoreturn.dispose,getProcedureInfo:function(){return{name:this.getTitleValue("NAME"),parameterNames:this.parameterNames_,parameterIDs:this.paramIds_,type:this.type,callType:this.callType_}},getVars:Blockly.Blocks.procedures_defnoreturn.getVars,renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,userCreated:Blockly.Blocks.procedures_defnoreturn.userCreated,shouldBeGrayedOut:Blockly.Blocks.procedures_defnoreturn.shouldBeGrayedOut,callType_:"procedures_callreturn"},Blockly.Blocks.procedures_mutatorcontainer={init:function(){this.setHSV(94,.84,.6),this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.setTooltip(""),this.contextMenu=!1}},Blockly.Blocks.procedures_mutatorarg={init:function(){this.setHSV(94,.84,.6),this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendTitle(new Blockly.FieldTextInput("x",this.validator),"NAME"),Blockly.valueTypeTabShapeMap&&(this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_MUTATORARG_TYPE).appendTitle(new Blockly.FieldDropdown(function(){return goog.object.getValues(Blockly.BlockValueType).map(function(e){return[e,e]})}),"TYPE"),this.setInputsInline(!0)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(""),this.contextMenu=!1}},Blockly.Blocks.procedures_mutatorarg.validator=function(e){return(e=e.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""))||null},Blockly.Blocks.procedures_callnoreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL),this.setHSV(94,.84,.6);var e=this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL).appendTitle("","NAME");if(Blockly.useModalFunctionEditor){var t=new Blockly.FieldIcon(Blockly.Msg.FUNCTION_EDIT);Blockly.bindEvent_(t.fieldGroup_,"mousedown",this,this.openEditor),e.appendTitle(t)}this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP),this.currentParameterNames_=[],this.currentParameterIDs=this.parameterIDsToArgumentConnections=null},openEditor:function(e){e.stopPropagation(),Blockly.functionEditor.openEditorForCallBlock_(this)},getCallName:function(){return this.getTitleValue("NAME")},renameProcedure:function(e,t){Blockly.Names.equals(e,this.getTitleValue("NAME"))&&(this.setTitleValue(t,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",t)))},setProcedureParameters:function(e,t,o){if(t){if(t.length!=e.length)throw"Error: paramNames and paramIds must be the same length.";this.currentParameterIDs||(this.parameterIDsToArgumentConnections={},e.join("\n")==this.currentParameterNames_.join("\n")?this.currentParameterIDs=t:this.currentParameterIDs=[]);var n,i,r=this.rendered;for(this.rendered=!1,n=this.currentParameterNames_.length-1;0<=n;n--)if(i=this.getInput("ARG"+n)){var l=i.connection.targetConnection;this.parameterIDsToArgumentConnections[this.currentParameterIDs[n]]=l,this.removeInput("ARG"+n)}for(this.currentParameterNames_=[].concat(e),this.currentParameterIDs=t,this.currentParameterTypes_=o,n=0;n<this.currentParameterNames_.length;n++)i=this.appendValueInput("ARG"+n).setAlign(Blockly.ALIGN_RIGHT).appendTitle(this.currentParameterNames_[n]),this.currentParameterIDs&&((e=this.currentParameterIDs[n])in this.parameterIDsToArgumentConnections&&(!(l=this.parameterIDsToArgumentConnections[e])||l.targetConnection||l.sourceBlock_.blockSpace!=this.blockSpace?delete this.parameterIDsToArgumentConnections[e]:i.connection.connect(l))),i.setStrictCheck(this.currentParameterTypes_[n]);(this.rendered=r)&&(this.render(),this.bumpNeighbours())}else this.parameterIDsToArgumentConnections={},this.currentParameterIDs=null},mutationToDom:function(){var e=document.createElement("mutation");e.setAttribute("name",this.getTitleValue("NAME"));for(var t=0;t<this.currentParameterNames_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.currentParameterNames_[t]),this.currentParameterTypes_[t]&&o.setAttribute("type",this.currentParameterTypes_[t]),e.appendChild(o)}return e},domToMutation:function(e){var t=e.getAttribute("name");if(this.setTitleValue(t,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",t)),(t=Blockly.Procedures.getDefinition(t,this.blockSpace))&&t.mutator&&t.mutator.isVisible())e=t.getProcedureInfo(),this.setProcedureParameters(e.parameterNames,e.parameterIDs,e.parameterTypes);else{this.currentParameterNames_=[],this.currentParameterTypes_=[],t=0;for(var o;o=e.childNodes[t];t++)"arg"==o.nodeName.toLowerCase()&&(this.currentParameterNames_.push(o.getAttribute("name")),this.currentParameterTypes_.push(o.getAttribute("type")));this.setProcedureParameters(this.currentParameterNames_,this.currentParameterNames_,this.currentParameterTypes_)}},renameVar:function(e,t){for(var o=0;o<this.currentParameterNames_.length;o++)Blockly.Names.equals(e,this.currentParameterNames_[o])&&(this.currentParameterNames_[o]=t,this.getInput("ARG"+o).titleRow[0].setText(t))},customContextMenu:function(e){var t={enabled:!0};t.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var o=this.getTitleValue("NAME"),n=this.blockSpace;t.callback=function(){var e=Blockly.Procedures.getDefinition(o,n);e&&e.select()},e.push(t)}},Blockly.Blocks.procedures_callreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL),this.setHSV(94,.84,.6);var e=this.appendDummyInput().appendTitle(Blockly.Msg.PROCEDURES_CALLRETURN_CALL).appendTitle("","NAME");if(Blockly.functionEditor){var t=new Blockly.FieldIcon(Blockly.Msg.FUNCTION_EDIT);Blockly.bindEvent_(t.fieldGroup_,"mousedown",this,this.openEditor),e.appendTitle(t)}this.setOutput(!0),this.setTooltip(Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP),this.currentParameterNames_=[],this.currentParameterIDs=this.parameterIDsToArgumentConnections=null},openEditor:Blockly.Blocks.procedures_callnoreturn.openEditor,getCallName:Blockly.Blocks.procedures_callnoreturn.getCallName,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,setProcedureParameters:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters,mutationToDom:Blockly.Blocks.procedures_callnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callnoreturn.domToMutation,renameVar:Blockly.Blocks.procedures_callnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_callnoreturn.customContextMenu},Blockly.Blocks.procedures_ifreturn={init:function(){this.setHelpUrl("http://c2.com/cgi/wiki?GuardClause"),this.setHSV(94,.84,.6),this.appendValueInput("CONDITION").setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP),this.hasReturnValue_=!0},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("value",Number(this.hasReturnValue_)),e},domToMutation:function(e){this.hasReturnValue_=1==e.getAttribute("value"),this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(){if(this.blockSpace){var e=!1,t=this;do{if("procedures_defnoreturn"==t.type||"procedures_defreturn"==t.type){e=!0;break}t=t.getSurroundParent()}while(t);e?("procedures_defnoreturn"==t.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=t.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING)}}},Blockly.Blocks.functionalProcedures={},Blockly.Blocks.functional_definition={shouldHideIfInMainBlockSpace:function(){return!0},init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.setHSV(94,.84,.6),this.setFunctional(!0,{headerHeight:0,rowBuffer:3}),this.setFunctionalOutput(!1);var e=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,this);this.appendDummyInput().appendTitle(Blockly.Msg.DEFINE_FUNCTION_DEFINE).appendTitle(new Blockly.FieldTextInput(e,Blockly.Procedures.rename),"NAME").appendTitle("","PARAMS"),this.appendFunctionalInput("STACK"),this.setFunctional(!0),this.setTooltip(Blockly.Msg.FUNCTIONAL_PROCEDURE_DEFINE_TOOLTIP),this.isFunctionalVariable_=!1,this.parameterNames_=[],this.paramIds_=[],this.parameterTypes_=[]},updateInputsToType:function(e){this.updateInputType_(this.getInput("STACK"),e),this.render()},updateInputType_:function(e,t){e.setHSV.apply(e,Blockly.FunctionalTypeColors[t]),e.setCheck(t)},mutationToDom:function(){for(var e=document.createElement("mutation"),t=0;t<this.parameterNames_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.parameterNames_[t]),this.parameterTypes_[t]&&o.setAttribute("type",this.parameterTypes_[t]),e.appendChild(o)}return this.description_&&((t=document.createElement("description")).textContent=this.description_,e.appendChild(t)),this.outputType_&&((t=document.createElement("outputType")).textContent=this.outputType_,e.appendChild(t)),this.isFunctionalVariable_&&((t=document.createElement("isfunctionalvariable")).textContent="true",e.appendChild(t)),e},domToMutation:function(e){this.parameterNames_=[];for(var t,o=0;t=e.childNodes[o];o++){var n=t.nodeName.toLowerCase();"arg"===n?(this.parameterNames_.push(t.getAttribute("name")),this.parameterTypes_.push(t.getAttribute("type"))):"description"===n?this.description_=t.textContent:"outputtype"===n?this.updateOutputType(t.textContent):"isfunctionalvariable"===n&&(this.isFunctionalVariable_=!0)}this.updateParams_()},isVariable:function(){return this.isFunctionalVariable_},convertToVariable:function(){this.isFunctionalVariable_=!0},updateParamsFromArrays:function(e,t,o){this.parameterNames_=goog.array.clone(e),this.paramIds_=t?goog.array.clone(t):null,this.parameterTypes_=goog.array.clone(o),this.updateParams_(),this.updateCallerParams_()},updateParams_:function(){for(var e=!1,t={},o=0;o<this.parameterNames_.length;o++){if(t["arg_"+this.parameterNames_[o].toLowerCase()]){e=!0;break}t["arg_"+this.parameterNames_[o].toLowerCase()]=!0}e?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null),e="",this.parameterNames_.length&&(e=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.parameterNames_.join(", ")),this.setTitleValue(e,"PARAMS")},updateCallerParams_:function(){Blockly.Procedures.mutateCallers(this.getTitleValue("NAME"),this.blockSpace,this.parameterNames_,this.paramIds_,this.parameterTypes_)},getOutputType:function(){return this.outputType_},updateOutputType:function(e){this.outputType_=e,this.setHSV.apply(this,Blockly.FunctionalTypeColors[e])},dispose:function(e,t,o){if(!o){var n=this.getTitleValue("NAME");Blockly.Procedures.disposeCallers(n,this.blockSpace)}Blockly.Block.prototype.dispose.apply(this,arguments)},getProcedureInfo:function(){return{name:this.getTitleValue("NAME"),type:this.type,callType:this.callType_,parameterNames:this.parameterNames_,parameterTypes:this.parameterTypes_,isFunctionalVariable:this.isFunctionalVariable_}},getVars:function(){return{Default:this.parameterNames_}},renameVar:function(e,t){var o,n=!1;for(o=0;o<this.parameterNames_.length;o++)Blockly.Names.equals(e,this.parameterNames_[o])&&(this.parameterNames_[o]=t,n=!0);if(n&&(this.updateParams_(),this.mutator&&this.mutator.isVisible()))for(n=this.mutator.blockSpace_.getAllBlocks(),o=0;o<n.length;o++){var i=n[o];"functional_procedures_mutatorarg"==i.type&&Blockly.Names.equals(e,i.getTitleValue("NAME"))&&i.setTitleValue(t,"NAME")}},removeVar:function(e){-1<(e=this.parameterNames_.indexOf(e))&&(this.parameterNames_.splice(e,1),this.updateParams_())},changeParamType:function(e,t){for(var o=!1,n=0;n<this.parameterNames_.length;n++)Blockly.Names.equals(e,this.parameterNames_[n])&&(this.parameterTypes_[n]=t,o=!0);o&&(this.updateParams_(),this.updateCallerParams_())},shouldBeGrayedOut:function(){return!1},callType_:"functional_call"},Blockly.Blocks.functional_call={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL),this.setTooltip("Calls a user-defined function"),this.setHSV(94,.84,.6);var e=this.appendDummyInput().appendTitle(new Blockly.FieldLabel("Function Call",{fixedSize:{height:35}}),"NAME").appendTitle("","PARAM_TEXT");if(Blockly.useContractEditor&&this.blockSpace!==Blockly.modalBlockSpace){var t=new Blockly.FieldIcon(Blockly.Msg.FUNCTION_EDIT);Blockly.bindEvent_(t.fieldGroup_,"mousedown",this,this.openEditor),e.appendTitle(t),this.editLabel_=t}this.setFunctional(!0),this.currentParameterNames_=[],this.parameterIDsToArgumentConnections_={},this.currentParameterIDs_=[],this.currentParameterTypes_=[],this.currentDescription_=this.currentOutputType_=null,this.blockSpace.events.listen(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE,this.updateAttributesFromDefinition_,!1,this),this.changeFunctionalOutput(Blockly.BlockValueType.NONE)},updateAttributesFromDefinition_:function(){var e=Blockly.Procedures.getDefinition(this.getTitleValue("NAME"),this.blockSpace.blockSpaceEditor.blockSpace);e&&(e.outputType_&&e.outputType_!==this.currentOutputType_&&(this.currentOutputType_=e.outputType_,this.changeFunctionalOutput(e.outputType_)),e.description_&&e.description_!==this.currentDescription_&&(this.currentDescription_=e.description_,this.setTooltip(e.description_)))},beforeDispose:function(){this.blockSpace.events.unlisten(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE,this.updateAttributesFromDefinition_,!1,this)},openEditor:function(e){e.stopPropagation(),Blockly.functionEditor.openEditorForCallBlock_(this)},getCallName:function(){return this.getTitleValue("NAME")},getParamTypes:function(){return this.currentParameterTypes_},renameProcedure:function(e,t){Blockly.Names.equals(e,this.getTitleValue("NAME"))&&this.setTitleValue(t,"NAME")},setProcedureParameters:function(e,t,o){if(t){if(t.length!=e.length)throw"Error: paramNames and paramIds must be the same length.";this.currentParameterIDs_||(this.parameterIDsToArgumentConnections_={},e.join("\n")===this.currentParameterNames_.join("\n")?this.currentParameterIDs_=t:this.currentParameterIDs_=[]);var n,i,r=this.rendered;for(this.rendered=!1,n=this.currentParameterNames_.length-1;0<=n;n--)if(i=this.getInput("ARG"+n)){var l=i.connection.targetConnection;this.parameterIDsToArgumentConnections_[this.currentParameterIDs_[n]]=l,this.removeInput("ARG"+n)}for(this.currentParameterNames_=goog.array.clone(e),this.currentParameterIDs_=goog.array.clone(t),this.currentParameterTypes_=goog.array.clone(o),n=0;n<this.currentParameterNames_.length;n++)i=this.appendFunctionalInput("ARG"+n).setAlign(Blockly.ALIGN_CENTRE).setInline(0<n),l=this.currentParameterTypes_[n],i.setHSV.apply(i,Blockly.FunctionalTypeColors[l]),i.setCheck(l),this.currentParameterIDs_&&((e=this.currentParameterIDs_[n])in this.parameterIDsToArgumentConnections_&&(!(l=this.parameterIDsToArgumentConnections_[e])||l.targetConnection||l.sourceBlock_.blockSpace!=this.blockSpace?delete this.parameterIDsToArgumentConnections_[e]:i.connection.connect(l)));this.refreshParameterTitleString_(),(this.rendered=r)&&this.render()}else this.parameterIDsToArgumentConnections_={},this.currentParameterIDs_=null},refreshParameterTitleString_:function(){var e=0<this.currentParameterNames_.length?" ("+this.currentParameterNames_.join(", ")+")":"";this.setTitleValue(e,"PARAM_TEXT")},mutationToDom:function(){var e=document.createElement("mutation");e.setAttribute("name",this.getTitleValue("NAME"));for(var t=0;t<this.currentParameterNames_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.currentParameterNames_[t]),o.setAttribute("type",this.currentParameterTypes_[t]),e.appendChild(o)}return e},domToMutation:function(e){var t,o=e.getAttribute("name");for(this.setTitleValue(o,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",o)),this.currentParameterNames_=[],this.currentParameterIDs_=[],this.currentParameterTypes_=[],o=0;t=e.childNodes[o];o++)"arg"==t.nodeName.toLowerCase()&&(this.currentParameterNames_.push(t.getAttribute("name")),this.currentParameterTypes_.push(t.getAttribute("type")),this.currentParameterIDs_.push(Blockly.getUID()));this.setProcedureParameters(this.currentParameterNames_,this.currentParameterIDs_,this.currentParameterTypes_),this.updateAttributesFromDefinition_()},renameVar:function(e,t){for(var o=0;o<this.currentParameterNames_.length;o++)Blockly.Names.equals(e,this.currentParameterNames_[o])&&(this.currentParameterNames_[o]=t,this.refreshParameterTitleString_())}},Blockly.Blocks.functional_pass={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL),this.setTooltip("Pass a user-defined function"),this.setHSV(94,.84,.6);var e=this.appendDummyInput().appendTitle(new Blockly.FieldLabel("Pass Function",{fixedSize:{height:35}}),"NAME").appendTitle("","PARAM_TEXT");if(Blockly.useContractEditor&&this.blockSpace!==Blockly.modalBlockSpace){var t=new Blockly.FieldIcon(Blockly.Msg.FUNCTION_EDIT);Blockly.bindEvent_(t.fieldGroup_,"mousedown",this,this.openEditor),e.appendTitle(t),this.editLabel_=t}this.setFunctional(!0),this.setMovable(!!Blockly.editBlocks),this.setColorFromName_(),this.blockSpace.events.listen(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE,this.setColorFromName_,!1,this),this.changeFunctionalOutput(Blockly.BlockValueType.FUNCTION)},openEditor:function(e){e.stopPropagation(),Blockly.functionEditor.openEditorForCallBlock_(this)},renameProcedure:function(e,t){Blockly.Names.equals(e,this.getTitleValue("NAME"))&&(this.setTitleValue(t,"NAME"),this.setColorFromName_())},setColorFromName_:function(){var e=this.getTitleValue("NAME");e&&(e=Blockly.mainBlockSpace.findFunction(e))&&(e=e.getOutputType(),this.setHSV.apply(this,Blockly.FunctionalTypeColors[e]))},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("name",this.getTitleValue("NAME")),e},domToMutation:function(e){e=e.getAttribute("name"),this.setTitleValue(e,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",e)),this.setColorFromName_()}},Blockly.Blocks.procedural_to_functional_call=Blockly.Blocks.procedures_callreturn,Blockly.Blocks.lists={},Blockly.Blocks.lists_create_empty={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL),this.setOutput(!0,Blockly.BlockValueType.ARRAY),this.appendDummyInput().appendTitle(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE),this.setTooltip(Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP)}},Blockly.Blocks.lists_create_with={init:function(){this.appendValueInput("ADD0").appendTitle(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH),this.appendValueInput("ADD1"),this.appendValueInput("ADD2"),this.setOutput(!0,Blockly.BlockValueType.ARRAY),this.setMutator(new Blockly.Mutator(["lists_create_with_item"])),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP),this.itemCount_=3},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("items",this.itemCount_),e},domToMutation:function(e){var t;for(t=0;t<this.itemCount_;t++)this.removeInput("ADD"+t);for(this.itemCount_=window.parseInt(e.getAttribute("items"),10),t=0;t<this.itemCount_;t++)e=this.appendValueInput("ADD"+t),0==t&&e.appendTitle(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH);0==this.itemCount_&&this.appendDummyInput("EMPTY").appendTitle(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE)},decompose:function(e){var t=new Blockly.Block(e,"lists_create_with_container");t.initSvg();for(var o=t.getInput("STACK").connection,n=0;n<this.itemCount_;n++){var i=new Blockly.Block(e,"lists_create_with_item");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return t},compose:function(e){if(0==this.itemCount_)this.removeInput("EMPTY");else for(var t=this.itemCount_-1;0<=t;t--)this.removeInput("ADD"+t);for(this.itemCount_=0,e=e.getInputTargetBlock("STACK");e;)t=this.appendValueInput("ADD"+this.itemCount_),0==this.itemCount_&&t.appendTitle(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH),e.valueConnection_&&t.connection.connect(e.valueConnection_),this.itemCount_++,e=e.nextConnection&&e.nextConnection.targetBlock();0==this.itemCount_&&this.appendDummyInput("EMPTY").appendTitle(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE)},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t=0;e;){var o=this.getInput("ADD"+t);e.valueConnection_=o&&o.connection.targetConnection,t++,e=e.nextConnection&&e.nextConnection.targetBlock()}}},Blockly.Blocks.lists_create_with_container={init:function(){this.setHSV(40,1,.99),this.appendDummyInput().appendTitle(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.lists_create_with_item={init:function(){this.setHSV(40,1,.99),this.appendDummyInput().appendTitle(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.lists_repeat={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_REPEAT_HELPURL),this.setOutput(!0,Blockly.BlockValueType.ARRAY),this.interpolateMsg(Blockly.Msg.LISTS_REPEAT_TITLE,["ITEM",null,Blockly.ALIGN_RIGHT],["NUM","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setTooltip(Blockly.Msg.LISTS_REPEAT_TOOLTIP)}},Blockly.Blocks.lists_length={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_LENGTH_HELPURL),this.setHSV(40,1,.99),this.appendValueInput("VALUE").setCheck([Blockly.BlockValueType.ARRAY,Blockly.BlockValueType.STRING]).appendTitle(Blockly.Msg.LISTS_LENGTH_INPUT_LENGTH),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.setTooltip(Blockly.Msg.LISTS_LENGTH_TOOLTIP)}},Blockly.Blocks.lists_isEmpty={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_IS_EMPTY_HELPURL),this.setHSV(40,1,.99),this.interpolateMsg(Blockly.Msg.LISTS_IS_EMPTY_TITLE,["VALUE",["Array","String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.setTooltip(Blockly.Msg.LISTS_TOOLTIP)}},Blockly.Blocks.lists_indexOf={init:function(){var e=[[Blockly.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[Blockly.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL),this.setHSV(40,1,.99),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("VALUE").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST),this.appendValueInput("FIND").appendTitle(new Blockly.FieldDropdown(e),"END"),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.LISTS_INDEX_OF_TOOLTIP)}},Blockly.Blocks.lists_getIndex={init:function(){var e=[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"],[Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[Blockly.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL),this.setHSV(40,1,.99),e=new Blockly.FieldDropdown(e,function(e){this.sourceBlock_.updateStatement("REMOVE"==e)}),this.appendValueInput("VALUE").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendTitle(e,"MODE").appendTitle("","SPACE"),this.appendDummyInput("AT"),Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendTitle(Blockly.Msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("MODE")+"_"+t.getTitleValue("WHERE");return Blockly.Msg["LISTS_GET_INDEX_TOOLTIP_"+e]})},mutationToDom:function(){var e=document.createElement("mutation");e.setAttribute("statement",!this.outputConnection);var t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){var t="true"==e.getAttribute("statement");this.updateStatement(t),e="false"!=e.getAttribute("at"),this.updateAt(e)},updateStatement:function(e){e!=!this.outputConnection&&(this.unplug(!0,!0),e?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck(Blockly.BlockValueType.NUMBER),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendTitle(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt(o),n.setTitleValue(t,"WHERE"),null}});this.getInput("AT").appendTitle(t,"WHERE"),Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},Blockly.Blocks.lists_setIndex={init:function(){var e=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"],[Blockly.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL),this.setHSV(40,1,.99),this.appendValueInput("LIST").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendTitle(new Blockly.FieldDropdown(e),"MODE").appendTitle("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendTitle(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("MODE")+"_"+t.getTitleValue("WHERE");return Blockly.Msg["LISTS_SET_INDEX_TOOLTIP_"+e]})},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){e="false"!=e.getAttribute("at"),this.updateAt(e)},updateAt:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck(Blockly.BlockValueType.NUMBER),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendTitle(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt(o),n.setTitleValue(t,"WHERE"),null}});this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendTitle(t,"WHERE")}},Blockly.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"]],this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL),this.appendValueInput("LIST").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendTitle(Blockly.Msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,Blockly.BlockValueType.ARRAY),this.updateAt(1,!0),this.updateAt(2,!0),this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT1").type==Blockly.INPUT_VALUE;return e.setAttribute("at1",t),t=this.getInput("AT2").type==Blockly.INPUT_VALUE,e.setAttribute("at2",t),e},domToMutation:function(e){var t="true"==e.getAttribute("at1");e="true"==e.getAttribute("at2"),this.updateAt(1,t),this.updateAt(2,e)},updateAt:function(e,t){this.removeInput("AT"+e),this.removeInput("ORDINAL"+e,!0),t?(this.appendValueInput("AT"+e).setCheck(Blockly.BlockValueType.NUMBER),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+e).appendTitle(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+e);var o=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+e],function(o){var n="FROM_START"==o||"FROM_END"==o;if(n!=t){var i=this.sourceBlock_;return i.updateAt(e,n),i.setTitleValue(o,"WHERE"+e),null}});this.getInput("AT"+e).appendTitle(o,"WHERE"+e),1==e&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}},Blockly.Blocks.logic={},Blockly.Blocks.controls_if={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL),this.setColour(210),this.appendValueInput("IF0").setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_IF),this.appendStatementInput("DO0").appendTitle(Blockly.Msg.CONTROLS_IF_MSG_THEN),this.setPreviousStatement(!0),this.setNextStatement(!0),Blockly.disableIfElseEditing||this.setMutator(new Blockly.Mutator(["controls_if_elseif","controls_if_else"]));var e=this;this.setTooltip(function(){return e.elseifCount_||e.elseCount_?!e.elseifCount_&&e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_2:e.elseifCount_&&!e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_3:e.elseifCount_&&e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_4:"":Blockly.Msg.CONTROLS_IF_TOOLTIP_1}),this.elseCount_=this.elseifCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var e=document.createElement("mutation");return this.elseifCount_&&e.setAttribute("elseif",this.elseifCount_),this.elseCount_&&e.setAttribute("else",1),e},domToMutation:function(e){for(this.elseifCount_=window.parseInt(e.getAttribute("elseif"),10),this.elseCount_=window.parseInt(e.getAttribute("else"),10),e=1;e<=this.elseifCount_;e++)this.appendValueInput("IF"+e).setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+e).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendTitle(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},decompose:function(e){var t=new Blockly.Block(e,"controls_if_if");t.initSvg();for(var o=t.getInput("STACK").connection,n=1;n<=this.elseifCount_;n++){var i=new Blockly.Block(e,"controls_if_elseif");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return this.elseCount_&&((e=new Blockly.Block(e,"controls_if_else")).initSvg(),o.connect(e.previousConnection)),t},compose:function(e){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var t=this.elseifCount_;0<t;t--)this.removeInput("IF"+t),this.removeInput("DO"+t);for(this.elseifCount_=0,e=e.getInputTargetBlock("STACK");e;){switch(e.type){case"controls_if_elseif":this.elseifCount_++,t=this.appendValueInput("IF"+this.elseifCount_).setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);var o=this.appendStatementInput("DO"+this.elseifCount_);o.appendTitle(Blockly.Msg.CONTROLS_IF_MSG_THEN),e.valueConnection_&&t.connection.connect(e.valueConnection_),e.statementConnection_&&o.connection.connect(e.statementConnection_);break;case"controls_if_else":this.elseCount_++,(t=this.appendStatementInput("ELSE")).appendTitle(Blockly.Msg.CONTROLS_IF_MSG_ELSE),e.statementConnection_&&t.connection.connect(e.statementConnection_);break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t,o=1;e;){switch(e.type){case"controls_if_elseif":var n=this.getInput("IF"+o);t=this.getInput("DO"+o),e.valueConnection_=n&&n.connection.targetConnection,e.statementConnection_=t&&t.connection.targetConnection,o++;break;case"controls_if_else":t=this.getInput("ELSE"),e.statementConnection_=t&&t.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}}},Blockly.Blocks.controls_if_if={init:function(){this.setHSV(196,1,.79),this.appendDummyInput().appendTitle(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.controls_if_elseif={init:function(){this.setHSV(196,1,.79),this.appendDummyInput().appendTitle(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.controls_if_else={init:function(){this.setHSV(196,1,.79),this.appendDummyInput().appendTitle(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE),this.setPreviousStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.logic_compare={init:function(){var e=Blockly.RTL?[["=","EQ"],["≠","NEQ"],[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.appendValueInput("A"),this.appendValueInput("B").appendTitle(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("OP");return{EQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,LT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT,LTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE,GT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT,GTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE}[e]})}},Blockly.Blocks.logic_operation={init:function(){var e=[[Blockly.Msg.LOGIC_OPERATION_AND,"AND"],[Blockly.Msg.LOGIC_OPERATION_OR,"OR"]];this.setHelpUrl(Blockly.Msg.LOGIC_OPERATION_HELPURL),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.appendValueInput("A").setCheck(Blockly.BlockValueType.BOOLEAN),this.appendValueInput("B").setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("OP");return{AND:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND,OR:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR}[e]})}},Blockly.Blocks.logic_negate={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_NEGATE_HELPURL),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.interpolateMsg(Blockly.Msg.LOGIC_NEGATE_TITLE,["BOOL",Blockly.BlockValueType.BOOLEAN,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setTooltip(Blockly.Msg.LOGIC_NEGATE_TOOLTIP)}},Blockly.Blocks.logic_boolean={init:function(){var e=[[Blockly.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Blockly.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]];this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.appendDummyInput().appendTitle(new Blockly.FieldDropdown(e),"BOOL"),this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP)}},Blockly.Blocks.logic_null={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_NULL_HELPURL),this.setHSV(196,1,.79),this.setOutput(!0),this.appendDummyInput().appendTitle(Blockly.Msg.LOGIC_NULL),this.setTooltip(Blockly.Msg.LOGIC_NULL_TOOLTIP)}},Blockly.Blocks.logic_ternary={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL),this.setHSV(196,1,.79),this.appendValueInput("IF").setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(Blockly.Msg.LOGIC_TERNARY_CONDITION),this.appendValueInput("THEN").appendTitle(Blockly.Msg.LOGIC_TERNARY_IF_TRUE),this.appendValueInput("ELSE").appendTitle(Blockly.Msg.LOGIC_TERNARY_IF_FALSE),this.setOutput(!0),this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP)}},Blockly.Blocks.loops={},Blockly.Blocks.controls_repeat={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL),this.setHSV(322,.9,.95),this.appendDummyInput().appendTitle(Blockly.Msg.CONTROLS_REPEAT_TITLE_REPEAT).appendTitle(new Blockly.FieldTextInput("10",Blockly.FieldTextInput.nonnegativeIntegerValidator),"TIMES").appendTitle(Blockly.Msg.CONTROLS_REPEAT_TITLE_TIMES),this.appendStatementInput("DO").appendTitle(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_TOOLTIP)}},Blockly.Blocks.controls_repeat_ext={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL),this.setHSV(322,.9,.95),this.interpolateMsg(Blockly.Msg.CONTROLS_REPEAT_TITLE,["TIMES","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO").appendTitle(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_TOOLTIP)}},Blockly.Blocks.controls_whileUntil={init:function(){var e=[[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]];this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL),this.setHSV(322,.9,.95),this.appendValueInput("BOOL").setCheck(Blockly.BlockValueType.BOOLEAN).appendTitle(new Blockly.FieldDropdown(e),"MODE"),this.appendStatementInput("DO").appendTitle(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("MODE");return{WHILE:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[e]})}},Blockly.Blocks.controls_for={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_FOR_HELPURL),this.setHSV(322,.9,.95),this.interpolateMsg(Blockly.Msg.CONTROLS_FOR_INPUT_COUNTER,goog.bind(function(){this.appendDummyInput().appendTitle(new Blockly.FieldVariable(null),"VAR")},this),["FROM","Number",Blockly.Msg.ALIGN_RIGHT],["TO","Number",Blockly.Msg.ALIGN_RIGHT],["BY","Number",Blockly.Msg.ALIGN_RIGHT],Blockly.Msg.ALIGN_RIGHT),this.appendStatementInput("DO").appendTitle(Blockly.Msg.CONTROLS_FOR_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",e.getTitleValue("VAR"))})},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")},customContextMenu:function(e){var t={enabled:!0},o=this.getTitleValue("VAR");t.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",o),(o=goog.dom.createDom("title",null,o)).setAttribute("name","VAR"),(o=goog.dom.createDom("block",null,o)).setAttribute("type","variables_get"),t.callback=Blockly.ContextMenu.callbackFactory(this,o),e.push(t)},domToMutation:function(e){"default_var"===e.getAttribute("name")&&(e=Blockly.Variables.generateUniqueNameFromBase_(e.childNodes[0].data),this.setTitleValue(e,"VAR"))}},Blockly.Blocks.controls_forEach={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_FOREACH_HELPURL),this.setHSV(322,.9,.95),this.appendValueInput("LIST").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(Blockly.Msg.CONTROLS_FOREACH_INPUT_ITEM).appendTitle(new Blockly.FieldVariable(null),"VAR").appendTitle(Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST),Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST_TAIL&&(this.appendDummyInput().appendTitle(Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST_TAIL),this.setInputsInline(!0)),this.appendStatementInput("DO").appendTitle(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1",e.getTitleValue("VAR"))})},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")},customContextMenu:Blockly.Blocks.controls_for.customContextMenu},Blockly.Blocks.controls_flow_statements={init:function(){var e=[[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK,"BREAK"],[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE,"CONTINUE"]];this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL),this.setHSV(322,.9,.95),this.appendDummyInput().appendTitle(new Blockly.FieldDropdown(e),"FLOW"),this.setPreviousStatement(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("FLOW");return{BREAK:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,CONTINUE:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[e]})},onchange:function(){if(this.blockSpace){var e=!1,t=this;do{if("controls_repeat"==t.type||"controls_repeat_ext"==t.type||"controls_forEach"==t.type||"controls_for"==t.type||"controls_whileUntil"==t.type){e=!0;break}t=t.getSurroundParent()}while(t);e?this.setWarningText(null):this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING)}}},Blockly.Blocks.math={},Blockly.Blocks.math_number={init:function(){this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL),this.appendDummyInput().appendTitle(new Blockly.FieldTextInput("0",Blockly.FieldTextInput.numberValidator),"NUM"),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.setTooltip(Blockly.Msg.MATH_NUMBER_TOOLTIP)}},Blockly.Blocks.math_arithmetic={init:function(){var e=[[Blockly.Msg.MATH_ADDITION_SYMBOL,"ADD"],[Blockly.Msg.MATH_SUBTRACTION_SYMBOL,"MINUS"],[Blockly.Msg.MATH_MULTIPLICATION_SYMBOL,"MULTIPLY"],[Blockly.Msg.MATH_DIVISION_SYMBOL,"DIVIDE"],[Blockly.Msg.MATH_POWER_SYMBOL,"POWER"]];this.setHelpUrl(Blockly.Msg.MATH_ARITHMETIC_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("A").setCheck(Blockly.BlockValueType.NUMBER),this.appendValueInput("B").setCheck(Blockly.BlockValueType.NUMBER).appendTitle(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getTitleValue("OP");return{ADD:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]})}},Blockly.Blocks.math_single={init:function(){var e=[[Blockly.Msg.MATH_SINGLE_OP_ROOT,"ROOT"],[Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE,"ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]];this.setHelpUrl(Blockly.Msg.MATH_SINGLE_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("NUM").setCheck(Blockly.BlockValueType.NUMBER).appendTitle(new Blockly.FieldDropdown(e),"OP");var t=this;this.setTooltip(function(){var e=t.getTitleValue("OP");return{ROOT:Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT,ABS:Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS,NEG:Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG,LN:Blockly.Msg.MATH_SINGLE_TOOLTIP_LN,LOG10:Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10,EXP:Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP,POW10:Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10}[e]})}},Blockly.Blocks.math_trig={init:function(){var e=[[Blockly.Msg.MATH_TRIG_SIN,"SIN"],[Blockly.Msg.MATH_TRIG_COS,"COS"],[Blockly.Msg.MATH_TRIG_TAN,"TAN"],[Blockly.Msg.MATH_TRIG_ASIN,"ASIN"],[Blockly.Msg.MATH_TRIG_ACOS,"ACOS"],[Blockly.Msg.MATH_TRIG_ATAN,"ATAN"]];this.setHelpUrl(Blockly.Msg.MATH_TRIG_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("NUM").setCheck(Blockly.BlockValueType.NUMBER).appendTitle(new Blockly.FieldDropdown(e),"OP");var t=this;this.setTooltip(function(){var e=t.getTitleValue("OP");return{SIN:Blockly.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Blockly.Msg.MATH_TRIG_TOOLTIP_COS,TAN:Blockly.Msg.MATH_TRIG_TOOLTIP_TAN,ASIN:Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN,ACOS:Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS,ATAN:Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN}[e]})}},Blockly.Blocks.math_constant={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CONSTANT_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendDummyInput().appendTitle(new Blockly.FieldDropdown([["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]),"CONSTANT"),this.setTooltip(Blockly.Msg.MATH_CONSTANT_TOOLTIP)}},Blockly.Blocks.math_number_property={init:function(){var e=[[Blockly.Msg.MATH_IS_EVEN,"EVEN"],[Blockly.Msg.MATH_IS_ODD,"ODD"],[Blockly.Msg.MATH_IS_PRIME,"PRIME"],[Blockly.Msg.MATH_IS_WHOLE,"WHOLE"],[Blockly.Msg.MATH_IS_POSITIVE,"POSITIVE"],[Blockly.Msg.MATH_IS_NEGATIVE,"NEGATIVE"],[Blockly.Msg.MATH_IS_DIVISIBLE_BY,"DIVISIBLE_BY"]];this.appendValueInput("NUMBER_TO_CHECK").setCheck(Blockly.BlockValueType.NUMBER),e=new Blockly.FieldDropdown(e,function(e){this.sourceBlock_.updateShape("DIVISIBLE_BY"==e)}),this.appendDummyInput().appendTitle(e,"PROPERTY"),this.setInputsInline(!0),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.setTooltip(Blockly.Msg.MATH_IS_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t="DIVISIBLE_BY"==this.getTitleValue("PROPERTY");return e.setAttribute("divisor_input",t),e},domToMutation:function(e){e="true"==e.getAttribute("divisor_input"),this.updateShape(e)},updateShape:function(e){var t=this.getInput("DIVISOR");e?t||this.appendValueInput("DIVISOR").setCheck(Blockly.BlockValueType.NUMBER):t&&this.removeInput("DIVISOR")}},Blockly.Blocks.math_change={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CHANGE_HELPURL),this.setHSV(258,.35,.62),this.appendValueInput("DELTA").setCheck(Blockly.BlockValueType.NUMBER).appendTitle(Blockly.Msg.MATH_CHANGE_TITLE_CHANGE).appendTitle(new Blockly.FieldVariable(Blockly.Msg.MATH_CHANGE_TITLE_ITEM),"VAR").appendTitle(Blockly.Msg.MATH_CHANGE_INPUT_BY),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",e.getTitleValue("VAR"))})},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")}},Blockly.Blocks.math_round={init:function(){var e=[[Blockly.Msg.MATH_ROUND_OPERATOR_ROUND,"ROUND"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP,"ROUNDUP"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN,"ROUNDDOWN"]];this.setHelpUrl(Blockly.Msg.MATH_ROUND_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("NUM").setCheck(Blockly.BlockValueType.NUMBER).appendTitle(new Blockly.FieldDropdown(e),"OP"),this.setTooltip(Blockly.Msg.MATH_ROUND_TOOLTIP)}},Blockly.Blocks.math_on_list={init:function(){var e=[[Blockly.Msg.MATH_ONLIST_OPERATOR_SUM,"SUM"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MIN,"MIN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MAX,"MAX"],[Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE,"AVERAGE"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN,"MEDIAN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MODE,"MODE"],[Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV,"STD_DEV"],[Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM,"RANDOM"]],t=this;this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),e=new Blockly.FieldDropdown(e,function(e){"MODE"==e?t.outputConnection.setCheck(Blockly.BlockValueType.ARRAY):t.outputConnection.setCheck(Blockly.BlockValueType.NUMBER)}),this.appendValueInput("LIST").setCheck(Blockly.BlockValueType.ARRAY).appendTitle(e,"OP"),this.setTooltip(function(){var e=t.getTitleValue("OP");return{SUM:Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM,MIN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN,MAX:Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX,AVERAGE:Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE,MEDIAN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN,MODE:Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE,STD_DEV:Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV,RANDOM:Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM}[e]})}},Blockly.Blocks.math_modulo={init:function(){this.setHelpUrl(Blockly.Msg.MATH_MODULO_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.interpolateMsg(Blockly.Msg.MATH_MODULO_TITLE,["DIVIDEND","Number",Blockly.ALIGN_RIGHT],["DIVISOR","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_MODULO_TOOLTIP)}},Blockly.Blocks.math_constrain={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CONSTRAIN_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.interpolateMsg(Blockly.Msg.MATH_CONSTRAIN_TITLE,["VALUE","Number",Blockly.ALIGN_RIGHT],["LOW","Number",Blockly.ALIGN_RIGHT],["HIGH","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_CONSTRAIN_TOOLTIP)}},Blockly.Blocks.math_random_int={init:function(){this.setHelpUrl(Blockly.Msg.MATH_RANDOM_INT_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.interpolateMsg(Blockly.Msg.MATH_RANDOM_INT_TITLE,["FROM","Number",Blockly.ALIGN_RIGHT],["TO","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_RANDOM_INT_TOOLTIP)}},Blockly.Blocks.math_random_float={init:function(){this.setHelpUrl(Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendDummyInput().appendTitle(Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM),this.setTooltip(Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP)}},Blockly.Blocks.text={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL),this.appendDummyInput().appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote0.png"),12,12)).appendTitle(new Blockly.FieldTextInput(""),"TEXT").appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote1.png"),12,12)),this.setOutput(!0,Blockly.BlockValueType.STRING),this.setTooltip(Blockly.Msg.TEXT_TEXT_TOOLTIP)}},Blockly.Blocks.text_join={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL),this.appendValueInput("ADD0").appendTitle(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH),this.appendValueInput("ADD1"),this.setOutput(!0,Blockly.BlockValueType.STRING),this.setMutator(new Blockly.Mutator(["text_create_join_item"])),this.setTooltip(Blockly.Msg.TEXT_JOIN_TOOLTIP),this.itemCount_=2},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("items",this.itemCount_),e},domToMutation:function(e){var t;for(t=0;t<this.itemCount_;t++)this.removeInput("ADD"+t);for(this.itemCount_=window.parseInt(e.getAttribute("items"),10),t=0;t<this.itemCount_;t++)e=this.appendValueInput("ADD"+t),0==t&&e.appendTitle(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH);0==this.itemCount_&&this.appendDummyInput("EMPTY").appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote0.png"),12,12)).appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote1.png"),12,12))},decompose:function(e){var t=new Blockly.Block(e,"text_create_join_container");t.initSvg();for(var o=t.getInput("STACK").connection,n=0;n<this.itemCount_;n++){var i=new Blockly.Block(e,"text_create_join_item");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return t},compose:function(e){if(0==this.itemCount_)this.removeInput("EMPTY");else for(var t=this.itemCount_-1;0<=t;t--)this.removeInput("ADD"+t);for(this.itemCount_=0,e=e.getInputTargetBlock("STACK");e;)t=this.appendValueInput("ADD"+this.itemCount_),0==this.itemCount_&&t.appendTitle(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH),e.valueConnection_&&t.connection.connect(e.valueConnection_),this.itemCount_++,e=e.nextConnection&&e.nextConnection.targetBlock();0==this.itemCount_&&this.appendDummyInput("EMPTY").appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote0.png"),12,12)).appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote1.png"),12,12))},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t=0;e;){var o=this.getInput("ADD"+t);e.valueConnection_=o&&o.connection.targetConnection,t++,e=e.nextConnection&&e.nextConnection.targetBlock()}}},Blockly.Blocks.text_create_join_container={init:function(){this.setColour(160),this.appendDummyInput().appendTitle(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.text_create_join_item={init:function(){this.setColour(160),this.appendDummyInput().appendTitle(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.text_append={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL),this.setColour(160),this.appendValueInput("TEXT").appendTitle(Blockly.Msg.TEXT_APPEND_TO).appendTitle(new Blockly.FieldVariable(Blockly.Msg.TEXT_APPEND_VARIABLE),"VAR").appendTitle(Blockly.Msg.TEXT_APPEND_APPENDTEXT),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",e.getTitleValue("VAR"))})},getVars:Blockly.Variables.getVars,renameVar:function(e,t){Blockly.Names.equals(e,this.getTitleValue("VAR"))&&this.setTitleValue(t,"VAR")}},Blockly.Blocks.text_length={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_LENGTH_HELPURL),this.setColour(160),this.interpolateMsg(Blockly.Msg.TEXT_LENGTH_TITLE,["VALUE",["String","Array"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.setTooltip(Blockly.Msg.TEXT_LENGTH_TOOLTIP)}},Blockly.Blocks.text_isEmpty={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_ISEMPTY_HELPURL),this.setColour(160),this.interpolateMsg(Blockly.Msg.TEXT_ISEMPTY_TITLE,["VALUE",["String","Array"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setOutput(!0,Blockly.BlockValueType.BOOLEAN),this.setTooltip(Blockly.Msg.TEXT_ISEMPTY_TOOLTIP)}},Blockly.Blocks.text_indexOf={init:function(){var e=[[Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST,"FIRST"],[Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.TEXT_INDEXOF_HELPURL),this.setColour(160),this.setOutput(!0,Blockly.BlockValueType.NUMBER),this.appendValueInput("VALUE").setCheck(Blockly.BlockValueType.STRING).appendTitle(Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT),this.appendValueInput("FIND").setCheck(Blockly.BlockValueType.STRING).appendTitle(new Blockly.FieldDropdown(e),"END"),Blockly.Msg.TEXT_INDEXOF_TAIL&&this.appendDummyInput().appendTitle(Blockly.Msg.TEXT_INDEXOF_TAIL),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.TEXT_INDEXOF_TOOLTIP)}},Blockly.Blocks.text_charAt={init:function(){this.WHERE_OPTIONS=[[Blockly.Msg.TEXT_CHARAT_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_CHARAT_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_CHARAT_FIRST,"FIRST"],[Blockly.Msg.TEXT_CHARAT_LAST,"LAST"],[Blockly.Msg.TEXT_CHARAT_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.TEXT_CHARAT_HELPURL),this.setOutput(!0,Blockly.BlockValueType.STRING),this.appendValueInput("VALUE").setCheck(Blockly.BlockValueType.STRING).appendTitle(Blockly.Msg.TEXT_CHARAT_INPUT_INTEXT),this.appendDummyInput("AT"),this.setInputsInline(!0),this.updateAt(!0),this.setTooltip(Blockly.Msg.TEXT_CHARAT_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){e="false"!=e.getAttribute("at"),this.updateAt(e)},updateAt:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck(Blockly.BlockValueType.NUMBER),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendTitle(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),Blockly.Msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendTitle(Blockly.Msg.TEXT_CHARAT_TAIL));var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt(o),n.setTitleValue(t,"WHERE"),null}});this.getInput("AT").appendTitle(t,"WHERE")}},Blockly.Blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]],this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL),this.appendValueInput("STRING").setCheck(Blockly.BlockValueType.STRING).appendTitle(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendTitle(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL),this.setInputsInline(!0),this.setOutput(!0,Blockly.BlockValueType.STRING),this.updateAt(1,!0),this.updateAt(2,!0),this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT1").type==Blockly.INPUT_VALUE;return e.setAttribute("at1",t),t=this.getInput("AT2").type==Blockly.INPUT_VALUE,e.setAttribute("at2",t),e},domToMutation:function(e){var t="true"==e.getAttribute("at1");e="true"==e.getAttribute("at2"),this.updateAt(1,t),this.updateAt(2,e)},updateAt:function(e,t){this.removeInput("AT"+e),this.removeInput("ORDINAL"+e,!0),t?(this.appendValueInput("AT"+e).setCheck(Blockly.BlockValueType.NUMBER),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+e).appendTitle(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+e),2==e&&Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendTitle(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));var o=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+e],function(o){var n="FROM_START"==o||"FROM_END"==o;if(n!=t){var i=this.sourceBlock_;return i.updateAt(e,n),i.setTitleValue(o,"WHERE"+e),null}});this.getInput("AT"+e).appendTitle(o,"WHERE"+e),1==e&&this.moveInputBefore("AT1","AT2")}},Blockly.Blocks.text_changeCase={init:function(){var e=[[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL),this.appendValueInput("TEXT").setCheck(Blockly.BlockValueType.STRING).appendTitle(new Blockly.FieldDropdown(e),"CASE"),this.setOutput(!0,Blockly.BlockValueType.STRING),this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP)}},Blockly.Blocks.text_trim={init:function(){var e=[[Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL),this.appendValueInput("TEXT").setCheck(Blockly.BlockValueType.STRING).appendTitle(new Blockly.FieldDropdown(e),"MODE"),this.setOutput(!0,Blockly.BlockValueType.STRING),this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)}},Blockly.Blocks.text_print={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_PRINT_HELPURL),this.setColour(160),this.interpolateMsg(Blockly.Msg.TEXT_PRINT_TITLE,["TEXT",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP)}},Blockly.Blocks.text_prompt={init:function(){var e=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],t=this;this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL),e=new Blockly.FieldDropdown(e,function(e){"NUMBER"==e?t.outputConnection.setCheck(Blockly.BlockValueType.NUMBER):t.outputConnection.setCheck(Blockly.BlockValueType.STRING)}),this.appendDummyInput().appendTitle(e,"TYPE").appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote0.png"),12,12)).appendTitle(new Blockly.FieldTextInput(""),"TEXT").appendTitle(new Blockly.FieldImage(Blockly.assetUrl("media/quote1.png"),12,12)),this.setOutput(!0,Blockly.BlockValueType.STRING),t=this,this.setTooltip(function(){return"TEXT"==t.getTitleValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}},Blockly.Blocks.unknown={unknownBlock:!0,init:function(){this.setHSV(0,0,.8)}},Blockly.JavaScript=Blockly.Generator.get("JavaScript"),Blockly.JavaScript.addReservedWords("Blockly,break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with,class,enum,export,extends,import,super,implements,interface,let,package,private,protected,public,static,yield,const,null,true,false,Array,ArrayBuffer,Boolean,Date,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Error,eval,EvalError,Float32Array,Float64Array,Function,Infinity,Int16Array,Int32Array,Int8Array,isFinite,isNaN,Iterator,JSON,Math,NaN,Number,Object,parseFloat,parseInt,RangeError,ReferenceError,RegExp,StopIteration,String,SyntaxError,TypeError,Uint16Array,Uint32Array,Uint8Array,Uint8ClampedArray,undefined,uneval,URIError,applicationCache,closed,Components,content,_content,controllers,crypto,defaultStatus,dialogArguments,directories,document,frameElement,frames,fullScreen,globalStorage,history,innerHeight,innerWidth,length,location,locationbar,localStorage,menubar,messageManager,mozAnimationStartTime,mozInnerScreenX,mozInnerScreenY,mozPaintCount,name,navigator,opener,outerHeight,outerWidth,pageXOffset,pageYOffset,parent,performance,personalbar,pkcs11,returnValue,screen,screenX,screenY,scrollbars,scrollMaxX,scrollMaxY,scrollX,scrollY,self,sessionStorage,sidebar,status,statusbar,toolbar,top,URL,window,addEventListener,alert,atob,back,blur,btoa,captureEvents,clearImmediate,clearInterval,clearTimeout,close,confirm,disableExternalCapture,dispatchEvent,dump,enableExternalCapture,escape,find,focus,forward,GeckoActiveXObject,getAttention,getAttentionWithCycleCount,getComputedStyle,getSelection,home,matchMedia,maximize,minimize,moveBy,moveTo,mozRequestAnimationFrame,open,openDialog,postMessage,print,prompt,QueryInterface,releaseEvents,removeEventListener,resizeBy,resizeTo,restore,routeEvent,scroll,scrollBy,scrollByLines,scrollByPages,scrollTo,setCursor,setImmediate,setInterval,setResizable,setTimeout,showModalDialog,sizeToContent,stop,unescape,updateCommands,XPCNativeWrapper,XPCSafeJSObjectWrapper,onabort,onbeforeunload,onblur,onchange,onclick,onclose,oncontextmenu,ondevicemotion,ondeviceorientation,ondragdrop,onerror,onfocus,onhashchange,onkeydown,onkeypress,onkeyup,onload,onmousedown,onmousemove,onmouseout,onmouseover,onmouseup,onmozbeforepaint,onpaint,onpopstate,onreset,onresize,onscroll,onselect,onsubmit,onunload,onpageshow,onpagehide,Image,Option,Worker,Event,Range,File,FileReader,Blob,BlobBuilder,Attr,CDATASection,CharacterData,Comment,console,DocumentFragment,DocumentType,DomConfiguration,DOMError,DOMErrorHandler,DOMException,DOMImplementation,DOMImplementationList,DOMImplementationRegistry,DOMImplementationSource,DOMLocator,DOMObject,DOMString,DOMStringList,DOMTimeStamp,DOMUserData,Entity,EntityReference,MediaQueryList,MediaQueryListListener,NameList,NamedNodeMap,Node,NodeFilter,NodeIterator,NodeList,Notation,Plugin,PluginArray,ProcessingInstruction,SharedWorker,Text,TimeRanges,Treewalker,TypeInfo,UserDataHandler,Worker,WorkerGlobalScope,HTMLDocument,HTMLElement,HTMLAnchorElement,HTMLAppletElement,HTMLAudioElement,HTMLAreaElement,HTMLBaseElement,HTMLBaseFontElement,HTMLBodyElement,HTMLBRElement,HTMLButtonElement,HTMLCanvasElement,HTMLDirectoryElement,HTMLDivElement,HTMLDListElement,HTMLEmbedElement,HTMLFieldSetElement,HTMLFontElement,HTMLFormElement,HTMLFrameElement,HTMLFrameSetElement,HTMLHeadElement,HTMLHeadingElement,HTMLHtmlElement,HTMLHRElement,HTMLIFrameElement,HTMLImageElement,HTMLInputElement,HTMLKeygenElement,HTMLLabelElement,HTMLLIElement,HTMLLinkElement,HTMLMapElement,HTMLMenuElement,HTMLMetaElement,HTMLModElement,HTMLObjectElement,HTMLOListElement,HTMLOptGroupElement,HTMLOptionElement,HTMLOutputElement,HTMLParagraphElement,HTMLParamElement,HTMLPreElement,HTMLQuoteElement,HTMLScriptElement,HTMLSelectElement,HTMLSourceElement,HTMLSpanElement,HTMLStyleElement,HTMLTableElement,HTMLTableCaptionElement,HTMLTableCellElement,HTMLTableDataCellElement,HTMLTableHeaderCellElement,HTMLTableColElement,HTMLTableRowElement,HTMLTableSectionElement,HTMLTextAreaElement,HTMLTimeElement,HTMLTitleElement,HTMLTrackElement,HTMLUListElement,HTMLUnknownElement,HTMLVideoElement,HTMLCanvasElement,CanvasRenderingContext2D,CanvasGradient,CanvasPattern,TextMetrics,ImageData,CanvasPixelArray,HTMLAudioElement,HTMLVideoElement,NotifyAudioAvailableEvent,HTMLCollection,HTMLAllCollection,HTMLFormControlsCollection,HTMLOptionsCollection,HTMLPropertiesCollection,DOMTokenList,DOMSettableTokenList,DOMStringMap,RadioNodeList,SVGDocument,SVGElement,SVGAElement,SVGAltGlyphElement,SVGAltGlyphDefElement,SVGAltGlyphItemElement,SVGAnimationElement,SVGAnimateElement,SVGAnimateColorElement,SVGAnimateMotionElement,SVGAnimateTransformElement,SVGSetElement,SVGCircleElement,SVGClipPathElement,SVGColorProfileElement,SVGCursorElement,SVGDefsElement,SVGDescElement,SVGEllipseElement,SVGFilterElement,SVGFilterPrimitiveStandardAttributes,SVGFEBlendElement,SVGFEColorMatrixElement,SVGFEComponentTransferElement,SVGFECompositeElement,SVGFEConvolveMatrixElement,SVGFEDiffuseLightingElement,SVGFEDisplacementMapElement,SVGFEDistantLightElement,SVGFEFloodElement,SVGFEGaussianBlurElement,SVGFEImageElement,SVGFEMergeElement,SVGFEMergeNodeElement,SVGFEMorphologyElement,SVGFEOffsetElement,SVGFEPointLightElement,SVGFESpecularLightingElement,SVGFESpotLightElement,SVGFETileElement,SVGFETurbulenceElement,SVGComponentTransferFunctionElement,SVGFEFuncRElement,SVGFEFuncGElement,SVGFEFuncBElement,SVGFEFuncAElement,SVGFontElement,SVGFontFaceElement,SVGFontFaceFormatElement,SVGFontFaceNameElement,SVGFontFaceSrcElement,SVGFontFaceUriElement,SVGForeignObjectElement,SVGGElement,SVGGlyphElement,SVGGlyphRefElement,SVGGradientElement,SVGLinearGradientElement,SVGRadialGradientElement,SVGHKernElement,SVGImageElement,SVGLineElement,SVGMarkerElement,SVGMaskElement,SVGMetadataElement,SVGMissingGlyphElement,SVGMPathElement,SVGPathElement,SVGPatternElement,SVGPolylineElement,SVGPolygonElement,SVGRectElement,SVGScriptElement,SVGStopElement,SVGStyleElement,SVGSVGElement,SVGSwitchElement,SVGSymbolElement,SVGTextElement,SVGTextPathElement,SVGTitleElement,SVGTRefElement,SVGTSpanElement,SVGUseElement,SVGViewElement,SVGVKernElement,SVGAngle,SVGColor,SVGICCColor,SVGElementInstance,SVGElementInstanceList,SVGLength,SVGLengthList,SVGMatrix,SVGNumber,SVGNumberList,SVGPaint,SVGPoint,SVGPointList,SVGPreserveAspectRatio,SVGRect,SVGStringList,SVGTransform,SVGTransformList,SVGAnimatedAngle,SVGAnimatedBoolean,SVGAnimatedEnumeration,SVGAnimatedInteger,SVGAnimatedLength,SVGAnimatedLengthList,SVGAnimatedNumber,SVGAnimatedNumberList,SVGAnimatedPreserveAspectRatio,SVGAnimatedRect,SVGAnimatedString,SVGAnimatedTransformList,SVGPathSegList,SVGPathSeg,SVGPathSegArcAbs,SVGPathSegArcRel,SVGPathSegClosePath,SVGPathSegCurvetoCubicAbs,SVGPathSegCurvetoCubicRel,SVGPathSegCurvetoCubicSmoothAbs,SVGPathSegCurvetoCubicSmoothRel,SVGPathSegCurvetoQuadraticAbs,SVGPathSegCurvetoQuadraticRel,SVGPathSegCurvetoQuadraticSmoothAbs,SVGPathSegCurvetoQuadraticSmoothRel,SVGPathSegLinetoAbs,SVGPathSegLinetoHorizontalAbs,SVGPathSegLinetoHorizontalRel,SVGPathSegLinetoRel,SVGPathSegLinetoVerticalAbs,SVGPathSegLinetoVerticalRel,SVGPathSegMovetoAbs,SVGPathSegMovetoRel,ElementTimeControl,TimeEvent,SVGAnimatedPathData,SVGAnimatedPoints,SVGColorProfileRule,SVGCSSRule,SVGExternalResourcesRequired,SVGFitToViewBox,SVGLangSpace,SVGLocatable,SVGRenderingIntent,SVGStylable,SVGTests,SVGTextContentElement,SVGTextPositioningElement,SVGTransformable,SVGUnitTypes,SVGURIReference,SVGViewSpec,SVGZoomAndPan"),Blockly.JavaScript.ORDER_ATOMIC=0,Blockly.JavaScript.ORDER_MEMBER=1,Blockly.JavaScript.ORDER_NEW=1,Blockly.JavaScript.ORDER_FUNCTION_CALL=2,Blockly.JavaScript.ORDER_INCREMENT=3,Blockly.JavaScript.ORDER_DECREMENT=3,Blockly.JavaScript.ORDER_LOGICAL_NOT=4,Blockly.JavaScript.ORDER_BITWISE_NOT=4,Blockly.JavaScript.ORDER_UNARY_PLUS=4,Blockly.JavaScript.ORDER_UNARY_NEGATION=4,Blockly.JavaScript.ORDER_TYPEOF=4,Blockly.JavaScript.ORDER_VOID=4,Blockly.JavaScript.ORDER_DELETE=4,Blockly.JavaScript.ORDER_MULTIPLICATION=5,Blockly.JavaScript.ORDER_DIVISION=5,Blockly.JavaScript.ORDER_MODULUS=5,Blockly.JavaScript.ORDER_ADDITION=6,Blockly.JavaScript.ORDER_SUBTRACTION=6,Blockly.JavaScript.ORDER_BITWISE_SHIFT=7,Blockly.JavaScript.ORDER_RELATIONAL=8,Blockly.JavaScript.ORDER_IN=8,Blockly.JavaScript.ORDER_INSTANCEOF=8,Blockly.JavaScript.ORDER_EQUALITY=9,Blockly.JavaScript.ORDER_BITWISE_AND=10,Blockly.JavaScript.ORDER_BITWISE_XOR=11,Blockly.JavaScript.ORDER_BITWISE_OR=12,Blockly.JavaScript.ORDER_LOGICAL_AND=13,Blockly.JavaScript.ORDER_LOGICAL_OR=14,Blockly.JavaScript.ORDER_CONDITIONAL=15,Blockly.JavaScript.ORDER_ASSIGNMENT=16,Blockly.JavaScript.ORDER_COMMA=17,Blockly.JavaScript.ORDER_NONE=99,Blockly.JavaScript.INFINITE_LOOP_TRAP=null,Blockly.JavaScript.init=function(e){if(Blockly.JavaScript.definitions_={},Blockly.Variables&&(Blockly.JavaScript.variableDB_?Blockly.JavaScript.variableDB_.reset():Blockly.JavaScript.variableDB_=new Blockly.Names(Blockly.JavaScript.RESERVED_WORDS_),!Blockly.varsInGlobals)){var t=[];e=Blockly.Variables.allVariables(e);for(var o=0;o<e.length;o++)t[o]="var "+Blockly.JavaScript.variableDB_.getName(e[o],Blockly.Variables.NAME_TYPE)+";";Blockly.JavaScript.definitions_.variables=t.join("\n")}},Blockly.JavaScript.finish=function(e){var t,o=[];for(t in Blockly.JavaScript.definitions_)o.push(Blockly.JavaScript.definitions_[t]);return o.join("\n\n")+"\n\n\n"+e},Blockly.JavaScript.scrubNakedValue=function(e){return e+";\n"},Blockly.JavaScript.quote_=function(e){return"'"+(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'"))+"'"},Blockly.JavaScript.translateVarName=function(e){var t=Blockly.JavaScript.variableDB_.getName(e,Blockly.Variables.NAME_TYPE);return Blockly.varsInGlobals?Blockly.JavaScript.variableDB_.checkSpecificType(e,Blockly.Variables.NAME_TYPE,Blockly.Variables.NAME_TYPE_LOCAL)?t:"Globals."+t:t},Blockly.JavaScript.scrub_=function(e,t,o){return null===t?"":(e=!e.skipNextBlockGeneration&&e.nextConnection&&e.nextConnection.targetBlock(),t+(o=this.blockToCode(e,o)))},Blockly.JavaScript.colour={},Blockly.JavaScript.colour_picker=function(){return["'"+this.getTitleValue("COLOUR")+"'",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.colour_random=function(){if(!Blockly.JavaScript.definitions_.colour_random){var e=Blockly.JavaScript.variableDB_.getDistinctName("colour_random",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.colour_random.functionName=e;var t=[];t.push("function "+e+"() {"),t.push("  var num = Math.floor(Math.random() * Math.pow(2, 24));"),t.push("  return '#' + ('00000' + num.toString(16)).substr(-6);"),t.push("}"),Blockly.JavaScript.definitions_.colour_random=t.join("\n")}return[Blockly.JavaScript.colour_random.functionName+"()",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.colour_rgb=function(){var e=Blockly.JavaScript.valueToCode(this,"RED",Blockly.JavaScript.ORDER_COMMA)||0,t=Blockly.JavaScript.valueToCode(this,"GREEN",Blockly.JavaScript.ORDER_COMMA)||0,o=Blockly.JavaScript.valueToCode(this,"BLUE",Blockly.JavaScript.ORDER_COMMA)||0;if(!Blockly.JavaScript.definitions_.colour_rgb){var n=Blockly.JavaScript.variableDB_.getDistinctName("colour_rgb",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.colour_rgb.functionName=n;var i=[];i.push("function "+n+"(r, g, b) {"),i.push("  r = Math.round(Math.max(Math.min(Number(r), 255), 0));"),i.push("  g = Math.round(Math.max(Math.min(Number(g), 255), 0));"),i.push("  b = Math.round(Math.max(Math.min(Number(b), 255), 0));"),i.push("  r = ('0' + (r || 0).toString(16)).slice(-2);"),i.push("  g = ('0' + (g || 0).toString(16)).slice(-2);"),i.push("  b = ('0' + (b || 0).toString(16)).slice(-2);"),i.push("  return '#' + r + g + b;"),i.push("}"),Blockly.JavaScript.definitions_.colour_rgb=i.join("\n")}return[Blockly.JavaScript.colour_rgb.functionName+"("+e+", "+t+", "+o+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.colour_blend=function(){var e=Blockly.JavaScript.valueToCode(this,"COLOUR1",Blockly.JavaScript.ORDER_COMMA)||"'#000000'",t=Blockly.JavaScript.valueToCode(this,"COLOUR2",Blockly.JavaScript.ORDER_COMMA)||"'#000000'",o=Blockly.JavaScript.valueToCode(this,"RATIO",Blockly.JavaScript.ORDER_COMMA)||.5;if(!Blockly.JavaScript.definitions_.colour_blend){var n=Blockly.JavaScript.variableDB_.getDistinctName("colour_blend",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.colour_blend.functionName=n;var i=[];i.push("function "+n+"(c1, c2, ratio) {"),i.push("  ratio = Math.max(Math.min(Number(ratio), 1), 0);"),i.push("  var r1 = parseInt(c1.substring(1, 3), 16);"),i.push("  var g1 = parseInt(c1.substring(3, 5), 16);"),i.push("  var b1 = parseInt(c1.substring(5, 7), 16);"),i.push("  var r2 = parseInt(c2.substring(1, 3), 16);"),i.push("  var g2 = parseInt(c2.substring(3, 5), 16);"),i.push("  var b2 = parseInt(c2.substring(5, 7), 16);"),i.push("  var r = Math.round(r1 * (1 - ratio) + r2 * ratio);"),i.push("  var g = Math.round(g1 * (1 - ratio) + g2 * ratio);"),i.push("  var b = Math.round(b1 * (1 - ratio) + b2 * ratio);"),i.push("  r = ('0' + (r || 0).toString(16)).slice(-2);"),i.push("  g = ('0' + (g || 0).toString(16)).slice(-2);"),i.push("  b = ('0' + (b || 0).toString(16)).slice(-2);"),i.push("  return '#' + r + g + b;"),i.push("}"),Blockly.JavaScript.definitions_.colour_blend=i.join("\n")}return[Blockly.JavaScript.colour_blend.functionName+"("+e+", "+t+", "+o+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.functionalExamples={},Blockly.JavaScript.functional_example=function(){return["("+(Blockly.JavaScript.statementToCode(this,"EXPECTED",Blockly.JavaScript.ORDER_NONE)||"null")+" == "+(Blockly.JavaScript.statementToCode(this,"ACTUAL",Blockly.JavaScript.ORDER_NONE)||"null")+")",0]},Blockly.JavaScript.functionalParameters={},Blockly.JavaScript.functional_parameters_get=function(){return Blockly.JavaScript.translateVarName(this.getTitleValue("VAR"))},Blockly.JavaScript.functionalProcedures={},Blockly.JavaScript.functional_definition=function(){for(var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE),t=[],o=0;o<this.parameterNames_.length;o++)t[o]=Blockly.JavaScript.variableDB_.getName(this.parameterNames_[o],Blockly.Variables.NAME_TYPE,Blockly.Variables.NAME_TYPE_LOCAL);o="",Blockly.JavaScript.INFINITE_LOOP_TRAP&&(o=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+o);var n=Blockly.JavaScript.statementToCode(this,"STACK",Blockly.JavaScript.ORDER_NONE)||"";return n&&(n="  return "+n+";\n"),t=(Blockly.varsInGlobals?"Globals."+e+" = function":"function "+e)+"("+t.join(", ")+") {\n"+o+n+"\n}",t=Blockly.JavaScript.scrub_(this,t),Blockly.JavaScript.definitions_[e]=t,null},Blockly.JavaScript.functional_call=function(){for(var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE),t=[],o=0;o<this.currentParameterNames_.length;o++)t[o]=Blockly.JavaScript.statementToCode(this,"ARG"+o,Blockly.JavaScript.ORDER_COMMA)||"null";return(Blockly.varsInGlobals?"Globals.":"")+e+"("+t.join(", ")+")"},Blockly.JavaScript.functional_pass=function(){var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE);return(Blockly.varsInGlobals?"Globals.":"")+e},Blockly.JavaScript.procedural_to_functional_call=function(){for(var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE),t=[],o=0;o<this.currentParameterNames_.length;o++){var n=Blockly.JavaScript.valueToCode(this,"ARG"+o,Blockly.JavaScript.ORDER_COMMA);t[o]=n||"null"}return[(Blockly.varsInGlobals?"Globals.":"")+e+"("+t.join(", ")+")",Blockly.JavaScript.ORDER_NONE]},Blockly.JavaScript.lists={},Blockly.JavaScript.lists_create_empty=function(){return["[]",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.lists_create_with=function(){for(var e=Array(this.itemCount_),t=0;t<this.itemCount_;t++)e[t]=Blockly.JavaScript.valueToCode(this,"ADD"+t,Blockly.JavaScript.ORDER_COMMA)||"null";return[e="["+e.join(", ")+"]",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.lists_repeat=function(){if(!Blockly.JavaScript.definitions_.lists_repeat){var e=Blockly.JavaScript.variableDB_.getDistinctName("lists_repeat",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.lists_repeat.repeat=e;var t=[];t.push("function "+e+"(value, n) {"),t.push("  var array = [];"),t.push("  for (var i = 0; i < n; i++) {"),t.push("    array[i] = value;"),t.push("  }"),t.push("  return array;"),t.push("}"),Blockly.JavaScript.definitions_.lists_repeat=t.join("\n")}return e=Blockly.JavaScript.valueToCode(this,"ITEM",Blockly.JavaScript.ORDER_COMMA)||"null",t=Blockly.JavaScript.valueToCode(this,"NUM",Blockly.JavaScript.ORDER_COMMA)||"0",[Blockly.JavaScript.lists_repeat.repeat+"("+e+", "+t+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.lists_length=function(){return[(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_FUNCTION_CALL)||"''")+".length",Blockly.JavaScript.ORDER_MEMBER]},Blockly.JavaScript.lists_isEmpty=function(){return["!"+(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"[]")+".length",Blockly.JavaScript.ORDER_LOGICAL_NOT]},Blockly.JavaScript.lists_indexOf=function(){var e="FIRST"==this.getTitleValue("END")?"indexOf":"lastIndexOf",t=Blockly.JavaScript.valueToCode(this,"FIND",Blockly.JavaScript.ORDER_NONE)||"''";return[(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"[]")+"."+e+"("+t+") + 1",Blockly.JavaScript.ORDER_MEMBER]},Blockly.JavaScript.lists_getIndex=function(){var e=this.getTitleValue("MODE")||"GET",t=this.getTitleValue("WHERE")||"FROM_START",o=Blockly.JavaScript.valueToCode(this,"AT",Blockly.JavaScript.ORDER_UNARY_NEGATION)||"1",n=Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"[]";if("FIRST"==t){if("GET"==e)return[n+"[0]",Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"==e)return[n+".shift()",Blockly.JavaScript.ORDER_MEMBER];if("REMOVE"==e)return n+".shift();\n"}else if("LAST"==t){if("GET"==e)return[n+".slice(-1)[0]",Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"==e)return[n+".pop()",Blockly.JavaScript.ORDER_MEMBER];if("REMOVE"==e)return n+".pop();\n"}else if("FROM_START"==t){if(o=Blockly.isNumber(o)?parseFloat(o)-1:o+" - 1","GET"==e)return[n+"["+o+"]",Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"==e)return[n+".splice("+o+", 1)[0]",Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"==e)return n+".splice("+o+", 1);\n"}else if("FROM_END"==t){if("GET"==e)return[n+".slice(-"+o+")[0]",Blockly.JavaScript.ORDER_FUNCTION_CALL];if("GET_REMOVE"==e||"REMOVE"==e){if(!Blockly.JavaScript.definitions_.lists_remove_from_end){t=Blockly.JavaScript.variableDB_.getDistinctName("lists_remove_from_end",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.lists_getIndex.lists_remove_from_end=t;var i=[];i.push("function "+t+"(list, x) {"),i.push("  x = list.length - x;"),i.push("  return list.splice(x, 1)[0];"),i.push("}"),Blockly.JavaScript.definitions_.lists_remove_from_end=i.join("\n")}if(o=Blockly.JavaScript.lists_getIndex.lists_remove_from_end+"("+n+", "+o+")","GET_REMOVE"==e)return[o,Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"==e)return o+";\n"}}else if("RANDOM"==t){if(Blockly.JavaScript.definitions_.lists_get_random_item||(t=Blockly.JavaScript.variableDB_.getDistinctName("lists_get_random_item",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.lists_getIndex.random=t,(i=[]).push("function "+t+"(list, remove) {"),i.push("  var x = Math.floor(Math.random() * list.length);"),i.push("  if (remove) {"),i.push("    return list.splice(x, 1)[0];"),i.push("  } else {"),i.push("    return list[x];"),i.push("  }"),i.push("}"),Blockly.JavaScript.definitions_.lists_get_random_item=i.join("\n")),o=Blockly.JavaScript.lists_getIndex.random+"("+n+", "+("GET"!=e)+")","GET"==e||"GET_REMOVE"==e)return[o,Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"==e)return o+";\n"}throw"Unhandled combination (lists_getIndex)."},Blockly.JavaScript.lists_setIndex=function(){function e(){if(t.match(/^\w+$/))return"";var e=Blockly.JavaScript.variableDB_.getDistinctName("tmp_list",Blockly.Variables.NAME_TYPE),o="var "+e+" = "+t+";\n";return t=e,o}var t=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_MEMBER)||"[]",o=this.getTitleValue("MODE")||"GET",n=this.getTitleValue("WHERE")||"FROM_START",i=Blockly.JavaScript.valueToCode(this,"AT",Blockly.JavaScript.ORDER_NONE)||"1",r=Blockly.JavaScript.valueToCode(this,"TO",Blockly.JavaScript.ORDER_ASSIGNMENT)||"null";if("FIRST"==n){if("SET"==o)return t+"[0] = "+r+";\n";if("INSERT"==o)return t+".unshift("+r+");\n"}else if("LAST"==n){if("SET"==o)return(n=e())+(t+"[")+t+".length - 1] = "+r+";\n";if("INSERT"==o)return t+".push("+r+");\n"}else if("FROM_START"==n){if(i=Blockly.isNumber(i)?parseFloat(i)-1:i+" - 1","SET"==o)return t+"["+i+"] = "+r+";\n";if("INSERT"==o)return t+".splice("+i+", 0, "+r+");\n"}else if("FROM_END"==n){if(n=e(),"SET"==o)return n+(t+"[")+t+".length - "+i+"] = "+r+";\n";if("INSERT"==o)return n+(t+".splice(")+t+".length - "+i+", 0, "+r+");\n"}else if("RANDOM"==n){if(n=e(),n+="var "+(i=Blockly.JavaScript.variableDB_.getDistinctName("tmp_x",Blockly.Variables.NAME_TYPE))+" = Math.floor(Math.random() * "+t+".length);\n","SET"==o)return n+(t+"[")+i+"] = "+r+";\n";if("INSERT"==o)return n+(t+".splice(")+i+", 0, "+r+");\n"}throw"Unhandled combination (lists_setIndex)."},Blockly.JavaScript.lists_getSublist=function(){var e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_MEMBER)||"[]",t=this.getTitleValue("WHERE1"),o=this.getTitleValue("WHERE2"),n=Blockly.JavaScript.valueToCode(this,"AT1",Blockly.JavaScript.ORDER_NONE)||"1",i=Blockly.JavaScript.valueToCode(this,"AT2",Blockly.JavaScript.ORDER_NONE)||"1";if("FIRST"==t&&"LAST"==o)e+=".concat()";else{if(!Blockly.JavaScript.definitions_.lists_get_sublist){var r=Blockly.JavaScript.variableDB_.getDistinctName("lists_get_sublist",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.lists_getSublist.func=r;var l=[];l.push("function "+r+"(list, where1, at1, where2, at2) {"),l.push("  function getAt(where, at) {"),l.push("    if (where == 'FROM_START') {"),l.push("      at--;"),l.push("    } else if (where == 'FROM_END') {"),l.push("      at = list.length - at;"),l.push("    } else if (where == 'FIRST') {"),l.push("      at = 0;"),l.push("    } else if (where == 'LAST') {"),l.push("      at = list.length - 1;"),l.push("    } else {"),l.push("      throw 'Unhandled option (lists_getSublist).';"),l.push("    }"),l.push("    return at;"),l.push("  }"),l.push("  at1 = getAt(where1, at1);"),l.push("  at2 = getAt(where2, at2) + 1;"),l.push("  return list.slice(at1, at2);"),l.push("}"),Blockly.JavaScript.definitions_.lists_get_sublist=l.join("\n")}e=Blockly.JavaScript.lists_getSublist.func+"("+e+", '"+t+"', "+n+", '"+o+"', "+i+")"}return[e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.logic={},Blockly.JavaScript.controls_if=function(){var e=0,t=Blockly.JavaScript.valueToCode(this,"IF"+e,Blockly.JavaScript.ORDER_NONE)||"false",o=Blockly.JavaScript.statementToCode(this,"DO"+e),n="if ("+t+") {\n"+o+"}";for(e=1;e<=this.elseifCount_;e++)n+=" else if ("+(t=Blockly.JavaScript.valueToCode(this,"IF"+e,Blockly.JavaScript.ORDER_NONE)||"false")+") {\n"+(o=Blockly.JavaScript.statementToCode(this,"DO"+e))+"}";return this.elseCount_&&(n+=" else {\n"+(o=Blockly.JavaScript.statementToCode(this,"ELSE"))+"}\n"),n+"\n"},Blockly.JavaScript.logic_compare=function(){var e=this.getTitleValue("OP"),t="=="==(e=Blockly.JavaScript.logic_compare.OPERATORS[e])||"!="==e?Blockly.JavaScript.ORDER_EQUALITY:Blockly.JavaScript.ORDER_RELATIONAL;return[(Blockly.JavaScript.valueToCode(this,"A",t)||"0")+" "+e+" "+(Blockly.JavaScript.valueToCode(this,"B",t)||"0"),t]},Blockly.JavaScript.logic_compare.OPERATORS={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="},Blockly.JavaScript.logic_operation=function(){var e="AND"==this.getTitleValue("OP")?"&&":"||",t="&&"==e?Blockly.JavaScript.ORDER_LOGICAL_AND:Blockly.JavaScript.ORDER_LOGICAL_OR;return[(Blockly.JavaScript.valueToCode(this,"A",t)||"false")+" "+e+" "+(Blockly.JavaScript.valueToCode(this,"B",t)||"false"),t]},Blockly.JavaScript.logic_negate=function(){var e=Blockly.JavaScript.ORDER_LOGICAL_NOT;return["!"+(Blockly.JavaScript.valueToCode(this,"BOOL",e)||"false"),e]},Blockly.JavaScript.logic_boolean=function(){return["TRUE"==this.getTitleValue("BOOL")?"true":"false",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.logic_null=function(){return["null",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.logic_ternary=function(){return[(Blockly.JavaScript.valueToCode(this,"IF",Blockly.JavaScript.ORDER_CONDITIONAL)||"false")+" ? "+(Blockly.JavaScript.valueToCode(this,"THEN",Blockly.JavaScript.ORDER_CONDITIONAL)||"null")+" : "+(Blockly.JavaScript.valueToCode(this,"ELSE",Blockly.JavaScript.ORDER_CONDITIONAL)||"null"),Blockly.JavaScript.ORDER_CONDITIONAL]},Blockly.JavaScript.loops={},Blockly.JavaScript.controls_repeat=function(){var e=Number(this.getTitleValue("TIMES"))||0,t=Blockly.JavaScript.statementToCode(this,"DO");Blockly.JavaScript.INFINITE_LOOP_TRAP&&(t=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+t);var o=Blockly.JavaScript.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE);return"for (var "+o+" = 0; "+o+" < "+e+"; "+o+"++) {\n"+t+"}\n"},Blockly.JavaScript.controls_repeat_ext=function(){var e=Blockly.JavaScript.valueToCode(this,"TIMES",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",t=Blockly.JavaScript.statementToCode(this,"DO");Blockly.JavaScript.INFINITE_LOOP_TRAP&&(t=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+t);var o="",n=Blockly.JavaScript.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),i=e;return e.match(/^\w+$/)||Blockly.isNumber(e)||(o+="var "+(i=Blockly.JavaScript.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE))+" = "+e+";\n"),o+"for (var "+n+" = 0; "+n+" < "+i+"; "+n+"++) {\n"+t+"}\n"},Blockly.JavaScript.controls_whileUntil=function(){var e="UNTIL"==this.getTitleValue("MODE"),t=Blockly.JavaScript.valueToCode(this,"BOOL",e?Blockly.JavaScript.ORDER_LOGICAL_NOT:Blockly.JavaScript.ORDER_NONE)||"false",o=Blockly.JavaScript.statementToCode(this,"DO");return Blockly.JavaScript.INFINITE_LOOP_TRAP&&(o=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+o),e&&(t="!"+t),"while ("+t+") {\n"+o+"}\n"},Blockly.JavaScript.controls_for=function(){var e=Blockly.JavaScript.translateVarName(this.getTitleValue("VAR")),t=Blockly.JavaScript.valueToCode(this,"FROM",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",o=Blockly.JavaScript.valueToCode(this,"TO",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",n=Blockly.JavaScript.valueToCode(this,"BY",Blockly.JavaScript.ORDER_ASSIGNMENT)||"1",i=Blockly.JavaScript.statementToCode(this,"DO");if(Blockly.JavaScript.INFINITE_LOOP_TRAP&&(i=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+i),Blockly.isNumber(t)&&Blockly.isNumber(o)&&Blockly.isNumber(n)){var r=parseFloat(t)<=parseFloat(o),l="for ("+e+" = "+t+"; "+e+(r?" <= ":" >= ")+o+"; "+e;1===(e=Math.abs(parseFloat(n)))?l+=r?"++":"--":(l+=(r?" += ":" -= ")+e,0===e&&(i='  throw new Error("Infinity");\n'+i)),l+=") {\n"+i+"}\n"}else{l="";var s=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("VAR"),Blockly.Variables.NAME_TYPE);r=t,t.match(/^\w+$/)||Blockly.isNumber(t)||(l+="var "+(r=Blockly.JavaScript.variableDB_.getDistinctName(s+"_start",Blockly.Variables.NAME_TYPE))+" = "+t+";\n"),t=o,o.match(/^\w+$/)||Blockly.isNumber(o)||(l+="var "+(t=Blockly.JavaScript.variableDB_.getDistinctName(s+"_end",Blockly.Variables.NAME_TYPE))+" = "+o+";\n"),l+="var "+(o=Blockly.JavaScript.variableDB_.getDistinctName(s+"_inc",Blockly.Variables.NAME_TYPE))+" = ",l=(l=Blockly.isNumber(n)?l+(Math.abs(n)+";\n"):l+"Math.abs("+n+");\n")+"if ("+r+" > "+t+") {\n  "+o+" = -"+o+";\n}\n",l+="for ("+e+" = "+r+";\n     "+o+" >= 0 ? "+e+" <= "+t+" : "+e+" >= "+t+";\n     "+e+" += "+o+") {\n"+i+"}\n"}return l},Blockly.JavaScript.controls_forEach=function(){var e=Blockly.JavaScript.translateVarName(this.getTitleValue("VAR")),t=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_ASSIGNMENT)||"[]",o=Blockly.JavaScript.statementToCode(this,"DO");Blockly.JavaScript.INFINITE_LOOP_TRAP&&(o=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+o);var n=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("VAR"),Blockly.Variables.NAME_TYPE),i=Blockly.JavaScript.variableDB_.getDistinctName(n+"_index",Blockly.Variables.NAME_TYPE);return t.match(/^\w+$/)?e="for (var "+i+" in  "+t+") {\n  "+e+" = "+t+"["+i+"];\n"+o+"}\n":e="var "+(n=Blockly.JavaScript.variableDB_.getDistinctName(n+"_list",Blockly.Variables.NAME_TYPE))+" = "+t+";\nfor (var "+i+" in "+n+") {\n  "+e+" = "+n+"["+i+"];\n"+o+"}\n",e},Blockly.JavaScript.controls_flow_statements=function(){switch(this.getTitleValue("FLOW")){case"BREAK":return"break;\n";case"CONTINUE":return"continue;\n"}throw"Unknown flow statement."},Blockly.JavaScript.math={},Blockly.JavaScript.math_number=function(){return[window.parseFloat(this.getTitleValue("NUM"))||0,Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.math_arithmetic=function(){var e=this.getTitleValue("OP"),t=Blockly.JavaScript.math_arithmetic.OPERATORS[e];e=t[0],t=t[1];var o=Blockly.JavaScript.valueToCode(this,"A",t)||"0",n=Blockly.JavaScript.valueToCode(this,"B",t)||"0";return e?[o+e+n,t]:["Math.pow("+o+", "+n+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.math_arithmetic.OPERATORS={ADD:[" + ",Blockly.JavaScript.ORDER_ADDITION],MINUS:[" - ",Blockly.JavaScript.ORDER_SUBTRACTION],MULTIPLY:[" * ",Blockly.JavaScript.ORDER_MULTIPLICATION],DIVIDE:[" / ",Blockly.JavaScript.ORDER_DIVISION],POWER:[null,Blockly.JavaScript.ORDER_COMMA]},Blockly.JavaScript.math_single=function(){var e=this.getTitleValue("OP");if("NEG"==e){var t=Blockly.JavaScript.valueToCode(this,"NUM",Blockly.JavaScript.ORDER_UNARY_NEGATION)||"0";return"-"==t[0]&&(t=" "+t),["-"+t,Blockly.JavaScript.ORDER_UNARY_NEGATION]}switch(t="SIN"==e||"COS"==e||"TAN"==e?Blockly.JavaScript.valueToCode(this,"NUM",Blockly.JavaScript.ORDER_DIVISION)||"0":Blockly.JavaScript.valueToCode(this,"NUM",Blockly.JavaScript.ORDER_NONE)||"0",e){case"ABS":var o="Math.abs("+t+")";break;case"ROOT":o="Math.sqrt("+t+")";break;case"LN":o="Math.log("+t+")";break;case"EXP":o="Math.exp("+t+")";break;case"POW10":o="Math.pow(10,"+t+")";break;case"ROUND":o="Math.round("+t+")";break;case"ROUNDUP":o="Math.ceil("+t+")";break;case"ROUNDDOWN":o="Math.floor("+t+")";break;case"SIN":o="Math.sin("+t+" / 180 * Math.PI)";break;case"COS":o="Math.cos("+t+" / 180 * Math.PI)";break;case"TAN":o="Math.tan("+t+" / 180 * Math.PI)"}if(o)return[o,Blockly.JavaScript.ORDER_FUNCTION_CALL];switch(e){case"LOG10":o="Math.log("+t+") / Math.log(10)";break;case"ASIN":o="Math.asin("+t+") / Math.PI * 180";break;case"ACOS":o="Math.acos("+t+") / Math.PI * 180";break;case"ATAN":o="Math.atan("+t+") / Math.PI * 180";break;default:throw"Unknown math operator: "+e}return[o,Blockly.JavaScript.ORDER_DIVISION]},Blockly.JavaScript.math_constant=function(){var e=this.getTitleValue("CONSTANT");return Blockly.JavaScript.math_constant.CONSTANTS[e]},Blockly.JavaScript.math_constant.CONSTANTS={PI:["Math.PI",Blockly.JavaScript.ORDER_MEMBER],E:["Math.E",Blockly.JavaScript.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",Blockly.JavaScript.ORDER_DIVISION],SQRT2:["Math.SQRT2",Blockly.JavaScript.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",Blockly.JavaScript.ORDER_MEMBER],INFINITY:["Infinity",Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.math_number_property=function(){var e=Blockly.JavaScript.valueToCode(this,"NUMBER_TO_CHECK",Blockly.JavaScript.ORDER_MODULUS)||"0",t=this.getTitleValue("PROPERTY");if("PRIME"==t){if(!Blockly.JavaScript.definitions_.isPrime){t=Blockly.JavaScript.variableDB_.getDistinctName("isPrime",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.logic_prime=t;var o=[];o.push("function "+t+"(n) {"),o.push("  // http://en.wikipedia.org/wiki/Primality_test#Naive_methods"),o.push("  if (n == 2 || n == 3) {"),o.push("    return true;"),o.push("  }"),o.push("  // False if n is NaN, negative, is 1, or not whole."),o.push("  // And false if n is divisible by 2 or 3."),o.push("  if (isNaN(n) || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {"),o.push("    return false;"),o.push("  }"),o.push("  // Check all the numbers of form 6k +/- 1, up to sqrt(n)."),o.push("  for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {"),o.push("    if (n % (x - 1) == 0 || n % (x + 1) == 0) {"),o.push("      return false;"),o.push("    }"),o.push("  }"),o.push("  return true;"),o.push("}"),Blockly.JavaScript.definitions_.isPrime=o.join("\n")}return[o=Blockly.JavaScript.logic_prime+"("+e+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]}switch(t){case"EVEN":o=e+" % 2 == 0";break;case"ODD":o=e+" % 2 == 1";break;case"WHOLE":o=e+" % 1 == 0";break;case"POSITIVE":o=e+" > 0";break;case"NEGATIVE":o=e+" < 0";break;case"DIVISIBLE_BY":o=e+" % "+(t=Blockly.JavaScript.valueToCode(this,"DIVISOR",Blockly.JavaScript.ORDER_MODULUS)||"0")+" == 0"}return[o,Blockly.JavaScript.ORDER_EQUALITY]},Blockly.JavaScript.math_change=function(){var e=Blockly.JavaScript.valueToCode(this,"DELTA",Blockly.JavaScript.ORDER_ADDITION)||"0",t=Blockly.JavaScript.translateVarName(this.getTitleValue("VAR"));return t+" = (typeof "+t+" == 'number' ? "+t+" : 0) + "+e+";\n"},Blockly.JavaScript.math_round=Blockly.JavaScript.math_single,Blockly.JavaScript.math_trig=Blockly.JavaScript.math_single,Blockly.JavaScript.math_on_list=function(){var e=this.getTitleValue("OP");switch(e){case"SUM":e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_MEMBER)||"[]",e+=".reduce(function(x, y) {return x + y;})";break;case"MIN":e="Math.min.apply(null, "+(e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_COMMA)||"[]")+")";break;case"MAX":e="Math.max.apply(null, "+(e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_COMMA)||"[]")+")";break;case"AVERAGE":if(!Blockly.JavaScript.definitions_.math_mean){var t=Blockly.JavaScript.variableDB_.getDistinctName("math_mean",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.math_on_list.math_mean=t,(e=[]).push("function "+t+"(myList) {"),e.push("  return myList.reduce(function(x, y) {return x + y;}) / myList.length;"),e.push("}"),Blockly.JavaScript.definitions_.math_mean=e.join("\n")}e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_NONE)||"[]",e=Blockly.JavaScript.math_on_list.math_mean+"("+e+")";break;case"MEDIAN":Blockly.JavaScript.definitions_.math_median||(t=Blockly.JavaScript.variableDB_.getDistinctName("math_median",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.math_on_list.math_median=t,(e=[]).push("function "+t+"(myList) {"),e.push("  var localList = myList.filter(function (x) {return typeof x == 'number';});"),e.push("  if (!localList.length) return null;"),e.push("  localList.sort(function(a, b) {return b - a;});"),e.push("  if (localList.length % 2 == 0) {"),e.push("    return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;"),e.push("  } else {"),e.push("    return localList[(localList.length - 1) / 2];"),e.push("  }"),e.push("}"),Blockly.JavaScript.definitions_.math_median=e.join("\n")),e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_NONE)||"[]",e=Blockly.JavaScript.math_on_list.math_median+"("+e+")";break;case"MODE":Blockly.JavaScript.definitions_.math_modes||(t=Blockly.JavaScript.variableDB_.getDistinctName("math_modes",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.math_on_list.math_modes=t,(e=[]).push("function "+t+"(values) {"),e.push("  var modes = [];"),e.push("  var counts = [];"),e.push("  var maxCount = 0;"),e.push("  for (var i = 0; i < values.length; i++) {"),e.push("    var value = values[i];"),e.push("    var found = false;"),e.push("    var thisCount;"),e.push("    for (var j = 0; j < counts.length; j++) {"),e.push("      if (counts[j][0] === value) {"),e.push("        thisCount = ++counts[j][1];"),e.push("        found = true;"),e.push("        break;"),e.push("      }"),e.push("    }"),e.push("    if (!found) {"),e.push("      counts.push([value, 1]);"),e.push("      thisCount = 1;"),e.push("    }"),e.push("    maxCount = Math.max(thisCount, maxCount);"),e.push("  }"),e.push("  for (var j = 0; j < counts.length; j++) {"),e.push("    if (counts[j][1] == maxCount) {"),e.push("        modes.push(counts[j][0]);"),e.push("    }"),e.push("  }"),e.push("  return modes;"),e.push("}"),Blockly.JavaScript.definitions_.math_modes=e.join("\n")),e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_NONE)||"[]",e=Blockly.JavaScript.math_on_list.math_modes+"("+e+")";break;case"STD_DEV":Blockly.JavaScript.definitions_.math_standard_deviation||(t=Blockly.JavaScript.variableDB_.getDistinctName("math_standard_deviation",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.math_on_list.math_standard_deviation=t,(e=[]).push("function "+t+"(numbers) {"),e.push("  var n = numbers.length;"),e.push("  if (!n) return null;"),e.push("  var mean = numbers.reduce(function(x, y) {return x + y;}) / n;"),e.push("  var variance = 0;"),e.push("  for (var j = 0; j < n; j++) {"),e.push("    variance += Math.pow(numbers[j] - mean, 2);"),e.push("  }"),e.push("  variance = variance / n;"),e.push("  return Math.sqrt(variance);"),e.push("}"),Blockly.JavaScript.definitions_.math_standard_deviation=e.join("\n")),e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_NONE)||"[]",e=Blockly.JavaScript.math_on_list.math_standard_deviation+"("+e+")";break;case"RANDOM":Blockly.JavaScript.definitions_.math_random_item||(t=Blockly.JavaScript.variableDB_.getDistinctName("math_random_item",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.math_on_list.math_random_item=t,(e=[]).push("function "+t+"(list) {"),e.push("  var x = Math.floor(Math.random() * list.length);"),e.push("  return list[x];"),e.push("}"),Blockly.JavaScript.definitions_.math_random_item=e.join("\n")),e=Blockly.JavaScript.valueToCode(this,"LIST",Blockly.JavaScript.ORDER_NONE)||"[]",e=Blockly.JavaScript.math_on_list.math_random_item+"("+e+")";break;default:throw"Unknown operator: "+e}return[e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.math_modulo=function(){return[(Blockly.JavaScript.valueToCode(this,"DIVIDEND",Blockly.JavaScript.ORDER_MODULUS)||"0")+" % "+(Blockly.JavaScript.valueToCode(this,"DIVISOR",Blockly.JavaScript.ORDER_MODULUS)||"0"),Blockly.JavaScript.ORDER_MODULUS]},Blockly.JavaScript.math_constrain=function(){return["Math.min(Math.max("+(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_COMMA)||"0")+", "+(Blockly.JavaScript.valueToCode(this,"LOW",Blockly.JavaScript.ORDER_COMMA)||"0")+"), "+(Blockly.JavaScript.valueToCode(this,"HIGH",Blockly.JavaScript.ORDER_COMMA)||"Infinity")+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.math_random_int=function(){var e=Blockly.JavaScript.valueToCode(this,"FROM",Blockly.JavaScript.ORDER_COMMA)||"0",t=Blockly.JavaScript.valueToCode(this,"TO",Blockly.JavaScript.ORDER_COMMA)||"0";if(!Blockly.JavaScript.definitions_.math_random_int){var o=Blockly.JavaScript.variableDB_.getDistinctName("math_random_int",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.math_random_int.random_function=o;var n=[];n.push("function "+o+"(a, b) {"),n.push("  if (a > b) {"),n.push("    // Swap a and b to ensure a is smaller."),n.push("    var c = a;"),n.push("    a = b;"),n.push("    b = c;"),n.push("  }"),n.push("  return Math.floor(Math.random() * (b - a + 1) + a);"),n.push("}"),Blockly.JavaScript.definitions_.math_random_int=n.join("\n")}return[Blockly.JavaScript.math_random_int.random_function+"("+e+", "+t+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.math_random_float=function(){return["Math.random()",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.procedures={},Blockly.JavaScript.procedures_defreturn=function(){var e=this.getTitle_("NAME");e=e.id&&"behavior_definition"===this.type?e.id:e.getValue(),e=Blockly.JavaScript.variableDB_.getName(e,Blockly.Procedures.NAME_TYPE);for(var t=[],o=0;o<this.parameterNames_.length;o++)t[o]=Blockly.JavaScript.variableDB_.getName(this.parameterNames_[o],Blockly.Variables.NAME_TYPE,Blockly.Variables.NAME_TYPE_LOCAL);o=Blockly.JavaScript.statementToCode(this,"STACK"),Blockly.JavaScript.INFINITE_LOOP_TRAP&&(o=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+o);var n=Blockly.JavaScript.valueToCode(this,"RETURN",Blockly.JavaScript.ORDER_NONE)||"";return n&&(n="  return "+n+";\n"),t=(Blockly.varsInGlobals?"Globals."+e+" = function":"function "+e)+"("+t.join(", ")+") {\n"+o+n+"}",t=Blockly.JavaScript.scrub_(this,t),Blockly.JavaScript.definitions_[e]=t,null},Blockly.JavaScript.procedures_defnoreturn=Blockly.JavaScript.procedures_defreturn,Blockly.JavaScript.procedures_callreturn=function(){for(var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE),t=[],o=0;o<this.currentParameterNames_.length;o++)t[o]=Blockly.JavaScript.valueToCode(this,"ARG"+o,Blockly.JavaScript.ORDER_COMMA)||"null";return[(Blockly.varsInGlobals?"Globals.":"")+e+"("+t.join(", ")+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.procedures_callnoreturn=function(){for(var e=Blockly.JavaScript.variableDB_.getName(this.getTitleValue("NAME"),Blockly.Procedures.NAME_TYPE),t=[],o=0;o<this.currentParameterNames_.length;o++)t[o]=Blockly.JavaScript.valueToCode(this,"ARG"+o,Blockly.JavaScript.ORDER_COMMA)||"null";return(Blockly.varsInGlobals?"Globals.":"")+e+"("+t.join(", ")+");\n"},Blockly.JavaScript.procedures_ifreturn=function(){var e="if ("+(Blockly.JavaScript.valueToCode(this,"CONDITION",Blockly.JavaScript.ORDER_NONE)||"false")+") {\n";this.hasReturnValue_?e+="  return "+(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_NONE)||"null")+";\n":e+="  return;\n";return e+"}\n"},Blockly.JavaScript.text=function(){return[Blockly.JavaScript.quote_(this.getTitleValue("TEXT")),Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.text_join=function(){if(0==this.itemCount_)return["''",Blockly.JavaScript.ORDER_ATOMIC];if(1==this.itemCount_){var e=Blockly.JavaScript.valueToCode(this,"ADD0",Blockly.JavaScript.ORDER_NONE)||"''";return["String("+e+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]}if(2==this.itemCount_){e=Blockly.JavaScript.valueToCode(this,"ADD0",Blockly.JavaScript.ORDER_NONE)||"''";var t=Blockly.JavaScript.valueToCode(this,"ADD1",Blockly.JavaScript.ORDER_NONE)||"''";return["String("+e+") + String("+t+")",Blockly.JavaScript.ORDER_ADDITION]}for(e=Array(this.itemCount_),t=0;t<this.itemCount_;t++)e[t]=Blockly.JavaScript.valueToCode(this,"ADD"+t,Blockly.JavaScript.ORDER_COMMA)||"''";return[e="["+e.join(",")+"].join('')",Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.text_append=function(){var e=Blockly.JavaScript.translateVarName(this.getTitleValue("VAR"));return e+" = String("+e+") + String("+(Blockly.JavaScript.valueToCode(this,"TEXT",Blockly.JavaScript.ORDER_NONE)||"''")+");\n"},Blockly.JavaScript.text_length=function(){return[(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_FUNCTION_CALL)||"''")+".length",Blockly.JavaScript.ORDER_MEMBER]},Blockly.JavaScript.text_isEmpty=function(){return["!"+(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"''"),Blockly.JavaScript.ORDER_LOGICAL_NOT]},Blockly.JavaScript.text_indexOf=function(){var e="FIRST"==this.getTitleValue("END")?"indexOf":"lastIndexOf",t=Blockly.JavaScript.valueToCode(this,"FIND",Blockly.JavaScript.ORDER_NONE)||"''";return[(Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"''")+"."+e+"("+t+") + 1",Blockly.JavaScript.ORDER_MEMBER]},Blockly.JavaScript.text_charAt=function(){var e=this.getTitleValue("WHERE")||"FROM_START",t=Blockly.JavaScript.valueToCode(this,"AT",Blockly.JavaScript.ORDER_UNARY_NEGATION)||"1",o=Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_MEMBER)||"''";switch(e){case"FIRST":return[o+".charAt(0)",Blockly.JavaScript.ORDER_FUNCTION_CALL];case"LAST":return[o+".slice(-1)",Blockly.JavaScript.ORDER_FUNCTION_CALL];case"FROM_START":return[o+".charAt("+(t=Blockly.isNumber(t)?parseFloat(t)-1:t+" - 1")+")",Blockly.JavaScript.ORDER_FUNCTION_CALL];case"FROM_END":return[o+".slice(-"+t+").charAt(0)",Blockly.JavaScript.ORDER_FUNCTION_CALL];case"RANDOM":return Blockly.JavaScript.definitions_.text_random_letter||(e=Blockly.JavaScript.variableDB_.getDistinctName("text_random_letter",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.text_charAt.text_random_letter=e,(t=[]).push("function "+e+"(text) {"),t.push("  var x = Math.floor(Math.random() * text.length);"),t.push("  return text[x];"),t.push("}"),Blockly.JavaScript.definitions_.text_random_letter=t.join("\n")),[o=Blockly.JavaScript.text_charAt.text_random_letter+"("+o+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]}throw"Unhandled option (text_charAt)."},Blockly.JavaScript.text_getSubstring=function(){var e=Blockly.JavaScript.valueToCode(this,"STRING",Blockly.JavaScript.ORDER_MEMBER)||"[]",t=this.getTitleValue("WHERE1"),o=this.getTitleValue("WHERE2"),n=Blockly.JavaScript.valueToCode(this,"AT1",Blockly.JavaScript.ORDER_NONE)||"1",i=Blockly.JavaScript.valueToCode(this,"AT2",Blockly.JavaScript.ORDER_NONE)||"1";if("FIRST"!=t||"LAST"!=o){if(!Blockly.JavaScript.definitions_.text_get_substring){var r=Blockly.JavaScript.variableDB_.getDistinctName("text_get_substring",Blockly.Generator.NAME_TYPE);Blockly.JavaScript.text_getSubstring.func=r;var l=[];l.push("function "+r+"(text, where1, at1, where2, at2) {"),l.push("  function getAt(where, at) {"),l.push("    if (where == 'FROM_START') {"),l.push("      at--;"),l.push("    } else if (where == 'FROM_END') {"),l.push("      at = text.length - at;"),l.push("    } else if (where == 'FIRST') {"),l.push("      at = 0;"),l.push("    } else if (where == 'LAST') {"),l.push("      at = text.length - 1;"),l.push("    } else {"),l.push("      throw 'Unhandled option (text_getSubstring).';"),l.push("    }"),l.push("    return at;"),l.push("  }"),l.push("  at1 = getAt(where1, at1);"),l.push("  at2 = getAt(where2, at2) + 1;"),l.push("  return text.slice(at1, at2);"),l.push("}"),Blockly.JavaScript.definitions_.text_get_substring=l.join("\n")}e=Blockly.JavaScript.text_getSubstring.func+"("+e+", '"+t+"', "+n+", '"+o+"', "+i+")"}return[e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.text_changeCase=function(){var e=this.getTitleValue("CASE");if(e=Blockly.JavaScript.text_changeCase.OPERATORS[e]){var t=Blockly.JavaScript.valueToCode(this,"TEXT",Blockly.JavaScript.ORDER_MEMBER)||"''";e=t+e}else Blockly.JavaScript.definitions_.text_toTitleCase||(e=Blockly.JavaScript.variableDB_.getDistinctName("text_toTitleCase",Blockly.Generator.NAME_TYPE),Blockly.JavaScript.text_changeCase.toTitleCase=e,(t=[]).push("function "+e+"(str) {"),t.push("  return str.replace(/\\S+/g,"),t.push("      function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});"),t.push("}"),Blockly.JavaScript.definitions_.text_toTitleCase=t.join("\n")),t=Blockly.JavaScript.valueToCode(this,"TEXT",Blockly.JavaScript.ORDER_NONE)||"''",e=Blockly.JavaScript.text_changeCase.toTitleCase+"("+t+")";return[e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.text_changeCase.OPERATORS={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null},Blockly.JavaScript.text_trim=function(){var e=this.getTitleValue("MODE");return e=Blockly.JavaScript.text_trim.OPERATORS[e],[(Blockly.JavaScript.valueToCode(this,"TEXT",Blockly.JavaScript.ORDER_MEMBER)||"''")+e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.text_trim.OPERATORS={LEFT:".trimLeft()",RIGHT:".trimRight()",BOTH:".trim()"},Blockly.JavaScript.text_print=function(){return"window.alert("+(Blockly.JavaScript.valueToCode(this,"TEXT",Blockly.JavaScript.ORDER_NONE)||"''")+");\n"},Blockly.JavaScript.text_prompt=function(){var e="window.prompt("+Blockly.JavaScript.quote_(this.getTitleValue("TEXT"))+")";return"NUMBER"==this.getTitleValue("TYPE")&&(e="window.parseFloat("+e+")"),[e,Blockly.JavaScript.ORDER_FUNCTION_CALL]},Blockly.JavaScript.variables={},Blockly.JavaScript.variables_get=function(){return[Blockly.JavaScript.translateVarName(this.getTitleValue("VAR")),Blockly.JavaScript.ORDER_ATOMIC]},Blockly.JavaScript.variables_set=function(){var e=Blockly.JavaScript.valueToCode(this,"VALUE",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";return Blockly.JavaScript.translateVarName(this.getTitleValue("VAR"))+" = "+e+";\n"},Blockly.JavaScript.parameters_get=Blockly.JavaScript.variables_get,Blockly.JavaScript.parameters_set=Blockly.JavaScript.variables_set,Blockly.JavaScript.sprite_variables_get=Blockly.JavaScript.variables_get,Blockly.JavaScript.sprite_variables_set=Blockly.JavaScript.variables_set,Blockly.assetUrl=void 0,Blockly.SVG_NS="http://www.w3.org/2000/svg",Blockly.HTML_NS="http://www.w3.org/1999/xhtml",Blockly.HSV_SATURATION=.45,Blockly.HSV_VALUE=.65,Blockly.makeColour=function(e,t,o){return goog.color.hsvToHex(e,t,256*o)},Blockly.INPUT_VALUE=1,Blockly.OUTPUT_VALUE=2,Blockly.NEXT_STATEMENT=3,Blockly.PREVIOUS_STATEMENT=4,Blockly.DUMMY_INPUT=5,Blockly.FUNCTIONAL_INPUT=6,Blockly.FUNCTIONAL_OUTPUT=7,Blockly.ALIGN_LEFT=-1,Blockly.ALIGN_CENTRE=0,Blockly.ALIGN_RIGHT=1,Blockly.OPPOSITE_TYPE=[],Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE]=Blockly.OUTPUT_VALUE,Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE]=Blockly.INPUT_VALUE,Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT]=Blockly.PREVIOUS_STATEMENT,Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT]=Blockly.NEXT_STATEMENT,Blockly.OPPOSITE_TYPE[Blockly.FUNCTIONAL_INPUT]=Blockly.FUNCTIONAL_OUTPUT,Blockly.OPPOSITE_TYPE[Blockly.FUNCTIONAL_OUTPUT]=Blockly.FUNCTIONAL_INPUT,Blockly.selected=null,Blockly.readOnly=!1,Blockly.showUnusedBlocks=!1,Blockly.highlightedConnection_=null,Blockly.localConnection_=null,Blockly.DRAG_RADIUS=5,Blockly.SNAP_RADIUS=15,Blockly.BUMP_UNCONNECTED=!0,Blockly.BUMP_DELAY=250,Blockly.COLLAPSE_CHARS=30,Blockly.mainBlockSpace=null,Blockly.mainBlockSpaceEditor=null,Blockly.clipboard_=null,Blockly.playAudio=function(e){Blockly.audioPlayer&&Blockly.audioPlayer.play(e)},Blockly.removeAllRanges=function(){function e(){try{window.getSelection().removeAllRanges()}catch(e){}}if(window.getSelection){var t=window.getSelection();t&&t.removeAllRanges&&(e(),window.setTimeout(function(){e()},0))}};var BlocklyModule={};goog.Timer.defaultTimerObject=window,module.exports=Blockly;
//# sourceMappingURL=blockly.js.map