text: var COMPILED=!0,goog=goog||{};goog.global=this;goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c=c[d]?c[d]:c[d]={}:c[d]=b};goog.define=function(a,b){var c=b;COMPILED||goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]);goog.exportPath_(a,c)};goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;
  goog.provide=function(a){if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a];for(var b=a;(b=b.substring(0,b.lastIndexOf(".")))&&!goog.getObjectByName(b);)goog.implicitNamespaces_[b]=!0}goog.exportPath_(a)};goog.setTestOnly=function(a){if(COMPILED&&!goog.DEBUG)throw a=a||"",Error("Importing test-only code into non-debug environment"+a?": "+a:".");};goog.forwardDeclare=function(a){};
  COMPILED||(goog.isProvided_=function(a){return!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={});goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};
  goog.addDependency=function(a,b,c){if(goog.DEPENDENCIES_ENABLED){var d;a=a.replace(/\\/g,"/");for(var e=goog.dependencies_,f=0;d=b[f];f++)e.nameToPath[d]=a,a in e.pathToNames||(e.pathToNames[a]={}),e.pathToNames[a][d]=!0;for(d=0;b=c[d];d++)a in e.requires||(e.requires[a]={}),e.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0;
  goog.require=function(a){if(!COMPILED&&!goog.isProvided_(a)){if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b){goog.included_[b]=!0;goog.writeScripts_();return}}a="goog.require could not find: "+a;goog.global.console&&goog.global.console.error(a);throw Error(a);}};goog.basePath="";goog.nullFunction=function(){};goog.identityFunction=function(a,b){return a};goog.abstractMethod=function(){throw Error("unimplemented abstract method");};
  goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;
  goog.DEPENDENCIES_ENABLED&&(goog.included_={},goog.dependencies_={pathToNames:{},nameToPath:{},requires:{},visited:{},written:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return"undefined"!=typeof a&&"write"in a},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH)goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("script"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:
  d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a){var b=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_;!goog.dependencies_.written[a]&&b(a)&&(goog.dependencies_.written[a]=!0)},goog.writeScriptTag_=function(a){if(goog.inHtmlDocument_()){var b=goog.global.document;if("complete"==b.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}b.write('<script type="text/javascript" src="'+a+'">\x3c/script>');
  return!0}return!1},goog.writeScripts_=function(){function a(e){if(!(e in d.written)){if(!(e in d.visited)&&(d.visited[e]=!0,e in d.requires))for(var g in d.requires[e])if(!goog.isProvided_(g))if(g in d.nameToPath)a(d.nameToPath[g]);else throw Error("Undefined nameToPath for "+g);e in c||(c[e]=!0,b.push(e))}}var b=[],c={},d=goog.dependencies_,e;for(e in goog.included_)d.written[e]||a(e);for(e=0;e<b.length;e++)if(b[e])goog.importScript_(goog.basePath+b[e]);else throw Error("Undefined script input");
  },goog.getPathFromDeps_=function(a){return a in goog.dependencies_.nameToPath?goog.dependencies_.nameToPath[a]:null},goog.findBasePath_(),goog.global.CLOSURE_NO_DEPS||goog.importScript_(goog.basePath+"deps.js"));
  goog.typeOf=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
  else if("function"==b&&"undefined"==typeof a.call)return"object";return b};goog.isDef=function(a){return void 0!==a};goog.isNull=function(a){return null===a};goog.isDefAndNotNull=function(a){return null!=a};goog.isArray=function(a){return"array"==goog.typeOf(a)};goog.isArrayLike=function(a){var b=goog.typeOf(a);return"array"==b||"object"==b&&"number"==typeof a.length};goog.isDateLike=function(a){return goog.isObject(a)&&"function"==typeof a.getFullYear};goog.isString=function(a){return"string"==typeof a};
  goog.isBoolean=function(a){return"boolean"==typeof a};goog.isNumber=function(a){return"number"==typeof a};goog.isFunction=function(a){return"function"==goog.typeOf(a)};goog.isObject=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b};goog.getUid=function(a){return a[goog.UID_PROPERTY_]||(a[goog.UID_PROPERTY_]=++goog.uidCounter_)};goog.hasUid=function(a){return!!a[goog.UID_PROPERTY_]};goog.removeUid=function(a){"removeAttribute"in a&&a.removeAttribute(goog.UID_PROPERTY_);try{delete a[goog.UID_PROPERTY_]}catch(b){}};
  goog.UID_PROPERTY_="closure_uid_"+(1E9*Math.random()>>>0);goog.uidCounter_=0;goog.getHashCode=goog.getUid;goog.removeHashCode=goog.removeUid;goog.cloneObject=function(a){var b=goog.typeOf(a);if("object"==b||"array"==b){if(a.clone)return a.clone();var b="array"==b?[]:{},c;for(c in a)b[c]=goog.cloneObject(a[c]);return b}return a};goog.bindNative_=function(a,b,c){return a.call.apply(a.bind,arguments)};
  goog.bindJs_=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}};goog.bind=function(a,b,c){Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_;return goog.bind.apply(null,arguments)};
  goog.partial=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}};goog.mixin=function(a,b){for(var c in b)a[c]=b[c]};goog.now=goog.TRUSTED_SITE&&Date.now||function(){return+new Date};
  goog.globalEval=function(a){if(goog.global.execScript)goog.global.execScript(a,"JavaScript");else if(goog.global.eval)if(null==goog.evalWorksForGlobals_&&(goog.global.eval("var _et_ = 1;"),"undefined"!=typeof goog.global._et_?(delete goog.global._et_,goog.evalWorksForGlobals_=!0):goog.evalWorksForGlobals_=!1),goog.evalWorksForGlobals_)goog.global.eval(a);else{var b=goog.global.document,c=b.createElement("script");c.type="text/javascript";c.defer=!1;c.appendChild(b.createTextNode(a));b.body.appendChild(c);
  b.body.removeChild(c)}else throw Error("goog.globalEval not available");};goog.evalWorksForGlobals_=null;goog.getCssName=function(a,b){var c=function(a){return goog.cssNameMapping_[a]||a},d=function(a){a=a.split("-");for(var b=[],d=0;d<a.length;d++)b.push(c(a[d]));return b.join("-")},d=goog.cssNameMapping_?"BY_WHOLE"==goog.cssNameMappingStyle_?c:d:function(a){return a};return b?a+"-"+d(b):d(a)};goog.setCssNameMapping=function(a,b){goog.cssNameMapping_=a;goog.cssNameMappingStyle_=b};
  !COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.getMsg=function(a,b){var c=b||{},d;for(d in c){var e=(""+c[d]).replace(/\$/g,"$$$$");a=a.replace(RegExp("\\{\\$"+d+"\\}","gi"),e)}return a};goog.getMsgWithFallback=function(a,b){return a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,c)};goog.exportProperty=function(a,b,c){a[b]=c};
  goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.base=function(a,c,f){var g=Array.prototype.slice.call(arguments,2);return b.prototype[c].apply(a,g)}};
  goog.base=function(a,b,c){var d=arguments.callee.caller;if(goog.DEBUG&&!d)throw Error("arguments.caller not defined.  goog.base() expects not to be running in strict mode. See http://www.ecma-international.org/ecma-262/5.1/#sec-C");if(d.superClass_)return d.superClass_.constructor.apply(a,Array.prototype.slice.call(arguments,1));for(var e=Array.prototype.slice.call(arguments,2),f=!1,g=a.constructor;g;g=g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,
  e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("goog.base called from a method of one name to a method of a different name");};goog.scope=function(a){a.call(goog.global)};var Blockly={ImageDimensionCache:{}};Blockly.ImageDimensionCache.imageDimensions_={};Blockly.ImageDimensionCache.IMAGE_LOADING_WIDTH=40;Blockly.ImageDimensionCache.IMAGE_LOADING_HEIGHT=40;Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate=function(a,b){var c=Blockly.ImageDimensionCache.getCachedDimensions(a);if(c)return c;Blockly.ImageDimensionCache.getDimensionsAsync(a,b);return{width:Blockly.ImageDimensionCache.IMAGE_LOADING_WIDTH,height:Blockly.ImageDimensionCache.IMAGE_LOADING_HEIGHT}};
  Blockly.ImageDimensionCache.getCachedDimensions=function(a){return Blockly.ImageDimensionCache.imageDimensions_[a]};Blockly.ImageDimensionCache.storeDimensions=function(a,b,c){Blockly.ImageDimensionCache.imageDimensions_[a]={width:b,height:c}};Blockly.ImageDimensionCache.getDimensionsAsync=function(a,b){var c=new Image;c.onload=function(){Blockly.ImageDimensionCache.storeDimensions(a,c.width,c.height);b(c.width,c.height)};c.src=a};goog.string={};goog.string.Unicode={NBSP:"\u00a0"};goog.string.startsWith=function(a,b){return 0==a.lastIndexOf(b,0)};goog.string.endsWith=function(a,b){var c=a.length-b.length;return 0<=c&&a.indexOf(b,c)==c};goog.string.caseInsensitiveStartsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(0,b.length))};goog.string.caseInsensitiveEndsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(a.length-b.length,b.length))};
  goog.string.caseInsensitiveEquals=function(a,b){return a.toLowerCase()==b.toLowerCase()};goog.string.subs=function(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};goog.string.collapseWhitespace=function(a){return a.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")};goog.string.isEmpty=function(a){return/^[\s\xa0]*$/.test(a)};goog.string.isEmptySafe=function(a){return goog.string.isEmpty(goog.string.makeSafe(a))};
  goog.string.isBreakingWhitespace=function(a){return!/[^\t\n\r ]/.test(a)};goog.string.isAlpha=function(a){return!/[^a-zA-Z]/.test(a)};goog.string.isNumeric=function(a){return!/[^0-9]/.test(a)};goog.string.isAlphaNumeric=function(a){return!/[^a-zA-Z0-9]/.test(a)};goog.string.isSpace=function(a){return" "==a};goog.string.isUnicodeChar=function(a){return 1==a.length&&" "<=a&&"~">=a||"\u0080"<=a&&"\ufffd">=a};goog.string.stripNewlines=function(a){return a.replace(/(\r\n|\r|\n)+/g," ")};
  goog.string.canonicalizeNewlines=function(a){return a.replace(/(\r\n|\r|\n)/g,"\n")};goog.string.normalizeWhitespace=function(a){return a.replace(/\xa0|\s/g," ")};goog.string.normalizeSpaces=function(a){return a.replace(/\xa0|[ \t]+/g," ")};goog.string.collapseBreakingSpaces=function(a){return a.replace(/[\t\r\n ]+/g," ").replace(/^[\t\r\n ]+|[\t\r\n ]+$/g,"")};goog.string.trim=function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};
  goog.string.trimLeft=function(a){return a.replace(/^[\s\xa0]+/,"")};goog.string.trimRight=function(a){return a.replace(/[\s\xa0]+$/,"")};goog.string.caseInsensitiveCompare=function(a,b){var c=String(a).toLowerCase(),d=String(b).toLowerCase();return c<d?-1:c==d?0:1};goog.string.numerateCompareRegExp_=/(\.\d+)|(\d+)|(\D+)/g;
  goog.string.numerateCompare=function(a,b){if(a==b)return 0;if(!a)return-1;if(!b)return 1;for(var c=a.toLowerCase().match(goog.string.numerateCompareRegExp_),d=b.toLowerCase().match(goog.string.numerateCompareRegExp_),e=Math.min(c.length,d.length),f=0;f<e;f++){var g=c[f],h=d[f];if(g!=h)return c=parseInt(g,10),!isNaN(c)&&(d=parseInt(h,10),!isNaN(d)&&c-d)?c-d:g<h?-1:1}return c.length!=d.length?c.length-d.length:a<b?-1:1};goog.string.urlEncode=function(a){return encodeURIComponent(String(a))};
  goog.string.urlDecode=function(a){return decodeURIComponent(a.replace(/\+/g," "))};goog.string.newLineToBr=function(a,b){return a.replace(/(\r\n|\r|\n)/g,b?"<br />":"<br>")};
  goog.string.htmlEscape=function(a,b){if(b)return a.replace(goog.string.amperRe_,"&amp;").replace(goog.string.ltRe_,"&lt;").replace(goog.string.gtRe_,"&gt;").replace(goog.string.quotRe_,"&quot;").replace(goog.string.singleQuoteRe_,"&#39;");if(!goog.string.allRe_.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(goog.string.amperRe_,"&amp;"));-1!=a.indexOf("<")&&(a=a.replace(goog.string.ltRe_,"&lt;"));-1!=a.indexOf(">")&&(a=a.replace(goog.string.gtRe_,"&gt;"));-1!=a.indexOf('"')&&(a=a.replace(goog.string.quotRe_,
  "&quot;"));-1!=a.indexOf("'")&&(a=a.replace(goog.string.singleQuoteRe_,"&#39;"));return a};goog.string.amperRe_=/&/g;goog.string.ltRe_=/</g;goog.string.gtRe_=/>/g;goog.string.quotRe_=/"/g;goog.string.singleQuoteRe_=/'/g;goog.string.allRe_=/[&<>"']/;goog.string.unescapeEntities=function(a){return goog.string.contains(a,"&")?"document"in goog.global?goog.string.unescapeEntitiesUsingDom_(a):goog.string.unescapePureXmlEntities_(a):a};
  goog.string.unescapeEntitiesWithDocument=function(a,b){return goog.string.contains(a,"&")?goog.string.unescapeEntitiesUsingDom_(a,b):a};
  goog.string.unescapeEntitiesUsingDom_=function(a,b){var c={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"'},d;d=b?b.createElement("div"):document.createElement("div");return a.replace(goog.string.HTML_ENTITY_PATTERN_,function(a,b){var g=c[a];if(g)return g;if("#"==b.charAt(0)){var h=Number("0"+b.substr(1));isNaN(h)||(g=String.fromCharCode(h))}g||(d.innerHTML=a+" ",g=d.firstChild.nodeValue.slice(0,-1));return c[a]=g})};
  goog.string.unescapePureXmlEntities_=function(a){return a.replace(/&([^;]+);/g,function(a,c){switch(c){case "amp":return"&";case "lt":return"<";case "gt":return">";case "quot":return'"';default:if("#"==c.charAt(0)){var d=Number("0"+c.substr(1));if(!isNaN(d))return String.fromCharCode(d)}return a}})};goog.string.HTML_ENTITY_PATTERN_=/&([^;\s<&]+);?/g;goog.string.whitespaceEscape=function(a,b){return goog.string.newLineToBr(a.replace(/  /g," &#160;"),b)};
  goog.string.stripQuotes=function(a,b){for(var c=b.length,d=0;d<c;d++){var e=1==c?b:b.charAt(d);if(a.charAt(0)==e&&a.charAt(a.length-1)==e)return a.substring(1,a.length-1)}return a};goog.string.truncate=function(a,b,c){c&&(a=goog.string.unescapeEntities(a));a.length>b&&(a=a.substring(0,b-3)+"...");c&&(a=goog.string.htmlEscape(a));return a};
  goog.string.truncateMiddle=function(a,b,c,d){c&&(a=goog.string.unescapeEntities(a));if(d&&a.length>b){d>b&&(d=b);var e=a.length-d;a=a.substring(0,b-d)+"..."+a.substring(e)}else a.length>b&&(d=Math.floor(b/2),e=a.length-d,a=a.substring(0,d+b%2)+"..."+a.substring(e));c&&(a=goog.string.htmlEscape(a));return a};goog.string.specialEscapeChars_={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\"};goog.string.jsEscapeCache_={"'":"\\'"};
  goog.string.quote=function(a){a=String(a);if(a.quote)return a.quote();for(var b=['"'],c=0;c<a.length;c++){var d=a.charAt(c),e=d.charCodeAt(0);b[c+1]=goog.string.specialEscapeChars_[d]||(31<e&&127>e?d:goog.string.escapeChar(d))}b.push('"');return b.join("")};goog.string.escapeString=function(a){for(var b=[],c=0;c<a.length;c++)b[c]=goog.string.escapeChar(a.charAt(c));return b.join("")};
  goog.string.escapeChar=function(a){if(a in goog.string.jsEscapeCache_)return goog.string.jsEscapeCache_[a];if(a in goog.string.specialEscapeChars_)return goog.string.jsEscapeCache_[a]=goog.string.specialEscapeChars_[a];var b=a,c=a.charCodeAt(0);if(31<c&&127>c)b=a;else{if(256>c){if(b="\\x",16>c||256<c)b+="0"}else b="\\u",4096>c&&(b+="0");b+=c.toString(16).toUpperCase()}return goog.string.jsEscapeCache_[a]=b};goog.string.toMap=function(a){for(var b={},c=0;c<a.length;c++)b[a.charAt(c)]=!0;return b};
  goog.string.contains=function(a,b){return-1!=a.indexOf(b)};goog.string.countOf=function(a,b){return a&&b?a.split(b).length-1:0};goog.string.removeAt=function(a,b,c){var d=a;0<=b&&b<a.length&&0<c&&(d=a.substr(0,b)+a.substr(b+c,a.length-b-c));return d};goog.string.remove=function(a,b){var c=RegExp(goog.string.regExpEscape(b),"");return a.replace(c,"")};goog.string.removeAll=function(a,b){var c=RegExp(goog.string.regExpEscape(b),"g");return a.replace(c,"")};
  goog.string.regExpEscape=function(a){return String(a).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")};goog.string.repeat=function(a,b){return Array(b+1).join(a)};goog.string.padNumber=function(a,b,c){a=goog.isDef(c)?a.toFixed(c):String(a);c=a.indexOf(".");-1==c&&(c=a.length);return goog.string.repeat("0",Math.max(0,b-c))+a};goog.string.makeSafe=function(a){return null==a?"":String(a)};goog.string.buildString=function(a){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(a,b){for(var c=0,d=goog.string.trim(String(a)).split("."),e=goog.string.trim(String(b)).split("."),f=Math.max(d.length,e.length),g=0;0==c&&g<f;g++){var h=d[g]||"",k=e[g]||"",l=RegExp("(\\d*)(\\D*)","g"),m=RegExp("(\\d*)(\\D*)","g");do{var n=l.exec(h)||["","",""],p=m.exec(k)||["","",""];if(0==n[0].length&&0==p[0].length)break;var c=0==n[1].length?0:parseInt(n[1],10),q=0==p[1].length?0:parseInt(p[1],10),c=goog.string.compareElements_(c,q)||goog.string.compareElements_(0==
  n[2].length,0==p[2].length)||goog.string.compareElements_(n[2],p[2])}while(0==c)}return c};goog.string.compareElements_=function(a,b){return a<b?-1:a>b?1:0};goog.string.HASHCODE_MAX_=4294967296;goog.string.hashCode=function(a){for(var b=0,c=0;c<a.length;++c)b=31*b+a.charCodeAt(c),b%=goog.string.HASHCODE_MAX_;return b};goog.string.uniqueStringCounter_=2147483648*Math.random()|0;goog.string.createUniqueString=function(){return"goog_"+goog.string.uniqueStringCounter_++};
  goog.string.toNumber=function(a){var b=Number(a);return 0==b&&goog.string.isEmpty(a)?NaN:b};goog.string.isLowerCamelCase=function(a){return/^[a-z]+([A-Z][a-z]*)*$/.test(a)};goog.string.isUpperCamelCase=function(a){return/^([A-Z][a-z]*)+$/.test(a)};goog.string.toCamelCase=function(a){return String(a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()})};goog.string.toSelectorCase=function(a){return String(a).replace(/([A-Z])/g,"-$1").toLowerCase()};
  goog.string.toTitleCase=function(a,b){var c=goog.isString(b)?goog.string.regExpEscape(b):"\\s";return a.replace(RegExp("(^"+(c?"|["+c+"]+":"")+")([a-z])","g"),function(a,b,c){return b+c.toUpperCase()})};goog.string.parseInt=function(a){isFinite(a)&&(a=String(a));return goog.isString(a)?/^\s*-?0x/i.test(a)?parseInt(a,16):parseInt(a,10):NaN};goog.string.splitLimit=function(a,b,c){a=a.split(b);for(var d=[];0<c&&a.length;)d.push(a.shift()),c--;a.length&&d.push(a.join(b));return d};goog.userAgent={};goog.userAgent.ASSUME_IE=!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_GECKO||goog.userAgent.ASSUME_MOBILE_WEBKIT||goog.userAgent.ASSUME_WEBKIT||goog.userAgent.ASSUME_OPERA;
  goog.userAgent.getUserAgentString=function(){return goog.global.navigator?goog.global.navigator.userAgent:null};goog.userAgent.getNavigator=function(){return goog.global.navigator};
  goog.userAgent.init_=function(){goog.userAgent.detectedOpera_=!1;goog.userAgent.detectedIe_=!1;goog.userAgent.detectedWebkit_=!1;goog.userAgent.detectedMobile_=!1;goog.userAgent.detectedGecko_=!1;var a;if(!goog.userAgent.BROWSER_KNOWN_&&(a=goog.userAgent.getUserAgentString())){var b=goog.userAgent.getNavigator();goog.userAgent.detectedOpera_=goog.string.startsWith(a,"Opera");goog.userAgent.detectedIe_=!goog.userAgent.detectedOpera_&&(goog.string.contains(a,"MSIE")||goog.string.contains(a,"Trident"));
  goog.userAgent.detectedWebkit_=!goog.userAgent.detectedOpera_&&goog.string.contains(a,"WebKit");goog.userAgent.detectedMobile_=goog.userAgent.detectedWebkit_&&goog.string.contains(a,"Mobile");goog.userAgent.detectedGecko_=!goog.userAgent.detectedOpera_&&!goog.userAgent.detectedWebkit_&&!goog.userAgent.detectedIe_&&"Gecko"==b.product}};goog.userAgent.BROWSER_KNOWN_||goog.userAgent.init_();goog.userAgent.OPERA=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_OPERA:goog.userAgent.detectedOpera_;
  goog.userAgent.IE=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_IE:goog.userAgent.detectedIe_;goog.userAgent.GECKO=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_GECKO:goog.userAgent.detectedGecko_;goog.userAgent.WEBKIT=goog.userAgent.BROWSER_KNOWN_?goog.userAgent.ASSUME_WEBKIT||goog.userAgent.ASSUME_MOBILE_WEBKIT:goog.userAgent.detectedWebkit_;goog.userAgent.MOBILE=goog.userAgent.ASSUME_MOBILE_WEBKIT||goog.userAgent.detectedMobile_;goog.userAgent.SAFARI=goog.userAgent.WEBKIT;
  goog.userAgent.determinePlatform_=function(){var a=goog.userAgent.getNavigator();return a&&a.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.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.initPlatform_=function(){goog.userAgent.detectedMac_=goog.string.contains(goog.userAgent.PLATFORM,"Mac");goog.userAgent.detectedWindows_=goog.string.contains(goog.userAgent.PLATFORM,"Win");goog.userAgent.detectedLinux_=goog.string.contains(goog.userAgent.PLATFORM,"Linux");goog.userAgent.detectedX11_=!!goog.userAgent.getNavigator()&&goog.string.contains(goog.userAgent.getNavigator().appVersion||"","X11");var a=goog.userAgent.getUserAgentString();goog.userAgent.detectedAndroid_=!!a&&
  goog.string.contains(a,"Android");goog.userAgent.detectedIPhone_=!!a&&goog.string.contains(a,"iPhone");goog.userAgent.detectedIPad_=!!a&&goog.string.contains(a,"iPad")};goog.userAgent.PLATFORM_KNOWN_||goog.userAgent.initPlatform_();goog.userAgent.MAC=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_MAC:goog.userAgent.detectedMac_;goog.userAgent.WINDOWS=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_WINDOWS:goog.userAgent.detectedWindows_;
  goog.userAgent.LINUX=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_LINUX:goog.userAgent.detectedLinux_;goog.userAgent.X11=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_X11:goog.userAgent.detectedX11_;goog.userAgent.ANDROID=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_ANDROID:goog.userAgent.detectedAndroid_;goog.userAgent.IPHONE=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPHONE:goog.userAgent.detectedIPhone_;
  goog.userAgent.IPAD=goog.userAgent.PLATFORM_KNOWN_?goog.userAgent.ASSUME_IPAD:goog.userAgent.detectedIPad_;
  goog.userAgent.determineVersion_=function(){var a="",b;goog.userAgent.OPERA&&goog.global.opera?(a=goog.global.opera.version,a="function"==typeof a?a():a):(goog.userAgent.GECKO?b=/rv\:([^\);]+)(\)|;)/:goog.userAgent.IE?b=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:goog.userAgent.WEBKIT&&(b=/WebKit\/(\S+)/),b&&(a=(a=b.exec(goog.userAgent.getUserAgentString()))?a[1]:""));return goog.userAgent.IE&&(b=goog.userAgent.getDocumentMode_(),b>parseFloat(a))?String(b):a};
  goog.userAgent.getDocumentMode_=function(){var a=goog.global.document;return a?a.documentMode:void 0};goog.userAgent.VERSION=goog.userAgent.determineVersion_();goog.userAgent.compare=function(a,b){return goog.string.compareVersions(a,b)};goog.userAgent.isVersionOrHigherCache_={};
  goog.userAgent.isVersionOrHigher=function(a){return goog.userAgent.ASSUME_ANY_VERSION||goog.userAgent.isVersionOrHigherCache_[a]||(goog.userAgent.isVersionOrHigherCache_[a]=0<=goog.string.compareVersions(goog.userAgent.VERSION,a))};goog.userAgent.isVersion=goog.userAgent.isVersionOrHigher;goog.userAgent.isDocumentModeOrHigher=function(a){return goog.userAgent.IE&&goog.userAgent.DOCUMENT_MODE>=a};goog.userAgent.isDocumentMode=goog.userAgent.isDocumentModeOrHigher;
  goog.userAgent.DOCUMENT_MODE=function(){var a=goog.global.document;return a&&goog.userAgent.IE?goog.userAgent.getDocumentMode_()||("CSS1Compat"==a.compatMode?parseInt(goog.userAgent.VERSION,10):5):void 0}();var INLINE_ROW=-1;Blockly.BlockSvg=function(a){this.block_=a;var b={"block-id":a.id};a.htmlId&&(b.id=a.htmlId);this.svgGroup_=Blockly.createSvgElement("g",b,null);this.initChildren();this.forcedInputWidths={}};
  Blockly.BlockSvg.prototype.initChildren=function(){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_;Blockly.Tooltip.bindMouseEvents(this.svgPath_);this.updateMovable()};Blockly.BlockSvg.DISABLED_COLOUR="#808080";Blockly.BlockSvg.prototype.init=function(){var a=this.block_;this.updateColour();for(var b=0,c;c=a.inputList[b];b++)c.init();a.mutator&&a.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(a){a?(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;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_RTL="v 6.5 m -"+0.98*BS.TAB_WIDTH+",2.5 q -"+0.05*BS.TAB_WIDTH+",10 "+0.27*BS.TAB_WIDTH+",10 m "+0.71*BS.TAB_WIDTH+",-2.5 v 1.5";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{top:0,right:0,bottom:0,left:0}};
  function brokenControlPointWorkaround(){return Blockly.BROKEN_CONTROL_POINTS?"c 0,5 0,-5 0,0":""}function oppositeIfRTL(a){return Blockly.RTL?-a:a}Blockly.BlockSvg.prototype.dispose=function(){goog.dom.removeNode(this.svgGroup_);this.block_=this.svgPathDark_=this.svgPathLight_=this.svgPath_=this.svgGroup_=null};
  Blockly.BlockSvg.prototype.disposeUiEffect=function(){Blockly.playAudio("delete");var a=this.block_.blockSpace.blockSpaceEditor.svg_,b=Blockly.getSvgXY_(this.svgGroup_,a),c=this.svgGroup_.cloneNode(!0);c.translateX_=b.x;c.translateY_=b.y;c.setAttribute("transform","translate("+c.translateX_+","+c.translateY_+")");a.appendChild(c);0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")?(c.style.display="inline",c.bBox_={x:c.getBBox().x,y:c.getBBox().y,width:c.scrollWidth,
  height:c.scrollHeight}):c.bBox_=c.getBBox();c.startDate_=new Date;Blockly.BlockSvg.disposeUiStep_(c)};Blockly.BlockSvg.disposeUiStep_=function(a){var b=(new Date-a.startDate_)/150;if(1<b)goog.dom.removeNode(a);else{var c=a.translateX_+oppositeIfRTL(a.bBox_.width/2*b);a.setAttribute("transform","translate("+(c+", "+(a.translateY_+a.bBox_.height*b))+") scale("+(1-b)+")");window.setTimeout(function(){Blockly.BlockSvg.disposeUiStep_(a)},10)}};
  Blockly.BlockSvg.prototype.connectionUiEffect=function(){Blockly.playAudio("click");var a=Blockly.getSvgXY_(this.svgGroup_,this.block_.blockSpace.blockSpaceEditor.svg_);this.block_.outputConnection?(a.x+=oppositeIfRTL(-3),a.y+=13):this.block_.previousConnection&&(a.x+=oppositeIfRTL(23),a.y+=3);a=Blockly.createSvgElement("circle",{cx:a.x,cy:a.y,r:0,fill:"none",stroke:"#888","stroke-width":10},this.block_.blockSpace.blockSpaceEditor.svg_);a.startDate_=new Date;Blockly.BlockSvg.connectionUiStep_(a)};
  Blockly.BlockSvg.connectionUiStep_=function(a){var b=(new Date-a.startDate_)/150;1<b?goog.dom.removeNode(a):(a.setAttribute("r",25*b),a.style.opacity=1-b,window.setTimeout(function(){Blockly.BlockSvg.connectionUiStep_(a)},10))};Blockly.BlockSvg.prototype.updateColour=function(){if(!this.block_.disabled){var a;a=this.block_.shouldBeGrayedOut()?BS.DISABLED_COLOUR:this.block_.getHexColour();this.updateToColour_(a)}};
  Blockly.BlockSvg.prototype.updateToColour_=function(a){var b=goog.color.hexToRgb(a),c=goog.color.lighten(b,0.3),b=goog.color.darken(b,0.4);this.svgPathLight_.setAttribute("stroke",goog.color.rgbArrayToHex(c));this.svgPathDark_.setAttribute("fill",goog.color.rgbArrayToHex(b));this.svgPath_.setAttribute("fill",a);(a=this.block_.getFillPattern())&&this.svgPathFill_.setAttribute("fill","url(#"+a+")")};
  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 a=this.block_.getChildren(),b=0,c;c=a[b];b++)c.svg_.updateDisabled()};Blockly.BlockSvg.prototype.addSelect=function(){Blockly.addClass_(this.svgGroup_,"blocklySelected");this.svgGroup_.parentNode.appendChild(this.svgGroup_)};
  Blockly.BlockSvg.prototype.addSelectNoMove=function(){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(a){this.block_.rendered=!0;for(var b=oppositeIfRTL(BS.SEP_SPACE_X),c=this.block_.getIcons(),d=0;d<c.length;d++)b=c[d].renderIcon(b);b-=oppositeIfRTL(BS.SEP_SPACE_X);c=this.renderCompute_(b);this.renderDraw_(b,c);a||((a=this.block_.getParent())?a.render():Blockly.fireUiEvent(window,"resize"))};
  Blockly.BlockSvg.prototype.renderTitles_=function(a,b,c){for(var d=b,e=0,f;f=a[e];e++){var g=f.getSize(),h=b;Blockly.RTL&&(h=-(b+g.width));f.getRootElement().setAttribute("transform","translate("+h+", "+(c+f.getBufferY())+")");g.width&&(b+=g.width+BS.SEP_SPACE_X)}return b-d};
  Blockly.BlockSvg.prototype.renderCompute_=function(a){var b=this.block_.inputList,c=[];c.rightEdge=a+2*BS.SEP_SPACE_X;if(this.block_.previousConnection||this.block_.nextConnection)c.rightEdge=Math.max(c.rightEdge,BS.NOTCH_WIDTH+BS.SEP_SPACE_X);for(var d=0,e=0,f=!1,g=!1,h=!1,k,l=0,m;m=b[l];l++)if(m.isVisible()){0!==l&&m.isInline()||(k=[],k.type=m.type,k.height=0,c.push(k));if(0<k.length||m.isInline())k.type=INLINE_ROW;0===k.length&&m.type===Blockly.FUNCTIONAL_INPUT&&(k.type=INLINE_ROW);k.push(m);var n=
  inputRenderSize(m);m.renderHeight=n.height;m.renderWidth=n.width;k.height=Math.max(k.height,m.renderHeight);n=inputTitleRenderSize(m,0===l?a:0);m.titleWidth=n.width;k.height=Math.max(k.height,n.height);k.type!=INLINE_ROW&&(k.type==Blockly.NEXT_STATEMENT?(g=!0,e=Math.max(e,m.titleWidth)):(k.type===Blockly.INPUT_VALUE||k.type===Blockly.FUNCTIONAL_INPUT?f=!0:k.type===Blockly.DUMMY_INPUT&&(h=!0),d=Math.max(d,m.titleWidth)))}thickenInlineRows(c);c.statementEdge=2*BS.SEP_SPACE_X+e;g&&(c.rightEdge=Math.max(c.rightEdge,
  c.statementEdge+BS.NOTCH_WIDTH));f?c.rightEdge=Math.max(c.rightEdge,d+2*BS.SEP_SPACE_X+BS.TAB_WIDTH):h&&(c.rightEdge=Math.max(c.rightEdge,d+2*BS.SEP_SPACE_X));c.hasValue=f;c.hasStatement=g;c.hasDummy=h;c.rightEdgeWithoutInline=c.rightEdge;for(l=0;k=c[l];l++)k.type===INLINE_ROW&&(c.rightEdge=Math.max(c.rightEdge,this.widthInlineRow(k)));return c};
  function thickenInlineRows(a){for(var b,c=0;b=a[c];c++)if(b.thicker=!1,b.type===INLINE_ROW)for(var d=0,e;e=b[d];d++)if(e.type===Blockly.INPUT_VALUE||e.type===Blockly.FUNCTIONAL_INPUT){b.height+=2*BS.INLINE_PADDING_Y;b.thicker=!0;break}}
  function inputRenderSize(a){var b=BS.MIN_BLOCK_Y,c=BS.TAB_WIDTH+BS.SEP_SPACE_X;a.type===Blockly.FUNCTIONAL_INPUT&&(c=BS.NOTCH_WIDTH+BS.SEP_SPACE_X);a.connection&&a.connection.targetConnection&&(a=a.connection.targetBlock().getHeightWidth(),b=Math.max(b,a.height),c=Math.max(c,a.width));return{width:c,height:b}}
  function inputTitleRenderSize(a,b){for(var c=oppositeIfRTL(b),d=0,e,f=0;e=a.titleRow[f];f++)e=e.getSize(),e.width&&(c+=e.width+(0<f?BS.SEP_SPACE_X:0)),d=Math.max(d,e.height);return{width:c,height:d}}Blockly.BlockSvg.prototype.widthInlineRow=function(a){for(var b=BS.SEP_SPACE_X,c=0,d;d=a[c];c++)b+=BS.SEP_SPACE_X+this.inputWidthToOccupy_(d);return b};
  Blockly.BlockSvg.prototype.renderDraw_=function(a,b){if(this.block_.outputConnection)this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0;else{this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!1;if(this.block_.previousConnection){var c=this.block_.previousConnection.targetBlock();c&&c.nextConnection&&c.nextConnection.targetConnection==this.block_.previousConnection&&(this.squareTopLeftCorner_=!0)}this.block_.nextConnection&&(c=this.block_.nextConnection.targetBlock())&&c.previousConnection&&
  c.previousConnection.targetConnection==this.block_.nextConnection&&(this.squareBottomLeftCorner_=!0)}this.block_.previousConnection&&this.block_.previousConnection.type===Blockly.FUNCTIONAL_OUTPUT&&(this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0);for(c=0;c<this.block_.inputList.length;c++)this.block_.inputList[c].type===Blockly.FUNCTIONAL_INPUT&&(this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0);var d=this.block_.getRelativeToSurfaceXY(),c={core:[],inline:[],highlight:[],highlightInline:[],
  curX:a,curY:0};this.renderDrawTop_(c,b.rightEdge,d);this.renderDrawRight_(c,d,b,a);this.renderDrawBottom_(c,d);this.renderDrawLeft_(c);d=c.core.join(" ")+"\n"+c.inline.join(" ");this.svgPath_.setAttribute("d",d);this.svgPathFill_&&this.svgPathFill_.setAttribute("d",d);this.svgPathDark_.setAttribute("d",d);d=c.highlight.join(" ")+"\n"+c.highlightInline.join(" ");this.svgPathLight_.setAttribute("d",d);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(a,b,c){this.squareTopLeftCorner_?(a.core.push("m 0,0"),a.highlight.push("m 1,1")):(a.core.push(BS.TOP_LEFT_CORNER_START),a.highlight.push(Blockly.RTL?BS.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL:BS.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR),a.core.push(BS.TOP_LEFT_CORNER),a.highlight.push(BS.TOP_LEFT_CORNER_HIGHLIGHT));a.core.push(brokenControlPointWorkaround());if(this.block_.previousConnection){var d=this.block_.previousConnection.getNotchPaths();a.core.push("H",
  BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH);a.highlight.push("H",BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH);a.core.push(d.left);a.highlight.push(d.leftHighlight);d=c.x+oppositeIfRTL(BS.NOTCH_WIDTH);this.block_.previousConnection.moveTo(d,c.y)}a.core.push("H",b);a.highlight.push("H",b+(Blockly.RTL?-1:0));a.curX=b};
  Blockly.BlockSvg.prototype.renderDrawRight_=function(a,b,c,d){for(var e=0,f;f=c[e];e++)a.curX=BS.SEP_SPACE_X,0===e&&(a.curX+=oppositeIfRTL(d)),a.highlight.push("M",c.rightEdge-1+","+(a.curY+1)),this.block_.isCollapsed()?this.renderDrawRightCollapsed_(a,f):f.type===INLINE_ROW?this.renderDrawRightInline_(a,c,e,b):f.type===Blockly.INPUT_VALUE?this.renderDrawRightInputValue_(a,c,e,b):f.type===Blockly.DUMMY_INPUT?this.renderDrawRightDummyInput_(a,c,e):f.type===Blockly.NEXT_STATEMENT&&this.renderDrawRightNextStatement_(a,
  c,e,b),a.curY+=f.height;c.length||(a.curY=BS.MIN_BLOCK_Y,a.core.push("V",a.curY),Blockly.RTL&&a.highlight.push("V",a.curY-1))};Blockly.BlockSvg.prototype.renderDrawRightCollapsed_=function(a,b){a.curX+=this.renderTitles_(b[0].titleRow,a.curX,a.curY+BS.TITLE_HEIGHT);a.core.push(BS.JAGGED_TEETH);Blockly.RTL?a.highlight.push("l 8,0 0,3.8 7,3.2 m -14.5,9 l 8,4"):a.highlight.push("h 8");var c=b.height-BS.JAGGED_TEETH_HEIGHT;a.core.push("v",c);Blockly.RTL&&a.highlight.push("v",c-2)};
  Blockly.BlockSvg.prototype.renderDrawRightInputValue_=function(a,b,c,d){var e=b[c];c=e[0];var f=a.curX,g=a.curY+BS.TITLE_HEIGHT;if(c.align!=Blockly.ALIGN_LEFT){var h=b.rightEdge-c.titleWidth-BS.TAB_WIDTH-2*BS.SEP_SPACE_X;c.align===Blockly.ALIGN_RIGHT?f+=h:c.align===Blockly.ALIGN_CENTRE&&(f+=(h+f)/2)}a.curX+=this.renderTitles_(c.titleRow,f,g);a.core.push(BS.TAB_PATH_DOWN);a.core.push("v",e.height-BS.TAB_HEIGHT);Blockly.RTL?(a.highlight.push(BS.TAB_PATH_DOWN_HIGHLIGHT_RTL),a.highlight.push("v",e.height-
  BS.TAB_HEIGHT)):(a.highlight.push("M",b.rightEdge-4.2+","+(a.curY+BS.TAB_HEIGHT-0.4)),a.highlight.push("l",0.42*BS.TAB_WIDTH+",-1.8"));b=d.x+oppositeIfRTL(b.rightEdge+1);c.connection.moveTo(b,d.y+a.curY);c.connection.targetConnection&&c.connection.tighten_()};
  Blockly.BlockSvg.prototype.renderDrawRightDummyInput_=function(a,b,c){c=b[c];var d=c[0],e=a.curX,f=a.curY+BS.TITLE_HEIGHT;if(d.align===Blockly.ALIGN_RIGHT){var g=b.rightEdge-d.titleWidth-2*BS.SEP_SPACE_X;b.hasValue&&(g-=BS.TAB_WIDTH);e+=g}d.align===Blockly.ALIGN_CENTRE&&(e=(b.rightEdge-d.titleWidth)/2);this.renderTitles_(d.titleRow,e,f);a.core.push("v",c.height);Blockly.RTL&&a.highlight.push("v",c.height-2)};
  Blockly.BlockSvg.prototype.renderDrawRightNextStatement_=function(a,b,c,d){var e;e=b[c];var f=e[0];0===c&&(a.core.push("v",BS.SEP_SPACE_Y),Blockly.RTL&&a.highlight.push("v",BS.SEP_SPACE_Y-1),a.curY+=BS.SEP_SPACE_Y);var g=a.curX,h=a.curY+BS.TITLE_HEIGHT;if(f.align!=Blockly.ALIGN_LEFT){var k=b.statementEdge-f.titleWidth-2*BS.SEP_SPACE_X;f.align==Blockly.ALIGN_RIGHT?g+=k:f.align==Blockly.ALIGN_CENTRE&&(g+=(k+g)/2)}k=f.connection.getNotchPaths();this.renderTitles_(f.titleRow,g,h);a.curX=b.statementEdge+
  BS.NOTCH_WIDTH;a.core.push("H",a.curX);a.core.push(this.innerTopLeftCorner(k.right));a.core.push("v",e.height-2*BS.CORNER_RADIUS);a.core.push(BS.INNER_BOTTOM_LEFT_CORNER);a.core.push("H",b.rightEdgeWithoutInline);Blockly.RTL?(a.highlight.push("M",a.curX-BS.NOTCH_WIDTH+BS.DISTANCE_45_OUTSIDE+","+(a.curY+BS.DISTANCE_45_OUTSIDE)),a.highlight.push(BS.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),a.highlight.push("v",e.height-2*BS.CORNER_RADIUS),a.highlight.push(BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL),a.highlight.push("H",
  b.rightEdgeWithoutInline-1)):(a.highlight.push("M",a.curX-BS.NOTCH_WIDTH+BS.DISTANCE_45_OUTSIDE+","+(a.curY+e.height-BS.DISTANCE_45_OUTSIDE)),a.highlight.push(BS.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR),a.highlight.push("H",b.rightEdgeWithoutInline));e=d.x+oppositeIfRTL(a.curX);f.connection.moveTo(e,d.y+a.curY+1);f.connection.targetConnection&&f.connection.tighten_();if(c===b.length-1||b[c+1].type===Blockly.NEXT_STATEMENT)a.core.push("v",BS.SEP_SPACE_Y),Blockly.RTL&&a.highlight.push("v",BS.SEP_SPACE_Y-
  1),a.curY+=BS.SEP_SPACE_Y};
  Blockly.BlockSvg.prototype.renderDrawRightInline_=function(a,b,c,d){var e,f;c=b[c];var g=!1,h=c[0].align;if(c[0].type===Blockly.FUNCTIONAL_INPUT){var k=BS.SEP_SPACE_X*(c.length-1);c.forEach(function(a){k+=this.inputWidthToOccupy_(a)},this);b.rightEdge>k&&h===Blockly.ALIGN_CENTRE&&(a.curX=(b.rightEdge-k)/2)}for(var h=0,l;l=c[h];h++)e=a.curX,f=a.curY+BS.TITLE_HEIGHT,c.thicker&&(f+=BS.INLINE_PADDING_Y),a.curX+=this.renderTitles_(l.titleRow,e,f),l.type===Blockly.INPUT_VALUE?(a.curX+=l.renderWidth+BS.SEP_SPACE_X,
  a.inline.push("M",a.curX-BS.SEP_SPACE_X+","+(a.curY+BS.INLINE_PADDING_Y)),a.inline.push("h",BS.TAB_WIDTH-l.renderWidth),a.inline.push(BS.TAB_PATH_DOWN),a.inline.push("v",l.renderHeight-BS.TAB_HEIGHT),a.inline.push("h",l.renderWidth-BS.TAB_WIDTH),a.inline.push("z"),Blockly.RTL?(a.highlightInline.push("M",a.curX-BS.SEP_SPACE_X+BS.TAB_WIDTH-l.renderWidth-1+","+(a.curY+BS.INLINE_PADDING_Y+1)),a.highlightInline.push(BS.TAB_PATH_DOWN_HIGHLIGHT_RTL),a.highlightInline.push("v",l.renderHeight-BS.TAB_HEIGHT+
  2),a.highlightInline.push("h",l.renderWidth-BS.TAB_WIDTH)):(a.highlightInline.push("M",a.curX-BS.SEP_SPACE_X+1+","+(a.curY+BS.INLINE_PADDING_Y+1)),a.highlightInline.push("v",l.renderHeight),a.highlightInline.push("h",BS.TAB_WIDTH-l.renderWidth),a.highlightInline.push("M",a.curX-l.renderWidth-BS.SEP_SPACE_X+3.8+","+(a.curY+BS.INLINE_PADDING_Y+BS.TAB_HEIGHT-0.4)),a.highlightInline.push("l",0.42*BS.TAB_WIDTH+",-1.8")),e=d.x+oppositeIfRTL(a.curX+BS.TAB_WIDTH-BS.SEP_SPACE_X-l.renderWidth+1),f=d.y+a.curY+
  BS.INLINE_PADDING_Y,l.connection.moveTo(e,f),l.connection.targetConnection&&l.connection.tighten_()):l.type===Blockly.FUNCTIONAL_INPUT?(g=!0,this.renderDrawRightInlineFunctional_(a,l,d)):l.type!=Blockly.DUMMY_INPUT&&(a.curX+=l.renderWidth+BS.SEP_SPACE_X);a.curX=Math.max(a.curX,b.rightEdge);a.core.push("H",a.curX);g||a.highlight.push("H",a.curX+(Blockly.RTL?-1:0));a.core.push("v",c.height);Blockly.RTL&&a.highlight.push("v",c.height-2)};
  Blockly.BlockSvg.prototype.inputWidthToOccupy_=function(a){return a.renderWidth+(a.extraSpace||0)};Blockly.BlockSvg.prototype.renderDrawRightInlineFunctional_=function(a,b,c){throw"Only supported for functional blocks";};
  Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b){a.core.push(brokenControlPointWorkaround());if(this.block_.nextConnection){var c=this.block_.nextConnection.getNotchPaths();a.core.push("H",BS.NOTCH_WIDTH+" "+c.right);c=b.x+oppositeIfRTL(BS.NOTCH_WIDTH);this.block_.nextConnection.moveTo(c,b.y+a.curY+1);this.block_.nextConnection.targetConnection&&this.block_.nextConnection.tighten_()}this.squareBottomLeftCorner_?(a.core.push("H 0"),Blockly.RTL||a.highlight.push("M","1,"+a.curY)):(a.core.push("H",
  BS.CORNER_RADIUS),a.core.push("a",BS.CORNER_RADIUS+","+BS.CORNER_RADIUS+" 0 0,1 -"+BS.CORNER_RADIUS+",-"+BS.CORNER_RADIUS),Blockly.RTL||(a.highlight.push("M",BS.DISTANCE_45_INSIDE+","+(a.curY-BS.DISTANCE_45_INSIDE)),a.highlight.push("A",BS.CORNER_RADIUS-1+","+(BS.CORNER_RADIUS-1)+" 0 0,1 1,"+(a.curY-BS.CORNER_RADIUS))))};
  Blockly.BlockSvg.prototype.renderDrawLeft_=function(a){this.block_.outputConnection?(a.core.push("V",BS.TAB_HEIGHT),a.core.push("c 0,-10 -"+BS.TAB_WIDTH+",8 -"+BS.TAB_WIDTH+",-7.5 s "+BS.TAB_WIDTH+",2.5 "+BS.TAB_WIDTH+",-7.5"),Blockly.RTL?(a.highlight.push("M",-0.3*BS.TAB_WIDTH+",8.9"),a.highlight.push("l",-0.45*BS.TAB_WIDTH+",-2.1")):(a.highlight.push("V",BS.TAB_HEIGHT-1),a.highlight.push("m",-0.92*BS.TAB_WIDTH+",-1 q "+-0.19*BS.TAB_WIDTH+",-5.5 0,-11"),a.highlight.push("m",0.92*BS.TAB_WIDTH+",1 V 1 H 2"))):
  Blockly.RTL||a.highlight.push("V",this.squareTopLeftCorner_?1:BS.CORNER_RADIUS);a.core.push("z")};Blockly.BlockSvg.prototype.setVisible=function(a){this.svgGroup_.style.display=a?"":"none"};Blockly.BlockSvg.prototype.innerTopLeftCorner=function(a){return a+" 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.Field=function(a){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(a);this.visible_=!0};Blockly.Field.prototype.getParentEditor_=function(){return this.sourceBlock_.blockSpace.blockSpaceEditor};
  Blockly.Field.prototype.getRootSVGElement_=function(){return this.getParentEditor_().svg_};Blockly.Field.NBSP="\u00a0";Blockly.Field.prototype.EDITABLE=!0;
  Blockly.Field.prototype.init=function(a){if(this.sourceBlock_)throw"Field has already been initialized once.";this.sourceBlock_=a;this.updateEditable();a.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(a){this.visible_=a;this.getRootElement().style.display=a?"block":"none"};Blockly.Field.prototype.getRootElement=function(){return this.fieldGroup_};Blockly.Field.prototype.updateWidth_=function(){var a;a=this.textElement_.getComputedTextLength?this.textElement_.getComputedTextLength():1;this.borderRect_&&this.borderRect_.setAttribute("width",a+Blockly.BlockSvg.SEP_SPACE_X);this.size_.width=a};
  Blockly.Field.prototype.getSize=function(){this.size_.width||this.updateWidth_();return this.size_};Blockly.Field.prototype.getBufferY=function(){return 0};Blockly.Field.prototype.getText=function(){return this.text_};Blockly.Field.prototype.setText=function(a){null!==a&&a!==this.text_&&(this.text_=a,goog.dom.removeChildren(this.textElement_),a=a.replace(/\s/g,Blockly.Field.NBSP),a||(a=Blockly.Field.NBSP),a=document.createTextNode(a),this.textElement_.appendChild(a),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(a){this.setText(a)};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(a){this.showEditorOnClick_()&&a.stopPropagation()};Blockly.Field.prototype.onMouseUp_=function(a){this.showEditorOnClick_()||Blockly.isRightButton(a)||Blockly.Block.isFreelyDragging()||this.sourceBlock_.isEditable()&&this.showEditor_()};
  Blockly.Field.prototype.onClick_=function(a){this.showEditorOnClick_()&&(Blockly.isRightButton(a)||this.sourceBlock_.isEditable()&&this.showEditor_())};Blockly.Field.prototype.setTooltip=function(a){};Blockly.FieldImage=function(a,b,c){if(!b&&!c){var d=this;c=Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate(a,function(a,b){d.isDestroyed_()||d.updateDimensions_(a,b)});b=c.width;c=c.height}this.initializeWithImage_(a,b,c)};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(a,b,c){this.sourceBlock_=null;c=Number(c);b=Number(b);this.size_={height:c+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:b};this.fieldGroup_=Blockly.createSvgElement("g",{},null);this.imageElement_=Blockly.createSvgElement("image",{height:c+"px",width:b+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y},this.fieldGroup_);this.setText(a);goog.userAgent.GECKO&&(this.clickRectElement_=Blockly.createSvgElement("rect",{height:c+"px",width:b+"px",y:Blockly.FieldImage.IMAGE_OFFSET_Y,
  "fill-opacity":0},this.fieldGroup_))};Blockly.FieldImage.prototype.updateDimensions_=function(a,b){this.size_={height:b+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:a};this.imageElement_.setAttribute("width",a+"px");this.imageElement_.setAttribute("height",b+"px");this.clickRectElement_&&(this.clickRectElement_.setAttribute("width",a+"px"),this.clickRectElement_.setAttribute("height",b+"px"));this.refreshRender()};Blockly.FieldImage.prototype.clickRectElement_=null;
  Blockly.FieldImage.prototype.EDITABLE=!1;Blockly.FieldImage.prototype.init=function(a){if(this.sourceBlock_)throw"Image has already been initialized once.";this.sourceBlock_=a;a.getSvgRoot().appendChild(this.fieldGroup_);a=this.getClickTarget();a.tooltip=this.sourceBlock_;Blockly.Tooltip&&Blockly.Tooltip.bindMouseEvents(a)};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(a){this.getClickTarget().tooltip=a};Blockly.FieldImage.prototype.getText=function(){return this.src_};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.src_=a,this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(a)?a:""))};Blockly.FieldRectangularDropdown=function(a){this.choices_=a;a=this.choices_[0];this.value_=a[Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX];a=a[Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX];this.size_={width:Blockly.FieldImage.IMAGE_LOADING_WIDTH,height:Blockly.FieldImage.IMAGE_LOADING_HEIGHT};this.buildDOMElements_();this.updatePreviewData_(a)};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="\u25bc";Blockly.FieldRectangularDropdown.UP_ARROW_CHARACTER="\u25b2";Blockly.FieldRectangularDropdown.prototype.CURSOR="default";Blockly.FieldRectangularDropdown.prototype.EDITABLE=!0;Blockly.FieldRectangularDropdown.prototype.getOptions=function(){return this.choices_};
  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(a){throw Error("FieldRectangularDropdown.prototype.updatePreviewData_ not implemented");};
  Blockly.FieldRectangularDropdown.prototype.updateDimensions_=function(a,b){this.previewSize_={width:a,height:b};var c=b+2*Blockly.FieldRectangularDropdown.BORDER_MARGIN,d=a+2*Blockly.FieldRectangularDropdown.BORDER_MARGIN+Blockly.FieldRectangularDropdown.BORDER_EXTRA_ARROW_WIDTH;this.updatePreviewDimensions_(a,b);this.clickRectElement_.setAttribute("width",d+"px");this.clickRectElement_.setAttribute("height",c+"px");this.dropdownBorderRectElement_.setAttribute("width",d+"px");this.dropdownBorderRectElement_.setAttribute("height",
  c+"px");var e=b/2-Blockly.FieldImage.IMAGE_OFFSET_Y;this.dropdownArrowText_.setAttribute("x",a+Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_X_OFFSET_FROM_PREVIEW_RIGHT);this.dropdownArrowText_.setAttribute("y",e+Blockly.FieldRectangularDropdown.DROPDOWN_ARROW_Y_OFFSET_FROM_PREVIEW_MIDDLE);this.size_={height:c+Blockly.FieldImage.BELOW_IMAGE_PADDING,width:d};this.refreshRender()};
  Blockly.FieldRectangularDropdown.prototype.updatePreviewDimensions_=function(a,b){throw Error("FieldRectangularDropdown.prototype.updatePreviewDimensions_ not implemented");};Blockly.FieldRectangularDropdown.prototype.createDropdownPreviewElement_=function(a){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(a){this.arrowCharacter_.firstChild.nodeValue=a?Blockly.FieldRectangularDropdown.UP_ARROW_CHARACTER:Blockly.FieldRectangularDropdown.DOWN_ARROW_CHARACTER};
  Blockly.FieldRectangularDropdown.prototype.showMenu_=function(){Blockly.WidgetDiv.show(this,this.generateMenuClosedHandler_());this.menu_=this.createMenuWithChoices_(this.choices_);goog.events.listen(this.menu_,goog.ui.Component.EventType.ACTION,this.generateMenuItemSelectedHandler_());this.addPositionAndShowMenu(this.menu_);this.pointArrowUp_()};Blockly.FieldRectangularDropdown.prototype.menuAlreadyShowing_=function(){return this.menu_&&Blockly.WidgetDiv.isOwner(this)&&Blockly.WidgetDiv.isVisible()};
  Blockly.FieldRectangularDropdown.prototype.createMenuWithChoices_=function(a){for(var b=new goog.ui.Menu,c=0;c<a.length;c++){var d=a[c][Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX],e=d===this.value_,f=this.createDropdownPreviewElement_(a[c][Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX]),f=new goog.ui.MenuItem(f);f.setValue(d);d=1===chooseNumberOfColumns(a.length);e&&d?b.addItemAt(f,0):b.addItem(f)}return b};
  function chooseNumberOfColumns(a){return 7>=a?1:Math.floor(Math.sqrt(a))}Blockly.FieldRectangularDropdown.prototype.generateMenuItemSelectedHandler_=function(){var a=this;return function(b){if(b=b.target)b=b.getValue(),null!==b&&a.setValue(b);Blockly.WidgetDiv.hideIfOwner(a)}};Blockly.FieldRectangularDropdown.prototype.generateMenuClosedHandler_=function(){var a=this;return function(){a.pointArrowDown_()}};
  Blockly.FieldRectangularDropdown.prototype.addPositionAndShowMenu=function(a){var b=goog.dom.getViewportSize(),c=goog.style.getViewportPageOffset(document),d=Blockly.WidgetDiv.DIV;d.style.visibility="hidden";a.render(d);a.setAllowAutoFocus(!0);var e=a.getElement();Blockly.addClass_(e,"blocklyDropdownMenu");Blockly.addClass_(e,Blockly.FieldRectangularDropdown.MENU_CSS_CLASS);Blockly.addClass_(e,"goog-menu-noaccel");var f=this.calculateBackdropColourWithoutAlpha_();e.style.borderColor=f;e.style.background=
  f;a=chooseNumberOfColumns(a.getChildCount());if(f=1<a)e.style.width=(this.previewSize_.width+4)*a+4+"px",Blockly.addClass_(e,"blocklyGridDropdownMenu");e=this.calculateMenuPosition_(this.previewElement_,f);Blockly.WidgetDiv.position(e.x,e.y,b,c);d.style.visibility="visible"};
  Blockly.FieldRectangularDropdown.prototype.calculateMenuPosition_=function(a,b){var c=Blockly.getAbsoluteXY_(a,this.getRootSVGElement_()),c={x:c.x-Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER,y:c.y-Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER};b&&(c.y+=this.previewSize_.height+Blockly.FieldRectangularDropdown.DROPDOWN_MENU_BORDER);return c};Blockly.FieldRectangularDropdown.prototype.getValue=function(){return this.value_};
  Blockly.FieldRectangularDropdown.prototype.setValue=function(a){this.value_=a;this.refreshPreview_()};Blockly.FieldRectangularDropdown.prototype.refreshPreview_=function(){this.updatePreviewData_(this.getCurrentPreviewData_())};Blockly.FieldRectangularDropdown.prototype.getCurrentPreviewData_=function(){return this.getPreviewDataForValue_(this.value_)};
  Blockly.FieldRectangularDropdown.prototype.getPreviewDataForValue_=function(a){for(var b=this.choices_,c=0;c<b.length;c++)if(b[c][Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX]==a)return b[c][Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX];throw'Preview data for given value "'+a+'" not found';};
  Blockly.FieldRectangularDropdown.prototype.init=function(a){if(this.sourceBlock_)throw"Field has already been initialized once.";this.sourceBlock_=a;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(a){this.doNotOpenEditorNextMouseUp_?this.doNotOpenEditorNextMouseUp_=!1:Blockly.isRightButton(a)||Blockly.Block.isFreelyDragging()||!this.sourceBlock_.isEditable()||this.showMenu_()};Blockly.FieldRectangularDropdown.prototype.onMouseDown_=function(a){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 a=this.sourceBlock_.getHexColour();return Blockly.mixColoursWithForegroundOpacity("#ffffff",a,0.6)};Blockly.FieldColourDropdown=function(a,b,c){a=this.convertColourChoicesToTuples_(a);Blockly.FieldColourDropdown.superClass_.constructor.call(this,a);this.updateDimensions_(b,c)};goog.inherits(Blockly.FieldColourDropdown,Blockly.FieldRectangularDropdown);
  Blockly.FieldColourDropdown.prototype.convertColourChoicesToTuples_=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=[];e[Blockly.FieldRectangularDropdown.TUPLE_PREVIEW_DATA_INDEX]=d;e[Blockly.FieldRectangularDropdown.TUPLE_VALUE_INDEX]=d;b.push(e)}return b};
  Blockly.FieldColourDropdown.prototype.addPreviewElementTo_=function(a){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"},a)};Blockly.FieldColourDropdown.prototype.createDropdownPreviewElement_=function(a){var b=document.createElement("div");b.style.backgroundColor=a;b.style.width=this.previewSize_.width+"px";b.style.height=this.previewSize_.height+"px";return b};
  Blockly.FieldColourDropdown.prototype.updatePreviewData_=function(a){this.previewElement_.setAttribute("fill",a)};Blockly.FieldColourDropdown.prototype.updatePreviewDimensions_=function(a,b){this.previewElement_.setAttribute("width",a+"px");this.previewElement_.setAttribute("height",b+"px")};Blockly.Names=function(a){this.reservedDict_={};if(a){a=a.split(",");for(var b=0;b<a.length;b++)this.reservedDict_[Blockly.Names.PREFIX_+a[b]]=!0}this.reset()};Blockly.Names.PREFIX_="$_";Blockly.Names.prototype.reset=function(){this.db_={};this.dbSpecificType_={};this.dbReverse_={}};Blockly.Names.prototype.getName=function(a,b,c){var d=Blockly.Names.PREFIX_+a.toLowerCase()+"_"+b;if(d in this.db_)return this.db_[d];a=this.getDistinctName(a,b);this.db_[d]=a;c&&(this.dbSpecificType_[d]=c);return a};
  Blockly.Names.prototype.checkSpecificType=function(a,b,c){a=Blockly.Names.PREFIX_+a.toLowerCase()+"_"+b;return a in this.dbSpecificType_&&this.dbSpecificType_[a]===c};Blockly.Names.prototype.getDistinctName=function(a,b){for(var c=this.safeName_(a),d="";this.dbReverse_[Blockly.Names.PREFIX_+c+d]||Blockly.Names.PREFIX_+c+d in this.reservedDict_;)d=d?d+1:2;c+=d;this.dbReverse_[Blockly.Names.PREFIX_+c]=!0;return c};
  Blockly.Names.prototype.safeName_=function(a){a?(a=encodeURI(a.replace(/ /g,"_")).replace(/[^\w]/g,"_"),-1!="0123456789".indexOf(a[0])&&(a="my_"+a)):a="unnamed";return a};Blockly.Names.equals=function(a,b){return a.toLowerCase()==b.toLowerCase()};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.debug={};goog.debug.Error=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.asserts={};goog.asserts.ENABLE_ASSERTS=goog.DEBUG;goog.asserts.AssertionError=function(a,b){b.unshift(a);goog.debug.Error.call(this,goog.string.subs.apply(null,b));b.shift();this.messagePattern=a};goog.inherits(goog.asserts.AssertionError,goog.debug.Error);goog.asserts.AssertionError.prototype.name="AssertionError";goog.asserts.doAssertFailure_=function(a,b,c,d){var e="Assertion failed";if(c)var e=e+(": "+c),f=d;else a&&(e+=": "+a,f=b);throw new goog.asserts.AssertionError(""+e,f||[]);};
  goog.asserts.assert=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!a&&goog.asserts.doAssertFailure_("",null,b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.fail=function(a,b){if(goog.asserts.ENABLE_ASSERTS)throw new goog.asserts.AssertionError("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};
  goog.asserts.assertNumber=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isNumber(a)&&goog.asserts.doAssertFailure_("Expected number but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertString=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isString(a)&&goog.asserts.doAssertFailure_("Expected string but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
  goog.asserts.assertFunction=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isFunction(a)&&goog.asserts.doAssertFailure_("Expected function but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertObject=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isObject(a)&&goog.asserts.doAssertFailure_("Expected object but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
  goog.asserts.assertArray=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isArray(a)&&goog.asserts.doAssertFailure_("Expected array but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertBoolean=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isBoolean(a)&&goog.asserts.doAssertFailure_("Expected boolean but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
  goog.asserts.assertElement=function(a,b,c){!goog.asserts.ENABLE_ASSERTS||goog.isObject(a)&&a.nodeType==goog.dom.NodeType.ELEMENT||goog.asserts.doAssertFailure_("Expected Element but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertInstanceof=function(a,b,c,d){!goog.asserts.ENABLE_ASSERTS||a instanceof b||goog.asserts.doAssertFailure_("instanceof check failed.",null,c,Array.prototype.slice.call(arguments,3));return a};
  goog.asserts.assertObjectPrototypeIsIntact=function(){for(var a in Object.prototype)goog.asserts.fail(a+" should not be enumerable in Object.prototype.")};goog.events={};goog.events.EventId=function(a){this.id=a};goog.events.EventId.prototype.toString=function(){return this.id};goog.events.Listenable=function(){};goog.events.Listenable.IMPLEMENTED_BY_PROP="closure_listenable_"+(1E6*Math.random()|0);goog.events.Listenable.addImplementation=function(a){a.prototype[goog.events.Listenable.IMPLEMENTED_BY_PROP]=!0};goog.events.Listenable.isImplementedBy=function(a){try{return!(!a||!a[goog.events.Listenable.IMPLEMENTED_BY_PROP])}catch(b){return!1}};goog.events.ListenableKey=function(){};goog.events.ListenableKey.counter_=0;goog.events.ListenableKey.reserveKey=function(){return++goog.events.ListenableKey.counter_};goog.events.Listener=function(a,b,c,d,e,f){goog.events.Listener.ENABLE_MONITORING&&(this.creationStack=Error().stack);this.listener=a;this.proxy=b;this.src=c;this.type=d;this.capture=!!e;this.handler=f;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.object={};goog.object.forEach=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)};goog.object.filter=function(a,b,c){var d={},e;for(e in a)b.call(c,a[e],e,a)&&(d[e]=a[e]);return d};goog.object.map=function(a,b,c){var d={},e;for(e in a)d[e]=b.call(c,a[e],e,a);return d};goog.object.some=function(a,b,c){for(var d in a)if(b.call(c,a[d],d,a))return!0;return!1};goog.object.every=function(a,b,c){for(var d in a)if(!b.call(c,a[d],d,a))return!1;return!0};
  goog.object.getCount=function(a){var b=0,c;for(c in a)b++;return b};goog.object.getAnyKey=function(a){for(var b in a)return b};goog.object.getAnyValue=function(a){for(var b in a)return a[b]};goog.object.contains=function(a,b){return goog.object.containsValue(a,b)};goog.object.getValues=function(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b};goog.object.getKeys=function(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b};
  goog.object.getValueByKeys=function(a,b){for(var c=goog.isArrayLike(b),d=c?b:arguments,c=c?0:1;c<d.length&&(a=a[d[c]],goog.isDef(a));c++);return a};goog.object.containsKey=function(a,b){return b in a};goog.object.containsValue=function(a,b){for(var c in a)if(a[c]==b)return!0;return!1};goog.object.findKey=function(a,b,c){for(var d in a)if(b.call(c,a[d],d,a))return d};goog.object.findValue=function(a,b,c){return(b=goog.object.findKey(a,b,c))&&a[b]};
  goog.object.isEmpty=function(a){for(var b in a)return!1;return!0};goog.object.clear=function(a){for(var b in a)delete a[b]};goog.object.remove=function(a,b){var c;(c=b in a)&&delete a[b];return c};goog.object.add=function(a,b,c){if(b in a)throw Error('The object already contains the key "'+b+'"');goog.object.set(a,b,c)};goog.object.get=function(a,b,c){return b in a?a[b]:c};goog.object.set=function(a,b,c){a[b]=c};goog.object.setIfUndefined=function(a,b,c){return b in a?a[b]:a[b]=c};
  goog.object.clone=function(a){var b={},c;for(c in a)b[c]=a[c];return b};goog.object.unsafeClone=function(a){var b=goog.typeOf(a);if("object"==b||"array"==b){if(a.clone)return a.clone();var b="array"==b?[]:{},c;for(c in a)b[c]=goog.object.unsafeClone(a[c]);return b}return a};goog.object.transpose=function(a){var b={},c;for(c in a)b[a[c]]=c;return b};goog.object.PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
  goog.object.extend=function(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<goog.object.PROTOTYPE_FIELDS_.length;f++)c=goog.object.PROTOTYPE_FIELDS_[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};
  goog.object.create=function(a){var b=arguments.length;if(1==b&&goog.isArray(arguments[0]))return goog.object.create.apply(null,arguments[0]);if(b%2)throw Error("Uneven number of arguments");for(var c={},d=0;d<b;d+=2)c[arguments[d]]=arguments[d+1];return c};goog.object.createSet=function(a){var b=arguments.length;if(1==b&&goog.isArray(arguments[0]))return goog.object.createSet.apply(null,arguments[0]);for(var c={},d=0;d<b;d++)c[arguments[d]]=!0;return c};
  goog.object.createImmutableView=function(a){var b=a;Object.isFrozen&&!Object.isFrozen(a)&&(b=Object.create(a),Object.freeze(b));return b};goog.object.isImmutableView=function(a){return!!Object.isFrozen&&Object.isFrozen(a)};goog.array={};goog.NATIVE_ARRAY_PROTOTYPES=goog.TRUSTED_SITE;goog.array.ASSUME_NATIVE_FUNCTIONS=!1;goog.array.peek=function(a){return a[a.length-1]};goog.array.ARRAY_PROTOTYPE_=Array.prototype;
  goog.array.indexOf=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.indexOf)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(goog.isString(a))return goog.isString(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};
  goog.array.lastIndexOf=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.lastIndexOf)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.lastIndexOf.call(a,b,null==c?a.length-1:c)}:function(a,b,c){c=null==c?a.length-1:c;0>c&&(c=Math.max(0,a.length+c));if(goog.isString(a))return goog.isString(b)&&1==b.length?a.lastIndexOf(b,c):-1;for(;0<=c;c--)if(c in a&&a[c]===b)return c;return-1};
  goog.array.forEach=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.forEach)?function(a,b,c){goog.asserts.assert(null!=a.length);goog.array.ARRAY_PROTOTYPE_.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)};goog.array.forEachRight=function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,d=d-1;0<=d;--d)d in e&&b.call(c,e[d],d,a)};
  goog.array.filter=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.filter)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,g=goog.isString(a)?a.split(""):a,h=0;h<d;h++)if(h in g){var k=g[h];b.call(c,k,h,a)&&(e[f++]=k)}return e};
  goog.array.map=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.map)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=goog.isString(a)?a.split(""):a,g=0;g<d;g++)g in f&&(e[g]=b.call(c,f[g],g,a));return e};
  goog.array.reduce=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.reduce)?function(a,b,c,d){goog.asserts.assert(null!=a.length);d&&(b=goog.bind(b,d));return goog.array.ARRAY_PROTOTYPE_.reduce.call(a,b,c)}:function(a,b,c,d){var e=c;goog.array.forEach(a,function(c,g){e=b.call(d,e,c,g,a)});return e};
  goog.array.reduceRight=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.reduceRight)?function(a,b,c,d){goog.asserts.assert(null!=a.length);d&&(b=goog.bind(b,d));return goog.array.ARRAY_PROTOTYPE_.reduceRight.call(a,b,c)}:function(a,b,c,d){var e=c;goog.array.forEachRight(a,function(c,g){e=b.call(d,e,c,g,a)});return e};
  goog.array.some=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.some)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1};
  goog.array.every=goog.NATIVE_ARRAY_PROTOTYPES&&(goog.array.ASSUME_NATIVE_FUNCTIONS||goog.array.ARRAY_PROTOTYPE_.every)?function(a,b,c){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};goog.array.count=function(a,b,c){var d=0;goog.array.forEach(a,function(a,f,g){b.call(c,a,f,g)&&++d},c);return d};
  goog.array.find=function(a,b,c){b=goog.array.findIndex(a,b,c);return 0>b?null:goog.isString(a)?a.charAt(b):a[b]};goog.array.findIndex=function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1};goog.array.findRight=function(a,b,c){b=goog.array.findIndexRight(a,b,c);return 0>b?null:goog.isString(a)?a.charAt(b):a[b]};
  goog.array.findIndexRight=function(a,b,c){for(var d=a.length,e=goog.isString(a)?a.split(""):a,d=d-1;0<=d;d--)if(d in e&&b.call(c,e[d],d,a))return d;return-1};goog.array.contains=function(a,b){return 0<=goog.array.indexOf(a,b)};goog.array.isEmpty=function(a){return 0==a.length};goog.array.clear=function(a){if(!goog.isArray(a))for(var b=a.length-1;0<=b;b--)delete a[b];a.length=0};goog.array.insert=function(a,b){goog.array.contains(a,b)||a.push(b)};
  goog.array.insertAt=function(a,b,c){goog.array.splice(a,c,0,b)};goog.array.insertArrayAt=function(a,b,c){goog.partial(goog.array.splice,a,c,0).apply(null,b)};goog.array.insertBefore=function(a,b,c){var d;2==arguments.length||0>(d=goog.array.indexOf(a,c))?a.push(b):goog.array.insertAt(a,b,d)};goog.array.remove=function(a,b){var c=goog.array.indexOf(a,b),d;(d=0<=c)&&goog.array.removeAt(a,c);return d};
  goog.array.removeAt=function(a,b){goog.asserts.assert(null!=a.length);return 1==goog.array.ARRAY_PROTOTYPE_.splice.call(a,b,1).length};goog.array.removeIf=function(a,b,c){b=goog.array.findIndex(a,b,c);return 0<=b?(goog.array.removeAt(a,b),!0):!1};goog.array.concat=function(a){return goog.array.ARRAY_PROTOTYPE_.concat.apply(goog.array.ARRAY_PROTOTYPE_,arguments)};goog.array.toArray=function(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]};goog.array.clone=goog.array.toArray;
  goog.array.extend=function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c],e;if(goog.isArray(d)||(e=goog.isArrayLike(d))&&Object.prototype.hasOwnProperty.call(d,"callee"))a.push.apply(a,d);else if(e)for(var f=a.length,g=d.length,h=0;h<g;h++)a[f+h]=d[h];else a.push(d)}};goog.array.splice=function(a,b,c,d){goog.asserts.assert(null!=a.length);return goog.array.ARRAY_PROTOTYPE_.splice.apply(a,goog.array.slice(arguments,1))};
  goog.array.slice=function(a,b,c){goog.asserts.assert(null!=a.length);return 2>=arguments.length?goog.array.ARRAY_PROTOTYPE_.slice.call(a,b):goog.array.ARRAY_PROTOTYPE_.slice.call(a,b,c)};goog.array.removeDuplicates=function(a,b,c){b=b||a;var d=function(a){return goog.isObject(g)?"o"+goog.getUid(g):(typeof g).charAt(0)+g};c=c||d;for(var d={},e=0,f=0;f<a.length;){var g=a[f++],h=c(g);Object.prototype.hasOwnProperty.call(d,h)||(d[h]=!0,b[e++]=g)}b.length=e};
  goog.array.binarySearch=function(a,b,c){return goog.array.binarySearch_(a,c||goog.array.defaultCompare,!1,b)};goog.array.binarySelect=function(a,b,c){return goog.array.binarySearch_(a,b,!0,void 0,c)};goog.array.binarySearch_=function(a,b,c,d,e){for(var f=0,g=a.length,h;f<g;){var k=f+g>>1,l;l=c?b.call(e,a[k],k,a):b(d,a[k]);0<l?f=k+1:(g=k,h=!l)}return h?f:~f};goog.array.sort=function(a,b){a.sort(b||goog.array.defaultCompare)};
  goog.array.stableSort=function(a,b){for(var c=0;c<a.length;c++)a[c]={index:c,value:a[c]};var d=b||goog.array.defaultCompare;goog.array.sort(a,function(a,b){return d(a.value,b.value)||a.index-b.index});for(c=0;c<a.length;c++)a[c]=a[c].value};goog.array.sortObjectsByKey=function(a,b,c){var d=c||goog.array.defaultCompare;goog.array.sort(a,function(a,c){return d(a[b],c[b])})};
  goog.array.isSorted=function(a,b,c){b=b||goog.array.defaultCompare;for(var d=1;d<a.length;d++){var e=b(a[d-1],a[d]);if(0<e||0==e&&c)return!1}return!0};goog.array.equals=function(a,b,c){if(!goog.isArrayLike(a)||!goog.isArrayLike(b)||a.length!=b.length)return!1;var d=a.length;c=c||goog.array.defaultCompareEquality;for(var e=0;e<d;e++)if(!c(a[e],b[e]))return!1;return!0};
  goog.array.compare3=function(a,b,c){c=c||goog.array.defaultCompare;for(var d=Math.min(a.length,b.length),e=0;e<d;e++){var f=c(a[e],b[e]);if(0!=f)return f}return goog.array.defaultCompare(a.length,b.length)};goog.array.defaultCompare=function(a,b){return a>b?1:a<b?-1:0};goog.array.defaultCompareEquality=function(a,b){return a===b};goog.array.binaryInsert=function(a,b,c){c=goog.array.binarySearch(a,b,c);return 0>c?(goog.array.insertAt(a,b,-(c+1)),!0):!1};
  goog.array.binaryRemove=function(a,b,c){b=goog.array.binarySearch(a,b,c);return 0<=b?goog.array.removeAt(a,b):!1};goog.array.bucket=function(a,b,c){for(var d={},e=0;e<a.length;e++){var f=a[e],g=b.call(c,f,e,a);goog.isDef(g)&&(d[g]||(d[g]=[])).push(f)}return d};goog.array.toObject=function(a,b,c){var d={};goog.array.forEach(a,function(e,f){d[b.call(c,e,f,a)]=e});return d};
  goog.array.range=function(a,b,c){var d=[],e=0,f=a;c=c||1;void 0!==b&&(e=a,f=b);if(0>c*(f-e))return[];if(0<c)for(a=e;a<f;a+=c)d.push(a);else for(a=e;a>f;a+=c)d.push(a);return d};goog.array.repeat=function(a,b){for(var c=[],d=0;d<b;d++)c[d]=a;return c};goog.array.flatten=function(a){for(var b=[],c=0;c<arguments.length;c++){var d=arguments[c];goog.isArray(d)?b.push.apply(b,goog.array.flatten.apply(null,d)):b.push(d)}return b};
  goog.array.rotate=function(a,b){goog.asserts.assert(null!=a.length);a.length&&(b%=a.length,0<b?goog.array.ARRAY_PROTOTYPE_.unshift.apply(a,a.splice(-b,b)):0>b&&goog.array.ARRAY_PROTOTYPE_.push.apply(a,a.splice(0,-b)));return a};goog.array.moveItem=function(a,b,c){goog.asserts.assert(0<=b&&b<a.length);goog.asserts.assert(0<=c&&c<a.length);b=goog.array.ARRAY_PROTOTYPE_.splice.call(a,b,1);goog.array.ARRAY_PROTOTYPE_.splice.call(a,c,0,b[0])};
  goog.array.zip=function(a){if(!arguments.length)return[];for(var b=[],c=0;;c++){for(var d=[],e=0;e<arguments.length;e++){var f=arguments[e];if(c>=f.length)return b;d.push(f[c])}b.push(d)}};goog.array.shuffle=function(a,b){for(var c=b||Math.random,d=a.length-1;0<d;d--){var e=Math.floor(c()*(d+1)),f=a[d];a[d]=a[e];a[e]=f}};goog.events.ListenerMap=function(a){this.src=a;this.listeners={};this.typeCount_=0};goog.events.ListenerMap.prototype.getTypeCount=function(){return this.typeCount_};goog.events.ListenerMap.prototype.getListenerCount=function(){var a=0,b;for(b in this.listeners)a+=this.listeners[b].length;return a};
  goog.events.ListenerMap.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.listeners[f];a||(a=this.listeners[f]=[],this.typeCount_++);var g=goog.events.ListenerMap.findListenerIndex_(a,b,d,e);-1<g?(b=a[g],c||(b.callOnce=!1)):(b=new goog.events.Listener(b,null,this.src,f,!!d,e),b.callOnce=c,a.push(b));return b};
  goog.events.ListenerMap.prototype.remove=function(a,b,c,d){a=a.toString();if(!(a in this.listeners))return!1;var e=this.listeners[a];b=goog.events.ListenerMap.findListenerIndex_(e,b,c,d);return-1<b?(e[b].markAsRemoved(),goog.array.removeAt(e,b),0==e.length&&(delete this.listeners[a],this.typeCount_--),!0):!1};
  goog.events.ListenerMap.prototype.removeByKey=function(a){var b=a.type;if(!(b in this.listeners))return!1;var c=goog.array.remove(this.listeners[b],a);c&&(a.markAsRemoved(),0==this.listeners[b].length&&(delete this.listeners[b],this.typeCount_--));return c};goog.events.ListenerMap.prototype.removeAll=function(a){a=a&&a.toString();var b=0,c;for(c in this.listeners)if(!a||c==a){for(var d=this.listeners[c],e=0;e<d.length;e++)++b,d[e].markAsRemoved();delete this.listeners[c];this.typeCount_--}return b};
  goog.events.ListenerMap.prototype.getListeners=function(a,b){var c=this.listeners[a.toString()],d=[];if(c)for(var e=0;e<c.length;++e){var f=c[e];f.capture==b&&d.push(f)}return d};goog.events.ListenerMap.prototype.getListener=function(a,b,c,d){a=this.listeners[a.toString()];var e=-1;a&&(e=goog.events.ListenerMap.findListenerIndex_(a,b,c,d));return-1<e?a[e]:null};
  goog.events.ListenerMap.prototype.hasListener=function(a,b){var c=goog.isDef(a),d=c?a.toString():"",e=goog.isDef(b);return goog.object.some(this.listeners,function(a,g){for(var h=0;h<a.length;++h)if(!(c&&a[h].type!=d||e&&a[h].capture!=b))return!0;return!1})};goog.events.ListenerMap.findListenerIndex_=function(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e];if(!f.removed&&f.listener==b&&f.capture==!!c&&f.handler==d)return e}return-1};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.debug.entryPointRegistry={};goog.debug.EntryPointMonitor=function(){};goog.debug.entryPointRegistry.refList_=[];goog.debug.entryPointRegistry.monitors_=[];goog.debug.entryPointRegistry.monitorsMayExist_=!1;goog.debug.entryPointRegistry.register=function(a){goog.debug.entryPointRegistry.refList_[goog.debug.entryPointRegistry.refList_.length]=a;if(goog.debug.entryPointRegistry.monitorsMayExist_)for(var b=goog.debug.entryPointRegistry.monitors_,c=0;c<b.length;c++)a(goog.bind(b[c].wrap,b[c]))};
  goog.debug.entryPointRegistry.monitorAll=function(a){goog.debug.entryPointRegistry.monitorsMayExist_=!0;for(var b=goog.bind(a.wrap,a),c=0;c<goog.debug.entryPointRegistry.refList_.length;c++)goog.debug.entryPointRegistry.refList_[c](b);goog.debug.entryPointRegistry.monitors_.push(a)};
  goog.debug.entryPointRegistry.unmonitorAllIfPossible=function(a){var b=goog.debug.entryPointRegistry.monitors_;goog.asserts.assert(a==b[b.length-1],"Only the most recent monitor can be unwrapped.");a=goog.bind(a.unwrap,a);for(var c=0;c<goog.debug.entryPointRegistry.refList_.length;c++)goog.debug.entryPointRegistry.refList_[c](a);b.length--};goog.events.getVendorPrefixedName_=function(a){return goog.userAgent.WEBKIT?"webkit"+a:goog.userAgent.OPERA?"o"+a.toLowerCase():a.toLowerCase()};
  goog.events.EventType={CLICK:"click",DBLCLICK:"dblclick",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",MOUSEOVER:"mouseover",MOUSEOUT:"mouseout",MOUSEMOVE:"mousemove",MOUSEENTER:"mouseenter",MOUSELEAVE:"mouseleave",SELECTSTART:"selectstart",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",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",DOMCONTENTLOADED:"DOMContentLoaded",ERROR:"error",HELP:"help",LOAD:"load",LOSECAPTURE:"losecapture",ORIENTATIONCHANGE:"orientationchange",READYSTATECHANGE:"readystatechange",RESIZE:"resize",SCROLL:"scroll",
  UNLOAD:"unload",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",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"};goog.disposable={};goog.disposable.IDisposable=function(){};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)};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 a=[],b;for(b in goog.Disposable.instances_)goog.Disposable.instances_.hasOwnProperty(b)&&a.push(goog.Disposable.instances_[Number(b)]);return a};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 a=goog.getUid(this);if(goog.Disposable.MONITORING_MODE==goog.Disposable.MonitoringMode.PERMANENT&&!goog.Disposable.instances_.hasOwnProperty(a))throw Error(this+" did not call the goog.Disposable base constructor or was disposed of after a clearUndisposedObjects call");delete goog.Disposable.instances_[a]}};
  goog.Disposable.prototype.registerDisposable=function(a){this.addOnDisposeCallback(goog.partial(goog.dispose,a))};goog.Disposable.prototype.addOnDisposeCallback=function(a,b){this.onDisposeCallbacks_||(this.onDisposeCallbacks_=[]);this.onDisposeCallbacks_.push(goog.bind(a,b))};goog.Disposable.prototype.disposeInternal=function(){if(this.onDisposeCallbacks_)for(;this.onDisposeCallbacks_.length;)this.onDisposeCallbacks_.shift()()};
  goog.Disposable.isDisposed=function(a){return a&&"function"==typeof a.isDisposed?a.isDisposed():!1};goog.dispose=function(a){a&&"function"==typeof a.dispose&&a.dispose()};goog.disposeAll=function(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];goog.isArrayLike(d)?goog.disposeAll.apply(null,d):goog.dispose(d)}};goog.events.Event=function(a,b){this.type=a instanceof goog.events.EventId?String(a):a;this.currentTarget=this.target=b;this.defaultPrevented=this.propagationStopped_=!1;this.returnValue_=!0};goog.events.Event.prototype.disposeInternal=function(){};goog.events.Event.prototype.dispose=function(){};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(a){a.stopPropagation()};goog.events.Event.preventDefault=function(a){a.preventDefault()};goog.reflect={};goog.reflect.object=function(a,b){return b};goog.reflect.sinkValue=function(a){goog.reflect.sinkValue[" "](a);return a};goog.reflect.sinkValue[" "]=goog.nullFunction;goog.reflect.canAccessProperty=function(a,b){try{return goog.reflect.sinkValue(a[b]),!0}catch(c){}return!1};goog.events.BrowserEvent=function(a,b){goog.events.BrowserEvent.base(this,"constructor",a?a.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;a&&this.init(a,b)};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(a,b){var c=this.type=a.type;this.target=a.target||a.srcElement;this.currentTarget=b;var d=a.relatedTarget;d?goog.userAgent.GECKO&&(goog.reflect.canAccessProperty(d,"nodeName")||(d=null)):c==goog.events.EventType.MOUSEOVER?d=a.fromElement:c==goog.events.EventType.MOUSEOUT&&(d=a.toElement);this.relatedTarget=d;this.offsetX=goog.userAgent.WEBKIT||void 0!==a.offsetX?a.offsetX:a.layerX;this.offsetY=goog.userAgent.WEBKIT||void 0!==a.offsetY?a.offsetY:a.layerY;
  this.clientX=void 0!==a.clientX?a.clientX:a.pageX;this.clientY=void 0!==a.clientY?a.clientY:a.pageY;this.screenX=a.screenX||0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||("keypress"==c?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.platformModifierKey=goog.userAgent.MAC?a.metaKey:a.ctrlKey;this.state=a.state;this.event_=a;a.defaultPrevented&&this.preventDefault()};
  goog.events.BrowserEvent.prototype.isButton=function(a){return goog.events.BrowserFeature.HAS_W3C_BUTTON?this.event_.button==a:"click"==this.type?a==goog.events.BrowserEvent.MouseButton.LEFT:!!(this.event_.button&goog.events.BrowserEvent.IEButtonMap[a])};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 a=this.event_;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,goog.events.BrowserFeature.SET_KEY_CODE_TO_PREVENT_DEFAULT)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};goog.events.BrowserEvent.prototype.getBrowserEvent=function(){return this.event_};goog.events.BrowserEvent.prototype.disposeInternal=function(){};goog.events.listeners_={};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(a,b,c,d,e){if(goog.isArray(b)){for(var f=0;f<b.length;f++)goog.events.listen(a,b[f],c,d,e);return null}c=goog.events.wrapListener(c);return goog.events.Listenable.isImplementedBy(a)?a.listen(b,c,d,e):goog.events.listen_(a,b,c,!1,d,e)};
  goog.events.listen_=function(a,b,c,d,e,f){if(!b)throw Error("Invalid event type");var g=!!e;if(g&&!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 h=goog.events.getListenerMap_(a);h||(a[goog.events.LISTENER_MAP_PROP_]=h=new goog.events.ListenerMap(a));
  c=h.add(b,c,d,e,f);if(c.proxy)return c;d=goog.events.getProxy();c.proxy=d;d.src=a;d.listener=c;a.addEventListener?a.addEventListener(b,d,g):a.attachEvent(goog.events.getOnString_(b),d);goog.events.listenerCountEstimate_++;return c};goog.events.getProxy=function(){var a=goog.events.handleBrowserEvent_,b=goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT?function(c){return a.call(b.src,b.listener,c)}:function(c){c=a.call(b.src,b.listener,c);if(!c)return c};return b};
  goog.events.listenOnce=function(a,b,c,d,e){if(goog.isArray(b)){for(var f=0;f<b.length;f++)goog.events.listenOnce(a,b[f],c,d,e);return null}c=goog.events.wrapListener(c);return goog.events.Listenable.isImplementedBy(a)?a.listenOnce(b,c,d,e):goog.events.listen_(a,b,c,!0,d,e)};goog.events.listenWithWrapper=function(a,b,c,d,e){b.listen(a,c,d,e)};
  goog.events.unlisten=function(a,b,c,d,e){if(goog.isArray(b)){for(var f=0;f<b.length;f++)goog.events.unlisten(a,b[f],c,d,e);return null}c=goog.events.wrapListener(c);if(goog.events.Listenable.isImplementedBy(a))return a.unlisten(b,c,d,e);if(!a)return!1;d=!!d;if(a=goog.events.getListenerMap_(a))if(b=a.getListener(b,c,d,e))return goog.events.unlistenByKey(b);return!1};
  goog.events.unlistenByKey=function(a){if(goog.isNumber(a)||!a||a.removed)return!1;var b=a.src;if(goog.events.Listenable.isImplementedBy(b))return b.unlistenByKey(a);var c=a.type,d=a.proxy;b.removeEventListener?b.removeEventListener(c,d,a.capture):b.detachEvent&&b.detachEvent(goog.events.getOnString_(c),d);goog.events.listenerCountEstimate_--;(c=goog.events.getListenerMap_(b))?(c.removeByKey(a),0==c.getTypeCount()&&(c.src=null,b[goog.events.LISTENER_MAP_PROP_]=null)):a.markAsRemoved();return!0};
  goog.events.unlistenWithWrapper=function(a,b,c,d,e){b.unlisten(a,c,d,e)};goog.events.removeAll=function(a,b){if(!a)return 0;if(goog.events.Listenable.isImplementedBy(a))return a.removeAllListeners(b);var c=goog.events.getListenerMap_(a);if(!c)return 0;var d=0,e;for(e in c.listeners)if(!b||e==b)for(var f=goog.array.clone(c.listeners[e]),g=0;g<f.length;++g)goog.events.unlistenByKey(f[g])&&++d;return d};goog.events.removeAllNativeListeners=function(){return goog.events.listenerCountEstimate_=0};
  goog.events.getListeners=function(a,b,c){return goog.events.Listenable.isImplementedBy(a)?a.getListeners(b,c):a?(a=goog.events.getListenerMap_(a))?a.getListeners(b,c):[]:[]};goog.events.getListener=function(a,b,c,d,e){c=goog.events.wrapListener(c);d=!!d;return goog.events.Listenable.isImplementedBy(a)?a.getListener(b,c,d,e):a?(a=goog.events.getListenerMap_(a))?a.getListener(b,c,d,e):null:null};
  goog.events.hasListener=function(a,b,c){if(goog.events.Listenable.isImplementedBy(a))return a.hasListener(b,c);a=goog.events.getListenerMap_(a);return!!a&&a.hasListener(b,c)};goog.events.expose=function(a){var b=[],c;for(c in a)a[c]&&a[c].id?b.push(c+" = "+a[c]+" ("+a[c].id+")"):b.push(c+" = "+a[c]);return b.join("\n")};goog.events.getOnString_=function(a){return a in goog.events.onStringMap_?goog.events.onStringMap_[a]:goog.events.onStringMap_[a]=goog.events.onString_+a};
  goog.events.fireListeners=function(a,b,c,d){return goog.events.Listenable.isImplementedBy(a)?a.fireListeners(b,c,d):goog.events.fireListeners_(a,b,c,d)};goog.events.fireListeners_=function(a,b,c,d){var e=1;if(a=goog.events.getListenerMap_(a))if(b=a.listeners[b])for(b=goog.array.clone(b),a=0;a<b.length;a++){var f=b[a];f&&f.capture==c&&!f.removed&&(e&=!1!==goog.events.fireListener(f,d))}return Boolean(e)};
  goog.events.fireListener=function(a,b){var c=a.listener,d=a.handler||a.src;a.callOnce&&goog.events.unlistenByKey(a);return c.call(d,b)};goog.events.getTotalListenerCount=function(){return goog.events.listenerCountEstimate_};goog.events.dispatchEvent=function(a,b){goog.asserts.assert(goog.events.Listenable.isImplementedBy(a),"Can not use goog.events.dispatchEvent with non-goog.events.Listenable instance.");return a.dispatchEvent(b)};
  goog.events.protectBrowserEventEntryPoint=function(a){goog.events.handleBrowserEvent_=a.protectEntryPoint(goog.events.handleBrowserEvent_)};
  goog.events.handleBrowserEvent_=function(a,b){if(a.removed)return!0;if(!goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT){var c=b||goog.getObjectByName("window.event"),d=new goog.events.BrowserEvent(c,this),e=!0;if(goog.events.CAPTURE_SIMULATION_MODE==goog.events.CaptureSimulationMode.ON){if(!goog.events.isMarkedIeEvent_(c)){goog.events.markIeEvent_(c);for(var c=[],f=d.currentTarget;f;f=f.parentNode)c.push(f);for(var f=a.type,g=c.length-1;!d.propagationStopped_&&0<=g;g--)d.currentTarget=c[g],e&=goog.events.fireListeners_(c[g],
  f,!0,d);for(g=0;!d.propagationStopped_&&g<c.length;g++)d.currentTarget=c[g],e&=goog.events.fireListeners_(c[g],f,!1,d)}}else e=goog.events.fireListener(a,d);return e}return goog.events.fireListener(a,new goog.events.BrowserEvent(b,this))};goog.events.markIeEvent_=function(a){var b=!1;if(0==a.keyCode)try{a.keyCode=-1;return}catch(c){b=!0}if(b||void 0==a.returnValue)a.returnValue=!0};goog.events.isMarkedIeEvent_=function(a){return 0>a.keyCode||void 0!=a.returnValue};goog.events.uniqueIdCounter_=0;
  goog.events.getUniqueId=function(a){return a+"_"+goog.events.uniqueIdCounter_++};goog.events.getListenerMap_=function(a){a=a[goog.events.LISTENER_MAP_PROP_];return a instanceof goog.events.ListenerMap?a:null};goog.events.LISTENER_WRAPPER_PROP_="__closure_events_fn_"+(1E9*Math.random()>>>0);
  goog.events.wrapListener=function(a){goog.asserts.assert(a,"Listener can not be null.");if(goog.isFunction(a))return a;goog.asserts.assert(a.handleEvent,"An object listener must have handleEvent method.");return a[goog.events.LISTENER_WRAPPER_PROP_]||(a[goog.events.LISTENER_WRAPPER_PROP_]=function(b){return a.handleEvent(b)})};goog.debug.entryPointRegistry.register(function(a){goog.events.handleBrowserEvent_=a(goog.events.handleBrowserEvent_)});Blockly.FieldDropdown=function(a,b){this.menuGenerator_=a||[[Blockly.FieldDropdown.NO_OPTIONS_MESSAGE,Blockly.FieldDropdown.NO_OPTIONS_MESSAGE]];this.changeHandler_=b;this.trimOptions_();var c=this.getOptions()[0];this.value_=c[1];this.arrow_=Blockly.createSvgElement("tspan",{"class":"blocklyArrow"},null);this.arrow_.appendChild(document.createTextNode(Blockly.RTL?"\u25bc ":" \u25bc"));Blockly.FieldDropdown.superClass_.constructor.call(this,c[0])};goog.inherits(Blockly.FieldDropdown,Blockly.Field);
  Blockly.FieldDropdown.CHECKMARK_OVERHANG=25;Blockly.FieldDropdown.NO_OPTIONS_MESSAGE="uninitialized";Blockly.FieldDropdown.prototype.CURSOR="default";
  Blockly.FieldDropdown.prototype.showEditor_=function(){Blockly.WidgetDiv.show(this,null);for(var a=this,b=new goog.ui.Menu,c=this.getOptions(),d=0;d<c.length;d++){var e=c[d][1],f=new goog.ui.MenuItem(c[d][0]);f.setValue(e);f.setCheckable(!0);b.addItem(f);f.setChecked(e===this.value_)}goog.events.listen(b,goog.ui.Component.EventType.ACTION,function(b){if(b=b.target){b=b.getValue();if(a.changeHandler_){var c=a.changeHandler_(b);void 0!==c&&(b=c)}null!==b&&a.setValue(b)}Blockly.WidgetDiv.hideIfOwner(a)});
  var c=goog.dom.getViewportSize(),d=goog.style.getViewportPageOffset(document),e=Blockly.getAbsoluteXY_(this.borderRect_,this.getRootSVGElement_()),f=this.borderRect_.getBBox(),g=Blockly.WidgetDiv.DIV;g.style.visibility="hidden";b.render(g);b.setAllowAutoFocus(!0);b=b.getElement();Blockly.addClass_(b,"blocklyDropdownMenu");Blockly.addClass_(b,"goog-menu-noaccel");b.style.borderColor="hsla("+this.sourceBlock_.getColour()+", "+100*this.sourceBlock_.getSaturation()+"%, "+100*this.sourceBlock_.getValue()+
  "%, 0.5)";b.style.overflowY="auto";b.style["max-height"]="250px";b=goog.style.getSize(b);e.y=e.y+b.height+f.height>=c.height+d.y?e.y-b.height:e.y+f.height;Blockly.RTL?(e.x+=f.width,e.x+=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x<d.x+b.width&&(e.x=d.x+b.width)):(e.x-=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x>c.width+d.x-b.width&&(e.x=c.width+d.x-b.width));Blockly.isIOS()&&(e.y-=d.y);Blockly.WidgetDiv.position(e.x,e.y,c,d);g.style.visibility="visible"};
  Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixTitle=this.prefixTitle=null;var a=this.menuGenerator_;if(goog.isArray(a)&&!(2>a.length)){var b=a.map(function(a){return a[0]}),c=Blockly.shortestStringLength(b),d=Blockly.commonWordPrefix(b,c),e=Blockly.commonWordSuffix(b,c);if((d||e)&&!(c<=d+e)){d&&(this.prefixTitle=b[0].substring(0,d-1));e&&(this.suffixTitle=b[0].substr(1-e));b=[];for(c=0;c<a.length;c++){var f=a[c][0],g=a[c][1],f=f.substring(d,f.length-e);b[c]=[f,g]}this.menuGenerator_=
  b}}};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(a){this.value_=a;for(var b=this.getOptions(),c=0;c<b.length;c++)if(b[c][1]==a){this.setText(b[c][0]);return}this.setText(a)};Blockly.FieldDropdown.prototype.setToFirstValue_=function(){this.setValue(this.getOptions()[0][1])};
  Blockly.FieldDropdown.prototype.setConfig=function(a){this.config=a;a=Blockly.printerRangeToNumbers(a);0!==a.length&&(this.menuGenerator_=goog.array.map(a,function(a){return[a.toString(),a.toString()]}),this.setToFirstValue_())};
  Blockly.FieldDropdown.prototype.setText=function(a){this.sourceBlock_&&(this.arrow_.style.fill=this.sourceBlock_.getHexColour());null!==a&&(this.text_=a,goog.dom.removeChildren(this.textElement_),a=a.replace(/\s/g,Blockly.Field.NBSP),a||(a=Blockly.Field.NBSP),a=document.createTextNode(a),this.textElement_.appendChild(a),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.Msg={};Blockly.ScrollbarPair=function(a,b,c){this.blockSpace_=a;this.oldHostMetrics_=null;b&&(this.hScroll=new Blockly.Scrollbar(a,!0,b&&c));c&&(this.vScroll=new Blockly.Scrollbar(a,!1,b&&c));b&&c&&(this.corner_=Blockly.createSvgElement("rect",{height:Blockly.Scrollbar.scrollbarThickness,width:Blockly.Scrollbar.scrollbarThickness,style:"fill: #fff"},null),Blockly.Scrollbar.insertAfter_(this.corner_,a.getBubbleCanvas()))};
  Blockly.ScrollbarPair.prototype.dispose=function(){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 a=this.blockSpace_.getMetrics();if(a){var b=this.metricsChangedOnAxis.bind(this,this.oldHostMetrics_,a),c=b(["viewWidth","absoluteLeft","viewHeight","absoluteTop"]),d=c||b(["contentWidth","viewLeft","contentLeft"]),b=c||b(["contentHeight","viewTop","contentTop"]);this.hScroll&&d&&this.hScroll.resize(a);this.vScroll&&b&&this.vScroll.resize(a);this.vScroll&&this.hScroll&&c&&(this.corner_.setAttribute("x",this.vScroll.xCoordinate),this.corner_.setAttribute("y",
  this.hScroll.yCoordinate));this.oldHostMetrics_=a}};Blockly.ScrollbarPair.prototype.metricsChangedOnAxis=function(a,b,c){return a?c.some(function(c){return a[c]!=b[c]}):!0};Blockly.ScrollbarPair.prototype.set=function(a,b){this.hScroll&&this.hScroll.set(a,!0);this.vScroll&&this.vScroll.set(b,!0)};
  Blockly.ScrollbarSvg=function(a,b,c){this.blockSpace_=a;this.pair_=c||!1;this.horizontal_=b;this.createDom_();b?(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(a){if(!a&&(a=this.blockSpace_.getMetrics(),!a))return;var b=this.blockSpace_.getScrollableSize(a);if(this.horizontal_){var c=a.viewWidth;this.pair_?c-=Blockly.Scrollbar.scrollbarThickness:this.setVisible(c<b.width);this.ratio_=c/b.width;if(-Infinity===this.ratio_||Infinity===this.ratio_||isNaN(this.ratio_))this.ratio_=0;var b=a.viewWidth*this.ratio_,d=a.viewLeft*this.ratio_;this.svgKnob_.setAttribute("width",Math.max(0,b));this.xCoordinate=a.absoluteLeft;
  this.pair_&&Blockly.RTL&&(this.xCoordinate+=a.absoluteLeft+Blockly.Scrollbar.scrollbarThickness);this.yCoordinate=a.absoluteTop+a.viewHeight-Blockly.Scrollbar.scrollbarThickness;this.svgGroup_.setAttribute("transform","translate("+this.xCoordinate+", "+this.yCoordinate+")");this.svgBackground_.setAttribute("width",Math.max(0,c));this.svgKnob_.setAttribute("x",this.constrainKnob_(d))}else{c=a.viewHeight;this.pair_?c-=Blockly.Scrollbar.scrollbarThickness:this.setVisible(c<b.height);this.ratio_=c/b.height;
  if(-Infinity===this.ratio_||Infinity===this.ratio_||isNaN(this.ratio_))this.ratio_=0;b=a.viewHeight*this.ratio_;d=a.viewTop*this.ratio_;this.svgKnob_.setAttribute("height",Math.max(0,b));this.xCoordinate=a.absoluteLeft;Blockly.RTL||(this.xCoordinate+=a.viewWidth-Blockly.Scrollbar.scrollbarThickness);this.yCoordinate=a.absoluteTop;this.svgGroup_.setAttribute("transform","translate("+this.xCoordinate+", "+this.yCoordinate+")");this.svgBackground_.setAttribute("height",Math.max(0,c));this.svgKnob_.setAttribute("y",
  this.constrainKnob_(d))}this.onScroll_()};Blockly.ScrollbarSvg.prototype.createDom_=function(){this.svgGroup_=Blockly.createSvgElement("g",{},null);this.svgBackground_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarBackground"},this.svgGroup_);var a=Math.floor((Blockly.Scrollbar.scrollbarThickness-6)/2);this.svgKnob_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarKnob",rx:a,ry:a},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(a){if(a!=this.isVisible()){if(this.pair_)throw"Unable to toggle visibility of paired scrollbars.";a?this.svgGroup_.setAttribute("display","block"):(this.blockSpace_.setMetrics({x:0,y:0}),this.svgGroup_.setAttribute("display","none"))}};
  Blockly.ScrollbarSvg.prototype.onMouseDownBar_=function(a){this.blockSpace_.blockSpaceEditor.hideChaff(!0);if(!Blockly.isRightButton(a)){var b=Blockly.mouseToSvg(a,this.blockSpace_.blockSpaceEditor.svg_),b=this.horizontal_?b.x:b.y,c=Blockly.getSvgXY_(this.svgKnob_,this.blockSpace_.blockSpaceEditor.svg_),c=this.horizontal_?c.x:c.y,d=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"width":"height")),e=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),f=0.95*d;b<=c?e-=f:b>=c+d&&
  (e+=f);this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(e));this.onScroll_()}a.stopPropagation()};
  Blockly.ScrollbarSvg.prototype.onMouseDownKnob_=function(a){this.blockSpace_.blockSpaceEditor.hideChaff(!0);this.onMouseUpKnob_();Blockly.isRightButton(a)||(this.startDragKnob=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),this.startDragMouse=this.horizontal_?a.clientX:a.clientY,Blockly.ScrollbarSvg.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUpKnob_),Blockly.ScrollbarSvg.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMoveKnob_));
  a.stopPropagation()};Blockly.ScrollbarSvg.prototype.onMouseMoveKnob_=function(a){this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(this.startDragKnob+((this.horizontal_?a.clientX:a.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(a){if(0>=a||isNaN(a))a=0;else{var b=this.horizontal_?"width":"height",c=parseFloat(this.svgBackground_.getAttribute(b)),b=parseFloat(this.svgKnob_.getAttribute(b));a=Math.min(a,c-b)}return a};
  Blockly.ScrollbarSvg.prototype.onScroll_=function(){var a=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),b=parseFloat(this.svgBackground_.getAttribute(this.horizontal_?"width":"height")),a=a/b;isNaN(a)&&(a=0);b={};this.horizontal_?b.x=a:b.y=a;this.blockSpace_.setMetrics(b)};Blockly.ScrollbarSvg.prototype.set=function(a,b){this.svgKnob_.setAttribute(this.horizontal_?"x":"y",a*this.ratio_);if(b)this.onScroll_()};Blockly.Scrollbar=Blockly.ScrollbarSvg;
  Blockly.Scrollbar.scrollbarThickness=15;Blockly.Scrollbar.insertAfter_=function(a,b){var c=b.nextSibling,d=b.parentNode;if(!d)throw"Reference node has no parent.";c?d.insertBefore(a,c):d.appendChild(a)};goog.math={};goog.math.randomInt=function(a){return Math.floor(Math.random()*a)};goog.math.uniformRandom=function(a,b){return a+Math.random()*(b-a)};goog.math.clamp=function(a,b,c){return Math.min(Math.max(a,b),c)};goog.math.modulo=function(a,b){var c=a%b;return 0>c*b?c+b:c};goog.math.lerp=function(a,b,c){return a+c*(b-a)};goog.math.nearlyEquals=function(a,b,c){return Math.abs(a-b)<=(c||1E-6)};goog.math.standardAngle=function(a){return goog.math.modulo(a,360)};
  goog.math.toRadians=function(a){return a*Math.PI/180};goog.math.toDegrees=function(a){return 180*a/Math.PI};goog.math.angleDx=function(a,b){return b*Math.cos(goog.math.toRadians(a))};goog.math.angleDy=function(a,b){return b*Math.sin(goog.math.toRadians(a))};goog.math.angle=function(a,b,c,d){return goog.math.standardAngle(goog.math.toDegrees(Math.atan2(d-b,c-a)))};goog.math.angleDifference=function(a,b){var c=goog.math.standardAngle(b)-goog.math.standardAngle(a);180<c?c-=360:-180>=c&&(c=360+c);return c};
  goog.math.sign=function(a){return 0==a?0:0>a?-1:1};goog.math.longestCommonSubsequence=function(a,b,c,d){c=c||function(a,b){return a==b};d=d||function(b,c){return a[b]};for(var e=a.length,f=b.length,g=[],h=0;h<e+1;h++)g[h]=[],g[h][0]=0;for(var k=0;k<f+1;k++)g[0][k]=0;for(h=1;h<=e;h++)for(k=1;k<=f;k++)c(a[h-1],b[k-1])?g[h][k]=g[h-1][k-1]+1:g[h][k]=Math.max(g[h-1][k],g[h][k-1]);for(var l=[],h=e,k=f;0<h&&0<k;)c(a[h-1],b[k-1])?(l.unshift(d(h-1,k-1)),h--,k--):g[h-1][k]>g[h][k-1]?h--:k--;return l};
  goog.math.sum=function(a){return goog.array.reduce(arguments,function(a,c){return a+c},0)};goog.math.average=function(a){return goog.math.sum.apply(null,arguments)/arguments.length};goog.math.sampleVariance=function(a){var b=arguments.length;if(2>b)return 0;var c=goog.math.average.apply(null,arguments);return goog.math.sum.apply(null,goog.array.map(arguments,function(a){return Math.pow(a-c,2)}))/(b-1)};goog.math.standardDeviation=function(a){return Math.sqrt(goog.math.sampleVariance.apply(null,arguments))};
  goog.math.isInt=function(a){return isFinite(a)&&0==a%1};goog.math.isFiniteNumber=function(a){return isFinite(a)&&!isNaN(a)};goog.math.log10Floor=function(a){if(0<a){var b=Math.round(Math.log(a)*Math.LOG10E);return b-(Math.pow(10,b)>a)}return 0==a?-Infinity:NaN};goog.math.safeFloor=function(a,b){goog.asserts.assert(!goog.isDef(b)||0<b);return Math.floor(a+(b||2E-15))};goog.math.safeCeil=function(a,b){goog.asserts.assert(!goog.isDef(b)||0<b);return Math.ceil(a-(b||2E-15))};goog.math.Coordinate=function(a,b){this.x=goog.isDef(a)?a:0;this.y=goog.isDef(b)?b: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.equals=function(a,b){return a==b?!0:a&&b?a.x==b.x&&a.y==b.y:!1};goog.math.Coordinate.distance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)};
  goog.math.Coordinate.magnitude=function(a){return Math.sqrt(a.x*a.x+a.y*a.y)};goog.math.Coordinate.azimuth=function(a){return goog.math.angle(0,0,a.x,a.y)};goog.math.Coordinate.squaredDistance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d};goog.math.Coordinate.difference=function(a,b){return new goog.math.Coordinate(a.x-b.x,a.y-b.y)};goog.math.Coordinate.sum=function(a,b){return new goog.math.Coordinate(a.x+b.x,a.y+b.y)};
  goog.math.Coordinate.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this};goog.math.Coordinate.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this};goog.math.Coordinate.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this};goog.math.Coordinate.prototype.translate=function(a,b){a instanceof goog.math.Coordinate?(this.x+=a.x,this.y+=a.y):(this.x+=a,goog.isNumber(b)&&(this.y+=b));return this};
  goog.math.Coordinate.prototype.scale=function(a,b){var c=goog.isNumber(b)?b:a;this.x*=a;this.y*=c;return this};goog.math.Coordinate.prototype.rotateRadians=function(a,b){var c=b||new goog.math.Coordinate(0,0),d=this.x,e=this.y,f=Math.cos(a),g=Math.sin(a);this.x=(d-c.x)*f-(e-c.y)*g+c.x;this.y=(d-c.x)*g+(e-c.y)*f+c.y};goog.math.Coordinate.prototype.rotateDegrees=function(a,b){this.rotateRadians(goog.math.toRadians(a),b)};goog.math.Size=function(a,b){this.width=a;this.height=b};goog.math.Size.equals=function(a,b){return a==b?!0:a&&b?a.width==b.width&&a.height==b.height:!1};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(){this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};
  goog.math.Size.prototype.fitsInside=function(a){return this.width<=a.width&&this.height<=a.height};goog.math.Size.prototype.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};goog.math.Size.prototype.round=function(){this.width=Math.round(this.width);this.height=Math.round(this.height);return this};goog.math.Size.prototype.scale=function(a,b){var c=goog.isNumber(b)?b:a;this.width*=a;this.height*=c;return this};
  goog.math.Size.prototype.scaleToFit=function(a){a=this.aspectRatio()>a.aspectRatio()?a.width/this.width:a.height/this.height;return this.scale(a)};goog.math.Box=function(a,b,c,d){this.top=a;this.right=b;this.bottom=c;this.left=d};goog.math.Box.boundingBox=function(a){for(var b=new goog.math.Box(arguments[0].y,arguments[0].x,arguments[0].y,arguments[0].x),c=1;c<arguments.length;c++){var d=arguments[c];b.top=Math.min(b.top,d.y);b.right=Math.max(b.right,d.x);b.bottom=Math.max(b.bottom,d.y);b.left=Math.min(b.left,d.x)}return b};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(a){return goog.math.Box.contains(this,a)};goog.math.Box.prototype.expand=function(a,b,c,d){goog.isObject(a)?(this.top-=a.top,this.right+=a.right,this.bottom+=a.bottom,this.left-=a.left):(this.top-=a,this.right+=b,this.bottom+=c,this.left-=d);return this};
  goog.math.Box.prototype.expandToInclude=function(a){this.left=Math.min(this.left,a.left);this.top=Math.min(this.top,a.top);this.right=Math.max(this.right,a.right);this.bottom=Math.max(this.bottom,a.bottom)};goog.math.Box.equals=function(a,b){return a==b?!0:a&&b?a.top==b.top&&a.right==b.right&&a.bottom==b.bottom&&a.left==b.left:!1};
  goog.math.Box.contains=function(a,b){return a&&b?b instanceof goog.math.Box?b.left>=a.left&&b.right<=a.right&&b.top>=a.top&&b.bottom<=a.bottom:b.x>=a.left&&b.x<=a.right&&b.y>=a.top&&b.y<=a.bottom:!1};goog.math.Box.relativePositionX=function(a,b){return b.x<a.left?b.x-a.left:b.x>a.right?b.x-a.right:0};goog.math.Box.relativePositionY=function(a,b){return b.y<a.top?b.y-a.top:b.y>a.bottom?b.y-a.bottom:0};
  goog.math.Box.distance=function(a,b){var c=goog.math.Box.relativePositionX(a,b),d=goog.math.Box.relativePositionY(a,b);return Math.sqrt(c*c+d*d)};goog.math.Box.intersects=function(a,b){return a.left<=b.right&&b.left<=a.right&&a.top<=b.bottom&&b.top<=a.bottom};goog.math.Box.intersectsWithPadding=function(a,b,c){return a.left<=b.right+c&&b.left<=a.right+c&&a.top<=b.bottom+c&&b.top<=a.bottom+c};
  goog.math.Box.prototype.ceil=function(){this.top=Math.ceil(this.top);this.right=Math.ceil(this.right);this.bottom=Math.ceil(this.bottom);this.left=Math.ceil(this.left);return this};goog.math.Box.prototype.floor=function(){this.top=Math.floor(this.top);this.right=Math.floor(this.right);this.bottom=Math.floor(this.bottom);this.left=Math.floor(this.left);return this};
  goog.math.Box.prototype.round=function(){this.top=Math.round(this.top);this.right=Math.round(this.right);this.bottom=Math.round(this.bottom);this.left=Math.round(this.left);return this};goog.math.Box.prototype.translate=function(a,b){a instanceof goog.math.Coordinate?(this.left+=a.x,this.right+=a.x,this.top+=a.y,this.bottom+=a.y):(this.left+=a,this.right+=a,goog.isNumber(b)&&(this.top+=b,this.bottom+=b));return this};
  goog.math.Box.prototype.scale=function(a,b){var c=goog.isNumber(b)?b:a;this.left*=a;this.right*=a;this.top*=c;this.bottom*=c;return this};goog.math.Rect=function(a,b,c,d){this.left=a;this.top=b;this.width=c;this.height=d};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.createFromBox=function(a){return new goog.math.Rect(a.left,a.top,a.right-a.left,a.bottom-a.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(a,b){return a==b?!0:a&&b?a.left==b.left&&a.width==b.width&&a.top==b.top&&a.height==b.height:!1};
  goog.math.Rect.prototype.intersection=function(a){var b=Math.max(this.left,a.left),c=Math.min(this.left+this.width,a.left+a.width);if(b<=c){var d=Math.max(this.top,a.top);a=Math.min(this.top+this.height,a.top+a.height);if(d<=a)return this.left=b,this.top=d,this.width=c-b,this.height=a-d,!0}return!1};
  goog.math.Rect.intersection=function(a,b){var c=Math.max(a.left,b.left),d=Math.min(a.left+a.width,b.left+b.width);if(c<=d){var e=Math.max(a.top,b.top),f=Math.min(a.top+a.height,b.top+b.height);if(e<=f)return new goog.math.Rect(c,e,d-c,f-e)}return null};goog.math.Rect.intersects=function(a,b){return a.left<=b.left+b.width&&b.left<=a.left+a.width&&a.top<=b.top+b.height&&b.top<=a.top+a.height};goog.math.Rect.prototype.intersects=function(a){return goog.math.Rect.intersects(this,a)};
  goog.math.Rect.difference=function(a,b){var c=goog.math.Rect.intersection(a,b);if(!c||!c.height||!c.width)return[a.clone()];var c=[],d=a.top,e=a.height,f=a.left+a.width,g=a.top+a.height,h=b.left+b.width,k=b.top+b.height;b.top>a.top&&(c.push(new goog.math.Rect(a.left,a.top,a.width,b.top-a.top)),d=b.top,e-=b.top-a.top);k<g&&(c.push(new goog.math.Rect(a.left,k,a.width,g-k)),e=k-d);b.left>a.left&&c.push(new goog.math.Rect(a.left,d,b.left-a.left,e));h<f&&c.push(new goog.math.Rect(h,d,f-h,e));return c};
  goog.math.Rect.prototype.difference=function(a){return goog.math.Rect.difference(this,a)};goog.math.Rect.prototype.boundingRect=function(a){var b=Math.max(this.left+this.width,a.left+a.width),c=Math.max(this.top+this.height,a.top+a.height);this.left=Math.min(this.left,a.left);this.top=Math.min(this.top,a.top);this.width=b-this.left;this.height=c-this.top};goog.math.Rect.boundingRect=function(a,b){if(!a||!b)return null;var c=a.clone();c.boundingRect(b);return c};
  goog.math.Rect.prototype.contains=function(a){return a instanceof goog.math.Rect?this.left<=a.left&&this.left+this.width>=a.left+a.width&&this.top<=a.top&&this.top+this.height>=a.top+a.height:a.x>=this.left&&a.x<=this.left+this.width&&a.y>=this.top&&a.y<=this.top+this.height};goog.math.Rect.prototype.squaredDistance=function(a){var b=a.x<this.left?this.left-a.x:Math.max(a.x-(this.left+this.width),0);a=a.y<this.top?this.top-a.y:Math.max(a.y-(this.top+this.height),0);return b*b+a*a};
  goog.math.Rect.prototype.distance=function(a){return Math.sqrt(this.squaredDistance(a))};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(){this.left=Math.ceil(this.left);this.top=Math.ceil(this.top);this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};goog.math.Rect.prototype.floor=function(){this.left=Math.floor(this.left);this.top=Math.floor(this.top);this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};
  goog.math.Rect.prototype.round=function(){this.left=Math.round(this.left);this.top=Math.round(this.top);this.width=Math.round(this.width);this.height=Math.round(this.height);return this};goog.math.Rect.prototype.translate=function(a,b){a instanceof goog.math.Coordinate?(this.left+=a.x,this.top+=a.y):(this.left+=a,goog.isNumber(b)&&(this.top+=b));return this};goog.math.Rect.prototype.scale=function(a,b){var c=goog.isNumber(b)?b:a;this.left*=a;this.width*=a;this.top*=c;this.height*=c;return this};Blockly.Trashcan=function(a){this.blockSpace_=a};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(){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_));return this.svgGroup_};Blockly.Trashcan.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.blockSpace_=this.svgOpenCan_=this.svgClosedCan_=null};Blockly.Trashcan.prototype.getHeight=function(){return Blockly.Trashcan.HEIGHT_};
  Blockly.Trashcan.prototype.setOpen_=function(a){this.isOpen!=a&&(this.isOpen=a,this.animateLid_())};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(a){this.blockSpace_=a;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(a,b){this.unbindBeginPanDragHandler();this.target_=a;this.onTargetMouseDown_=b;this.mouseDownEventBindData_=Blockly.bindEvent_(a,"mousedown",this,this.onPanDragTargetMouseDown_);this.contextMenuBlockEventBindData_=Blockly.bindEvent_(a,"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(a){if(this.onTargetMouseDown_)this.onTargetMouseDown_();var b=a.target&&a.target===this.target_;Blockly.selected&&!this.blockSpace_.isReadOnly()&&b&&Blockly.selected.unselect();var c=Blockly.selected&&!Blockly.selected.isMovable()&&!Blockly.selected.isEditable(),b=b||c||this.blockSpace_.isReadOnly(),c=!Blockly.isRightButton(a);this.blockSpace_.scrollbarPair&&c&&b&&(this.beginDragScroll_(a),a.stopPropagation(),a.preventDefault())};
  Blockly.PanDragHandler.prototype.beginDragScroll_=function(a){this.startMouseX_=a.clientX;this.startMouseY_=a.clientY;this.startScrollX_=this.blockSpace_.getScrollOffsetX();this.startScrollY_=this.blockSpace_.getScrollOffsetY();this.bindDuringPanDragHandlers_()};
  Blockly.PanDragHandler.prototype.onPanDragMouseMove_=function(a){Blockly.removeAllRanges();this.blockSpace_.scrollTo(this.startScrollX_+-(a.clientX-this.startMouseX_),this.startScrollY_+-(a.clientY-this.startMouseY_));a.stopPropagation();a.preventDefault()};Blockly.PanDragHandler.prototype.onPanDragMouseUp_=function(a){this.unbindDuringPanDragHandlers_();a.stopPropagation();a.preventDefault()};goog.math.Vec2=function(a,b){this.x=a;this.y=b};goog.inherits(goog.math.Vec2,goog.math.Coordinate);goog.math.Vec2.randomUnit=function(){var a=2*Math.random()*Math.PI;return new goog.math.Vec2(Math.cos(a),Math.sin(a))};goog.math.Vec2.random=function(){var a=Math.sqrt(Math.random()),b=2*Math.random()*Math.PI;return new goog.math.Vec2(Math.cos(b)*a,Math.sin(b)*a)};goog.math.Vec2.fromCoordinate=function(a){return new goog.math.Vec2(a.x,a.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(){this.x=-this.x;this.y=-this.y;return this};goog.math.Vec2.prototype.normalize=function(){return this.scale(1/this.magnitude())};
  goog.math.Vec2.prototype.add=function(a){this.x+=a.x;this.y+=a.y;return this};goog.math.Vec2.prototype.subtract=function(a){this.x-=a.x;this.y-=a.y;return this};goog.math.Vec2.prototype.rotate=function(a){var b=Math.cos(a);a=Math.sin(a);var c=this.y*b+this.x*a;this.x=this.x*b-this.y*a;this.y=c;return this};goog.math.Vec2.rotateAroundPoint=function(a,b,c){return a.clone().subtract(b).rotate(c).add(b)};goog.math.Vec2.prototype.equals=function(a){return this==a||!!a&&this.x==a.x&&this.y==a.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(a,b){return new goog.math.Vec2(a.x+b.x,a.y+b.y)};goog.math.Vec2.difference=function(a,b){return new goog.math.Vec2(a.x-b.x,a.y-b.y)};goog.math.Vec2.dot=function(a,b){return a.x*b.x+a.y*b.y};
  goog.math.Vec2.lerp=function(a,b,c){return new goog.math.Vec2(goog.math.lerp(a.x,b.x,c),goog.math.lerp(a.y,b.y,c))};goog.functions={};goog.functions.constant=function(a){return function(){return a}};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(a,b){return a};goog.functions.error=function(a){return function(){throw Error(a);}};goog.functions.fail=function(a){return function(){throw a;}};
  goog.functions.lock=function(a,b){b=b||0;return function(){return a.apply(this,Array.prototype.slice.call(arguments,0,b))}};goog.functions.nth=function(a){return function(){return arguments[a]}};goog.functions.withReturnValue=function(a,b){return goog.functions.sequence(a,goog.functions.constant(b))};goog.functions.compose=function(a,b){var c=arguments,d=c.length;return function(){var a;d&&(a=c[d-1].apply(this,arguments));for(var b=d-2;0<=b;b--)a=c[b].call(this,a);return a}};
  goog.functions.sequence=function(a){var b=arguments,c=b.length;return function(){for(var a,e=0;e<c;e++)a=b[e].apply(this,arguments);return a}};goog.functions.and=function(a){var b=arguments,c=b.length;return function(){for(var a=0;a<c;a++)if(!b[a].apply(this,arguments))return!1;return!0}};goog.functions.or=function(a){var b=arguments,c=b.length;return function(){for(var a=0;a<c;a++)if(b[a].apply(this,arguments))return!0;return!1}};
  goog.functions.not=function(a){return function(){return!a.apply(this,arguments)}};goog.functions.create=function(a,b){var c=function(){};c.prototype=a.prototype;c=new c;a.apply(c,Array.prototype.slice.call(arguments,1));return c};goog.functions.CACHE_RETURN_VALUE=!0;goog.functions.cacheReturnValue=function(a){var b=!1,c;return function(){if(!goog.functions.CACHE_RETURN_VALUE)return a();b||(c=a(),b=!0);return c}};goog.async={};goog.async.AnimationDelay=function(a,b,c){goog.async.AnimationDelay.base(this,"constructor");this.listener_=a;this.handler_=c;this.win_=b||window;this.callback_=goog.bind(this.doAction_,this)};goog.inherits(goog.async.AnimationDelay,goog.Disposable);goog.async.AnimationDelay.prototype.id_=null;goog.async.AnimationDelay.prototype.usingListeners_=!1;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 a=this.getRaf_(),b=this.getCancelRaf_();a&&!b&&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_=a&&b?a.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 a=this.getRaf_(),b=this.getCancelRaf_();a&&!b&&this.win_.mozRequestAnimationFrame?goog.events.unlistenByKey(this.id_):a&&b?b.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.base(this,"disposeInternal")};
  goog.async.AnimationDelay.prototype.getRaf_=function(){var a=this.win_;return a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||null};goog.async.AnimationDelay.prototype.getCancelRaf_=function(){var a=this.win_;return a.cancelRequestAnimationFrame||a.webkitCancelRequestAnimationFrame||a.mozCancelRequestAnimationFrame||a.oCancelRequestAnimationFrame||a.msCancelRequestAnimationFrame||null};Blockly.AutoScroll=function(a,b){this.blockSpace_=a;this.activePanVector_=b;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(a){var b=a-this.lastTime_;this.lastTime_=a;this.scrollTick_(b);this.animationDelay_.start()};Blockly.AutoScroll.prototype.scrollTick_=function(a){this.blockSpace_.scrollDeltaWithAnySelectedBlock(this.activePanVector_.x*a,this.activePanVector_.y*a,this.lastMouseX_,this.lastMouseY_)};Blockly.AutoScroll.prototype.updateProperties=function(a,b,c){this.activePanVector_=a;this.lastMouseX_=b;this.lastMouseY_=c};Blockly.ScrollOnBlockDragHandler=function(a){this.blockSpace_=a;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 MS_PER_SEC=1E3,MOUSE_SPEED_SLOW=0.5,MOUSE_SPEED_FAST=1.6,BLOCK_SPEED_SLOW=0.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=0.85,FALLBACK_DRAG_MARGIN=15;Blockly.ScrollOnBlockDragHandler.DEBUG=!1;
  Blockly.ScrollOnBlockDragHandler.prototype.panIfOverEdge=function(a,b,c){if(this.blockSpace_.currentlyScrollable()){var d=[];this.blockSpace_.scrollbarPair&&this.blockSpace_.scrollbarPair.canScrollHorizontally()&&d.push("left","right");this.blockSpace_.scrollbarPair&&this.blockSpace_.scrollbarPair.canScrollVertically()&&d.push("top","bottom");if(0!==d.length){var e=Blockly.mouseCoordinatesToSvg(b,c,this.blockSpace_.blockSpaceEditor.svg_),e=Blockly.svgCoordinatesToViewport(new goog.math.Coordinate(e.x,
  e.y),this.blockSpace_),e=Blockly.viewportCoordinateToBlockSpace(e,this.blockSpace_),f=this.blockSpace_.getViewportBox(),g=a.getBox(),h=Blockly.getBoxHeight(g),k=Blockly.getBoxHeight(f);h>k*OVERSIZE_BLOCK_THRESHOLD&&(g.top=Math.max(g.top,e.y-FALLBACK_DRAG_MARGIN),g.bottom=Math.min(g.bottom,e.y+FALLBACK_DRAG_MARGIN));h=Blockly.getBoxWidth(g);k=Blockly.getBoxWidth(f);h>k*OVERSIZE_BLOCK_THRESHOLD&&(g.left=Math.max(g.left,e.x-FALLBACK_DRAG_MARGIN),g.right=Math.min(g.right,e.x+FALLBACK_DRAG_MARGIN));var l=
  Blockly.getBoxOverflow(f,g),m=Blockly.getPointBoxOverflow(f,new goog.math.Coordinate(e.x,e.y));Blockly.ScrollOnBlockDragHandler.DEBUG&&(this.blockSpace_.drawDebugCircle("mouse circle",new goog.math.Coordinate(e.x,e.y),"orange"),this.blockSpace_.drawDebugBox("block box"+a.id,g,"purple"),this.blockSpace_.drawDebugBox("block space box",f,"blue"));var n=new goog.math.Vec2(0,0);d.forEach(function(a){var b=m[a],c=l[a];a=this.SCROLL_DIRECTION_VECTORS[a];var d=[];Blockly.numberWithin(c,BLOCK_START_DISTANCE,
  BLOCK_START_FAST_DISTANCE,!1)&&d.push(a.clone().scale(BLOCK_SPEED_SLOW));c>BLOCK_START_FAST_DISTANCE&&d.push(a.clone().scale(BLOCK_SPEED_FAST));Blockly.numberWithin(b,MOUSE_START_DISTANCE,MOUSE_START_FAST_DISTANCE,!1)&&d.push(a.clone().scale(MOUSE_SPEED_SLOW));b>MOUSE_START_FAST_DISTANCE&&d.push(a.clone().scale(MOUSE_SPEED_FAST));(b=d.reduce(function(a,b){return a?a.magnitude()>b.magnitude()?a:b:b},null))&&(n=goog.math.Vec2.sum(n,b))},this);n.equals(new goog.math.Vec2(0,0))?this.stopAutoScrolling():
  (this.activeAutoScroll_=this.activeAutoScroll_||new Blockly.AutoScroll(this.blockSpace_,n),this.activeAutoScroll_.updateProperties(n,b,c))}}};Blockly.Xml={};Blockly.Xml.blockSpaceToDom=function(a){var b=Blockly.isMsie()?document.createElementNS(null,"xml"):document.createElement("xml");a=a.getTopBlocks(!0);for(var c=0,d;c<a.length;c++)d=a[c],d=Blockly.Xml.blockToDom(d),b.appendChild(d);return b};
  Blockly.Xml.blockToDom=function(a,b){var c=goog.dom.createDom("block"),d,e,f,g,h;c.setAttribute("type",a.type);a.mutationToDom&&(g=a.mutationToDom())&&c.appendChild(g);for(e=0;e<a.inputList.length;e++)for(g=a.inputList[e],f=0;f<g.titleRow.length;f++)if(h=g.titleRow[f],h.name&&h.EDITABLE){var k=goog.dom.createDom("title",null,h.getValue());k.setAttribute("name",h.name);h.config&&k.setAttribute("config",h.config);c.appendChild(k)}a.comment&&(g=goog.dom.createDom("comment",null,a.comment.getText()),
  g.setAttribute("pinned",a.comment.isVisible()),e=a.comment.getBubbleSize(),g.setAttribute("h",e.height),g.setAttribute("w",e.width),c.appendChild(g));f=!1;for(e=0;e<a.inputList.length;e++)if(g=a.inputList[e],h=!0,g.type!=Blockly.DUMMY_INPUT){var k=!1,l=g.connection.targetBlock();g.type===Blockly.INPUT_VALUE?(d=goog.dom.createDom("value"),f=!0):g.type===Blockly.NEXT_STATEMENT?(d=goog.dom.createDom("statement"),k=b):g.type===Blockly.FUNCTIONAL_INPUT&&(d=goog.dom.createDom("functional_input"),k=b,f=
  !0);l&&!k&&(d.appendChild(Blockly.Xml.blockToDom(l)),h=!1);d.setAttribute("name",g.name);h||c.appendChild(d)}f&&c.setAttribute("inline",a.inputsInline);a.isCollapsed()&&c.setAttribute("collapsed",!0);a.disabled&&c.setAttribute("disabled",!0);a.isDeletable()||c.setAttribute("deletable",!1);a.isMovable()||c.setAttribute("movable",!1);a.isEditable()||c.setAttribute("editable",!1);a.isUserVisible()||c.setAttribute("uservisible",!1);/^procedures_def/.test(a.type)&&a.userCreated&&c.setAttribute("usercreated",
  !0);a.htmlId&&c.setAttribute("id",a.htmlId);a.nextConnection&&!b&&(d=a.nextConnection.targetBlock())&&(d=goog.dom.createDom("next",null,Blockly.Xml.blockToDom(d)),c.appendChild(d));return c};Blockly.Xml.domToText=function(a){return(new XMLSerializer).serializeToString(a).replace(RegExp(' xmlns="http://www.w3.org/1999/xhtml"',"g"),"")};
  Blockly.Xml.domToPrettyText=function(a){a=Blockly.Xml.domToText(a).split("<");for(var b="",c=1;c<a.length;c++){var d=a[c];"/"==d[0]&&(b=b.substring(2));a[c]=b+"<"+d;"/"!=d[0]&&"/>"!=d.slice(-2)&&(b+="  ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};
  Blockly.Xml.textToDom=function(a){a=(new DOMParser).parseFromString(a,"text/xml");if(!a||!a.firstChild||"xml"!=a.firstChild.nodeName.toLowerCase())throw"Blockly.Xml.textToDom did not obtain a valid XML tree.";return a.firstChild};
  Blockly.Xml.domToBlockSpace=function(a,b){for(var c=a.getMetrics(),d=c?c.viewWidth:0,e=Blockly.RTL?d-Blockly.BlockSpace.AUTO_LAYOUT_PADDING_LEFT:Blockly.BlockSpace.AUTO_LAYOUT_PADDING_LEFT,f=Blockly.BlockSpace.AUTO_LAYOUT_PADDING_TOP,c=function(a){var b=a.blockly_block.getSvgPadding()||{top:0,right:0,bottom:0,left:0},c=a.blockly_block.getHeightWidth();isNaN(a.x)?(a.x=e,a.x+=Blockly.RTL?-b.right:b.left):a.x=Blockly.RTL?d-a.x:a.x;isNaN(a.y)&&(a.y=f+b.top,f+=c.height+Blockly.BlockSvg.SEP_SPACE_Y+b.bottom+
  b.top);a.blockly_block.moveTo(a.x,a.y)},g=[],h=0,k;k=b.childNodes[h];h++)if("block"===k.nodeName.toLowerCase()){var l=Blockly.Xml.domToBlock(a,k),m=parseInt(k.getAttribute("x"),10);k=parseInt(k.getAttribute("y"),10);g.push({blockly_block:l,x:m,y:k})}g.filter(function(a){return a.blockly_block.isVisible()}).forEach(c);g.filter(function(a){return!a.blockly_block.isVisible()}).forEach(c);a.events.dispatchEvent(Blockly.BlockSpace.EVENTS.EVENT_BLOCKS_IMPORTED)};
  Blockly.Xml.domToBlock=function(a,b){var c=b.getAttribute("type"),d=b.getAttribute("id"),c=new Blockly.Block(a,c,d);c.initSvg();(d=b.getAttribute("inline"))&&c.setInputsInline("true"===d);(d=b.getAttribute("collapsed"))&&c.setCollapsed("true"===d);(d=b.getAttribute("disabled"))&&c.setDisabled("true"===d);(d=b.getAttribute("deletable"))&&c.setDeletable("true"===d);(d=b.getAttribute("movable"))&&c.setMovable("true"===d);(d=b.getAttribute("editable"))&&c.setEditable("true"===d);(d=b.getAttribute("next_connection_disabled"))&&
  c.setNextConnectionDisabled("true"===d);(d=b.getAttribute("uservisible"))&&c.setUserVisible("true"===d);if(d=b.getAttribute("usercreated"))c.userCreated="true"===d;for(var e=null,d=0,f;d<b.childNodes.length;d++)if(f=b.childNodes[d],3!=f.nodeType||!f.data.match(/^\s*$/)){for(var e=null,g=0,h;g<f.childNodes.length;g++)h=f.childNodes[g],3==h.nodeType&&h.data.match(/^\s*$/)||(e=h);g=f.getAttribute("name");switch(f.nodeName.toLowerCase()){case "mutation":c.domToMutation&&c.domToMutation(f);break;case "comment":c.setCommentText(f.textContent);
  (e=f.getAttribute("pinned"))&&c.comment.setVisible("true"==e);e=parseInt(f.getAttribute("w"),10);f=parseInt(f.getAttribute("h"),10);isNaN(e)||isNaN(f)||c.comment.setBubbleSize(e,f);break;case "title":(e=f.getAttribute("config"))&&c.setFieldConfig(g,e);c.setTitleValue(f.textContent,g);break;case "value":case "statement":case "functional_input":f=c.getInput(g);if(!f)throw"Input does not exist: "+g;if(e&&"block"==e.nodeName.toLowerCase())if(e=Blockly.Xml.domToBlock(a,e),e.outputConnection)f.connection.connect(e.outputConnection);
  else if(e.previousConnection)f.connection.connect(e.previousConnection);else throw"Child block does not have output or previous statement.";break;case "next":if(e&&"block"==e.nodeName.toLowerCase()){if(!c.nextConnection)throw"Next statement does not exist.";if(c.nextConnection.targetConnection)throw"Next statement is already connected.";e=Blockly.Xml.domToBlock(a,e);if(!e.previousConnection)throw"Next block does not have previous statement.";c.nextConnection.connect(e.previousConnection)}}}(d=c.nextConnection&&
  c.nextConnection.targetBlock())?d.render():c.render();return c};Blockly.Xml.deleteNext=function(a){for(var b=0,c;b<a.childNodes.length;b++)if(c=a.childNodes[b],"next"==c.nodeName.toLowerCase()){a.removeChild(c);break}};Blockly.ScrollOnWheelHandler=function(a){this.blockSpace_=a;this.mousewheelEventBindData_=this.wheelEventBindData_=null};Blockly.ScrollOnWheelHandler.prototype.bindTo=function(a){this.unbindWheelScrollHandler();this.wheelEventBindData_=Blockly.bindEvent_(a,"wheel",this,this.onWheel_);this.mousewheelEventBindData_=Blockly.bindEvent_(a,"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(a){if(this.blockSpace_.scrollbarPair){var b=Blockly.getNormalizedWheelDeltaY(a);b&&(this.blockSpace_.scrollWithAnySelectedBlock(this.blockSpace_.getScrollOffsetX(),this.blockSpace_.getScrollOffsetY()+b,a.clientX,a.clientY),a.stopPropagation(),a.preventDefault())}};Blockly.BlockSpace=function(a,b,c){this.blockSpaceEditor=a;this.getMetrics=b;this.setMetrics=function(a){c(a);Blockly.fireUiEvent(window,"block_space_metrics_set")};this.isFlyout=!1;this.topBlocks_=[];this.deleteAreas_=[];this.pickedUpBlockOrigin_=null;this.maxBlocks=Infinity;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.EVENT_BLOCKS_IMPORTED="blocksImported";Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE="blockSpaceChange";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(a,b){var c=(new Blockly.BlockSpaceEditor(a,function(){var a=Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_.call(this);if(!a)return null;a.viewHeight+=Blockly.BlockSpace.SCROLLABLE_MARGIN_BELOW_BOTTOM;return a},function(a){Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_.call(this,a)},!0,!0)).blockSpace;Blockly.Xml.domToBlockSpace(c,b);return c};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.debugLogOnEvents=function(){goog.object.forEach(Blockly.BlockSpace.EVENTS,function(a,b){this.events.listen(a,function(c){console.log(c);console.log(b);console.log(a)},!1,this)},this)};Blockly.BlockSpace.prototype.findFunction=function(a){return goog.array.find(this.getTopBlocks(),function(b){return goog.array.contains(Blockly.Procedures.DEFINITION_BLOCK_TYPES,b.type)&&Blockly.Names.equals(a,b.getTitleValue("NAME"))})};
  Blockly.BlockSpace.prototype.findFunctionExamples=function(a){return goog.array.filter(this.getTopBlocks(),function(b){return Blockly.ContractEditor.EXAMPLE_BLOCK_TYPE===b.type?(b=b.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME))&&(!a||Blockly.Names.equals(a,b.getTitleValue("NAME"))):!1})};
  Blockly.BlockSpace.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"svgGroup"},null);this.clippingGroup_=Blockly.createSvgElement("g",{"class":"svgClippingGroup"},this.svgGroup_);this.svgBlockCanvas_=Blockly.createSvgElement("g",{"class":"svgBlockCanvas"},this.clippingGroup_);this.svgDragCanvas_=Blockly.createSvgElement("g",{"class":"svgDragCanvas"},this.svgGroup_);this.svgBubbleCanvas_=Blockly.createSvgElement("g",{"class":"svgBubbleCanvas"},this.svgGroup_);this.svgDebugCanvas_=
  Blockly.createSvgElement("g",{"class":"svgDebugCanvas"},this.svgGroup_);this.fireChangeEvent();return this.svgGroup_};Blockly.BlockSpace.prototype.moveElementToDragCanvas=function(a){this.getDragCanvas().appendChild(a)};Blockly.BlockSpace.prototype.moveElementToMainCanvas=function(a){this.getCanvas().appendChild(a)};
  Blockly.BlockSpace.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);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 a=this.trashcan.createDom();this.svgBlockCanvas_.appendChild(a);this.trashcan.init()}};Blockly.BlockSpace.prototype.setTrashcan=function(a){this.trashcan=a};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(a){this.topBlocks_.push(a);this.fireChangeEvent()};
  Blockly.BlockSpace.prototype.removeTopBlock=function(a){for(var b=!1,c,d=0;d<this.topBlocks_.length;d++)if(c=this.topBlocks_[d],c==a){this.topBlocks_.splice(d,1);b=!0;break}if(!b)throw"Block not present this blockSpace's list of top-most blocks.";this.fireChangeEvent()};
  Blockly.BlockSpace.prototype.getTopBlocks=function(a,b){void 0===a&&(a=!1);void 0===b&&(b=!0);var c=[],c=!b||this!==Blockly.mainBlockSpace&&this!==Blockly.modalBlockSpace?c.concat(this.topBlocks_):c.concat(Blockly.mainBlockSpace.topBlocks_).concat(Blockly.modalBlockSpace?Blockly.modalBlockSpace.topBlocks_:[]);if(a&&1<c.length){var d=Math.sin(Blockly.BlockSpace.SCAN_ANGLE/180*Math.PI);Blockly.RTL&&(d*=-1);c.sort(function(a,b){var c=a.getRelativeToSurfaceXY(),h=b.getRelativeToSurfaceXY();return c.y+
  d*c.x-(h.y+d*h.x)})}return c};Blockly.BlockSpace.prototype.getAllVisibleBlocks=function(){return goog.array.filter(this.getAllBlocks(),function(a){return a.isUserVisible()})};Blockly.BlockSpace.prototype.getAllBlocks=function(a){a=a||{};a=this.getTopBlocks(!1,a.shareMainModal);for(var b=0;b<a.length;b++)a=a.concat(a[b].getChildren());return a};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 a=this.getAllBlocks(),b=0,c;b<a.length;b++)c=a[b],c.getChildren().length||c.render()};Blockly.BlockSpace.prototype.getBlockById=function(a){for(var b=this.getAllBlocks(),c=0,d;c<b.length;c++)if(d=b[c],d.id==a)return d;return null};
  Blockly.BlockSpace.prototype.traceOn=function(a){this.traceOn_=a;this.traceWrapper_&&(Blockly.unbindEvent_(this.traceWrapper_),this.traceWrapper_=null);a&&(this.traceWrapper_=Blockly.bindEvent_(this.svgBlockCanvas_,"blocklySelectChange",this,function(){this.traceOn_=!1}))};
  Blockly.BlockSpace.prototype.highlightBlock=function(a,b){if(this.traceOn_&&!Blockly.Block.isDragging()){var c=null;if(a&&(c=this.getBlockById(a),!c))return;this.traceOn(!1);c?c.select(b):Blockly.selected&&Blockly.selected.unselect();this.traceOn(!0)}};
  Blockly.BlockSpace.prototype.fireChangeEvent=function(){this.fireChangeEventPid_&&window.clearTimeout(this.fireChangeEventPid_);var a=this.svgBlockCanvas_;if(a){var b=this;this.fireChangeEventPid_=window.setTimeout(function(){b.events.dispatchEvent(Blockly.BlockSpace.EVENTS.BLOCK_SPACE_CHANGE);Blockly.fireUiEvent(a,"blocklyBlockSpaceChange")},0)}fireGlobalChangeEventPid_&&window.clearTimeout(fireGlobalChangeEventPid_);fireGlobalChangeEventPid_=window.setTimeout(function(){Blockly.fireUiEvent(window,
  "workspaceChange")},0)};
  Blockly.BlockSpace.prototype.paste=function(a){var b=a.dom;if(this!==a.sourceBlockSpace){if("parameters_get"===b.getAttribute("type"))return;goog.array.forEach(b.getElementsByTagName("block"),function(a){"parameters_get"===a.getAttribute("type")&&goog.dom.removeNode(a)})}if(!(b.getElementsByTagName("block").length>=this.remainingCapacity())){a=Blockly.Xml.domToBlock(this,b);var c=parseInt(b.getAttribute("x"),10),b=parseInt(b.getAttribute("y"),10);if(!isNaN(c)&&!isNaN(b)){Blockly.RTL&&(c=-c);var d;
  do{d=!1;for(var e=this.getAllBlocks(),f=0,g;f<e.length;f++)g=e[f],g=g.getRelativeToSurfaceXY(),1>=Math.abs(c-g.x)&&1>=Math.abs(b-g.y)&&(c=Blockly.RTL?c-Blockly.SNAP_RADIUS:c+Blockly.SNAP_RADIUS,b+=2*Blockly.SNAP_RADIUS,d=!0)}while(d);a.moveBy(c,b)}a.setUserVisible(!0);a.select()}};Blockly.BlockSpace.prototype.remainingCapacity=function(){return Infinity==this.maxBlocks?Infinity:this.maxBlocks-this.getAllBlocks().length};
  Blockly.BlockSpace.prototype.recordPickedUpBlockOrigin=function(){var a=this.blockSpaceEditor.getCanvasBBox(this.getDragCanvas());this.pickedUpBlockOrigin_=Blockly.svgRectToRect(a)};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(a,b,c){if(!Blockly.languageTree)return!1;a=Blockly.mouseCoordinatesToSvg(a,b,this.blockSpaceEditor.svg_);a=new goog.math.Coordinate(a.x,a.y);c=Blockly.mouseCoordinatesToSvg(c,0,this.blockSpaceEditor.svg_);c=new goog.math.Coordinate(c.x,c.x);this.deleteAreaTrash_&&(this.deleteAreaTrash_.contains(a)?this.trashcan.setOpen_(!0):this.trashcan.setOpen_(!1));this.drawTrashZone(a.x,c.x);for(c=0;c<this.deleteAreas_.length;c++)if(b=this.deleteAreas_[c],b.contains(a))return!0;
  this.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED);return!1};Blockly.BlockSpace.prototype.hideDelete=function(){this.drawTrashZone(Blockly.RTL?-1E4:1E4,0)};
  Blockly.BlockSpace.prototype.drawTrashZone=function(a,b){var c,d,e,f,g=null,h=this.blockSpaceEditor.hideTrashRect_?Blockly.mainBlockSpaceEditor:this.blockSpaceEditor;this.blockSpaceEditor.toolbox?(f=h.toolbox,c=h.svgBackground_,d=f.tree_.element_,e=f.trashcan,f=f.trashcanHolder,this.blockSpaceEditor.hideTrashRect_&&(g=this.blockSpaceEditor.toolbox.tree_.element_)):(e=h.flyout_,c=e.svgBackground_,d=e.blockSpace_.svgGroup_,e=e.trashcan,f=e.svgGroup_,this.blockSpaceEditor.hideTrashRect_&&(g=this.blockSpaceEditor.flyout_.svgGroup_));
  var k=c.getBoundingClientRect().width,l=!1,m;Blockly.RTL?(l=a>b+10,k=h.svg_.getBoundingClientRect().width-k,h=k-a,m=k-b-10):(l=a<b-10,h=a-k,m=b-k-10);var k=1,n=1-0.8;l&&(0>=h?(k=0,e.setOpen_(!0)):(e.setOpen_(!1),k=h>=m?1:100>m?h/m:100>h?0.8*(h/100):0.8+(h-100)/(m-100)*n));e=1-k;c.style.fill="rgb("+Math.floor(170*e+221*k)+", "+Math.floor(170*e+221*k)+", "+Math.floor(170*e+221*k)+")";d.style.opacity=k;g&&(g.style.opacity=k);f.style.opacity=e;f.style.display=0===e?"none":"block"};
  Blockly.BlockSpace.prototype.getScrollableSize=function(a){var b=this.scrollbarPair,c=b&&b.canScrollHorizontally(),b=b&&b.canScrollVertically(),d=this.isFlyout?0:Blockly.BlockSpace.SCROLLABLE_MARGIN_BELOW_BOTTOM;return{width:c?Math.max(a.contentLeft+a.contentWidth,a.viewWidth):a.viewWidth,height:b?Math.max(a.contentTop+a.contentHeight+d,a.viewHeight):a.viewHeight}};
  Blockly.BlockSpace.prototype.getScrollableBox=function(){var a=this.getScrollableSize(this.getMetrics());return new goog.math.Box(0,a.width,a.height,0)};Blockly.BlockSpace.prototype.getViewportBox=function(){var a=this.getMetrics();return new goog.math.Box(this.getScrollOffsetY(),this.getScrollOffsetX()+a.viewWidth,this.getScrollOffsetY()+a.viewHeight,this.getScrollOffsetX())};Blockly.BlockSpace.prototype.panIfOverEdge=function(a,b,c){this.scrollOnBlockDragHandler_.panIfOverEdge(a,b,c)};
  Blockly.BlockSpace.prototype.stopAutoScrolling=function(){this.scrollOnBlockDragHandler_.stopAutoScrolling()};Blockly.BlockSpace.prototype.scrollIntoView=function(a){var b=a.getBox(),c=this.getViewportBox();a=Blockly.getBoxOverflow(c,b);Blockly.addToNonZeroSides(a,Blockly.BlockSpace.DROPPED_BLOCK_PAN_MARGIN);var d=Blockly.isBoxWiderThan(b,c),e=Blockly.isBoxTallerThan(b,c),b=d||e?goog.math.Box.intersects(b,c):!1;this.scrollToDelta(d&&b?0:a.right-a.left,e&&b?0:a.bottom-a.top)};
  Blockly.BlockSpace.prototype.scrollDeltaWithAnySelectedBlock=function(a,b,c,d){this.scrollWithAnySelectedBlock(this.getScrollOffsetX()+a,this.getScrollOffsetY()+b,c,d)};Blockly.BlockSpace.prototype.scrollWithAnySelectedBlock=function(a,b,c,d){var e=this.getScrollOffset();this.scrollTo(a,b);Blockly.Block.isFreelyDragging()&&Blockly.selected&&(a=this.getScrollOffset().subtract(e),Blockly.selected.startDragMouseX-=a.x,Blockly.selected.startDragMouseY-=a.y,Blockly.selected.moveBlockBeingDragged_(c,d))};
  Blockly.BlockSpace.prototype.scrollToDelta=function(a,b){this.scrollTo(this.getScrollOffsetX()+a,this.getScrollOffsetY()+b)};Blockly.BlockSpace.prototype.scrollTo=function(a,b){if(this.scrollbarPair){var c=this.getMaxScrollOffsets();a=goog.math.clamp(a,0,c.x);b=goog.math.clamp(b,0,c.y);this.scrollbarPair.set(a,b)}};Blockly.BlockSpace.prototype.currentlyScrollable=function(){var a=this.getMaxScrollOffsets();return 0<a.x||0<a.y};
  Blockly.BlockSpace.prototype.getMaxScrollOffsets=function(){var a=this.getMetrics(),b=this.getScrollableSize(a);return{x:b.width-a.viewWidth,y:b.height-a.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(a,b){this.panDragHandler_.bindBeginPanDragHandler(a,b)};Blockly.BlockSpace.prototype.bindScrollOnWheelHandler=function(a){this.scrollOnWheelHandler_.bindTo(a)};Blockly.BlockSpace.prototype.unbindBeginPanDragHandler=function(){this.panDragHandler_.unbindBeginPanDragHandler()};Blockly.BlockSpace.prototype.debugRects_={};
  Blockly.BlockSpace.prototype.drawDebugBox=function(a,b,c){b=goog.math.Rect.createFromBox(b);this.debugRects_[a]||(this.debugRects_[a]=Blockly.createSvgElement("rect",{fill:"none",style:"pointer-events: none"},this.svgDebugCanvas_));this.svgDebugCanvas_.setAttribute("transform",this.svgBlockCanvas_.getAttribute("transform"));a=this.debugRects_[a];a.setAttribute("x",b.left);a.setAttribute("y",b.top);a.setAttribute("width",b.width);a.setAttribute("height",b.height);a.setAttribute("stroke",c);a.setAttribute("stroke-width",
  3)};Blockly.BlockSpace.prototype.debugCircles_={};Blockly.BlockSpace.prototype.drawDebugCircle=function(a,b,c){this.debugCircles_[a]||(this.debugCircles_[a]=Blockly.createSvgElement("circle",{cx:"50",cy:"50",r:"50",style:"pointer-events: none"},this.svgDebugCanvas_));this.svgDebugCanvas_.setAttribute("transform",this.svgBlockCanvas_.getAttribute("transform"));a=this.debugCircles_[a];a.setAttribute("cx",""+b.x);a.setAttribute("cy",""+b.y);a.setAttribute("r",10);a.setAttribute("fill",c)};
  Blockly.BlockSpace.prototype.clearDebugDrawings=function(){[this.debugCircles_,this.debugRects_].forEach(function(a){for(var b in a)goog.dom.removeNode(a[b])});this.debugCircles_={};this.debugRects_={}};goog.string.StringBuffer=function(a,b){null!=a&&this.append.apply(this,arguments)};goog.string.StringBuffer.prototype.buffer_="";goog.string.StringBuffer.prototype.set=function(a){this.buffer_=""+a};goog.string.StringBuffer.prototype.append=function(a,b,c){this.buffer_+=a;if(null!=b)for(var d=1;d<arguments.length;d++)this.buffer_+=arguments[d];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.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(a,b){if(b&&a in b)return a;var c=goog.dom.vendor.getVendorJsPrefix();return c?(c=c.toLowerCase(),c+=goog.string.toTitleCase(a),!goog.isDef(b)||c in b?c:null):null};goog.dom.vendor.getPrefixedEventType=function(a){return((goog.dom.vendor.getVendorJsPrefix()||"")+a).toLowerCase()};goog.dom.classes={};goog.dom.classes.set=function(a,b){a.className=b};goog.dom.classes.get=function(a){a=a.className;return goog.isString(a)&&a.match(/\S+/g)||[]};goog.dom.classes.add=function(a,b){var c=goog.dom.classes.get(a),d=goog.array.slice(arguments,1),e=c.length+d.length;goog.dom.classes.add_(c,d);goog.dom.classes.set(a,c.join(" "));return c.length==e};
  goog.dom.classes.remove=function(a,b){var c=goog.dom.classes.get(a),d=goog.array.slice(arguments,1),e=goog.dom.classes.getDifference_(c,d);goog.dom.classes.set(a,e.join(" "));return e.length==c.length-d.length};goog.dom.classes.add_=function(a,b){for(var c=0;c<b.length;c++)goog.array.contains(a,b[c])||a.push(b[c])};goog.dom.classes.getDifference_=function(a,b){return goog.array.filter(a,function(a){return!goog.array.contains(b,a)})};
  goog.dom.classes.swap=function(a,b,c){for(var d=goog.dom.classes.get(a),e=!1,f=0;f<d.length;f++)d[f]==b&&(goog.array.splice(d,f--,1),e=!0);e&&(d.push(c),goog.dom.classes.set(a,d.join(" ")));return e};goog.dom.classes.addRemove=function(a,b,c){var d=goog.dom.classes.get(a);goog.isString(b)?goog.array.remove(d,b):goog.isArray(b)&&(d=goog.dom.classes.getDifference_(d,b));goog.isString(c)&&!goog.array.contains(d,c)?d.push(c):goog.isArray(c)&&goog.dom.classes.add_(d,c);goog.dom.classes.set(a,d.join(" "))};
  goog.dom.classes.has=function(a,b){return goog.array.contains(goog.dom.classes.get(a),b)};goog.dom.classes.enable=function(a,b,c){c?goog.dom.classes.add(a,b):goog.dom.classes.remove(a,b)};goog.dom.classes.toggle=function(a,b){var c=!goog.dom.classes.has(a,b);goog.dom.classes.enable(a,b,c);return c};goog.dom.TagName={A:"A",ABBR:"ABBR",ACRONYM:"ACRONYM",ADDRESS:"ADDRESS",APPLET:"APPLET",AREA:"AREA",ARTICLE:"ARTICLE",ASIDE:"ASIDE",AUDIO:"AUDIO",B:"B",BASE:"BASE",BASEFONT:"BASEFONT",BDI:"BDI",BDO:"BDO",BIG:"BIG",BLOCKQUOTE:"BLOCKQUOTE",BODY:"BODY",BR:"BR",BUTTON:"BUTTON",CANVAS:"CANVAS",CAPTION:"CAPTION",CENTER:"CENTER",CITE:"CITE",CODE:"CODE",COL:"COL",COLGROUP:"COLGROUP",COMMAND:"COMMAND",DATA:"DATA",DATALIST:"DATALIST",DD:"DD",DEL:"DEL",DETAILS:"DETAILS",DFN:"DFN",DIALOG:"DIALOG",DIR:"DIR",DIV:"DIV",
  DL:"DL",DT:"DT",EM:"EM",EMBED:"EMBED",FIELDSET:"FIELDSET",FIGCAPTION:"FIGCAPTION",FIGURE:"FIGURE",FONT:"FONT",FOOTER:"FOOTER",FORM:"FORM",FRAME:"FRAME",FRAMESET:"FRAMESET",H1:"H1",H2:"H2",H3:"H3",H4:"H4",H5:"H5",H6:"H6",HEAD:"HEAD",HEADER:"HEADER",HGROUP:"HGROUP",HR:"HR",HTML:"HTML",I:"I",IFRAME:"IFRAME",IMG:"IMG",INPUT:"INPUT",INS:"INS",ISINDEX:"ISINDEX",KBD:"KBD",KEYGEN:"KEYGEN",LABEL:"LABEL",LEGEND:"LEGEND",LI:"LI",LINK:"LINK",MAP:"MAP",MARK:"MARK",MATH:"MATH",MENU:"MENU",META:"META",METER:"METER",
  NAV:"NAV",NOFRAMES:"NOFRAMES",NOSCRIPT:"NOSCRIPT",OBJECT:"OBJECT",OL:"OL",OPTGROUP:"OPTGROUP",OPTION:"OPTION",OUTPUT:"OUTPUT",P:"P",PARAM:"PARAM",PRE:"PRE",PROGRESS:"PROGRESS",Q:"Q",RP:"RP",RT:"RT",RUBY:"RUBY",S:"S",SAMP:"SAMP",SCRIPT:"SCRIPT",SECTION:"SECTION",SELECT:"SELECT",SMALL:"SMALL",SOURCE:"SOURCE",SPAN:"SPAN",STRIKE:"STRIKE",STRONG:"STRONG",STYLE:"STYLE",SUB:"SUB",SUMMARY:"SUMMARY",SUP:"SUP",SVG:"SVG",TABLE:"TABLE",TBODY:"TBODY",TD:"TD",TEXTAREA:"TEXTAREA",TFOOT:"TFOOT",TH:"TH",THEAD:"THEAD",
  TIME:"TIME",TITLE:"TITLE",TR:"TR",TRACK:"TRACK",TT:"TT",U:"U",UL:"UL",VAR:"VAR",VIDEO:"VIDEO",WBR:"WBR"};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};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(a){return a?new goog.dom.DomHelper(goog.dom.getOwnerDocument(a)):goog.dom.defaultDomHelper_||(goog.dom.defaultDomHelper_=new goog.dom.DomHelper)};goog.dom.getDocument=function(){return document};goog.dom.getElement=function(a){return goog.dom.getElementHelper_(document,a)};
  goog.dom.getElementHelper_=function(a,b){return goog.isString(b)?a.getElementById(b):b};goog.dom.getRequiredElement=function(a){return goog.dom.getRequiredElementHelper_(document,a)};goog.dom.getRequiredElementHelper_=function(a,b){goog.asserts.assertString(b);var c=goog.dom.getElementHelper_(a,b);return c=goog.asserts.assertElement(c,"No element found with id: "+b)};goog.dom.$=goog.dom.getElement;
  goog.dom.getElementsByTagNameAndClass=function(a,b,c){return goog.dom.getElementsByTagNameAndClass_(document,a,b,c)};goog.dom.getElementsByClass=function(a,b){var c=b||document;return goog.dom.canUseQuerySelector_(c)?c.querySelectorAll("."+a):goog.dom.getElementsByTagNameAndClass_(document,"*",a,b)};goog.dom.getElementByClass=function(a,b){var c=b||document,d=null;return(d=goog.dom.canUseQuerySelector_(c)?c.querySelector("."+a):goog.dom.getElementsByTagNameAndClass_(document,"*",a,b)[0])||null};
  goog.dom.getRequiredElementByClass=function(a,b){var c=goog.dom.getElementByClass(a,b);return goog.asserts.assert(c,"No element found with className: "+a)};goog.dom.canUseQuerySelector_=function(a){return!(!a.querySelectorAll||!a.querySelector)};
  goog.dom.getElementsByTagNameAndClass_=function(a,b,c,d){a=d||a;b=b&&"*"!=b?b.toUpperCase():"";if(goog.dom.canUseQuerySelector_(a)&&(b||c))return a.querySelectorAll(b+(c?"."+c:""));if(c&&a.getElementsByClassName){a=a.getElementsByClassName(c);if(b){d={};for(var e=0,f=0,g;g=a[f];f++)b==g.nodeName&&(d[e++]=g);d.length=e;return d}return a}a=a.getElementsByTagName(b||"*");if(c){d={};for(f=e=0;g=a[f];f++)b=g.className,"function"==typeof b.split&&goog.array.contains(b.split(/\s+/),c)&&(d[e++]=g);d.length=
  e;return d}return a};goog.dom.$$=goog.dom.getElementsByTagNameAndClass;goog.dom.setProperties=function(a,b){goog.object.forEach(b,function(b,d){"style"==d?a.style.cssText=b:"class"==d?a.className=b:"for"==d?a.htmlFor=b:d in goog.dom.DIRECT_ATTRIBUTE_MAP_?a.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP_[d],b):goog.string.startsWith(d,"aria-")||goog.string.startsWith(d,"data-")?a.setAttribute(d,b):a[d]=b})};
  goog.dom.DIRECT_ATTRIBUTE_MAP_={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};goog.dom.getViewportSize=function(a){return goog.dom.getViewportSize_(a||window)};goog.dom.getViewportSize_=function(a){a=a.document;a=goog.dom.isCss1CompatMode_(a)?a.documentElement:a.body;return new goog.math.Size(a.clientWidth,a.clientHeight)};
  goog.dom.getDocumentHeight=function(){return goog.dom.getDocumentHeight_(window)};goog.dom.getDocumentHeight_=function(a){var b=a.document,c=0;if(b){a=goog.dom.getViewportSize_(a).height;var c=b.body,d=b.documentElement;if(goog.dom.isCss1CompatMode_(b)&&d.scrollHeight)c=d.scrollHeight!=a?d.scrollHeight:d.offsetHeight;else{var b=d.scrollHeight,e=d.offsetHeight;d.clientHeight!=e&&(b=c.scrollHeight,e=c.offsetHeight);c=b>a?b>e?b:e:b<e?b:e}}return c};
  goog.dom.getPageScroll=function(a){return goog.dom.getDomHelper((a||goog.global||window).document).getDocumentScroll()};goog.dom.getDocumentScroll=function(){return goog.dom.getDocumentScroll_(document)};
  goog.dom.getDocumentScroll_=function(a){var b=goog.dom.getDocumentScrollElement_(a);a=goog.dom.getWindow_(a);return goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("10")&&a.pageYOffset!=b.scrollTop?new goog.math.Coordinate(b.scrollLeft,b.scrollTop):new goog.math.Coordinate(a.pageXOffset||b.scrollLeft,a.pageYOffset||b.scrollTop)};goog.dom.getDocumentScrollElement=function(){return goog.dom.getDocumentScrollElement_(document)};
  goog.dom.getDocumentScrollElement_=function(a){return!goog.userAgent.WEBKIT&&goog.dom.isCss1CompatMode_(a)?a.documentElement:a.body||a.documentElement};goog.dom.getWindow=function(a){return a?goog.dom.getWindow_(a):window};goog.dom.getWindow_=function(a){return a.parentWindow||a.defaultView};goog.dom.createDom=function(a,b,c){return goog.dom.createDom_(document,arguments)};
  goog.dom.createDom_=function(a,b){var c=b[0],d=b[1];if(!goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES&&d&&(d.name||d.type)){c=["<",c];d.name&&c.push(' name="',goog.string.htmlEscape(d.name),'"');if(d.type){c.push(' type="',goog.string.htmlEscape(d.type),'"');var e={};goog.object.extend(e,d);delete e.type;d=e}c.push(">");c=c.join("")}c=a.createElement(c);d&&(goog.isString(d)?c.className=d:goog.isArray(d)?goog.dom.classes.add.apply(null,[c].concat(d)):goog.dom.setProperties(c,d));2<b.length&&
  goog.dom.append_(a,c,b,2);return c};goog.dom.append_=function(a,b,c,d){function e(c){c&&b.appendChild(goog.isString(c)?a.createTextNode(c):c)}for(;d<c.length;d++){var f=c[d];goog.isArrayLike(f)&&!goog.dom.isNodeLike(f)?goog.array.forEach(goog.dom.isNodeList(f)?goog.array.toArray(f):f,e):e(f)}};goog.dom.$dom=goog.dom.createDom;goog.dom.createElement=function(a){return document.createElement(a)};goog.dom.createTextNode=function(a){return document.createTextNode(String(a))};
  goog.dom.createTable=function(a,b,c){return goog.dom.createTable_(document,a,b,!!c)};goog.dom.createTable_=function(a,b,c,d){for(var e=["<tr>"],f=0;f<c;f++)e.push(d?"<td>&nbsp;</td>":"<td></td>");e.push("</tr>");e=e.join("");c=["<table>"];for(f=0;f<b;f++)c.push(e);c.push("</table>");a=a.createElement(goog.dom.TagName.DIV);a.innerHTML=c.join("");return a.removeChild(a.firstChild)};goog.dom.htmlToDocumentFragment=function(a){return goog.dom.htmlToDocumentFragment_(document,a)};
  goog.dom.htmlToDocumentFragment_=function(a,b){var c=a.createElement("div");goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT?(c.innerHTML="<br>"+b,c.removeChild(c.firstChild)):c.innerHTML=b;if(1==c.childNodes.length)return c.removeChild(c.firstChild);for(var d=a.createDocumentFragment();c.firstChild;)d.appendChild(c.firstChild);return d};goog.dom.isCss1CompatMode=function(){return goog.dom.isCss1CompatMode_(document)};
  goog.dom.isCss1CompatMode_=function(a){return goog.dom.COMPAT_MODE_KNOWN_?goog.dom.ASSUME_STANDARDS_MODE:"CSS1Compat"==a.compatMode};goog.dom.canHaveChildren=function(a){if(a.nodeType!=goog.dom.NodeType.ELEMENT)return!1;switch(a.tagName){case goog.dom.TagName.APPLET:case goog.dom.TagName.AREA:case goog.dom.TagName.BASE:case goog.dom.TagName.BR:case goog.dom.TagName.COL:case goog.dom.TagName.COMMAND:case goog.dom.TagName.EMBED:case goog.dom.TagName.FRAME:case goog.dom.TagName.HR:case goog.dom.TagName.IMG:case goog.dom.TagName.INPUT:case goog.dom.TagName.IFRAME:case goog.dom.TagName.ISINDEX:case goog.dom.TagName.KEYGEN:case goog.dom.TagName.LINK:case goog.dom.TagName.NOFRAMES:case goog.dom.TagName.NOSCRIPT:case goog.dom.TagName.META:case goog.dom.TagName.OBJECT:case goog.dom.TagName.PARAM:case goog.dom.TagName.SCRIPT:case goog.dom.TagName.SOURCE:case goog.dom.TagName.STYLE:case goog.dom.TagName.TRACK:case goog.dom.TagName.WBR:return!1}return!0};
  goog.dom.appendChild=function(a,b){a.appendChild(b)};goog.dom.append=function(a,b){goog.dom.append_(goog.dom.getOwnerDocument(a),a,arguments,1)};goog.dom.removeChildren=function(a){for(var b;b=a.firstChild;)a.removeChild(b)};goog.dom.insertSiblingBefore=function(a,b){b.parentNode&&b.parentNode.insertBefore(a,b)};goog.dom.insertSiblingAfter=function(a,b){b.parentNode&&b.parentNode.insertBefore(a,b.nextSibling)};goog.dom.insertChildAt=function(a,b,c){a.insertBefore(b,a.childNodes[c]||null)};
  goog.dom.removeNode=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};goog.dom.replaceNode=function(a,b){var c=b.parentNode;c&&c.replaceChild(a,b)};goog.dom.flattenElement=function(a){var b,c=a.parentNode;if(c&&c.nodeType!=goog.dom.NodeType.DOCUMENT_FRAGMENT){if(a.removeNode)return a.removeNode(!1);for(;b=a.firstChild;)c.insertBefore(b,a);return goog.dom.removeNode(a)}};
  goog.dom.getChildren=function(a){return goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE&&void 0!=a.children?a.children:goog.array.filter(a.childNodes,function(a){return a.nodeType==goog.dom.NodeType.ELEMENT})};goog.dom.getFirstElementChild=function(a){return void 0!=a.firstElementChild?a.firstElementChild:goog.dom.getNextElementNode_(a.firstChild,!0)};goog.dom.getLastElementChild=function(a){return void 0!=a.lastElementChild?a.lastElementChild:goog.dom.getNextElementNode_(a.lastChild,!1)};
  goog.dom.getNextElementSibling=function(a){return void 0!=a.nextElementSibling?a.nextElementSibling:goog.dom.getNextElementNode_(a.nextSibling,!0)};goog.dom.getPreviousElementSibling=function(a){return void 0!=a.previousElementSibling?a.previousElementSibling:goog.dom.getNextElementNode_(a.previousSibling,!1)};goog.dom.getNextElementNode_=function(a,b){for(;a&&a.nodeType!=goog.dom.NodeType.ELEMENT;)a=b?a.nextSibling:a.previousSibling;return a};
  goog.dom.getNextNode=function(a){if(!a)return null;if(a.firstChild)return a.firstChild;for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null};goog.dom.getPreviousNode=function(a){if(!a)return null;if(!a.previousSibling)return a.parentNode;for(a=a.previousSibling;a&&a.lastChild;)a=a.lastChild;return a};goog.dom.isNodeLike=function(a){return goog.isObject(a)&&0<a.nodeType};goog.dom.isElement=function(a){return goog.isObject(a)&&a.nodeType==goog.dom.NodeType.ELEMENT};
  goog.dom.isWindow=function(a){return goog.isObject(a)&&a.window==a};goog.dom.getParentElement=function(a){if(goog.dom.BrowserFeature.CAN_USE_PARENT_ELEMENT_PROPERTY&&!(goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("9")&&!goog.userAgent.isVersionOrHigher("10")&&goog.global.SVGElement&&a instanceof goog.global.SVGElement))return a.parentElement;a=a.parentNode;return goog.dom.isElement(a)?a:null};
  goog.dom.contains=function(a,b){if(a.contains&&b.nodeType==goog.dom.NodeType.ELEMENT)return a==b||a.contains(b);if("undefined"!=typeof a.compareDocumentPosition)return a==b||Boolean(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a};
  goog.dom.compareNodeOrder=function(a,b){if(a==b)return 0;if(a.compareDocumentPosition)return a.compareDocumentPosition(b)&2?1:-1;if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(9)){if(a.nodeType==goog.dom.NodeType.DOCUMENT)return-1;if(b.nodeType==goog.dom.NodeType.DOCUMENT)return 1}if("sourceIndex"in a||a.parentNode&&"sourceIndex"in a.parentNode){var c=a.nodeType==goog.dom.NodeType.ELEMENT,d=b.nodeType==goog.dom.NodeType.ELEMENT;if(c&&d)return a.sourceIndex-b.sourceIndex;var e=a.parentNode,
  f=b.parentNode;return e==f?goog.dom.compareSiblingOrder_(a,b):!c&&goog.dom.contains(e,b)?-1*goog.dom.compareParentsDescendantNodeIe_(a,b):!d&&goog.dom.contains(f,a)?goog.dom.compareParentsDescendantNodeIe_(b,a):(c?a.sourceIndex:e.sourceIndex)-(d?b.sourceIndex:f.sourceIndex)}d=goog.dom.getOwnerDocument(a);c=d.createRange();c.selectNode(a);c.collapse(!0);d=d.createRange();d.selectNode(b);d.collapse(!0);return c.compareBoundaryPoints(goog.global.Range.START_TO_END,d)};
  goog.dom.compareParentsDescendantNodeIe_=function(a,b){var c=a.parentNode;if(c==b)return-1;for(var d=b;d.parentNode!=c;)d=d.parentNode;return goog.dom.compareSiblingOrder_(d,a)};goog.dom.compareSiblingOrder_=function(a,b){for(var c=b;c=c.previousSibling;)if(c==a)return-1;return 1};
  goog.dom.findCommonAncestor=function(a){var b,c=arguments.length;if(!c)return null;if(1==c)return arguments[0];var d=[],e=Infinity;for(b=0;b<c;b++){for(var f=[],g=arguments[b];g;)f.unshift(g),g=g.parentNode;d.push(f);e=Math.min(e,f.length)}f=null;for(b=0;b<e;b++){for(var g=d[0][b],h=1;h<c;h++)if(g!=d[h][b])return f;f=g}return f};goog.dom.getOwnerDocument=function(a){return a.nodeType==goog.dom.NodeType.DOCUMENT?a:a.ownerDocument||a.document};
  goog.dom.getFrameContentDocument=function(a){return a.contentDocument||a.contentWindow.document};goog.dom.getFrameContentWindow=function(a){return a.contentWindow||goog.dom.getWindow(goog.dom.getFrameContentDocument(a))};
  goog.dom.setTextContent=function(a,b){goog.asserts.assert(null!=a,"goog.dom.setTextContent expects a non-null value for node");if("textContent"in a)a.textContent=b;else if(a.nodeType==goog.dom.NodeType.TEXT)a.data=b;else if(a.firstChild&&a.firstChild.nodeType==goog.dom.NodeType.TEXT){for(;a.lastChild!=a.firstChild;)a.removeChild(a.lastChild);a.firstChild.data=b}else{goog.dom.removeChildren(a);var c=goog.dom.getOwnerDocument(a);a.appendChild(c.createTextNode(String(b)))}};
  goog.dom.getOuterHtml=function(a){if("outerHTML"in a)return a.outerHTML;var b=goog.dom.getOwnerDocument(a).createElement("div");b.appendChild(a.cloneNode(!0));return b.innerHTML};goog.dom.findNode=function(a,b){var c=[];return goog.dom.findNodes_(a,b,c,!0)?c[0]:void 0};goog.dom.findNodes=function(a,b){var c=[];goog.dom.findNodes_(a,b,c,!1);return c};goog.dom.findNodes_=function(a,b,c,d){if(null!=a)for(a=a.firstChild;a;){if(b(a)&&(c.push(a),d)||goog.dom.findNodes_(a,b,c,d))return!0;a=a.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(a){return goog.dom.hasSpecifiedTabIndex_(a)&&goog.dom.isTabIndexFocusable_(a)};goog.dom.setFocusableTabIndex=function(a,b){b?a.tabIndex=0:(a.tabIndex=-1,a.removeAttribute("tabIndex"))};
  goog.dom.isFocusable=function(a){var b;return(b=goog.dom.nativelySupportsFocus_(a)?!a.disabled&&(!goog.dom.hasSpecifiedTabIndex_(a)||goog.dom.isTabIndexFocusable_(a)):goog.dom.isFocusableTabIndex(a))&&goog.userAgent.IE?goog.dom.hasNonZeroBoundingRect_(a):b};goog.dom.hasSpecifiedTabIndex_=function(a){a=a.getAttributeNode("tabindex");return goog.isDefAndNotNull(a)&&a.specified};goog.dom.isTabIndexFocusable_=function(a){a=a.tabIndex;return goog.isNumber(a)&&0<=a&&32768>a};
  goog.dom.nativelySupportsFocus_=function(a){return a.tagName==goog.dom.TagName.A||a.tagName==goog.dom.TagName.INPUT||a.tagName==goog.dom.TagName.TEXTAREA||a.tagName==goog.dom.TagName.SELECT||a.tagName==goog.dom.TagName.BUTTON};goog.dom.hasNonZeroBoundingRect_=function(a){a=goog.isFunction(a.getBoundingClientRect)?a.getBoundingClientRect():{height:a.offsetHeight,width:a.offsetWidth};return goog.isDefAndNotNull(a)&&0<a.height&&0<a.width};
  goog.dom.getTextContent=function(a){if(goog.dom.BrowserFeature.CAN_USE_INNER_TEXT&&"innerText"in a)a=goog.string.canonicalizeNewlines(a.innerText);else{var b=[];goog.dom.getTextContent_(a,b,!0);a=b.join("")}a=a.replace(/ \xAD /g," ").replace(/\xAD/g,"");a=a.replace(/\u200B/g,"");goog.dom.BrowserFeature.CAN_USE_INNER_TEXT||(a=a.replace(/ +/g," "));" "!=a&&(a=a.replace(/^\s*/,""));return a};goog.dom.getRawTextContent=function(a){var b=[];goog.dom.getTextContent_(a,b,!1);return b.join("")};
  goog.dom.getTextContent_=function(a,b,c){if(!(a.nodeName in goog.dom.TAGS_TO_IGNORE_))if(a.nodeType==goog.dom.NodeType.TEXT)c?b.push(String(a.nodeValue).replace(/(\r\n|\r|\n)/g,"")):b.push(a.nodeValue);else if(a.nodeName in goog.dom.PREDEFINED_TAG_VALUES_)b.push(goog.dom.PREDEFINED_TAG_VALUES_[a.nodeName]);else for(a=a.firstChild;a;)goog.dom.getTextContent_(a,b,c),a=a.nextSibling};goog.dom.getNodeTextLength=function(a){return goog.dom.getTextContent(a).length};
  goog.dom.getNodeTextOffset=function(a,b){for(var c=b||goog.dom.getOwnerDocument(a).body,d=[];a&&a!=c;){for(var e=a;e=e.previousSibling;)d.unshift(goog.dom.getTextContent(e));a=a.parentNode}return goog.string.trimLeft(d.join("")).replace(/ +/g," ").length};
  goog.dom.getNodeAtOffset=function(a,b,c){a=[a];for(var d=0,e=null;0<a.length&&d<b;)if(e=a.pop(),!(e.nodeName in goog.dom.TAGS_TO_IGNORE_))if(e.nodeType==goog.dom.NodeType.TEXT)var f=e.nodeValue.replace(/(\r\n|\r|\n)/g,"").replace(/ +/g," "),d=d+f.length;else if(e.nodeName in goog.dom.PREDEFINED_TAG_VALUES_)d+=goog.dom.PREDEFINED_TAG_VALUES_[e.nodeName].length;else for(f=e.childNodes.length-1;0<=f;f--)a.push(e.childNodes[f]);goog.isObject(c)&&(c.remainder=e?e.nodeValue.length+b-d-1:0,c.node=e);return e};
  goog.dom.isNodeList=function(a){if(a&&"number"==typeof a.length){if(goog.isObject(a))return"function"==typeof a.item||"string"==typeof a.item;if(goog.isFunction(a))return"function"==typeof a.item}return!1};goog.dom.getAncestorByTagNameAndClass=function(a,b,c){if(!b&&!c)return null;var d=b?b.toUpperCase():null;return goog.dom.getAncestor(a,function(a){return(!d||a.nodeName==d)&&(!c||goog.dom.classes.has(a,c))},!0)};
  goog.dom.getAncestorByClass=function(a,b){return goog.dom.getAncestorByTagNameAndClass(a,null,b)};goog.dom.getAncestor=function(a,b,c,d){c||(a=a.parentNode);c=null==d;for(var e=0;a&&(c||e<=d);){if(b(a))return a;a=a.parentNode;e++}return null};goog.dom.getActiveElement=function(a){try{return a&&a.activeElement}catch(b){}return null};
  goog.dom.getPixelRatio=goog.functions.cacheReturnValue(function(){var a=goog.dom.getWindow(),b=goog.userAgent.GECKO&&goog.userAgent.MOBILE;return goog.isDef(a.devicePixelRatio)&&!b?a.devicePixelRatio:a.matchMedia?goog.dom.matchesPixelRatio_(0.75)||goog.dom.matchesPixelRatio_(1.5)||goog.dom.matchesPixelRatio_(2)||goog.dom.matchesPixelRatio_(3)||1:1});
  goog.dom.matchesPixelRatio_=function(a){return goog.dom.getWindow().matchMedia("(-webkit-min-device-pixel-ratio: "+a+"),(min--moz-device-pixel-ratio: "+a+"),(min-resolution: "+a+"dppx)").matches?a:0};goog.dom.DomHelper=function(a){this.document_=a||goog.global.document||document};goog.dom.DomHelper.prototype.getDomHelper=goog.dom.getDomHelper;goog.dom.DomHelper.prototype.setDocument=function(a){this.document_=a};goog.dom.DomHelper.prototype.getDocument=function(){return this.document_};
  goog.dom.DomHelper.prototype.getElement=function(a){return goog.dom.getElementHelper_(this.document_,a)};goog.dom.DomHelper.prototype.getRequiredElement=function(a){return goog.dom.getRequiredElementHelper_(this.document_,a)};goog.dom.DomHelper.prototype.$=goog.dom.DomHelper.prototype.getElement;goog.dom.DomHelper.prototype.getElementsByTagNameAndClass=function(a,b,c){return goog.dom.getElementsByTagNameAndClass_(this.document_,a,b,c)};
  goog.dom.DomHelper.prototype.getElementsByClass=function(a,b){return goog.dom.getElementsByClass(a,b||this.document_)};goog.dom.DomHelper.prototype.getElementByClass=function(a,b){return goog.dom.getElementByClass(a,b||this.document_)};goog.dom.DomHelper.prototype.getRequiredElementByClass=function(a,b){return goog.dom.getRequiredElementByClass(a,b||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(a){return goog.dom.getViewportSize(a||this.getWindow())};goog.dom.DomHelper.prototype.getDocumentHeight=function(){return goog.dom.getDocumentHeight_(this.getWindow())};goog.dom.DomHelper.prototype.createDom=function(a,b,c){return goog.dom.createDom_(this.document_,arguments)};goog.dom.DomHelper.prototype.$dom=goog.dom.DomHelper.prototype.createDom;
  goog.dom.DomHelper.prototype.createElement=function(a){return this.document_.createElement(a)};goog.dom.DomHelper.prototype.createTextNode=function(a){return this.document_.createTextNode(String(a))};goog.dom.DomHelper.prototype.createTable=function(a,b,c){return goog.dom.createTable_(this.document_,a,b,!!c)};goog.dom.DomHelper.prototype.htmlToDocumentFragment=function(a){return goog.dom.htmlToDocumentFragment_(this.document_,a)};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(a){return goog.dom.getActiveElement(a||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.style={};goog.style.GET_BOUNDING_CLIENT_RECT_ALWAYS_EXISTS=!1;goog.style.setStyle=function(a,b,c){goog.isString(b)?goog.style.setStyle_(a,c,b):goog.object.forEach(b,goog.partial(goog.style.setStyle_,a))};goog.style.setStyle_=function(a,b,c){(c=goog.style.getVendorJsStyleName_(a,c))&&(a.style[c]=b)};goog.style.getVendorJsStyleName_=function(a,b){var c=goog.string.toCamelCase(b);if(void 0===a.style[c]){var d=goog.dom.vendor.getVendorJsPrefix()+goog.string.toTitleCase(b);if(void 0!==a.style[d])return d}return c};
  goog.style.getVendorStyleName_=function(a,b){var c=goog.string.toCamelCase(b);return void 0===a.style[c]&&(c=goog.dom.vendor.getVendorJsPrefix()+goog.string.toTitleCase(b),void 0!==a.style[c])?goog.dom.vendor.getVendorPrefix()+"-"+b:b};goog.style.getStyle=function(a,b){var c=a.style[goog.string.toCamelCase(b)];return"undefined"!==typeof c?c:a.style[goog.style.getVendorJsStyleName_(a,b)]||""};
  goog.style.getComputedStyle=function(a,b){var c=goog.dom.getOwnerDocument(a);return c.defaultView&&c.defaultView.getComputedStyle&&(c=c.defaultView.getComputedStyle(a,null))?c[b]||c.getPropertyValue(b)||"":""};goog.style.getCascadedStyle=function(a,b){return a.currentStyle?a.currentStyle[b]:null};goog.style.getStyle_=function(a,b){return goog.style.getComputedStyle(a,b)||goog.style.getCascadedStyle(a,b)||a.style&&a.style[b]};
  goog.style.getComputedBoxSizing=function(a){return goog.style.getStyle_(a,"boxSizing")||goog.style.getStyle_(a,"MozBoxSizing")||goog.style.getStyle_(a,"WebkitBoxSizing")||null};goog.style.getComputedPosition=function(a){return goog.style.getStyle_(a,"position")};goog.style.getBackgroundColor=function(a){return goog.style.getStyle_(a,"backgroundColor")};goog.style.getComputedOverflowX=function(a){return goog.style.getStyle_(a,"overflowX")};
  goog.style.getComputedOverflowY=function(a){return goog.style.getStyle_(a,"overflowY")};goog.style.getComputedZIndex=function(a){return goog.style.getStyle_(a,"zIndex")};goog.style.getComputedTextAlign=function(a){return goog.style.getStyle_(a,"textAlign")};goog.style.getComputedCursor=function(a){return goog.style.getStyle_(a,"cursor")};
  goog.style.setPosition=function(a,b,c){var d,e=goog.userAgent.GECKO&&(goog.userAgent.MAC||goog.userAgent.X11)&&goog.userAgent.isVersionOrHigher("1.9");b instanceof goog.math.Coordinate?(d=b.x,b=b.y):(d=b,b=c);a.style.left=goog.style.getPixelStyleValue_(d,e);a.style.top=goog.style.getPixelStyleValue_(b,e)};goog.style.getPosition=function(a){return new goog.math.Coordinate(a.offsetLeft,a.offsetTop)};
  goog.style.getClientViewportElement=function(a){a=a?goog.dom.getOwnerDocument(a):goog.dom.getDocument();return!goog.userAgent.IE||goog.userAgent.isDocumentModeOrHigher(9)||goog.dom.getDomHelper(a).isCss1CompatMode()?a.documentElement:a.body};goog.style.getViewportPageOffset=function(a){var b=a.body;a=a.documentElement;return new goog.math.Coordinate(b.scrollLeft||a.scrollLeft,b.scrollTop||a.scrollTop)};
  goog.style.getBoundingClientRect_=function(a){var b;try{b=a.getBoundingClientRect()}catch(c){return{left:0,top:0,right:0,bottom:0}}goog.userAgent.IE&&a.ownerDocument.body&&(a=a.ownerDocument,b.left-=a.documentElement.clientLeft+a.body.clientLeft,b.top-=a.documentElement.clientTop+a.body.clientTop);return b};
  goog.style.getOffsetParent=function(a){if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(8))return a.offsetParent;var b=goog.dom.getOwnerDocument(a),c=goog.style.getStyle_(a,"position"),d="fixed"==c||"absolute"==c;for(a=a.parentNode;a&&a!=b;a=a.parentNode)if(c=goog.style.getStyle_(a,"position"),d=d&&"static"==c&&a!=b.documentElement&&a!=b.body,!d&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight||"fixed"==c||"absolute"==c||"relative"==c))return a;return null};
  goog.style.getVisibleRectForElement=function(a){for(var b=new goog.math.Box(0,Infinity,Infinity,0),c=goog.dom.getDomHelper(a),d=c.getDocument().body,e=c.getDocument().documentElement,f=c.getDocumentScrollElement();a=goog.style.getOffsetParent(a);)if(!(goog.userAgent.IE&&0==a.clientWidth||goog.userAgent.WEBKIT&&0==a.clientHeight&&a==d||a==d||a==e||"visible"==goog.style.getStyle_(a,"overflow"))){var g=goog.style.getPageOffset(a),h=goog.style.getClientLeftTop(a);g.x+=h.x;g.y+=h.y;b.top=Math.max(b.top,
  g.y);b.right=Math.min(b.right,g.x+a.clientWidth);b.bottom=Math.min(b.bottom,g.y+a.clientHeight);b.left=Math.max(b.left,g.x)}d=f.scrollLeft;f=f.scrollTop;b.left=Math.max(b.left,d);b.top=Math.max(b.top,f);c=c.getViewportSize();b.right=Math.min(b.right,d+c.width);b.bottom=Math.min(b.bottom,f+c.height);return 0<=b.top&&0<=b.left&&b.bottom>b.top&&b.right>b.left?b:null};
  goog.style.getContainerOffsetToScrollInto=function(a,b,c){var d=goog.style.getPageOffset(a),e=goog.style.getPageOffset(b),f=goog.style.getBorderBox(b),g=d.x-e.x-f.left,d=d.y-e.y-f.top,e=b.clientWidth-a.offsetWidth;a=b.clientHeight-a.offsetHeight;f=b.scrollLeft;b=b.scrollTop;c?(f+=g-e/2,b+=d-a/2):(f+=Math.min(g,Math.max(g-e,0)),b+=Math.min(d,Math.max(d-a,0)));return new goog.math.Coordinate(f,b)};
  goog.style.scrollIntoContainerView=function(a,b,c){a=goog.style.getContainerOffsetToScrollInto(a,b,c);b.scrollLeft=a.x;b.scrollTop=a.y};
  goog.style.getClientLeftTop=function(a){if(goog.userAgent.GECKO&&!goog.userAgent.isVersionOrHigher("1.9")){var b=parseFloat(goog.style.getComputedStyle(a,"borderLeftWidth"));if(goog.style.isRightToLeft(a))var c=a.offsetWidth-a.clientWidth-b-parseFloat(goog.style.getComputedStyle(a,"borderRightWidth")),b=b+c;return new goog.math.Coordinate(b,parseFloat(goog.style.getComputedStyle(a,"borderTopWidth")))}return new goog.math.Coordinate(a.clientLeft,a.clientTop)};
  goog.style.getPageOffset=function(a){var b,c=goog.dom.getOwnerDocument(a),d=goog.style.getStyle_(a,"position");goog.asserts.assertObject(a,"Parameter is required");var e=!goog.style.GET_BOUNDING_CLIENT_RECT_ALWAYS_EXISTS&&goog.userAgent.GECKO&&c.getBoxObjectFor&&!a.getBoundingClientRect&&"absolute"==d&&(b=c.getBoxObjectFor(a))&&(0>b.screenX||0>b.screenY),f=new goog.math.Coordinate(0,0),g=goog.style.getClientViewportElement(c);if(a==g)return f;if(goog.style.GET_BOUNDING_CLIENT_RECT_ALWAYS_EXISTS||
  a.getBoundingClientRect)b=goog.style.getBoundingClientRect_(a),a=goog.dom.getDomHelper(c).getDocumentScroll(),f.x=b.left+a.x,f.y=b.top+a.y;else if(c.getBoxObjectFor&&!e)b=c.getBoxObjectFor(a),a=c.getBoxObjectFor(g),f.x=b.screenX-a.screenX,f.y=b.screenY-a.screenY;else{b=a;do{f.x+=b.offsetLeft;f.y+=b.offsetTop;b!=a&&(f.x+=b.clientLeft||0,f.y+=b.clientTop||0);if(goog.userAgent.WEBKIT&&"fixed"==goog.style.getComputedPosition(b)){f.x+=c.body.scrollLeft;f.y+=c.body.scrollTop;break}b=b.offsetParent}while(b&&
  b!=a);if(goog.userAgent.OPERA||goog.userAgent.WEBKIT&&"absolute"==d)f.y-=c.body.offsetTop;for(b=a;(b=goog.style.getOffsetParent(b))&&b!=c.body&&b!=g;)f.x-=b.scrollLeft,goog.userAgent.OPERA&&"TR"==b.tagName||(f.y-=b.scrollTop)}return f};goog.style.getPageOffsetLeft=function(a){return goog.style.getPageOffset(a).x};goog.style.getPageOffsetTop=function(a){return goog.style.getPageOffset(a).y};
  goog.style.getFramedPageOffset=function(a,b){var c=new goog.math.Coordinate(0,0),d=goog.dom.getWindow(goog.dom.getOwnerDocument(a)),e=a;do{var f=d==b?goog.style.getPageOffset(e):goog.style.getClientPositionForElement_(goog.asserts.assert(e));c.x+=f.x;c.y+=f.y}while(d&&d!=b&&(e=d.frameElement)&&(d=d.parent));return c};
  goog.style.translateRectForAnotherFrame=function(a,b,c){if(b.getDocument()!=c.getDocument()){var d=b.getDocument().body;c=goog.style.getFramedPageOffset(d,c.getWindow());c=goog.math.Coordinate.difference(c,goog.style.getPageOffset(d));goog.userAgent.IE&&!b.isCss1CompatMode()&&(c=goog.math.Coordinate.difference(c,b.getDocumentScroll()));a.left+=c.x;a.top+=c.y}};
  goog.style.getRelativePosition=function(a,b){var c=goog.style.getClientPosition(a),d=goog.style.getClientPosition(b);return new goog.math.Coordinate(c.x-d.x,c.y-d.y)};
  goog.style.getClientPositionForElement_=function(a){var b;if(goog.style.GET_BOUNDING_CLIENT_RECT_ALWAYS_EXISTS||a.getBoundingClientRect)b=goog.style.getBoundingClientRect_(a),b=new goog.math.Coordinate(b.left,b.top);else{b=goog.dom.getDomHelper(a).getDocumentScroll();var c=goog.style.getPageOffset(a);b=new goog.math.Coordinate(c.x-b.x,c.y-b.y)}return goog.userAgent.GECKO&&!goog.userAgent.isVersionOrHigher(12)?goog.math.Coordinate.sum(b,goog.style.getCssTranslation(a)):b};
  goog.style.getClientPosition=function(a){goog.asserts.assert(a);if(a.nodeType==goog.dom.NodeType.ELEMENT)return goog.style.getClientPositionForElement_(a);var b=goog.isFunction(a.getBrowserEvent),c=a;a.targetTouches?c=a.targetTouches[0]:b&&a.getBrowserEvent().targetTouches&&(c=a.getBrowserEvent().targetTouches[0]);return new goog.math.Coordinate(c.clientX,c.clientY)};
  goog.style.setPageOffset=function(a,b,c){var d=goog.style.getPageOffset(a);b instanceof goog.math.Coordinate&&(c=b.y,b=b.x);goog.style.setPosition(a,a.offsetLeft+(b-d.x),a.offsetTop+(c-d.y))};goog.style.setSize=function(a,b,c){if(b instanceof goog.math.Size)c=b.height,b=b.width;else if(void 0==c)throw Error("missing height argument");goog.style.setWidth(a,b);goog.style.setHeight(a,c)};goog.style.getPixelStyleValue_=function(a,b){"number"==typeof a&&(a=(b?Math.round(a):a)+"px");return a};
  goog.style.setHeight=function(a,b){a.style.height=goog.style.getPixelStyleValue_(b,!0)};goog.style.setWidth=function(a,b){a.style.width=goog.style.getPixelStyleValue_(b,!0)};goog.style.getSize=function(a){return goog.style.evaluateWithTemporaryDisplay_(goog.style.getSizeWithDisplay_,a)};
  goog.style.evaluateWithTemporaryDisplay_=function(a,b){if("none"!=goog.style.getStyle_(b,"display"))return a(b);var c=b.style,d=c.display,e=c.visibility,f=c.position;c.visibility="hidden";c.position="absolute";c.display="inline";var g=a(b);c.display=d;c.position=f;c.visibility=e;return g};
  goog.style.getSizeWithDisplay_=function(a){var b=a.offsetWidth,c=a.offsetHeight,d=goog.userAgent.WEBKIT&&!b&&!c;return goog.isDef(b)&&!d||!a.getBoundingClientRect?new goog.math.Size(b,c):(a=goog.style.getBoundingClientRect_(a),new goog.math.Size(a.right-a.left,a.bottom-a.top))};goog.style.getTransformedSize=function(a){if(!a.getBoundingClientRect)return null;a=goog.style.evaluateWithTemporaryDisplay_(goog.style.getBoundingClientRect_,a);return new goog.math.Size(a.right-a.left,a.bottom-a.top)};
  goog.style.getBounds=function(a){var b=goog.style.getPageOffset(a);a=goog.style.getSize(a);return new goog.math.Rect(b.x,b.y,a.width,a.height)};goog.style.toCamelCase=function(a){return goog.string.toCamelCase(String(a))};goog.style.toSelectorCase=function(a){return goog.string.toSelectorCase(a)};
  goog.style.getOpacity=function(a){var b=a.style;a="";"opacity"in b?a=b.opacity:"MozOpacity"in b?a=b.MozOpacity:"filter"in b&&(b=b.filter.match(/alpha\(opacity=([\d.]+)\)/))&&(a=String(b[1]/100));return""==a?a:Number(a)};goog.style.setOpacity=function(a,b){var c=a.style;"opacity"in c?c.opacity=b:"MozOpacity"in c?c.MozOpacity=b:"filter"in c&&(c.filter=""===b?"":"alpha(opacity="+100*b+")")};
  goog.style.setTransparentBackgroundImage=function(a,b){var c=a.style;goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?c.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+b+'", sizingMethod="crop")':(c.backgroundImage="url("+b+")",c.backgroundPosition="top left",c.backgroundRepeat="no-repeat")};goog.style.clearTransparentBackgroundImage=function(a){a=a.style;"filter"in a?a.filter="":a.backgroundImage="none"};
  goog.style.showElement=function(a,b){goog.style.setElementShown(a,b)};goog.style.setElementShown=function(a,b){a.style.display=b?"":"none"};goog.style.isElementShown=function(a){return"none"!=a.style.display};
  goog.style.installStyles=function(a,b){var c=goog.dom.getDomHelper(b),d=null,e=c.getDocument();goog.userAgent.IE&&e.createStyleSheet?(d=e.createStyleSheet(),goog.style.setStyles(d,a)):(e=c.getElementsByTagNameAndClass("head")[0],e||(d=c.getElementsByTagNameAndClass("body")[0],e=c.createDom("head"),d.parentNode.insertBefore(e,d)),d=c.createDom("style"),goog.style.setStyles(d,a),c.appendChild(e,d));return d};goog.style.uninstallStyles=function(a){goog.dom.removeNode(a.ownerNode||a.owningElement||a)};
  goog.style.setStyles=function(a,b){goog.userAgent.IE&&goog.isDef(a.cssText)?a.cssText=b:a.innerHTML=b};goog.style.setPreWrap=function(a){a=a.style;goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?(a.whiteSpace="pre",a.wordWrap="break-word"):a.whiteSpace=goog.userAgent.GECKO?"-moz-pre-wrap":"pre-wrap"};
  goog.style.setInlineBlock=function(a){a=a.style;a.position="relative";goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("8")?(a.zoom="1",a.display="inline"):a.display=goog.userAgent.GECKO?goog.userAgent.isVersionOrHigher("1.9a")?"inline-block":"-moz-inline-box":"inline-block"};goog.style.isRightToLeft=function(a){return"rtl"==goog.style.getStyle_(a,"direction")};goog.style.unselectableStyle_=goog.userAgent.GECKO?"MozUserSelect":goog.userAgent.WEBKIT?"WebkitUserSelect":null;
  goog.style.isUnselectable=function(a){return goog.style.unselectableStyle_?"none"==a.style[goog.style.unselectableStyle_].toLowerCase():goog.userAgent.IE||goog.userAgent.OPERA?"on"==a.getAttribute("unselectable"):!1};
  goog.style.setUnselectable=function(a,b,c){c=c?null:a.getElementsByTagName("*");var d=goog.style.unselectableStyle_;if(d){if(b=b?"none":"",a.style[d]=b,c){a=0;for(var e;e=c[a];a++)e.style[d]=b}}else if(goog.userAgent.IE||goog.userAgent.OPERA)if(b=b?"on":"",a.setAttribute("unselectable",b),c)for(a=0;e=c[a];a++)e.setAttribute("unselectable",b)};goog.style.getBorderBoxSize=function(a){return new goog.math.Size(a.offsetWidth,a.offsetHeight)};
  goog.style.setBorderBoxSize=function(a,b){var c=goog.dom.getOwnerDocument(a),d=goog.dom.getDomHelper(c).isCss1CompatMode();if(!goog.userAgent.IE||d&&goog.userAgent.isVersionOrHigher("8"))goog.style.setBoxSizingSize_(a,b,"border-box");else if(c=a.style,d){var d=goog.style.getPaddingBox(a),e=goog.style.getBorderBox(a);c.pixelWidth=b.width-e.left-d.left-d.right-e.right;c.pixelHeight=b.height-e.top-d.top-d.bottom-e.bottom}else c.pixelWidth=b.width,c.pixelHeight=b.height};
  goog.style.getContentBoxSize=function(a){var b=goog.dom.getOwnerDocument(a),c=goog.userAgent.IE&&a.currentStyle;if(c&&goog.dom.getDomHelper(b).isCss1CompatMode()&&"auto"!=c.width&&"auto"!=c.height&&!c.boxSizing)return b=goog.style.getIePixelValue_(a,c.width,"width","pixelWidth"),a=goog.style.getIePixelValue_(a,c.height,"height","pixelHeight"),new goog.math.Size(b,a);c=goog.style.getBorderBoxSize(a);b=goog.style.getPaddingBox(a);a=goog.style.getBorderBox(a);return new goog.math.Size(c.width-a.left-
  b.left-b.right-a.right,c.height-a.top-b.top-b.bottom-a.bottom)};
  goog.style.setContentBoxSize=function(a,b){var c=goog.dom.getOwnerDocument(a),d=goog.dom.getDomHelper(c).isCss1CompatMode();if(!goog.userAgent.IE||d&&goog.userAgent.isVersionOrHigher("8"))goog.style.setBoxSizingSize_(a,b,"content-box");else if(c=a.style,d)c.pixelWidth=b.width,c.pixelHeight=b.height;else{var d=goog.style.getPaddingBox(a),e=goog.style.getBorderBox(a);c.pixelWidth=b.width+e.left+d.left+d.right+e.right;c.pixelHeight=b.height+e.top+d.top+d.bottom+e.bottom}};
  goog.style.setBoxSizingSize_=function(a,b,c){a=a.style;goog.userAgent.GECKO?a.MozBoxSizing=c:goog.userAgent.WEBKIT?a.WebkitBoxSizing=c:a.boxSizing=c;a.width=Math.max(b.width,0)+"px";a.height=Math.max(b.height,0)+"px"};goog.style.getIePixelValue_=function(a,b,c,d){if(/^\d+px?$/.test(b))return parseInt(b,10);var e=a.style[c],f=a.runtimeStyle[c];a.runtimeStyle[c]=a.currentStyle[c];a.style[c]=b;b=a.style[d];a.style[c]=e;a.runtimeStyle[c]=f;return b};
  goog.style.getIePixelDistance_=function(a,b){var c=goog.style.getCascadedStyle(a,b);return c?goog.style.getIePixelValue_(a,c,"left","pixelLeft"):0};
  goog.style.getBox_=function(a,b){if(goog.userAgent.IE){var c=goog.style.getIePixelDistance_(a,b+"Left"),d=goog.style.getIePixelDistance_(a,b+"Right"),e=goog.style.getIePixelDistance_(a,b+"Top"),f=goog.style.getIePixelDistance_(a,b+"Bottom");return new goog.math.Box(e,d,f,c)}c=goog.style.getComputedStyle(a,b+"Left");d=goog.style.getComputedStyle(a,b+"Right");e=goog.style.getComputedStyle(a,b+"Top");f=goog.style.getComputedStyle(a,b+"Bottom");return new goog.math.Box(parseFloat(e),parseFloat(d),parseFloat(f),
  parseFloat(c))};goog.style.getPaddingBox=function(a){return goog.style.getBox_(a,"padding")};goog.style.getMarginBox=function(a){return goog.style.getBox_(a,"margin")};goog.style.ieBorderWidthKeywords_={thin:2,medium:4,thick:6};
  goog.style.getIePixelBorder_=function(a,b){if("none"==goog.style.getCascadedStyle(a,b+"Style"))return 0;var c=goog.style.getCascadedStyle(a,b+"Width");return c in goog.style.ieBorderWidthKeywords_?goog.style.ieBorderWidthKeywords_[c]:goog.style.getIePixelValue_(a,c,"left","pixelLeft")};
  goog.style.getBorderBox=function(a){if(goog.userAgent.IE&&!goog.userAgent.isDocumentModeOrHigher(9)){var b=goog.style.getIePixelBorder_(a,"borderLeft"),c=goog.style.getIePixelBorder_(a,"borderRight"),d=goog.style.getIePixelBorder_(a,"borderTop");a=goog.style.getIePixelBorder_(a,"borderBottom");return new goog.math.Box(d,c,a,b)}b=goog.style.getComputedStyle(a,"borderLeftWidth");c=goog.style.getComputedStyle(a,"borderRightWidth");d=goog.style.getComputedStyle(a,"borderTopWidth");a=goog.style.getComputedStyle(a,
  "borderBottomWidth");return new goog.math.Box(parseFloat(d),parseFloat(c),parseFloat(a),parseFloat(b))};goog.style.getFontFamily=function(a){var b=goog.dom.getOwnerDocument(a),c="";if(b.body.createTextRange){b=b.body.createTextRange();b.moveToElementText(a);try{c=b.queryCommandValue("FontName")}catch(d){c=""}}c||(c=goog.style.getStyle_(a,"fontFamily"));a=c.split(",");1<a.length&&(c=a[0]);return goog.string.stripQuotes(c,"\"'")};goog.style.lengthUnitRegex_=/[^\d]+$/;
  goog.style.getLengthUnits=function(a){return(a=a.match(goog.style.lengthUnitRegex_))&&a[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(a){var b=goog.style.getStyle_(a,"fontSize"),c=goog.style.getLengthUnits(b);if(b&&"px"==c)return parseInt(b,10);if(goog.userAgent.IE){if(c in goog.style.ABSOLUTE_CSS_LENGTH_UNITS_)return goog.style.getIePixelValue_(a,b,"left","pixelLeft");if(a.parentNode&&a.parentNode.nodeType==goog.dom.NodeType.ELEMENT&&c in goog.style.CONVERTIBLE_RELATIVE_CSS_UNITS_)return a=a.parentNode,c=goog.style.getStyle_(a,"fontSize"),goog.style.getIePixelValue_(a,b==c?"1em":b,"left","pixelLeft")}c=
  goog.dom.createDom("span",{style:"visibility:hidden;position:absolute;line-height:0;padding:0;margin:0;border:0;height:1em;"});goog.dom.appendChild(a,c);b=c.offsetHeight;goog.dom.removeNode(c);return b};goog.style.parseStyleAttribute=function(a){var b={};goog.array.forEach(a.split(/\s*;\s*/),function(a){a=a.split(/\s*:\s*/);2==a.length&&(b[goog.string.toCamelCase(a[0].toLowerCase())]=a[1])});return b};
  goog.style.toStyleAttribute=function(a){var b=[];goog.object.forEach(a,function(a,d){b.push(goog.string.toSelectorCase(d),":",a,";")});return b.join("")};goog.style.setFloat=function(a,b){a.style[goog.userAgent.IE?"styleFloat":"cssFloat"]=b};goog.style.getFloat=function(a){return a.style[goog.userAgent.IE?"styleFloat":"cssFloat"]||""};
  goog.style.getScrollbarWidth=function(a){var b=goog.dom.createElement("div");a&&(b.className=a);b.style.cssText="overflow:auto;position:absolute;top:0;width:100px;height:100px";a=goog.dom.createElement("div");goog.style.setSize(a,"200px","200px");b.appendChild(a);goog.dom.appendChild(goog.dom.getDocument().body,b);a=b.offsetWidth-b.clientWidth;goog.dom.removeNode(b);return a};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(a){var b;goog.userAgent.IE?b="-ms-transform":goog.userAgent.WEBKIT?b="-webkit-transform":goog.userAgent.OPERA?b="-o-transform":goog.userAgent.GECKO&&(b="-moz-transform");var c;b&&(c=goog.style.getStyle_(a,b));c||(c=goog.style.getStyle_(a,"transform"));return c?(a=c.match(goog.style.MATRIX_TRANSLATION_REGEX_))?new goog.math.Coordinate(parseFloat(a[1]),parseFloat(a[2])):new goog.math.Coordinate(0,0):new goog.math.Coordinate(0,0)};goog.events.EventHandler=function(a){goog.Disposable.call(this);this.handler_=a;this.keys_={}};goog.inherits(goog.events.EventHandler,goog.Disposable);goog.events.EventHandler.typeArray_=[];goog.events.EventHandler.prototype.listen=function(a,b,c,d){return this.listen_(a,b,c,d)};goog.events.EventHandler.prototype.listenWithScope=function(a,b,c,d,e){return this.listen_(a,b,c,d,e)};
  goog.events.EventHandler.prototype.listen_=function(a,b,c,d,e){goog.isArray(b)||(goog.events.EventHandler.typeArray_[0]=b,b=goog.events.EventHandler.typeArray_);for(var f=0;f<b.length;f++){var g=goog.events.listen(a,b[f],c||this.handleEvent,d||!1,e||this.handler_||this);if(!g)break;this.keys_[g.key]=g}return this};goog.events.EventHandler.prototype.listenOnce=function(a,b,c,d){return this.listenOnce_(a,b,c,d)};
  goog.events.EventHandler.prototype.listenOnceWithScope=function(a,b,c,d,e){return this.listenOnce_(a,b,c,d,e)};goog.events.EventHandler.prototype.listenOnce_=function(a,b,c,d,e){if(goog.isArray(b))for(var f=0;f<b.length;f++)this.listenOnce_(a,b[f],c,d,e);else{a=goog.events.listenOnce(a,b,c||this.handleEvent,d,e||this.handler_||this);if(!a)return this;this.keys_[a.key]=a}return this};goog.events.EventHandler.prototype.listenWithWrapper=function(a,b,c,d){return this.listenWithWrapper_(a,b,c,d)};
  goog.events.EventHandler.prototype.listenWithWrapperAndScope=function(a,b,c,d,e){return this.listenWithWrapper_(a,b,c,d,e)};goog.events.EventHandler.prototype.listenWithWrapper_=function(a,b,c,d,e){b.listen(a,c,d,e||this.handler_||this,this);return this};goog.events.EventHandler.prototype.getListenerCount=function(){var a=0,b;for(b in this.keys_)Object.prototype.hasOwnProperty.call(this.keys_,b)&&a++;return a};
  goog.events.EventHandler.prototype.unlisten=function(a,b,c,d,e){if(goog.isArray(b))for(var f=0;f<b.length;f++)this.unlisten(a,b[f],c,d,e);else if(a=goog.events.getListener(a,b,c||this.handleEvent,d,e||this.handler_||this))goog.events.unlistenByKey(a),delete this.keys_[a.key];return this};goog.events.EventHandler.prototype.unlistenWithWrapper=function(a,b,c,d,e){b.unlisten(a,c,d,e||this.handler_||this,this);return this};
  goog.events.EventHandler.prototype.removeAll=function(){goog.object.forEach(this.keys_,goog.events.unlistenByKey);this.keys_={}};goog.events.EventHandler.prototype.disposeInternal=function(){goog.events.EventHandler.superClass_.disposeInternal.call(this);this.removeAll()};goog.events.EventHandler.prototype.handleEvent=function(a){throw Error("EventHandler.handleEvent not implemented");};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.events.EventTarget=function(){goog.Disposable.call(this);this.eventTargetListeners_=new goog.events.ListenerMap(this);this.actualEventTarget_=this};goog.inherits(goog.events.EventTarget,goog.Disposable);goog.events.Listenable.addImplementation(goog.events.EventTarget);goog.events.EventTarget.MAX_ANCESTORS_=1E3;goog.events.EventTarget.prototype.parentEventTarget_=null;goog.events.EventTarget.prototype.getParentEventTarget=function(){return this.parentEventTarget_};
  goog.events.EventTarget.prototype.setParentEventTarget=function(a){this.parentEventTarget_=a};goog.events.EventTarget.prototype.addEventListener=function(a,b,c,d){goog.events.listen(this,a,b,c,d)};goog.events.EventTarget.prototype.removeEventListener=function(a,b,c,d){goog.events.unlisten(this,a,b,c,d)};
  goog.events.EventTarget.prototype.dispatchEvent=function(a){this.assertInitialized_();var b,c=this.getParentEventTarget();if(c){b=[];for(var d=1;c;c=c.getParentEventTarget())b.push(c),goog.asserts.assert(++d<goog.events.EventTarget.MAX_ANCESTORS_,"infinite loop")}return goog.events.EventTarget.dispatchEventInternal_(this.actualEventTarget_,a,b)};
  goog.events.EventTarget.prototype.disposeInternal=function(){goog.events.EventTarget.superClass_.disposeInternal.call(this);this.removeAllListeners();this.parentEventTarget_=null};goog.events.EventTarget.prototype.listen=function(a,b,c,d){this.assertInitialized_();return this.eventTargetListeners_.add(String(a),b,!1,c,d)};goog.events.EventTarget.prototype.listenOnce=function(a,b,c,d){return this.eventTargetListeners_.add(String(a),b,!0,c,d)};
  goog.events.EventTarget.prototype.unlisten=function(a,b,c,d){return this.eventTargetListeners_.remove(String(a),b,c,d)};goog.events.EventTarget.prototype.unlistenByKey=function(a){return this.eventTargetListeners_.removeByKey(a)};goog.events.EventTarget.prototype.removeAllListeners=function(a){return this.eventTargetListeners_?this.eventTargetListeners_.removeAll(a):0};
  goog.events.EventTarget.prototype.fireListeners=function(a,b,c){a=this.eventTargetListeners_.listeners[String(a)];if(!a)return!0;a=goog.array.clone(a);for(var d=!0,e=0;e<a.length;++e){var f=a[e];if(f&&!f.removed&&f.capture==b){var g=f.listener,h=f.handler||f.src;f.callOnce&&this.unlistenByKey(f);d=!1!==g.call(h,c)&&d}}return d&&!1!=c.returnValue_};goog.events.EventTarget.prototype.getListeners=function(a,b){return this.eventTargetListeners_.getListeners(String(a),b)};
  goog.events.EventTarget.prototype.getListener=function(a,b,c,d){return this.eventTargetListeners_.getListener(String(a),b,c,d)};goog.events.EventTarget.prototype.hasListener=function(a,b){var c=goog.isDef(a)?String(a):void 0;return this.eventTargetListeners_.hasListener(c,b)};goog.events.EventTarget.prototype.setTargetForTesting=function(a){this.actualEventTarget_=a};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(a,b,c){var d=b.type||b;if(goog.isString(b))b=new goog.events.Event(b,a);else if(b instanceof goog.events.Event)b.target=b.target||a;else{var e=b;b=new goog.events.Event(d,a);goog.object.extend(b,e)}var e=!0,f;if(c)for(var g=c.length-1;!b.propagationStopped_&&0<=g;g--)f=b.currentTarget=c[g],e=f.fireListeners(d,!0,b)&&e;b.propagationStopped_||(f=b.currentTarget=a,e=f.fireListeners(d,!0,b)&&e,b.propagationStopped_||(e=f.fireListeners(d,!1,b)&&e));
  if(c)for(g=0;!b.propagationStopped_&&g<c.length;g++)f=b.currentTarget=c[g],e=f.fireListeners(d,!1,b)&&e;return e};goog.ui.Component=function(a){goog.events.EventTarget.call(this);this.dom_=a||goog.dom.getDomHelper();this.rightToLeft_=goog.ui.Component.defaultRightToLeft_};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:-1==goog.ui.Component.DEFAULT_BIDI_DIR?!0: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(a,b){switch(a){case goog.ui.Component.State.DISABLED:return b?goog.ui.Component.EventType.DISABLE:goog.ui.Component.EventType.ENABLE;case goog.ui.Component.State.HOVER:return b?goog.ui.Component.EventType.HIGHLIGHT:goog.ui.Component.EventType.UNHIGHLIGHT;case goog.ui.Component.State.ACTIVE:return b?goog.ui.Component.EventType.ACTIVATE:goog.ui.Component.EventType.DEACTIVATE;case goog.ui.Component.State.SELECTED:return b?goog.ui.Component.EventType.SELECT:
  goog.ui.Component.EventType.UNSELECT;case goog.ui.Component.State.CHECKED:return b?goog.ui.Component.EventType.CHECK:goog.ui.Component.EventType.UNCHECK;case goog.ui.Component.State.FOCUSED:return b?goog.ui.Component.EventType.FOCUS:goog.ui.Component.EventType.BLUR;case goog.ui.Component.State.OPENED:return b?goog.ui.Component.EventType.OPEN:goog.ui.Component.EventType.CLOSE}throw Error(goog.ui.Component.Error.STATE_INVALID);};
  goog.ui.Component.setDefaultRightToLeft=function(a){goog.ui.Component.defaultRightToLeft_=a};goog.ui.Component.prototype.id_=null;goog.ui.Component.prototype.inDocument_=!1;goog.ui.Component.prototype.element_=null;goog.ui.Component.prototype.rightToLeft_=null;goog.ui.Component.prototype.model_=null;goog.ui.Component.prototype.parent_=null;goog.ui.Component.prototype.children_=null;goog.ui.Component.prototype.childIndex_=null;goog.ui.Component.prototype.wasDecorated_=!1;
  goog.ui.Component.prototype.getId=function(){return this.id_||(this.id_=this.idGenerator_.getNextUniqueId())};goog.ui.Component.prototype.setId=function(a){this.parent_&&this.parent_.childIndex_&&(goog.object.remove(this.parent_.childIndex_,this.id_),goog.object.add(this.parent_.childIndex_,a,this));this.id_=a};goog.ui.Component.prototype.getElement=function(){return this.element_};
  goog.ui.Component.prototype.getElementStrict=function(){var a=this.element_;goog.asserts.assert(a,"Can not call getElementStrict before rendering/decorating.");return a};goog.ui.Component.prototype.setElementInternal=function(a){this.element_=a};goog.ui.Component.prototype.getElementsByClass=function(a){return this.element_?this.dom_.getElementsByClass(a,this.element_):[]};goog.ui.Component.prototype.getElementByClass=function(a){return this.element_?this.dom_.getElementByClass(a,this.element_):null};
  goog.ui.Component.prototype.getRequiredElementByClass=function(a){var b=this.getElementByClass(a);goog.asserts.assert(b,"Expected element in component with class: %s",a);return b};goog.ui.Component.prototype.getHandler=function(){this.googUiComponentHandler_||(this.googUiComponentHandler_=new goog.events.EventHandler(this));return this.googUiComponentHandler_};
  goog.ui.Component.prototype.setParent=function(a){if(this==a)throw Error(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);if(a&&this.parent_&&this.id_&&this.parent_.getChild(this.id_)&&this.parent_!=a)throw Error(goog.ui.Component.Error.PARENT_UNABLE_TO_BE_SET);this.parent_=a;goog.ui.Component.superClass_.setParentEventTarget.call(this,a)};goog.ui.Component.prototype.getParent=function(){return this.parent_};
  goog.ui.Component.prototype.setParentEventTarget=function(a){if(this.parent_&&this.parent_!=a)throw Error(goog.ui.Component.Error.NOT_SUPPORTED);goog.ui.Component.superClass_.setParentEventTarget.call(this,a)};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(a){this.render_(a)};
  goog.ui.Component.prototype.renderBefore=function(a){this.render_(a.parentNode,a)};goog.ui.Component.prototype.render_=function(a,b){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.element_||this.createDom();a?a.insertBefore(this.element_,b||null):this.dom_.getDocument().body.appendChild(this.element_);this.parent_&&!this.parent_.isInDocument()||this.enterDocument()};
  goog.ui.Component.prototype.decorate=function(a){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);if(a&&this.canDecorate(a)){this.wasDecorated_=!0;var b=goog.dom.getOwnerDocument(a);this.dom_&&this.dom_.getDocument()==b||(this.dom_=goog.dom.getDomHelper(a));this.decorateInternal(a);goog.ui.Component.ALLOW_DETACHED_DECORATION&&!goog.dom.contains(b,a)||this.enterDocument()}else throw Error(goog.ui.Component.Error.DECORATE_INVALID);};goog.ui.Component.prototype.canDecorate=function(a){return!0};
  goog.ui.Component.prototype.wasDecorated=function(){return this.wasDecorated_};goog.ui.Component.prototype.decorateInternal=function(a){this.element_=a};goog.ui.Component.prototype.enterDocument=function(){this.inDocument_=!0;this.forEachChild(function(a){!a.isInDocument()&&a.getElement()&&a.enterDocument()})};
  goog.ui.Component.prototype.exitDocument=function(){this.forEachChild(function(a){a.isInDocument()&&a.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(a){a.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(a){return this.getId()+"."+a};goog.ui.Component.prototype.makeIds=function(a){var b={},c;for(c in a)b[c]=this.makeId(a[c]);return b};goog.ui.Component.prototype.getModel=function(){return this.model_};goog.ui.Component.prototype.setModel=function(a){this.model_=a};goog.ui.Component.prototype.getFragmentFromId=function(a){return a.substring(this.getId().length+1)};
  goog.ui.Component.prototype.getElementByFragment=function(a){if(!this.inDocument_)throw Error(goog.ui.Component.Error.NOT_IN_DOCUMENT);return this.dom_.getElement(this.makeId(a))};goog.ui.Component.prototype.addChild=function(a,b){this.addChildAt(a,this.getChildCount(),b)};
  goog.ui.Component.prototype.addChildAt=function(a,b,c){goog.asserts.assert(!!a,"Provided element must not be null.");if(a.inDocument_&&(c||!this.inDocument_))throw Error(goog.ui.Component.Error.ALREADY_RENDERED);if(0>b||b>this.getChildCount())throw Error(goog.ui.Component.Error.CHILD_INDEX_OUT_OF_BOUNDS);this.childIndex_&&this.children_||(this.childIndex_={},this.children_=[]);a.getParent()==this?(goog.object.set(this.childIndex_,a.getId(),a),goog.array.remove(this.children_,a)):goog.object.add(this.childIndex_,
  a.getId(),a);a.setParent(this);goog.array.insertAt(this.children_,a,b);a.inDocument_&&this.inDocument_&&a.getParent()==this?(c=this.getContentElement(),c.insertBefore(a.getElement(),c.childNodes[b]||null)):c?(this.element_||this.createDom(),b=this.getChildAt(b+1),a.render_(this.getContentElement(),b?b.element_:null)):this.inDocument_&&!a.inDocument_&&a.element_&&a.element_.parentNode&&a.element_.parentNode.nodeType==goog.dom.NodeType.ELEMENT&&a.enterDocument()};
  goog.ui.Component.prototype.getContentElement=function(){return this.element_};goog.ui.Component.prototype.isRightToLeft=function(){null==this.rightToLeft_&&(this.rightToLeft_=goog.style.isRightToLeft(this.inDocument_?this.element_:this.dom_.getDocument().body));return this.rightToLeft_};goog.ui.Component.prototype.setRightToLeft=function(a){if(this.inDocument_)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.rightToLeft_=a};
  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 a=[];this.forEachChild(function(b){a.push(b.getId())});return a};goog.ui.Component.prototype.getChild=function(a){return this.childIndex_&&a?goog.object.get(this.childIndex_,a)||null:null};
  goog.ui.Component.prototype.getChildAt=function(a){return this.children_?this.children_[a]||null:null};goog.ui.Component.prototype.forEachChild=function(a,b){this.children_&&goog.array.forEach(this.children_,a,b)};goog.ui.Component.prototype.indexOfChild=function(a){return this.children_&&a?goog.array.indexOf(this.children_,a):-1};
  goog.ui.Component.prototype.removeChild=function(a,b){if(a){var c=goog.isString(a)?a:a.getId();a=this.getChild(c);c&&a&&(goog.object.remove(this.childIndex_,c),goog.array.remove(this.children_,a),b&&(a.exitDocument(),a.element_&&goog.dom.removeNode(a.element_)),a.setParent(null))}if(!a)throw Error(goog.ui.Component.Error.NOT_OUR_CHILD);return a};goog.ui.Component.prototype.removeChildAt=function(a,b){return this.removeChild(this.getChildAt(a),b)};
  goog.ui.Component.prototype.removeChildren=function(a){for(var b=[];this.hasChildren();)b.push(this.removeChildAt(0,a));return b};goog.Timer=function(a,b){goog.events.EventTarget.call(this);this.interval_=a||1;this.timerObject_=b||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.prototype.enabled=!1;goog.Timer.defaultTimerObject=goog.global;goog.Timer.intervalScale=0.8;goog.Timer.prototype.timer_=null;goog.Timer.prototype.getInterval=function(){return this.interval_};
  goog.Timer.prototype.setInterval=function(a){this.interval_=a;this.timer_&&this.enabled?(this.stop(),this.start()):this.timer_&&this.stop()};
  goog.Timer.prototype.tick_=function(){if(this.enabled){var a=goog.now()-this.last_;0<a&&a<this.interval_*goog.Timer.intervalScale?this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_-a):(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(a,b,c){if(goog.isFunction(a))c&&(a=goog.bind(a,c));else if(a&&"function"==typeof a.handleEvent)a=goog.bind(a.handleEvent,a);else throw Error("Invalid listener argument");return b>goog.Timer.MAX_TIMEOUT_?-1:goog.Timer.defaultTimerObject.setTimeout(a,b||0)};goog.Timer.clear=function(a){goog.Timer.defaultTimerObject.clearTimeout(a)};goog.a11y={};goog.a11y.aria={};
  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(){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"));return goog.a11y.aria.DefaultStateValueMap_};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",TIMER:"timer",TOOLBAR:"toolbar",TOOLTIP:"tooltip",TREE:"tree",TREEGRID:"treegrid",TREEITEM:"treeitem"};goog.a11y.aria.ARIA_PREFIX_="aria-";goog.a11y.aria.ROLE_ATTRIBUTE_="role";goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_=[goog.dom.TagName.A,goog.dom.TagName.AREA,goog.dom.TagName.BUTTON,goog.dom.TagName.HEAD,goog.dom.TagName.INPUT,goog.dom.TagName.LINK,goog.dom.TagName.MENU,goog.dom.TagName.META,goog.dom.TagName.OPTGROUP,goog.dom.TagName.OPTION,goog.dom.TagName.PROGRESS,goog.dom.TagName.STYLE,goog.dom.TagName.SELECT,goog.dom.TagName.SOURCE,goog.dom.TagName.TEXTAREA,goog.dom.TagName.TITLE,goog.dom.TagName.TRACK];
  goog.a11y.aria.setRole=function(a,b){b?(goog.asserts.ENABLE_ASSERTS&&goog.asserts.assert(goog.object.containsValue(goog.a11y.aria.Role,b),"No such ARIA role "+b),a.setAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_,b)):goog.a11y.aria.removeRole(a)};goog.a11y.aria.getRole=function(a){return a.getAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_)||null};goog.a11y.aria.removeRole=function(a){a.removeAttribute(goog.a11y.aria.ROLE_ATTRIBUTE_)};
  goog.a11y.aria.setState=function(a,b,c){goog.isArrayLike(c)&&(c=c.join(" "));var d=goog.a11y.aria.getAriaAttributeName_(b);""===c||void 0==c?(c=goog.a11y.aria.datatables.getDefaultValuesMap(),b in c?a.setAttribute(d,c[b]):a.removeAttribute(d)):a.setAttribute(d,c)};goog.a11y.aria.removeState=function(a,b){a.removeAttribute(goog.a11y.aria.getAriaAttributeName_(b))};goog.a11y.aria.getState=function(a,b){var c=a.getAttribute(goog.a11y.aria.getAriaAttributeName_(b));return null==c||void 0==c?"":String(c)};
  goog.a11y.aria.getActiveDescendant=function(a){var b=goog.a11y.aria.getState(a,goog.a11y.aria.State.ACTIVEDESCENDANT);return goog.dom.getOwnerDocument(a).getElementById(b)};goog.a11y.aria.setActiveDescendant=function(a,b){var c="";b&&(c=b.id,goog.asserts.assert(c,"The active element should have an id."));goog.a11y.aria.setState(a,goog.a11y.aria.State.ACTIVEDESCENDANT,c)};goog.a11y.aria.getLabel=function(a){return goog.a11y.aria.getState(a,goog.a11y.aria.State.LABEL)};
  goog.a11y.aria.setLabel=function(a,b){goog.a11y.aria.setState(a,goog.a11y.aria.State.LABEL,b)};goog.a11y.aria.assertRoleIsSetInternalUtil=function(a,b){if(!goog.array.contains(goog.a11y.aria.TAGS_WITH_ASSUMED_ROLES_,a.tagName)){var c=goog.a11y.aria.getRole(a);goog.asserts.assert(null!=c,"The element ARIA role cannot be null.");goog.asserts.assert(goog.array.contains(b,c),'Non existing or incorrect role set for element.The role set is "'+c+'". The role should be any of "'+b+'". Check the ARIA specification for more details http://www.w3.org/TR/wai-aria/roles.')}};
  goog.a11y.aria.getStateBoolean=function(a,b){var c=a.getAttribute(goog.a11y.aria.getAriaAttributeName_(b));goog.asserts.assert(goog.isBoolean(c)||null==c||"true"==c||"false"==c);return null==c?c:goog.isBoolean(c)?c:"true"==c};goog.a11y.aria.getStateNumber=function(a,b){var c=a.getAttribute(goog.a11y.aria.getAriaAttributeName_(b));goog.asserts.assert((null==c||!isNaN(Number(c)))&&!goog.isBoolean(c));return null==c?null:Number(c)};
  goog.a11y.aria.getStateString=function(a,b){var c=a.getAttribute(goog.a11y.aria.getAriaAttributeName_(b));goog.asserts.assert((null==c||goog.isString(c))&&isNaN(Number(c))&&"true"!=c&&"false"!=c);return null==c?null:c};goog.a11y.aria.getStringArrayStateInternalUtil=function(a,b){var c=a.getAttribute(goog.a11y.aria.getAriaAttributeName_(b));return goog.a11y.aria.splitStringOnWhitespace_(c)};goog.a11y.aria.splitStringOnWhitespace_=function(a){return a?a.split(/\s+/):[]};
  goog.a11y.aria.getAriaAttributeName_=function(a){goog.asserts.ENABLE_ASSERTS&&(goog.asserts.assert(a,"ARIA attribute cannot be empty."),goog.asserts.assert(goog.object.containsValue(goog.a11y.aria.State,a),"No such ARIA attribute "+a));return goog.a11y.aria.ARIA_PREFIX_+a};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,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,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,PHANTOM:255};
  goog.events.KeyCodes.isTextModifyingKeyEvent=function(a){if(a.altKey&&!a.ctrlKey||a.metaKey||a.keyCode>=goog.events.KeyCodes.F1&&a.keyCode<=goog.events.KeyCodes.F12)return!1;switch(a.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.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 a.keyCode<goog.events.KeyCodes.FIRST_MEDIA_KEY||a.keyCode>goog.events.KeyCodes.LAST_MEDIA_KEY}};
  goog.events.KeyCodes.firesKeyPressEvent=function(a,b,c,d,e){if(!(goog.userAgent.IE||goog.userAgent.WEBKIT&&goog.userAgent.isVersionOrHigher("525")))return!0;if(goog.userAgent.MAC&&e)return goog.events.KeyCodes.isCharacterKey(a);if(e&&!d)return!1;goog.isNumber(b)&&(b=goog.events.KeyCodes.normalizeKeyCode(b));if(!c&&(b==goog.events.KeyCodes.CTRL||b==goog.events.KeyCodes.ALT||goog.userAgent.MAC&&b==goog.events.KeyCodes.META))return!1;if(goog.userAgent.WEBKIT&&d&&c)switch(a){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&&
  d&&b==a)return!1;switch(a){case goog.events.KeyCodes.ENTER:return!(goog.userAgent.IE&&goog.userAgent.isDocumentModeOrHigher(9));case goog.events.KeyCodes.ESC:return!goog.userAgent.WEBKIT}return goog.events.KeyCodes.isCharacterKey(a)};
  goog.events.KeyCodes.isCharacterKey=function(a){if(a>=goog.events.KeyCodes.ZERO&&a<=goog.events.KeyCodes.NINE||a>=goog.events.KeyCodes.NUM_ZERO&&a<=goog.events.KeyCodes.NUM_MULTIPLY||a>=goog.events.KeyCodes.A&&a<=goog.events.KeyCodes.Z||goog.userAgent.WEBKIT&&0==a)return!0;switch(a){case goog.events.KeyCodes.SPACE:case goog.events.KeyCodes.QUESTION_MARK: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(a){return goog.userAgent.GECKO?goog.events.KeyCodes.normalizeGeckoKeyCode(a):goog.userAgent.MAC&&goog.userAgent.WEBKIT?goog.events.KeyCodes.normalizeMacWebKitKeyCode(a):a};
  goog.events.KeyCodes.normalizeGeckoKeyCode=function(a){switch(a){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 a}};
  goog.events.KeyCodes.normalizeMacWebKitKeyCode=function(a){switch(a){case goog.events.KeyCodes.MAC_WK_CMD_RIGHT:return goog.events.KeyCodes.META;default:return a}};goog.ui.tree={};goog.ui.tree.BaseNode=function(a,b,c){goog.ui.Component.call(this,c);this.config_=b||goog.ui.tree.TreeControl.defaultConfig;this.html_=a};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.selected_=!1;goog.ui.tree.BaseNode.prototype.expanded_=!1;
  goog.ui.tree.BaseNode.prototype.toolTip_=null;goog.ui.tree.BaseNode.prototype.afterLabelHtml_="";goog.ui.tree.BaseNode.prototype.isUserCollapsible_=!0;goog.ui.tree.BaseNode.prototype.depth_=-1;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 a=this.getElement();if(a){var b=this.getLabelElement();b&&!b.id&&(b.id=this.getId()+".label");goog.a11y.aria.setRole(a,"treeitem");goog.a11y.aria.setState(a,"selected",!1);goog.a11y.aria.setState(a,"expanded",!1);goog.a11y.aria.setState(a,"level",this.getDepth());b&&goog.a11y.aria.setState(a,"labelledby",b.id);(a=this.getIconElement())&&goog.a11y.aria.setRole(a,"presentation");(a=this.getExpandIconElement())&&goog.a11y.aria.setRole(a,
  "presentation");if(a=this.getChildrenElement())if(goog.a11y.aria.setRole(a,"group"),a.hasChildNodes())for(a=this.getChildCount(),b=1;b<=a;b++){var c=this.getChildAt(b-1).getElement();goog.asserts.assert(c,"The child element cannot be null");goog.a11y.aria.setState(c,"setsize",a);goog.a11y.aria.setState(c,"posinset",b)}}};goog.ui.tree.BaseNode.prototype.createDom=function(){var a=new goog.string.StringBuffer;this.toHtml(a);a=this.getDomHelper().htmlToDocumentFragment(a.toString());this.setElementInternal(a)};
  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(a,b,c){goog.asserts.assert(!a.getParent());c=this.getChildAt(b-1);var d=this.getChildAt(b);goog.ui.tree.BaseNode.superClass_.addChildAt.call(this,a,b);a.previousSibling_=c;a.nextSibling_=d;c?c.nextSibling_=a:this.firstChild_=a;d?d.previousSibling_=a:this.lastChild_=a;(b=this.getTree())&&a.setTreeInternal(b);a.setDepth_(this.getDepth()+1);if(this.getElement()&&(this.updateExpandIcon(),this.getExpanded())){b=this.getChildrenElement();a.getElement()||
  a.createDom();var e=a.getElement(),f=d&&d.getElement();b.insertBefore(e,f);this.isInDocument()&&a.enterDocument();d||(c?c.updateExpandIcon():(goog.style.setElementShown(b,!0),this.setExpanded(this.getExpanded())))}};goog.ui.tree.BaseNode.prototype.add=function(a,b){goog.asserts.assert(!b||b.getParent()==this,"Can only add nodes before siblings");a.getParent()&&a.getParent().removeChild(a);this.addChildAt(a,b?this.indexOfChild(b):this.getChildCount());return a};
  goog.ui.tree.BaseNode.prototype.removeChild=function(a,b){var c=this.getTree(),d=c?c.getSelectedItem():null;if(d==a||a.contains(d))c.hasFocus()?(this.select(),goog.Timer.callOnce(this.onTimeoutSelect_,10,this)):this.select();goog.ui.tree.BaseNode.superClass_.removeChild.call(this,a);this.lastChild_==a&&(this.lastChild_=a.previousSibling_);this.firstChild_==a&&(this.firstChild_=a.nextSibling_);a.previousSibling_&&(a.previousSibling_.nextSibling_=a.nextSibling_);a.nextSibling_&&(a.nextSibling_.previousSibling_=
  a.previousSibling_);d=a.isLastSibling();a.tree_=null;a.depth_=-1;if(c&&(c.removeNode(this),this.isInDocument())){c=this.getChildrenElement();if(a.isInDocument()){var e=a.getElement();c.removeChild(e);a.exitDocument()}d&&(d=this.getLastChild())&&d.updateExpandIcon();this.hasChildren()||(c.style.display="none",this.updateExpandIcon(),this.updateIcon_())}return a};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.getDepth=function(){var a=this.depth_;0>a&&(a=this.computeDepth_(),this.setDepth_(a));return a};goog.ui.tree.BaseNode.prototype.computeDepth_=function(){var a=this.getParent();return a?a.getDepth()+1:0};goog.ui.tree.BaseNode.prototype.setDepth_=function(a){if(a!=this.depth_){this.depth_=a;var b=this.getRowElement();if(b){var c=this.getPixelIndent_()+"px";this.isRightToLeft()?b.style.paddingRight=c:b.style.paddingLeft=c}this.forEachChild(function(b){b.setDepth_(a+1)})}};
  goog.ui.tree.BaseNode.prototype.contains=function(a){for(;a;){if(a==this)return!0;a=a.getParent()}return!1};goog.ui.tree.BaseNode.EMPTY_CHILDREN_=[];goog.ui.tree.BaseNode.prototype.getChildren=function(){var a=[];this.forEachChild(function(b){a.push(b)});return a};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 a=this.getTree();a&&a.setSelectedItem(this)};goog.ui.tree.BaseNode.prototype.deselect=goog.nullFunction;
  goog.ui.tree.BaseNode.prototype.setSelectedInternal=function(a){if(this.selected_!=a){this.selected_=a;this.updateRow();var b=this.getElement();b&&(goog.a11y.aria.setState(b,"selected",a),a&&(a=this.getTree().getElement(),goog.asserts.assert(a,"The DOM element for the tree cannot be null"),goog.a11y.aria.setState(a,"activedescendant",this.getId())))}};goog.ui.tree.BaseNode.prototype.getExpanded=function(){return this.expanded_};
  goog.ui.tree.BaseNode.prototype.setExpandedInternal=function(a){this.expanded_=a};
  goog.ui.tree.BaseNode.prototype.setExpanded=function(a){var b=a!=this.expanded_;if(!b||this.dispatchEvent(a?goog.ui.tree.BaseNode.EventType.BEFORE_EXPAND:goog.ui.tree.BaseNode.EventType.BEFORE_COLLAPSE)){var c;this.expanded_=a;c=this.getTree();var d=this.getElement();if(this.hasChildren()){if(!a&&c&&this.contains(c.getSelectedItem())&&this.select(),d){if(c=this.getChildrenElement())if(goog.style.setElementShown(c,a),a&&this.isInDocument()&&!c.hasChildNodes()){var e=new goog.string.StringBuffer;this.forEachChild(function(a){a.toHtml(e)});
  c.innerHTML=e.toString();this.forEachChild(function(a){a.enterDocument()})}this.updateExpandIcon()}}else(c=this.getChildrenElement())&&goog.style.setElementShown(c,!1);d&&(this.updateIcon_(),goog.a11y.aria.setState(d,"expanded",a));b&&this.dispatchEvent(a?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(a){a.collapseAll()})};goog.ui.tree.BaseNode.prototype.collapseAll=function(){this.collapseChildren();this.collapse()};goog.ui.tree.BaseNode.prototype.expandChildren=function(){this.forEachChild(function(a){a.expandAll()})};goog.ui.tree.BaseNode.prototype.expandAll=function(){this.expandChildren();this.expand()};
  goog.ui.tree.BaseNode.prototype.reveal=function(){var a=this.getParent();a&&(a.setExpanded(!0),a.reveal())};goog.ui.tree.BaseNode.prototype.setIsUserCollapsible=function(a){(this.isUserCollapsible_=a)||this.expand();this.getElement()&&this.updateExpandIcon()};goog.ui.tree.BaseNode.prototype.isUserCollapsible=function(){return this.isUserCollapsible_};
  goog.ui.tree.BaseNode.prototype.toHtml=function(a){var b=this.getTree(),b=!b.getShowLines()||b==this.getParent()&&!b.getShowRootLines()?this.config_.cssChildrenNoLines:this.config_.cssChildren,c=this.getExpanded()&&this.hasChildren();a.append('<div class="',this.config_.cssItem,'" id="',this.getId(),'">',this.getRowHtml(),'<div class="',b,'" style="',this.getLineStyle(),c?"":"display:none;",'">');c&&this.forEachChild(function(b){b.toHtml(a)});a.append("</div></div>")};
  goog.ui.tree.BaseNode.prototype.getPixelIndent_=function(){return Math.max(0,(this.getDepth()-1)*this.config_.indentWidth)};goog.ui.tree.BaseNode.prototype.getRowHtml=function(){var a=new goog.string.StringBuffer;a.append('<div class="',this.getRowClassName(),'" style="padding-',this.isRightToLeft()?"right:":"left:",this.getPixelIndent_(),'px">',this.getExpandIconHtml(),this.getIconHtml(),this.getLabelHtml(),"</div>");return a.toString()};
  goog.ui.tree.BaseNode.prototype.getRowClassName=function(){var a;a=this.isSelected()?" "+this.config_.cssSelectedRow:"";return this.config_.cssTreeRow+a};goog.ui.tree.BaseNode.prototype.getLabelHtml=function(){var a=this.getToolTip(),b=new goog.string.StringBuffer;b.append('<span class="',this.config_.cssItemLabel,'"',a?' title="'+goog.string.htmlEscape(a)+'"':"",">",this.getHtml(),"</span>","<span>",this.getAfterLabelHtml(),"</span>");return b.toString()};
  goog.ui.tree.BaseNode.prototype.getAfterLabelHtml=function(){return this.afterLabelHtml_};goog.ui.tree.BaseNode.prototype.setAfterLabelHtml=function(a){this.afterLabelHtml_=a;var b=this.getAfterLabelElement();b&&(b.innerHTML=a)};goog.ui.tree.BaseNode.prototype.getIconHtml=function(){return'<span style="display:inline-block" class="'+this.getCalculatedIconClass()+'"></span>'};
  goog.ui.tree.BaseNode.prototype.getExpandIconHtml=function(){return'<span type="expand" style="display:inline-block" class="'+this.getExpandIconClass()+'"></span>'};
  goog.ui.tree.BaseNode.prototype.getExpandIconClass=function(){var a=this.getTree(),b=!a.getShowLines()||a==this.getParent()&&!a.getShowRootLines(),c=this.config_,d=new goog.string.StringBuffer;d.append(c.cssTreeIcon," ",c.cssExpandTreeIcon," ");if(this.hasChildren()){var e=0;a.getShowExpandIcons()&&this.isUserCollapsible_&&(e=this.getExpanded()?2:1);b||(e=this.isLastSibling()?e+4:e+8);switch(e){case 1:d.append(c.cssExpandTreeIconPlus);break;case 2:d.append(c.cssExpandTreeIconMinus);break;case 4:d.append(c.cssExpandTreeIconL);
  break;case 5:d.append(c.cssExpandTreeIconLPlus);break;case 6:d.append(c.cssExpandTreeIconLMinus);break;case 8:d.append(c.cssExpandTreeIconT);break;case 9:d.append(c.cssExpandTreeIconTPlus);break;case 10:d.append(c.cssExpandTreeIconTMinus);break;default:d.append(c.cssExpandTreeIconBlank)}}else b?d.append(c.cssExpandTreeIconBlank):this.isLastSibling()?d.append(c.cssExpandTreeIconL):d.append(c.cssExpandTreeIconT);return d.toString()};
  goog.ui.tree.BaseNode.prototype.getLineStyle=function(){return"background-position:"+this.getLineStyle2()+";"};goog.ui.tree.BaseNode.prototype.getLineStyle2=function(){return(this.isLastSibling()?"-100":(this.getDepth()-1)*this.config_.indentWidth)+"px 0"};goog.ui.tree.BaseNode.prototype.getElement=function(){var a=goog.ui.tree.BaseNode.superClass_.getElement.call(this);a||(a=this.getDomHelper().getElement(this.getId()),this.setElementInternal(a));return a};
  goog.ui.tree.BaseNode.prototype.getRowElement=function(){var a=this.getElement();return a?a.firstChild:null};goog.ui.tree.BaseNode.prototype.getExpandIconElement=function(){var a=this.getRowElement();return a?a.firstChild:null};goog.ui.tree.BaseNode.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.childNodes[1]:null};goog.ui.tree.BaseNode.prototype.getLabelElement=function(){var a=this.getRowElement();return a&&a.lastChild?a.lastChild.previousSibling:null};
  goog.ui.tree.BaseNode.prototype.getAfterLabelElement=function(){var a=this.getRowElement();return a?a.lastChild:null};goog.ui.tree.BaseNode.prototype.getChildrenElement=function(){var a=this.getElement();return a?a.lastChild:null};goog.ui.tree.BaseNode.prototype.setIconClass=function(a){this.iconClass_=a;this.isInDocument()&&this.updateIcon_()};goog.ui.tree.BaseNode.prototype.getIconClass=function(){return this.iconClass_};
  goog.ui.tree.BaseNode.prototype.setExpandedIconClass=function(a){this.expandedIconClass_=a;this.isInDocument()&&this.updateIcon_()};goog.ui.tree.BaseNode.prototype.getExpandedIconClass=function(){return this.expandedIconClass_};goog.ui.tree.BaseNode.prototype.setText=function(a){this.setHtml(goog.string.htmlEscape(a))};goog.ui.tree.BaseNode.prototype.getText=function(){return goog.string.unescapeEntities(this.getHtml())};
  goog.ui.tree.BaseNode.prototype.setHtml=function(a){this.html_=a;var b=this.getLabelElement();b&&(b.innerHTML=a);(a=this.getTree())&&a.setNode(this)};goog.ui.tree.BaseNode.prototype.getHtml=function(){return this.html_};goog.ui.tree.BaseNode.prototype.setToolTip=function(a){this.toolTip_=a;var b=this.getLabelElement();b&&(b.title=a)};goog.ui.tree.BaseNode.prototype.getToolTip=function(){return this.toolTip_};
  goog.ui.tree.BaseNode.prototype.updateRow=function(){var a=this.getRowElement();a&&(a.className=this.getRowClassName())};goog.ui.tree.BaseNode.prototype.updateExpandIcon=function(){var a=this.getExpandIconElement();a&&(a.className=this.getExpandIconClass());if(a=this.getChildrenElement())a.style.backgroundPosition=this.getLineStyle2()};goog.ui.tree.BaseNode.prototype.updateIcon_=function(){this.getIconElement().className=this.getCalculatedIconClass()};
  goog.ui.tree.BaseNode.prototype.onMouseDown=function(a){"expand"==a.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(a){"expand"==a.target.getAttribute("type")&&this.hasChildren()||this.isUserCollapsible_&&this.toggle()};
  goog.ui.tree.BaseNode.prototype.onKeyDown=function(a){var b=!0;switch(a.keyCode){case goog.events.KeyCodes.RIGHT:if(a.altKey)break;this.hasChildren()&&(this.getExpanded()?this.getFirstChild().select():this.setExpanded(!0));break;case goog.events.KeyCodes.LEFT:if(a.altKey)break;if(this.hasChildren()&&this.getExpanded()&&this.isUserCollapsible_)this.setExpanded(!1);else{var c=this.getParent(),d=this.getTree();c&&(d.getShowRootNode()||c!=d)&&c.select()}break;case goog.events.KeyCodes.DOWN:(c=this.getNextShownNode())&&
  c.select();break;case goog.events.KeyCodes.UP:(c=this.getPreviousShownNode())&&c.select();break;default:b=!1}b&&(a.preventDefault(),(d=this.getTree())&&d.clearTypeAhead());return b};goog.ui.tree.BaseNode.prototype.onKeyPress_=function(a){!a.altKey&&a.keyCode>=goog.events.KeyCodes.LEFT&&a.keyCode<=goog.events.KeyCodes.DOWN&&a.preventDefault()};
  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 a=this,b;a!=this.getTree();){b=a.getNextSibling();if(null!=b)return b;a=a.getParent()}return null};
  goog.ui.tree.BaseNode.prototype.getPreviousShownNode=function(){var a=this.getPreviousSibling();if(null!=a)return a.getLastShownDescendant();var a=this.getParent(),b=this.getTree();return b.getShowRootNode()||a!=b?a:null};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(a){this.tree_!=a&&(this.tree_=a,a.setNode(this),this.forEachChild(function(b){b.setTreeInternal(a)}))};goog.ui.tree.TreeNode=function(a,b,c){goog.ui.tree.BaseNode.call(this,a,b,c)};goog.inherits(goog.ui.tree.TreeNode,goog.ui.tree.BaseNode);goog.ui.tree.TreeNode.prototype.tree_=null;goog.ui.tree.TreeNode.prototype.getTree=function(){if(this.tree_)return this.tree_;var a=this.getParent();return a&&(a=a.getTree())?(this.setTreeInternal(a),a):null};
  goog.ui.tree.TreeNode.prototype.getCalculatedIconClass=function(){var a=this.getExpanded();if(a&&this.expandedIconClass_)return this.expandedIconClass_;if(!a&&this.iconClass_)return this.iconClass_;var b=this.getConfig();if(this.hasChildren()){if(a&&b.cssExpandedFolderIcon)return b.cssTreeIcon+" "+b.cssExpandedFolderIcon;if(!a&&b.cssCollapsedFolderIcon)return b.cssTreeIcon+" "+b.cssCollapsedFolderIcon}else if(b.cssFileIcon)return b.cssTreeIcon+" "+b.cssFileIcon;return""};var FRAME_MARGIN_SIDE=15,FRAME_MARGIN_TOP=10,FRAME_MARGIN_BOTTOM=5,FRAME_HEADER_HEIGHT=25;Blockly.BlockSvgFramed=function(a){Blockly.BlockSvg.call(this,a)};goog.inherits(Blockly.BlockSvgFramed,Blockly.BlockSvg);
  Blockly.BlockSvgFramed.prototype.initChildren=function(){var a=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,width:"100%"},a);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(a,b){Blockly.BlockSvgFramed.superClass_.renderDraw_.call(this,a,b);var c=this.svgPath_.getBoundingClientRect(),d=c.width+2*FRAME_MARGIN_SIDE,c=c.height+FRAME_MARGIN_TOP+FRAME_MARGIN_BOTTOM+FRAME_HEADER_HEIGHT;this.frameBase_.setAttribute("width",d);this.frameBase_.setAttribute("height",c);this.frameHeader_.setAttribute("width",d);this.frameHeader_.setAttribute("height",c);Blockly.RTL&&(this.frameClipRect_.setAttribute("x",-d+FRAME_MARGIN_SIDE),
  this.frameHeader_.setAttribute("x",-d+FRAME_MARGIN_SIDE),this.frameBase_.setAttribute("x",-d+FRAME_MARGIN_SIDE),this.frameText_.setAttribute("x",-d+2*FRAME_MARGIN_SIDE));this.frameText_.getAttribute("y")||(d=Math.abs(this.frameText_.getBoundingClientRect().top-this.svgPathDark_.getBoundingClientRect().top),this.frameText_.setAttribute("y",-(FRAME_MARGIN_TOP+(FRAME_HEADER_HEIGHT-d)/2)))};
  Blockly.BlockSvgFramed.prototype.dispose=function(){Blockly.BlockSvgFramed.superClass_.dispose.call(this);this.frameText_=this.frameHeader_=this.frameBase_=this.frameClipRect_=null};goog.dom.classlist={};goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST=!1;goog.dom.classlist.get=function(a){if(goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList)return a.classList;a=a.className;return goog.isString(a)&&a.match(/\S+/g)||[]};goog.dom.classlist.set=function(a,b){a.className=b};goog.dom.classlist.contains=function(a,b){return goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList?a.classList.contains(b):goog.array.contains(goog.dom.classlist.get(a),b)};
  goog.dom.classlist.add=function(a,b){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList?a.classList.add(b):goog.dom.classlist.contains(a,b)||(a.className+=0<a.className.length?" "+b:b)};
  goog.dom.classlist.addAll=function(a,b){if(goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList)goog.array.forEach(b,function(b){goog.dom.classlist.add(a,b)});else{var c={};goog.array.forEach(goog.dom.classlist.get(a),function(a){c[a]=!0});goog.array.forEach(b,function(a){c[a]=!0});a.className="";for(var d in c)a.className+=0<a.className.length?" "+d:d}};
  goog.dom.classlist.remove=function(a,b){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList?a.classList.remove(b):goog.dom.classlist.contains(a,b)&&(a.className=goog.array.filter(goog.dom.classlist.get(a),function(a){return a!=b}).join(" "))};
  goog.dom.classlist.removeAll=function(a,b){goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST||a.classList?goog.array.forEach(b,function(b){goog.dom.classlist.remove(a,b)}):a.className=goog.array.filter(goog.dom.classlist.get(a),function(a){return!goog.array.contains(b,a)}).join(" ")};goog.dom.classlist.enable=function(a,b,c){c?goog.dom.classlist.add(a,b):goog.dom.classlist.remove(a,b)};
  goog.dom.classlist.swap=function(a,b,c){return goog.dom.classlist.contains(a,b)?(goog.dom.classlist.remove(a,b),goog.dom.classlist.add(a,c),!0):!1};goog.dom.classlist.toggle=function(a,b){var c=!goog.dom.classlist.contains(a,b);goog.dom.classlist.enable(a,b,c);return c};goog.dom.classlist.addRemove=function(a,b,c){goog.dom.classlist.remove(a,b);goog.dom.classlist.add(a,c)};goog.ui.registry={};goog.ui.registry.getDefaultRenderer=function(a){for(var b;a;){b=goog.getUid(a);if(b=goog.ui.registry.defaultRenderers_[b])break;a=a.superClass_?a.superClass_.constructor:null}return b?goog.isFunction(b.getInstance)?b.getInstance():new b:null};
  goog.ui.registry.setDefaultRenderer=function(a,b){if(!goog.isFunction(a))throw Error("Invalid component class "+a);if(!goog.isFunction(b))throw Error("Invalid renderer class "+b);var c=goog.getUid(a);goog.ui.registry.defaultRenderers_[c]=b};goog.ui.registry.getDecoratorByClassName=function(a){return a in goog.ui.registry.decoratorFunctions_?goog.ui.registry.decoratorFunctions_[a]():null};
  goog.ui.registry.setDecoratorByClassName=function(a,b){if(!a)throw Error("Invalid class name "+a);if(!goog.isFunction(b))throw Error("Invalid decorator function "+b);goog.ui.registry.decoratorFunctions_[a]=b};goog.ui.registry.getDecorator=function(a){for(var b=goog.dom.classlist.get(a),c=0,d=b.length;c<d;c++)if(a=goog.ui.registry.getDecoratorByClassName(b[c]))return a;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(a){this.ariaRole_=a};goog.addSingletonGetter(goog.ui.ContainerRenderer);goog.ui.ContainerRenderer.getCustomRenderer=function(a,b){var c=new a;c.getCssClass=function(){return b};return c};goog.ui.ContainerRenderer.CSS_CLASS="goog-container";goog.ui.ContainerRenderer.prototype.getAriaRole=function(){return this.ariaRole_};goog.ui.ContainerRenderer.prototype.enableTabIndex=function(a,b){a&&(a.tabIndex=b?0:-1)};
  goog.ui.ContainerRenderer.prototype.createDom=function(a){return a.getDomHelper().createDom("div",this.getClassNames(a).join(" "))};goog.ui.ContainerRenderer.prototype.getContentElement=function(a){return a};goog.ui.ContainerRenderer.prototype.canDecorate=function(a){return"DIV"==a.tagName};
  goog.ui.ContainerRenderer.prototype.decorate=function(a,b){b.id&&a.setId(b.id);var c=this.getCssClass(),d=!1,e=goog.dom.classlist.get(b);e&&goog.array.forEach(e,function(b){b==c?d=!0:b&&this.setStateFromClassName(a,b,c)},this);d||goog.dom.classlist.add(b,c);this.decorateChildren(a,this.getContentElement(b));return b};
  goog.ui.ContainerRenderer.prototype.setStateFromClassName=function(a,b,c){b==c+"-disabled"?a.setEnabled(!1):b==c+"-horizontal"?a.setOrientation(goog.ui.Container.Orientation.HORIZONTAL):b==c+"-vertical"&&a.setOrientation(goog.ui.Container.Orientation.VERTICAL)};
  goog.ui.ContainerRenderer.prototype.decorateChildren=function(a,b,c){if(b){c=c||b.firstChild;for(var d;c&&c.parentNode==b;){d=c.nextSibling;if(c.nodeType==goog.dom.NodeType.ELEMENT){var e=this.getDecoratorForChild(c);e&&(e.setElementInternal(c),a.isEnabled()||e.setEnabled(!1),a.addChild(e),e.decorate(c))}else c.nodeValue&&""!=goog.string.trim(c.nodeValue)||b.removeChild(c);c=d}}};goog.ui.ContainerRenderer.prototype.getDecoratorForChild=function(a){return goog.ui.registry.getDecorator(a)};
  goog.ui.ContainerRenderer.prototype.initializeDom=function(a){a=a.getElement();goog.asserts.assert(a,"The container DOM element cannot be null.");goog.style.setUnselectable(a,!0,goog.userAgent.GECKO);goog.userAgent.IE&&(a.hideFocus=!0);var b=this.getAriaRole();b&&goog.a11y.aria.setRole(a,b)};goog.ui.ContainerRenderer.prototype.getKeyEventTarget=function(a){return a.getElement()};goog.ui.ContainerRenderer.prototype.getCssClass=function(){return goog.ui.ContainerRenderer.CSS_CLASS};
  goog.ui.ContainerRenderer.prototype.getClassNames=function(a){var b=this.getCssClass(),c=a.getOrientation()==goog.ui.Container.Orientation.HORIZONTAL,c=[b,c?b+"-horizontal":b+"-vertical"];a.isEnabled()||c.push(b+"-disabled");return c};goog.ui.ContainerRenderer.prototype.getDefaultOrientation=function(){return goog.ui.Container.Orientation.VERTICAL};goog.ui.ControlRenderer=function(){};goog.addSingletonGetter(goog.ui.ControlRenderer);goog.ui.ControlRenderer.getCustomRenderer=function(a,b){var c=new a;c.getCssClass=function(){return b};return c};goog.ui.ControlRenderer.CSS_CLASS="goog-control";goog.ui.ControlRenderer.IE6_CLASS_COMBINATIONS=[];goog.ui.ControlRenderer.prototype.getAriaRole=function(){};
  goog.ui.ControlRenderer.prototype.createDom=function(a){var b=a.getDomHelper().createDom("div",this.getClassNames(a).join(" "),a.getContent());this.setAriaStates(a,b);return b};goog.ui.ControlRenderer.prototype.getContentElement=function(a){return a};
  goog.ui.ControlRenderer.prototype.enableClassName=function(a,b,c){if(a=a.getElement?a.getElement():a)if(goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")){var d=this.getAppliedCombinedClassNames_(goog.dom.classes.get(a),b);d.push(b);goog.partial(c?goog.dom.classes.add:goog.dom.classes.remove,a).apply(null,d)}else goog.dom.classes.enable(a,b,c)};goog.ui.ControlRenderer.prototype.enableExtraClassName=function(a,b,c){this.enableClassName(a,b,c)};
  goog.ui.ControlRenderer.prototype.canDecorate=function(a){return!0};
  goog.ui.ControlRenderer.prototype.decorate=function(a,b){b.id&&a.setId(b.id);var c=this.getContentElement(b);c&&c.firstChild?a.setContentInternal(c.firstChild.nextSibling?goog.array.clone(c.childNodes):c.firstChild):a.setContentInternal(null);var d=0,e=this.getCssClass(),f=this.getStructuralCssClass(),g=!1,h=!1,c=!1,k=goog.dom.classes.get(b);goog.array.forEach(k,function(a){g||a!=e?h||a!=f?d|=this.getStateFromClass(a):h=!0:(g=!0,f==e&&(h=!0))},this);a.setStateInternal(d);g||(k.push(e),f==e&&(h=!0));
  h||k.push(f);var l=a.getExtraClassNames();l&&k.push.apply(k,l);if(goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")){var m=this.getAppliedCombinedClassNames_(k);0<m.length&&(k.push.apply(k,m),c=!0)}g&&h&&!l&&!c||goog.dom.classes.set(b,k.join(" "));this.setAriaStates(a,b);return b};goog.ui.ControlRenderer.prototype.initializeDom=function(a){a.isRightToLeft()&&this.setRightToLeft(a.getElement(),!0);a.isEnabled()&&this.setFocusable(a,a.isVisible())};
  goog.ui.ControlRenderer.prototype.setAriaRole=function(a,b){var c=b||this.getAriaRole();c&&(goog.asserts.assert(a,"The element passed as a first parameter cannot be null."),goog.a11y.aria.setRole(a,c))};
  goog.ui.ControlRenderer.prototype.setAriaStates=function(a,b){goog.asserts.assert(a);goog.asserts.assert(b);a.isVisible()||goog.a11y.aria.setState(b,goog.a11y.aria.State.HIDDEN,!a.isVisible());a.isEnabled()||this.updateAriaState(b,goog.ui.Component.State.DISABLED,!a.isEnabled());a.isSupportedState(goog.ui.Component.State.SELECTED)&&this.updateAriaState(b,goog.ui.Component.State.SELECTED,a.isSelected());a.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(b,goog.ui.Component.State.CHECKED,
  a.isChecked());a.isSupportedState(goog.ui.Component.State.OPENED)&&this.updateAriaState(b,goog.ui.Component.State.OPENED,a.isOpen())};goog.ui.ControlRenderer.prototype.setAllowTextSelection=function(a,b){goog.style.setUnselectable(a,!b,!goog.userAgent.IE&&!goog.userAgent.OPERA)};goog.ui.ControlRenderer.prototype.setRightToLeft=function(a,b){this.enableClassName(a,this.getStructuralCssClass()+"-rtl",b)};
  goog.ui.ControlRenderer.prototype.isFocusable=function(a){var b;return a.isSupportedState(goog.ui.Component.State.FOCUSED)&&(b=a.getKeyEventTarget())?goog.dom.isFocusableTabIndex(b):!1};goog.ui.ControlRenderer.prototype.setFocusable=function(a,b){var c;if(a.isSupportedState(goog.ui.Component.State.FOCUSED)&&(c=a.getKeyEventTarget())){if(!b&&a.isFocused()){try{c.blur()}catch(d){}a.isFocused()&&a.handleBlur(null)}goog.dom.isFocusableTabIndex(c)!=b&&goog.dom.setFocusableTabIndex(c,b)}};
  goog.ui.ControlRenderer.prototype.setVisible=function(a,b){goog.style.setElementShown(a,b);a&&goog.a11y.aria.setState(a,goog.a11y.aria.State.HIDDEN,!b)};goog.ui.ControlRenderer.prototype.setState=function(a,b,c){var d=a.getElement();if(d){var e=this.getClassForState(b);e&&this.enableClassName(a,e,c);this.updateAriaState(d,b,c)}};
  goog.ui.ControlRenderer.prototype.updateAriaState=function(a,b,c){goog.ui.ControlRenderer.ARIA_STATE_MAP_||(goog.ui.ControlRenderer.ARIA_STATE_MAP_=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));if(b=goog.ui.ControlRenderer.ARIA_STATE_MAP_[b])goog.asserts.assert(a,"The element passed as a first parameter cannot be null."),
  goog.a11y.aria.setState(a,b,c)};goog.ui.ControlRenderer.prototype.setContent=function(a,b){var c=this.getContentElement(a);if(c&&(goog.dom.removeChildren(c),b))if(goog.isString(b))goog.dom.setTextContent(c,b);else{var d=function(a){if(a){var b=goog.dom.getOwnerDocument(c);c.appendChild(goog.isString(a)?b.createTextNode(a):a)}};goog.isArray(b)?goog.array.forEach(b,d):!goog.isArrayLike(b)||"nodeType"in b?d(b):goog.array.forEach(goog.array.clone(b),d)}};
  goog.ui.ControlRenderer.prototype.getKeyEventTarget=function(a){return a.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(a){var b=this.getCssClass(),c=[b],d=this.getStructuralCssClass();d!=b&&c.push(d);b=this.getClassNamesForState(a.getState());c.push.apply(c,b);(a=a.getExtraClassNames())&&c.push.apply(c,a);goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")&&c.push.apply(c,this.getAppliedCombinedClassNames_(c));return c};
  goog.ui.ControlRenderer.prototype.getAppliedCombinedClassNames_=function(a,b){var c=[];b&&(a=a.concat([b]));goog.array.forEach(this.getIe6ClassCombinations(),function(d){!goog.array.every(d,goog.partial(goog.array.contains,a))||b&&!goog.array.contains(d,b)||c.push(d.join("_"))});return c};goog.ui.ControlRenderer.prototype.getClassNamesForState=function(a){for(var b=[];a;){var c=a&-a;b.push(this.getClassForState(c));a&=~c}return b};
  goog.ui.ControlRenderer.prototype.getClassForState=function(a){this.classByState_||this.createClassByStateMap_();return this.classByState_[a]};goog.ui.ControlRenderer.prototype.getStateFromClass=function(a){this.stateByClass_||this.createStateByClassMap_();a=parseInt(this.stateByClass_[a],10);return isNaN(a)?0:a};
  goog.ui.ControlRenderer.prototype.createClassByStateMap_=function(){var a=this.getStructuralCssClass();this.classByState_=goog.object.create(goog.ui.Component.State.DISABLED,a+"-disabled",goog.ui.Component.State.HOVER,a+"-hover",goog.ui.Component.State.ACTIVE,a+"-active",goog.ui.Component.State.SELECTED,a+"-selected",goog.ui.Component.State.CHECKED,a+"-checked",goog.ui.Component.State.FOCUSED,a+"-focused",goog.ui.Component.State.OPENED,a+"-open")};
  goog.ui.ControlRenderer.prototype.createStateByClassMap_=function(){this.classByState_||this.createClassByStateMap_();this.stateByClass_=goog.object.transpose(this.classByState_)};goog.ui.decorate=function(a){var b=goog.ui.registry.getDecorator(a);b&&b.decorate(a);return b};goog.events.KeyHandler=function(a,b){goog.events.EventTarget.call(this);a&&this.attach(a,b)};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.WEBKIT&&goog.userAgent.isVersionOrHigher("525");goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_=goog.userAgent.MAC&&goog.userAgent.GECKO;
  goog.events.KeyHandler.prototype.handleKeyDown_=function(a){goog.userAgent.WEBKIT&&(this.lastKey_==goog.events.KeyCodes.CTRL&&!a.ctrlKey||this.lastKey_==goog.events.KeyCodes.ALT&&!a.altKey||goog.userAgent.MAC&&this.lastKey_==goog.events.KeyCodes.META&&!a.metaKey)&&(this.keyCode_=this.lastKey_=-1);-1==this.lastKey_&&(a.ctrlKey&&a.keyCode!=goog.events.KeyCodes.CTRL?this.lastKey_=goog.events.KeyCodes.CTRL:a.altKey&&a.keyCode!=goog.events.KeyCodes.ALT?this.lastKey_=goog.events.KeyCodes.ALT:a.metaKey&&
  a.keyCode!=goog.events.KeyCodes.META&&(this.lastKey_=goog.events.KeyCodes.META));goog.events.KeyHandler.USES_KEYDOWN_&&!goog.events.KeyCodes.firesKeyPressEvent(a.keyCode,this.lastKey_,a.shiftKey,a.ctrlKey,a.altKey)?this.handleEvent(a):(this.keyCode_=goog.events.KeyCodes.normalizeKeyCode(a.keyCode),goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_&&(this.altKey_=a.altKey))};goog.events.KeyHandler.prototype.resetState=function(){this.keyCode_=this.lastKey_=-1};
  goog.events.KeyHandler.prototype.handleKeyup_=function(a){this.resetState();this.altKey_=a.altKey};
  goog.events.KeyHandler.prototype.handleEvent=function(a){var b=a.getBrowserEvent(),c,d,e=b.altKey;goog.userAgent.IE&&a.type==goog.events.EventType.KEYPRESS?(c=this.keyCode_,d=c!=goog.events.KeyCodes.ENTER&&c!=goog.events.KeyCodes.ESC?b.keyCode:0):goog.userAgent.WEBKIT&&a.type==goog.events.EventType.KEYPRESS?(c=this.keyCode_,d=0<=b.charCode&&63232>b.charCode&&goog.events.KeyCodes.isCharacterKey(c)?b.charCode:0):goog.userAgent.OPERA?(c=this.keyCode_,d=goog.events.KeyCodes.isCharacterKey(c)?b.keyCode:
  0):(c=b.keyCode||this.keyCode_,d=b.charCode||0,goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_&&(e=this.altKey_),goog.userAgent.MAC&&d==goog.events.KeyCodes.QUESTION_MARK&&c==goog.events.KeyCodes.WIN_KEY&&(c=goog.events.KeyCodes.SLASH));var f=c=goog.events.KeyCodes.normalizeKeyCode(c),g=b.keyIdentifier;c?63232<=c&&c in goog.events.KeyHandler.safariKey_?f=goog.events.KeyHandler.safariKey_[c]:25==c&&a.shiftKey&&(f=9):g&&g in goog.events.KeyHandler.keyIdentifier_&&(f=goog.events.KeyHandler.keyIdentifier_[g]);
  a=f==this.lastKey_;this.lastKey_=f;b=new goog.events.KeyEvent(f,d,a,b);b.altKey=e;this.dispatchEvent(b)};goog.events.KeyHandler.prototype.getElement=function(){return this.element_};
  goog.events.KeyHandler.prototype.attach=function(a,b){this.keyUpKey_&&this.detach();this.element_=a;this.keyPressKey_=goog.events.listen(this.element_,goog.events.EventType.KEYPRESS,this,b);this.keyDownKey_=goog.events.listen(this.element_,goog.events.EventType.KEYDOWN,this.handleKeyDown_,b,this);this.keyUpKey_=goog.events.listen(this.element_,goog.events.EventType.KEYUP,this.handleKeyup_,b,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(a,b,c,d){goog.events.BrowserEvent.call(this,d);this.type=goog.events.KeyHandler.EventType.KEY;this.keyCode=a;this.charCode=b;this.repeat=c};goog.inherits(goog.events.KeyEvent,goog.events.BrowserEvent);goog.ui.Control=function(a,b,c){goog.ui.Component.call(this,c);this.renderer_=b||goog.ui.registry.getDefaultRenderer(this.constructor);this.setContentInternal(goog.isDef(a)?a:null)};goog.inherits(goog.ui.Control,goog.ui.Component);goog.ui.Control.registerDecorator=goog.ui.registry.setDecoratorByClassName;goog.ui.Control.getDecorator=goog.ui.registry.getDecorator;goog.ui.Control.decorate=goog.ui.decorate;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(a){this.isInDocument()&&a!=this.handleMouseEvents_&&this.enableMouseEventHandling_(a);this.handleMouseEvents_=a};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(a){if(this.isInDocument())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.getElement()&&this.setElementInternal(null);this.renderer_=a};goog.ui.Control.prototype.getExtraClassNames=function(){return this.extraClassNames_};
  goog.ui.Control.prototype.addClassName=function(a){a&&(this.extraClassNames_?goog.array.contains(this.extraClassNames_,a)||this.extraClassNames_.push(a):this.extraClassNames_=[a],this.renderer_.enableExtraClassName(this,a,!0))};goog.ui.Control.prototype.removeClassName=function(a){a&&this.extraClassNames_&&goog.array.remove(this.extraClassNames_,a)&&(0==this.extraClassNames_.length&&(this.extraClassNames_=null),this.renderer_.enableExtraClassName(this,a,!1))};
  goog.ui.Control.prototype.enableClassName=function(a,b){b?this.addClassName(a):this.removeClassName(a)};goog.ui.Control.prototype.createDom=function(){var a=this.renderer_.createDom(this);this.setElementInternal(a);this.renderer_.setAriaRole(a,this.getPreferredAriaRole());this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(a,!1);this.isVisible()||this.renderer_.setVisible(a,!1)};goog.ui.Control.prototype.getPreferredAriaRole=function(){return this.preferredAriaRole_};
  goog.ui.Control.prototype.setPreferredAriaRole=function(a){this.preferredAriaRole_=a};goog.ui.Control.prototype.getContentElement=function(){return this.renderer_.getContentElement(this.getElement())};goog.ui.Control.prototype.canDecorate=function(a){return this.renderer_.canDecorate(a)};
  goog.ui.Control.prototype.decorateInternal=function(a){a=this.renderer_.decorate(this,a);this.setElementInternal(a);this.renderer_.setAriaRole(a,this.getPreferredAriaRole());this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(a,!1);this.visible_="none"!=a.style.display};
  goog.ui.Control.prototype.enterDocument=function(){goog.ui.Control.superClass_.enterDocument.call(this);this.renderer_.initializeDom(this);if(this.supportedStates_&~goog.ui.Component.State.DISABLED&&(this.isHandleMouseEvents()&&this.enableMouseEventHandling_(!0),this.isSupportedState(goog.ui.Component.State.FOCUSED))){var a=this.getKeyEventTarget();if(a){var b=this.getKeyHandler();b.attach(a);this.getHandler().listen(b,goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent).listen(a,goog.events.EventType.FOCUS,
  this.handleFocus).listen(a,goog.events.EventType.BLUR,this.handleBlur)}}};
  goog.ui.Control.prototype.enableMouseEventHandling_=function(a){var b=this.getHandler(),c=this.getElement();a?(b.listen(c,goog.events.EventType.MOUSEOVER,this.handleMouseOver).listen(c,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).listen(c,goog.events.EventType.MOUSEUP,this.handleMouseUp).listen(c,goog.events.EventType.MOUSEOUT,this.handleMouseOut),this.handleContextMenu!=goog.nullFunction&&b.listen(c,goog.events.EventType.CONTEXTMENU,this.handleContextMenu),goog.userAgent.IE&&b.listen(c,
  goog.events.EventType.DBLCLICK,this.handleDblClick)):(b.unlisten(c,goog.events.EventType.MOUSEOVER,this.handleMouseOver).unlisten(c,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).unlisten(c,goog.events.EventType.MOUSEUP,this.handleMouseUp).unlisten(c,goog.events.EventType.MOUSEOUT,this.handleMouseOut),this.handleContextMenu!=goog.nullFunction&&b.unlisten(c,goog.events.EventType.CONTEXTMENU,this.handleContextMenu),goog.userAgent.IE&&b.unlisten(c,goog.events.EventType.DBLCLICK,this.handleDblClick))};
  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.extraClassNames_=this.content_=null};goog.ui.Control.prototype.getContent=function(){return this.content_};
  goog.ui.Control.prototype.setContent=function(a){this.renderer_.setContent(this.getElement(),a);this.setContentInternal(a)};goog.ui.Control.prototype.setContentInternal=function(a){this.content_=a};goog.ui.Control.prototype.getCaption=function(){var a=this.getContent();if(!a)return"";a=goog.isString(a)?a:goog.isArray(a)?goog.array.map(a,goog.dom.getRawTextContent).join(""):goog.dom.getTextContent(a);return goog.string.collapseBreakingSpaces(a)};goog.ui.Control.prototype.setCaption=function(a){this.setContent(a)};
  goog.ui.Control.prototype.setRightToLeft=function(a){goog.ui.Control.superClass_.setRightToLeft.call(this,a);var b=this.getElement();b&&this.renderer_.setRightToLeft(b,a)};goog.ui.Control.prototype.isAllowTextSelection=function(){return this.allowTextSelection_};goog.ui.Control.prototype.setAllowTextSelection=function(a){this.allowTextSelection_=a;var b=this.getElement();b&&this.renderer_.setAllowTextSelection(b,a)};goog.ui.Control.prototype.isVisible=function(){return this.visible_};
  goog.ui.Control.prototype.setVisible=function(a,b){if(b||this.visible_!=a&&this.dispatchEvent(a?goog.ui.Component.EventType.SHOW:goog.ui.Component.EventType.HIDE)){var c=this.getElement();c&&this.renderer_.setVisible(c,a);this.isEnabled()&&this.renderer_.setFocusable(this,a);this.visible_=a;return!0}return!1};goog.ui.Control.prototype.isEnabled=function(){return!this.hasState(goog.ui.Component.State.DISABLED)};
  goog.ui.Control.prototype.isParentDisabled_=function(){var a=this.getParent();return!!a&&"function"==typeof a.isEnabled&&!a.isEnabled()};goog.ui.Control.prototype.setEnabled=function(a){!this.isParentDisabled_()&&this.isTransitionAllowed(goog.ui.Component.State.DISABLED,!a)&&(a||(this.setActive(!1),this.setHighlighted(!1)),this.isVisible()&&this.renderer_.setFocusable(this,a),this.setState(goog.ui.Component.State.DISABLED,!a))};goog.ui.Control.prototype.isHighlighted=function(){return this.hasState(goog.ui.Component.State.HOVER)};
  goog.ui.Control.prototype.setHighlighted=function(a){this.isTransitionAllowed(goog.ui.Component.State.HOVER,a)&&this.setState(goog.ui.Component.State.HOVER,a)};goog.ui.Control.prototype.isActive=function(){return this.hasState(goog.ui.Component.State.ACTIVE)};goog.ui.Control.prototype.setActive=function(a){this.isTransitionAllowed(goog.ui.Component.State.ACTIVE,a)&&this.setState(goog.ui.Component.State.ACTIVE,a)};goog.ui.Control.prototype.isSelected=function(){return this.hasState(goog.ui.Component.State.SELECTED)};
  goog.ui.Control.prototype.setSelected=function(a){this.isTransitionAllowed(goog.ui.Component.State.SELECTED,a)&&this.setState(goog.ui.Component.State.SELECTED,a)};goog.ui.Control.prototype.isChecked=function(){return this.hasState(goog.ui.Component.State.CHECKED)};goog.ui.Control.prototype.setChecked=function(a){this.isTransitionAllowed(goog.ui.Component.State.CHECKED,a)&&this.setState(goog.ui.Component.State.CHECKED,a)};goog.ui.Control.prototype.isFocused=function(){return this.hasState(goog.ui.Component.State.FOCUSED)};
  goog.ui.Control.prototype.setFocused=function(a){this.isTransitionAllowed(goog.ui.Component.State.FOCUSED,a)&&this.setState(goog.ui.Component.State.FOCUSED,a)};goog.ui.Control.prototype.isOpen=function(){return this.hasState(goog.ui.Component.State.OPENED)};goog.ui.Control.prototype.setOpen=function(a){this.isTransitionAllowed(goog.ui.Component.State.OPENED,a)&&this.setState(goog.ui.Component.State.OPENED,a)};goog.ui.Control.prototype.getState=function(){return this.state_};
  goog.ui.Control.prototype.hasState=function(a){return!!(this.state_&a)};goog.ui.Control.prototype.setState=function(a,b){this.isSupportedState(a)&&b!=this.hasState(a)&&(this.renderer_.setState(this,a,b),this.state_=b?this.state_|a:this.state_&~a)};goog.ui.Control.prototype.setStateInternal=function(a){this.state_=a};goog.ui.Control.prototype.isSupportedState=function(a){return!!(this.supportedStates_&a)};
  goog.ui.Control.prototype.setSupportedState=function(a,b){if(this.isInDocument()&&this.hasState(a)&&!b)throw Error(goog.ui.Component.Error.ALREADY_RENDERED);!b&&this.hasState(a)&&this.setState(a,!1);this.supportedStates_=b?this.supportedStates_|a:this.supportedStates_&~a};goog.ui.Control.prototype.isAutoState=function(a){return!!(this.autoStates_&a)&&this.isSupportedState(a)};goog.ui.Control.prototype.setAutoStates=function(a,b){this.autoStates_=b?this.autoStates_|a:this.autoStates_&~a};
  goog.ui.Control.prototype.isDispatchTransitionEvents=function(a){return!!(this.statesWithTransitionEvents_&a)&&this.isSupportedState(a)};goog.ui.Control.prototype.setDispatchTransitionEvents=function(a,b){this.statesWithTransitionEvents_=b?this.statesWithTransitionEvents_|a:this.statesWithTransitionEvents_&~a};
  goog.ui.Control.prototype.isTransitionAllowed=function(a,b){return this.isSupportedState(a)&&this.hasState(a)!=b&&(!(this.statesWithTransitionEvents_&a)||this.dispatchEvent(goog.ui.Component.getStateTransitionEvent(a,b)))&&!this.isDisposed()};goog.ui.Control.prototype.handleMouseOver=function(a){!goog.ui.Control.isMouseEventWithinElement_(a,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(a){!goog.ui.Control.isMouseEventWithinElement_(a,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(a,b){return!!a.relatedTarget&&goog.dom.contains(b,a.relatedTarget)};
  goog.ui.Control.prototype.handleMouseDown=function(a){this.isEnabled()&&(this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!0),a.isMouseActionButton()&&(this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!0),this.renderer_.isFocusable(this)&&this.getKeyEventTarget().focus()));!this.isAllowTextSelection()&&a.isMouseActionButton()&&a.preventDefault()};
  goog.ui.Control.prototype.handleMouseUp=function(a){this.isEnabled()&&(this.isAutoState(goog.ui.Component.State.HOVER)&&this.setHighlighted(!0),this.isActive()&&this.performActionInternal(a)&&this.isAutoState(goog.ui.Component.State.ACTIVE)&&this.setActive(!1))};goog.ui.Control.prototype.handleDblClick=function(a){this.isEnabled()&&this.performActionInternal(a)};
  goog.ui.Control.prototype.performActionInternal=function(a){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 b=new goog.events.Event(goog.ui.Component.EventType.ACTION,this);a&&(b.altKey=a.altKey,b.ctrlKey=a.ctrlKey,b.metaKey=a.metaKey,b.shiftKey=a.shiftKey,b.platformModifierKey=a.platformModifierKey);return this.dispatchEvent(b)};
  goog.ui.Control.prototype.handleFocus=function(a){this.isAutoState(goog.ui.Component.State.FOCUSED)&&this.setFocused(!0)};goog.ui.Control.prototype.handleBlur=function(a){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(a){return this.isVisible()&&this.isEnabled()&&this.handleKeyEventInternal(a)?(a.preventDefault(),a.stopPropagation(),!0):!1};
  goog.ui.Control.prototype.handleKeyEventInternal=function(a){return a.keyCode==goog.events.KeyCodes.ENTER&&this.performActionInternal(a)};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.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(a){return a.getDomHelper().createDom("div",this.getCssClass())};
  goog.ui.MenuSeparatorRenderer.prototype.decorate=function(a,b){b.id&&a.setId(b.id);if("HR"==b.tagName){var c=b;b=this.createDom(a);goog.dom.insertSiblingBefore(b,c);goog.dom.removeNode(c)}else goog.dom.classlist.add(b,this.getCssClass());return b};goog.ui.MenuSeparatorRenderer.prototype.setContent=function(a,b){};goog.ui.MenuSeparatorRenderer.prototype.getCssClass=function(){return goog.ui.MenuSeparatorRenderer.CSS_CLASS};goog.ui.Separator=function(a,b){goog.ui.Control.call(this,null,a||goog.ui.MenuSeparatorRenderer.getInstance(),b);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 a=this.getElement();goog.asserts.assert(a,"The DOM element for the separator cannot be null.");goog.a11y.aria.setRole(a,"separator")};goog.ui.registry.setDecoratorByClassName(goog.ui.MenuSeparatorRenderer.CSS_CLASS,function(){return new goog.ui.Separator});goog.ui.MenuRenderer=function(a){goog.ui.ContainerRenderer.call(this,a||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(a){return"UL"==a.tagName||goog.ui.MenuRenderer.superClass_.canDecorate.call(this,a)};
  goog.ui.MenuRenderer.prototype.getDecoratorForChild=function(a){return"HR"==a.tagName?new goog.ui.Separator:goog.ui.MenuRenderer.superClass_.getDecoratorForChild.call(this,a)};goog.ui.MenuRenderer.prototype.containsElement=function(a,b){return goog.dom.contains(a.getElement(),b)};goog.ui.MenuRenderer.prototype.getCssClass=function(){return goog.ui.MenuRenderer.CSS_CLASS};
  goog.ui.MenuRenderer.prototype.initializeDom=function(a){goog.ui.MenuRenderer.superClass_.initializeDom.call(this,a);a=a.getElement();goog.asserts.assert(a,"The menu DOM element cannot be null.");goog.a11y.aria.setState(a,goog.a11y.aria.State.HASPOPUP,"true")};goog.ui.MenuSeparator=function(a){goog.ui.Separator.call(this,goog.ui.MenuSeparatorRenderer.getInstance(),a)};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.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(a){var b=this.classNameCache_[a];if(!b){switch(a){case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.HOVER:b=this.getStructuralCssClass()+"-highlight";break;case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX:b=this.getStructuralCssClass()+"-checkbox";break;case goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT:b=this.getStructuralCssClass()+"-content"}this.classNameCache_[a]=b}return b};
  goog.ui.MenuItemRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.MENU_ITEM};goog.ui.MenuItemRenderer.prototype.createDom=function(a){var b=a.getDomHelper().createDom("div",this.getClassNames(a).join(" "),this.createContent(a.getContent(),a.getDomHelper()));this.setEnableCheckBoxStructure(a,b,a.isSupportedState(goog.ui.Component.State.SELECTED)||a.isSupportedState(goog.ui.Component.State.CHECKED));this.setAriaStates(a,b);this.correctAriaRole(a,b);return b};
  goog.ui.MenuItemRenderer.prototype.getContentElement=function(a){return a&&a.firstChild};goog.ui.MenuItemRenderer.prototype.decorate=function(a,b){this.hasContentStructure(b)||b.appendChild(this.createContent(b.childNodes,a.getDomHelper()));goog.dom.classlist.contains(b,"goog-option")&&(a.setCheckable(!0),this.setCheckable(a,b,!0));return goog.ui.MenuItemRenderer.superClass_.decorate.call(this,a,b)};
  goog.ui.MenuItemRenderer.prototype.setContent=function(a,b){var c=this.getContentElement(a),d=this.hasCheckBoxStructure(a)?c.firstChild:null;goog.ui.MenuItemRenderer.superClass_.setContent.call(this,a,b);d&&!this.hasCheckBoxStructure(a)&&c.insertBefore(d,c.firstChild||null)};
  goog.ui.MenuItemRenderer.prototype.hasContentStructure=function(a){a=goog.dom.getFirstElementChild(a);var b=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT);return!!a&&goog.dom.classlist.contains(a,b)};goog.ui.MenuItemRenderer.prototype.createContent=function(a,b){var c=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT);return b.createDom("div",c,a)};
  goog.ui.MenuItemRenderer.prototype.setSelectable=function(a,b,c){b&&(goog.a11y.aria.setRole(b,c?goog.a11y.aria.Role.MENU_ITEM_RADIO:this.getAriaRole()),this.setEnableCheckBoxStructure(a,b,c))};goog.ui.MenuItemRenderer.prototype.setCheckable=function(a,b,c){b&&(goog.a11y.aria.setRole(b,c?goog.a11y.aria.Role.MENU_ITEM_CHECKBOX:this.getAriaRole()),this.setEnableCheckBoxStructure(a,b,c))};
  goog.ui.MenuItemRenderer.prototype.hasCheckBoxStructure=function(a){if(a=this.getContentElement(a)){a=a.firstChild;var b=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX);return!!a&&goog.dom.isElement(a)&&goog.dom.classlist.contains(a,b)}return!1};
  goog.ui.MenuItemRenderer.prototype.setEnableCheckBoxStructure=function(a,b,c){c!=this.hasCheckBoxStructure(b)&&(goog.dom.classlist.enable(b,"goog-option",c),b=this.getContentElement(b),c?(c=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CHECKBOX),b.insertBefore(a.getDomHelper().createDom("div",c),b.firstChild||null)):b.removeChild(b.firstChild))};
  goog.ui.MenuItemRenderer.prototype.getClassForState=function(a){switch(a){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,a)}};
  goog.ui.MenuItemRenderer.prototype.getStateFromClass=function(a){var b=this.getCompositeCssClass_(goog.ui.MenuItemRenderer.CompositeCssClassIndex_.HOVER);switch(a){case "goog-option-selected":return goog.ui.Component.State.CHECKED;case b:return goog.ui.Component.State.HOVER;default:return goog.ui.MenuItemRenderer.superClass_.getStateFromClass.call(this,a)}};goog.ui.MenuItemRenderer.prototype.getCssClass=function(){return goog.ui.MenuItemRenderer.CSS_CLASS};
  goog.ui.MenuItemRenderer.prototype.correctAriaRole=function(a,b){(a.isSupportedState(goog.ui.Component.State.SELECTED)||a.isSupportedState(goog.ui.Component.State.CHECKED))&&this.setAriaRole(b,a.isSupportedState(goog.ui.Component.State.CHECKED)?goog.a11y.aria.Role.MENU_ITEM_CHECKBOX:goog.a11y.aria.Role.MENU_ITEM_RADIO)};goog.ui.MenuItem=function(a,b,c,d){goog.ui.Control.call(this,a,d||goog.ui.MenuItemRenderer.getInstance(),c);this.setValue(b)};goog.inherits(goog.ui.MenuItem,goog.ui.Control);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 a=this.getModel();return null!=a?a:this.getCaption()};goog.ui.MenuItem.prototype.setValue=function(a){this.setModel(a)};
  goog.ui.MenuItem.prototype.setSelectable=function(a){this.setSupportedState(goog.ui.Component.State.SELECTED,a);this.isChecked()&&!a&&this.setChecked(!1);var b=this.getElement();b&&this.getRenderer().setSelectable(this,b,a)};goog.ui.MenuItem.prototype.setCheckable=function(a){this.setSupportedState(goog.ui.Component.State.CHECKED,a);var b=this.getElement();b&&this.getRenderer().setCheckable(this,b,a)};
  goog.ui.MenuItem.prototype.getCaption=function(){var a=this.getContent();if(goog.isArray(a)){var b=goog.ui.MenuItem.ACCELERATOR_CLASS_,c=goog.ui.MenuItem.MNEMONIC_WRAPPER_CLASS_,a=goog.array.map(a,function(a){return goog.dom.isElement(a)&&(goog.dom.classlist.contains(a,b)||goog.dom.classlist.contains(a,c))?"":goog.dom.getRawTextContent(a)}).join("");return goog.string.collapseBreakingSpaces(a)}return goog.ui.MenuItem.superClass_.getCaption.call(this)};
  goog.ui.MenuItem.prototype.handleMouseUp=function(a){var b=this.getParent();if(b){var c=b.openingCoords;b.openingCoords=null;if(c&&goog.isNumber(a.clientX)&&(b=new goog.math.Coordinate(a.clientX,a.clientY),goog.math.Coordinate.equals(c,b)))return}goog.ui.MenuItem.base(this,"handleMouseUp",a)};goog.ui.MenuItem.prototype.handleKeyEventInternal=function(a){return a.keyCode==this.getMnemonic()&&this.performActionInternal(a)?!0:goog.ui.MenuItem.base(this,"handleKeyEventInternal",a)};
  goog.ui.MenuItem.prototype.setMnemonic=function(a){this.mnemonicKey_=a};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.createDom=function(){goog.ui.MenuItem.base(this,"createDom");this.getRenderer().correctAriaRole(this,this.getElement())};goog.ui.Container=function(a,b,c){goog.ui.Component.call(this,c);this.renderer_=b||goog.ui.ContainerRenderer.getInstance();this.orientation_=a||this.renderer_.getDefaultOrientation()};goog.inherits(goog.ui.Container,goog.ui.Component);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(a){if(this.focusable_){var b=this.getKeyEventTarget(),c=this.isInDocument();this.keyEventTarget_=a;var d=this.getKeyEventTarget();c&&(this.keyEventTarget_=b,this.enableFocusHandling_(!1),this.keyEventTarget_=a,this.getKeyHandler().attach(d),this.enableFocusHandling_(!0))}else throw Error("Can't set key event target for container that doesn't support keyboard focus!");};
  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(a){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.renderer_=a};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(a){return this.renderer_.canDecorate(a)};goog.ui.Container.prototype.decorateInternal=function(a){this.setElementInternal(this.renderer_.decorate(this,a));"none"==a.style.display&&(this.visible_=!1)};
  goog.ui.Container.prototype.enterDocument=function(){goog.ui.Container.superClass_.enterDocument.call(this);this.forEachChild(function(a){a.isInDocument()&&this.registerChildId_(a)},this);var a=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(a,goog.events.EventType.MOUSEDOWN,this.handleMouseDown).listen(goog.dom.getOwnerDocument(a),goog.events.EventType.MOUSEUP,this.handleDocumentMouseUp).listen(a,[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(a){var b=this.getHandler(),c=this.getKeyEventTarget();a?b.listen(c,goog.events.EventType.FOCUS,this.handleFocus).listen(c,goog.events.EventType.BLUR,this.handleBlur).listen(this.getKeyHandler(),goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent):b.unlisten(c,goog.events.EventType.FOCUS,this.handleFocus).unlisten(c,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(a){return!0};
  goog.ui.Container.prototype.handleHighlightItem=function(a){var b=this.indexOfChild(a.target);if(-1<b&&b!=this.highlightedIndex_){var c=this.getHighlighted();c&&c.setHighlighted(!1);this.highlightedIndex_=b;c=this.getHighlighted();this.isMouseButtonPressed()&&c.setActive(!0);this.openFollowsHighlight_&&this.openItem_&&c!=this.openItem_&&(c.isSupportedState(goog.ui.Component.State.OPENED)?c.setOpen(!0):this.openItem_.setOpen(!1))}b=this.getElement();goog.asserts.assert(b,"The DOM element for the container cannot be null.");
  null!=a.target.getElement()&&goog.a11y.aria.setState(b,goog.a11y.aria.State.ACTIVEDESCENDANT,a.target.getElement().id)};goog.ui.Container.prototype.handleUnHighlightItem=function(a){a.target==this.getHighlighted()&&(this.highlightedIndex_=-1);a=this.getElement();goog.asserts.assert(a,"The DOM element for the container cannot be null.");goog.a11y.aria.removeState(a,goog.a11y.aria.State.ACTIVEDESCENDANT)};
  goog.ui.Container.prototype.handleOpenItem=function(a){(a=a.target)&&a!=this.openItem_&&a.getParent()==this&&(this.openItem_&&this.openItem_.setOpen(!1),this.openItem_=a)};goog.ui.Container.prototype.handleCloseItem=function(a){a.target==this.openItem_&&(this.openItem_=null)};goog.ui.Container.prototype.handleMouseDown=function(a){this.enabled_&&this.setMouseButtonPressed(!0);var b=this.getKeyEventTarget();b&&goog.dom.isFocusableTabIndex(b)?b.focus():a.preventDefault()};
  goog.ui.Container.prototype.handleDocumentMouseUp=function(a){this.setMouseButtonPressed(!1)};goog.ui.Container.prototype.handleChildMouseEvents=function(a){var b=this.getOwnerControl(a.target);if(b)switch(a.type){case goog.events.EventType.MOUSEDOWN:b.handleMouseDown(a);break;case goog.events.EventType.MOUSEUP:b.handleMouseUp(a);break;case goog.events.EventType.MOUSEOVER:b.handleMouseOver(a);break;case goog.events.EventType.MOUSEOUT:b.handleMouseOut(a);break;case goog.events.EventType.CONTEXTMENU:b.handleContextMenu(a)}};
  goog.ui.Container.prototype.getOwnerControl=function(a){if(this.childElementIdMap_)for(var b=this.getElement();a&&a!==b;){var c=a.id;if(c in this.childElementIdMap_)return this.childElementIdMap_[c];a=a.parentNode}return null};goog.ui.Container.prototype.handleFocus=function(a){};goog.ui.Container.prototype.handleBlur=function(a){this.setHighlightedIndex(-1);this.setMouseButtonPressed(!1);this.openItem_&&this.openItem_.setOpen(!1)};
  goog.ui.Container.prototype.handleKeyEvent=function(a){return this.isEnabled()&&this.isVisible()&&(0!=this.getChildCount()||this.keyEventTarget_)&&this.handleKeyEventInternal(a)?(a.preventDefault(),a.stopPropagation(),!0):!1};
  goog.ui.Container.prototype.handleKeyEventInternal=function(a){var b=this.getHighlighted();if(b&&"function"==typeof b.handleKeyEvent&&b.handleKeyEvent(a)||this.openItem_&&this.openItem_!=b&&"function"==typeof this.openItem_.handleKeyEvent&&this.openItem_.handleKeyEvent(a))return!0;if(a.shiftKey||a.ctrlKey||a.metaKey||a.altKey)return!1;switch(a.keyCode){case goog.events.KeyCodes.ESC:if(this.isFocusable())this.getKeyEventTarget().blur();else return!1;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)this.highlightPrevious();else return!1;break;case goog.events.KeyCodes.LEFT:if(this.orientation_==goog.ui.Container.Orientation.HORIZONTAL)this.isRightToLeft()?this.highlightNext():this.highlightPrevious();else return!1;break;case goog.events.KeyCodes.DOWN:if(this.orientation_==goog.ui.Container.Orientation.VERTICAL)this.highlightNext();else return!1;
  break;case goog.events.KeyCodes.RIGHT:if(this.orientation_==goog.ui.Container.Orientation.HORIZONTAL)this.isRightToLeft()?this.highlightPrevious():this.highlightNext();else return!1;break;default:return!1}return!0};goog.ui.Container.prototype.registerChildId_=function(a){var b=a.getElement(),b=b.id||(b.id=a.getId());this.childElementIdMap_||(this.childElementIdMap_={});this.childElementIdMap_[b]=a};
  goog.ui.Container.prototype.addChild=function(a,b){goog.asserts.assertInstanceof(a,goog.ui.Control,"The child of a container must be a control");goog.ui.Container.superClass_.addChild.call(this,a,b)};
  goog.ui.Container.prototype.addChildAt=function(a,b,c){a.setDispatchTransitionEvents(goog.ui.Component.State.HOVER,!0);a.setDispatchTransitionEvents(goog.ui.Component.State.OPENED,!0);!this.isFocusable()&&this.isFocusableChildrenAllowed()||a.setSupportedState(goog.ui.Component.State.FOCUSED,!1);a.setHandleMouseEvents(!1);goog.ui.Container.superClass_.addChildAt.call(this,a,b,c);a.isInDocument()&&this.isInDocument()&&this.registerChildId_(a);b<=this.highlightedIndex_&&this.highlightedIndex_++};
  goog.ui.Container.prototype.removeChild=function(a,b){if(a=goog.isString(a)?this.getChild(a):a){var c=this.indexOfChild(a);-1!=c&&(c==this.highlightedIndex_?(a.setHighlighted(!1),this.highlightedIndex_=-1):c<this.highlightedIndex_&&this.highlightedIndex_--);(c=a.getElement())&&c.id&&this.childElementIdMap_&&goog.object.remove(this.childElementIdMap_,c.id)}a=goog.ui.Container.superClass_.removeChild.call(this,a,b);a.setHandleMouseEvents(!0);return a};goog.ui.Container.prototype.getOrientation=function(){return this.orientation_};
  goog.ui.Container.prototype.setOrientation=function(a){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.orientation_=a};goog.ui.Container.prototype.isVisible=function(){return this.visible_};
  goog.ui.Container.prototype.setVisible=function(a,b){if(b||this.visible_!=a&&this.dispatchEvent(a?goog.ui.Component.EventType.SHOW:goog.ui.Component.EventType.HIDE)){this.visible_=a;var c=this.getElement();c&&(goog.style.setElementShown(c,a),this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),this.enabled_&&this.visible_),b||this.dispatchEvent(this.visible_?goog.ui.Container.EventType.AFTER_SHOW:goog.ui.Container.EventType.AFTER_HIDE));return!0}return!1};
  goog.ui.Container.prototype.isEnabled=function(){return this.enabled_};
  goog.ui.Container.prototype.setEnabled=function(a){this.enabled_!=a&&this.dispatchEvent(a?goog.ui.Component.EventType.ENABLE:goog.ui.Component.EventType.DISABLE)&&(a?(this.enabled_=!0,this.forEachChild(function(a){a.wasDisabled?delete a.wasDisabled:a.setEnabled(!0)})):(this.forEachChild(function(a){a.isEnabled()?a.setEnabled(!1):a.wasDisabled=!0}),this.enabled_=!1,this.setMouseButtonPressed(!1)),this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),a&&this.visible_))};
  goog.ui.Container.prototype.isFocusable=function(){return this.focusable_};goog.ui.Container.prototype.setFocusable=function(a){a!=this.focusable_&&this.isInDocument()&&this.enableFocusHandling_(a);this.focusable_=a;this.enabled_&&this.visible_&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),a)};goog.ui.Container.prototype.isFocusableChildrenAllowed=function(){return this.allowFocusableChildren_};
  goog.ui.Container.prototype.setFocusableChildrenAllowed=function(a){this.allowFocusableChildren_=a};goog.ui.Container.prototype.isOpenFollowsHighlight=function(){return this.openFollowsHighlight_};goog.ui.Container.prototype.setOpenFollowsHighlight=function(a){this.openFollowsHighlight_=a};goog.ui.Container.prototype.getHighlightedIndex=function(){return this.highlightedIndex_};
  goog.ui.Container.prototype.setHighlightedIndex=function(a){(a=this.getChildAt(a))?a.setHighlighted(!0):-1<this.highlightedIndex_&&this.getHighlighted().setHighlighted(!1)};goog.ui.Container.prototype.setHighlighted=function(a){this.setHighlightedIndex(this.indexOfChild(a))};goog.ui.Container.prototype.getHighlighted=function(){return this.getChildAt(this.highlightedIndex_)};
  goog.ui.Container.prototype.highlightFirst=function(){this.highlightHelper(function(a,b){return(a+1)%b},this.getChildCount()-1)};goog.ui.Container.prototype.highlightLast=function(){this.highlightHelper(function(a,b){a--;return 0>a?b-1:a},0)};goog.ui.Container.prototype.highlightNext=function(){this.highlightHelper(function(a,b){return(a+1)%b},this.highlightedIndex_)};goog.ui.Container.prototype.highlightPrevious=function(){this.highlightHelper(function(a,b){a--;return 0>a?b-1:a},this.highlightedIndex_)};
  goog.ui.Container.prototype.highlightHelper=function(a,b){for(var c=0>b?this.indexOfChild(this.openItem_):b,d=this.getChildCount(),c=a.call(this,c,d),e=0;e<=d;){var f=this.getChildAt(c);if(f&&this.canHighlightItem(f))return this.setHighlightedIndexFromKeyEvent(c),!0;e++;c=a.call(this,c,d)}return!1};goog.ui.Container.prototype.canHighlightItem=function(a){return a.isVisible()&&a.isEnabled()&&a.isSupportedState(goog.ui.Component.State.HOVER)};
  goog.ui.Container.prototype.setHighlightedIndexFromKeyEvent=function(a){this.setHighlightedIndex(a)};goog.ui.Container.prototype.getOpenItem=function(){return this.openItem_};goog.ui.Container.prototype.isMouseButtonPressed=function(){return this.mouseButtonPressed_};goog.ui.Container.prototype.setMouseButtonPressed=function(a){this.mouseButtonPressed_=a};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(a,b,c){goog.ui.Control.call(this,a,c||goog.ui.MenuHeaderRenderer.getInstance(),b);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.Menu=function(a,b){goog.ui.Container.call(this,goog.ui.Container.Orientation.VERTICAL,b||goog.ui.MenuRenderer.getInstance(),a);this.setFocusable(!1)};goog.inherits(goog.ui.Menu,goog.ui.Container);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(a){if(this.getRenderer().containsElement(this,a))return!0;for(var b=0,c=this.getChildCount();b<c;b++){var d=this.getChildAt(b);if("function"==typeof d.containsElement&&d.containsElement(a))return!0}return!1};goog.ui.Menu.prototype.addItem=function(a){this.addChild(a,!0)};
  goog.ui.Menu.prototype.addItemAt=function(a,b){this.addChildAt(a,b,!0)};goog.ui.Menu.prototype.removeItem=function(a){(a=this.removeChild(a,!0))&&a.dispose()};goog.ui.Menu.prototype.removeItemAt=function(a){(a=this.removeChildAt(a,!0))&&a.dispose()};goog.ui.Menu.prototype.getItemAt=function(a){return this.getChildAt(a)};goog.ui.Menu.prototype.getItemCount=function(){return this.getChildCount()};goog.ui.Menu.prototype.getItems=function(){var a=[];this.forEachChild(function(b){a.push(b)});return a};
  goog.ui.Menu.prototype.setPosition=function(a,b){var c=this.isVisible();c||goog.style.setElementShown(this.getElement(),!0);goog.style.setPageOffset(this.getElement(),a,b);c||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(a){(this.allowAutoFocus_=a)&&this.setFocusable(!0)};goog.ui.Menu.prototype.getAllowAutoFocus=function(){return this.allowAutoFocus_};
  goog.ui.Menu.prototype.setAllowHighlightDisabled=function(a){this.allowHighlightDisabled_=a};goog.ui.Menu.prototype.getAllowHighlightDisabled=function(){return this.allowHighlightDisabled_};goog.ui.Menu.prototype.setVisible=function(a,b,c){(b=goog.ui.Menu.superClass_.setVisible.call(this,a,b))&&a&&this.isInDocument()&&this.allowAutoFocus_&&this.getKeyEventTarget().focus();a&&c&&goog.isNumber(c.clientX)?this.openingCoords=new goog.math.Coordinate(c.clientX,c.clientY):this.openingCoords=null;return b};
  goog.ui.Menu.prototype.handleEnterItem=function(a){this.allowAutoFocus_&&this.getKeyEventTarget().focus();return goog.ui.Menu.superClass_.handleEnterItem.call(this,a)};goog.ui.Menu.prototype.highlightNextPrefix=function(a){var b=RegExp("^"+goog.string.regExpEscape(a),"i");return this.highlightHelper(function(a,d){var e=0>a?0:a,f=!1;do{++a;a==d&&(a=0,f=!0);var g=this.getChildAt(a).getCaption();if(g&&g.match(b))return a}while(!f||a!=e);return this.getHighlightedIndex()},this.getHighlightedIndex())};
  goog.ui.Menu.prototype.canHighlightItem=function(a){return(this.allowHighlightDisabled_||a.isEnabled())&&a.isVisible()&&a.isSupportedState(goog.ui.Component.State.HOVER)};goog.ui.Menu.prototype.decorateInternal=function(a){this.decorateContent(a);goog.ui.Menu.superClass_.decorateInternal.call(this,a)};
  goog.ui.Menu.prototype.handleKeyEventInternal=function(a){var b=goog.ui.Menu.base(this,"handleKeyEventInternal",a);b||this.forEachChild(function(c){!b&&c.getMnemonic&&c.getMnemonic()==a.keyCode&&(this.isEnabled()&&this.setHighlighted(c),b=c.handleKeyEvent(a))},this);return b};goog.ui.Menu.prototype.setHighlightedIndex=function(a){goog.ui.Menu.base(this,"setHighlightedIndex",a);(a=this.getChildAt(a))&&goog.style.scrollIntoContainerView(a.getElement(),this.getElement())};
  goog.ui.Menu.prototype.decorateContent=function(a){var b=this.getRenderer();a=this.getDomHelper().getElementsByTagNameAndClass("div",b.getCssClass()+"-content",a);for(var c=a.length,d=0;d<c;d++)b.decorateChildren(this,a[d])};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;
  Blockly.ContextMenu.show=function(a,b){Blockly.WidgetDiv.show(Blockly.ContextMenu,null);if(b.length){for(var c=new goog.ui.Menu,d=0,e;e=b[d];d++){var f=new goog.ui.MenuItem(e.text);c.addItem(f);f.setEnabled(e.enabled);e.enabled&&goog.events.listen(f,goog.ui.Component.EventType.ACTION,e.callback)}goog.events.listen(c,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);e=goog.dom.getViewportSize();f=goog.style.getViewportPageOffset(document);c.render(Blockly.WidgetDiv.DIV);c.setAllowAutoFocus(!0);
  d=c.getElement();Blockly.addClass_(d,"blocklyContextMenu");var c=goog.style.getSize(d),d=a.clientX+f.x,g=a.clientY+f.y;a.clientY+c.height>=e.height&&(g-=c.height);Blockly.RTL?c.width>=a.clientX&&(d+=c.width):a.clientX+c.width>=e.width&&(d-=c.width);Blockly.WidgetDiv.position(d,g,e,f);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(a){var b=Blockly.createSvgElement("g",{"class":"blocklyMenuDiv"},null);Blockly.createSvgElement("rect",{height:Blockly.ContextMenu.Y_HEIGHT},b);var c=Blockly.createSvgElement("text",{"class":"blocklyMenuText",x:Blockly.ContextMenu.X_PADDING,y:15},b);a=document.createTextNode(a);c.appendChild(a);return b};
  Blockly.ContextMenu.callbackFactory=function(a,b){return function(){var c=Blockly.Xml.domToBlock(a.blockSpace,b),d=a.getRelativeToSurfaceXY();d.x=Blockly.RTL?d.x-Blockly.SNAP_RADIUS:d.x+Blockly.SNAP_RADIUS;d.y+=2*Blockly.SNAP_RADIUS;c.moveBy(d.x,d.y);c.select()}};Blockly.Bubble=function(a,b,c,d,e,f,g){var h=Blockly.Bubble.ARROW_ANGLE;Blockly.RTL&&(h=-h);this.arrow_radians_=2*(h/360)*Math.PI;this.blockSpace_=a;this.content_=b;this.shape_=c;a.getBubbleCanvas().appendChild(this.createDom_(b,!(!f||!g)));this.setAnchorLocation(d,e);if(!f||!g){var k;try{k=b.getBBox()}catch(l){k=this.blockSpace_.getCanvas().getBBox()}f=k.width+2*Blockly.Bubble.BORDER_WIDTH;g=k.height+2*Blockly.Bubble.BORDER_WIDTH}this.setBubbleSize(f,g);this.positionBubble_();this.renderArrow_();
  this.rendered_=!0;a.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(a,b){this.bubbleGroup_=Blockly.createSvgElement("g",{},null);var c=Blockly.createSvgElement("g",{filter:"url(#blocklyEmboss)"},this.bubbleGroup_);this.bubbleArrow_=Blockly.createSvgElement("path",{},c);this.bubbleBack_=Blockly.createSvgElement("rect",{"class":"blocklyDraggable",x:0,y:0,rx:Blockly.Bubble.BORDER_WIDTH,ry:Blockly.Bubble.BORDER_WIDTH},c);b?(this.resizeGroup_=Blockly.createSvgElement("g",{"class":Blockly.RTL?"blocklyResizeSW":"blocklyResizeSE"},
  this.bubbleGroup_),c=2*Blockly.Bubble.BORDER_WIDTH,Blockly.createSvgElement("polygon",{points:"0,x x,x x,0".replace(/x/g,c.toString())},this.resizeGroup_),Blockly.createSvgElement("line",{"class":"blocklyResizeLine",x1:c/3,y1:c-1,x2:c-1,y2:c/3},this.resizeGroup_),Blockly.createSvgElement("line",{"class":"blocklyResizeLine",x1:2*c/3,y1:c-1,x2:c-1,y2:2*c/3},this.resizeGroup_)):this.resizeGroup_=null;this.bubbleGroup_.appendChild(a);return this.bubbleGroup_};
  Blockly.Bubble.prototype.bubbleMouseDown_=function(a){this.promote_();Blockly.Bubble.unbindDragEvents_();Blockly.isRightButton(a)||Blockly.isTargetInput(a)||(this.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),this.dragDeltaX=Blockly.RTL?this.relativeLeft_+a.clientX:this.relativeLeft_-a.clientX,this.dragDeltaY=this.relativeTop_-a.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(),a.stopPropagation())};Blockly.Bubble.prototype.bubbleMouseMove_=function(a){this.autoLayout_=!1;this.relativeLeft_=Blockly.RTL?this.dragDeltaX-a.clientX:this.dragDeltaX+a.clientX;this.relativeTop_=this.dragDeltaY+a.clientY;this.positionBubble_();this.renderArrow_()};
  Blockly.Bubble.prototype.resizeMouseDown_=function(a){this.promote_();Blockly.Bubble.unbindDragEvents_();Blockly.isRightButton(a)||(this.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),this.resizeDeltaWidth=Blockly.RTL?this.width_+a.clientX:this.width_-a.clientX,this.resizeDeltaHeight=this.height_-a.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(),a.stopPropagation())};Blockly.Bubble.prototype.resizeMouseMove_=function(a){this.autoLayout_=!1;var b=this.resizeDeltaWidth,c=this.resizeDeltaHeight+a.clientY,b=Blockly.RTL?b-a.clientX:b+a.clientX;this.setBubbleSize(b,c);Blockly.RTL&&this.positionBubble_()};Blockly.Bubble.prototype.registerResizeEvent=function(a,b){Blockly.bindEvent_(this.bubbleGroup_,"resize",a,b)};Blockly.Bubble.prototype.promote_=function(){this.bubbleGroup_.parentNode.appendChild(this.bubbleGroup_)};
  Blockly.Bubble.prototype.setAnchorLocation=function(a,b){this.anchorX_=a;this.anchorY_=b;this.rendered_&&this.positionBubble_()};
  Blockly.Bubble.prototype.layoutBubble_=function(){var a=-this.width_/4,b=-this.height_-Blockly.BlockSvg.MIN_BLOCK_Y;if(this.blockSpace_.scrollbarPair){var c=this.blockSpace_.getMetrics();this.anchorX_+a<Blockly.BlockSvg.SEP_SPACE_X+c.viewLeft?a=Blockly.BlockSvg.SEP_SPACE_X+c.viewLeft-this.anchorX_:c.viewLeft+c.viewWidth<this.anchorX_+a+this.width_+Blockly.BlockSvg.SEP_SPACE_X+Blockly.Scrollbar.scrollbarThickness&&(a=c.viewLeft+c.viewWidth-this.anchorX_-this.width_-Blockly.BlockSvg.SEP_SPACE_X-Blockly.Scrollbar.scrollbarThickness);
  this.anchorY_+b<Blockly.BlockSvg.SEP_SPACE_Y+c.viewTop&&(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")?(this.shape_.style.display="inline",b={x:this.shape_.getBBox().x,y:this.shape_.getBBox().y,width:this.shape_.scrollWidth,height:this.shape_.scrollHeight}):b=this.shape_.getBBox(),b=b.height)}this.relativeLeft_=a;this.relativeTop_=b};
  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_)+")")};Blockly.Bubble.prototype.getBubbleSize=function(){return{width:this.width_,height:this.height_}};
  Blockly.Bubble.prototype.setBubbleSize=function(a,b){var c=2*Blockly.Bubble.BORDER_WIDTH;a=Math.max(a,c+45);b=Math.max(b,c+Blockly.BlockSvg.TITLE_HEIGHT);this.width_=a;this.height_=b;this.bubbleBack_.setAttribute("width",a);this.bubbleBack_.setAttribute("height",b);this.resizeGroup_&&(Blockly.RTL?this.resizeGroup_.setAttribute("transform","translate("+2*Blockly.Bubble.BORDER_WIDTH+", "+(b-c)+") scale(-1 1)"):this.resizeGroup_.setAttribute("transform","translate("+(a-c)+", "+(b-c)+")"));this.rendered_&&
  (this.autoLayout_&&this.layoutBubble_(),this.positionBubble_(),this.renderArrow_());Blockly.fireUiEvent(this.bubbleGroup_,"resize")};
  Blockly.Bubble.prototype.renderArrow_=function(){var a=[],b=this.width_/2,c=this.height_/2,d=-this.relativeLeft_,e=-this.relativeTop_;if(b==d&&c==e)a.push("M "+b+","+c);else{e-=c;d-=b;Blockly.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);0>e&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>2*Math.PI&&(h-=2*Math.PI);var k=Math.sin(h),l=Math.cos(h),m=this.getBubbleSize(),h=(m.width+m.height)/Blockly.Bubble.ARROW_THICKNESS,h=Math.min(h,m.width,m.height)/2,m=1-Blockly.Bubble.ANCHOR_RADIUS/f,d=b+m*d,e=c+
  m*e,m=b+h*l,n=c+h*k,b=b-h*l,c=c-h*k,k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+m+","+n);a.push("C"+(m+f)+","+(n+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)};
  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(a){this.block_=a};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(a){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(a){if(this.block_.isCollapsed())return this.iconGroup_.setAttribute("display","none"),a;this.iconGroup_.setAttribute("display","block");var b=2*Blockly.Icon.RADIUS;Blockly.RTL&&(a-=b);this.iconGroup_.setAttribute("transform","translate("+a+", 5)");this.computeIconLocation();return a=Blockly.RTL?a-Blockly.BlockSvg.SEP_SPACE_X:a+(b+Blockly.BlockSvg.SEP_SPACE_X)};
  Blockly.Icon.prototype.setIconLocation=function(a,b){this.iconX_=a;this.iconY_=b;this.isVisible()&&this.bubble_.setAnchorLocation(a,b)};Blockly.Icon.prototype.computeIconLocation=function(){var a=this.block_.getRelativeToSurfaceXY(),b=Blockly.getRelativeXY(this.iconGroup_),c=a.x+b.x+Blockly.Icon.RADIUS,a=a.y+b.y+Blockly.Icon.RADIUS;c===this.iconX_&&a===this.iconY_||this.setIconLocation(c,a)};Blockly.Icon.prototype.getIconLocation=function(){return{x:this.iconX_,y:this.iconY_}};Blockly.Mutator=function(a){Blockly.Mutator.superClass_.constructor.call(this,null);this.quarkXml_=[];for(var b=0;b<a.length;b++){var c=goog.dom.createDom("block",{type:a[b]});this.quarkXml_[b]=c}};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 a=Blockly.Icon.RADIUS/2;Blockly.createSvgElement("rect",{"class":"blocklyIconShield",width:4*a,height:4*a,rx:a,ry:a},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("\u2605"))};
  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 a=this,b=this.block_.blockSpace.blockSpaceEditor;this.blockSpace_=new Blockly.BlockSpace(b,function(){return a.getFlyoutMetrics_()},null);this.blockSpace_.flyout_=new Blockly.Flyout(b);this.blockSpace_.flyout_.autoClose=
  !1;this.svgDialog_.appendChild(this.blockSpace_.flyout_.createDom());this.svgDialog_.appendChild(this.blockSpace_.createDom());return this.svgDialog_};
  Blockly.Mutator.prototype.resizeBubble_=function(){var a=2*Blockly.Bubble.BORDER_WIDTH,b=this.blockSpace_.getCanvas().getBBox(),c=this.blockSpace_.flyout_.getMetrics_(),d;d=Blockly.RTL?-b.x:b.width+b.x;b=Math.max(b.height+3*a,c.contentHeight+20);d+=3*a;if(Math.abs(this.blockSpaceWidth_-d)>a||Math.abs(this.blockSpaceHeight_-b)>a)this.blockSpaceWidth_=d,this.blockSpaceHeight_=b,this.bubble_.setBubbleSize(d+a,b+a),this.svgDialog_.setAttribute("width",this.blockSpaceWidth_),this.svgDialog_.setAttribute("height",
  this.blockSpaceHeight_);Blockly.RTL&&(a="translate("+this.blockSpaceWidth_+",0)",this.blockSpace_.getCanvas().setAttribute("transform",a),this.blockSpace_.getDragCanvas().setAttribute("transform",a))};
  Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){this.bubble_=new Blockly.Bubble(this.block_.blockSpace,this.createEditor_(),this.block_.svg_.svgGroup_,this.iconX_,this.iconY_,null,null);var b=this;this.blockSpace_.flyout_.init(this.blockSpace_,!1);this.blockSpace_.flyout_.show(this.quarkXml_);this.rootBlock_=this.block_.decompose(this.blockSpace_);a=this.rootBlock_.getDescendants();for(var c=0,d;d=a[c];c++)d.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);
  a=2*this.blockSpace_.flyout_.CORNER_RADIUS;c=this.blockSpace_.flyout_.width_+a;Blockly.RTL&&(c=-c);this.rootBlock_.moveBy(c,a);this.block_.saveConnections&&(this.block_.saveConnections(this.rootBlock_),this.sourceListener_=Blockly.bindEvent_(this.block_.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this.block_,function(){b.block_.saveConnections(b.rootBlock_)}));this.resizeBubble_();Blockly.bindEvent_(this.blockSpace_.getCanvas(),"blocklyBlockSpaceChange",this.block_,function(){b.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 a=this.blockSpace_.getTopBlocks(!1),b=0,c;c=a[b];b++){var d=c.getRelativeToSurfaceXY(),e=c.getHeightWidth();20>d.y+e.height&&c.moveBy(0,20-e.height-d.y)}this.rootBlock_.blockSpace==this.blockSpace_&&(a=this.block_.rendered,this.block_.rendered=!1,this.block_.compose(this.rootBlock_),this.block_.rendered=a,this.block_.rendered&&this.block_.render(),Blockly.Block.isDragging()||this.resizeBubble_(),
  this.block_.blockSpace.fireChangeEvent())}};Blockly.Mutator.prototype.getFlyoutMetrics_=function(){var a=0;Blockly.RTL&&(a+=this.blockSpaceWidth_);return{viewHeight:this.blockSpaceHeight_,viewWidth:this.blockSpaceWidth_,absoluteTop:0,absoluteLeft:a}};Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)};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"};Blockly.Connection=function(a,b){this.sourceBlock_=a;this.targetConnection=null;this.type=b;this.y_=this.x_=0;this.inDB_=!1;this.dbList_=this.sourceBlock_.blockSpace.connectionDBList;this.check_=null};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(a){if(this.sourceBlock_==a.sourceBlock_)throw"Attempted to connect a block to itself.";if(this.sourceBlock_.blockSpace!==a.sourceBlock_.blockSpace)throw"Blocks are on different blockSpaces.";if(Blockly.OPPOSITE_TYPE[this.type]!=a.type)throw"Attempt to connect incompatible types.";if(this.isConnected())throw"Source connection already connected.";a.targetConnection&&this.handleOrphan_(a);var b,c;this.isSuperior()?(b=this.sourceBlock_,c=a.sourceBlock_):(b=
  a.sourceBlock_,c=this.sourceBlock_);this.targetConnection=a;a.targetConnection=this;c.setParent(b);b.rendered&&b.getSvgRenderer().updateDisabled();c.rendered&&c.getSvgRenderer().updateDisabled();b.rendered&&c.rendered&&(this.type==Blockly.NEXT_STATEMENT||this.type==Blockly.PREVIOUS_STATEMENT?c.render():b.render());this.sourceBlock_.isUserVisible()||this.sourceBlock_.setUserVisible(!1)};
  Blockly.Connection.prototype.handleOrphan_=function(a){var b=a.targetBlock();b.setParent(null);b.setUserVisible(!0);if(this.type===Blockly.INPUT_VALUE||this.type===Blockly.OUTPUT_VALUE){if(!b.outputConnection)throw"Orphan block does not have an output connection.";for(var c=this.sourceBlock_;c=Blockly.Connection.singleConnection_(c,b);)if(c.targetBlock())c=c.targetBlock();else{c.connect(b.outputConnection);b=null;break}b&&window.setTimeout(function(){b.outputConnection.bumpAwayFrom_(a)},Blockly.BUMP_DELAY)}else if(this.type===
  Blockly.FUNCTIONAL_INPUT||this.type===Blockly.FUNCTIONAL_OUTPUT){if(!b.previousConnection)throw"Orphan block does not have a previous connection.";window.setTimeout(function(){b.previousConnection.bumpAwayFrom_(a)},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(!b.previousConnection)throw"Orphan block does not have a previous connection.";for(c=this.sourceBlock_;c.nextConnection;)if(c.nextConnection.targetConnection)c=
  c.nextConnection.targetBlock();else{c.nextConnection.connect(b.previousConnection);b=null;break}b&&window.setTimeout(function(){b.previousConnection.bumpAwayFrom_(a)},Blockly.BUMP_DELAY)}};Blockly.Connection.singleConnection_=function(a,b){for(var c=!1,d=0;d<a.inputList.length;d++){var e=a.inputList[d].connection;if(e&&e.type==Blockly.INPUT_VALUE&&b.outputConnection.checkAllowedConnectionType_(e)){if(c)return null;c=e}}return c};
  Blockly.Connection.prototype.disconnect=function(){var a=this.targetConnection;if(!a)throw"Source connection not connected.";if(a.targetConnection!=this)throw"Target connection not connected to source connection.";this.targetConnection=a.targetConnection=null;this.sourceBlock_.setUserVisible(!0);var b;this.isSuperior()?(b=this.sourceBlock_,a=a.sourceBlock_):(b=a.sourceBlock_,a=this.sourceBlock_);b.rendered&&b.render();a.rendered&&(a.getSvgRenderer().updateDisabled(),a.render())};
  Blockly.Connection.prototype.targetBlock=function(){return this.targetConnection?this.targetConnection.sourceBlock_:null};
  Blockly.Connection.prototype.bumpAwayFrom_=function(a){if(!Blockly.Block.isDragging()){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.sourceBlock_.getRootBlock();if(!b.isMovable())return;a=this;c=!0}b.getSvgRoot().parentNode.appendChild(b.getSvgRoot());var d=a.x_+Blockly.SNAP_RADIUS-this.x_;a=a.y_+2*Blockly.SNAP_RADIUS-this.y_;c&&(a=-a);Blockly.RTL&&(d=-d);b.moveBy(d,a)}}};
  Blockly.Connection.prototype.moveTo=function(a,b){this.inDB_&&this.dbList_[this.type].removeConnection_(this);this.x_=a;this.y_=b;this.dbList_[this.type].addConnection_(this)};Blockly.Connection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)};
  Blockly.Connection.prototype.highlight=function(){var a;if(this.type===Blockly.INPUT_VALUE||this.type===Blockly.OUTPUT_VALUE)a=Blockly.RTL?-Blockly.BlockSvg.TAB_WIDTH:Blockly.BlockSvg.TAB_WIDTH,a="m 0,0 v 5 c 0,10 "+-a+",-8 "+-a+",7.5 s "+a+",-2.5 "+a+",7.5 v 5";else{a=5+Blockly.BlockSvg.NOTCH_PATH_WIDTH;var b=this.getNotchPaths();a=Blockly.RTL?"m "+a+",0 h -5 "+b.right+" h -5":"m -"+a+",0 h 5 "+b.left+" h 5"}b=this.sourceBlock_.getRelativeToSurfaceXY();Blockly.Connection.highlightedPath_=Blockly.createSvgElement("path",
  {"class":"blocklyHighlightedConnectionPath",d:a,transform:"translate("+(this.x_-b.x)+", "+(this.y_-b.y)+")"},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 a=this&&this.check_||[];return 1===a.length&&a[0]===Blockly.BlockValueType.FUNCTION?SQUARE_NOTCH_PATHS:ROUNDED_NOTCH_PATHS};
  Blockly.Connection.prototype.tighten_=function(){var a=Math.round(this.targetConnection.x_-this.x_),b=Math.round(this.targetConnection.y_-this.y_);if(0!=a||0!=b){var c=this.targetBlock(),d=c.getSvgRoot();if(!d)throw"block is not rendered.";d=Blockly.getRelativeXY(d);c.getSvgRoot().setAttribute("transform","translate("+(d.x-a)+", "+(d.y-b)+")");c.moveConnections_(-a,-b)}};
  Blockly.Connection.prototype.closest=function(a,b,c){function d(d){var h=e[d],k=h.sourceBlock_;if(!k.isVisible()||(h.type===Blockly.OUTPUT_VALUE||h.type===Blockly.FUNCTIONAL_OUTPUT||h.type===Blockly.PREVIOUS_STATEMENT)&&h.targetConnection||h.targetConnection&&!h.targetBlock().isMovable()||h.targetConnection&&!h.targetBlock().canDisconnectFromParent()||!p.checkAllowedConnectionType_(h))return!0;do{if(n==k)return!0;k=k.getParent()}while(k);var l=h.x_,k=h.y_;h.sourceBlock_.getDragging()&&(l+=b,k+=c);
  h=f-l;k=g-k;h=Math.sqrt(h*h+k*k);h<=a&&(m=e[d],a=h);return k<a}if(this.isConnected())return{connection:null,radius:a};for(var e=this.dbList_[Blockly.OPPOSITE_TYPE[this.type]],f=this.x_+b,g=this.y_+c,h=0,k=e.length-2,l=k;h<l;)e[l].y_<g?h=l:k=l,l=Math.floor((h+k)/2);var k=h=l,m=null,n=this.sourceBlock_,p=this;if(e.length){for(;0<=h&&d(h);)h--;do k++;while(k<e.length&&d(k))}return{connection:m,radius:a}};
  Blockly.Connection.prototype.checkAllowedConnectionType_=function(a){if(this.acceptsAnyType()||a.acceptsAnyType())return!0;for(var b=0;b<this.check_.length;b++)if(a.acceptsType(this.check_[b]))return!0;return!1};Blockly.Connection.prototype.acceptsAnyType=function(){return!this.check_||this.acceptsType(Blockly.BlockValueType.NONE)};Blockly.Connection.prototype.acceptsType=function(a){return!this.check_||goog.array.contains(this.check_,a)};
  Blockly.Connection.prototype.setCheck=function(a){a&&a!==Blockly.BlockValueType.NONE?(a instanceof Array||(a=[a]),this.check_=a,this.targetConnection&&!this.checkAllowedConnectionType_(this.targetConnection)&&(this.isSuperior()?this.targetBlock().setParent(null):this.sourceBlock_.setParent(null),this.sourceBlock_.bumpNeighbours_())):this.check_=null;return this};Blockly.Connection.prototype.getCheck=function(){return this.check_};
  Blockly.Connection.prototype.neighbours_=function(a){function b(b){var f=c[b],g=f.sourceBlock_;if(!Blockly.editBlocks&&!g.isVisible())return!0;g=d-f.x_;f=e-f.y_;Math.sqrt(g*g+f*f)<=a&&k.push(c[b]);return f<a}for(var c=this.dbList_[Blockly.OPPOSITE_TYPE[this.type]],d=this.x_,e=this.y_,f=0,g=c.length-2,h=g;f<h;)c[h].y_<e?f=h:g=h,h=Math.floor((f+g)/2);var g=f=h,k=[];if(c.length){for(;0<=f&&b(f);)f--;do g++;while(g<c.length&&b(g))}return k};
  Blockly.Connection.prototype.hideAll=function(){this.inDB_&&this.dbList_[this.type].removeConnection_(this);if(this.isConnected())for(var a=this.targetBlock().getDescendants(),b=0;b<a.length;b++){for(var c=a[b],d=c.getConnections_(!0),e=0;e<d.length;e++){var f=d[e];f.inDB_&&this.dbList_[f.type].removeConnection_(f)}c=c.getIcons();for(d=0;d<c.length;d++)c[d].setVisible(!1)}};
  Blockly.Connection.prototype.unhideAll=function(){this.inDB_||this.dbList_[this.type].addConnection_(this);var a=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return a;var b=this.targetBlock();if(b){var c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(var d=0;d<c.length;d++)a=a.concat(c[d].unhideAll());0==a.length&&(a[0]=b)}return a};
  Blockly.ConnectionDB=function(){};Blockly.ConnectionDB.prototype=[];Blockly.ConnectionDB.constructor=Blockly.ConnectionDB;Blockly.ConnectionDB.prototype.addConnection_=function(a){if(a.inDB_)throw"Connection already in database.";for(var b=0,c=this.length;b<c;){var d=Math.floor((b+c)/2);if(this[d].y_<a.y_)b=d+1;else if(this[d].y_>a.y_)c=d;else{b=d;break}}this.splice(b,0,a);a.inDB_=!0};
  Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw"Connection not in database.";a.inDB_=!1;for(var b=0,c=this.length-2,d=c;b<d;)this[d].y_<a.y_?b=d:c=d,d=Math.floor((b+c)/2);for(c=b=d;0<=b&&this[b].y_==a.y_;){if(this[b]==a){this.splice(b,1);return}b--}do{if(this[c]==a){this.splice(c,1);return}c++}while(c<this.length&&this[c].y_==a.y_);throw"Unable to find connection in connectionDB.";};
  Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.FUNCTIONAL_INPUT]=new Blockly.ConnectionDB;b[Blockly.FUNCTIONAL_OUTPUT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Blocks={};Blockly.BlockSvgFunctional=function(a,b){b=b||{};this.headerHeight=b.headerHeight||0;this.rowBuffer=b.rowBuffer||0;this.patternId_=null;this.inputMarkers_={};this.inputClickTargets_={};this.forcedInputSpacings={};Blockly.BlockSvg.call(this,a)};goog.inherits(Blockly.BlockSvgFunctional,Blockly.BlockSvg);
  Blockly.BlockSvgFunctional.prototype.initChildren=function(){var a=Blockly.makeColour(this.block_.getColour(),this.block_.getSaturation(),this.block_.getValue()),b=goog.color.lighten(goog.color.hexToRgb(a),0.3);goog.color.lighten(goog.color.hexToRgb(a),0.8);Blockly.BlockSvgFunctional.superClass_.initChildren.call(this);a=Blockly.createSvgElement("clipPath",{id:"blockClip"+this.block_.id},this.svgGroup_);this.blockClipRect_=Blockly.createSvgElement("path",{},a);this.divider_=Blockly.createSvgElement("rect",
  {x:1,y:this.headerHeight,height:3,width:0,fill:goog.color.rgbArrayToHex(b),"clip-path":"url(#blockClip"+this.block_.id+")",visibility:0<this.headerHeight?"visible":"hidden"},this.svgGroup_);this.createFunctionalMarkers_()};
  Blockly.BlockSvgFunctional.prototype.renderDraw_=function(a,b){this.createFunctionalMarkers_();Blockly.BlockSvgFunctional.superClass_.renderDraw_.call(this,a,b);this.blockClipRect_.setAttribute("d",this.svgPath_.getAttribute("d"));try{var c=this.svgPath_.getBBox();this.divider_.setAttribute("width",Math.max(0,c.width-2))}catch(d){}};
  Blockly.BlockSvgFunctional.prototype.createFunctionalMarkers_=function(){for(var a=[],b=0;b<this.block_.inputList.length;b++){var c=this.block_.inputList[b];a.push(c.name);this.inputMarkers_[c.name]||c.type!==Blockly.FUNCTIONAL_INPUT||(this.inputMarkers_[c.name]=Blockly.createSvgElement("rect",{fill:"white"},this.svgGroup_),this.inputClickTargets_[c.name]=Blockly.createSvgElement("path",{fill:"white",opacity:"0","class":"inputClickTarget"},this.svgGroup_),this.block_.blockSpace.isFlyout||this.addInputClickListener_(c.name))}Object.keys(this.inputMarkers_).forEach(function(b){if(-1===
  a.indexOf(b)){var c=this.inputMarkers_[b];c.parentNode.removeChild(c);delete this.inputMarkers_[b];c=this.inputClickTargets_[b];c.parentNode.removeChild(c);delete this.inputMarkers_[b]}},this)};
  Blockly.BlockSvgFunctional.prototype.addInputClickListener_=function(a){var b=this.block_.blockSpace,c=this.block_;Blockly.bindEvent_(this.inputClickTargets_[a],"mousedown",this,function(d){if(!Blockly.isRightButton(d)){var e=c.getInput(a);if(!e.connection.acceptsAnyType()){if(e.connection.acceptsType("Number"))d="functional_math_number";else if(e.connection.acceptsType("String"))d="functional_string";else return;d=new Blockly.Block(b,d);d.initSvg();e.connection.connect(d.previousConnection);for(var e=
  d.getTitles(),f=0;f<e.length;f++)e[f]instanceof Blockly.FieldTextInput&&e[f].showEditor_();d.render()}}})};Blockly.BlockSvgFunctional.prototype.renderDrawRight_=function(a,b,c,d){this.rowBuffer&&(a.core.push("v",this.rowBuffer),a.curY+=this.rowBuffer);Blockly.BlockSvgFunctional.superClass_.renderDrawRight_.call(this,a,b,c,d)};
  Blockly.BlockSvgFunctional.prototype.renderDrawRightInlineFunctional_=function(a,b,c){var d=a.curX,e=a.curY+BS.INLINE_PADDING_Y,f=BS.NOTCH_WIDTH-BS.NOTCH_PATH_WIDTH,g=b.connection.getNotchPaths(),h=[];h.push("M",d+","+e);h.push("h",f);h.push(g.left);h.push("H",d+b.renderWidth);h.push("v",b.renderHeight);h.push("H",d);h.push("z");a.inline=a.inline.concat(h);this.inputClickTargets_[b.name].setAttribute("d",h.join(" "));this.inputMarkers_[b.name].setAttribute("x",d+5);this.inputMarkers_[b.name].setAttribute("y",
  e+15);this.inputMarkers_[b.name].setAttribute("width",b.renderWidth-10);this.inputMarkers_[b.name].setAttribute("height",5);this.inputMarkers_[b.name].setAttribute("fill",b.getHexColour());this.inputMarkers_[b.name].setAttribute("visibility",b.connection.targetConnection?"hidden":"visible");this.inputClickTargets_[b.name].setAttribute("visibility",b.connection.targetConnection?"hidden":"visible");a.curX+=this.inputWidthToOccupy_(b)+BS.SEP_SPACE_X;b.connection.moveTo(c.x+d+BS.NOTCH_WIDTH,c.y+e);b.connection.targetConnection&&
  b.connection.tighten_()};Blockly.BlockSvgFunctional.prototype.updateToColour_=function(a){Blockly.BlockSvgFunctional.superClass_.updateToColour_.call(this,a);this.divider_&&(a=goog.color.lighten(goog.color.hexToRgb(a),0.3),this.divider_.setAttribute("fill",goog.color.rgbArrayToHex(a)))};Blockly.BlockSvgFunctional.prototype.dispose=function(){Blockly.BlockSvgFunctional.superClass_.dispose.call(this);this.divider_=this.blockClipRect_=null};Blockly.Comment=function(a){Blockly.Comment.superClass_.constructor.call(this,a);this.createIcon_()};goog.inherits(Blockly.Comment,Blockly.Icon);Blockly.Comment.prototype.text_="";Blockly.Comment.prototype.width_=160;Blockly.Comment.prototype.height_=80;
  Blockly.Comment.prototype.createIcon_=function(){Blockly.Icon.prototype.createIcon_.call(this);Blockly.createSvgElement("circle",{"class":"blocklyIconShield",r:Blockly.Icon.RADIUS,cx:Blockly.Icon.RADIUS,cy:Blockly.Icon.RADIUS},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.Comment.prototype.createEditor_=function(){this.foreignObject_=Blockly.createSvgElement("foreignObject",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);var a=document.createElementNS(Blockly.HTML_NS,"body");a.setAttribute("xmlns",Blockly.HTML_NS);a.className="blocklyMinimalBody";this.textarea_=document.createElementNS(Blockly.HTML_NS,"textarea");this.textarea_.className="blocklyCommentTextarea";this.textarea_.setAttribute("dir",Blockly.RTL?"RTL":"LTR");a.appendChild(this.textarea_);
  this.foreignObject_.appendChild(a);Blockly.bindEvent_(this.textarea_,"mouseup",this,this.textareaFocus_);return this.foreignObject_};Blockly.Comment.prototype.resizeBubble_=function(){var a=this.bubble_.getBubbleSize(),b=2*Blockly.Bubble.BORDER_WIDTH;this.foreignObject_.setAttribute("width",a.width-b);this.foreignObject_.setAttribute("height",a.height-b);this.textarea_.style.width=a.width-b-4+"px";this.textarea_.style.height=a.height-b-4+"px"};
  Blockly.Comment.prototype.setVisible=function(a){if(a!=this.isVisible()){var b=this.getText(),c=this.getBubbleSize();a?(this.bubble_=new Blockly.Bubble(this.block_.blockSpace,this.createEditor_(),this.block_.svg_.svgGroup_,this.iconX_,this.iconY_,this.width_,this.height_),this.bubble_.registerResizeEvent(this,this.resizeBubble_),this.updateColour(),this.text_=null):(this.bubble_.dispose(),this.foreignObject_=this.textarea_=this.bubble_=null);this.setText(b);this.setBubbleSize(c.width,c.height)}};
  Blockly.Comment.prototype.textareaFocus_=function(a){this.bubble_.promote_();this.textarea_.focus()};Blockly.Comment.prototype.getBubbleSize=function(){return this.isVisible()?this.bubble_.getBubbleSize():{width:this.width_,height:this.height_}};Blockly.Comment.prototype.setBubbleSize=function(a,b){this.isVisible()?this.bubble_.setBubbleSize(a,b):(this.width_=a,this.height_=b)};Blockly.Comment.prototype.getText=function(){return this.isVisible()?this.textarea_.value:this.text_};
  Blockly.Comment.prototype.setText=function(a){this.isVisible()?this.textarea_.value=a:this.text_=a};Blockly.Comment.prototype.dispose=function(){this.block_.comment=null;Blockly.Icon.prototype.dispose.call(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 a=Blockly.createSvgElement("g",{"class":"blocklyHidden"},null);Blockly.Tooltip.svgGroup_=a;Blockly.Tooltip.svgShadow_=Blockly.createSvgElement("rect",{"class":"blocklyTooltipShadow",x:2,y:2},a);Blockly.Tooltip.svgBackground_=Blockly.createSvgElement("rect",{"class":"blocklyTooltipBackground"},a);Blockly.Tooltip.svgText_=Blockly.createSvgElement("text",{"class":"blocklyTooltipText"},a);return a};
  Blockly.Tooltip.bindMouseEvents=function(a){Blockly.bindEvent_(a,"mouseover",null,Blockly.Tooltip.onMouseOver_);Blockly.bindEvent_(a,"mouseout",null,Blockly.Tooltip.onMouseOut_);Blockly.bindEvent_(a,"mousemove",null,Blockly.Tooltip.onMouseMove_)};Blockly.Tooltip.onMouseOver_=function(a){for(a=a.target;!goog.isString(a.tooltip)&&!goog.isFunction(a.tooltip);)a=a.tooltip;Blockly.Tooltip.element_!=a&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=a);window.clearTimeout(Blockly.Tooltip.mouseOutPid_)};
  Blockly.Tooltip.onMouseOut_=function(a){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(a){if(Blockly.Tooltip.element_&&Blockly.Tooltip.element_.tooltip&&!Blockly.Block.isDragging()&&!Blockly.WidgetDiv.isVisible())if(Blockly.Tooltip.visible){a=Blockly.mouseToSvg(a);var b=Blockly.Tooltip.lastXY_.y-a.y;Math.sqrt(Math.pow(Blockly.Tooltip.lastXY_.x-a.x,2)+Math.pow(b,2))>Blockly.Tooltip.RADIUS_OK&&Blockly.Tooltip.hide()}else Blockly.Tooltip.poisonedElement_!=Blockly.Tooltip.element_&&(window.clearTimeout(Blockly.Tooltip.showPid_),Blockly.Tooltip.lastXY_=
  Blockly.mouseToSvg(a),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(){Blockly.Tooltip.poisonedElement_=Blockly.Tooltip.element_;if(Blockly.Tooltip.svgGroup_){goog.dom.removeChildren(Blockly.Tooltip.svgText_);var a=Blockly.Tooltip.element_.tooltip;goog.isFunction(a)&&(a=a());for(var a=a.split("\n"),b=0;b<a.length;b++){var c=Blockly.createSvgElement("tspan",{dy:"1em",x:Blockly.Tooltip.MARGINS},Blockly.Tooltip.svgText_),d=document.createTextNode(a[b]);c.appendChild(d)}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",a={x:Blockly.Tooltip.svgText_.getBBox().x,y:Blockly.Tooltip.svgText_.getBBox().y,width:Blockly.Tooltip.svgText_.scrollWidth,height:Blockly.Tooltip.svgText_.scrollHeight}):a=Blockly.Tooltip.svgText_.getBBox();b=2*Blockly.Tooltip.MARGINS+a.width;c=a.height;Blockly.Tooltip.svgBackground_.setAttribute("width",b);Blockly.Tooltip.svgBackground_.setAttribute("height",c);Blockly.Tooltip.svgShadow_.setAttribute("width",
  b);Blockly.Tooltip.svgShadow_.setAttribute("height",c);if(Blockly.RTL)for(var c=a.width,d=0,e;e=Blockly.Tooltip.svgText_.childNodes[d];d++)e.setAttribute("text-anchor","end"),e.setAttribute("x",c+Blockly.Tooltip.MARGINS);c=Blockly.Tooltip.lastXY_.x;c=Blockly.RTL?c-(Blockly.Tooltip.OFFSET_X+b):c+Blockly.Tooltip.OFFSET_X;b=Blockly.Tooltip.lastXY_.y+Blockly.Tooltip.OFFSET_Y;d=Blockly.mainBlockSpaceEditor.svgSize();b+a.height>d.height&&(b-=a.height+2*Blockly.Tooltip.OFFSET_Y);Blockly.RTL?c=Math.max(Blockly.Tooltip.MARGINS,
  c):c+a.width>d.width-2*Blockly.Tooltip.MARGINS&&(c=d.width-a.width-2*Blockly.Tooltip.MARGINS);Blockly.Tooltip.svgGroup_.setAttribute("transform","translate("+c+","+b+")")}};Blockly.FieldLabel=function(a,b){b=b||{};this.sourceBlock_=null;this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText"},null);var c={width:0,height:25};this.forceWidth_=(this.forceSize_=b.hasOwnProperty("fixedSize"))&&void 0!==b.fixedSize.width;this.fontSize_=b.fontSize;this.size_=this.forceSize_?b.fixedSize:c;this.setText(a);this.fieldGroup_=this.textElement_};goog.inherits(Blockly.FieldLabel,Blockly.Field);Blockly.FieldLabel.prototype.EDITABLE=!1;
  Blockly.FieldLabel.prototype.init=function(a){if(this.sourceBlock_)throw"Text has already been initialized once.";this.sourceBlock_=a;a.getSvgRoot().appendChild(this.textElement_);this.textElement_.tooltip=this.sourceBlock_;Blockly.Tooltip&&Blockly.Tooltip.bindMouseEvents(this.textElement_)};Blockly.FieldLabel.prototype.getSize=function(){this.size_.width||this.forceWidth_||this.updateWidth_();return this.size_};
  Blockly.FieldLabel.prototype.getBufferY=function(){return this.fontSize_?(this.size_.height-this.fontSize_)/2:0};Blockly.FieldLabel.prototype.setText=function(a){null!==a&&a!==this.text_&&(this.text_=a,goog.dom.removeChildren(this.textElement_),a=a.replace(/\s/g,Blockly.Field.NBSP),a||(a=Blockly.Field.NBSP),a=document.createTextNode(a),this.textElement_.appendChild(a),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(a){this.textElement_.tooltip=a};Blockly.Input=function(a,b,c,d){this.type=a;this.name=b;this.sourceBlock_=c;this.connection=d;this.titleRow=[];this.align=Blockly.ALIGN_LEFT;this.inline_=!1;this.visible_=!0;this.colour_={hue:null,saturation:null,value:null}};
  Blockly.Input.prototype.appendTitle=function(a,b){if(!a&&!b)return this;goog.isString(a)&&(a=new Blockly.FieldLabel(a));this.sourceBlock_.svg_&&a.init(this.sourceBlock_);a.name=b;a.prefixTitle&&this.appendTitle(a.prefixTitle);this.titleRow.push(a);a.suffixTitle&&this.appendTitle(a.suffixTitle);this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_());return this};Blockly.Input.prototype.isVisible=function(){return this.visible_};
  Blockly.Input.prototype.setVisible=function(a){var b=[];if(this.visible_==a)return b;for(var c=(this.visible_=a)?"block":"none",d=0,e;e=this.titleRow[d];d++)e.setVisible(a);this.connection&&(b=a?this.connection.unhideAll():this.connection.hideAll(),d=this.connection.targetBlock())&&(d.svg_.getRootElement().style.display=c,a||(d.rendered=!1));return b};Blockly.Input.prototype.setCheck=function(a){if(!this.connection)throw"This input does not have a connection.";this.connection.setCheck(a);return this};
  Blockly.Input.prototype.setAlign=function(a){this.align=a;this.sourceBlock_.rendered&&this.sourceBlock_.render();return this};Blockly.Input.prototype.init=function(){for(var a=0;a<this.titleRow.length;a++)this.titleRow[a].init(this.sourceBlock_)};Blockly.Input.prototype.dispose=function(){for(var a=0,b;b=this.titleRow[a];a++)b.dispose();this.connection&&this.connection.dispose();this.sourceBlock_=null};
  Blockly.Input.prototype.setInline=function(a){void 0===a&&(a=!0);this.inline_=a;if(this.type===Blockly.NEXT_STATEMENT&&a)throw"Can't inline next statement";return this};Blockly.Input.prototype.isInline=function(){return this.type===Blockly.NEXT_STATEMENT?!1:this.inline_||this.sourceBlock_.inputsInline};Blockly.Input.prototype.setHSV=function(a,b,c){if(this.type!==Blockly.FUNCTIONAL_INPUT)throw"setColor only for functional inputs";this.colour_={hue:a,saturation:b,value:c};return this};
  Blockly.Input.prototype.getHexColour=function(){return Blockly.makeColour(this.colour_.hue,this.colour_.saturation,this.colour_.value)};Blockly.Input.prototype.matchesBlock=function(a){return a.getColour()!==this.colour_.hue||a.getSaturation()!==this.colour_.saturation||a.getValue()!==this.colour_.value?!1:!0};Blockly.Warning=function(a){Blockly.Warning.superClass_.constructor.call(this,a);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(a){var b=Blockly.createSvgElement("text",{"class":"blocklyText",y:Blockly.Bubble.BORDER_WIDTH},null);a=a.split("\n");for(var c=0;c<a.length;c++){var d=Blockly.createSvgElement("tspan",{dy:"1em",x:Blockly.Bubble.BORDER_WIDTH},b),e=document.createTextNode(a[c]);d.appendChild(e)}return b};
  Blockly.Warning.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){a=this.textToDom_(this.text_);this.bubble_=new Blockly.Bubble(this.block_.blockSpace,a,this.block_.svg_.svgGroup_,this.iconX_,this.iconY_,null,null);if(Blockly.RTL){if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){a.style.display="inline";var b={x:a.getBBox().x,y:a.getBBox().y,width:a.scrollWidth,height:a.scrollHeight}.width}else b=a.getBBox().width;for(var c=0,d;d=a.childNodes[c];c++)d.setAttribute("text-anchor",
  "end"),d.setAttribute("x",b+Blockly.Bubble.BORDER_WIDTH)}this.updateColour();a=this.bubble_.getBubbleSize();this.bubble_.setBubbleSize(a.width,a.height)}else this.bubble_.dispose(),this.foreignObject_=this.body_=this.bubble_=null};Blockly.Warning.prototype.bodyFocus_=function(a){this.bubble_.promote_()};Blockly.Warning.prototype.setText=function(a){this.text_=a;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(a,b,c){this.id=++Blockly.uidCounter_;this.htmlId=c;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=
  a;this.isInFlyout=a.isFlyout;this.colourSaturation_=0.45;this.colourValue_=0.65;this.fillPattern_=null;this.blockSvgClass_=Blockly.BlockSvg;this.customOptions_={};this.beforeDispose=null;this.setRenderBlockSpace(a);if(b){this.type=b;a=Blockly.Blocks[b];if(!a)throw'Error: "'+b+'" is an unknown language block.';goog.mixin(this,a)}goog.isFunction(this.init)&&this.init();this.shouldHideIfInMainBlockSpace&&this.shouldHideIfInMainBlockSpace()&&this.blockSpace===Blockly.mainBlockSpace&&this.setCurrentlyHidden(!0);
  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.comment=null;Blockly.Block.prototype.warning=null;Blockly.Block.prototype.init=null;Blockly.Block.prototype.onchange=null;
  Blockly.Block.prototype.setRenderBlockSpace=function(a){this.blockSpace=a;this.blockSpace.addTopBlock(this);goog.isFunction(this.onchange)&&Blockly.bindEvent_(this.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this,this.onchange)};Blockly.Block.prototype.getIcons=function(){var a=[];this.mutator&&a.push(this.mutator);this.comment&&a.push(this.comment);this.warning&&a.push(this.warning);return a};
  Blockly.Block.prototype.initSvg=function(){this.svg_=new this.blockSvgClass_(this,this.customOptions_);this.svg_.init();this.blockSpace.isReadOnly()||Blockly.bindEvent_(this.svg_.getRootElement(),"mousedown",this,this.onMouseDown_);this.setCurrentlyHidden(this.currentlyHidden_);this.moveToFrontOfMainCanvas_()};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.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 a=Blockly.selected;if(Blockly.Block.isFreelyDragging()&&a){a.blockSpace.clearPickedUpBlockOrigin();a.blockSpace.stopAutoScrolling();var b=a.getRelativeToSurfaceXY();a.moveConnections_(b.x-a.startDragX,
  b.y-a.startDragY);delete a.draggedBubbles_;a.setDragging_(!1);a.moveToFrontOfMainCanvas_();a.render();goog.Timer.callOnce(a.bumpNeighbours_,Blockly.BUMP_DELAY,a);a.blockSpace.blockSpaceEditor.bumpBlocksIntoBlockSpace();a.blockSpace.scrollIntoView(a);Blockly.fireUiEvent(window,"resize")}a&&(a.blockSpace.fireChangeEvent(),a.blockSpace.blockSpaceEditor.setCursor(Blockly.Css.Cursor.OPEN));Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_NOT_DRAGGING;a&&a.blockEvents.dispatchEvent(Blockly.Block.EVENTS.AFTER_DROPPED)};
  Blockly.Block.prototype.select=function(a){if(!this.svg_)throw"Block is not rendered.";Blockly.selected&&Blockly.selected.unselect();Blockly.selected=this;this.svg_.addSelect();a&&this.svg_.addSpotlight();Blockly.fireUiEvent(this.blockSpace.getCanvas(),"blocklySelectChange")};Blockly.Block.prototype.unselect=function(){if(!this.svg_)throw"Block is not rendered.";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(a,b){goog.isFunction(this.beforeDispose)&&this.beforeDispose();this.rendered=!1;this.unplug(a);b&&this.svg_&&this.svg_.disposeUiEffect();var c=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();for(var d=this.childBlocks_.length-1;0<=
  d;d--)this.childBlocks_[d].dispose(!1);for(var e=this.getIcons(),d=0;d<e.length;d++)e[d].dispose();for(d=0;e=this.inputList[d];d++)e.dispose();this.inputList=[];e=this.getConnections_(!0);for(d=0;d<e.length;d++){var f=e[d];f.targetConnection&&f.disconnect();e[d].dispose()}this.svg_&&(this.svg_.dispose(),this.svg_=null);this.blockEvents.dispatchEvent(Blockly.Block.EVENTS.AFTER_DISPOSED);c()};
  Blockly.Block.prototype.unplug=function(a,b){b=b&&!!this.getParent();if(this.outputConnection)this.outputConnection.targetConnection&&this.setParent(null);else{var c=null;this.previousConnection&&this.previousConnection.targetConnection&&(c=this.previousConnection.targetConnection,this.setParent(null));if(a&&this.nextConnection&&this.nextConnection.targetConnection){var d=this.nextConnection.targetConnection;this.nextConnection.targetBlock().setParent(null);c&&c.connect(d)}}b&&this.moveBy(Blockly.SNAP_RADIUS*
  (Blockly.RTL?-1:1),2*Blockly.SNAP_RADIUS)};Blockly.Block.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=!1;if(this.svg_){var d=this.svg_.getRootElement();do c=Blockly.getRelativeXY(d),a+=c.x,b+=c.y,d=d.parentNode,c=d==this.blockSpace.getCanvas()||d==this.blockSpace.getDragCanvas();while(d&&!c)}return{x:a,y:b}};
  Blockly.Block.prototype.moveTo=function(a,b){var c=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+a+", "+b+")");this.moveConnections_(a-c.x,b-c.y)};Blockly.Block.prototype.moveBy=function(a,b){var c=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+(c.x+a)+", "+(c.y+b)+")");this.moveConnections_(a,b)};
  Blockly.Block.prototype.getBox=function(){var a=this.getHeightWidth(),b=this.getRelativeToSurfaceXY();this.outputConnection&&(b.x-=Blockly.BlockSvg.TAB_WIDTH);return new goog.math.Box(b.y,b.x+a.width,b.y+a.height,b.x)};Blockly.Block.prototype.getSvgPadding=function(){return this.svg_&&this.svg_.getPadding()};
  Blockly.Block.prototype.getHeightWidth=function(){var a;try{var b=Blockly.ieVersion()&&10>=Blockly.ieVersion(),c;b&&(c=this.getSvgRoot().style.display,this.getSvgRoot().style.display="inline");a=goog.object.clone(this.getSvgRoot().getBBox());b&&(this.getSvgRoot().style.display=c)}catch(d){return{height:0,width:0}}b=0;Blockly.BROKEN_CONTROL_POINTS&&(a.height-=10,this.nextConnection&&(a.height+=4),b=-5);0<a.height&&(a.height-=1);a.height=Math.max(0,a.height+(a.y-b));return a};
  Blockly.Block.prototype.onMouseDown_=function(a){a.preventDefault();if("inputClickTarget"===(a.target.getAttribute&&a.target.getAttribute("class")))a.stopPropagation();else if(document.activeElement&&document.activeElement.blur&&document.activeElement.blur(),!this.isInFlyout){this.blockSpace.blockSpaceEditor.svgResize();Blockly.BlockSpaceEditor.terminateDrag_();this.select();this.blockSpace.blockSpaceEditor.hideChaff();if(Blockly.isRightButton(a))Blockly.editBlocks&&this.showContextMenu_(a);else if(this.isMovable()&&
  this.canDisconnectFromParent()){Blockly.removeAllRanges();this.blockSpace.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED);var b=this.getRelativeToSurfaceXY();this.startDragX=b.x;this.startDragY=b.y;void 0!==a.startDragMouseX_&&void 0!==a.startDragMouseY_?(this.startDragMouseX=a.startDragMouseX_,this.startDragMouseY=a.startDragMouseY_,a.startDragMouseX_=void 0,a.startDragMouseY_=void 0):(this.startDragMouseX=a.clientX,this.startDragMouseY=a.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_=[];for(var b=this.getDescendants(),c=0,d;d=b[c];c++){d=d.getIcons();for(var e=0;e<d.length;e++){var f=d[e].getIconLocation();f.bubble=d[e];this.draggedBubbles_.push(f)}}}else return;a.stopPropagation()}};
  Blockly.Block.prototype.onMouseUp_=function(a){var b=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(),b.trashcan&&b.trashcan.close()):Blockly.selected&&Blockly.selected.areBlockAndDescendantsDeletable()&&b.isDeleteArea(a.clientX,a.clientY,
  this.startDragMouseX)&&((a=b.trashcan)&&goog.Timer.callOnce(a.close,100,a),Blockly.selected.dispose(!1,!0),Blockly.fireUiEvent(window,"resize"));Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);b.hideDelete();b.blockSpaceEditor.setCursor(Blockly.Css.Cursor.OPEN)};Blockly.Block.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
  Blockly.Block.prototype.duplicate_=function(){var a=Blockly.Xml.blockToDom(this);Blockly.Xml.deleteNext(a);var a=Blockly.Xml.domToBlock(this.blockSpace,a),b=this.getRelativeToSurfaceXY();b.x=Blockly.RTL?b.x-Blockly.SNAP_RADIUS:b.x+Blockly.SNAP_RADIUS;b.y+=2*Blockly.SNAP_RADIUS;a.moveBy(b.x,b.y);return a};
  Blockly.Block.prototype.showContextMenu_=function(a){if(!this.blockSpace.isReadOnly()&&this.contextMenu){var b=this,c=[];if(this.isDeletable()&&!b.isInFlyout){var d={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){b.duplicate_()}};this.getDescendants().length>this.blockSpace.remainingCapacity()&&(d.enabled=!1);c.push(d);d={text:this.disabled?Blockly.Msg.ENABLE_BLOCK:Blockly.Msg.DISABLE_BLOCK,enabled:!this.getInheritedDisabled(),callback:function(){b.setDisabled(!b.disabled)}};c.push(d);
  d=this.getDescendants().length;b.nextConnection&&b.nextConnection.targetConnection&&(d-=this.nextConnection.targetBlock().getDescendants().length);d={text:1==d?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",d),enabled:!0,callback:function(){b.dispose(!0,!0)}};c.push(d)}Blockly.editBlocks&&(c.push({text:this.userVisible_?"Make Invisible to Users":"Make Visible to Users",enabled:!0,callback:function(){b.setUserVisible(!b.isUserVisible());Blockly.ContextMenu.hide()}}),c.push({text:this.deletable_?
  "Make Undeletable to Users":"Make Deletable to Users",enabled:!0,callback:function(){b.setDeletable(!b.isDeletable());Blockly.ContextMenu.hide()}}),c.push({text:this.movable_?"Make Immovable to Users":"Make Movable to Users",enabled:!0,callback:function(){b.setMovable(!b.isMovable());Blockly.ContextMenu.hide()}}));this.customContextMenu&&!b.isInFlyout&&this.customContextMenu(c);Blockly.ContextMenu.show(a,c);Blockly.ContextMenu.currentBlock=this}};
  Blockly.Block.prototype.getConnections_=function(a){var b=[];if(a||this.rendered)if(this.outputConnection&&b.push(this.outputConnection),this.nextConnection&&b.push(this.nextConnection),this.previousConnection&&b.push(this.previousConnection),a||!this.collapsed_){a=0;for(var c;c=this.inputList[a];a++)c.connection&&b.push(c.connection)}return b};
  Blockly.Block.prototype.getLeafConnections_=function(a){var b=this,c=[],d=[this.outputConnection,this.nextConnection,this.previousConnection];this.inputList.forEach(function(a){d.push(a.connection)});d.forEach(function(d){if(d){var f=d.targetBlock();f?f!==a&&(c=c.concat(f.getLeafConnections_(b))):c.push(d)}});return c};
  Blockly.Block.prototype.moveConnections_=function(a,b){if(this.rendered){for(var c=this.getConnections_(!1),d=0;d<c.length;d++)c[d].moveBy(a,b);c=this.getIcons();for(d=0;d<c.length;d++)c[d].computeIconLocation();for(d=0;d<this.childBlocks_.length;d++)this.childBlocks_[d].moveConnections_(a,b)}};Blockly.Block.prototype.setDragging_=function(a){this.setDraggingHandleImmovable_(a,null)};Blockly.Block.prototype.getDragging=function(){return this.dragging_};
  Blockly.Block.prototype.setDraggingHandleImmovable_=function(a,b){a?(this.dragging_=!0,this.svg_.addDragging()):(this.dragging_=!1,this.svg_.removeDragging());for(var c=0;c<this.childBlocks_.length;c++){var d=this.childBlocks_[c];if(a&&null!==b&&!d.isMovable()){b(d);break}d.setDraggingHandleImmovable_(a,b)}};Blockly.Block.prototype.setCanDisconnectFromParent=function(a){this.canDisconnectFromParent_=a};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(a,b){Blockly.removeAllRanges();var c=a-this.startDragMouseX,d=b-this.startDragMouseY;if(Blockly.Block.dragMode_==Blockly.Block.DRAG_MODE_INSIDE_STICKY_RADIUS&&Math.sqrt(Math.pow(c,2)+Math.pow(d,2))>Blockly.DRAG_RADIUS){Blockly.Block.dragMode_=Blockly.Block.DRAG_MODE_FREELY_DRAGGING;var e=this.generateReconnector_(this.previousConnection);this.setParent(null);this.setDraggingHandleImmovable_(!0,e);this.moveToDragCanvas_();this.blockSpace.recordPickedUpBlockOrigin();
  this.blockSpace.recordDeleteAreas()}if(Blockly.Block.dragMode_==Blockly.Block.DRAG_MODE_FREELY_DRAGGING){var e=this.startDragX+c,f=this.startDragY+d;this.svg_.getRootElement().setAttribute("transform","translate("+e+", "+f+")");for(e=0;e<this.draggedBubbles_.length;e++)f=this.draggedBubbles_[e],f.bubble.setIconLocation(f.x+c,f.y+d);for(var f=this.getLeafConnections_(null),g=null,h=null,k=Blockly.SNAP_RADIUS,e=0;e<f.length;e++){var l=f[e],m=l.closest(k,c,d);m.connection&&(g=m.connection,h=l,k=m.radius)}Blockly.highlightedConnection_&&
  Blockly.highlightedConnection_!=g&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null,Blockly.localConnection_=null);g&&g!=Blockly.highlightedConnection_&&(g.highlight(),Blockly.highlightedConnection_=g,Blockly.localConnection_=h);this.areBlockAndDescendantsDeletable()&&this.blockSpace.isDeleteArea(a,b,this.startDragMouseX)}};
  Blockly.Block.prototype.onMouseMove_=function(a){"mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button||(this.moveBlockBeingDragged_(a.clientX,a.clientY),this.blockSpace.panIfOverEdge(this,a.clientX,a.clientY));a.stopPropagation()};Blockly.Block.prototype.generateReconnector_=function(a){var b;a&&a.targetConnection&&(b=a.targetConnection);return function(a){a.previousConnection&&(a.setParent(null),b&&b.connect(a.previousConnection))}};
  Blockly.Block.prototype.bumpNeighbours_=function(){if(!Blockly.Block.isDragging()&&Blockly.BUMP_UNCONNECTED){var a=this.getRootBlock();if(!a.isInFlyout)for(var b=this.getConnections_(!1),c=0;c<b.length;c++){var d=b[c];d.targetConnection&&d.isSuperior()&&d.targetBlock().bumpNeighbours_();for(var e=d.neighbours_(Blockly.SNAP_RADIUS),f=0;f<e.length;f++){var g=e[f];d.targetConnection&&g.targetConnection||g.sourceBlock_.getRootBlock()!=a&&(d.isSuperior()?g.bumpAwayFrom_(d):d.bumpAwayFrom_(g))}}}};
  Blockly.Block.prototype.getParent=function(){return this.parentBlock_};Blockly.Block.prototype.getSurroundParent=function(){for(var a=this;;){do{var b=a,a=a.getParent();if(!a)return null}while(a.nextConnection&&a.nextConnection.targetBlock()==b);return a}};Blockly.Block.prototype.getRootBlock=function(){var a,b=this;do a=b,b=a.parentBlock_;while(b);return a};Blockly.Block.prototype.getChildren=function(){return this.childBlocks_};
  Blockly.Block.prototype.setParent=function(a){if(this.parentBlock_){for(var b=this.parentBlock_.childBlocks_,c,d=0;c=b[d];d++)if(c==this){b.splice(d,1);break}b=this.getRelativeToSurfaceXY();this.moveToFrontOfMainCanvas_();this.svg_.getRootElement().setAttribute("transform","translate("+b.x+", "+b.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.parentBlock_=a)?(a.childBlocks_.push(this),b=this.getRelativeToSurfaceXY(),a.svg_&&this.svg_&&a.svg_.getRootElement().appendChild(this.svg_.getRootElement()),a=this.getRelativeToSurfaceXY(),this.moveConnections_(a.x-b.x,a.y-b.y)):this.blockSpace.addTopBlock(this)};Blockly.Block.prototype.getDescendants=function(){for(var a=[this],b,c=0;b=this.childBlocks_[c];c++)a=a.concat(b.getDescendants());return a};
  Blockly.Block.prototype.areBlockAndDescendantsDeletable=function(){var a=this.childBlocks_.some(function(a){return!a.areBlockAndDescendantsDeletable()});return this.isDeletable()&&!a};Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.blockSpace.isReadOnly()};Blockly.Block.prototype.setDeletable=function(a){this.deletable_=a;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(a){this.movable_=a;this.svg_&&this.svg_.updateMovable()};Blockly.Block.prototype.isEditable=function(){return this.editable_&&!this.blockSpace.isReadOnly()};
  Blockly.Block.prototype.setEditable=function(a){this.editable_=a;for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.titleRow[d];d++)e.updateEditable();c=this.getIcons();for(b=0;b<c.length;b++)c[b].updateEditable();this.editLabel_&&this.editLabel_.setVisible(a)};Blockly.Block.prototype.isUserVisible=function(){return this.userVisible_};
  Blockly.Block.prototype.setUserVisible=function(a,b){(this.userVisible_=a)?this.svg_&&Blockly.removeClass_(this.svg_.svgGroup_,"userHidden"):this.svg_&&Blockly.addClass_(this.svg_.svgGroup_,"userHidden");this.childBlocks_.forEach(function(c){c.setUserVisible(a,b)});b&&a&&0===this.childBlocks_.length&&this.svg_&&this.render()};Blockly.Block.prototype.setNextConnectionDisabled=function(a){this.nextConnectionDisabled_=a;!0===this.nextConnectionDisabled_&&this.setNextStatement(!1)};
  Blockly.Block.prototype.isCurrentlyBeingDragged=function(){return Blockly.selected===this&&Blockly.Block.isFreelyDragging()};Blockly.Block.prototype.isCurrentlyHidden_=function(){return this.currentlyHidden_};Blockly.Block.prototype.setCurrentlyHidden=function(a){this.currentlyHidden_=a;this.svg_&&(this.svg_.setVisible(!a),a||this.refreshRender())};
  Blockly.Block.prototype.isVisible=function(){var a=(!this.parentBlock_||this.parentBlock_.isVisible())&&!this.isCurrentlyHidden_();return Blockly.editBlocks?a:a&&this.isUserVisible()};Blockly.Block.prototype.setHelpUrl=function(a){this.helpUrl=a};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(a){this.colourHue_=a;this.svg_&&this.svg_.updateColour();var b=this.getIcons();for(a=0;a<b.length;a++)b[a].updateColour();if(this.rendered){for(a=0;b=this.inputList[a];a++)for(var c=0,d;d=b.titleRow[c];c++)d.setText(null);this.render()}};Blockly.Block.prototype.setFillPattern=function(a){this.fillPattern_=a};Blockly.Block.prototype.setFramed=function(a){this.blockSvgClass_=a?Blockly.BlockSvgFramed:Blockly.BlockSvg};
  Blockly.Block.prototype.setFunctional=function(a,b){this.blockSvgClass_=a?Blockly.BlockSvgFunctional:Blockly.BlockSvg;this.customOptions_=a?b:{}};Blockly.Block.prototype.setHSV=function(a,b,c){this.colourHue_=a;this.colourSaturation_=b;this.colourValue_=c;this.svg_&&this.svg_.updateColour();b=this.getIcons();for(a=0;a<b.length;a++)b[a].updateColour();if(this.rendered){for(a=0;b=this.inputList[a];a++){c=0;for(var d;d=b.titleRow[c];c++)d.setText(null)}this.render()}};
  Blockly.Block.prototype.getTitle_=function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.titleRow[d];d++)if(e.name===a)return e;return null};Blockly.Block.prototype.getTitles=function(){for(var a=[],b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.titleRow[d];d++)a.push(e);return a};Blockly.Block.prototype.getTitleValue=function(a){return(a=this.getTitle_(a))?a.getValue():null};
  Blockly.Block.prototype.setTitleValue=function(a,b){var c=this.getTitle_(b);if(c)c.setValue(a);else throw'Title "'+b+'" not found.';};Blockly.Block.prototype.setFieldConfig=function(a,b){var c=this.getTitle_(a);if(!c)throw'Title "'+name+'" not found.';c.setConfig&&c.setConfig(b)};Blockly.Block.prototype.setTooltip=function(a){this.tooltip=a};
  Blockly.Block.prototype.setPreviousStatement=function(a,b){if(this.previousConnection){if(this.previousConnection.targetConnection)throw"Must disconnect previous statement before removing connection.";this.previousConnection.dispose();this.previousConnection=null}if(a){if(this.outputConnection)throw"Remove output connection prior to adding previous connection.";void 0===b&&(b=null);this.previousConnection=new Blockly.Connection(this,Blockly.PREVIOUS_STATEMENT);this.previousConnection.setCheck(b)}this.refreshRender()};
  Blockly.Block.prototype.setNextStatement=function(a,b){if(this.nextConnection){if(this.nextConnection.targetConnection)throw"Must disconnect next statement before removing connection.";this.nextConnection.dispose();this.nextConnection=null}a&&(void 0===b&&(b=null),this.nextConnection=new Blockly.Connection(this,Blockly.NEXT_STATEMENT),this.nextConnection.setCheck(b));this.refreshRender()};
  Blockly.Block.prototype.setOutput=function(a,b){if(this.outputConnection){if(this.outputConnection.targetConnection)throw"Must disconnect output value before removing connection.";this.outputConnection.dispose();this.outputConnection=null}if(a){if(this.previousConnection)throw"Remove previous connection prior to adding output connection.";void 0===b&&(b=null);this.outputConnection=new Blockly.Connection(this,Blockly.OUTPUT_VALUE);this.outputConnection.setCheck(b)}this.refreshRender()};
  Blockly.Block.prototype.refreshRender=function(){this.rendered&&(this.render(),this.bumpNeighbours_())};
  Blockly.Block.prototype.setFunctionalOutput=function(a,b){if(this.previousConnection){if(this.previousConnection.targetConnection)throw"Must disconnect output value before removing connection.";this.previousConnection.dispose();this.previousConnection=null}if(a){if(this.previousConnection)throw"Remove previous connection prior to adding output connection.";void 0===b&&(b=null);this.previousConnection=new Blockly.Connection(this,Blockly.FUNCTIONAL_OUTPUT);this.previousConnection.setCheck(b)}this.refreshRender()};
  Blockly.Block.prototype.changeFunctionalOutput=function(a){this.setHSV.apply(this,Blockly.FunctionalTypeColors[a]);this.previousConnection=this.previousConnection||new Blockly.Connection(this,Blockly.FUNCTIONAL_OUTPUT);this.previousConnection.setCheck(a);this.refreshRender()};Blockly.Block.prototype.setInputsInline=function(a){this.inputsInline=a;this.rendered&&(this.render(),this.bumpNeighbours_(),this.blockSpace.fireChangeEvent())};
  Blockly.Block.prototype.setDisabled=function(a){this.disabled!=a&&(this.disabled=a,this.svg_.updateDisabled(),this.blockSpace.fireChangeEvent())};Blockly.Block.prototype.getInheritedDisabled=function(){for(var a=this;;){a=a.getSurroundParent();if(!a)return!1;if(a.disabled)return!0}};Blockly.Block.prototype.isCollapsed=function(){return this.collapsed_};
  Blockly.Block.prototype.setCollapsed=function(a){if(this.collapsed_!=a){this.collapsed_=a;for(var b=[],c=0,d;d=this.inputList[c];c++)b=b.concat(d.setVisible(!a));if(a){a=this.getIcons();for(c=0;c<a.length;c++)a[c].setVisible(!1);c=this.toString(Blockly.COLLAPSE_CHARS);this.appendDummyInput("_TEMP_COLLAPSED_INPUT").appendTitle(c)}else this.removeInput("_TEMP_COLLAPSED_INPUT");b.length||(b[0]=this);if(this.rendered){for(c=0;a=b[c];c++)a.render();this.bumpNeighbours_()}}};
  Blockly.Block.prototype.toString=function(a){for(var b=[],c=0,d;d=this.inputList[c];c++){for(var e=0,f;f=d.titleRow[e];e++)b.push(f.getText());d.connection&&((d=d.connection.targetBlock())?b.push(d.toString()):b.push("?"))}b=goog.string.trim(b.join(" "))||"???";a&&(b=goog.string.truncate(b,a));return b};Blockly.Block.prototype.appendValueInput=function(a){return this.appendInput_(Blockly.INPUT_VALUE,a)};
  Blockly.Block.prototype.appendStatementInput=function(a){return this.appendInput_(Blockly.NEXT_STATEMENT,a)};Blockly.Block.prototype.appendDummyInput=function(a){return this.appendInput_(Blockly.DUMMY_INPUT,a||"")};Blockly.Block.prototype.appendFunctionalInput=function(a){return this.appendInput_(Blockly.FUNCTIONAL_INPUT,a)};
  Blockly.Block.prototype.interpolateMsg=function(a,b){goog.asserts.assertString(a);var c=arguments.length-1;goog.asserts.assertNumber(c);for(var d=a.split(/(%\d)/),e=0;e<d.length;e+=2){var f=goog.string.trim(d[e]),g=d[e+1];if(g){var h=window.parseInt(g.charAt(1),10),k=arguments[h];goog.asserts.assertArray(k,'Message symbol "%s" is out of range.',g);this.appendValueInput(k[0]).setCheck(k[1]).setAlign(k[2]).appendTitle(f);arguments[h]=null}else f&&this.appendDummyInput().setAlign(c).appendTitle(f)}for(e=
  1;e<arguments.length-1;e++)goog.asserts.assert(null===arguments[e],'Input "%%s" not used in message: "%s"',e,a);this.setInputsInline(!a.match(/%1\s*$/))};Blockly.Block.prototype.appendInput_=function(a,b){var c=null;if(a===Blockly.INPUT_VALUE||a===Blockly.NEXT_STATEMENT||a===Blockly.FUNCTIONAL_INPUT)c=new Blockly.Connection(this,a);c=new Blockly.Input(a,b,this,c);this.inputList.push(c);this.rendered&&(this.render(),this.bumpNeighbours_());return c};
  Blockly.Block.prototype.moveInputBefore=function(a,b){if(a==b)throw"Can't move \""+a+'" to itself.';for(var c=-1,d=-1,e=0,f;f=this.inputList[e];e++)if(f.name==a){if(c=e,-1!=d)break}else if(f.name==b&&(d=e,-1!=c))break;if(-1==c)throw'Named input "'+a+'" not found.';if(-1==d)throw'Reference input "'+a+'" not found.';this.inputList.splice(c,1);c<d&&d--;this.inputList.splice(d,0,f);this.rendered&&(this.render(),this.bumpNeighbours_())};
  Blockly.Block.prototype.removeInput=function(a,b){for(var c=0,d;d=this.inputList[c];c++)if(d.name==a){d.connection&&d.connection.targetConnection&&d.connection.targetBlock().setParent(null);d.dispose();this.inputList.splice(c,1);this.rendered&&(this.render(),this.bumpNeighbours_());return}b||goog.asserts.fail('Input "%s" not found.',a)};Blockly.Block.prototype.getInput=function(a){for(var b=0,c;c=this.inputList[b];b++)if(c.name==a)return c;return null};
  Blockly.Block.prototype.getInputTargetBlock=function(a){return(a=this.getInput(a))&&a.connection&&a.connection.targetBlock()};Blockly.Block.prototype.attachBlockToInputName=function(a,b){var c=this.getInput(b);if(!c||!c.connection)throw"Block has no input named "+name;a.previousConnection.connect(c.connection)};Blockly.Block.prototype.setMutator=function(a){this.mutator&&this.mutator!==a&&this.mutator.dispose();a&&(a.block_=this,this.mutator=a,this.svg_&&a.createIcon())};
  Blockly.Block.prototype.getCommentText=function(){return this.comment?this.comment.getText().replace(/\s+$/,"").replace(/ +\n/g,"\n"):""};Blockly.Block.prototype.setCommentText=function(a){if(!Blockly.Comment)throw"Comments not supported.";var b=!1;goog.isString(a)?(this.comment||(this.comment=new Blockly.Comment(this),b=!0),this.comment.setText(a)):this.comment&&(this.comment.dispose(),b=!0);this.rendered&&(this.render(),b&&this.bumpNeighbours_())};
  Blockly.Block.prototype.setWarningText=function(a){if(!Blockly.Warning)throw"Warnings not supported.";this.isInFlyout&&(a=null);var b=!1;goog.isString(a)?(this.warning||(this.warning=new Blockly.Warning(this),b=!0),this.warning.setText(a)):this.warning&&(this.warning.dispose(),b=!0);b&&this.rendered&&(this.render(),this.bumpNeighbours_())};Blockly.Block.prototype.svgInitialized=function(){return!!this.svg_};
  Blockly.Block.prototype.render=function(){if(!this.svg_)throw"Uninitialized block cannot be rendered.  Call block.initSvg()";this.svg_.render()};Blockly.Block.prototype.getSvgRenderer=function(){return this.svg_};Blockly.Block.prototype.getRootBlock=function(){for(var a,b=this;b;)a=b,b=b.getParent();return a};Blockly.Block.prototype.hasUnfilledFunctionalInput=function(){return this.inputList.some(function(a){return a.type===Blockly.FUNCTIONAL_INPUT&&a.connection&&!a.connection.targetBlock()})};Blockly.Flyout=function(a,b){var c=this;this.blockSpaceEditor_=a;this.blockSpace_=new Blockly.BlockSpace(a,function(){return c.getMetrics_()},function(a){return c.setMetrics_(a)});this.blockSpace_.isFlyout=!0;this.static_=b;this.changeWrapper_=null;this.height_=this.width_=0;this.buttons_=[];this.listeners_=[];this.enabled_=!0};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;Blockly.Flyout.prototype.onResizeWrapper_=null;
  Blockly.Flyout.prototype.createDom=function(a){this.svgGroup_=Blockly.createSvgElement("g",{"class":"svgFlyoutGroup"},null);this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.blockSpace_.createDom());a||(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_));return 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_=null;this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.targetBlockSpace_=this.svgBackground_=null};
  Blockly.Flyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;var a=this.height_-2*this.CORNER_RADIUS,b=this.width_;try{if(Blockly.isMsie()||Blockly.isTrident()){this.blockSpace_.getCanvas().style.display="inline";var c={x:this.blockSpace_.getCanvas().getBBox().x,y:this.blockSpace_.getCanvas().getBBox().y,width:this.blockSpace_.getCanvas().scrollWidth,height:this.blockSpace_.getCanvas().scrollHeight}}else c=this.blockSpace_.getCanvas().getBBox()}catch(d){c={height:0,y:0}}return{viewHeight:a,
  viewWidth:b,contentHeight:c.height+c.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(a){var b=this.getMetrics_();goog.isNumber(a.y)&&(this.blockSpace_.yOffsetFromView=-b.contentHeight*a.y-b.contentTop);a=this.blockSpace_.yOffsetFromView+b.absoluteTop;this.blockSpace_.getCanvas().setAttribute("transform","translate(0,"+a+")");this.blockSpace_.getDragCanvas().setAttribute("transform","translate(0,"+a+")")};
  Blockly.Flyout.prototype.init=function(a,b){this.targetBlockSpace_=a;b&&(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.filterForCapacity_)};
  Blockly.Flyout.prototype.position_=function(){if(this.isVisible()){var a=this.targetBlockSpace_.customFlyoutMetrics_?this.targetBlockSpace_.customFlyoutMetrics_():this.targetBlockSpace_.getMetrics();if(a){var b=this.width_-this.CORNER_RADIUS;Blockly.RTL&&(b*=-1);var c=["M "+(Blockly.RTL?this.width_:0)+",0"];c.push("h",b);c.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);c.push("v",Math.max(0,a.viewHeight-2*this.CORNER_RADIUS));
  c.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);c.push("h",-b);c.push("z");this.svgBackground_.setAttribute("d",c.join(" "));b=a.absoluteLeft;c=a.absoluteTop;Blockly.RTL?(b=this.static_?0:-this.width_,b+=a.viewWidth):this.static_&&(b-=this.width_);this.svgGroup_.setAttribute("transform","translate("+b+","+c+")");this.height_=a.viewHeight;this.blockSpace_.updateScrollableSize();this.svgTrashcan_&&(a=this.svgGroup_.getBoundingClientRect().width,
  a=Math.round(a/2-35),this.svgTrashcan_.setAttribute("transform","translate("+a+", 20)"))}}};Blockly.Flyout.prototype.isVisible=function(){return"block"==this.svgGroup_.style.display};
  Blockly.Flyout.prototype.hide=function(a){if(this.isVisible()){this.svgGroup_.style.display="none";this.blockSpace_.unbindBeginPanDragHandler();for(var b=0,c;c=this.listeners_[b];b++)Blockly.unbindEvent_(c);this.listeners_.splice(0);this.reflowWrapper_&&(Blockly.unbindEvent_(this.reflowWrapper_),this.reflowWrapper_=null);this.blockSpace_.getTopBlocks(!1).forEach(function(b){b!==a&&b.dispose(!1,!1)});for(b=0;c=this.buttons_[b];b++)goog.dom.removeNode(c);goog.dom.removeNode(goog.dom.getElementByClass("createFunction",
  this.blockSpace_.svgGroup_));this.buttons_.splice(0)}};Blockly.Flyout.prototype.layoutBlock_=function(a,b,c,d){d=a.getHeightWidth();a.moveBy(b.x,b.y);b.y+=d.height+c};
  Blockly.Flyout.prototype.show=function(a){this.hide();this.svgGroup_.style.display="block";var b=this.CORNER_RADIUS,c=Blockly.RTL?this.width_:b+Blockly.BlockSvg.TAB_WIDTH,d={x:c,y:b};this.blockSpace_.bindBeginPanDragHandler(this.svgBackground_);this.blockSpace_.bindScrollOnWheelHandler(this.svgGroup_);var e=[],f=[];this.minFlyoutWidth_=0;var g=a&&a[0];if(g===Blockly.Variables.NAME_TYPE){for(var g=1,h;h=a[g];g++)h.tagName&&"BLOCK"===h.tagName.toUpperCase()&&(e.push(Blockly.Xml.domToBlock(this.blockSpace_,
  h)),f.push(3*b));Blockly.Variables.flyoutCategory(e,f,b,this.blockSpace_)}else if(g===Blockly.Procedures.NAME_TYPE)Blockly.functionEditor&&!Blockly.functionEditor.isOpen()&&this.addButtonToFlyout_(d,Blockly.Msg.FUNCTION_CREATE,this.createFunction_),Blockly.Procedures.flyoutCategory(e,f,b,this.blockSpace_,function(a){return!a.isFunctionalVariable});else if(g===Blockly.Procedures.NAME_TYPE_FUNCTIONAL_VARIABLE)Blockly.functionEditor&&!Blockly.functionEditor.isOpen()&&this.addButtonToFlyout_(d,Blockly.Msg.FUNCTIONAL_VARIABLE_CREATE,
  this.createFunctionalVariable_),Blockly.Procedures.flyoutCategory(e,f,b,this.blockSpace_,function(a){return a.isFunctionalVariable});else for(g=0;h=a[g];g++)h.tagName&&"BLOCK"===h.tagName.toUpperCase()&&(e.push(Blockly.Xml.domToBlock(this.blockSpace_,h)),f.push(3*b));for(g=0;a=e[g];g++){b=a.getDescendants();h=0;for(var k;k=b[h];h++)k.isInFlyout=!0,k.setCommentText(null);a.render();this.layoutBlock_(a,d,f[g],c);b=Blockly.createSvgElement("rect",{"fill-opacity":0},null);this.blockSpace_.getCanvas().insertBefore(b,
  a.getSvgRoot());a.flyoutRect_=b;this.buttons_[g]=b;h=a.getSvgRoot();this.autoClose?this.listeners_.push(Blockly.bindEvent_(h,"mousedown",null,this.createBlockFunc_(a))):this.listeners_.push(Blockly.bindEvent_(h,"mousedown",null,this.blockMouseDown_(a)));this.listeners_.push(Blockly.bindEvent_(h,"mouseover",a.svg_,a.svg_.addSelectNoMove));this.listeners_.push(Blockly.bindEvent_(h,"mouseout",a.svg_,a.svg_.removeSelect));this.listeners_.push(Blockly.bindEvent_(b,"mousedown",null,this.createBlockFunc_(a)));
  this.listeners_.push(Blockly.bindEvent_(b,"mouseover",a.svg_,a.svg_.addSelectNoMove));this.listeners_.push(Blockly.bindEvent_(b,"mouseout",a.svg_,a.svg_.removeSelect))}this.width_=0;this.reflow();this.filterForCapacity_();Blockly.fireUiEvent(window,"resize");this.reflowWrapper_=Blockly.bindEvent_(this.blockSpace_.getCanvas(),"blocklyBlockSpaceChange",this,this.reflow);this.blockSpace_.fireChangeEvent()};
  Blockly.Flyout.prototype.addButtonToFlyout_=function(a,b,c){var d=Blockly.createSvgElement("g",{"class":"createFunction"},this.blockSpace_.svgGroup_),e=Blockly.createSvgElement("rect",{rx:5,ry:5,fill:"orange",stroke:"white"},d),f=Blockly.createSvgElement("text",{x:5,y:5,"class":"blocklyText"},d);f.textContent=b;b=f.getBoundingClientRect();this.minFlyoutWidth_=b.width+10;e.setAttribute("width",b.width+10);e.setAttribute("height",b.height+10);e.setAttribute("y",-b.height+5-1);d.setAttribute("transform",
  "translate(17, 25)");Blockly.bindEvent_(d,"mousedown",this,c);a.y+=40};
  Blockly.Flyout.prototype.reflow=function(){for(var a=this.minFlyoutWidth_||0,b=this.CORNER_RADIUS,c=this.blockSpace_.getTopBlocks(!1),d=0,e;e=c[d];d++)var f=e.getHeightWidth(),a=Math.max(a,f.width);a+=b+Blockly.BlockSvg.TAB_WIDTH+b/2+Blockly.Scrollbar.scrollbarThickness;if(this.width_!=a){for(d=0;e=c[d];d++){var f=e.getHeightWidth(),g=e.getRelativeToSurfaceXY();if(Blockly.RTL){var h=a-b-Blockly.BlockSvg.TAB_WIDTH-g.x;e.moveBy(h,0);g.x+=h}e.flyoutRect_&&(e.flyoutRect_.setAttribute("width",f.width),
  e.flyoutRect_.setAttribute("height",f.height),e.flyoutRect_.setAttribute("x",Blockly.RTL?g.x-f.width:g.x),e.flyoutRect_.setAttribute("y",g.y))}this.width_=a;Blockly.fireUiEvent(window,"resize")}};
  Blockly.Flyout.prototype.blockMouseDown_=function(a){var b=this;return function(c){b.enabled_&&(Blockly.BlockSpaceEditor.terminateDrag_(),b.blockSpace_.blockSpaceEditor.hideChaff(),Blockly.isRightButton(c)||(Blockly.removeAllRanges(),b.blockSpace_.blockSpaceEditor.setCursor(Blockly.Css.Cursor.CLOSED),Blockly.Flyout.startDragMouseX_=c.clientX,Blockly.Flyout.startDragMouseY_=c.clientY,Blockly.Flyout.startBlock_=a,Blockly.Flyout.startFlyout_=b,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,
  "mouseup",this,Blockly.BlockSpaceEditor.terminateDrag_),Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,b.onMouseMove_)),c.stopPropagation())}};
  Blockly.Flyout.prototype.onMouseMove_=function(a){if("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)a.stopPropagation();else{Blockly.removeAllRanges();var b=a.clientY-Blockly.Flyout.startDragMouseY_;Math.sqrt(Math.pow(a.clientX-Blockly.Flyout.startDragMouseX_,2)+Math.pow(b,2))>Blockly.DRAG_RADIUS&&(a.startDragMouseX_=Blockly.Flyout.startDragMouseX_,a.startDragMouseY_=Blockly.Flyout.startDragMouseY_,Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(a))}};
  Blockly.Flyout.prototype.createFunction_=function(){Blockly.functionEditor.openWithNewFunction()};Blockly.Flyout.prototype.createFunctionalVariable_=function(){Blockly.contractEditor.openWithNewVariable()};
  Blockly.Flyout.prototype.createBlockFunc_=function(a){var b=this;return function(c){if(b.enabled_&&!Blockly.isRightButton(c)&&!a.disabled){var d=Blockly.Xml.blockToDom(a),d=Blockly.Xml.domToBlock(b.targetBlockSpace_,d),e=a.getSvgRoot();if(!e)throw"originBlock is not rendered.";var e=Blockly.getSvgXY_(e,a.blockSpace.blockSpaceEditor.svg_),f=d.getSvgRoot();if(!f)throw"block is not rendered.";f=Blockly.getSvgXY_(f,d.blockSpace.blockSpaceEditor.svg_);d.moveBy(e.x-f.x,e.y-f.y);b.autoClose?(b.hide(a),d.blockEvents.listenOnce(Blockly.Block.EVENTS.AFTER_DROPPED,
  function(){a.dispose(!1,!1)})):b.filterForCapacity_();d.onMouseDown_(c)}}};Blockly.Flyout.prototype.filterForCapacity_=function(){for(var a=this.targetBlockSpace_.remainingCapacity(),b=this.blockSpace_.getTopBlocks(!1),c=0,d;d=b[c];c++){var e=d.getDescendants().length>a;d.setDisabled(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(a){this.enabled_=a};Blockly.Flyout.prototype.getRect=function(){var a=Blockly.getSvgXY_(this.svgGroup_).x;Blockly.RTL||(a-=1E7);return new goog.math.Rect(a,-1E7,1E7+this.width_,this.height_+2E7)};goog.structs={};goog.structs.getCount=function(a){return"function"==typeof a.getCount?a.getCount():goog.isArrayLike(a)||goog.isString(a)?a.length:goog.object.getCount(a)};goog.structs.getValues=function(a){if("function"==typeof a.getValues)return a.getValues();if(goog.isString(a))return a.split("");if(goog.isArrayLike(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return goog.object.getValues(a)};
  goog.structs.getKeys=function(a){if("function"==typeof a.getKeys)return a.getKeys();if("function"!=typeof a.getValues){if(goog.isArrayLike(a)||goog.isString(a)){var b=[];a=a.length;for(var c=0;c<a;c++)b.push(c);return b}return goog.object.getKeys(a)}};goog.structs.contains=function(a,b){return"function"==typeof a.contains?a.contains(b):"function"==typeof a.containsValue?a.containsValue(b):goog.isArrayLike(a)||goog.isString(a)?goog.array.contains(a,b):goog.object.containsValue(a,b)};
  goog.structs.isEmpty=function(a){return"function"==typeof a.isEmpty?a.isEmpty():goog.isArrayLike(a)||goog.isString(a)?goog.array.isEmpty(a):goog.object.isEmpty(a)};goog.structs.clear=function(a){"function"==typeof a.clear?a.clear():goog.isArrayLike(a)?goog.array.clear(a):goog.object.clear(a)};
  goog.structs.forEach=function(a,b,c){if("function"==typeof a.forEach)a.forEach(b,c);else if(goog.isArrayLike(a)||goog.isString(a))goog.array.forEach(a,b,c);else for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)b.call(c,e[g],d&&d[g],a)};
  goog.structs.filter=function(a,b,c){if("function"==typeof a.filter)return a.filter(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.filter(a,b,c);var d,e=goog.structs.getKeys(a),f=goog.structs.getValues(a),g=f.length;if(e){d={};for(var h=0;h<g;h++)b.call(c,f[h],e[h],a)&&(d[e[h]]=f[h])}else for(d=[],h=0;h<g;h++)b.call(c,f[h],void 0,a)&&d.push(f[h]);return d};
  goog.structs.map=function(a,b,c){if("function"==typeof a.map)return a.map(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.map(a,b,c);var d,e=goog.structs.getKeys(a),f=goog.structs.getValues(a),g=f.length;if(e){d={};for(var h=0;h<g;h++)d[e[h]]=b.call(c,f[h],e[h],a)}else for(d=[],h=0;h<g;h++)d[h]=b.call(c,f[h],void 0,a);return d};
  goog.structs.some=function(a,b,c){if("function"==typeof a.some)return a.some(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.some(a,b,c);for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)if(b.call(c,e[g],d&&d[g],a))return!0;return!1};
  goog.structs.every=function(a,b,c){if("function"==typeof a.every)return a.every(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.every(a,b,c);for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)if(!b.call(c,e[g],d&&d[g],a))return!1;return!0};goog.structs.Trie=function(a){this.value_=void 0;this.childNodes_={};a&&this.setAll(a)};goog.structs.Trie.prototype.set=function(a,b){this.setOrAdd_(a,b,!1)};goog.structs.Trie.prototype.add=function(a,b){this.setOrAdd_(a,b,!0)};
  goog.structs.Trie.prototype.setOrAdd_=function(a,b,c){for(var d=this,e=0;e<a.length;e++){var f=a.charAt(e);d.childNodes_[f]||(d.childNodes_[f]=new goog.structs.Trie);d=d.childNodes_[f]}if(c&&void 0!==d.value_)throw Error('The collection already contains the key "'+a+'"');d.value_=b};goog.structs.Trie.prototype.setAll=function(a){var b=goog.structs.getKeys(a);a=goog.structs.getValues(a);for(var c=0;c<b.length;c++)this.set(b[c],a[c])};
  goog.structs.Trie.prototype.getChildNode_=function(a){for(var b=this,c=0;c<a.length;c++){var d=a.charAt(c),b=b.childNodes_[d];if(!b)return}return b};goog.structs.Trie.prototype.get=function(a){return(a=this.getChildNode_(a))?a.value_:void 0};goog.structs.Trie.prototype.getKeyAndPrefixes=function(a,b){var c=this,d={},e=b||0;void 0!==c.value_&&(d[e]=c.value_);for(;e<a.length;e++){var f=a.charAt(e);if(!(f in c.childNodes_))break;c=c.childNodes_[f];void 0!==c.value_&&(d[e]=c.value_)}return d};
  goog.structs.Trie.prototype.getValues=function(){var a=[];this.getValuesInternal_(a);return a};goog.structs.Trie.prototype.getValuesInternal_=function(a){void 0!==this.value_&&a.push(this.value_);for(var b in this.childNodes_)this.childNodes_[b].getValuesInternal_(a)};goog.structs.Trie.prototype.getKeys=function(a){var b=[];if(a){for(var c=this,d=0;d<a.length;d++){var e=a.charAt(d);if(!c.childNodes_[e])return[];c=c.childNodes_[e]}c.getKeysInternal_(a,b)}else this.getKeysInternal_("",b);return b};
  goog.structs.Trie.prototype.getKeysInternal_=function(a,b){void 0!==this.value_&&b.push(a);for(var c in this.childNodes_)this.childNodes_[c].getKeysInternal_(a+c,b)};goog.structs.Trie.prototype.containsKey=function(a){return void 0!==this.get(a)};goog.structs.Trie.prototype.containsPrefix=function(a){return 0==a.length?!this.isEmpty():!!this.getChildNode_(a)};
  goog.structs.Trie.prototype.containsValue=function(a){if(this.value_===a)return!0;for(var b in this.childNodes_)if(this.childNodes_[b].containsValue(a))return!0;return!1};goog.structs.Trie.prototype.clear=function(){this.childNodes_={};this.value_=void 0};
  goog.structs.Trie.prototype.remove=function(a){for(var b=this,c=[],d=0;d<a.length;d++){var e=a.charAt(d);if(!b.childNodes_[e])throw Error('The collection does not have the key "'+a+'"');c.push([b,e]);b=b.childNodes_[e]}a=b.value_;for(delete b.value_;0<c.length;)if(e=c.pop(),b=e[0],e=e[1],b.childNodes_[e].isEmpty())delete b.childNodes_[e];else break;return a};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};goog.ui.tree.TypeAhead.prototype.buffer_="";goog.ui.tree.TypeAhead.prototype.matchingLabels_=null;goog.ui.tree.TypeAhead.prototype.matchingNodes_=null;goog.ui.tree.TypeAhead.prototype.matchingLabelIndex_=0;goog.ui.tree.TypeAhead.prototype.matchingNodeIndex_=0;goog.ui.tree.TypeAhead.Offset={DOWN:1,UP:-1};
  goog.ui.tree.TypeAhead.prototype.handleNavigation=function(a){var b=!1;switch(a.keyCode){case goog.events.KeyCodes.DOWN:case goog.events.KeyCodes.UP:a.ctrlKey&&(this.jumpTo_(a.keyCode==goog.events.KeyCodes.DOWN?goog.ui.tree.TypeAhead.Offset.DOWN:goog.ui.tree.TypeAhead.Offset.UP),b=!0);break;case goog.events.KeyCodes.BACKSPACE:a=this.buffer_.length-1;b=!0;0<a?(this.buffer_=this.buffer_.substring(0,a),this.jumpToLabel_(this.buffer_)):0==a?this.buffer_="":b=!1;break;case goog.events.KeyCodes.ESC:this.buffer_=
  "",b=!0}return b};goog.ui.tree.TypeAhead.prototype.handleTypeAheadChar=function(a){var b=!1;a.ctrlKey||a.altKey||(a=String.fromCharCode(a.charCode||a.keyCode).toLowerCase(),goog.string.isUnicodeChar(a)&&(" "!=a||this.buffer_)&&(this.buffer_+=a,b=this.jumpToLabel_(this.buffer_)));return b};goog.ui.tree.TypeAhead.prototype.setNodeInMap=function(a){var b=a.getText();if(b&&!goog.string.isEmptySafe(b)){var b=b.toLowerCase(),c=this.nodeMap_.get(b);c?c.push(a):this.nodeMap_.set(b,[a])}};
  goog.ui.tree.TypeAhead.prototype.removeNodeFromMap=function(a){var b=a.getText();if(b&&!goog.string.isEmptySafe(b)){var b=b.toLowerCase(),c=this.nodeMap_.get(b);c&&(goog.array.remove(c,a),c.length&&this.nodeMap_.remove(b))}};goog.ui.tree.TypeAhead.prototype.jumpToLabel_=function(a){var b=!1;(a=this.nodeMap_.getKeys(a))&&a.length&&(this.matchingLabelIndex_=this.matchingNodeIndex_=0,b=this.nodeMap_.get(a[0]),b=this.selectMatchingNode_(b))&&(this.matchingLabels_=a);return b};
  goog.ui.tree.TypeAhead.prototype.jumpTo_=function(a){var b=!1,c=this.matchingLabels_;if(c){var b=null,d=!1;if(this.matchingNodes_){var e=this.matchingNodeIndex_+a;0<=e&&e<this.matchingNodes_.length?(this.matchingNodeIndex_=e,b=this.matchingNodes_):d=!0}b||(e=this.matchingLabelIndex_+a,0<=e&&e<c.length&&(this.matchingLabelIndex_=e),c.length>this.matchingLabelIndex_&&(b=this.nodeMap_.get(c[this.matchingLabelIndex_])),b&&b.length&&d&&(this.matchingNodeIndex_=a==goog.ui.tree.TypeAhead.Offset.UP?b.length-
  1:0));if(b=this.selectMatchingNode_(b))this.matchingLabels_=c}return b};goog.ui.tree.TypeAhead.prototype.selectMatchingNode_=function(a){var b;a&&(this.matchingNodeIndex_<a.length&&(b=a[this.matchingNodeIndex_],this.matchingNodes_=a),b&&(b.reveal(),b.select()));return!!b};goog.ui.tree.TypeAhead.prototype.clear=function(){this.buffer_=""};goog.structs.Collection=function(){};goog.iter={};goog.iter.StopIteration="StopIteration"in goog.global?goog.global.StopIteration:Error("StopIteration");goog.iter.Iterator=function(){};goog.iter.Iterator.prototype.next=function(){throw goog.iter.StopIteration;};goog.iter.Iterator.prototype.__iterator__=function(a){return this};
  goog.iter.toIterator=function(a){if(a instanceof goog.iter.Iterator)return a;if("function"==typeof a.__iterator__)return a.__iterator__(!1);if(goog.isArrayLike(a)){var b=0,c=new goog.iter.Iterator;c.next=function(){for(;;){if(b>=a.length)throw goog.iter.StopIteration;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");};
  goog.iter.forEach=function(a,b,c){if(goog.isArrayLike(a))try{goog.array.forEach(a,b,c)}catch(d){if(d!==goog.iter.StopIteration)throw d;}else{a=goog.iter.toIterator(a);try{for(;;)b.call(c,a.next(),void 0,a)}catch(e){if(e!==goog.iter.StopIteration)throw e;}}};goog.iter.filter=function(a,b,c){var d=goog.iter.toIterator(a);a=new goog.iter.Iterator;a.next=function(){for(;;){var a=d.next();if(b.call(c,a,void 0,d))return a}};return a};
  goog.iter.range=function(a,b,c){var d=0,e=a,f=c||1;1<arguments.length&&(d=a,e=b);if(0==f)throw Error("Range step argument must not be zero");var g=new goog.iter.Iterator;g.next=function(){if(0<f&&d>=e||0>f&&d<=e)throw goog.iter.StopIteration;var a=d;d+=f;return a};return g};goog.iter.join=function(a,b){return goog.iter.toArray(a).join(b)};goog.iter.map=function(a,b,c){var d=goog.iter.toIterator(a);a=new goog.iter.Iterator;a.next=function(){var a=d.next();return b.call(c,a,void 0,d)};return a};
  goog.iter.reduce=function(a,b,c,d){var e=c;goog.iter.forEach(a,function(a){e=b.call(d,e,a)});return e};goog.iter.some=function(a,b,c){a=goog.iter.toIterator(a);try{for(;;)if(b.call(c,a.next(),void 0,a))return!0}catch(d){if(d!==goog.iter.StopIteration)throw d;}return!1};goog.iter.every=function(a,b,c){a=goog.iter.toIterator(a);try{for(;;)if(!b.call(c,a.next(),void 0,a))return!1}catch(d){if(d!==goog.iter.StopIteration)throw d;}return!0};
  goog.iter.chain=function(a){var b=goog.iter.toIterator(arguments),c=new goog.iter.Iterator,d=null;c.next=function(){for(;;){if(null==d){var a=b.next();d=goog.iter.toIterator(a)}try{return d.next()}catch(c){if(c!==goog.iter.StopIteration)throw c;d=null}}};return c};goog.iter.chainFromIterable=function(a){return goog.iter.chain.apply(void 0,a)};
  goog.iter.dropWhile=function(a,b,c){var d=goog.iter.toIterator(a);a=new goog.iter.Iterator;var e=!0;a.next=function(){for(;;){var a=d.next();if(!e||!b.call(c,a,void 0,d))return e=!1,a}};return a};goog.iter.takeWhile=function(a,b,c){var d=goog.iter.toIterator(a);a=new goog.iter.Iterator;var e=!0;a.next=function(){for(;;)if(e){var a=d.next();if(b.call(c,a,void 0,d))return a;e=!1}else throw goog.iter.StopIteration;};return a};
  goog.iter.toArray=function(a){if(goog.isArrayLike(a))return goog.array.toArray(a);a=goog.iter.toIterator(a);var b=[];goog.iter.forEach(a,function(a){b.push(a)});return b};goog.iter.equals=function(a,b){var c=goog.iter.zipLongest({},a,b);return goog.iter.every(c,function(a){return a[0]==a[1]})};goog.iter.nextOrValue=function(a,b){try{return goog.iter.toIterator(a).next()}catch(c){if(c!=goog.iter.StopIteration)throw c;return b}};
  goog.iter.product=function(a){if(goog.array.some(arguments,function(a){return!a.length})||!arguments.length)return new goog.iter.Iterator;var b=new goog.iter.Iterator,c=arguments,d=goog.array.repeat(0,c.length);b.next=function(){if(d){for(var a=goog.array.map(d,function(a,b){return c[b][a]}),b=d.length-1;0<=b;b--){goog.asserts.assert(d);if(d[b]<c[b].length-1){d[b]++;break}if(0==b){d=null;break}d[b]=0}return a}throw goog.iter.StopIteration;};return b};
  goog.iter.cycle=function(a){var b=goog.iter.toIterator(a),c=[],d=0;a=new goog.iter.Iterator;var e=!1;a.next=function(){var a=null;if(!e)try{return a=b.next(),c.push(a),a}catch(g){if(g!=goog.iter.StopIteration||goog.array.isEmpty(c))throw g;e=!0}a=c[d];d=(d+1)%c.length;return a};return a};goog.iter.count=function(a,b){var c=a||0,d=goog.isDef(b)?b:1,e=new goog.iter.Iterator;e.next=function(){var a=c;c+=d;return a};return e};
  goog.iter.repeat=function(a){var b=new goog.iter.Iterator;b.next=goog.functions.constant(a);return b};goog.iter.accumulate=function(a){var b=goog.iter.toIterator(a),c=0;a=new goog.iter.Iterator;a.next=function(){return c+=b.next()};return a};goog.iter.zip=function(a){var b=arguments,c=new goog.iter.Iterator;if(0<b.length){var d=goog.array.map(b,goog.iter.toIterator);c.next=function(){return goog.array.map(d,function(a){return a.next()})}}return c};
  goog.iter.zipLongest=function(a,b){var c=goog.array.slice(arguments,1),d=new goog.iter.Iterator;if(0<c.length){var e=goog.array.map(c,goog.iter.toIterator);d.next=function(){var b=!1,c=goog.array.map(e,function(c){var d;try{d=c.next(),b=!0}catch(e){if(e!==goog.iter.StopIteration)throw e;d=a}return d});if(!b)throw goog.iter.StopIteration;return c}}return d};goog.iter.compress=function(a,b){var c=goog.iter.toIterator(b);return goog.iter.filter(a,function(){return!!c.next()})};
  goog.iter.GroupByIterator_=function(a,b){this.iterator=goog.iter.toIterator(a);this.keyFunc=b||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);this.targetKey=this.currentKey;return[this.currentKey,this.groupItems_(this.targetKey)]};
  goog.iter.GroupByIterator_.prototype.groupItems_=function(a){for(var b=[];this.currentKey==a;){b.push(this.currentValue);try{this.currentValue=this.iterator.next()}catch(c){if(c!==goog.iter.StopIteration)throw c;break}this.currentKey=this.keyFunc(this.currentValue)}return b};goog.iter.groupBy=function(a,b){return new goog.iter.GroupByIterator_(a,b)};
  goog.iter.tee=function(a,b){var c=goog.iter.toIterator(a),d=goog.isNumber(b)?b:2,e=goog.array.map(goog.array.range(d),function(){return[]}),f=function(){var a=c.next();goog.array.forEach(e,function(b){b.push(a)})};return goog.array.map(e,function(a){var b=new goog.iter.Iterator;b.next=function(){goog.array.isEmpty(a)&&f();goog.asserts.assert(!goog.array.isEmpty(a));return a.shift()};return b})};goog.iter.enumerate=function(a,b){return goog.iter.zip(goog.iter.count(b),a)};
  goog.iter.limit=function(a,b){goog.asserts.assert(goog.math.isInt(b)&&0<=b);var c=goog.iter.toIterator(a),d=new goog.iter.Iterator,e=b;d.next=function(){if(0<e--)return c.next();throw goog.iter.StopIteration;};return d};goog.iter.consume=function(a,b){goog.asserts.assert(goog.math.isInt(b)&&0<=b);for(var c=goog.iter.toIterator(a);0<b--;)goog.iter.nextOrValue(c,null);return c};
  goog.iter.slice=function(a,b,c){goog.asserts.assert(goog.math.isInt(b)&&0<=b);a=goog.iter.consume(a,b);goog.isNumber(c)&&(goog.asserts.assert(goog.math.isInt(c)&&c>=b),a=goog.iter.limit(a,c-b));return a};goog.iter.hasDuplicates_=function(a){var b=[];goog.array.removeDuplicates(a,b);return a.length!=b.length};goog.iter.permutations=function(a,b){var c=goog.iter.toArray(a),d=goog.isNumber(b)?b:c.length,c=goog.array.repeat(c,d),c=goog.iter.product.apply(void 0,c);return goog.iter.filter(c,function(a){return!goog.iter.hasDuplicates_(a)})};
  goog.iter.combinations=function(a,b){function c(a){return d[a]}var d=goog.iter.toArray(a),e=goog.iter.range(d.length),e=goog.iter.permutations(e,b),f=goog.iter.filter(e,function(a){return goog.array.isSorted(a)}),e=new goog.iter.Iterator;e.next=function(){return goog.array.map(f.next(),c)};return e};
  goog.iter.combinationsWithReplacement=function(a,b){function c(a){return d[a]}var d=goog.iter.toArray(a),e=goog.array.range(d.length),e=goog.array.repeat(e,b),e=goog.iter.product.apply(void 0,e),f=goog.iter.filter(e,function(a){return goog.array.isSorted(a)}),e=new goog.iter.Iterator;e.next=function(){return goog.array.map(f.next(),c)};return e};goog.structs.Map=function(a,b){this.map_={};this.keys_=[];this.version_=this.count_=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else a&&this.addAll(a)};goog.structs.Map.prototype.getCount=function(){return this.count_};goog.structs.Map.prototype.getValues=function(){this.cleanupKeysArray_();for(var a=[],b=0;b<this.keys_.length;b++)a.push(this.map_[this.keys_[b]]);return a};
  goog.structs.Map.prototype.getKeys=function(){this.cleanupKeysArray_();return this.keys_.concat()};goog.structs.Map.prototype.containsKey=function(a){return goog.structs.Map.hasKey_(this.map_,a)};goog.structs.Map.prototype.containsValue=function(a){for(var b=0;b<this.keys_.length;b++){var c=this.keys_[b];if(goog.structs.Map.hasKey_(this.map_,c)&&this.map_[c]==a)return!0}return!1};
  goog.structs.Map.prototype.equals=function(a,b){if(this===a)return!0;if(this.count_!=a.getCount())return!1;var c=b||goog.structs.Map.defaultEquals;this.cleanupKeysArray_();for(var d,e=0;d=this.keys_[e];e++)if(!c(this.get(d),a.get(d)))return!1;return!0};goog.structs.Map.defaultEquals=function(a,b){return a===b};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(a){return goog.structs.Map.hasKey_(this.map_,a)?(delete this.map_[a],this.count_--,this.version_++,this.keys_.length>2*this.count_&&this.cleanupKeysArray_(),!0):!1};
  goog.structs.Map.prototype.cleanupKeysArray_=function(){if(this.count_!=this.keys_.length){for(var a=0,b=0;a<this.keys_.length;){var c=this.keys_[a];goog.structs.Map.hasKey_(this.map_,c)&&(this.keys_[b++]=c);a++}this.keys_.length=b}if(this.count_!=this.keys_.length){for(var d={},b=a=0;a<this.keys_.length;)c=this.keys_[a],goog.structs.Map.hasKey_(d,c)||(this.keys_[b++]=c,d[c]=1),a++;this.keys_.length=b}};
  goog.structs.Map.prototype.get=function(a,b){return goog.structs.Map.hasKey_(this.map_,a)?this.map_[a]:b};goog.structs.Map.prototype.set=function(a,b){goog.structs.Map.hasKey_(this.map_,a)||(this.count_++,this.keys_.push(a),this.version_++);this.map_[a]=b};goog.structs.Map.prototype.addAll=function(a){var b;a instanceof goog.structs.Map?(b=a.getKeys(),a=a.getValues()):(b=goog.object.getKeys(a),a=goog.object.getValues(a));for(var c=0;c<b.length;c++)this.set(b[c],a[c])};
  goog.structs.Map.prototype.clone=function(){return new goog.structs.Map(this)};goog.structs.Map.prototype.transpose=function(){for(var a=new goog.structs.Map,b=0;b<this.keys_.length;b++){var c=this.keys_[b];a.set(this.map_[c],c)}return a};goog.structs.Map.prototype.toObject=function(){this.cleanupKeysArray_();for(var a={},b=0;b<this.keys_.length;b++){var c=this.keys_[b];a[c]=this.map_[c]}return a};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(a){this.cleanupKeysArray_();var b=0,c=this.keys_,d=this.map_,e=this.version_,f=this,g=new goog.iter.Iterator;g.next=function(){for(;;){if(e!=f.version_)throw Error("The map has changed since the iterator was created");if(b>=c.length)throw goog.iter.StopIteration;var g=c[b++];return a?g:d[g]}};return g};
  goog.structs.Map.hasKey_=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};goog.structs.Set=function(a){this.map_=new goog.structs.Map;a&&this.addAll(a)};goog.structs.Set.getKey_=function(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+goog.getUid(a):b.substr(0,1)+a};goog.structs.Set.prototype.getCount=function(){return this.map_.getCount()};goog.structs.Set.prototype.add=function(a){this.map_.set(goog.structs.Set.getKey_(a),a)};goog.structs.Set.prototype.addAll=function(a){a=goog.structs.getValues(a);for(var b=a.length,c=0;c<b;c++)this.add(a[c])};
  goog.structs.Set.prototype.removeAll=function(a){a=goog.structs.getValues(a);for(var b=a.length,c=0;c<b;c++)this.remove(a[c])};goog.structs.Set.prototype.remove=function(a){return this.map_.remove(goog.structs.Set.getKey_(a))};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(a){return this.map_.containsKey(goog.structs.Set.getKey_(a))};
  goog.structs.Set.prototype.containsAll=function(a){return goog.structs.every(a,this.contains,this)};goog.structs.Set.prototype.intersection=function(a){var b=new goog.structs.Set;a=goog.structs.getValues(a);for(var c=0;c<a.length;c++){var d=a[c];this.contains(d)&&b.add(d)}return b};goog.structs.Set.prototype.difference=function(a){var b=this.clone();b.removeAll(a);return b};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(a){return this.getCount()==goog.structs.getCount(a)&&this.isSubsetOf(a)};goog.structs.Set.prototype.isSubsetOf=function(a){var b=goog.structs.getCount(a);if(this.getCount()>b)return!1;!(a instanceof goog.structs.Set)&&5<b&&(a=new goog.structs.Set(a));return goog.structs.every(this,function(b){return goog.structs.contains(a,b)})};goog.structs.Set.prototype.__iterator__=function(a){return this.map_.__iterator__(!1)};goog.debug.LOGGING_ENABLED=goog.DEBUG;goog.debug.catchErrors=function(a,b,c){c=c||goog.global;var d=c.onerror,e=!!b;goog.userAgent.WEBKIT&&!goog.userAgent.isVersionOrHigher("535.3")&&(e=!e);c.onerror=function(b,c,h,k,l){d&&d(b,c,h,k,l);a({message:b,fileName:c,line:h,col:k,error:l});return e}};goog.debug.expose=function(a,b){if("undefined"==typeof a)return"undefined";if(null==a)return"NULL";var c=[],d;for(d in a)if(b||!goog.isFunction(a[d])){var e=d+" = ";try{e+=a[d]}catch(f){e+="*** "+f+" ***"}c.push(e)}return c.join("\n")};
  goog.debug.deepExpose=function(a,b){var c=[],d=function(a,f,g){var h=f+"  ";g=new goog.structs.Set(g);try{if(goog.isDef(a))if(goog.isNull(a))c.push("NULL");else if(goog.isString(a))c.push('"'+a.replace(/\n/g,"\n"+f)+'"');else if(goog.isFunction(a))c.push(String(a).replace(/\n/g,"\n"+f));else if(goog.isObject(a))if(g.contains(a))c.push("*** reference loop detected ***");else{g.add(a);c.push("{");for(var k in a)if(b||!goog.isFunction(a[k]))c.push("\n"),c.push(h),c.push(k+" = "),d(a[k],h,g);c.push("\n"+
  f+"}")}else c.push(a);else c.push("undefined")}catch(l){c.push("*** "+l+" ***")}};d(a,"",new goog.structs.Set);return c.join("")};goog.debug.exposeArray=function(a){for(var b=[],c=0;c<a.length;c++)goog.isArray(a[c])?b.push(goog.debug.exposeArray(a[c])):b.push(a[c]);return"[ "+b.join(", ")+" ]"};
  goog.debug.exposeException=function(a,b){try{var c=goog.debug.normalizeErrorObject(a);return"Message: "+goog.string.htmlEscape(c.message)+'\nUrl: <a href="view-source:'+c.fileName+'" target="_new">'+c.fileName+"</a>\nLine: "+c.lineNumber+"\n\nBrowser stack:\n"+goog.string.htmlEscape(c.stack+"-> ")+"[end]\n\nJS stack traversal:\n"+goog.string.htmlEscape(goog.debug.getStacktrace(b)+"-> ")}catch(d){return"Exception trying to expose exception! You win, we lose. "+d}};
  goog.debug.normalizeErrorObject=function(a){var b=goog.getObjectByName("window.location.href");if(goog.isString(a))return{message:a,name:"Unknown error",lineNumber:"Not available",fileName:b,stack:"Not available"};var c,d,e=!1;try{c=a.lineNumber||a.line||"Not available"}catch(f){c="Not available",e=!0}try{d=a.fileName||a.filename||a.sourceURL||goog.global.$googDebugFname||b}catch(g){d="Not available",e=!0}return!e&&a.lineNumber&&a.fileName&&a.stack&&a.message&&a.name?a:{message:a.message||"Not available",
  name:a.name||"UnknownError",lineNumber:c,fileName:d,stack:a.stack||"Not available"}};goog.debug.enhanceError=function(a,b){var c="string"==typeof a?Error(a):a;c.stack||(c.stack=goog.debug.getStacktrace(arguments.callee.caller));if(b){for(var d=0;c["message"+d];)++d;c["message"+d]=String(b)}return c};
  goog.debug.getStacktraceSimple=function(a){for(var b=[],c=arguments.callee.caller,d=0;c&&(!a||d<a);){b.push(goog.debug.getFunctionName(c));b.push("()\n");try{c=c.caller}catch(e){b.push("[exception trying to get caller]\n");break}d++;if(d>=goog.debug.MAX_STACK_DEPTH){b.push("[...long stack...]");break}}a&&d>=a?b.push("[...reached max depth limit...]"):b.push("[end]");return b.join("")};goog.debug.MAX_STACK_DEPTH=50;
  goog.debug.getStacktrace=function(a){return goog.debug.getStacktraceHelper_(a||arguments.callee.caller,[])};
  goog.debug.getStacktraceHelper_=function(a,b){var c=[];if(goog.array.contains(b,a))c.push("[...circular reference...]");else if(a&&b.length<goog.debug.MAX_STACK_DEPTH){c.push(goog.debug.getFunctionName(a)+"(");for(var d=a.arguments,e=0;d&&e<d.length;e++){0<e&&c.push(", ");var f;f=d[e];switch(typeof f){case "object":f=f?"object":"null";break;case "string":break;case "number":f=String(f);break;case "boolean":f=f?"true":"false";break;case "function":f=(f=goog.debug.getFunctionName(f))?f:"[fn]";break;
  default:f=typeof f}40<f.length&&(f=f.substr(0,40)+"...");c.push(f)}b.push(a);c.push(")\n");try{c.push(goog.debug.getStacktraceHelper_(a.caller,b))}catch(g){c.push("[exception trying to get caller]\n")}}else a?c.push("[...long stack...]"):c.push("[end]");return c.join("")};goog.debug.setFunctionResolver=function(a){goog.debug.fnNameResolver_=a};
  goog.debug.getFunctionName=function(a){if(goog.debug.fnNameCache_[a])return goog.debug.fnNameCache_[a];if(goog.debug.fnNameResolver_){var b=goog.debug.fnNameResolver_(a);if(b)return goog.debug.fnNameCache_[a]=b}a=String(a);goog.debug.fnNameCache_[a]||(b=/function ([^\(]+)/.exec(a),goog.debug.fnNameCache_[a]=b?b[1]:"[Anonymous]");return goog.debug.fnNameCache_[a]};
  goog.debug.makeWhitespaceVisible=function(a){return a.replace(/ /g,"[_]").replace(/\f/g,"[f]").replace(/\n/g,"[n]\n").replace(/\r/g,"[r]").replace(/\t/g,"[t]")};goog.debug.fnNameCache_={};goog.debug.LogRecord=function(a,b,c,d,e){this.reset(a,b,c,d,e)};goog.debug.LogRecord.prototype.sequenceNumber_=0;goog.debug.LogRecord.prototype.exception_=null;goog.debug.LogRecord.prototype.exceptionText_=null;goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS=!0;goog.debug.LogRecord.nextSequenceNumber_=0;
  goog.debug.LogRecord.prototype.reset=function(a,b,c,d,e){goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS&&(this.sequenceNumber_="number"==typeof e?e:goog.debug.LogRecord.nextSequenceNumber_++);this.time_=d||goog.now();this.level_=a;this.msg_=b;this.loggerName_=c;delete this.exception_;delete this.exceptionText_};goog.debug.LogRecord.prototype.getLoggerName=function(){return this.loggerName_};goog.debug.LogRecord.prototype.getException=function(){return this.exception_};
  goog.debug.LogRecord.prototype.setException=function(a){this.exception_=a};goog.debug.LogRecord.prototype.getExceptionText=function(){return this.exceptionText_};goog.debug.LogRecord.prototype.setExceptionText=function(a){this.exceptionText_=a};goog.debug.LogRecord.prototype.setLoggerName=function(a){this.loggerName_=a};goog.debug.LogRecord.prototype.getLevel=function(){return this.level_};goog.debug.LogRecord.prototype.setLevel=function(a){this.level_=a};
  goog.debug.LogRecord.prototype.getMessage=function(){return this.msg_};goog.debug.LogRecord.prototype.setMessage=function(a){this.msg_=a};goog.debug.LogRecord.prototype.getMillis=function(){return this.time_};goog.debug.LogRecord.prototype.setMillis=function(a){this.time_=a};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(){goog.debug.LogBuffer.instance_||(goog.debug.LogBuffer.instance_=new goog.debug.LogBuffer);return goog.debug.LogBuffer.instance_};goog.debug.LogBuffer.CAPACITY=0;
  goog.debug.LogBuffer.prototype.addRecord=function(a,b,c){var d=(this.curIndex_+1)%goog.debug.LogBuffer.CAPACITY;this.curIndex_=d;if(this.isFull_)return d=this.buffer_[d],d.reset(a,b,c),d;this.isFull_=d==goog.debug.LogBuffer.CAPACITY-1;return this.buffer_[d]=new goog.debug.LogRecord(a,b,c)};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(a){var b=this.buffer_;if(b[0]){var c=this.curIndex_,d=this.isFull_?c:-1;do d=(d+1)%goog.debug.LogBuffer.CAPACITY,a(b[d]);while(d!=c)}};goog.debug.Logger=function(a){this.name_=a;this.handlers_=this.children_=this.level_=this.parent_=null};goog.debug.Logger.ENABLE_HIERARCHY=!0;goog.debug.Logger.ENABLE_HIERARCHY||(goog.debug.Logger.rootHandlers_=[]);goog.debug.Logger.Level=function(a,b){this.name=a;this.value=b};goog.debug.Logger.Level.prototype.toString=function(){return this.name};goog.debug.Logger.Level.OFF=new goog.debug.Logger.Level("OFF",Infinity);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 a=0,b;b=goog.debug.Logger.Level.PREDEFINED_LEVELS[a];a++)goog.debug.Logger.Level.predefinedLevelsCache_[b.value]=b,goog.debug.Logger.Level.predefinedLevelsCache_[b.name]=b};
  goog.debug.Logger.Level.getPredefinedLevel=function(a){goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_();return goog.debug.Logger.Level.predefinedLevelsCache_[a]||null};
  goog.debug.Logger.Level.getPredefinedLevelByValue=function(a){goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_();if(a in goog.debug.Logger.Level.predefinedLevelsCache_)return goog.debug.Logger.Level.predefinedLevelsCache_[a];for(var b=0;b<goog.debug.Logger.Level.PREDEFINED_LEVELS.length;++b){var c=goog.debug.Logger.Level.PREDEFINED_LEVELS[b];if(c.value<=a)return c}return null};goog.debug.Logger.getLogger=function(a){return goog.debug.LogManager.getLogger(a)};
  goog.debug.Logger.logToProfilers=function(a){goog.global.console&&(goog.global.console.timeStamp?goog.global.console.timeStamp(a):goog.global.console.markTimeline&&goog.global.console.markTimeline(a));goog.global.msWriteProfilerMark&&goog.global.msWriteProfilerMark(a)};goog.debug.Logger.prototype.getName=function(){return this.name_};
  goog.debug.Logger.prototype.addHandler=function(a){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?(this.handlers_||(this.handlers_=[]),this.handlers_.push(a)):(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(a)))};
  goog.debug.Logger.prototype.removeHandler=function(a){if(goog.debug.LOGGING_ENABLED){var b=goog.debug.Logger.ENABLE_HIERARCHY?this.handlers_:goog.debug.Logger.rootHandlers_;return!!b&&goog.array.remove(b,a)}return!1};goog.debug.Logger.prototype.getParent=function(){return this.parent_};goog.debug.Logger.prototype.getChildren=function(){this.children_||(this.children_={});return this.children_};
  goog.debug.Logger.prototype.setLevel=function(a){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?this.level_=a:(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_=a))};goog.debug.Logger.prototype.getLevel=function(){return goog.debug.LOGGING_ENABLED?this.level_:goog.debug.Logger.Level.OFF};
  goog.debug.Logger.prototype.getEffectiveLevel=function(){if(!goog.debug.LOGGING_ENABLED)return goog.debug.Logger.Level.OFF;if(!goog.debug.Logger.ENABLE_HIERARCHY)return goog.debug.Logger.rootLevel_;if(this.level_)return this.level_;if(this.parent_)return this.parent_.getEffectiveLevel();goog.asserts.fail("Root logger has no level set.");return null};goog.debug.Logger.prototype.isLoggable=function(a){return goog.debug.LOGGING_ENABLED&&a.value>=this.getEffectiveLevel().value};
  goog.debug.Logger.prototype.log=function(a,b,c){goog.debug.LOGGING_ENABLED&&this.isLoggable(a)&&(goog.isFunction(b)&&(b=b()),this.doLogRecord_(this.getLogRecord(a,b,c)))};goog.debug.Logger.prototype.getLogRecord=function(a,b,c){var d=goog.debug.LogBuffer.isBufferingEnabled()?goog.debug.LogBuffer.getInstance().addRecord(a,b,this.name_):new goog.debug.LogRecord(a,String(b),this.name_);c&&(d.setException(c),d.setExceptionText(goog.debug.exposeException(c,arguments.callee.caller)));return d};
  goog.debug.Logger.prototype.shout=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SHOUT,a,b)};goog.debug.Logger.prototype.severe=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SEVERE,a,b)};goog.debug.Logger.prototype.warning=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.WARNING,a,b)};goog.debug.Logger.prototype.info=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.INFO,a,b)};
  goog.debug.Logger.prototype.config=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.CONFIG,a,b)};goog.debug.Logger.prototype.fine=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINE,a,b)};goog.debug.Logger.prototype.finer=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINER,a,b)};goog.debug.Logger.prototype.finest=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINEST,a,b)};
  goog.debug.Logger.prototype.logRecord=function(a){goog.debug.LOGGING_ENABLED&&this.isLoggable(a.getLevel())&&this.doLogRecord_(a)};goog.debug.Logger.prototype.doLogRecord_=function(a){goog.debug.Logger.logToProfilers("log:"+a.getMessage());if(goog.debug.Logger.ENABLE_HIERARCHY)for(var b=this;b;)b.callPublish_(a),b=b.getParent();else for(var b=0,c;c=goog.debug.Logger.rootHandlers_[b++];)c(a)};goog.debug.Logger.prototype.callPublish_=function(a){if(this.handlers_)for(var b=0,c;c=this.handlers_[b];b++)c(a)};
  goog.debug.Logger.prototype.setParent_=function(a){this.parent_=a};goog.debug.Logger.prototype.addChild_=function(a,b){this.getChildren()[a]=b};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.LogManager.loggers_[""]=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(){goog.debug.LogManager.initialize();return goog.debug.LogManager.rootLogger_};goog.debug.LogManager.getLogger=function(a){goog.debug.LogManager.initialize();return goog.debug.LogManager.loggers_[a]||goog.debug.LogManager.createLogger_(a)};
  goog.debug.LogManager.createFunctionForCatchErrors=function(a){return function(b){(a||goog.debug.LogManager.getRoot()).severe("Error: "+b.message+" ("+b.fileName+" @ Line: "+b.line+")")}};goog.debug.LogManager.createLogger_=function(a){var b=new goog.debug.Logger(a);if(goog.debug.Logger.ENABLE_HIERARCHY){var c=a.lastIndexOf("."),d=a.substr(0,c),c=a.substr(c+1),d=goog.debug.LogManager.getLogger(d);d.addChild_(c,b);b.setParent_(d)}return goog.debug.LogManager.loggers_[a]=b};goog.log={};goog.log.ENABLED=goog.debug.LOGGING_ENABLED;goog.log.Logger=goog.debug.Logger;goog.log.Level=goog.debug.Logger.Level;goog.log.LogRecord=goog.debug.LogRecord;goog.log.getLogger=function(a,b){if(goog.log.ENABLED){var c=goog.debug.LogManager.getLogger(a);b&&c&&c.setLevel(b);return c}return null};goog.log.addHandler=function(a,b){goog.log.ENABLED&&a&&a.addHandler(b)};goog.log.removeHandler=function(a,b){return goog.log.ENABLED&&a?a.removeHandler(b):!1};
  goog.log.log=function(a,b,c,d){goog.log.ENABLED&&a&&a.log(b,c,d)};goog.log.error=function(a,b,c){goog.log.ENABLED&&a&&a.severe(b,c)};goog.log.warning=function(a,b,c){goog.log.ENABLED&&a&&a.warning(b,c)};goog.log.info=function(a,b,c){goog.log.ENABLED&&a&&a.info(b,c)};goog.log.fine=function(a,b,c){goog.log.ENABLED&&a&&a.fine(b,c)};goog.events.FocusHandler=function(a){goog.events.EventTarget.call(this);this.element_=a;a=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_,a,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(a){var b=a.getBrowserEvent(),b=new goog.events.BrowserEvent(b);b.type="focusin"==a.type||"focus"==a.type?goog.events.FocusHandler.EventType.FOCUSIN:goog.events.FocusHandler.EventType.FOCUSOUT;this.dispatchEvent(b)};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.ui.tree.TreeControl=function(a,b,c){goog.ui.tree.BaseNode.call(this,a,b,c);this.setExpandedInternal(!0);this.setSelectedInternal(!0);this.selectedItem_=this;this.typeAhead_=new goog.ui.tree.TypeAhead;if(goog.userAgent.IE)try{document.execCommand("BackgroundImageCache",!1,!0)}catch(d){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.keyHandler_=null;
  goog.ui.tree.TreeControl.prototype.focusHandler_=null;goog.ui.tree.TreeControl.prototype.logger_=goog.log.getLogger("goog.ui.tree.TreeControl");goog.ui.tree.TreeControl.prototype.focused_=!1;goog.ui.tree.TreeControl.prototype.focusedNode_=null;goog.ui.tree.TreeControl.prototype.showLines_=!0;goog.ui.tree.TreeControl.prototype.showExpandIcons_=!0;goog.ui.tree.TreeControl.prototype.showRootNode_=!0;goog.ui.tree.TreeControl.prototype.showRootLines_=!0;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(a){this.focused_=!0;goog.dom.classlist.add(this.getElement(),"focused");this.selectedItem_&&this.selectedItem_.select()};goog.ui.tree.TreeControl.prototype.handleBlur_=function(a){this.focused_=!1;goog.dom.classlist.remove(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(a){this.showRootNode_?goog.ui.tree.TreeControl.superClass_.setExpanded.call(this,a):this.setExpandedInternal(a)};goog.ui.tree.TreeControl.prototype.getExpandIconHtml=function(){return""};goog.ui.tree.TreeControl.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.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 a=this.getExpanded();if(a&&this.expandedIconClass_)return this.expandedIconClass_;if(!a&&this.iconClass_)return this.iconClass_;var b=this.getConfig();return a&&b.cssExpandedRootIcon?b.cssTreeIcon+" "+b.cssExpandedRootIcon:!a&&b.cssCollapsedRootIcon?b.cssTreeIcon+" "+b.cssCollapsedRootIcon:""};
  goog.ui.tree.TreeControl.prototype.setSelectedItem=function(a){if(this.selectedItem_!=a){var b=!1;this.selectedItem_&&(b=this.selectedItem_==this.focusedNode_,this.selectedItem_.setSelectedInternal(!1));if(this.selectedItem_=a)a.setSelectedInternal(!0),b&&a.select();this.dispatchEvent(goog.events.EventType.CHANGE)}};goog.ui.tree.TreeControl.prototype.getSelectedItem=function(){return this.selectedItem_};
  goog.ui.tree.TreeControl.prototype.setShowLines=function(a){this.showLines_!=a&&(this.showLines_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowLines=function(){return this.showLines_};
  goog.ui.tree.TreeControl.prototype.updateLinesAndExpandIcons_=function(){function a(e){var f=e.getChildrenElement();if(f){var g=!c||b==e.getParent()&&!d?e.getConfig().cssChildrenNoLines:e.getConfig().cssChildren;f.className=g;if(f=e.getExpandIconElement())f.className=e.getExpandIconClass()}e.forEachChild(a)}var b=this,c=b.getShowLines(),d=b.getShowRootLines();a(this)};
  goog.ui.tree.TreeControl.prototype.setShowRootLines=function(a){this.showRootLines_!=a&&(this.showRootLines_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowRootLines=function(){return this.showRootLines_};goog.ui.tree.TreeControl.prototype.setShowExpandIcons=function(a){this.showExpandIcons_!=a&&(this.showExpandIcons_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowExpandIcons=function(){return this.showExpandIcons_};
  goog.ui.tree.TreeControl.prototype.setShowRootNode=function(a){if(this.showRootNode_!=a){this.showRootNode_=a;if(this.isInDocument()){var b=this.getRowElement();b&&(b.className=this.getRowClassName())}!a&&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 a=this.getElement();goog.asserts.assert(a,"The DOM element for the tree cannot be null.");goog.a11y.aria.setRole(a,"tree");goog.a11y.aria.setState(a,"labelledby",this.getLabelElement().id)};
  goog.ui.tree.TreeControl.prototype.enterDocument=function(){goog.ui.tree.TreeControl.superClass_.enterDocument.call(this);var a=this.getElement();a.className=this.getConfig().cssRoot;a.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 a=this.getElement();a.tabIndex=0;var b=this.keyHandler_=new goog.events.KeyHandler(a),c=this.focusHandler_=new goog.events.FocusHandler(a);this.getHandler().listen(c,goog.events.FocusHandler.EventType.FOCUSOUT,this.handleBlur_).listen(c,goog.events.FocusHandler.EventType.FOCUSIN,this.handleFocus_).listen(b,goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent).listen(a,goog.events.EventType.MOUSEDOWN,this.handleMouseEvent_).listen(a,
  goog.events.EventType.CLICK,this.handleMouseEvent_).listen(a,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(a){goog.log.fine(this.logger_,"Received event "+a.type);var b=this.getNodeFromEvent_(a);if(b)switch(a.type){case goog.events.EventType.MOUSEDOWN:b.onMouseDown(a);break;case goog.events.EventType.CLICK:b.onClick_(a);break;case goog.events.EventType.DBLCLICK:b.onDoubleClick_(a)}};
  goog.ui.tree.TreeControl.prototype.handleKeyEvent=function(a){var b=!1;(b=this.typeAhead_.handleNavigation(a)||this.selectedItem_&&this.selectedItem_.onKeyDown(a)||this.typeAhead_.handleTypeAheadChar(a))&&a.preventDefault();return b};goog.ui.tree.TreeControl.prototype.getNodeFromEvent_=function(a){var b=null;for(a=a.target;null!=a;){if(b=goog.ui.tree.BaseNode.allNodes[a.id])return b;if(a==this.getElement())break;a=a.parentNode}return null};
  goog.ui.tree.TreeControl.prototype.createNode=function(a){return new goog.ui.tree.TreeNode(a||"",this.getConfig(),this.getDomHelper())};goog.ui.tree.TreeControl.prototype.setNode=function(a){this.typeAhead_.setNodeInMap(a)};goog.ui.tree.TreeControl.prototype.removeNode=function(a){this.typeAhead_.removeNodeFromMap(a)};goog.ui.tree.TreeControl.prototype.clearTypeAhead=function(){this.typeAhead_.clear()};
  goog.ui.tree.TreeControl.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"};Blockly.Toolbox=function(a){this.blockSpaceEditor_=a;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(a){this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");this.HtmlDiv.setAttribute("dir",Blockly.RTL?"RTL":"LTR");goog.dom.insertSiblingBefore(this.HtmlDiv,a);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_);a.appendChild(this.flyout_.createDom(!0));Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(a){Blockly.fireUiEvent(window,"resize");Blockly.isRightButton(a)||a.target==this.HtmlDiv?this.blockSpaceEditor_.hideChaff(!1):this.blockSpaceEditor_.hideChaff(!0)})};
  Blockly.Toolbox.prototype.init=function(a,b){Blockly.Toolbox.CONFIG_.cleardotPath=Blockly.assetUrl("media/1x1.gif");Blockly.Toolbox.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(Blockly.RTL?"Rtl":"Ltr");var c=new Blockly.Toolbox.TreeControl(this,"root",Blockly.Toolbox.CONFIG_);this.tree_=c;c.setShowRootNode(!1);c.setShowLines(!1);c.setShowExpandIcons(!1);c.setSelectedItem(null);this.HtmlDiv.style.display="block";this.flyout_.init(a,!0);this.populate_();c.render(this.HtmlDiv);goog.events.listen(window,
  goog.events.EventType.RESIZE,goog.partial(this.position_,b),!1,this);this.position_(b);this.enabled=!0};
  Blockly.Toolbox.prototype.position_=function(a){var b=this.HtmlDiv,c=goog.style.getBorderBox(a.svg_),d=a.svgSize();Blockly.RTL?b.style.right=c.right+"px":b.style.marginLeft=c.left;b.style.height=d.height+"px";this.width=b.offsetWidth;Blockly.RTL||(this.width-=1);a.hideTrashRect_||(a.svgBackground_.setAttribute("x",Blockly.RTL?d.width-b.offsetWidth:0),a.svgBackground_.setAttribute("width",b.offsetWidth),a.svgBackground_.setAttribute("height",d.height));a=b.offsetWidth;b=this.trashcanHolder.getAttribute("width");
  a=Math.round(a/2-b/2);this.trashcanHolder.style.left=a+"px"};
  Blockly.Toolbox.prototype.populate_=function(){function a(c,d){for(var e=0,f;f=c.childNodes[e];e++)if(f.tagName){var g=f.tagName.toUpperCase();if("CATEGORY"===g){g=b.createNode(f.getAttribute("name"));g.blocks=[];d.add(g);var h=f.getAttribute("custom");h&&(g.blocks[0]=h);a(f,g)}else"BLOCK"===g&&d.blocks.push(f)}}var b=this.tree_;b.blocks=[];a(Blockly.languageTree,this.tree_);if(b.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 a=-1E7;Blockly.RTL&&(a=Blockly.mainBlockSpaceEditor.svgSize().width-this.width);return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};Blockly.Toolbox.TreeControl=function(a,b,c,d){goog.ui.tree.TreeControl.call(this,b,c,d);this.toolbox_=a};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
  Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(goog.events.BrowserFeature.TOUCH_ENABLED||"onpointerdown"in window||"onmspointerdown"in window){var a=this.getElement();Blockly.bindEvent_(a,goog.events.EventType.TOUCHSTART,this,this.handleTouchEvent_);Blockly.bindEvent_(a,goog.events.EventType.POINTERDOWN,this,this.handleTouchEvent_);Blockly.bindEvent_(a,goog.events.EventType.MSPOINTERDOWN,this,this.handleTouchEvent_)}};
  Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){a.preventDefault();var b=this.getNodeFromEvent_(a);!b||a.type!==goog.events.EventType.TOUCHSTART&&a.type!==goog.events.EventType.POINTERDOWN&&a.type!==goog.events.EventType.MSPOINTERDOWN||(a.stopImmediatePropagation(),window.setTimeout(function(){b.onMouseDown(a)},1))};Blockly.Toolbox.TreeControl.prototype.createNode=function(a){return new Blockly.Toolbox.TreeNode(this.toolbox_,a||"",this.getConfig(),this.getDomHelper())};
  Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){this.selectedItem_!=a&&(goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a),a&&a.blocks&&a.blocks.length?this.toolbox_.flyout_.show(a.blocks):this.toolbox_.flyout_.hide())};
  Blockly.Toolbox.TreeNode=function(a,b,c,d){goog.ui.tree.TreeNode.call(this,b,c,d);b=function(){Blockly.fireUiEvent(window,"resize")};this.toolbox_=a;goog.events.listen(this.toolbox_.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,b);goog.events.listen(this.toolbox_.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,b)};goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode);Blockly.Toolbox.TreeNode.prototype.getExpandIconHtml=function(){return"<span></span>"};
  Blockly.Toolbox.TreeNode.prototype.getExpandIconElement=function(){return null};Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(a){this.toolbox_.enabled&&(this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select(),this.updateRow(),a.stopPropagation())};Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(a){};Blockly.Variables={};Blockly.Variables.NAME_TYPE="VARIABLE";Blockly.Variables.NAME_TYPE_LOCAL="LOCALVARIABLE";Blockly.Variables.allVariables=function(a){var b;if(a)b=a.getDescendants();else if(Blockly.mainBlockSpace)b=Blockly.mainBlockSpace.getAllBlocks();else return[];a={};for(var c=0;c<b.length;c++){var d=b[c].getVars;if(d)for(var d=d.call(b[c]),e=0;e<d.length;e++){var f=d[e];f&&(a[Blockly.Names.PREFIX_+f.toLowerCase()]=f)}}b=[];for(var g in a)b.push(a[g]);return b};
  Blockly.Variables.renameVariable=function(a,b,c){if(b!==a){c=c.getAllBlocks({shareMainModal:!1});for(var d=0;d<c.length;d++){var e=c[d].renameVar;e&&e.call(c[d],a,b)}Blockly.functionEditor&&Blockly.functionEditor.isOpen()&&(Blockly.functionEditor.renameParameter(a,b),Blockly.functionEditor.refreshParamsEverywhere())}};
  Blockly.Variables.deleteVariable=function(a,b){for(var c=b.getAllBlocks({shareMainModal:!1}),d=0;d<c.length;d++){var e=c[d].removeVar;e&&e.call(c[d],a)}Blockly.functionEditor&&Blockly.functionEditor.isOpen()&&(Blockly.functionEditor.removeParameter(a),Blockly.functionEditor.refreshParamsEverywhere())};
  Blockly.Variables.flyoutCategory=function(a,b,c,d){var e=Blockly.Variables.allVariables();e.sort(goog.string.caseInsensitiveCompare);e.unshift(null);for(var f=void 0,g=0;g<e.length;g++)if(e[g]!==f){var h=Blockly.Blocks.variables_get?new Blockly.Block(d,"variables_get"):null;h&&h.initSvg();var k=Blockly.Blocks.variables_set?new Blockly.Block(d,"variables_set"):null;k&&k.initSvg();null===e[g]?f=(h||k).getVars()[0]:(h&&h.setTitleValue(e[g],"VAR"),k&&k.setTitleValue(e[g],"VAR"));k&&a.push(k);h&&a.push(h);
  h&&k?b.push(c,3*c):b.push(2*c)}};Blockly.Variables.generateUniqueName=function(a){if(a)return Blockly.Variables.generateUniqueNameFromBase_(a);a=Blockly.Variables.allVariables();var b="";if(a.length){a.sort(goog.string.caseInsensitiveCompare);for(var c=0,d="i",e=0,f=!1;!b;){e=0;for(f=!1;e<a.length&&!f;)a[e].toLowerCase()==d&&(f=!0),e++;f?("z"===d[0]?(c++,d="a"):(d=String.fromCharCode(d.charCodeAt(0)+1),"l"==d[0]&&(d=String.fromCharCode(d.charCodeAt(0)+1))),0<c&&(d+=c)):b=d}}else b="i";return b};
  Blockly.Variables.generateUniqueNameFromBase_=function(a){var b=Blockly.Variables.allVariables();if(-1===b.indexOf(a))return a;var c=1,d=/^([^\d]*)(\d+)$/.exec(a);d&&(a=d[1],c=parseInt(d[2],10)+1);do if(d=a+c.toString(),-1===b.indexOf(d))return d;while(c++)};Blockly.FieldVariable=function(a,b,c){var d;if(b===Blockly.FieldParameter.dropdownChange)d=b;else if(b){var e=this;d=function(a){var c=e.dropdownChange(a);a=void 0===c?a:null===c?e.getValue():c;b.call(e,a);return c}}else d=this.dropdownChange;Blockly.FieldVariable.superClass_.constructor.call(this,c||Blockly.FieldVariable.dropdownCreate,d);a?this.setValue(a):this.setValue(Blockly.Variables.generateUniqueName())};goog.inherits(Blockly.FieldVariable,Blockly.FieldDropdown);
  Blockly.FieldVariable.prototype.getValue=function(){return this.getText()};Blockly.FieldVariable.prototype.setValue=function(a){this.value_=a;this.setText(a)};Blockly.FieldVariable.dropdownCreate=function(){var a=Blockly.Variables.allVariables(),b=this.getText();b&&-1==a.indexOf(b)&&a.push(b);a.sort(goog.string.caseInsensitiveCompare);a.push(Blockly.Msg.RENAME_VARIABLE);a.push(Blockly.Msg.NEW_VARIABLE);for(var b=[],c=0;c<a.length;c++)b[c]=[a[c],a[c]];return b};
  Blockly.FieldVariable.prototype.dropdownChange=function(a){if(a===Blockly.Msg.RENAME_VARIABLE){var b=this.getText();this.getParentEditor_().hideChaff();Blockly.FieldVariable.modalPromptName(Blockly.Msg.RENAME_VARIABLE_TITLE.replace("%1",b),Blockly.Msg.CONFIRM_RENAME_VARIABLE,b,function(a){Blockly.Variables.renameVariable(b,a,this.sourceBlock_.blockSpace)}.bind(this));return null}if(a===Blockly.Msg.NEW_VARIABLE)return this.getParentEditor_().hideChaff(),Blockly.FieldVariable.modalPromptName(Blockly.Msg.NEW_VARIABLE_TITLE,
  Blockly.Msg.CONFIRM_CREATE_VARIABLE,"",function(a){this.setText(a);Blockly.Variables.renameVariable(a,a,this.sourceBlock_.blockSpace)}.bind(this)),null};Blockly.FieldVariable.modalPromptName=function(a,b,c,d){Blockly.showSimpleDialog({bodyText:a,prompt:!0,promptPrefill:c,cancelText:b,confirmText:Blockly.Msg.CANCEL,onConfirm:null,onCancel:d})};Blockly.FieldVariable.removeExtraWhitespace=function(a){return a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"")};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 a=[],b=[],c=[];Blockly.mainBlockSpace.getAllBlocks().forEach(function(d){if(d.getProcedureInfo){var e=d.getProcedureInfo();switch(d.type){case "functional_definition":c.push(e);"start_blocks"===Blockly.editBlocks&&(d=goog.object.clone(e),d.callType=Blockly.Procedures.PROCEDURAL_TO_FUNCTIONAL_CALL_TYPE,c.push(d));break;case "procedures_defreturn":a.push(e);break;case "procedures_defnoreturn":b.push(e)}}});b.sort(Blockly.Procedures.procedureInfoSort_);
  a.sort(Blockly.Procedures.procedureInfoSort_);c.sort(Blockly.Procedures.procedureInfoSort_);return goog.array.concat(b,a,c)};Blockly.Procedures.procedureInfoSort_=function(a,b){var c=a.name.toLowerCase(),d=b.name.toLowerCase();return c>d?1:c<d?-1:0};Blockly.Procedures.findLegalName=function(a,b){if(b.isInFlyout)return a;for(var c=a;!Blockly.Procedures.isLegalName(c,b.blockSpace,b);)var d=c.match(/^(.*?)(\d+)$/),c=d?d[1]+(parseInt(d[2],10)+1):c+"2";return c};
  Blockly.Procedures.isLegalName=function(a,b,c){return!b.getAllBlocks().filter(function(a){return a!==c}).some(function(b){return b.getProcedureInfo&&Blockly.Names.equals(b.getProcedureInfo().name,a)})};Blockly.Procedures.rename=function(a){a=a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");a=Blockly.Procedures.findLegalName(a,this.sourceBlock_);for(var b=this.sourceBlock_.blockSpace.getAllBlocks(),c=0;c<b.length;c++){var d=b[c].renameProcedure;d&&d.call(b[c],this.text_,a)}return a};
  Blockly.Procedures.flyoutCategory=function(a,b,c,d,e){if(!Blockly.functionEditor){if(Blockly.Blocks.procedures_defnoreturn){var f=new Blockly.Block(d,"procedures_defnoreturn");f.initSvg();a.push(f);b.push(2*c)}Blockly.Blocks.procedures_defreturn&&(f=new Blockly.Block(d,"procedures_defreturn"),f.initSvg(),a.push(f),b.push(2*c));Blockly.Blocks.procedures_ifreturn&&(f=new Blockly.Block(d,"procedures_ifreturn"),f.initSvg(),a.push(f),b.push(2*c));b.length&&(b[b.length-1]=3*c)}Blockly.Procedures.allProcedures().forEach(function(f){if(!e||
  e(f)){var h=Blockly.Procedures.createCallerBlock(d,f);a.push(h);b.push(2*c);Blockly.editBlocks&&(f=Blockly.Procedures.createFunctionPassingBlock(d,f),a.push(f),b.push(2*c))}})};Blockly.Procedures.createCallerFromDefinition=function(a,b){return Blockly.Procedures.createCallerBlock(a,b.getProcedureInfo())};
  Blockly.Procedures.createCallerBlock=function(a,b){var c=new Blockly.Block(a,b.callType);c.setTitleValue(b.name,"NAME");for(var d=[],e=0;e<b.parameterNames.length;e++)d[e]="ARG"+e;c.setProcedureParameters(b.parameterNames,d,b.parameterTypes);c.initSvg();return c};Blockly.Procedures.createFunctionPassingBlock=function(a,b){var c=new Blockly.Block(a,"functional_pass");c.setTitleValue(b.name,"NAME");c.initSvg();return c};
  Blockly.Procedures.getCallers=function(a,b){return b.getAllBlocks().filter(function(b){return b.getCallName&&Blockly.Names.equals(a,b.getCallName())})};Blockly.Procedures.disposeCallers=function(a,b){Blockly.Procedures.getCallers(a,b).forEach(function(a){a.dispose(!0,!1)})};Blockly.Procedures.mutateCallers=function(a,b,c,d,e){Blockly.Procedures.getCallers(a,b).forEach(function(a){a.setProcedureParameters(c,d,e)},this)};
  Blockly.Procedures.getDefinition=function(a,b){return goog.array.find(b.getAllBlocks(),function(b){return b.getProcedureInfo&&Blockly.Names.equals(b.getProcedureInfo().name,a)})};goog.structs.LinkedMap=function(a,b){this.maxCount_=a||null;this.cache_=!!b;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(a){(a=this.map_.get(a))&&this.cache_&&(a.remove(),this.insert_(a));return a};goog.structs.LinkedMap.prototype.get=function(a,b){var c=this.findAndMoveToTop_(a);return c?c.value:b};
  goog.structs.LinkedMap.prototype.peekValue=function(a,b){var c=this.map_.get(a);return c?c.value:b};goog.structs.LinkedMap.prototype.set=function(a,b){var c=this.findAndMoveToTop_(a);c?c.value=b:(c=new goog.structs.LinkedMap.Node_(a,b),this.map_.set(a,c),this.insert_(c))};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(a){return(a=this.map_.get(a))?(this.removeNode(a),!0):!1};goog.structs.LinkedMap.prototype.removeNode=function(a){a.remove();this.map_.remove(a.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.setMaxCount=function(a){this.maxCount_=a||null;null!=this.maxCount_&&this.truncate_(this.maxCount_)};goog.structs.LinkedMap.prototype.getKeys=function(){return this.map(function(a,b){return b})};goog.structs.LinkedMap.prototype.getValues=function(){return this.map(function(a,b){return a})};goog.structs.LinkedMap.prototype.contains=function(a){return this.some(function(b){return b==a})};goog.structs.LinkedMap.prototype.containsKey=function(a){return this.map_.containsKey(a)};
  goog.structs.LinkedMap.prototype.clear=function(){this.truncate_(0)};goog.structs.LinkedMap.prototype.forEach=function(a,b){for(var c=this.head_.next;c!=this.head_;c=c.next)a.call(b,c.value,c.key,this)};goog.structs.LinkedMap.prototype.map=function(a,b){for(var c=[],d=this.head_.next;d!=this.head_;d=d.next)c.push(a.call(b,d.value,d.key,this));return c};goog.structs.LinkedMap.prototype.some=function(a,b){for(var c=this.head_.next;c!=this.head_;c=c.next)if(a.call(b,c.value,c.key,this))return!0;return!1};
  goog.structs.LinkedMap.prototype.every=function(a,b){for(var c=this.head_.next;c!=this.head_;c=c.next)if(!a.call(b,c.value,c.key,this))return!1;return!0};goog.structs.LinkedMap.prototype.insert_=function(a){this.cache_?(a.next=this.head_.next,a.prev=this.head_,this.head_.next=a,a.next.prev=a):(a.prev=this.head_.prev,a.next=this.head_,this.head_.prev=a,a.prev.next=a);null!=this.maxCount_&&this.truncate_(this.maxCount_)};
  goog.structs.LinkedMap.prototype.truncate_=function(a){for(var b=this.map_.getCount();b>a;b--)this.removeNode(this.cache_?this.head_.prev:this.head_.next)};goog.structs.LinkedMap.prototype.popNode_=function(a){this.head_!=a&&this.removeNode(a);return a.value};goog.structs.LinkedMap.Node_=function(a,b){this.key=a;this.value=b};goog.structs.LinkedMap.Node_.prototype.remove=function(){this.prev.next=this.next;this.next.prev=this.prev;delete this.prev;delete this.next};Blockly.HorizontalFlyout=function(a){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(a){var b=this.targetBlockSpace_.getMetrics();this.width_=Math.max(0,b.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(a){a?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 a=this.targetBlockSpace_.getMetrics();if(a){var b=this.height_-this.CORNER_RADIUS,c=Math.max(0,a.viewWidth-2*this.CORNER_RADIUS),d=["M 0,0"];d.push("v",b);d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,0,this.CORNER_RADIUS,this.CORNER_RADIUS);d.push("h",c);d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,0,this.CORNER_RADIUS,-this.CORNER_RADIUS);d.push("v",-b);d.push("z");this.svgBackground_.setAttribute("d",
  d.join(" "));this.width_=c;this.svgGroup_.setAttribute("transform","translate("+a.absoluteLeft+","+(a.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(a,b,c,d){var e=a.getHeightWidth();if(Blockly.RTL&&0>b.x-e.width||!Blockly.RTL&&b.x+e.width>this.width_)this.flyoutRows++,b.y+=e.height+c/2,b.x=d;a.moveBy(b.x,b.y);a=e.width+c/2;Blockly.RTL&&(a=-a);b.x+=a;this.height_=b.y+e.height+c/2};Blockly.HorizontalFlyout.prototype.reflow=function(){};Blockly.BlockSpaceEditor=function(a,b,c,d,e){b&&(this.getBlockSpaceMetrics_=b);c&&(this.setBlockSpaceMetrics_=c);d&&(this.hideTrashRect_=d);this.readOnly_=!!e;this.blockSpace=new Blockly.BlockSpace(this,goog.bind(this.getBlockSpaceMetrics_,this),goog.bind(this.setBlockSpaceMetrics_,this),a);this.createDom_(a);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(a){if(!goog.dom.getElement("blocklySvgDefsGlobal")){a=Blockly.createSvgElement("svg",{id:"blocklyFilters",width:0,height:0,style:"display: block"},a);a=Blockly.createSvgElement("defs",{id:"blocklySvgDefsGlobal"},a);var b,c;b=Blockly.createSvgElement("filter",{id:"blocklyEmboss"},a);Blockly.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},b);c=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",
  surfaceScale:1,specularConstant:0.5,specularExponent:10,"lighting-color":"white",result:"specOut"},b);Blockly.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},c);Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},b);Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},b);b=Blockly.createSvgElement("filter",{id:"blocklyTrashcanShadowFilter",height:"150%",y:"-20%"},a);Blockly.createSvgElement("feGaussianBlur",
  {"in":"SourceAlpha",stdDeviation:2,result:"blur"},b);Blockly.createSvgElement("feOffset",{"in":"blur",dx:1,dy:1,result:"offsetBlur"},b);b=Blockly.createSvgElement("feMerge",{},b);Blockly.createSvgElement("feMergeNode",{"in":"offsetBlur"},b);Blockly.createSvgElement("feMergeNode",{"in":"SourceGraphic"},b);b=Blockly.createSvgElement("filter",{id:"blocklyShadowFilter"},a);Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},b);a=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",
  width:10,height:10},a);Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},a);Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},a)}};
  Blockly.BlockSpaceEditor.prototype.createDom_=function(a){a.setAttribute("dir","LTR");this.populateSVGEffects_(a);var b=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":"blocklySvg"},null);this.svg_=b;a.appendChild(b);goog.events.listen(b,"selectstart",function(){return!1});this.defs_=Blockly.createSvgElement("defs",{id:"blocklySvgDefs"},b);this.blockSpace.maxBlocks=Blockly.maxBlocks;
  this.hideTrashRect_||this.isReadOnly()||!Blockly.hasCategories||(this.svgBackground_=Blockly.createSvgElement("rect",{id:"toolboxRect","class":"blocklyToolboxBackground"},this.svg_));b.appendChild(this.blockSpace.createDom());this.isReadOnly()||(this.addToolboxOrFlyout_(),this.addChangeListener(this.bumpBlocksIfNotDragging));this.setEnableToolbox=function(a){this.isReadOnly()||(this.flyout_?this.flyout_.setEnabled(a):this.toolbox&&(this.toolbox.enabled=a))};b.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(a){this.defs_.appendChild(a)};Blockly.BlockSpaceEditor.prototype.addToolboxOrFlyout_=function(){Blockly.hasCategories?this.toolbox=new Blockly.Toolbox(this):this.addFlyout_()};
  Blockly.BlockSpaceEditor.prototype.addFlyout_=function(){var a=this.flyout_=new Blockly.Flyout(this,!0),b=a.createDom(!1);a.init(this.blockSpace,!0);a.autoClose=!1;goog.dom.insertSiblingBefore(b,this.blockSpace.svgGroup_)};Blockly.BlockSpaceEditor.prototype.getDeleteAreas=function(){var a=[];this.flyout_&&goog.array.extend(a,this.flyout_.getRect());this.toolbox&&goog.array.extend(a,this.toolbox.getRect());return a};
  Blockly.BlockSpaceEditor.prototype.bumpBlocksIfNotDragging=function(){Blockly.Block.isDragging()||this.bumpBlocksIntoBlockSpace()};
  Blockly.BlockSpaceEditor.prototype.bumpBlocksIntoBlockSpace=function(){var a=this.blockSpace.getMetrics();if(a){if(!Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK)var a=this.blockSpace.getScrollableSize(a),b=Blockly.BlockSpaceEditor.BUMP_PADDING_TOP,c=Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT,d=a.height-Blockly.BlockSpaceEditor.BUMP_PADDING_BOTTOM,e=a.width-Blockly.BlockSpaceEditor.BUMP_PADDING_RIGHT,f=e-c,g=d-b;this.blockSpace.getTopBlocks(!1,!1).forEach(function(a){if(a.isVisible()&&!a.isCurrentlyBeingDragged()){if(!Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK){var k=
  a.getHeightWidth();if(k.width>f||k.height>g)return}var l,m,n;if(Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK){var p=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),q=a.getBox(),r=Blockly.getBoxOverflow(p,q);l=Math.max(0,r.left);m=Math.max(0,r.right);k=Math.max(0,r.top);n=Math.max(0,r.bottom)}else n=a.getRelativeToSurfaceXY(),
  l=Math.max(0,c-n.x),m=Math.max(0,n.x-e),k=Math.max(0,b-n.y),n=Math.max(0,n.y-d);l=l?l:-m;k=k?k:-n;Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK&&(Blockly.isBoxWiderThan(q,p)&&(l=r.left),Blockly.isBoxTallerThan(q,p)&&(k=r.top));(r=l||k)&&a.moveBy(l,k);Blockly.BlockSpaceEditor.BUMP_DEBUG&&Blockly.BlockSpaceEditor.BUMP_ENTIRE_BLOCK&&(k=a.getBox(),this.blockSpace.drawDebugBox("block box"+a.id,q,r?"red":"green"),this.blockSpace.drawDebugBox("block after"+a.id,k,"purple"),this.blockSpace.drawDebugBox("block space box"+
  a.id,p,"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);Blockly.documentEventsBound_||(Blockly.bindEvent_(window,"resize",this,this.svgResize),Blockly.bindEvent_(document,"keydown",this,this.onKeyDown_),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.flyout_.show(Blockly.languageTree.childNodes)));if(Blockly.hasVerticalScrollbars||Blockly.hasHorizontalScrollbars)this.blockSpace.scrollbarPair=new Blockly.ScrollbarPair(this.blockSpace,Blockly.hasHorizontalScrollbars,Blockly.hasVerticalScrollbars),this.blockSpace.scrollbarPair.resize()};
  Blockly.BlockSpaceEditor.prototype.detectBrokenControlPoints=function(){if(goog.userAgent.WEBKIT){var a=Blockly.createSvgElement("path",{d:"m 0,0 c 0,-5 0,-5 0,0 H 50 V 50 z"},this.svg_);Blockly.isMsie()||Blockly.isTrident()?(a.style.display="inline",a.bBox_={x:a.getBBox().x,y:a.getBBox().y,width:a.scrollWidth,height:a.scrollHeight}):a.bBox_=a.getBBox();50<a.bBox_.height&&(Blockly.BROKEN_CONTROL_POINTS=!0);this.svg_.removeChild(a)}};
  Blockly.BlockSpaceEditor.prototype.svgSize=function(){return{width:this.svg_.cachedWidth_,height:this.svg_.cachedHeight_}};
  Blockly.BlockSpaceEditor.prototype.svgResize=function(){var a=this.svg_,b=window.getComputedStyle(a),c=0;b&&(c=(parseInt(b.borderLeftWidth,10)||0)+(parseInt(b.borderRightWidth,10)||0));var b=a.parentNode,d=this.getWorkspaceTopOffset(),c=b.clientWidth-c,b=b.clientHeight-d;a.cachedWidth_!=c&&(a.setAttribute("width",c+"px"),a.cachedWidth_=c);a.cachedHeight_!=b&&(a.setAttribute("height",b+"px"),a.cachedHeight_=b);this.blockSpace.scrollbarPair?this.blockSpace.scrollbarPair.resize():this.setBlockSpaceMetricsNoScroll_()};
  Blockly.BlockSpaceEditor.prototype.getWorkspaceTopOffset=function(){var a=this.svg_,b=a.parentNode,c=window.getComputedStyle(b),c=c?parseInt(c.borderTopWidth,10)||0:0;return goog.style.getPageOffsetTop(a)-(goog.style.getPageOffsetTop(b)+c)};Blockly.BlockSpaceEditor.prototype.appendSVGChild=function(a){this.svg_.appendChild(a)};Blockly.BlockSpaceEditor.prototype.getSVGElement=function(){return this.svg_};
  Blockly.BlockSpaceEditor.prototype.getBlockSpaceWidth=function(){var a=this.blockSpace.getMetrics();return a?a.viewWidth:0};Blockly.BlockSpaceEditor.prototype.getToolboxWidth=function(){var a=0,b=this.flyout_||this.toolbox&&this.toolbox.flyout_;b&&(b=b.blockSpace_.getMetrics())&&(a=b.viewWidth);this.toolbox&&(a+=this.toolbox.HtmlDiv.getBoundingClientRect().width);return a};Blockly.BlockSpaceEditor.prototype.setCursor=function(a){Blockly.Css.setCursor(a,this.svg_)};
  Blockly.BlockSpaceEditor.prototype.onKeyDown_=function(a){if(!Blockly.isTargetInput(a))if(27==a.keyCode)this.hideChaff();else if(8==a.keyCode||46==a.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(this.hideChaff(),Blockly.selected.dispose(!0,!0))}finally{a.preventDefault()}else if(a.altKey||a.ctrlKey||a.metaKey)Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isCopyable()&&(this.hideChaff(),67==a.keyCode?Blockly.BlockSpaceEditor.copy_(Blockly.selected):88==a.keyCode&&
  (Blockly.BlockSpaceEditor.copy_(Blockly.selected),Blockly.selected.dispose(!0,!0))),86==a.keyCode&&Blockly.clipboard_&&Blockly.focusedBlockSpace.paste(Blockly.clipboard_)};Blockly.BlockSpaceEditor.terminateDrag_=function(){Blockly.Block.terminateDrag_();Blockly.Flyout.terminateDrag_()};
  Blockly.BlockSpaceEditor.copy_=function(a){var b=Blockly.Xml.blockToDom(a);Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",Blockly.RTL?-c.x:c.x);b.setAttribute("y",c.y);Blockly.clipboard_={dom:b,sourceBlockSpace:a.blockSpace}};
  Blockly.BlockSpaceEditor.showContextMenu_=function(a){if(!this.isReadOnly()){var b=[];if(Blockly.collapse){for(var c=!1,d=!1,e=this.getTopBlocks(!1),f=0;f<e.length;f++)e[f].isCollapsed()?c=!0:d=!0;d={enabled:d};d.text=Blockly.Msg.COLLAPSE_ALL;d.callback=function(){for(var a=0;a<e.length;a++)e[a].setCollapsed(!0)};b.push(d);c={enabled:c};c.text=Blockly.Msg.EXPAND_ALL;c.callback=function(){for(var a=0;a<e.length;a++)e[a].setCollapsed(!1)};b.push(c)}c={enabled:!1};c.text=Blockly.Msg.HELP;c.callback=
  function(){};b.push(c);Blockly.ContextMenu.show(a,b)}};Blockly.BlockSpaceEditor.prototype.hideChaff=function(a){Blockly.Tooltip.hide();Blockly.WidgetDiv.hide();this.toolbox&&!a&&this.toolbox.flyout_&&this.toolbox.flyout_.autoClose&&this.toolbox.clearSelection()};
  Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_=function(){var a,b=this.svgSize(),c=0;if(this.toolbox||this.flyout_)c=this.toolbox?this.toolbox.width:this.flyout_.width_;b.width-=c;try{var d=this.getCanvasBBox(this.blockSpace.getCanvas());a=Blockly.svgRectToRect(d);this.blockSpace.pickedUpBlockOrigin_&&a.boundingRect(this.blockSpace.pickedUpBlockOrigin_)}catch(e){return null}var c=Blockly.RTL?0:c,d=this.blockSpace.getScrollOffsetX(),f=b.width,b=b.height,g=this.blockSpace.getScrollOffsetY();
  return{viewHeight:b,viewWidth:f,viewTop:g,viewLeft:d,contentHeight:a.height,contentWidth:a.width,contentTop:a.top,contentLeft:a.left,absoluteTop:0,absoluteLeft:c}};Blockly.BlockSpaceEditor.prototype.getCanvasBBox=function(a){return Blockly.isMsie()||Blockly.isTrident()?(a.style.display="inline",{x:a.getBBox().x,y:a.getBBox().y,width:a.scrollWidth,height:a.scrollHeight}):a.getBBox()};
  Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_=function(a){if(!this.blockSpace.scrollbarPair)throw"Attempt to set editor's scroll position without scrollbars.";var b=this.getBlockSpaceMetrics_(),c=this.blockSpace.getScrollableSize(b);goog.isNumber(a.x)&&(this.blockSpace.xOffsetFromView=-c.width*a.x);goog.isNumber(a.y)&&(this.blockSpace.yOffsetFromView=-c.height*a.y);a="translate("+(this.blockSpace.xOffsetFromView+b.absoluteLeft)+","+(this.blockSpace.yOffsetFromView+b.absoluteTop)+")";this.blockSpace.getCanvas().setAttribute("transform",
  a);this.blockSpace.getDragCanvas().setAttribute("transform",a);this.blockSpace.getBubbleCanvas().setAttribute("transform",a)};Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetricsNoScroll_=function(){var a=this.getBlockSpaceMetrics_();a&&(a="translate("+a.absoluteLeft+","+a.absoluteTop+")",this.blockSpace.getCanvas().setAttribute("transform",a),this.blockSpace.getDragCanvas().setAttribute("transform",a),this.blockSpace.getBubbleCanvas().setAttribute("transform",a))};
  Blockly.BlockSpaceEditor.prototype.addChangeListener=function(a){return Blockly.bindEvent_(this.blockSpace.getCanvas(),"blocklyBlockSpaceChange",this,a)};Blockly.BlockSpaceEditor.prototype.isReadOnly=function(){return Blockly.readOnly||this.readOnly_};Blockly.removeChangeListener=function(a){Blockly.unbindEvent_(a)};Blockly.FunctionEditor=function(){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};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.prototype.definitionBlockType="procedures_defnoreturn";Blockly.FunctionEditor.prototype.parameterBlockType="parameters_get";Blockly.FunctionEditor.prototype.autoOpenFunction=function(a){this.autoOpenWithLevelConfiguration({autoOpenFunction:a})};
  Blockly.FunctionEditor.prototype.autoOpenWithLevelConfiguration=function(a){a.autoOpenFunction&&this.openAndEditFunction(a.autoOpenFunction)};Blockly.FunctionEditor.prototype.openEditorForCallBlock_=function(a){var b=a.getTitleValue("NAME");a.blockSpace.blockSpaceEditor.hideChaff();this.hideIfOpen();this.openAndEditFunction(b)};
  Blockly.FunctionEditor.prototype.openAndEditFunction=function(a){var b=Blockly.mainBlockSpace.findFunction(a);if(!b)throw Error("Can't find definition block to edit");this.show();this.setupUIForBlock_(b);this.functionDefinitionBlock=this.moveToModalBlockSpace(b);this.functionDefinitionBlock.setMovable(!1);this.functionDefinitionBlock.setDeletable(!1);this.functionDefinitionBlock.setEditable(!1);this.populateParamToolbox_();this.setupUIAfterBlockInEditor_();goog.dom.getElement("functionNameText").value=
  a;goog.dom.getElement("functionDescriptionText").value=this.functionDefinitionBlock.description_||"";this.deleteButton_.setVisible(b.userCreated);Blockly.fireUiEvent(window,"function_editor_opened")};Blockly.FunctionEditor.prototype.setupUIForBlock_=function(a){};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 a=this.functionDefinitionBlock.getProcedureInfo(),b=0;b<a.parameterNames.length;b++)this.addParameter(a.parameterNames[b])};Blockly.FunctionEditor.prototype.getParamNameType=function(a){var b=this.orderedParamIDsToBlocks_.get(a);if(!b)throw"Block not found for ID "+a;return this.paramNameTypeFromXML_(b)};
  Blockly.FunctionEditor.prototype.paramNameTypeFromXML_=function(a){var b={};b.name=a.firstElementChild.textContent;b.type=a.childNodes[1].textContent;return b};Blockly.FunctionEditor.prototype.openWithNewFunction=function(){this.ensureCreated_();var a=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:this.definitionBlockType}));a.userCreated=!0;this.openAndEditFunction(a.getTitleValue("NAME"))};
  Blockly.FunctionEditor.prototype.bindToolboxHandlers_=function(){var a=goog.dom.getElement("paramAddText"),b=goog.dom.getElement("paramAddButton");Blockly.disableParamEditing||(Blockly.bindEvent_(b,"click",this,goog.bind(this.addParamFromInputField_,this,a)),Blockly.bindEvent_(a,"keydown",this,function(b){b.keyCode===goog.events.KeyCodes.ENTER&&this.addParamFromInputField_(a)}))};Blockly.FunctionEditor.prototype.addParamFromInputField_=function(a){var b=a.value;a.value="";this.addParameter(b);this.refreshParamsEverywhere()};
  Blockly.FunctionEditor.prototype.addParameter=function(a){this.orderedParamIDsToBlocks_.set(goog.events.getUniqueId("parameter"),this.newParameterBlock(a))};Blockly.FunctionEditor.prototype.newParameterBlock=function(a){var b=Blockly.createSvgElement("block",{type:this.parameterBlockType});Blockly.createSvgElement("title",{name:"VAR"},b).textContent=a;return b};
  Blockly.FunctionEditor.prototype.renameParameter=function(a,b){this.orderedParamIDsToBlocks_.forEach(function(c,d,e){c.firstElementChild&&c.firstElementChild.textContent===a&&(c.firstElementChild.textContent=b)});this.forEachParameterGetBlock(a,function(a){a.setTitleValue(b,"VAR")})};
  Blockly.FunctionEditor.prototype.changeParameterTypeInFlyoutXML=function(a,b){this.orderedParamIDsToBlocks_.forEach(function(c,d,e){c.firstElementChild&&c.firstElementChild.textContent===a&&(c.childNodes[1].firstElementChild.textContent=b)})};
  Blockly.FunctionEditor.prototype.removeParameter=function(a){var b=[];this.orderedParamIDsToBlocks_.forEach(function(c,d){c.firstElementChild&&c.firstElementChild.textContent===a&&b.push(d)});b.forEach(function(a){this.orderedParamIDsToBlocks_.remove(a)},this);this.forEachParameterGetBlock(a,function(a){a.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 a=this.paramsAsParallelArrays_();a.paramIDs=null;this.functionDefinitionBlock.updateParamsFromArrays(a.paramNames,a.paramIDs,a.paramTypes)};
  Blockly.FunctionEditor.prototype.refreshParamsOnFunction_=function(){var a=this.paramsAsParallelArrays_();this.functionDefinitionBlock.updateParamsFromArrays(a.paramNames,a.paramIDs,a.paramTypes)};Blockly.FunctionEditor.prototype.paramsAsParallelArrays_=function(){var a=[],b=[],c=[];this.orderedParamIDsToBlocks_.forEach(function(d,e){a.push(d.firstElementChild.textContent);b.push(e);1<d.childNodes.length&&c.push(d.childNodes[1].textContent)},this);return{paramNames:a,paramIDs:b,paramTypes:c}};
  Blockly.FunctionEditor.prototype.forEachParameterGetBlock=function(a,b){this.functionDefinitionBlock&&this.functionDefinitionBlock.getDescendants().forEach(function(c){"parameters_get"==c.type&&Blockly.Names.equals(a,c.getTitleValue("VAR"))&&b(c)})};
  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 a=this.functionDefinitionBlock;this.functionDefinitionBlock=null;this.moveToMainBlockSpace_(a);goog.dom.getElement("functionNameText").value="";goog.dom.getElement("functionDescriptionText").value="";goog.dom.getElement("paramAddText")&&(goog.dom.getElement("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(a){a.setMovable(!0);a.setDeletable(!0);var b=Blockly.Xml.blockToDom(a);a.dispose(!1,!1,!0);Blockly.Xml.domToBlock(Blockly.mainBlockSpace,b).setCurrentlyHidden(!0)};
  Blockly.FunctionEditor.prototype.moveToModalBlockSpace=function(a){var b=Blockly.Xml.blockToDom(a);a.dispose(!1,!1,!0);a=Blockly.Xml.domToBlock(this.modalBlockSpace,b);a.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);a.setCurrentlyHidden(!1);a.setUserVisible(!0,!0);return a};
  Blockly.FunctionEditor.prototype.create_=function(){function a(a){a=a.target.value;var b=/\)|\(/g;b.test(a)&&(a=a.replace(b,""),goog.dom.getElement("functionNameText").value=a);this.functionDefinitionBlock.setTitleValue(a,"NAME")}function b(a){this.functionDefinitionBlock.description_=a.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 c=this;this.modalBlockSpaceEditor=new Blockly.BlockSpaceEditor(this.container_,function(){var a=Blockly.BlockSpaceEditor.prototype.getBlockSpaceMetrics_.call(this);if(!a)return null;a.absoluteLeft+=FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH+1;a.absoluteTop+=c.getBlockSpaceEditorToScreenTop_();a.viewWidth-=2*(FRAME_MARGIN_SIDE+Blockly.Bubble.BORDER_WIDTH);a.viewHeight-=FRAME_MARGIN_TOP+
  Blockly.Bubble.BORDER_WIDTH+c.getWindowBorderChromeHeight();return a},function(a){Blockly.BlockSpaceEditor.prototype.setBlockSpaceMetrics_.call(this,a);c.contractDiv_&&(c.resizeUIComponents_(),c.layOutBlockSpaceItems_())},!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 d=Blockly.createSvgElement("clipPath",{id:"modalBlockCanvasClipRect"});this.modalBlockSpaceEditor.addToSvgDefs(d);this.modalBlockSpace.getClippingGroup().setAttribute("clip-path","url(#modalBlockCanvasClipRect)");this.clipPathRect_=Blockly.createSvgElement("rect",{x:0,y:0,width:1,height:1},d);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_(goog.dom.getElement("modalContainer"),"mousedown",this,function(a){a.target===a.currentTarget&&(this.modalBlockSpaceEditor.hideChaff(),Blockly.selected&&
  Blockly.selected.unselect())});Blockly.bindEvent_(goog.dom.getDocument().body,"keyup",this,function(a){if(a.keyCode===goog.events.KeyCodes.ESC)this.onClose()});Blockly.bindEvent_(goog.dom.getElement("modalEditorClose"),"mousedown",this,this.onClose);Blockly.bindEvent_(goog.dom.getElement("functionNameText"),"input",this,a);Blockly.bindEvent_(goog.dom.getElement("functionNameText"),"keydown",this,a);Blockly.bindEvent_(this.contractDiv_,"mousedown",null,function(){Blockly.selected&&Blockly.selected.unselect()});
  Blockly.bindEvent_(goog.dom.getElement("functionDescriptionText"),"input",this,b);Blockly.bindEvent_(goog.dom.getElement("functionDescriptionText"),"keydown",this,b);this.onResizeWrapper_=Blockly.bindEvent_(window,goog.events.EventType.RESIZE,this,this.position_);this.modalBlockSpaceEditor.svgResize()};
  Blockly.FunctionEditor.prototype.resizeUIComponents_=function(){var a=this.modalBlockSpace.getMetrics();this.resizeFrame_(a.viewWidth,a.viewHeight);this.positionClippingRects_(a);this.positionSizeContractDom_(a.viewWidth);this.positionCloseButton_(a.absoluteLeft,a.viewWidth);this.positionDeleteButton_(a.absoluteLeft,a.viewWidth)};
  Blockly.FunctionEditor.prototype.resizeFrame_=function(a,b){this.frameBase_.setAttribute("width",a+2*Blockly.Bubble.BORDER_WIDTH);this.frameBase_.setAttribute("height",b+2*Blockly.Bubble.BORDER_WIDTH+FRAME_HEADER_HEIGHT);this.frameInner_.setAttribute("width",a);this.frameInner_.setAttribute("height",b);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",a-2*FRAME_MARGIN_SIDE))};
  Blockly.FunctionEditor.prototype.positionClippingRects_=function(a){var b=a.viewWidth,c=a.viewHeight;this.clipPathRect_.setAttribute("x",a.absoluteLeft);this.clipPathRect_.setAttribute("y",a.absoluteTop);this.clipPathRect_.setAttribute("width",b);this.clipPathRect_.setAttribute("height",c);this.frameClipDiv_.style.left=a.absoluteLeft+"px";this.frameClipDiv_.style.top=a.absoluteTop+"px";this.frameClipDiv_.style.width=b+"px";this.frameClipDiv_.style.height=c+"px"};
  Blockly.FunctionEditor.prototype.positionSizeContractDom_=function(a){this.contractDiv_.style.left=this.modalBlockSpace.xOffsetFromView+"px";this.contractDiv_.style.top=this.getContractDomTopY_()+"px";this.contractDiv_.style.width=a+"px";this.positionFlyout_(0)};
  Blockly.FunctionEditor.prototype.positionCloseButton_=function(a,b){this.closeButton_.setAttribute("transform","translate("+(Blockly.RTL?Blockly.FunctionEditor.RTL_CLOSE_BUTTON_OFFSET:a+b+Blockly.FunctionEditor.CLOSE_BUTTON_OVERHANG-this.closeButton_.firstElementChild.getAttribute("width"))+",19)")};
  Blockly.FunctionEditor.prototype.positionDeleteButton_=function(a,b){var c=this.closeButton_.firstElementChild.getAttribute("width"),d=this.deleteButton_.getButtonWidth(),d=a+b+(Blockly.FunctionEditor.CLOSE_BUTTON_OVERHANG-c)-d-Blockly.FunctionEditor.DELETE_BUTTON_MARGIN,c=Blockly.FunctionEditor.RTL_CLOSE_BUTTON_OFFSET+c+Blockly.FunctionEditor.DELETE_BUTTON_MARGIN;this.deleteButton_.renderAt(Blockly.RTL?c:d,19)};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(a){a+=this.flyout_.getHeight();this.flyout_.customYOffset=a+this.modalBlockSpace.yOffsetFromView;this.flyout_.position_();return a};
  Blockly.FunctionEditor.prototype.layOutBlockSpaceItems_=function(){if(this.readyToBeLaidOut_()){var a=Blockly.RTL?this.modalBlockSpace.getMetrics().viewWidth-Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN:Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,b=this.getContractDivHeight(),b=this.positionFlyout_(b),b=b+Blockly.FunctionEditor.BLOCK_LAYOUT_TOP_MARGIN;this.functionDefinitionBlock.moveTo(a,b)}};
  Blockly.FunctionEditor.prototype.addCloseButton_=function(){this.closeButton_=Blockly.createSvgElement("g",{id:"modalEditorClose",filter:"url(#blocklyTrashcanShadowFilter)"});var a=Blockly.createSvgElement("rect",{rx:12,ry:12,fill:"#7665a0",stroke:"white","stroke-width":"2.5"},this.closeButton_),b=Blockly.createSvgElement("text",{x:7,y:7,"class":"blocklyText"},this.closeButton_);b.textContent=Blockly.Msg.CLOSE;this.modalBlockSpaceEditor.appendSVGChild(this.closeButton_);b=b.getBoundingClientRect();
  a.setAttribute("width",b.width+14);a.setAttribute("height",b.height+7);a.setAttribute("y",-b.height+7-1)};Blockly.FunctionEditor.prototype.addDeleteButton_=function(){this.deleteButton_=new Blockly.SvgTextButton(this.modalBlockSpaceEditor.getSVGElement(),Blockly.Msg.DELETE,this.onDeletePressed.bind(this))};
  Blockly.FunctionEditor.prototype.onDeletePressed=function(){var a=this.functionDefinitionBlock.getProcedureInfo().name,b=Blockly.Msg.CONFIRM_DELETE_FUNCTION_MESSAGE.replace("%1",a);Blockly.showSimpleDialog({bodyText:b,cancelText:Blockly.Msg.DELETE,confirmText:Blockly.Msg.KEEP,onConfirm:null,onCancel:this.onDeleteConfirmed.bind(this,a),cancelButtonClass:"red-delete-button"})};
  Blockly.FunctionEditor.prototype.onDeleteConfirmed=function(a){this.hideIfOpen();var b=Blockly.mainBlockSpace.findFunction(a);Blockly.mainBlockSpace.findFunctionExamples(a).concat(b).forEach(function(a){a.dispose(!1,!1,!0)})};
  Blockly.FunctionEditor.prototype.setupParametersToolbox_=function(){this.flyout_=new Blockly.HorizontalFlyout(this.modalBlockSpaceEditor);var a=this.flyout_.createDom();this.modalBlockSpace.getClippingGroup().insertBefore(a,this.modalBlockSpace.svgBlockCanvas_);this.flyout_.init(this.modalBlockSpace,!1)};
  Blockly.FunctionEditor.prototype.addEditorFrame_=function(){var a=this.modalBlockSpace.isReadOnly()?0:Blockly.hasCategories?goog.dom.getElementByClass("blocklyToolboxDiv").getBoundingClientRect().width:goog.dom.getElementByClass("blocklyFlyoutBackground").getBoundingClientRect().width;this.frameBase_=Blockly.createSvgElement("rect",{x:a+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:a+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:a+FRAME_MARGIN_SIDE+16,y:0+FRAME_MARGIN_TOP+22,"class":"blocklyText",style:"font-size: 12pt"},this.modalBackground_);this.frameText_.textContent=Blockly.Msg.FUNCTION_HEADER};
  Blockly.FunctionEditor.prototype.position_=function(){if(this.isOpen()){var a=this.modalBlockSpace.getMetrics();this.resizeFrame_(a.viewWidth,a.viewHeight);this.positionSizeContractDom_(a.viewWidth);this.layOutBlockSpaceItems_();this.modalBlockSpaceEditor.svgResize()}};Blockly.FunctionEditor.prototype.getContractDomTopY_=function(){return this.modalBlockSpace.yOffsetFromView};
  Blockly.FunctionEditor.prototype.createParameterEditor_=function(){Blockly.disableParamEditing||(goog.dom.getElement("paramEditingArea").innerHTML="<div>"+Blockly.Msg.FUNCTION_PARAMETERS_LABEL+'</div><div><input id="paramAddText" type="text" style="width: 200px;"/> <button id="paramAddButton" class="btn">'+Blockly.Msg.ADD_PARAMETER+"</button></div>")};
  Blockly.FunctionEditor.prototype.createFrameClipDiv_=function(){var a=goog.dom.createDom("div");a.style.position="absolute";a.style.overflow="hidden";a.style.pointerEvents="none";return a};
  Blockly.FunctionEditor.prototype.createContractDom_=function(){this.contractDiv_=goog.dom.createDom("div","blocklyToolboxDiv paramToolbox blocklyText flyoutColorGray innerModalDiv");Blockly.RTL&&this.contractDiv_.setAttribute("dir","RTL");this.contractDiv_.innerHTML="<div>"+Blockly.Msg.FUNCTION_NAME_LABEL+'</div><div><input id="functionNameText" type="text"></div><div>'+Blockly.Msg.FUNCTION_DESCRIPTION_LABEL+'</div><div><textarea id="functionDescriptionText" rows="2"></textarea></div><div style="margin: 0;" id="paramEditingArea"></div>';
  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)};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(a){var b={};a=String(a);var c=goog.color.prependHashIfNecessaryHelper(a);if(goog.color.isValidHexColor_(c))return b.hex=goog.color.normalizeHex(c),b.type="hex",b;c=goog.color.isValidRgbColor_(a);if(c.length)return b.hex=goog.color.rgbArrayToHex(c),b.type="rgb",b;if(goog.color.names&&(c=goog.color.names[a.toLowerCase()]))return b.hex=c,b.type="named",b;throw Error(a+" is not a valid color string");};
  goog.color.isValidColor=function(a){var b=goog.color.prependHashIfNecessaryHelper(a);return!!(goog.color.isValidHexColor_(b)||goog.color.isValidRgbColor_(a).length||goog.color.names&&goog.color.names[a.toLowerCase()])};goog.color.parseRgb=function(a){var b=goog.color.isValidRgbColor_(a);if(!b.length)throw Error(a+" is not a valid RGB color");return b};goog.color.hexToRgbStyle=function(a){return goog.color.rgbStyle_(goog.color.hexToRgb(a))};goog.color.hexTripletRe_=/#(.)(.)(.)/;
  goog.color.normalizeHex=function(a){if(!goog.color.isValidHexColor_(a))throw Error("'"+a+"' is not a valid hex color");4==a.length&&(a=a.replace(goog.color.hexTripletRe_,"#$1$1$2$2$3$3"));return a.toLowerCase()};goog.color.hexToRgb=function(a){a=goog.color.normalizeHex(a);var b=parseInt(a.substr(1,2),16),c=parseInt(a.substr(3,2),16);a=parseInt(a.substr(5,2),16);return[b,c,a]};
  goog.color.rgbToHex=function(a,b,c){a=Number(a);b=Number(b);c=Number(c);if(isNaN(a)||0>a||255<a||isNaN(b)||0>b||255<b||isNaN(c)||0>c||255<c)throw Error('"('+a+","+b+","+c+'") is not a valid RGB color');a=goog.color.prependZeroIfNecessaryHelper(a.toString(16));b=goog.color.prependZeroIfNecessaryHelper(b.toString(16));c=goog.color.prependZeroIfNecessaryHelper(c.toString(16));return"#"+a+b+c};goog.color.rgbArrayToHex=function(a){return goog.color.rgbToHex(a[0],a[1],a[2])};
  goog.color.rgbToHsl=function(a,b,c){a/=255;b/=255;c/=255;var d=Math.max(a,b,c),e=Math.min(a,b,c),f=0,g=0,h=0.5*(d+e);d!=e&&(d==a?f=60*(b-c)/(d-e):d==b?f=60*(c-a)/(d-e)+120:d==c&&(f=60*(a-b)/(d-e)+240),g=0<h&&0.5>=h?(d-e)/(2*h):(d-e)/(2-2*h));return[Math.round(f+360)%360,g,h]};goog.color.rgbArrayToHsl=function(a){return goog.color.rgbToHsl(a[0],a[1],a[2])};goog.color.hueToRgb_=function(a,b,c){0>c?c+=1:1<c&&(c-=1);return 1>6*c?a+6*(b-a)*c:1>2*c?b:2>3*c?a+6*(b-a)*(2/3-c):a};
  goog.color.hslToRgb=function(a,b,c){var d=0,e=0,f=0;a/=360;if(0==b)d=e=f=255*c;else var g=f=0,g=0.5>c?c*(1+b):c+b-b*c,f=2*c-g,d=255*goog.color.hueToRgb_(f,g,a+1/3),e=255*goog.color.hueToRgb_(f,g,a),f=255*goog.color.hueToRgb_(f,g,a-1/3);return[Math.round(d),Math.round(e),Math.round(f)]};goog.color.hslArrayToRgb=function(a){return goog.color.hslToRgb(a[0],a[1],a[2])};goog.color.validHexColorRe_=/^#(?:[0-9a-f]{3}){1,2}$/i;goog.color.isValidHexColor_=function(a){return goog.color.validHexColorRe_.test(a)};
  goog.color.normalizedHexColorRe_=/^#[0-9a-f]{6}$/;goog.color.isNormalizedHexColor_=function(a){return goog.color.normalizedHexColorRe_.test(a)};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(a){var b=a.match(goog.color.rgbColorRe_);if(b){a=Number(b[1]);var c=Number(b[2]),b=Number(b[3]);if(0<=a&&255>=a&&0<=c&&255>=c&&0<=b&&255>=b)return[a,c,b]}return[]};
  goog.color.prependZeroIfNecessaryHelper=function(a){return 1==a.length?"0"+a:a};goog.color.prependHashIfNecessaryHelper=function(a){return"#"==a.charAt(0)?a:"#"+a};goog.color.rgbStyle_=function(a){return"rgb("+a.join(",")+")"};
  goog.color.hsvToRgb=function(a,b,c){var d=0,e=0,f=0;if(0==b)f=e=d=c;else{var g=Math.floor(a/60),h=a/60-g;a=c*(1-b);var k=c*(1-b*h);b=c*(1-b*(1-h));switch(g){case 1:d=k;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=k;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=k;break;case 6:case 0:d=c,e=b,f=a}}return[Math.floor(d),Math.floor(e),Math.floor(f)]};
  goog.color.rgbToHsv=function(a,b,c){var d=Math.max(Math.max(a,b),c),e=Math.min(Math.min(a,b),c);if(e==d)e=a=0;else{var f=d-e,e=f/d;a=60*(a==d?(b-c)/f:b==d?2+(c-a)/f:4+(a-b)/f);0>a&&(a+=360);360<a&&(a-=360)}return[a,e,d]};goog.color.rgbArrayToHsv=function(a){return goog.color.rgbToHsv(a[0],a[1],a[2])};goog.color.hsvArrayToRgb=function(a){return goog.color.hsvToRgb(a[0],a[1],a[2])};goog.color.hexToHsl=function(a){a=goog.color.hexToRgb(a);return goog.color.rgbToHsl(a[0],a[1],a[2])};
  goog.color.hslToHex=function(a,b,c){return goog.color.rgbArrayToHex(goog.color.hslToRgb(a,b,c))};goog.color.hslArrayToHex=function(a){return goog.color.rgbArrayToHex(goog.color.hslToRgb(a[0],a[1],a[2]))};goog.color.hexToHsv=function(a){return goog.color.rgbArrayToHsv(goog.color.hexToRgb(a))};goog.color.hsvToHex=function(a,b,c){return goog.color.rgbArrayToHex(goog.color.hsvToRgb(a,b,c))};goog.color.hsvArrayToHex=function(a){return goog.color.hsvToHex(a[0],a[1],a[2])};
  goog.color.hslDistance=function(a,b){var c,d;c=0.5>=a[2]?a[1]*a[2]:a[1]*(1-a[2]);d=0.5>=b[2]?b[1]*b[2]:b[1]*(1-b[2]);return(a[2]-b[2])*(a[2]-b[2])+c*c+d*d-2*c*d*Math.cos(2*(a[0]/360-b[0]/360)*Math.PI)};goog.color.blend=function(a,b,c){c=goog.math.clamp(c,0,1);return[Math.round(c*a[0]+(1-c)*b[0]),Math.round(c*a[1]+(1-c)*b[1]),Math.round(c*a[2]+(1-c)*b[2])]};goog.color.darken=function(a,b){return goog.color.blend([0,0,0],a,b)};
  goog.color.lighten=function(a,b){return goog.color.blend([255,255,255],a,b)};goog.color.highContrast=function(a,b){for(var c=[],d=0;d<b.length;d++)c.push({color:b[d],diff:goog.color.yiqBrightnessDiff_(b[d],a)+goog.color.colorDiff_(b[d],a)});c.sort(function(a,b){return b.diff-a.diff});return c[0].color};goog.color.yiqBrightness_=function(a){return Math.round((299*a[0]+587*a[1]+114*a[2])/1E3)};goog.color.yiqBrightnessDiff_=function(a,b){return Math.abs(goog.color.yiqBrightness_(a)-goog.color.yiqBrightness_(b))};
  goog.color.colorDiff_=function(a,b){return Math.abs(a[0]-b[0])+Math.abs(a[1]-b[1])+Math.abs(a[2]-b[2])};var FUNCTION_BLOCK_VERTICAL_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_TOP,FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN=Blockly.BlockSpaceEditor.BUMP_PADDING_LEFT;
  Blockly.ContractDefinitionSection=function(a){this.definitionTableGroup=Blockly.createSvgElement("g",{},a);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(a){this.definitionTableGroup.style.display=a?"none":"block"};
  Blockly.ContractDefinitionSection.prototype.placeContent=function(a,b,c,d){if(!d)return a;var e=a;d.isVariable()?this.definitionTableGroup.style.display="none":(this.definitionTableGroup.style.display="block",this.horizontalDefinitionTopLine.setAttribute("transform","translate(0,"+e+")"),this.verticalDefinitionMidline.setAttribute("transform","translate("+b+","+e+")"),this.grayDefinitionBackground.setAttribute("transform","translate(0,"+a+")"),this.horizontalDefinitionTopLine.setAttribute("width",
  c));a+=FUNCTION_BLOCK_VERTICAL_MARGIN;var f=d.isVariable()?FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN:FUNCTION_BLOCK_MIN_HORIZONTAL_MARGIN+b;d.moveTo(f,a);a+=d.getHeightWidth().height;a+=FUNCTION_BLOCK_VERTICAL_MARGIN;d.isVariable()||(this.horizontalDefinitionBottomLine.setAttribute("transform","translate(0,"+a+")"),this.horizontalDefinitionBottomLine.setAttribute("width",c),this.verticalDefinitionMidline.setAttribute("height",a-e),this.grayDefinitionBackground.setAttribute("height",a-e),this.grayDefinitionBackground.setAttribute("width",
  b));return a};Blockly.TypeDropdown=function(a){this.buttonColorSquareDiv_=this.selectComponent_=null;this.onTypeChanged_=a.onTypeChanged;this.typeChoices_=a.typeChoices;this.type_=a.type;this.changeListenerKey_=null};
  Blockly.TypeDropdown.prototype.render=function(a){a=this.renderSelectComponent_(a);this.buttonColorSquareDiv_=this.createColorSquareDiv();goog.dom.appendChild(a.getElement(),this.buttonColorSquareDiv_);this.setSquareIconColor(this.type_,this.buttonColorSquareDiv_);this.attachListeners_(a);this.selectComponent_=a;this.setType_(this.type_)};Blockly.TypeDropdown.prototype.setType_=function(a){this.type_=a;this.setSquareIconColor(this.type_,this.buttonColorSquareDiv_)};
  Blockly.TypeDropdown.prototype.renderSelectComponent_=function(a){var b=this.createSelect_();b.render(a);return b};
  Blockly.TypeDropdown.prototype.createSelect_=function(){var a=new goog.ui.Select(null,null,goog.ui.FlatMenuButtonRenderer.getInstance(),null,new Blockly.CustomCssClassMenuRenderer("colored-type-dropdown"));this.typeChoices_.forEach(function(b){var c=new goog.ui.MenuItem(b);a.addItem(c);var d=this.createColorSquareDiv();goog.dom.insertChildAt(c.getElement(),d,0);this.setSquareIconColor(b,d)},this);a.setValue(this.type_);return a};
  Blockly.TypeDropdown.prototype.createColorSquareDiv=function(){return goog.dom.createDom("div","color-square-icon")};Blockly.TypeDropdown.prototype.attachListeners_=function(a){this.changeListenerKey_=goog.events.listen(a,goog.ui.Component.EventType.CHANGE,goog.bind(this.selectChanged_,this))};Blockly.TypeDropdown.prototype.selectChanged_=function(a){a=a.target.getContent();this.setType_(a);this.onTypeChanged_(a)};
  Blockly.TypeDropdown.prototype.setSquareIconColor=function(a,b){var c=Blockly.FunctionalTypeColors[a],c=goog.color.hsvToHex(c[0],c[1],255*c[2]);b.style.background=c};Blockly.TypeDropdown.prototype.dispose=function(){goog.events.unlistenByKey(this.changeListenerKey_);this.selectComponent_.dispose()};var TEXT_PADDING_LEFT="10",SEPARATOR_LINE_HEIGHT=2;
  Blockly.SvgHeader=function(a,b){var c=b||{backgroundColor:"#000",headerText:"Default Header"},d=c.onMouseDown?"":"pointer-events: none;";this.svgGroup_=Blockly.createSvgElement("g",{style:d},a,{belowExisting:!0});this.rectangleElement_=Blockly.createSvgElement("rect",{fill:c.backgroundColor,style:d},this.svgGroup_);this.separatorElement_=Blockly.createSvgElement("rect",{fill:"#FFF",style:d+"opacity:.3;"},this.svgGroup_);this.textElement_=Blockly.createSvgElement("text",{"class":"contractEditorHeaderText",
  style:d},this.svgGroup_);c.headerText&&(this.textElement_.textContent=c.headerText);c.onMouseDown&&Blockly.bindEvent_(this.svgGroup_,"click",null,c.onMouseDown)};Blockly.SvgHeader.prototype.showSeparator=function(a){goog.style.setElementShown(this.separatorElement_,a)};Blockly.SvgHeader.prototype.setColor=function(a){this.rectangleElement_.setAttribute("fill",a)};
  Blockly.SvgHeader.prototype.setPositionSize=function(a,b,c){this.svgGroup_.setAttribute("transform","translate(0,"+a+")");this.rectangleElement_.setAttribute("width",b+2);this.separatorElement_.setAttribute("width",b);this.separatorElement_.setAttribute("height",SEPARATOR_LINE_HEIGHT);this.separatorElement_.setAttribute("transform","translate(0,"+(c-1)+")");this.rectangleElement_.setAttribute("height",c);this.textElement_.setAttribute("x",TEXT_PADDING_LEFT);a=c/2;b=this.textElement_.getBBox().height/
  3;this.textElement_.setAttribute("y",a+b)};Blockly.SvgHeader.prototype.setText=function(a){this.textElement_.textContent=a};Blockly.SvgHeader.prototype.setVisible=function(a){goog.style.setElementShown(this.svgGroup_,a)};Blockly.SvgHeader.prototype.removeSelf=function(){goog.dom.removeNode(this.svgGroup_)};var NO_RESULT_TEXT="",SUCCESS_TEXT="Matches definition.",RESULT_TEXT_TOP_MARGIN=14,EMPTY_EXAMPLE_INPUT_WIDTH=40;
  Blockly.ExampleView=function(a,b,c){this.domParent_=a;this.svgParent_=b;this.contractEditor_=c;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.innerHTML=NO_RESULT_TEXT;goog.dom.append(this.domParent_,
  this.resultText);this.refreshTestingUI(!1)};Blockly.ExampleView.prototype.initializeTestButton_=function(a,b,c){var d=goog.dom.createDom("button","testButton launch blocklyLaunch exampleAreaButton"),e=goog.dom.createDom("div");e.innerHTML=a;a=goog.dom.createDom("img",b);a.setAttribute("src",Blockly.assetUrl("media/1x1.gif"));goog.dom.append(d,a);goog.dom.append(d,e);Blockly.bindEvent_(d,"click",null,c);return d};Blockly.ExampleView.prototype.getBlock=function(){return this.block_};
  Blockly.ExampleView.prototype.testExample_=function(){this.contractEditor_.resetExampleViews();var a=this.contractEditor_.testExample(this.block_,!0);this.setResult(a||SUCCESS_TEXT);this.refreshTestingUI(!0)};Blockly.ExampleView.prototype.reset=function(){goog.style.isElementShown(this.resetExampleButton)&&(this.contractEditor_.resetExample(this.block_),this.resultText.innerHTML=NO_RESULT_TEXT,this.refreshTestingUI(!1))};
  Blockly.ExampleView.prototype.setResult=function(a){this.resultText.innerHTML=a||SUCCESS_TEXT;this.refreshTestingUI(!1)};Blockly.ExampleView.prototype.refreshTestingUI=function(a){goog.style.setElementShown(this.resultText,Blockly.showExampleTestButtons);goog.style.setElementShown(this.testExampleButton,Blockly.showExampleTestButtons&&!a);goog.style.setElementShown(this.resetExampleButton,Blockly.showExampleTestButtons&&a)};
  Blockly.ExampleView.prototype.placeExampleAndGetNewY=function(a,b,c,d,e,f,g,h){this.block_=a;var k=b;e/=2;k+=e;if(!a.isCurrentlyBeingDragged()){var l=a.getInput(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);if(l.type===Blockly.FUNCTIONAL_INPUT){var m=l.extraSpace,n=EMPTY_EXAMPLE_INPUT_WIDTH,p=a.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);p&&(n=p.getHeightWidth().width);l.extraSpace=c-n;l.extraSpace!==m&&a.getSvgRenderer().render(!0)}a.moveTo(d,k)}var k=k+
  a.getHeightWidth().height,k=k+e,q=g+e;[this.testExampleButton,this.resetExampleButton].forEach(function(a){a.style.top=k-h+"px";a.style.left=q+"px"});a=Math.max(this.resetExampleButton.offsetWidth,this.testExampleButton.offsetWidth);c=Math.max(this.resetExampleButton.offsetHeight,this.testExampleButton.offsetHeight);this.resultText.style.top=k+RESULT_TEXT_TOP_MARGIN-h+"px";this.resultText.style.left=e+(q+a)+"px";k+=c;k+=e;this.horizontalLine.setAttribute("transform","translate(0,"+k+")");this.horizontalLine.setAttribute("width",
  f);this.grayBackdrop.setAttribute("transform","translate(0,"+b+")");this.grayBackdrop.setAttribute("width",g);this.grayBackdrop.setAttribute("height",k-b);return k};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)};goog.ui.Option=function(a,b,c){goog.ui.MenuItem.call(this,a,b,c);this.setSelectable(!0)};goog.inherits(goog.ui.Option,goog.ui.MenuItem);goog.ui.Option.prototype.performActionInternal=function(a){return this.dispatchEvent(goog.ui.Component.EventType.ACTION)};goog.ui.registry.setDecoratorByClassName("goog-option",function(){return new goog.ui.Option(null)});Blockly.XButton=function(a){this.onButtonPressed=a.onButtonPressed;this.eventsToUnbind_=[];this.buttonElement_=null};Blockly.XButton.prototype.render=function(a){var b=goog.dom.createDom("button");b.className="btn";b.innerHTML="Remove";b.style.marginRight="-10px";a.appendChild(b);this.eventsToUnbind_.push(Blockly.bindEvent_(b,"click",this,goog.bind(function(){if(this.onButtonPressed)this.onButtonPressed()},this)));this.buttonElement_=b};
  Blockly.XButton.prototype.dispose=function(){this.eventsToUnbind_.forEach(function(a){Blockly.unbindEvent_(a)});goog.array.clear(this.eventsToUnbind_);goog.dom.removeNode(this.buttonElement_)};Blockly.DomainNameInput=function(a){this.onNameChanged=a.onNameChanged;this.onEnterPressed=a.onEnterPressed;this.name=a.name;this.eventsToUnbind_=[];this.inputElement_=null};
  Blockly.DomainNameInput.prototype.render=function(a){var b=goog.dom.createDom("input");b.type="text";b.style.width="200px";b.style.placeholder=Blockly.Msg.FUNCTIONAL_NAME_LABEL;this.name&&(b.value=this.name);a.appendChild(b);this.eventsToUnbind_.push(Blockly.bindEvent_(b,"input",this,this.onInputChange_));this.eventsToUnbind_.push(Blockly.bindEvent_(b,"keydown",this,this.onInputChange_));this.inputElement_=b};Blockly.DomainNameInput.prototype.onInputChange_=function(a){if(this.onNameChanged)this.onNameChanged(a.target.value)};
  Blockly.DomainNameInput.prototype.dispose=function(){this.eventsToUnbind_.forEach(function(a){Blockly.unbindEvent_(a)});goog.array.clear(this.eventsToUnbind_);goog.dom.removeNode(this.inputElement_)};Blockly.DomainEditor=function(a){this.options=a;this.nameInput_=this.typeDropdown_=this.editorDom_=null};Blockly.DomainEditor.prototype.getParamID=function(){return this.options.paramID};
  Blockly.DomainEditor.prototype.render=function(a){var b=goog.dom.createDom("div"),c=new Blockly.TypeDropdown({onTypeChanged:this.options.onTypeChanged,typeChoices:this.options.typeChoices,type:this.options.type}),d=new Blockly.DomainNameInput({onNameChanged:this.options.onNameChanged,name:this.options.name}),e=new Blockly.XButton({onButtonPressed:this.options.onRemovePress});d.render(b);c.render(b);e.render(b);a.appendChild(b);this.editorDom_=b;this.typeDropdown_=c;this.nameInput_=d};
  Blockly.DomainEditor.prototype.dispose=function(){this.nameInput_.dispose();this.typeDropdown_.dispose();goog.dom.removeNode(this.editorDom_)};goog.style.bidi={};goog.style.bidi.getScrollLeft=function(a){var b=goog.style.isRightToLeft(a);return b&&goog.userAgent.GECKO?-a.scrollLeft:!b||goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("8")||"visible"==goog.style.getComputedOverflowX(a)?a.scrollLeft:a.scrollWidth-a.clientWidth-a.scrollLeft};
  goog.style.bidi.getOffsetStart=function(a){var b=a.offsetLeft,c=a.offsetParent;c||"fixed"!=goog.style.getComputedPosition(a)||(c=goog.dom.getOwnerDocument(a).documentElement);if(!c)return b;if(goog.userAgent.GECKO)var d=goog.style.getBorderBox(c),b=b+d.left;else goog.userAgent.isDocumentModeOrHigher(8)&&(d=goog.style.getBorderBox(c),b-=d.left);return goog.style.isRightToLeft(c)?c.clientWidth-(b+a.offsetWidth):b};
  goog.style.bidi.setScrollOffset=function(a,b){b=Math.max(b,0);goog.style.isRightToLeft(a)?goog.userAgent.GECKO?a.scrollLeft=-b:goog.userAgent.IE&&goog.userAgent.isVersionOrHigher("8")?a.scrollLeft=b:a.scrollLeft=a.scrollWidth-b-a.clientWidth:a.scrollLeft=b};goog.style.bidi.setPosition=function(a,b,c,d){goog.isNull(c)||(a.style.top=c+"px");d?(a.style.right=b+"px",a.style.left=""):(a.style.left=b+"px",a.style.right="")};goog.positioning={};goog.positioning.Corner={TOP_LEFT:0,TOP_RIGHT:2,BOTTOM_LEFT:1,BOTTOM_RIGHT:3,TOP_START:4,TOP_END:6,BOTTOM_START:5,BOTTOM_END:7};goog.positioning.CornerBit={BOTTOM:1,RIGHT:2,FLIP_RTL:4};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(a,b,c,d,e,f,g,h,k){goog.asserts.assert(c);var l=goog.positioning.getOffsetParentPageOffset(c),m=goog.positioning.getVisiblePart_(a);goog.style.translateRectForAnotherFrame(m,goog.dom.getDomHelper(a),goog.dom.getDomHelper(c));a=goog.positioning.getEffectiveCorner(a,b);m=new goog.math.Coordinate(a&goog.positioning.CornerBit.RIGHT?m.left+m.width:m.left,a&goog.positioning.CornerBit.BOTTOM?m.top+m.height:m.top);m=goog.math.Coordinate.difference(m,l);e&&(m.x+=
  (a&goog.positioning.CornerBit.RIGHT?-1:1)*e.x,m.y+=(a&goog.positioning.CornerBit.BOTTOM?-1:1)*e.y);var n;if(g)if(k)n=k;else if(n=goog.style.getVisibleRectForElement(c))n.top-=l.y,n.right-=l.x,n.bottom-=l.y,n.left-=l.x;return goog.positioning.positionAtCoordinate(m,c,d,f,n,g,h)};
  goog.positioning.getOffsetParentPageOffset=function(a){var b;if(a=a.offsetParent){var c=a.tagName==goog.dom.TagName.HTML||a.tagName==goog.dom.TagName.BODY;c&&"static"==goog.style.getComputedPosition(a)||(b=goog.style.getPageOffset(a),c||(b=goog.math.Coordinate.difference(b,new goog.math.Coordinate(goog.style.bidi.getScrollLeft(a),a.scrollTop))))}return b||new goog.math.Coordinate};
  goog.positioning.getVisiblePart_=function(a){var b=goog.style.getBounds(a);(a=goog.style.getVisibleRectForElement(a))&&b.intersection(goog.math.Rect.createFromBox(a));return b};
  goog.positioning.positionAtCoordinate=function(a,b,c,d,e,f,g){a=a.clone();var h=goog.positioning.OverflowStatus.NONE;c=goog.positioning.getEffectiveCorner(b,c);var k=goog.style.getSize(b);g=g?g.clone():k.clone();if(d||c!=goog.positioning.Corner.TOP_LEFT)c&goog.positioning.CornerBit.RIGHT?a.x-=g.width+(d?d.right:0):d&&(a.x+=d.left),c&goog.positioning.CornerBit.BOTTOM?a.y-=g.height+(d?d.bottom:0):d&&(a.y+=d.top);if(f&&(h=e?goog.positioning.adjustForViewport_(a,g,e,f):goog.positioning.OverflowStatus.FAILED_OUTSIDE_VIEWPORT,
  h&goog.positioning.OverflowStatus.FAILED))return h;goog.style.setPosition(b,a);goog.math.Size.equals(k,g)||goog.style.setBorderBoxSize(b,g);return h};
  goog.positioning.adjustForViewport_=function(a,b,c,d){var e=goog.positioning.OverflowStatus.NONE,f=goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN,g=goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;(d&f)==f&&(a.x<c.left||a.x>=c.right)&&(d&=~goog.positioning.Overflow.ADJUST_X);(d&g)==g&&(a.y<c.top||a.y>=c.bottom)&&(d&=~goog.positioning.Overflow.ADJUST_Y);a.x<c.left&&d&goog.positioning.Overflow.ADJUST_X&&(a.x=c.left,e|=goog.positioning.OverflowStatus.ADJUSTED_X);a.x<c.left&&a.x+b.width>c.right&&
  d&goog.positioning.Overflow.RESIZE_WIDTH&&(b.width=Math.max(b.width-(a.x+b.width-c.right),0),e|=goog.positioning.OverflowStatus.WIDTH_ADJUSTED);a.x+b.width>c.right&&d&goog.positioning.Overflow.ADJUST_X&&(a.x=Math.max(c.right-b.width,c.left),e|=goog.positioning.OverflowStatus.ADJUSTED_X);d&goog.positioning.Overflow.FAIL_X&&(e=e|(a.x<c.left?goog.positioning.OverflowStatus.FAILED_LEFT:0)|(a.x+b.width>c.right?goog.positioning.OverflowStatus.FAILED_RIGHT:0));a.y<c.top&&d&goog.positioning.Overflow.ADJUST_Y&&
  (a.y=c.top,e|=goog.positioning.OverflowStatus.ADJUSTED_Y);a.y<=c.top&&a.y+b.height<c.bottom&&d&goog.positioning.Overflow.RESIZE_HEIGHT&&(b.height=Math.max(b.height-(c.top-a.y),0),a.y=c.top,e|=goog.positioning.OverflowStatus.HEIGHT_ADJUSTED);a.y>=c.top&&a.y+b.height>c.bottom&&d&goog.positioning.Overflow.RESIZE_HEIGHT&&(b.height=Math.max(b.height-(a.y+b.height-c.bottom),0),e|=goog.positioning.OverflowStatus.HEIGHT_ADJUSTED);a.y+b.height>c.bottom&&d&goog.positioning.Overflow.ADJUST_Y&&(a.y=Math.max(c.bottom-
  b.height,c.top),e|=goog.positioning.OverflowStatus.ADJUSTED_Y);d&goog.positioning.Overflow.FAIL_Y&&(e=e|(a.y<c.top?goog.positioning.OverflowStatus.FAILED_TOP:0)|(a.y+b.height>c.bottom?goog.positioning.OverflowStatus.FAILED_BOTTOM:0));return e};goog.positioning.getEffectiveCorner=function(a,b){return(b&goog.positioning.CornerBit.FLIP_RTL&&goog.style.isRightToLeft(a)?b^goog.positioning.CornerBit.RIGHT:b)&~goog.positioning.CornerBit.FLIP_RTL};
  goog.positioning.flipCornerHorizontal=function(a){return a^goog.positioning.CornerBit.RIGHT};goog.positioning.flipCornerVertical=function(a){return a^goog.positioning.CornerBit.BOTTOM};goog.positioning.flipCorner=function(a){return a^goog.positioning.CornerBit.BOTTOM^goog.positioning.CornerBit.RIGHT};goog.userAgent.product={};goog.userAgent.product.ASSUME_FIREFOX=!1;goog.userAgent.product.ASSUME_CAMINO=!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_OPERA||goog.userAgent.product.ASSUME_FIREFOX||goog.userAgent.product.ASSUME_CAMINO||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.init_=function(){goog.userAgent.product.detectedFirefox_=!1;goog.userAgent.product.detectedCamino_=!1;goog.userAgent.product.detectedIphone_=!1;goog.userAgent.product.detectedIpad_=!1;goog.userAgent.product.detectedAndroid_=!1;goog.userAgent.product.detectedChrome_=!1;goog.userAgent.product.detectedSafari_=!1;var a=goog.userAgent.getUserAgentString();a&&(-1!=a.indexOf("Firefox")?goog.userAgent.product.detectedFirefox_=!0:-1!=a.indexOf("Camino")?goog.userAgent.product.detectedCamino_=
  !0:-1!=a.indexOf("iPhone")||-1!=a.indexOf("iPod")?goog.userAgent.product.detectedIphone_=!0:-1!=a.indexOf("iPad")?goog.userAgent.product.detectedIpad_=!0:-1!=a.indexOf("Chrome")?goog.userAgent.product.detectedChrome_=!0:-1!=a.indexOf("Android")?goog.userAgent.product.detectedAndroid_=!0:-1!=a.indexOf("Safari")&&(goog.userAgent.product.detectedSafari_=!0))};goog.userAgent.product.PRODUCT_KNOWN_||goog.userAgent.product.init_();goog.userAgent.product.OPERA=goog.userAgent.OPERA;
  goog.userAgent.product.IE=goog.userAgent.IE;goog.userAgent.product.FIREFOX=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_FIREFOX:goog.userAgent.product.detectedFirefox_;goog.userAgent.product.CAMINO=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_CAMINO:goog.userAgent.product.detectedCamino_;goog.userAgent.product.IPHONE=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_IPHONE:goog.userAgent.product.detectedIphone_;
  goog.userAgent.product.IPAD=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_IPAD:goog.userAgent.product.detectedIpad_;goog.userAgent.product.ANDROID=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_ANDROID:goog.userAgent.product.detectedAndroid_;goog.userAgent.product.CHROME=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_CHROME:goog.userAgent.product.detectedChrome_;
  goog.userAgent.product.SAFARI=goog.userAgent.product.PRODUCT_KNOWN_?goog.userAgent.product.ASSUME_SAFARI:goog.userAgent.product.detectedSafari_;goog.positioning.AbstractPosition=function(){};goog.positioning.AbstractPosition.prototype.reposition=function(a,b,c,d){};goog.positioning.AnchoredPosition=function(a,b,c){this.element=a;this.corner=b;this.overflow_=c};goog.inherits(goog.positioning.AnchoredPosition,goog.positioning.AbstractPosition);goog.positioning.AnchoredPosition.prototype.reposition=function(a,b,c,d){goog.positioning.positionAtAnchor(this.element,this.corner,a,b,void 0,c,this.overflow_)};goog.positioning.AnchoredViewportPosition=function(a,b,c,d){goog.positioning.AnchoredPosition.call(this,a,b);this.lastResortOverflow_=c?goog.positioning.Overflow.ADJUST_X|goog.positioning.Overflow.ADJUST_Y:goog.positioning.Overflow.IGNORE;this.overflowConstraint_=d||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(a){this.overflowConstraint_=a};goog.positioning.AnchoredViewportPosition.prototype.getLastResortOverflow=function(){return this.lastResortOverflow_};goog.positioning.AnchoredViewportPosition.prototype.setLastResortOverflow=function(a){this.lastResortOverflow_=a};
  goog.positioning.AnchoredViewportPosition.prototype.reposition=function(a,b,c,d){var e=goog.positioning.positionAtAnchor(this.element,this.corner,a,b,null,c,goog.positioning.Overflow.FAIL_X|goog.positioning.Overflow.FAIL_Y,d,this.overflowConstraint_);if(e&goog.positioning.OverflowStatus.FAILED){var f=this.adjustCorner(e,this.corner);b=this.adjustCorner(e,b);e=goog.positioning.positionAtAnchor(this.element,f,a,b,null,c,goog.positioning.Overflow.FAIL_X|goog.positioning.Overflow.FAIL_Y,d,this.overflowConstraint_);
  e&goog.positioning.OverflowStatus.FAILED&&(f=this.adjustCorner(e,f),b=this.adjustCorner(e,b),goog.positioning.positionAtAnchor(this.element,f,a,b,null,c,this.getLastResortOverflow(),d,this.overflowConstraint_))}};goog.positioning.AnchoredViewportPosition.prototype.adjustCorner=function(a,b){a&goog.positioning.OverflowStatus.FAILED_HORIZONTAL&&(b=goog.positioning.flipCornerHorizontal(b));a&goog.positioning.OverflowStatus.FAILED_VERTICAL&&(b=goog.positioning.flipCornerVertical(b));return b};goog.positioning.MenuAnchoredPosition=function(a,b,c,d){goog.positioning.AnchoredViewportPosition.call(this,a,b,c||d);(c||d)&&this.setLastResortOverflow(goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN|(d?goog.positioning.Overflow.RESIZE_HEIGHT:goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN))};goog.inherits(goog.positioning.MenuAnchoredPosition,goog.positioning.AnchoredViewportPosition);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(a,b,c){switch(b){case goog.ui.Component.State.SELECTED:case goog.ui.Component.State.CHECKED:goog.asserts.assert(a,"The button DOM element cannot be null.");goog.a11y.aria.setState(a,goog.a11y.aria.State.PRESSED,c);break;default:case goog.ui.Component.State.OPENED:case goog.ui.Component.State.DISABLED:goog.ui.ButtonRenderer.base(this,"updateAriaState",a,b,c)}};
  goog.ui.ButtonRenderer.prototype.createDom=function(a){var b=goog.ui.ButtonRenderer.base(this,"createDom",a);this.setTooltip(b,a.getTooltip());var c=a.getValue();c&&this.setValue(b,c);a.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(b,goog.ui.Component.State.CHECKED,a.isChecked());return b};
  goog.ui.ButtonRenderer.prototype.decorate=function(a,b){b=goog.ui.ButtonRenderer.superClass_.decorate.call(this,a,b);a.setValueInternal(this.getValue(b));a.setTooltipInternal(this.getTooltip(b));a.isSupportedState(goog.ui.Component.State.CHECKED)&&this.updateAriaState(b,goog.ui.Component.State.CHECKED,a.isChecked());return b};goog.ui.ButtonRenderer.prototype.getValue=goog.nullFunction;goog.ui.ButtonRenderer.prototype.setValue=goog.nullFunction;goog.ui.ButtonRenderer.prototype.getTooltip=function(a){return a.title};
  goog.ui.ButtonRenderer.prototype.setTooltip=function(a,b){a&&b&&(a.title=b)};goog.ui.ButtonRenderer.prototype.setCollapsed=function(a,b){var c=a.isRightToLeft(),d=this.getStructuralCssClass()+"-collapse-left",e=this.getStructuralCssClass()+"-collapse-right";a.enableClassName(c?e:d,!!(b&goog.ui.ButtonSide.START));a.enableClassName(c?d:e,!!(b&goog.ui.ButtonSide.END))};goog.ui.ButtonRenderer.prototype.getCssClass=function(){return goog.ui.ButtonRenderer.CSS_CLASS};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(a){this.setUpNativeButton_(a);return a.getDomHelper().createDom("button",{"class":this.getClassNames(a).join(" "),disabled:!a.isEnabled(),title:a.getTooltip()||"",value:a.getValue()||""},a.getCaption()||"")};goog.ui.NativeButtonRenderer.prototype.canDecorate=function(a){return"BUTTON"==a.tagName||"INPUT"==a.tagName&&("button"==a.type||"submit"==a.type||"reset"==a.type)};
  goog.ui.NativeButtonRenderer.prototype.decorate=function(a,b){this.setUpNativeButton_(a);if(b.disabled){var c=goog.asserts.assertString(this.getClassForState(goog.ui.Component.State.DISABLED));goog.dom.classlist.add(b,c)}return goog.ui.NativeButtonRenderer.superClass_.decorate.call(this,a,b)};goog.ui.NativeButtonRenderer.prototype.initializeDom=function(a){a.getHandler().listen(a.getElement(),goog.events.EventType.CLICK,a.performActionInternal)};
  goog.ui.NativeButtonRenderer.prototype.setAllowTextSelection=goog.nullFunction;goog.ui.NativeButtonRenderer.prototype.setRightToLeft=goog.nullFunction;goog.ui.NativeButtonRenderer.prototype.isFocusable=function(a){return a.isEnabled()};goog.ui.NativeButtonRenderer.prototype.setFocusable=goog.nullFunction;
  goog.ui.NativeButtonRenderer.prototype.setState=function(a,b,c){goog.ui.NativeButtonRenderer.superClass_.setState.call(this,a,b,c);(a=a.getElement())&&b==goog.ui.Component.State.DISABLED&&(a.disabled=c)};goog.ui.NativeButtonRenderer.prototype.getValue=function(a){return a.value};goog.ui.NativeButtonRenderer.prototype.setValue=function(a,b){a&&(a.value=b)};goog.ui.NativeButtonRenderer.prototype.updateAriaState=goog.nullFunction;
  goog.ui.NativeButtonRenderer.prototype.setUpNativeButton_=function(a){a.setHandleMouseEvents(!1);a.setAutoStates(goog.ui.Component.State.ALL,!1);a.setSupportedState(goog.ui.Component.State.FOCUSED,!1)};goog.ui.Button=function(a,b,c){goog.ui.Control.call(this,a,b||goog.ui.NativeButtonRenderer.getInstance(),c)};goog.inherits(goog.ui.Button,goog.ui.Control);goog.ui.Button.Side=goog.ui.ButtonSide;goog.ui.Button.prototype.getValue=function(){return this.value_};goog.ui.Button.prototype.setValue=function(a){this.value_=a;this.getRenderer().setValue(this.getElement(),a)};goog.ui.Button.prototype.setValueInternal=function(a){this.value_=a};goog.ui.Button.prototype.getTooltip=function(){return this.tooltip_};
  goog.ui.Button.prototype.setTooltip=function(a){this.tooltip_=a;this.getRenderer().setTooltip(this.getElement(),a)};goog.ui.Button.prototype.setTooltipInternal=function(a){this.tooltip_=a};goog.ui.Button.prototype.setCollapsed=function(a){this.getRenderer().setCollapsed(this,a)};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(){goog.ui.Button.superClass_.enterDocument.call(this);if(this.isSupportedState(goog.ui.Component.State.FOCUSED)){var a=this.getKeyEventTarget();a&&this.getHandler().listen(a,goog.events.EventType.KEYUP,this.handleKeyEventInternal)}};
  goog.ui.Button.prototype.handleKeyEventInternal=function(a){return a.keyCode==goog.events.KeyCodes.ENTER&&a.type==goog.events.KeyHandler.EventType.KEY||a.keyCode==goog.events.KeyCodes.SPACE&&a.type==goog.events.EventType.KEYUP?this.performActionInternal(a):a.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.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(a){var b=this.getClassNames(a),b={"class":goog.ui.INLINE_BLOCK_CLASSNAME+" "+b.join(" ")},b=a.getDomHelper().createDom("div",b,this.createButton(a.getContent(),a.getDomHelper()));this.setTooltip(b,a.getTooltip());this.setAriaStates(a,b);return b};goog.ui.CustomButtonRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.BUTTON};goog.ui.CustomButtonRenderer.prototype.getContentElement=function(a){return a&&a.firstChild.firstChild};
  goog.ui.CustomButtonRenderer.prototype.createButton=function(a,b){return b.createDom("div",goog.ui.INLINE_BLOCK_CLASSNAME+" "+(this.getCssClass()+"-outer-box"),b.createDom("div",goog.ui.INLINE_BLOCK_CLASSNAME+" "+(this.getCssClass()+"-inner-box"),a))};goog.ui.CustomButtonRenderer.prototype.canDecorate=function(a){return"DIV"==a.tagName};
  goog.ui.CustomButtonRenderer.prototype.hasBoxStructure=function(a,b){var c=a.getDomHelper().getFirstElementChild(b),d=this.getCssClass()+"-outer-box";return c&&goog.dom.classlist.contains(c,d)&&(c=a.getDomHelper().getFirstElementChild(c),d=this.getCssClass()+"-inner-box",c&&goog.dom.classlist.contains(c,d))?!0:!1};
  goog.ui.CustomButtonRenderer.prototype.decorate=function(a,b){goog.ui.CustomButtonRenderer.trimTextNodes_(b,!0);goog.ui.CustomButtonRenderer.trimTextNodes_(b,!1);this.hasBoxStructure(a,b)||b.appendChild(this.createButton(b.childNodes,a.getDomHelper()));goog.dom.classlist.addAll(b,[goog.ui.INLINE_BLOCK_CLASSNAME,this.getCssClass()]);return goog.ui.CustomButtonRenderer.superClass_.decorate.call(this,a,b)};goog.ui.CustomButtonRenderer.prototype.getCssClass=function(){return goog.ui.CustomButtonRenderer.CSS_CLASS};
  goog.ui.CustomButtonRenderer.trimTextNodes_=function(a,b){if(a)for(var c=b?a.firstChild:a.lastChild,d;c&&c.parentNode==a;){d=b?c.nextSibling:c.previousSibling;if(c.nodeType==goog.dom.NodeType.TEXT){var e=c.nodeValue;if(""==goog.string.trim(e))a.removeChild(c);else{c.nodeValue=b?goog.string.trimLeft(e):goog.string.trimRight(e);break}}else break;c=d}};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(a){return goog.ui.MenuButtonRenderer.superClass_.getContentElement.call(this,a&&a.firstChild)};
  goog.ui.MenuButtonRenderer.prototype.decorate=function(a,b){var c=goog.dom.getElementsByTagNameAndClass("*",goog.ui.MenuRenderer.CSS_CLASS,b)[0];if(c){goog.style.setElementShown(c,!1);goog.dom.appendChild(goog.dom.getOwnerDocument(c).body,c);var d=new goog.ui.Menu;d.decorate(c);a.setMenu(d)}return goog.ui.MenuButtonRenderer.superClass_.decorate.call(this,a,b)};
  goog.ui.MenuButtonRenderer.prototype.createButton=function(a,b){return goog.ui.MenuButtonRenderer.superClass_.createButton.call(this,[this.createCaption(a,b),this.createDropdown(b)],b)};goog.ui.MenuButtonRenderer.prototype.createCaption=function(a,b){return goog.ui.MenuButtonRenderer.wrapCaption(a,this.getCssClass(),b)};goog.ui.MenuButtonRenderer.wrapCaption=function(a,b,c){return c.createDom("div",goog.ui.INLINE_BLOCK_CLASSNAME+" "+(b+"-caption"),a)};
  goog.ui.MenuButtonRenderer.prototype.createDropdown=function(a){return a.createDom("div",goog.ui.INLINE_BLOCK_CLASSNAME+" "+(this.getCssClass()+"-dropdown"),"\u00a0")};goog.ui.MenuButtonRenderer.prototype.getCssClass=function(){return goog.ui.MenuButtonRenderer.CSS_CLASS};goog.ui.MenuButton=function(a,b,c,d,e){goog.ui.Button.call(this,a,c||goog.ui.MenuButtonRenderer.getInstance(),d);this.setSupportedState(goog.ui.Component.State.OPENED,!0);this.menuPosition_=new goog.positioning.MenuAnchoredPosition(null,goog.positioning.Corner.BOTTOM_START);b&&this.setMenu(b);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_=
  e||goog.ui.MenuRenderer.getInstance()};goog.inherits(goog.ui.MenuButton,goog.ui.Button);goog.ui.MenuButton.prototype.isFocusablePopupMenu_=!1;goog.ui.MenuButton.prototype.renderMenuAsSibling_=!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(){goog.ui.MenuButton.superClass_.exitDocument.call(this);this.attachKeyDownEventListener_(!1);if(this.menu_){this.setOpen(!1);this.menu_.exitDocument();this.attachMenuEventListeners_(this.menu_,!1);var a=this.menu_.getElement();a&&goog.dom.removeNode(a)}};
  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(a){goog.ui.MenuButton.superClass_.handleMouseDown.call(this,a);this.isActive()&&(this.setOpen(!this.isOpen(),a),this.menu_&&this.menu_.setMouseButtonPressed(this.isOpen()))};
  goog.ui.MenuButton.prototype.handleMouseUp=function(a){goog.ui.MenuButton.superClass_.handleMouseUp.call(this,a);this.menu_&&!this.isActive()&&this.menu_.setMouseButtonPressed(!1)};goog.ui.MenuButton.prototype.performActionInternal=function(a){this.setActive(!1);return!0};goog.ui.MenuButton.prototype.handleDocumentMouseDown=function(a){this.menu_&&this.menu_.isVisible()&&!this.containsElement(a.target)&&this.setOpen(!1)};
  goog.ui.MenuButton.prototype.containsElement=function(a){return a&&goog.dom.contains(this.getElement(),a)||this.menu_&&this.menu_.containsElement(a)||!1};
  goog.ui.MenuButton.prototype.handleKeyEventInternal=function(a){if(a.keyCode==goog.events.KeyCodes.SPACE){if(a.preventDefault(),a.type!=goog.events.EventType.KEYUP)return!0}else if(a.type!=goog.events.KeyHandler.EventType.KEY)return!1;if(this.menu_&&this.menu_.isVisible()){var b=this.menu_.handleKeyEvent(a);return a.keyCode==goog.events.KeyCodes.ESC?(this.setOpen(!1),!0):b}return a.keyCode==goog.events.KeyCodes.DOWN||a.keyCode==goog.events.KeyCodes.UP||a.keyCode==goog.events.KeyCodes.SPACE||a.keyCode==
  goog.events.KeyCodes.ENTER?(this.setOpen(!0,a),!0):!1};goog.ui.MenuButton.prototype.handleMenuAction=function(a){this.setOpen(!1)};goog.ui.MenuButton.prototype.handleMenuBlur=function(a){this.isActive()||this.setOpen(!1)};goog.ui.MenuButton.prototype.handleBlur=function(a){this.isFocusablePopupMenu()||this.setOpen(!1);goog.ui.MenuButton.superClass_.handleBlur.call(this,a)};
  goog.ui.MenuButton.prototype.getMenu=function(){this.menu_||this.setMenu(new goog.ui.Menu(this.getDomHelper(),this.menuRenderer_));return this.menu_||null};
  goog.ui.MenuButton.prototype.setMenu=function(a){var b=this.menu_;a!=b&&(b&&(this.setOpen(!1),this.isInDocument()&&this.attachMenuEventListeners_(b,!1),delete this.menu_),this.isInDocument()&&goog.a11y.aria.setState(this.getElementStrict(),goog.a11y.aria.State.HASPOPUP,!!a),a&&(this.menu_=a,a.setParent(this),a.setVisible(!1),a.setAllowAutoFocus(this.isFocusablePopupMenu()),this.isInDocument()&&this.attachMenuEventListeners_(a,!0)));return b};
  goog.ui.MenuButton.prototype.setMenuPosition=function(a){a&&(this.menuPosition_=a,this.positionElement_=a.element)};goog.ui.MenuButton.prototype.setPositionElement=function(a){this.positionElement_=a;this.positionMenu()};goog.ui.MenuButton.prototype.setMenuMargin=function(a){this.menuMargin_=a};goog.ui.MenuButton.prototype.addItem=function(a){this.getMenu().addChild(a,!0)};goog.ui.MenuButton.prototype.addItemAt=function(a,b){this.getMenu().addChildAt(a,b,!0)};
  goog.ui.MenuButton.prototype.removeItem=function(a){(a=this.getMenu().removeChild(a,!0))&&a.dispose()};goog.ui.MenuButton.prototype.removeItemAt=function(a){(a=this.getMenu().removeChildAt(a,!0))&&a.dispose()};goog.ui.MenuButton.prototype.getItemAt=function(a){return this.menu_?this.menu_.getChildAt(a):null};goog.ui.MenuButton.prototype.getItemCount=function(){return this.menu_?this.menu_.getChildCount():0};
  goog.ui.MenuButton.prototype.setVisible=function(a,b){var c=goog.ui.MenuButton.superClass_.setVisible.call(this,a,b);c&&!this.isVisible()&&this.setOpen(!1);return c};goog.ui.MenuButton.prototype.setEnabled=function(a){goog.ui.MenuButton.superClass_.setEnabled.call(this,a);this.isEnabled()||this.setOpen(!1)};goog.ui.MenuButton.prototype.isAlignMenuToStart=function(){var a=this.menuPosition_.corner;return a==goog.positioning.Corner.BOTTOM_START||a==goog.positioning.Corner.TOP_START};
  goog.ui.MenuButton.prototype.setAlignMenuToStart=function(a){this.menuPosition_.corner=a?goog.positioning.Corner.BOTTOM_START:goog.positioning.Corner.BOTTOM_END};goog.ui.MenuButton.prototype.setScrollOnOverflow=function(a){this.menuPosition_.setLastResortOverflow&&this.menuPosition_.setLastResortOverflow(goog.positioning.Overflow.ADJUST_X|(a?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(a){this.isFocusablePopupMenu_=a};goog.ui.MenuButton.prototype.setRenderMenuAsSibling=function(a){this.renderMenuAsSibling_=a};
  goog.ui.MenuButton.prototype.showMenu=function(){this.setOpen(!0)};goog.ui.MenuButton.prototype.hideMenu=function(){this.setOpen(!1)};
  goog.ui.MenuButton.prototype.setOpen=function(a,b){goog.ui.MenuButton.superClass_.setOpen.call(this,a);if(this.menu_&&this.hasState(goog.ui.Component.State.OPENED)==a){if(a)this.menu_.isInDocument()||(this.renderMenuAsSibling_?this.menu_.render(this.getElement().parentNode):this.menu_.render()),this.viewportBox_=goog.style.getVisibleRectForElement(this.getElement()),this.buttonRect_=goog.style.getBounds(this.getElement()),this.positionMenu(),this.menu_.setHighlightedIndex(!b||b.keyCode!=goog.events.KeyCodes.DOWN&&
  b.keyCode!=goog.events.KeyCodes.UP?-1:0);else{this.setActive(!1);this.menu_.setMouseButtonPressed(!1);var c=this.getElement();c&&(goog.a11y.aria.setState(c,goog.a11y.aria.State.ACTIVEDESCENDANT,""),goog.a11y.aria.setState(c,goog.a11y.aria.State.OWNS,""));goog.isDefAndNotNull(this.originalSize_)&&(this.originalSize_=void 0,(c=this.menu_.getElement())&&goog.style.setSize(c,"",""))}this.menu_.setVisible(a,!1,b);this.isDisposed()||this.attachPopupListeners_(a)}};
  goog.ui.MenuButton.prototype.invalidateMenuSize=function(){this.originalSize_=void 0};
  goog.ui.MenuButton.prototype.positionMenu=function(){if(this.menu_.isInDocument()){var a=this.positionElement_||this.getElement(),b=this.menuPosition_;this.menuPosition_.element=a;a=this.menu_.getElement();this.menu_.isVisible()||(a.style.visibility="hidden",goog.style.setElementShown(a,!0));!this.originalSize_&&this.isScrollOnOverflow()&&(this.originalSize_=goog.style.getSize(a));var c=goog.positioning.flipCornerVertical(b.corner);b.reposition(a,c,this.menuMargin_,this.originalSize_);this.menu_.isVisible()||
  (goog.style.setElementShown(a,!1),a.style.visibility="visible")}};goog.ui.MenuButton.prototype.onTick_=function(a){a=goog.style.getBounds(this.getElement());var b=goog.style.getVisibleRectForElement(this.getElement());goog.math.Rect.equals(this.buttonRect_,a)&&goog.math.Box.equals(this.viewportBox_,b)||(this.buttonRect_=a,this.viewportBox_=b,this.positionMenu())};
  goog.ui.MenuButton.prototype.attachMenuEventListeners_=function(a,b){var c=this.getHandler(),d=b?c.listen:c.unlisten;d.call(c,a,goog.ui.Component.EventType.ACTION,this.handleMenuAction);d.call(c,a,goog.ui.Component.EventType.HIGHLIGHT,this.handleHighlightItem);d.call(c,a,goog.ui.Component.EventType.UNHIGHLIGHT,this.handleUnHighlightItem)};
  goog.ui.MenuButton.prototype.attachKeyDownEventListener_=function(a){var b=this.getHandler();(a?b.listen:b.unlisten).call(b,this.getElement(),goog.events.EventType.KEYDOWN,this.handleKeyDownEvent_)};
  goog.ui.MenuButton.prototype.handleHighlightItem=function(a){var b=this.getElement();goog.asserts.assert(b,"The menu button DOM element cannot be null.");null!=a.target.getElement()&&(goog.a11y.aria.setState(b,goog.a11y.aria.State.ACTIVEDESCENDANT,a.target.getElement().id),goog.a11y.aria.setState(b,goog.a11y.aria.State.OWNS,a.target.getElement().id))};
  goog.ui.MenuButton.prototype.handleKeyDownEvent_=function(a){this.isSupportedState(goog.ui.Component.State.FOCUSED)&&this.getKeyEventTarget()&&this.menu_&&this.menu_.isVisible()&&a.stopPropagation()};
  goog.ui.MenuButton.prototype.handleUnHighlightItem=function(a){this.menu_.getHighlighted()||(a=this.getElement(),goog.asserts.assert(a,"The menu button DOM element cannot be null."),goog.a11y.aria.setState(a,goog.a11y.aria.State.ACTIVEDESCENDANT,""),goog.a11y.aria.setState(a,goog.a11y.aria.State.OWNS,""))};
  goog.ui.MenuButton.prototype.attachPopupListeners_=function(a){var b=this.getHandler(),c=a?b.listen:b.unlisten;c.call(b,this.getDomHelper().getDocument(),goog.events.EventType.MOUSEDOWN,this.handleDocumentMouseDown,!0);this.isFocusablePopupMenu()&&c.call(b,this.menu_,goog.ui.Component.EventType.BLUR,this.handleMenuBlur);c.call(b,this.timer_,goog.Timer.TICK,this.onTick_);a?this.timer_.start():this.timer_.stop()};goog.ui.registry.setDecoratorByClassName(goog.ui.MenuButtonRenderer.CSS_CLASS,function(){return new goog.ui.MenuButton(null)});goog.ui.SelectionModel=function(a){goog.events.EventTarget.call(this);this.items_=[];this.addItems(a)};goog.inherits(goog.ui.SelectionModel,goog.events.EventTarget);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(a){this.selectionHandler_=a};
  goog.ui.SelectionModel.prototype.getItemCount=function(){return this.items_.length};goog.ui.SelectionModel.prototype.indexOfItem=function(a){return a?goog.array.indexOf(this.items_,a):-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(a){return this.items_[a]||null};
  goog.ui.SelectionModel.prototype.addItems=function(a){a&&(goog.array.forEach(a,function(a){this.selectItem_(a,!1)},this),goog.array.extend(this.items_,a))};goog.ui.SelectionModel.prototype.addItem=function(a){this.addItemAt(a,this.getItemCount())};goog.ui.SelectionModel.prototype.addItemAt=function(a,b){a&&(this.selectItem_(a,!1),goog.array.insertAt(this.items_,a,b))};
  goog.ui.SelectionModel.prototype.removeItem=function(a){a&&goog.array.remove(this.items_,a)&&a==this.selectedItem_&&(this.selectedItem_=null,this.dispatchEvent(goog.events.EventType.SELECT))};goog.ui.SelectionModel.prototype.removeItemAt=function(a){this.removeItem(this.getItemAt(a))};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(a){a!=this.selectedItem_&&(this.selectItem_(this.selectedItem_,!1),this.selectedItem_=a,this.selectItem_(a,!0));this.dispatchEvent(goog.events.EventType.SELECT)};goog.ui.SelectionModel.prototype.getSelectedIndex=function(){return this.indexOfItem(this.selectedItem_)};goog.ui.SelectionModel.prototype.setSelectedIndex=function(a){this.setSelectedItem(this.getItemAt(a))};
  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(a,b){a&&("function"==typeof this.selectionHandler_?this.selectionHandler_(a,b):"function"==typeof a.setSelected&&a.setSelected(b))};goog.ui.Select=function(a,b,c,d,e){goog.ui.Select.base(this,"constructor",a,b,c,d,e||new goog.ui.MenuRenderer(goog.a11y.aria.Role.LISTBOX));this.defaultCaption_=this.getContent();this.initialAriaLabel_=null};goog.inherits(goog.ui.Select,goog.ui.MenuButton);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(a){goog.ui.Select.superClass_.decorateInternal.call(this,a);(a=this.getCaption())?this.setDefaultCaption(a):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(a){this.setSelectedItem(a.target);goog.ui.Select.base(this,"handleMenuAction",a);a.stopPropagation();this.dispatchEvent(goog.ui.Component.EventType.ACTION)};goog.ui.Select.prototype.handleSelectionChange=function(a){a=this.getSelectedItem();goog.ui.Select.superClass_.setValue.call(this,a&&a.getValue());this.updateCaption()};
  goog.ui.Select.prototype.setMenu=function(a){var b=goog.ui.Select.superClass_.setMenu.call(this,a);a!=b&&(this.selectionModel_&&this.selectionModel_.clear(),a&&(this.selectionModel_?a.forEachChild(function(a,b){this.setCorrectAriaRole_(a);this.selectionModel_.addItem(a)},this):this.createSelectionModel_(a)));return b};goog.ui.Select.prototype.getDefaultCaption=function(){return this.defaultCaption_};goog.ui.Select.prototype.setDefaultCaption=function(a){this.defaultCaption_=a;this.updateCaption()};
  goog.ui.Select.prototype.addItem=function(a){this.setCorrectAriaRole_(a);goog.ui.Select.superClass_.addItem.call(this,a);this.selectionModel_?this.selectionModel_.addItem(a):this.createSelectionModel_(this.getMenu())};goog.ui.Select.prototype.addItemAt=function(a,b){this.setCorrectAriaRole_(a);goog.ui.Select.superClass_.addItemAt.call(this,a,b);this.selectionModel_?this.selectionModel_.addItemAt(a,b):this.createSelectionModel_(this.getMenu())};
  goog.ui.Select.prototype.removeItem=function(a){goog.ui.Select.superClass_.removeItem.call(this,a);this.selectionModel_&&this.selectionModel_.removeItem(a)};goog.ui.Select.prototype.removeItemAt=function(a){goog.ui.Select.superClass_.removeItemAt.call(this,a);this.selectionModel_&&this.selectionModel_.removeItemAt(a)};goog.ui.Select.prototype.setSelectedItem=function(a){if(this.selectionModel_){var b=this.getSelectedItem();this.selectionModel_.setSelectedItem(a);a!=b&&this.dispatchEvent(goog.ui.Component.EventType.CHANGE)}};
  goog.ui.Select.prototype.setSelectedIndex=function(a){this.selectionModel_&&this.setSelectedItem(this.selectionModel_.getItemAt(a))};goog.ui.Select.prototype.setValue=function(a){if(goog.isDefAndNotNull(a)&&this.selectionModel_)for(var b=0,c;c=this.selectionModel_.getItemAt(b);b++)if(c&&"function"==typeof c.getValue&&c.getValue()==a){this.setSelectedItem(c);return}this.setSelectedItem(null)};goog.ui.Select.prototype.getValue=function(){var a=this.getSelectedItem();return a?a.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(a){this.selectionModel_=new goog.ui.SelectionModel;a&&a.forEachChild(function(a,c){this.setCorrectAriaRole_(a);this.selectionModel_.addItem(a)},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 a=this.getSelectedItem();this.setContent(a?a.getCaption():this.defaultCaption_);var b=this.getRenderer().getContentElement(this.getElement());b&&this.getDomHelper().isElement(b)&&(null==this.initialAriaLabel_&&(this.initialAriaLabel_=goog.a11y.aria.getLabel(b)),a=a?a.getElement():null,goog.a11y.aria.setLabel(b,a?goog.a11y.aria.getLabel(a):this.initialAriaLabel_))};
  goog.ui.Select.prototype.setCorrectAriaRole_=function(a){a.setPreferredAriaRole(a instanceof goog.ui.MenuItem?goog.a11y.aria.Role.OPTION:goog.a11y.aria.Role.SEPARATOR)};goog.ui.Select.prototype.setOpen=function(a,b){goog.ui.Select.superClass_.setOpen.call(this,a,b);this.isOpen()&&this.getMenu().setHighlightedIndex(this.getSelectedIndex())};goog.ui.registry.setDecoratorByClassName("goog-select",function(){return new goog.ui.Select(null)});Blockly.BlockValueType={NONE:"None",STRING:"String",NUMBER:"Number",IMAGE:"Image",BOOLEAN:"Boolean",FUNCTION:"Function",COLOUR:"Colour",ARRAY:"Array"};Blockly.FunctionalBlockUtils={};var typesToColors={};typesToColors[Blockly.BlockValueType.NONE]=[0,0,0];typesToColors[Blockly.BlockValueType.NUMBER]=[192,1,0.99];typesToColors[Blockly.BlockValueType.STRING]=[180,1,0.6];typesToColors[Blockly.BlockValueType.IMAGE]=[285,1,0.8];typesToColors[Blockly.BlockValueType.BOOLEAN]=[90,1,0.4];Blockly.FunctionalTypeColors=typesToColors;
  Blockly.FunctionalBlockUtils.initTitledFunctionalBlock=function(a,b,c,d,e){e=e||{};a.setFunctional(!0,{headerHeight:30});a.setHSV.apply(a,Blockly.FunctionalTypeColors[c]);var f={fixedSize:{height:35},fontSize:e.titleFontSize};a.appendDummyInput().appendTitle(new Blockly.FieldLabel(b,f)).setAlign(Blockly.ALIGN_CENTRE);for(b=0;b<d.length;b++){var f=d[b],g=a.appendFunctionalInput(f.name);g.setInline(0<b&&!e.verticallyStackInputs);g.setHSV.apply(g,Blockly.FunctionalTypeColors[f.type]);g.setCheck(f.type);
  g.setAlign(Blockly.ALIGN_CENTRE)}c===Blockly.BlockValueType.NONE?a.setFunctionalOutput(!1):a.setFunctionalOutput(!0,c)};
  Blockly.FunctionalBlockUtils.installStringPicker=function(a,b,c){var d=c.values;c=c.blockName;a.Blocks[c]={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 a.FieldDropdown(d),"VAL").appendTitle(new Blockly.FieldLabel('"')).setAlign(Blockly.ALIGN_CENTRE);this.setFunctionalOutput(!0,a.BlockValueType.STRING)}};b[c]=function(){return a.JavaScript.quote_(this.getTitleValue("VAL"))}};Blockly.SvgTextButton=function(a,b,c){a=Blockly.createSvgElement("g",{"class":"svgTextButton",filter:"url(#blocklyTrashcanShadowFilter)"},a);this.buttonRect=Blockly.createSvgElement("rect",{rx:12,ry:12,fill:"#7665a0",stroke:"white","stroke-width":"2.5"},a);var d=Blockly.createSvgElement("text",{x:7,y:7,"class":"blocklyText"},a);d.textContent=b;b=d.getBoundingClientRect();this.buttonRect.setAttribute("width",b.width+14);this.buttonRectHeight=b.height+7;this.buttonRect.setAttribute("height",this.buttonRectHeight);
  this.buttonRectYOffset=-b.height+7-1;this.buttonRect.setAttribute("y",this.buttonRectYOffset);Blockly.bindEvent_(a,"click",null,c);this.svgGroup_=a};Blockly.SvgTextButton.prototype.renderAt=function(a,b){this.svgGroup_.setAttribute("transform","translate("+a+","+b+")");return b+this.buttonRectHeight};Blockly.SvgTextButton.prototype.setVisible=function(a){goog.style.setElementShown(this.svgGroup_,a)};
  Blockly.SvgTextButton.prototype.getButtonWidth=function(){return parseInt(this.buttonRect.getAttribute("width"),10)};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(a){var b=this.getClassNames(a),b={"class":goog.ui.INLINE_BLOCK_CLASSNAME+" "+b.join(" ")},b=a.getDomHelper().createDom("div",b,a.getContent());this.setTooltip(b,a.getTooltip());this.setAriaStates(a,b);return b};goog.ui.FlatButtonRenderer.prototype.getAriaRole=function(){return goog.a11y.aria.Role.BUTTON};goog.ui.FlatButtonRenderer.prototype.canDecorate=function(a){return"DIV"==a.tagName};
  goog.ui.FlatButtonRenderer.prototype.decorate=function(a,b){goog.dom.classlist.add(b,goog.ui.INLINE_BLOCK_CLASSNAME);return goog.ui.FlatButtonRenderer.superClass_.decorate.call(this,a,b)};goog.ui.FlatButtonRenderer.prototype.getValue=function(a){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.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(a){var b=this.getClassNames(a),b={"class":goog.ui.INLINE_BLOCK_CLASSNAME+" "+b.join(" ")},b=a.getDomHelper().createDom("div",b,[this.createCaption(a.getContent(),a.getDomHelper()),this.createDropdown(a.getDomHelper())]);this.setTooltip(b,a.getTooltip());this.setAriaStates(a,b);return b};goog.ui.FlatMenuButtonRenderer.prototype.getContentElement=function(a){return a&&a.firstChild};
  goog.ui.FlatMenuButtonRenderer.prototype.decorate=function(a,b){var c=goog.dom.getElementsByTagNameAndClass("*",goog.ui.MenuRenderer.CSS_CLASS,b)[0];if(c){goog.style.setElementShown(c,!1);a.getDomHelper().getDocument().body.appendChild(c);var d=new goog.ui.Menu;d.decorate(c);a.setMenu(d)}goog.dom.getElementsByTagNameAndClass("*",this.getCssClass()+"-caption",b)[0]||b.appendChild(this.createCaption(b.childNodes,a.getDomHelper()));goog.dom.getElementsByTagNameAndClass("*",this.getCssClass()+"-dropdown",
  b)[0]||b.appendChild(this.createDropdown(a.getDomHelper()));return goog.ui.FlatMenuButtonRenderer.superClass_.decorate.call(this,a,b)};goog.ui.FlatMenuButtonRenderer.prototype.createCaption=function(a,b){return b.createDom("div",goog.ui.INLINE_BLOCK_CLASSNAME+" "+(this.getCssClass()+"-caption"),a)};goog.ui.FlatMenuButtonRenderer.prototype.createDropdown=function(a){return a.createDom("div",{"class":goog.ui.INLINE_BLOCK_CLASSNAME+" "+(this.getCssClass()+"-dropdown"),"aria-hidden":!0},"\u00a0")};
  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())});Blockly.CustomCssClassMenuRenderer=function(a){this.customCssClass_=a;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_};Blockly.SvgHighlightBox=function(a,b){b=b||{};var c=b.color||"#000",d=b.thickness||"30";this.svgGroup_=Blockly.createSvgElement("g",{style:"pointer-events: none;"},a);this.highlightRectangle_=Blockly.createSvgElement("rect",{fill:"none","stroke-width":d,stroke:c},this.svgGroup_)};
  Blockly.SvgHighlightBox.prototype.setPositionSize=function(a,b,c){this.svgGroup_.setAttribute("transform","translate(0,"+a+")");this.highlightRectangle_.setAttribute("width",b);this.highlightRectangle_.setAttribute("height",c)};var DOWN_TRIANGLE_CHARACTER="\u25bc",RIGHT_TRIANGLE_CHARACTER="\u25b6",DARK_GRAY_HEX="#898989",YELLOW_HEX="#ffa400",HIGHLIGHT_BOX_WIDTH=10,DEFAULT_HEADER_HEIGHT=25;
  Blockly.ContractEditorSectionView=function(a,b){this.headerText_=b.headerText;this.onCollapseCallback_=b.onCollapseCallback;this.placeContentCallback=b.placeContentCallback;this.headerHeight=b.headerHeight||DEFAULT_HEADER_HEIGHT;this.sectionNumber_=b.hasOwnProperty("sectionNumber")?b.sectionNumber:null;this.highlightBox_=b.highlightBox||null;this.completelyHidden_=this.highlighted_=!1;this.header_=new Blockly.SvgHeader(a,{headerText:this.textForCurrentState_(),onMouseDown:goog.bind(this.toggleCollapse,
  this),backgroundColor:DARK_GRAY_HEX});this.collapsed_=!1;this.showHeader_=!0};Blockly.ContractEditorSectionView.prototype.setHeaderColor=function(a){this.header_.setColor(a)};Blockly.ContractEditorSectionView.prototype.textForCurrentState_=function(){if(!this.onCollapseCallback_)return this.headerText_;var a;a=""+((this.collapsed_?RIGHT_TRIANGLE_CHARACTER:DOWN_TRIANGLE_CHARACTER)+" ");null!==this.sectionNumber_&&(a+=this.sectionNumber_+". ");return a+=this.headerText_};
  Blockly.ContractEditorSectionView.prototype.setHidden=function(a){(this.completelyHidden_=a)&&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(a){this.collapsed_=a;this.header_.showSeparator(a);if(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(a){this.highlighted_=a};Blockly.ContractEditorSectionView.prototype.setHeaderVisible=function(a){this.showHeader_=a};
  Blockly.ContractEditorSectionView.prototype.placeAndGetNewY=function(a,b){if(this.completelyHidden_)return this.header_.setVisible(!1),a;var c=a;this.header_.setVisible(this.showHeader_);this.showHeader_&&(this.header_.setPositionSize(a,b,this.headerHeight),a+=this.headerHeight);this.collapsed_||(a=this.placeAndGetNewYInnerSegment_(a));this.highlighted_&&this.highlightBox_.setPositionSize(c,b,a-c);return a};
  Blockly.ContractEditorSectionView.prototype.placeAndGetNewYInnerSegment_=function(a){this.placeContentCallback&&(a=this.placeContentCallback(a));return a};var EXAMPLE_BLOCK_MARGIN_BELOW=20,EXAMPLE_BLOCK_MARGIN_LEFT=Blockly.FunctionEditor.BLOCK_LAYOUT_LEFT_MARGIN,EXAMPLE_BLOCK_SECTION_MAGIN_BELOW=10,EXAMPLE_BLOCK_SECTION_MAGIN_ABOVE=15,HEADER_HEIGHT=30,DEFAULT_EXAMPLE_CALL_SECTION_WIDTH=100,MARGIN_BLOCK_TO_CALL_SLOT=13,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(a){Blockly.ContractEditor.superClass_.constructor.call(this);this.disableExamples_=a[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(a){return"Block ID is "+a.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 a=this.modalBlockSpace.svgBlockCanvas_,b=new Blockly.SvgHighlightBox(a,{color:YELLOW_HEX,thickness:HIGHLIGHT_BOX_WIDTH});this.contractSectionView_=new Blockly.ContractEditorSectionView(a,{sectionNumber:1,headerHeight:HEADER_HEIGHT,onCollapseCallback:goog.bind(function(a){this.contractDiv_.style.display=a?"none":"block";this.position_()},this),placeContentCallback:goog.bind(function(a){return a+
  this.getContractDivHeight()},this),highlightBox:b,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.innerHTML="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.innerHTML="Call";Blockly.svgIgnoreMouseEvents(this.callText);goog.dom.appendChild(this.exampleAreaDiv,this.callText);this.resultText=goog.dom.createDom("div","callResultText");this.resultText.innerHTML="Result";goog.dom.appendChild(this.exampleAreaDiv,this.resultText);Blockly.svgIgnoreMouseEvents(this.resultText);this.examplesTableGroup=
  Blockly.createSvgElement("g",{},a);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(a,
  {sectionNumber:2,headerHeight:HEADER_HEIGHT,headerText:"Examples",placeContentCallback:this.onPlaceExampleContent.bind(this),highlightBox:b,onCollapseCallback:goog.bind(function(a){this.exampleAreaDiv.style.display=a?"none":"block";this.examplesTableGroup.style.display=a?"none":"block";this.hiddenExampleBlocks_=this.setBlockSubsetVisibility(!a,goog.bind(this.isBlockInExampleArea,this),this.hiddenExampleBlocks_);this.position_()},this)});this.hiddenDefinitionBlocks_=[];this.definitionSectionLogic_=
  new Blockly.ContractDefinitionSection(a);this.definitionSectionView_=new Blockly.ContractEditorSectionView(a,{sectionNumber:3,headerHeight:HEADER_HEIGHT,headerText:"Definition",onCollapseCallback:goog.bind(function(a){this.flyout_.setVisibility(!a);a||this.refreshParamsInFlyout_();this.hiddenDefinitionBlocks_=this.setBlockSubsetVisibility(!a,goog.bind(this.isBlockInFunctionArea,this),this.hiddenDefinitionBlocks_);this.definitionSectionLogic_.handleCollapse(a);this.position_()},this),highlightBox:b,
  placeContentCallback:goog.bind(function(a){this.flyout_&&(a=this.positionFlyout_(a));return this.definitionSectionLogic_.placeContent(a,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(a){this.autoOpenConfig_=a;Blockly.ContractEditor.superClass_.autoOpenWithLevelConfiguration.call(this,a)};Blockly.ContractEditor.prototype.setBlockSubsetVisibility=function(a,b,c){var d=[];a?c.forEach(function(a){a.setCurrentlyHidden(!1)},this):this.modalBlockSpace.getTopBlocks().filter(b).forEach(function(a){d.push(a);a.setCurrentlyHidden(!0)},this);return d};
  Blockly.ContractEditor.prototype.isBlockInFunctionArea=function(a){return this.isVisibleInEditor_(a)&&!this.isBlockInExampleArea(a)};Blockly.ContractEditor.prototype.isBlockInExampleArea=function(a){return this.isAnExampleBlockInEditor_(a)||a!==this.functionDefinitionBlock&&this.isVisibleInEditor_(a)&&a.getRelativeToSurfaceXY().y<this.getFlyoutTopPosition()};Blockly.ContractEditor.prototype.isVisibleInEditor_=function(a){return a.blockSpace===this.modalBlockSpace&&a.isVisible()};
  Blockly.ContractEditor.prototype.getFlyoutTopPosition=function(){return this.flyout_.getYPosition()-this.flyout_.getHeight()};Blockly.ContractEditor.prototype.isAnExampleBlockInEditor_=function(a){return goog.array.contains(this.exampleBlocks,a)};
  Blockly.ContractEditor.prototype.hideAndRestoreBlocks_=function(){Blockly.ContractEditor.superClass_.hideAndRestoreBlocks_.call(this);goog.array.clone(this.exampleBlocks).forEach(function(a){this.moveToMainBlockSpace_(a)},this);goog.array.clear(this.exampleBlocks);this.domainEditors_.forEach(function(a){a.dispose()},this);goog.array.clear(this.domainEditors_);this.outputTypeSelector.dispose();this.outputTypeSelector=null};
  Blockly.ContractEditor.prototype.openAndEditFunction=function(a){Blockly.ContractEditor.superClass_.openAndEditFunction.call(this,a);this.addRangeEditor_();this.updateFrameColorForType_(this.functionDefinitionBlock.getOutputType());this.functionDefinitionBlock.setDeletable(!1);this.moveExampleBlocksToModal_(a);this.setupAfterExampleBlocksAdded_();this.position_();this.resetParamIDs_();this.refreshParamsEverywhere()};
  Blockly.ContractEditor.prototype.setSectionHighlighted=function(a){this.allSections_.forEach(function(b){b.setHighlighted(b===a)},this)};Blockly.ContractEditor.prototype.addNewExampleBlock_=function(){this.addNewExampleBlockForFunction_(this.functionDefinitionBlock);this.refreshBlockInputTypes_()};Blockly.ContractEditor.prototype.addNewExampleBlockForFunction_=function(a){a=this.createExampleBlock_(a);this.addExampleBlockFromMainBlockSpace(a);this.position_()};
  Blockly.ContractEditor.prototype.moveExampleBlocksToModal_=function(a){Blockly.mainBlockSpace.findFunctionExamples(a).forEach(function(a){this.addExampleBlockFromMainBlockSpace(a)},this)};Blockly.ContractEditor.prototype.registerTestHandler=function(a){this.testHandler_=a};Blockly.ContractEditor.prototype.registerTestResetHandler=function(a){this.testResetHandler_=a};Blockly.ContractEditor.prototype.registerTestsFailedOnCloseHandler=function(a){this.customFailureCloseHandler_=a};
  Blockly.ContractEditor.prototype.addExampleBlockFromMainBlockSpace=function(a){a=this.moveToModalBlockSpace(a);a.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME).setCanDisconnectFromParent(!1);this.exampleBlocks.push(a);a.blockEvents.listen(Blockly.Block.EVENTS.AFTER_DROPPED,function(){this.layOutBlockSpaceItems_();this.modalBlockSpace.updateScrollableSize()}.bind(this));a.blockEvents.listenOnce(Blockly.Block.EVENTS.AFTER_DISPOSED,this.removeExampleBlock_.bind(this,a),!1,
  this)};Blockly.ContractEditor.prototype.refreshBlockInputTypes_=function(){this.setBlockInputsToType_(this.currentFunctionDefinitionType_())};Blockly.ContractEditor.prototype.setBlockInputsToType_=function(a){this.exampleBlocks.concat(this.functionDefinitionBlock).forEach(function(b){b.updateInputsToType(a)},this)};
  Blockly.ContractEditor.prototype.currentFunctionDefinitionType_=function(){var a=this.functionDefinitionBlock.previousConnection.getCheck();if(!a||1!==a.length)throw"Contract editor function definition should have exactly one type check";return a[0]};Blockly.ContractEditor.prototype.removeExampleBlock_=function(a){goog.array.remove(this.exampleBlocks,a);this.position_()};Blockly.ContractEditor.prototype.openWithNewVariable=function(){this.openWithNewFunction(!0)};
  Blockly.ContractEditor.prototype.openWithNewFunction=function(a){this.ensureCreated_();var b=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:this.definitionBlockType}));b.updateOutputType(Blockly.ContractEditor.DEFAULT_OUTPUT_TYPE);b.userCreated=!0;if(a)b.convertToVariable();else for(a=0;a<Blockly.defaultNumExampleBlocks;a++)this.addNewExampleBlockForFunction_(b);this.openAndEditFunction(b.getTitleValue("NAME"))};
  Blockly.ContractEditor.prototype.createExampleBlock_=function(a){var b=Blockly.Xml.domToBlock(Blockly.mainBlockSpace,Blockly.createSvgElement("block",{type:Blockly.ContractEditor.EXAMPLE_BLOCK_TYPE}));a=Blockly.Procedures.createCallerFromDefinition(Blockly.mainBlockSpace,a);b.attachBlockToInputName(a,Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);return b};Blockly.ContractEditor.prototype.getFullWidth=function(){return this.modalBlockSpace.getMetrics().viewWidth};
  Blockly.ContractEditor.prototype.layOutBlockSpaceItems_=function(){if(this.readyToBeLaidOut_()){var a=this.getFullWidth(),b;b=this.contractSectionView_.placeAndGetNewY(0,a);b=this.examplesSectionView_.placeAndGetNewY(b,a);this.definitionSectionView_.placeAndGetNewY(b,a)}};
  Blockly.ContractEditor.prototype.createContractDom_=function(){this.contractDiv_=goog.dom.createDom("div","blocklyToolboxDiv paramToolbox blocklyText contractEditor flyoutColorGray innerModalDiv");Blockly.RTL&&this.contractDiv_.setAttribute("dir","RTL");this.contractDiv_.innerHTML="<div>"+Blockly.Msg.FUNCTIONAL_NAME_LABEL+'</div><div><input id="functionNameText" type="text"></div><div><span id="domain-label">'+Blockly.Msg.FUNCTIONAL_DOMAIN_LABEL+'</span> <span class="contract-type-hint"  id="domain-hint">(the domain is the type of input)</span></div><div id="domain-area" style="margin: 0;"></div><div class="clear" style="margin: 0;"></div><button id="paramAddButton" class="btn">Add Domain</button><div class="clear" style="margin: 0;"></div><div id="range-area" style="margin: 0;"><div><span id="outputTypeTitle">'+
  Blockly.Msg.FUNCTIONAL_RANGE_LABEL+'</span> <span class="contract-type-hint" id="range-hint">(the range is the type of output)</span></div><span id="outputTypeDropdown"></span></div><div id="description-area" style="margin: 0px;"><div>'+Blockly.Msg.FUNCTIONAL_DESCRIPTION_LABEL+'</div><div><textarea id="functionDescriptionText" rows="2"></textarea></div></div>';var a=this.modalBlockSpace.getMetrics();this.contractDiv_.style.left=a.absoluteLeft+"px";this.contractDiv_.style.top=a.absoluteTop+"px";this.contractDiv_.style.width=
  a.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(a){a=a.isVariable();this.frameText_.textContent=a?Blockly.Msg.FUNCTIONAL_VARIABLE_HEADER:Blockly.Msg.CONTRACT_EDITOR_HEADER;goog.dom.setTextContent(goog.dom.getElement("outputTypeTitle"),a?Blockly.Msg.FUNCTIONAL_VARIABLE_TYPE:Blockly.Msg.FUNCTIONAL_RANGE_LABEL);goog.style.setElementShown(goog.dom.getElement("domain-area"),!a);goog.style.setElementShown(goog.dom.getElement("domain-label"),!a);goog.style.setElementShown(goog.dom.getElement("paramAddButton"),
  !a);goog.style.setElementShown(goog.dom.getElement("description-area"),!a);goog.style.setElementShown(goog.dom.getElement("range-hint"),!a);goog.style.setElementShown(goog.dom.getElement("domain-hint"),!a)};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(a){this.allSections_.forEach(function(b,c){a?(a[c+HIGHLIGHT_CONFIG_SUFFIX]&&this.setSectionHighlighted(b),b.setCollapsed(a[c+COLLAPSE_CONFIG_SUFFIX])):(b.setHighlighted(!1),b.setHidden(!1),b.setHeaderVisible(!0),b.setCollapsed(b.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(a,b){var c=goog.events.getUniqueId("parameter");this.orderedParamIDsToBlocks_.set(c,this.newParameterBlock(a,b));this.addDomainEditorForParamID_(c)};
  Blockly.ContractEditor.prototype.addDomainEditorForParamID_=function(a){var b=this.getParamNameType(a);a=new Blockly.DomainEditor({paramID:a,name:b.name,type:b.type,onRemovePress:goog.bind(this.removeContractParameter_,this,a),onTypeChanged:goog.bind(this.changeParameterType_,this,a),onNameChanged:goog.bind(this.changeParameterName_,this,a),typeChoices:USER_TYPE_CHOICES});a.render(goog.dom.getElement("domain-area"));this.domainEditors_.push(a)};
  Blockly.ContractEditor.prototype.removeContractParameter_=function(a){this.orderedParamIDsToBlocks_.remove(a);this.refreshParamsEverywhere();goog.array.removeIf(this.domainEditors_,function(b){return b.getParamID()===a?(b.dispose(),!0):!1},this);this.position_()};
  Blockly.ContractEditor.prototype.newParameterBlock=function(a,b){b=b||Blockly.ContractEditor.DEFAULT_PARAMETER_TYPE;var c=Blockly.createSvgElement("block",{type:this.parameterBlockType});Blockly.createSvgElement("title",{name:"VAR"},c).textContent=a;if(b){var d=Blockly.createSvgElement("mutation",{},c);Blockly.createSvgElement("outputtype",{},d).textContent=b}return c};
  Blockly.ContractEditor.prototype.addParamsFromProcedure_=function(){for(var a=this.functionDefinitionBlock.getProcedureInfo(),b=0;b<a.parameterNames.length;b++)this.addParameter(a.parameterNames[b],a.parameterTypes[b])};
  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(a){this.updateFrameColorForType_(a);this.functionDefinitionBlock&&(this.setBlockInputsToType_(Blockly.BlockValueType.NONE),this.functionDefinitionBlock.updateOutputType(a),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(a){a=Blockly.FunctionalTypeColors[a];var b=goog.color.hsvToHex(a[0],a[1],255*a[2]);this.setFrameColor_(b);this.allSections_.forEach(function(a,d){a.setHeaderColor(b)},this)};Blockly.ContractEditor.prototype.setFrameColor_=function(a){this.frameBase_.style.fill=a};Blockly.ContractEditor.prototype.getOutputTypeDropdownElement_=function(){return goog.dom.getElement("outputTypeDropdown")};
  Blockly.ContractEditor.prototype.initializeAddButton_=function(){var a=goog.dom.getElement("paramAddButton");Blockly.bindEvent_(a,"mousedown",this,goog.bind(function(){this.addParameter(Blockly.Variables.generateUniqueName());this.refreshParamsEverywhere()},this))};Blockly.ContractEditor.prototype.changeParameterType_=function(a,b){var c=this.getParamNameType(a).name;this.functionDefinitionBlock.changeParamType(c,b);this.changeParameterTypeInFlyoutXML(c,b);this.refreshParamsEverywhere()};
  Blockly.ContractEditor.prototype.changeParameterName_=function(a,b){var c=this.getParamNameType(a).name;Blockly.Variables.renameVariable(c,b,Blockly.modalBlockSpace)};Blockly.ContractEditor.prototype.getVerticalMidlineOffset_=function(){return EXAMPLE_BLOCK_MARGIN_LEFT+this.getMaxExampleCallBlockWidth_()+MARGIN_BLOCK_TO_CALL_SLOT};
  Blockly.ContractEditor.prototype.getMaxExampleCallBlockWidth_=function(){return this.exampleBlocks.reduce(function(a,b){var c=b.getInputTargetBlock(Blockly.ContractEditor.EXAMPLE_BLOCK_ACTUAL_INPUT_NAME);if(!c)return a;c=c.getHeightWidth().width;return Math.max(a,c)},DEFAULT_EXAMPLE_CALL_SECTION_WIDTH)};Blockly.ContractEditor.prototype.resetExampleViews=function(){this.exampleViews_.forEach(function(a){a.reset()})};
  Blockly.ContractEditor.prototype.testExample=function(a,b){var c=this.testHandler_(a,b);return this.functionDefinitionBlock.getInput("STACK").connection.isConnected()?c:Blockly.Msg.DEFINE_FUNCTION_FOR_EXAMPLE};Blockly.ContractEditor.prototype.resetExample=function(a){this.testResetHandler_(a)};Blockly.ContractEditor.prototype.updateExampleResult=function(a,b){this.exampleViews_.some(function(c){if(c.getBlock()===a)return c.setResult(b),!0})};
  Blockly.ContractEditor.prototype.onPlaceExampleContent=function(a){var b=this.getMaxExampleCallBlockWidth_(),c=this.modalBlockSpace.getMetrics();this.exampleAreaDiv.style.left=this.modalBlockSpace.xOffsetFromView+"px";this.exampleAreaDiv.style.top=this.modalBlockSpace.yOffsetFromView+a+"px";this.exampleAreaDiv.style.width=c.viewWidth+"px";var c=EXAMPLE_BLOCK_SECTION_MAGIN_BELOW/2,d=a,e=this.getVerticalMidlineOffset_(),f=d;this.verticalExampleMidline.setAttribute("transform","translate("+e+","+d+")");
  var g=0<this.exampleBlocks.length;g&&(d+=c,this.callText.style.top=d-a+"px",this.callText.style.left=EXAMPLE_BLOCK_MARGIN_LEFT+"px",this.resultText.style.top=d-a+"px",this.resultText.style.left=e+EXAMPLE_BLOCK_MARGIN_LEFT+"px",d+=this.callText.offsetHeight,d+=c,this.topHorizontalLine.setAttribute("transform","translate(0,"+d+")"),this.topHorizontalLine.setAttribute("width",this.getFullWidth()),this.exampleBlocks.forEach(goog.bind(function(c,f){if(!(this.exampleViews_.length>f)){var g=new Blockly.ExampleView(this.exampleAreaDiv,
  this.examplesTableGroup,this);this.exampleViews_.push(g)}d=this.exampleViews_[f].placeExampleAndGetNewY(c,d,b,EXAMPLE_BLOCK_MARGIN_LEFT,EXAMPLE_BLOCK_MARGIN_BELOW,this.getFullWidth(),e,a)},this)));for(var h=this.exampleBlocks.length;h<this.exampleViews_.length;h++)this.exampleViews_[h].dispose();this.exampleViews_.length=this.exampleBlocks.length;this.verticalExampleMidline.style.display=g?"block":"none";this.topHorizontalLine.style.display=g?"block":"none";this.callText.style.display=g?"block":"none";
  this.resultText.style.display=g?"block":"none";this.verticalExampleMidline.setAttribute("height",d-f);d+=c;this.addExampleButton.style.top=d-a+"px";this.addExampleButton.style.left=EXAMPLE_BLOCK_MARGIN_LEFT+"px";d+=this.addExampleButton.offsetHeight;d+=EXAMPLE_BLOCK_SECTION_MAGIN_BELOW;this.exampleAreaDiv.style.height=d-a+"px";return d};
  Blockly.ContractEditor.prototype.onClose=function(){if(this.isOpen()){var a=!0;this.exampleViews_.forEach(function(b){var c=this.testExample(b.getBlock(),!1);b.setResult(c);b.refreshTestingUI(!1);a=a&&!c}.bind(this));!a&&this.customFailureCloseHandler_()||this.hideIfOpen()}};Blockly.FieldIcon=function(a){Blockly.FieldIcon.superClass_.constructor.apply(this,arguments);Blockly.addClass_(this.fieldGroup_,"blocklyIconGroup");Blockly.addClass_(this.borderRect_,"blocklyIconShield");this.textElement_.setAttribute("style","font-size:9pt; cursor:default;")};goog.inherits(Blockly.FieldIcon,Blockly.Field);Blockly.FieldIcon.prototype.EDITABLE=!1;Blockly.FieldIcon.prototype.showEditor_=function(){};goog.memoize=function(a,b){var c=b||goog.memoize.simpleSerializer;return function(){if(goog.memoize.ENABLE_MEMOIZE){var b=this||goog.global,b=b[goog.memoize.CACHE_PROPERTY_]||(b[goog.memoize.CACHE_PROPERTY_]={}),e=c(goog.getUid(a),arguments);return b.hasOwnProperty(e)?b[e]:b[e]=a.apply(this,arguments)}return a.apply(this,arguments)}};goog.memoize.ENABLE_MEMOIZE=!0;goog.memoize.clearCache=function(a){a[goog.memoize.CACHE_PROPERTY_]={}};goog.memoize.CACHE_PROPERTY_="closure_memoize_cache_";
  goog.memoize.simpleSerializer=function(a,b){for(var c=[a],d=b.length-1;0<=d;--d)c.push(typeof b[d],b[d]);return c.join("\x0B")};Blockly.utils={};Blockly.addClass_=function(a,b){var c=a.getAttribute("class")||"";Blockly.stringContainsClass_(c,b)&&(c&&(c+=" "),a.setAttribute("class",c+b))};Blockly.elementHasClass_=function(a,b){return Blockly.stringContainsClass_(a.getAttribute("class")||"",b)};Blockly.stringContainsClass_=function(a,b){return-1==(" "+a+" ").indexOf(" "+b+" ")};
  Blockly.removeClass_=function(a,b){var c=a.getAttribute("class");if(-1!=(" "+c+" ").indexOf(" "+b+" ")){for(var c=c.split(/\s+/),d=0;d<c.length;d++)c[d]&&c[d]!=b||(c.splice(d,1),d--);c.length?a.setAttribute("class",c.join(" ")):a.removeAttribute("class")}};
  Blockly.bindEvent_=function(a,b,c,d,e){e=!!e;var f=[],g;if(!a.addEventListener)throw"Element is not a DOM node with addEventListener.";g=function(a){d.apply(c,arguments)};var h=Blockly.bindEvent_.TOUCH_MAP[b];h?(window.navigator.pointerEnabled||window.navigator.msPointerEnabled||(a.addEventListener(b,g,e),f.push([a,b,g,e])),g=function(a){if(a.target&&a.target.style){var b=a.target.style;b.touchAction?b.touchAction="none":b.msTouchAction&&(b.msTouchAction="none")}for(var b=a.changedTouches||[a],e=
  0;e<b.length;++e)a.clientX=b[e].clientX,a.clientY=b[e].clientY,d.apply(c,arguments)},a.addEventListener(h,g,e),f.push([a,h,g,e])):(a.addEventListener(b,g,e),f.push([a,b,g,e]));return f};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&&(Blockly.bindEvent_.TOUCH_MAP={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"});
  Blockly.unbindEvent_=function(a){for(;a.length;){var b=a.pop(),c=b[2];b[0].removeEventListener(b[1],c,b[3])}return c};Blockly.fireUiEvent=function(a,b){var c=document;if(c.createEvent)c=c.createEvent("UIEvents"),c.initEvent(b,!0,!0),a.dispatchEvent(c);else if(c.createEventObject)c=c.createEventObject(),a.fireEvent("on"+b,c);else throw"FireEvent: No event creation mechanism.";};Blockly.noEvent=function(a){a.preventDefault();a.stopPropagation()};
  Blockly.getRelativeXY=function(a){var b={x:0,y:0},c=a.getAttribute("x");c&&(b.x=parseFloat(c));if(c=a.getAttribute("y"))b.y=parseFloat(c);if(a=(a=a.getAttribute("transform"))&&a.match(/translate\(\s*([-\d.]+)([ ,]\s*([-\d.]+)\s*\))?/))b.x+=parseFloat(a[1]),a[3]&&(b.y+=parseFloat(a[3]));return b};Blockly.getSvgXY_=function(a,b){var c=0,d=0,e=b||Blockly.topMostSVGParent(a);do{var f=Blockly.getRelativeXY(a),c=c+f.x,d=d+f.y;a=a.parentNode}while(a&&a!==e);return{x:c,y:d}};
  Blockly.getAbsoluteXY_=function(a,b){var c=Blockly.getSvgXY_(a,b);return Blockly.convertCoordinates(c.x,c.y,b||Blockly.topMostSVGParent(a),!1)};Blockly.topMostSVGParent=function(a){for(var b=null;a;)"svg"===a.tagName&&(b=a),a=goog.dom.getParentElement(a);return b||Blockly.mainBlockSpaceEditor.getSVGElement()};
  Blockly.createSvgElement=function(a,b,c,d){d=d||{};a=document.createElementNS(Blockly.SVG_NS,a);for(var e in b)a.setAttribute(e,b[e]);document.body.runtimeStyle&&(a.runtimeStyle=a.currentStyle=a.style);c&&(d.belowExisting?goog.dom.insertChildAt(c,a,0):goog.dom.appendChild(c,a));return a};Blockly.isRightButton=function(a){return 2==a.button||a.ctrlKey};
  Blockly.convertCoordinates=function(a,b,c,d){d&&(a-=window.pageXOffset,b-=window.pageYOffset);var e=c.createSVGPoint();e.x=a;e.y=b;a=c.getScreenCTM();d&&(a=a.inverse());e=e.matrixTransform(a);d||(goog.userAgent.IPAD||goog.userAgent.IPHONE)&&!goog.userAgent.isVersionOrHigher(538)||(e.x+=window.pageXOffset,e.y+=window.pageYOffset);return e};Blockly.mouseToSvg=function(a,b){return Blockly.mouseCoordinatesToSvg(a.clientX,a.clientY,b||Blockly.topMostSVGParent(a.target))};
  Blockly.mouseCoordinatesToSvg=function(a,b,c){return Blockly.convertCoordinates(a+window.pageXOffset,b+window.pageYOffset,c,!0)};Blockly.svgCoordinatesToViewport=function(a,b){var c=b.getMetrics();return new goog.math.Coordinate(a.x-c.absoluteLeft,a.y-c.absoluteTop)};Blockly.viewportCoordinateToBlockSpace=function(a,b){var c=b.getViewportBox();return new goog.math.Coordinate(a.x+c.left,a.y+c.top)};
  Blockly.shortestStringLength=function(a){if(!a.length)return 0;for(var b=a[0].length,c=1;c<a.length;c++)b=Math.min(b,a[c].length);return b};Blockly.commonWordPrefix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0][e],g=1;g<a.length;g++)if(f!=a[g][e])return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g][e])&&" "!=f)return c;return d};
  Blockly.commonWordSuffix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0].substr(-e-1,1),g=1;g<a.length;g++)if(f!=a[g].substr(-e-1,1))return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g].charAt(a[g].length-e-1))&&" "!=f)return c;return d};Blockly.isNumber=function(a){return!!a.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(a,b,c){a=goog.color.hexToRgb(a);var d=goog.color.hexToRgb(b);b=Math.round(d[0]*(1-c)+a[0]*c);var e=Math.round(d[1]*(1-c)+a[1]*c);c=Math.round(d[2]*(1-c)+a[2]*c);return goog.color.rgbToHex(b,e,c)};
  Blockly.printerRangeToNumbers=function(a){a=a.replace(/ /g,"").split(",");for(var b=[],c=/^(\d+)\-(\d+)$/,d=/^(\d+)$/,e=0;e<a.length;e++){var f=a[e],g=c.exec(f),f=d.exec(f);g?(g=goog.array.range(Number(g[1]),Number(g[2])+1),b=b.concat(g)):f&&b.push(Number(f[1]))}return b};Blockly.getUID=function(){return goog.events.getUniqueId("blocklyUID")};Blockly.isTargetInput=function(a){return"textarea"==a.target.type||"text"==a.target.type};Blockly.blockContextMenu=function(a){Blockly.isTargetInput(a)||a.preventDefault()};
  Blockly.getNormalizedWheelDeltaY=function(a){a=a.deltaY||-a.wheelDeltaY;if(!a)return null;goog.userAgent.GECKO&&(a*=10);return a};Blockly.getBoxOverflow=function(a,b){return new goog.math.Box(Math.max(0,a.top-b.top),Math.max(0,b.right-a.right),Math.max(0,b.bottom-a.bottom),Math.max(0,a.left-b.left))};Blockly.getPointBoxOverflow=function(a,b){return new goog.math.Box(a.top-b.y,b.x-a.right,b.y-a.bottom,a.left-b.x)};Blockly.isBoxWiderThan=function(a,b){return Blockly.getBoxWidth(a)>Blockly.getBoxWidth(b)};
  Blockly.isBoxTallerThan=function(a,b){return Blockly.getBoxHeight(a)>Blockly.getBoxHeight(b)};Blockly.getBoxWidth=function(a){return a.right-a.left};Blockly.getBoxHeight=function(a){return a.bottom-a.top};Blockly.numberWithin=function(a,b,c,d){return d?a>=b&&a<=c:a>b&&a<c};Blockly.svgRectToRect=function(a){return new goog.math.Rect(a.x,a.y,a.width,a.height)};Blockly.showSimpleDialog=function(a){Blockly.customSimpleDialog&&Blockly.customSimpleDialog(a)};
  Blockly.BOX_DIRECTIONS=["top","right","bottom","left"];Blockly.addToNonZeroSides=function(a,b){Blockly.BOX_DIRECTIONS.forEach(function(c){0!==a[c]&&(a[c]+=b)})};Blockly.svgIgnoreMouseEvents=function(a){a.style.pointerEvents="none"};Blockly.fireTestClickSequence=function(a){Blockly.fireTestMouseEvent(a,"mousedown");Blockly.fireTestMouseEvent(a,"mouseup");Blockly.fireTestMouseEvent(a,"click")};
  Blockly.fireTestMouseEvent=function(a,b){if(!document.createEvent)throw"fireTestMouseEvent is only for testing in browsers with createEvent";a.dispatchEvent(Blockly.makeTestMouseEvent(b))};Blockly.makeTestMouseEvent=function(a){var b=document.createEvent("MouseEvents");b.initMouseEvent(a,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null);return b};Blockly.findEmptyContainerBlock=function(a){for(var b=0;b<a.length;b++){var c=a[b];if(Blockly.findEmptyInput(c,Blockly.NEXT_STATEMENT))return c}return null};
  Blockly.findEmptyInput=function(a,b){return goog.array.find(a.inputList,function(a){return a.type===b&&!a.connection.targetConnection})};Blockly.FieldImageDropdown=function(a,b,c){this.width_=b;this.height_=c;Blockly.FieldImageDropdown.superClass_.constructor.call(this,a);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(a){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,preserveAspectRatio:"xMidYMid slice"},a)};Blockly.FieldImageDropdown.prototype.updatePreviewData_=function(a){this.previewElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);this.hasForcedDimensions_()||this.getUpdatedDimensions_(a)};
  Blockly.FieldImageDropdown.prototype.createDropdownPreviewElement_=function(a){return this.hasForcedDimensions_()?this.createAutoSizedDropdownPreviewElement_(a,this.width_,this.height_):this.createImageDropdownPreviewElement_(a)};
  Blockly.FieldImageDropdown.prototype.createAutoSizedDropdownPreviewElement_=function(a,b,c){var d=document.createElement("div");d.style.backgroundImage="url('"+a+"')";d.style.backgroundSize="cover";d.style.backgroundRepeat="no-repeat";d.style.backgroundPosition="50% 50%";d.style.width=b+"px";d.style.height=c+"px";return d};Blockly.FieldImageDropdown.prototype.createImageDropdownPreviewElement_=function(a){var b=document.createElement("img");b.setAttribute("src",a);return b};
  Blockly.FieldImageDropdown.prototype.getUpdatedDimensions_=function(a){var b=this;a=Blockly.ImageDimensionCache.getCachedDimensionsOrDefaultAndUpdate(a,function(a,d){b.updateDimensions_(a,d)});this.updateDimensions_(a.width,a.height)};Blockly.FieldImageDropdown.prototype.updatePreviewDimensions_=function(a,b){this.previewElement_.setAttribute("width",a+"px");this.previewElement_.setAttribute("height",b+"px")};goog.dom.TagWalkType={START_TAG:1,OTHER:0,END_TAG:-1};goog.dom.TagIterator=function(a,b,c,d,e){this.reversed=!!b;a&&this.setPosition(a,d);this.depth=void 0!=e?e:this.tagType||0;this.reversed&&(this.depth*=-1);this.constrained=!c};goog.inherits(goog.dom.TagIterator,goog.iter.Iterator);goog.dom.TagIterator.prototype.node=null;goog.dom.TagIterator.prototype.tagType=goog.dom.TagWalkType.OTHER;goog.dom.TagIterator.prototype.started_=!1;
  goog.dom.TagIterator.prototype.setPosition=function(a,b,c){if(this.node=a)goog.isNumber(b)?this.tagType=b: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(c)&&(this.depth=c)};goog.dom.TagIterator.prototype.copyFrom=function(a){this.node=a.node;this.tagType=a.tagType;this.depth=a.depth;this.reversed=a.reversed;this.constrained=a.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 a=this.reversed?goog.dom.TagWalkType.END_TAG:goog.dom.TagWalkType.START_TAG;this.tagType==a&&(this.tagType=-1*a,this.depth+=this.tagType*(this.reversed?-1:1))};
  goog.dom.TagIterator.prototype.restartTag=function(){var a=this.reversed?goog.dom.TagWalkType.START_TAG:goog.dom.TagWalkType.END_TAG;this.tagType==a&&(this.tagType=-1*a,this.depth+=this.tagType*(this.reversed?-1:1))};
  goog.dom.TagIterator.prototype.next=function(){var a;if(this.started_){if(!this.node||this.constrained&&0==this.depth)throw goog.iter.StopIteration;a=this.node;var b=this.reversed?goog.dom.TagWalkType.END_TAG:goog.dom.TagWalkType.START_TAG;if(this.tagType==b){var c=this.reversed?a.lastChild:a.firstChild;c?this.setPosition(c):this.setPosition(a,-1*b)}else(c=this.reversed?a.previousSibling:a.nextSibling)?this.setPosition(c):this.setPosition(a.parentNode,-1*b);this.depth+=this.tagType*(this.reversed?
  -1:1)}else this.started_=!0;a=this.node;if(!this.node)throw goog.iter.StopIteration;return a};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(a){return a.node==this.node&&(!this.node||a.tagType==this.tagType)};goog.dom.TagIterator.prototype.splice=function(a){var b=this.node;this.restartTag();this.reversed=!this.reversed;goog.dom.TagIterator.prototype.next.call(this);this.reversed=!this.reversed;for(var c=goog.isArrayLike(arguments[0])?arguments[0]:arguments,d=c.length-1;0<=d;d--)goog.dom.insertSiblingAfter(c[d],b);goog.dom.removeNode(b)};goog.dom.NodeIterator=function(a,b,c,d){goog.dom.TagIterator.call(this,a,b,c,null,d)};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(a){var b=this.getClassNames(a);a=a.getDomHelper().createDom(goog.dom.TagName.DIV,b?b.join(" "):null,this.createGrid(a.getContent(),a.getSize(),a.getDomHelper()));goog.a11y.aria.setRole(a,goog.a11y.aria.Role.GRID);return a};
  goog.ui.PaletteRenderer.prototype.createGrid=function(a,b,c){for(var d=[],e=0,f=0;e<b.height;e++){for(var g=[],h=0;h<b.width;h++){var k=a&&a[f++];g.push(this.createCell(k,c))}d.push(this.createRow(g,c))}return this.createTable(d,c)};goog.ui.PaletteRenderer.prototype.createTable=function(a,b){var c=b.createDom(goog.dom.TagName.TABLE,this.getCssClass()+"-table",b.createDom(goog.dom.TagName.TBODY,this.getCssClass()+"-body",a));c.cellSpacing=0;c.cellPadding=0;return c};
  goog.ui.PaletteRenderer.prototype.createRow=function(a,b){var c=b.createDom(goog.dom.TagName.TR,this.getCssClass()+"-row",a);goog.a11y.aria.setRole(c,goog.a11y.aria.Role.ROW);return c};
  goog.ui.PaletteRenderer.prototype.createCell=function(a,b){var c=b.createDom(goog.dom.TagName.TD,{"class":this.getCssClass()+"-cell",id:this.getCssClass()+"-cell-"+goog.ui.PaletteRenderer.cellId_++},a);goog.a11y.aria.setRole(c,goog.a11y.aria.Role.GRIDCELL);goog.a11y.aria.setState(c,goog.a11y.aria.State.SELECTED,!1);if(!goog.dom.getTextContent(c)&&!goog.a11y.aria.getLabel(c)){var d=this.findAriaLabelForCell_(c);d&&goog.a11y.aria.setLabel(c,d)}return c};
  goog.ui.PaletteRenderer.prototype.findAriaLabelForCell_=function(a){a=new goog.dom.NodeIterator(a);for(var b="",c;!b&&(c=goog.iter.nextOrValue(a,null));)c.nodeType==goog.dom.NodeType.ELEMENT&&(b=goog.a11y.aria.getLabel(c)||c.title);return b};goog.ui.PaletteRenderer.prototype.canDecorate=function(a){return!1};goog.ui.PaletteRenderer.prototype.decorate=function(a,b){return null};
  goog.ui.PaletteRenderer.prototype.setContent=function(a,b){if(a){var c=goog.dom.getElementsByTagNameAndClass(goog.dom.TagName.TBODY,this.getCssClass()+"-body",a)[0];if(c){var d=0;goog.array.forEach(c.rows,function(a){goog.array.forEach(a.cells,function(a){goog.dom.removeChildren(a);if(b){var c=b[d++];c&&goog.dom.appendChild(a,c)}})});if(d<b.length){for(var e=[],f=goog.dom.getDomHelper(a),g=c.rows[0].cells.length;d<b.length;){var h=b[d++];e.push(this.createCell(h,f));e.length==g&&(h=this.createRow(e,
  f),goog.dom.appendChild(c,h),e.length=0)}if(0<e.length){for(;e.length<g;)e.push(this.createCell("",f));h=this.createRow(e,f);goog.dom.appendChild(c,h)}}}goog.style.setUnselectable(a,!0,goog.userAgent.GECKO)}};goog.ui.PaletteRenderer.prototype.getContainingItem=function(a,b){for(var c=a.getElement();b&&b.nodeType==goog.dom.NodeType.ELEMENT&&b!=c;){if(b.tagName==goog.dom.TagName.TD&&goog.dom.classlist.contains(b,this.getCssClass()+"-cell"))return b.firstChild;b=b.parentNode}return null};
  goog.ui.PaletteRenderer.prototype.highlightCell=function(a,b,c){b&&(b=this.getCellForItem(b),goog.dom.classlist.enable(b,this.getCssClass()+"-cell-hover",c),goog.a11y.aria.setState(a.getElementStrict(),goog.a11y.aria.State.ACTIVEDESCENDANT,b.id))};goog.ui.PaletteRenderer.prototype.getCellForItem=function(a){return a?a.parentNode:null};
  goog.ui.PaletteRenderer.prototype.selectCell=function(a,b,c){b&&(a=b.parentNode,goog.dom.classlist.enable(a,this.getCssClass()+"-cell-selected",c),goog.a11y.aria.setState(a,goog.a11y.aria.State.SELECTED,c))};goog.ui.PaletteRenderer.prototype.getCssClass=function(){return goog.ui.PaletteRenderer.CSS_CLASS};goog.ui.Palette=function(a,b,c){goog.ui.Palette.base(this,"constructor",a,b||goog.ui.PaletteRenderer.getInstance(),c);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.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(a){goog.ui.Palette.superClass_.setContentInternal.call(this,a);this.adjustSize_();this.selectionModel_?(this.selectionModel_.clear(),this.selectionModel_.addItems(a)):(this.selectionModel_=new goog.ui.SelectionModel(a),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(a){};goog.ui.Palette.prototype.handleMouseOver=function(a){goog.ui.Palette.superClass_.handleMouseOver.call(this,a);var b=this.getRenderer().getContainingItem(this,a.target);b&&a.relatedTarget&&goog.dom.contains(b,a.relatedTarget)||b!=this.getHighlightedItem()&&this.setHighlightedItem(b)};
  goog.ui.Palette.prototype.handleMouseDown=function(a){goog.ui.Palette.superClass_.handleMouseDown.call(this,a);this.isActive()&&(a=this.getRenderer().getContainingItem(this,a.target),a!=this.getHighlightedItem()&&this.setHighlightedItem(a))};goog.ui.Palette.prototype.performActionInternal=function(a){var b=this.getHighlightedItem();return b?(this.setSelectedItem(b),goog.ui.Palette.base(this,"performActionInternal",a)):!1};
  goog.ui.Palette.prototype.handleKeyEvent=function(a){var b=this.getContent(),b=b?b.length:0,c=this.size_.width;if(0==b||!this.isEnabled())return!1;if(a.keyCode==goog.events.KeyCodes.ENTER||a.keyCode==goog.events.KeyCodes.SPACE)return this.performActionInternal(a);if(a.keyCode==goog.events.KeyCodes.HOME)return this.setHighlightedIndex(0),!0;if(a.keyCode==goog.events.KeyCodes.END)return this.setHighlightedIndex(b-1),!0;var d=0>this.highlightedIndex_?this.getSelectedIndex():this.highlightedIndex_;switch(a.keyCode){case goog.events.KeyCodes.LEFT:if(-1==
  d||0==d)d=b;this.setHighlightedIndex(d-1);a.preventDefault();return!0;case goog.events.KeyCodes.RIGHT:return d==b-1&&(d=-1),this.setHighlightedIndex(d+1),a.preventDefault(),!0;case goog.events.KeyCodes.UP:-1==d&&(d=b+c-1);if(d>=c)return this.setHighlightedIndex(d-c),a.preventDefault(),!0;break;case goog.events.KeyCodes.DOWN:if(-1==d&&(d=-c),d<b-c)return this.setHighlightedIndex(d+c),a.preventDefault(),!0}return!1};goog.ui.Palette.prototype.handleSelectionChange=function(a){};
  goog.ui.Palette.prototype.getSize=function(){return this.size_};goog.ui.Palette.prototype.setSize=function(a,b){if(this.getElement())throw Error(goog.ui.Component.Error.ALREADY_RENDERED);this.size_=goog.isNumber(a)?new goog.math.Size(a,b):a;this.adjustSize_()};goog.ui.Palette.prototype.getHighlightedIndex=function(){return this.highlightedIndex_};goog.ui.Palette.prototype.getHighlightedItem=function(){var a=this.getContent();return a&&a[this.highlightedIndex_]};
  goog.ui.Palette.prototype.getHighlightedCellElement_=function(){return this.getRenderer().getCellForItem(this.getHighlightedItem())};goog.ui.Palette.prototype.setHighlightedIndex=function(a){a!=this.highlightedIndex_&&(this.highlightIndex_(this.highlightedIndex_,!1),this.lastHighlightedIndex_=this.highlightedIndex_,this.highlightedIndex_=a,this.highlightIndex_(a,!0),this.dispatchEvent(goog.ui.Palette.EventType.AFTER_HIGHLIGHT))};
  goog.ui.Palette.prototype.setHighlightedItem=function(a){var b=this.getContent();this.setHighlightedIndex(b?goog.array.indexOf(b,a):-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(a){this.selectionModel_&&this.selectionModel_.setSelectedIndex(a)};
  goog.ui.Palette.prototype.setSelectedItem=function(a){this.selectionModel_&&this.selectionModel_.setSelectedItem(a)};goog.ui.Palette.prototype.highlightIndex_=function(a,b){if(this.getElement()){var c=this.getContent();if(c&&0<=a&&a<c.length){var d=this.getHighlightedCellElement_();this.currentCellControl_.getElement()!=d&&this.currentCellControl_.setElementInternal(d);this.currentCellControl_.tryHighlight(b)&&this.getRenderer().highlightCell(this,c[a],b)}}};
  goog.ui.Palette.prototype.setHighlighted=function(a){goog.ui.Palette.base(this,"setHighlighted",a);a&&-1==this.highlightedIndex_?this.setHighlightedIndex(-1<this.lastHighlightedIndex_?this.lastHighlightedIndex_:0):a||this.setHighlightedIndex(-1)};goog.ui.Palette.prototype.selectItem_=function(a,b){this.getElement()&&this.getRenderer().selectCell(this,a,b)};
  goog.ui.Palette.prototype.adjustSize_=function(){var a=this.getContent();if(a)if(this.size_&&this.size_.width){if(a=Math.ceil(a.length/this.size_.width),!goog.isNumber(this.size_.height)||this.size_.height<a)this.size_.height=a}else a=Math.ceil(Math.sqrt(a.length)),this.size_=new goog.math.Size(a,a);else this.size_=new goog.math.Size(0,0)};
  goog.ui.Palette.CurrentCell_=function(){goog.ui.Palette.CurrentCell_.base(this,"constructor",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(a){this.setHighlighted(a);return this.isHighlighted()==a};goog.ui.ColorPalette=function(a,b,c){this.colors_=a||[];goog.ui.Palette.call(this,null,b||goog.ui.PaletteRenderer.getInstance(),c);this.setColors(this.colors_)};goog.inherits(goog.ui.ColorPalette,goog.ui.Palette);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(a,b){this.colors_=a;this.labels_=b||null;this.normalizedColors_=null;this.setContent(this.createColorNodes())};goog.ui.ColorPalette.prototype.getSelectedColor=function(){var a=this.getSelectedItem();return a?(a=goog.style.getStyle(a,"background-color"),goog.ui.ColorPalette.parseColor_(a)):null};
  goog.ui.ColorPalette.prototype.setSelectedColor=function(a){a=goog.ui.ColorPalette.parseColor_(a);this.normalizedColors_||(this.normalizedColors_=goog.array.map(this.colors_,function(a){return goog.ui.ColorPalette.parseColor_(a)}));this.setSelectedIndex(a?goog.array.indexOf(this.normalizedColors_,a):-1)};
  goog.ui.ColorPalette.prototype.createColorNodes=function(){return goog.array.map(this.colors_,function(a,b){var c=this.getDomHelper().createDom("div",{"class":this.getRenderer().getCssClass()+"-colorswatch",style:"background-color:"+a});c.title=this.labels_&&this.labels_[b]?this.labels_[b]:"#"==a.charAt(0)?"RGB ("+goog.color.hexToRgb(a).join(", ")+")":a;return c},this)};goog.ui.ColorPalette.parseColor_=function(a){if(a)try{return goog.color.parse(a).hex}catch(b){}return null};goog.ui.ColorPicker=function(a,b){goog.ui.Component.call(this,a);this.colorPalette_=b||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(a){this.colorPalette_?this.colorPalette_.setColors(a):this.createColorPalette_(a)};goog.ui.ColorPicker.prototype.addColors=function(a){this.setColors(a)};goog.ui.ColorPicker.prototype.setSize=function(a){this.colorPalette_||this.createColorPalette_([]);this.colorPalette_.setSize(a)};goog.ui.ColorPicker.prototype.getSize=function(){return this.colorPalette_?this.colorPalette_.getSize():null};goog.ui.ColorPicker.prototype.setColumnCount=function(a){this.setSize(a)};
  goog.ui.ColorPicker.prototype.getSelectedIndex=function(){return this.colorPalette_?this.colorPalette_.getSelectedIndex():-1};goog.ui.ColorPicker.prototype.setSelectedIndex=function(a){this.colorPalette_&&this.colorPalette_.setSelectedIndex(a)};goog.ui.ColorPicker.prototype.getSelectedColor=function(){return this.colorPalette_?this.colorPalette_.getSelectedColor():null};goog.ui.ColorPicker.prototype.setSelectedColor=function(a){this.colorPalette_&&this.colorPalette_.setSelectedColor(a)};
  goog.ui.ColorPicker.prototype.isFocusable=function(){return this.focusable_};goog.ui.ColorPicker.prototype.setFocusable=function(a){this.focusable_=a;this.colorPalette_&&this.colorPalette_.setSupportedState(goog.ui.Component.State.FOCUSED,a)};goog.ui.ColorPicker.prototype.canDecorate=function(a){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(a){a.stopPropagation();this.dispatchEvent(goog.ui.ColorPicker.EventType.CHANGE)};goog.ui.ColorPicker.prototype.createColorPalette_=function(a){a=new goog.ui.ColorPalette(a,null,this.getDomHelper());a.setSize(goog.ui.ColorPicker.DEFAULT_NUM_COLS);a.setSupportedState(goog.ui.Component.State.FOCUSED,this.focusable_);this.addChild(a);this.colorPalette_=a;this.isInDocument()&&this.colorPalette_.render(this.getElement())};
  goog.ui.ColorPicker.createSimpleColorGrid=function(a){a=new goog.ui.ColorPicker(a);a.setSize(7);a.setColors(goog.ui.ColorPicker.SIMPLE_GRID_COLORS);return a};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(a,b){Blockly.FieldColour.superClass_.constructor.call(this,"\u00a0\u00a0\u00a0");this.changeHandler_=b;this.borderRect_.style.fillOpacity=1;this.setValue(a)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.prototype.CURSOR="default";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(a){this.colour_=a;this.borderRect_.style.fill=a;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(){Blockly.WidgetDiv.show(this,Blockly.FieldColour.widgetDispose_);var a=Blockly.WidgetDiv.DIV,b=new goog.ui.ColorPicker;b.setSize(Blockly.FieldColour.COLUMNS);b.setColors(Blockly.FieldColour.COLOURS);b.render(a);b.setSelectedColor(this.getValue());var c=Blockly.getAbsoluteXY_(this.borderRect_,this.getRootSVGElement_());if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){this.borderRect_.style.display="inline";var d=
  {x:this.borderRect_.getBBox().x,y:this.borderRect_.getBBox().y,width:this.borderRect_.scrollWidth,height:this.borderRect_.scrollHeight}}else d=this.borderRect_.getBBox();Blockly.RTL&&(c.x+=d.width);c.y+=d.height-1;Blockly.RTL&&(c.x-=a.offsetWidth);a.style.left=c.x+"px";a.style.top=c.y+"px";var e=this;Blockly.FieldColour.changeEventKey_=goog.events.listen(b,goog.ui.ColorPicker.EventType.CHANGE,function(a){a=a.target.getSelectedColor()||"#000000";Blockly.WidgetDiv.hide();if(e.changeHandler_){var b=
  e.changeHandler_(a);void 0!==b&&(a=b)}null!==a&&e.setValue(a)})};Blockly.FieldColour.widgetDispose_=function(){Blockly.FieldColour.changeEventKey_&&goog.events.unlistenByKey(Blockly.FieldColour.changeEventKey_)};Blockly.FieldTextInput=function(a,b){Blockly.FieldTextInput.superClass_.constructor.call(this,a);this.changeHandler_=b};goog.inherits(Blockly.FieldTextInput,Blockly.Field);Blockly.FieldTextInput.prototype.CURSOR="text";Blockly.FieldTextInput.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldTextInput.superClass_.dispose.call(this)};
  Blockly.FieldTextInput.prototype.setText=function(a){if(null!==a){if(this.changeHandler_){var b=this.changeHandler_(a);null!==b&&void 0!==b&&(a=b)}Blockly.Field.prototype.setText.call(this,a)}};
  Blockly.FieldTextInput.prototype.showEditor_=function(){Blockly.WidgetDiv.show(this,this.widgetDispose_());var a=Blockly.WidgetDiv.DIV,b=goog.dom.createDom("input","blocklyHtmlInput");this.changeHandler_===Blockly.FieldTextInput.numberValidator?(b.setAttribute("type","number"),b.setAttribute("step","any")):this.changeHandler_===Blockly.FieldTextInput.nonnegativeIntegerValidator&&(b.setAttribute("type","number"),b.setAttribute("pattern","\\d*"));Blockly.FieldTextInput.htmlInput_=b;a.appendChild(b);
  b.value=b.defaultValue=this.text_;b.oldValue_=null;this.validate_();this.resizeEditor_();b.focus();goog.userAgent.IPAD||goog.userAgent.IPHONE?b.setSelectionRange(0,9999):b.select();b.onKeyUpWrapper_=Blockly.bindEvent_(b,"keydown",this,function(a){a.stopPropagation()});b.onKeyUpWrapper_=Blockly.bindEvent_(b,"keyup",this,this.onHtmlInputChange_);b.onKeyPressWrapper_=Blockly.bindEvent_(b,"keypress",this,this.onHtmlInputChange_);a=this.sourceBlock_.blockSpace.getCanvas();b.onBlockSpaceChangeWrapper_=
  Blockly.bindEvent_(a,"blocklyBlockSpaceChange",this,this.resizeEditor_)};Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(a){var b=Blockly.FieldTextInput.htmlInput_;13==a.keyCode?(Blockly.WidgetDiv.hide(),a.preventDefault()):27==a.keyCode?(this.setText(b.defaultValue),Blockly.WidgetDiv.hide()):(a=b.value,a!==b.oldValue_?(b.oldValue_=a,this.setText(a),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render())};
  Blockly.FieldTextInput.prototype.validate_=function(){var a=!0;goog.asserts.assertObject(Blockly.FieldTextInput.htmlInput_);var b=Blockly.FieldTextInput.htmlInput_;this.changeHandler_&&(a=this.changeHandler_(b.value));null===a?Blockly.addClass_(b,"blocklyInvalidInput"):Blockly.removeClass_(b,"blocklyInvalidInput")};
  Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV;if(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident")){this.fieldGroup_.style.display="inline";var b={x:this.fieldGroup_.getBBox().x,y:this.fieldGroup_.getBBox().y,width:this.fieldGroup_.scrollWidth,height:this.fieldGroup_.scrollHeight}}else b=this.fieldGroup_.getBBox();a.style.width=b.width+"px";b=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 c={x:this.borderRect_.getBBox().x,y:this.borderRect_.getBBox().y,width:this.borderRect_.scrollWidth,height:this.borderRect_.scrollHeight}}else c=this.borderRect_.getBBox();b.x+=c.width;b.x-=a.offsetWidth}b.y+=1;goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
  Blockly.FieldTextInput.prototype.widgetDispose_=function(){var a=this;return function(){var b=Blockly.FieldTextInput.htmlInput_,c=b.value;a.changeHandler_&&(c=a.changeHandler_(c),null===c&&(c=b.defaultValue));a.setText(c);a.sourceBlock_.rendered&&a.sourceBlock_.render();Blockly.unbindEvent_(b.onKeyUpWrapper_);Blockly.unbindEvent_(b.onKeyPressWrapper_);Blockly.unbindEvent_(b.onBlockSpaceChangeWrapper_);Blockly.FieldTextInput.htmlInput_=null;Blockly.WidgetDiv.DIV.style.width="auto"}};
  Blockly.FieldTextInput.prototype.isKeyboardInputField_=function(){return!0};Blockly.FieldTextInput.numberValidator=function(a){a=(a||"").replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);return isNaN(a)?null:String(a)};Blockly.FieldTextInput.nonnegativeIntegerValidator=function(a){(a=Blockly.FieldTextInput.numberValidator(a))&&(a=String(Math.max(0,Math.floor(a))));return a};Blockly.Generator={};Blockly.Generator.NAME_TYPE="generated_function";Blockly.Generator.languages={};Blockly.Generator.get=function(a){if(!(a in Blockly.Generator.languages)){var b=new Blockly.CodeGenerator(a);Blockly.Generator.languages[a]=b}return Blockly.Generator.languages[a]};
  Blockly.Generator.blocksToCode=function(a,b,c){var d=[];a=Blockly.Generator.get(a);a.init();for(var e=0,f;f=b[e];e++){var g=a.blockToCode(f,c);g instanceof Array&&(g=g[0]);g&&(f.outputConnection&&a.scrubNakedValue&&(g=a.scrubNakedValue(g)),d.push(g))}d=d.join("\n");d=a.finish(d);d=d.replace(/^\s+\n/,"");d=d.replace(/\n\s+$/,"\n");return d=d.replace(/[ \t]+\n/g,"\n")};
  Blockly.Generator.blockSpaceToCode=function(a,b,c){var d;b?("string"==typeof b&&(b=[b]),d=goog.array.filter(Blockly.mainBlockSpace.getTopBlocks(!0),function(a){return goog.array.contains(b,a.type)},this)):d=Blockly.mainBlockSpace.getTopBlocks(!0);return Blockly.Generator.blocksToCode(a,d,c)};Blockly.Generator.prefixLines=function(a,b){return b+a.replace(/\n(.)/g,"\n"+b+"$1")};
  Blockly.Generator.allNestedComments=function(a){var b=[];a=a.getDescendants();for(var c=0;c<a.length;c++){var d=a[c].getCommentText();d&&b.push(d)}b.length&&b.push("");return b.join("\n")};Blockly.CodeGenerator=function(a){this.name_=a;this.RESERVED_WORDS_=""};
  Blockly.CodeGenerator.prototype.blockToCode=function(a,b){if(!a)return"";if(a.disabled||void 0!=b&&!b&&!a.isUserVisible()){var c=a.nextConnection&&a.nextConnection.targetBlock();return this.blockToCode(c,b)}c=this[a.type];if(!c)throw'Language "'+this.name_+'" does not know how to generate code for block type "'+a.type+'".';c=c.call(a);return c instanceof Array?[this.scrub_(a,c[0],b),c[1]]:this.scrub_(a,c,b)};
  Blockly.CodeGenerator.prototype.valueToCode=function(a,b,c){if(isNaN(c))throw'Expecting valid order from block "'+a.type+'".';a=a.getInputTargetBlock(b);if(!a)return"";var d=this.blockToCode(a);if(""===d)return"";if(!(d instanceof Array))throw'Expecting tuple from value block "'+a.type+'".';b=d[0];d=d[1];if(isNaN(d))throw'Expecting valid order from value block "'+a.type+'".';b&&c<=d&&(b="("+b+")");return b};
  Blockly.CodeGenerator.prototype.statementToCode=function(a,b){var c=a.getInputTargetBlock(b),d=this.blockToCode(c);if(!goog.isString(d))throw'Expecting code from statement block "'+c.type+'".';d&&(d=Blockly.Generator.prefixLines(d,"  "));return d};Blockly.CodeGenerator.prototype.addReservedWords=function(a){this.RESERVED_WORDS_+=a+","};goog.cssom={};goog.cssom.CssRuleType={STYLE:1,IMPORT:3,MEDIA:4,FONT_FACE:5,PAGE:6,NAMESPACE:7};goog.cssom.getAllCssText=function(a){return goog.cssom.getAllCss_(a||document.styleSheets,!0)};goog.cssom.getAllCssStyleRules=function(a){return goog.cssom.getAllCss_(a||document.styleSheets,!1)};goog.cssom.getCssRulesFromStyleSheet=function(a){var b=null;try{b=a.rules||a.cssRules}catch(c){if(15==c.code)throw c.styleSheet=a,c;}return b};
  goog.cssom.getAllCssStyleSheets=function(a,b){var c=[],d=a||document.styleSheets,e=goog.isDef(b)?b:!1;if(d.imports&&d.imports.length)for(var f=0,g=d.imports.length;f<g;f++)goog.array.extend(c,goog.cssom.getAllCssStyleSheets(d.imports[f]));else if(d.length)for(f=0,g=d.length;f<g;f++)goog.array.extend(c,goog.cssom.getAllCssStyleSheets(d[f]));else{var h=goog.cssom.getCssRulesFromStyleSheet(d);if(h&&h.length)for(var f=0,g=h.length,k;f<g;f++)k=h[f],k.styleSheet&&goog.array.extend(c,goog.cssom.getAllCssStyleSheets(k.styleSheet))}!(d.type||
  d.rules||d.cssRules)||d.disabled&&!e||c.push(d);return c};goog.cssom.getCssTextFromCssRule=function(a){var b="";a.cssText?b=a.cssText:a.style&&a.style.cssText&&a.selectorText&&(b=a.style.cssText.replace(/\s*-closure-parent-stylesheet:\s*\[object\];?\s*/gi,"").replace(/\s*-closure-rule-index:\s*[\d]+;?\s*/gi,""),b=a.selectorText+" { "+b+" }");return b};
  goog.cssom.getCssRuleIndexInParentStyleSheet=function(a,b){if(a.style&&a.style["-closure-rule-index"])return a.style["-closure-rule-index"];var c=b||goog.cssom.getParentStyleSheet(a);if(!c)throw Error("Cannot find a parentStyleSheet.");if((c=goog.cssom.getCssRulesFromStyleSheet(c))&&c.length)for(var d=0,e=c.length,f;d<e;d++)if(f=c[d],f==a)return d;return-1};goog.cssom.getParentStyleSheet=function(a){return a.parentStyleSheet||a.style&&a.style["-closure-parent-stylesheet"]};
  goog.cssom.replaceCssRule=function(a,b,c,d){if(c=c||goog.cssom.getParentStyleSheet(a))if(a=0<=d?d:goog.cssom.getCssRuleIndexInParentStyleSheet(a,c),0<=a)goog.cssom.removeCssRule(c,a),goog.cssom.addCssRule(c,b,a);else throw Error("Cannot proceed without the index of the cssRule.");else throw Error("Cannot proceed without the parentStyleSheet.");};
  goog.cssom.addCssRule=function(a,b,c){if(0>c||void 0==c)c=(a.cssRules||a.rules).length;if(a.insertRule)a.insertRule(b,c);else if(b=/^([^\{]+)\{([^\{]+)\}/.exec(b),3==b.length)a.addRule(b[1],b[2],c);else throw Error("Your CSSRule appears to be ill-formatted.");};goog.cssom.removeCssRule=function(a,b){a.deleteRule?a.deleteRule(b):a.removeRule(b)};
  goog.cssom.addCssText=function(a,b){var c=b?b.getDocument():goog.dom.getDocument(),d=c.createElement("style");d.type="text/css";c.getElementsByTagName("head")[0].appendChild(d);d.styleSheet?d.styleSheet.cssText=a:(c=c.createTextNode(a),d.appendChild(c));return d};goog.cssom.getFileNameFromStyleSheet=function(a){return(a=a.href)?/([^\/\?]+)[^\/]*$/.exec(a)[1]:null};
  goog.cssom.getAllCss_=function(a,b){for(var c=[],d=goog.cssom.getAllCssStyleSheets(a),e=0;a=d[e];e++){var f=goog.cssom.getCssRulesFromStyleSheet(a);if(f&&f.length){if(!b)var g=0;for(var h=0,k=f.length,l;h<k;h++)l=f[h],b&&!l.href?(l=goog.cssom.getCssTextFromCssRule(l),c.push(l)):l.href||(l.style&&(l.parentStyleSheet||(l.style["-closure-parent-stylesheet"]=a),l.style["-closure-rule-index"]=g),c.push(l)),b||g++}}return b?c.join(" "):c};Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed"};Blockly.Css.currentCursor_="";Blockly.Css.styleSheet_=null;Blockly.Css.inject=function(a){var b=Blockly.Css.CONTENT.join("\n"),b=b.replace(/%CONTAINER_ID%/g,a.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(b).sheet};
  Blockly.Css.setCursor=function(a,b){Blockly.readOnly||Blockly.Css.currentCursor_===a||(Blockly.Css.currentCursor_=a,b&&(a==Blockly.Css.Cursor.OPEN?Blockly.removeClass_(b.parentNode,"dragging"):Blockly.addClass_(b.parentNode,"dragging")))};
  Blockly.Css.CONTENT=[".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 {","  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: pointer;","  background-color: #fff;","  overflow: hidden;","}","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;","}",".blocklySpotlight>.blocklyPath {","  fill: #fc3;","}",".blocklySelected:not(.blocklyUndeletable)>.blocklyPath {","  stroke-width: 3px;","  stroke: #fc3;","}",".blocklySelected:not(.blocklyUndeletable)>.blocklyPathLight {",
  "  display: none;","}",".blocklyUndeletable>.blocklyEditableText>rect {","  fill-opacity: 1.0;","  fill: #ffdb74;","}",".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: default;","  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: default;",
  "  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;","}",".red-delete-button {","  background-color: #cc0000 !important;",
  "  border: 1px solid #cc0000 !important;","}",".blocklyIconShield {","  cursor: default;","  fill: #00c;","  stroke-width: 1px;","  stroke: #ccc;","}",".blocklyIconGroup:hover>.blocklyIconShield {","  fill: #00f;","  stroke: #fff;","}",".blocklyIconGroup:hover>.blocklyIconMark {","  fill: #fff;","}",".blocklyIconMark {","  cursor: default !important;","  font-family: sans-serif;","  font-size: 9pt;","  font-weight: bold;","  fill: #ccc;","  text-anchor: middle;","}",".blocklyWarningBody {","}",".blocklyMinimalBody {",
  "  margin: 0;","  padding: 0;","}",".blocklyCommentTextarea {","  margin: 0;","  padding: 2px;","  border: 0;","  resize: none;","  background-color: #ffc;","}",".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: default !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: "\u2713";',"}",".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: default;","  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: default;","}",".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: default;",
  "  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 {","  padding-right: 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: pointer;","  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: default;","}",".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(a,b){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=b;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(a){Blockly.WidgetDiv.isOwner(a)&&Blockly.WidgetDiv.hide()};Blockly.WidgetDiv.isOwner=function(a){return Blockly.WidgetDiv.owner_==a};
  Blockly.WidgetDiv.position=function(a,b,c,d){b<d.y&&(b=d.y);Blockly.RTL?a>c.width+d.x&&(a=c.width+d.x):a<d.x&&(a=d.x);Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px"};Blockly.FieldCheckbox=function(a,b){Blockly.FieldCheckbox.superClass_.constructor.call(this,"");this.changeHandler_=b;this.checkElement_=Blockly.createSvgElement("text",{"class":"blocklyText",x:-3},this.fieldGroup_);var c=document.createTextNode("\u2713");this.checkElement_.appendChild(c);this.setValue(a)};goog.inherits(Blockly.FieldCheckbox,Blockly.Field);Blockly.FieldCheckbox.prototype.CURSOR="default";Blockly.FieldCheckbox.prototype.getValue=function(){return String(this.state_).toUpperCase()};
  Blockly.FieldCheckbox.prototype.setValue=function(a){a="TRUE"==a;this.state_!==a&&(this.state_=a,this.checkElement_.style.display=a?"block":"none",this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.blockSpace.fireChangeEvent())};Blockly.FieldCheckbox.prototype.showEditor_=function(){var a=!this.state_;if(this.changeHandler_){var b=this.changeHandler_(a);void 0!==b&&(a=b)}null!==a&&this.setValue(String(a).toUpperCase())};Blockly.FieldParameter=function(a,b,c){Blockly.FieldParameter.superClass_.constructor.call(this,a,Blockly.FieldParameter.dropdownChange,Blockly.FieldParameter.dropdownCreate)};goog.inherits(Blockly.FieldParameter,Blockly.FieldVariable);Blockly.FieldParameter.dropdownCreate=function(){for(var a=[Blockly.Msg.RENAME_PARAMETER,Blockly.Msg.DELETE_PARAMETER],b=[],c=0;c<a.length;c++)b[c]=[a[c],a[c]];return b};
  Blockly.FieldParameter.dropdownChange=function(a){var b=this.getText();a===Blockly.Msg.RENAME_PARAMETER?(this.getParentEditor_().hideChaff(),Blockly.FieldVariable.modalPromptName(Blockly.Msg.RENAME_PARAMETER_TITLE.replace("%1",b),Blockly.Msg.CONFIRM_RENAME_VARIABLE,b,function(a){Blockly.Variables.renameVariable(b,a,this.sourceBlock_.blockSpace)}.bind(this))):a===Blockly.Msg.DELETE_PARAMETER&&Blockly.showSimpleDialog({bodyText:Blockly.Msg.DELETE_PARAMETER_TITLE.replace("%1",b),cancelText:Blockly.Msg.DELETE,
  confirmText:Blockly.Msg.KEEP,onConfirm:null,onCancel:function(){Blockly.Variables.deleteVariable(b,this.sourceBlock_.blockSpace)}.bind(this),cancelButtonClass:"red-delete-button"});return null};Blockly.inject=function(a,b,c){if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";b&&goog.mixin(Blockly,Blockly.parseOptions_(b));goog.ui.Component.setDefaultRightToLeft(Blockly.RTL);Blockly.Css.inject(a);c&&(Blockly.audioPlayer=c,Blockly.registerUISounds_(Blockly.audioPlayer));Blockly.mainBlockSpaceEditor=new Blockly.BlockSpaceEditor(a);Blockly.mainBlockSpace=Blockly.mainBlockSpaceEditor.blockSpace;Blockly.useModalFunctionEditor?Blockly.functionEditor=new Blockly.FunctionEditor:
  Blockly.useContractEditor&&(Blockly.functionEditor=new Blockly.ContractEditor({disableExamples:b&&b.disableExamples}),Blockly.contractEditor=Blockly.functionEditor);Blockly.focusedBlockSpace=Blockly.mainBlockSpace};
  Blockly.parseOptions_=function(a){var b,c,d,e,f,g=!!a.readOnly;g?(e=d=c=b=!1,f=null):((f=a.toolbox)?("string"!=typeof f&&"undefined"==typeof XSLTProcessor&&(f=f.outerHTML),"string"==typeof f&&(f=Blockly.Xml.textToDom(f)),b=!!f.getElementsByTagName("category").length):(f=null,b=!1),c=a.trashcan,void 0===c&&(c=b),d=a.collapse,void 0===d&&(d=b),e=a.grayOutUndeletableBlocks,void 0===e&&(e=!1));a.scrollbars&&(a.hasVerticalScrollbars=!0,a.hasHorizontalScrollbars=!0);return{RTL:!!a.rtl,collapse:d,readOnly:g,
  maxBlocks:a.maxBlocks||Infinity,assetUrl:a.assetUrl||function(a){return"./"+a},hasCategories:b,hasHorizontalScrollbars:a.hasHorizontalScrollbars,hasVerticalScrollbars:a.hasVerticalScrollbars,customSimpleDialog:a.customSimpleDialog,hasTrashcan:c,varsInGlobals:a.varsInGlobals||!1,languageTree:f,disableParamEditing:a.disableParamEditing||!1,disableVariableEditing:a.disableVariableEditing||!1,useModalFunctionEditor:a.useModalFunctionEditor||!1,useContractEditor:a.useContractEditor||!1,disableExamples:a.disableExamples||
  !1,defaultNumExampleBlocks:a.defaultNumExampleBlocks||0,grayOutUndeletableBlocks:e,editBlocks:a.editBlocks||!1,showExampleTestButtons:a.showExampleTestButtons||!1}};Blockly.registerUISounds_=function(a){a.register({id:"click",mp3:Blockly.assetUrl("media/click.mp3"),wav:Blockly.assetUrl("media/click.wav"),ogg:Blockly.assetUrl("media/click.ogg")});a.register({id:"delete",mp3:Blockly.assetUrl("media/delete.mp3"),wav:Blockly.assetUrl("media/delete.wav"),ogg:Blockly.assetUrl("media/delete.ogg")})};Blockly.FieldAngle=function(a,b){var c;if(b){var d=this;c=function(a){a=Blockly.FieldAngle.angleValidator.call(d,a);null!==a&&b.call(d,a);return a}}else c=Blockly.FieldAngle.angleValidator;this.symbol_=Blockly.createSvgElement("tspan",{},null);this.symbol_.appendChild(document.createTextNode("\u00b0"));Blockly.FieldAngle.superClass_.constructor.call(this,a,c)};goog.inherits(Blockly.FieldAngle,Blockly.FieldTextInput);Blockly.FieldAngle.HALF=50;Blockly.FieldAngle.RADIUS=Blockly.FieldAngle.HALF-1;
  Blockly.FieldAngle.prototype.dispose_=function(){var a=this;return function(){Blockly.FieldAngle.superClass_.dispose_.call(a)();a.gauge_=null;a.clickWrapper_&&Blockly.unbindEvent_(a.clickWrapper_);a.moveWrapper1_&&Blockly.unbindEvent_(a.moveWrapper1_);a.moveWrapper2_&&Blockly.unbindEvent_(a.moveWrapper2_)}};
  Blockly.FieldAngle.prototype.showEditor_=function(){Blockly.FieldAngle.superClass_.showEditor_.call(this);var a=Blockly.WidgetDiv.DIV;if(a.firstChild){var a=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"},a),b=Blockly.createSvgElement("circle",{cx:Blockly.FieldAngle.HALF,cy:Blockly.FieldAngle.HALF,r:Blockly.FieldAngle.RADIUS,
  "class":"blocklyAngleCircle"},a);this.gauge_=Blockly.createSvgElement("path",{"class":"blocklyAngleGuage"},a);for(var c=0;360>c;c+=15)Blockly.createSvgElement("line",{x1:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS,y1:Blockly.FieldAngle.HALF,x2:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS-(0==c%45?10:5),y2:Blockly.FieldAngle.HALF,"class":"blocklyAngleMarks",transform:"rotate("+c+", "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF+")"},a);a.style.marginLeft="-35px";this.clickWrapper_=
  Blockly.bindEvent_(a,"click",this,Blockly.WidgetDiv.hide);this.moveWrapper1_=Blockly.bindEvent_(b,"mousemove",this,this.onMouseMove);this.moveWrapper2_=Blockly.bindEvent_(this.gauge_,"mousemove",this,this.onMouseMove);this.updateGraph()}};
  Blockly.FieldAngle.prototype.onMouseMove=function(a){var b=this.gauge_.ownerSVGElement.getBoundingClientRect(),c=a.clientX-b.left-Blockly.FieldAngle.HALF;a=a.clientY-b.top-Blockly.FieldAngle.HALF;b=Math.atan(-a/c);isNaN(b)||(b=180*(b/Math.PI),0>c?b+=180:0<a&&(b+=360),b=String(Math.round(b)),Blockly.FieldTextInput.htmlInput_.value=b,this.setText(b))};
  Blockly.FieldAngle.prototype.setText=function(a){Blockly.FieldAngle.superClass_.setText.call(this,a);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 a=Number(this.getText())/180*Math.PI;if(isNaN(a))this.gauge_.setAttribute("d","M "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF);else{var b=Blockly.FieldAngle.HALF+Math.cos(a)*Blockly.FieldAngle.RADIUS,c=Blockly.FieldAngle.HALF+Math.sin(a)*-Blockly.FieldAngle.RADIUS;this.gauge_.setAttribute("d","M "+Blockly.FieldAngle.HALF+", "+Blockly.FieldAngle.HALF+" h "+Blockly.FieldAngle.RADIUS+" A "+Blockly.FieldAngle.RADIUS+","+
  Blockly.FieldAngle.RADIUS+" 0 "+(a>Math.PI?1:0)+" 0 "+b+","+c+" z")}}};Blockly.FieldAngle.angleValidator=function(a){a=Blockly.FieldTextInput.numberValidator(a);null!==a&&(a%=360,0>a&&(a+=360),a=String(a));return a};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=0.45;Blockly.HSV_VALUE=0.65;Blockly.makeColour=function(a,b,c){return goog.color.hsvToHex(a,b,256*c)};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.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(a){Blockly.audioPlayer&&Blockly.audioPlayer.play(a)};
  Blockly.removeAllRanges=function(){function a(){try{window.getSelection().removeAllRanges()}catch(a){}}if(window.getSelection){var b=window.getSelection();b&&b.removeAllRanges&&(a(),window.setTimeout(function(){a()},0))}};
  