text: /*
   protobuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
   Released under the Apache License, Version 2.0
   see: https://github.com/dcodeIO/protobuf.js for details
  */
  var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(e,p,d){if(d.get||d.set)throw new TypeError("ES3 does not support getters and setters.");e!=Array.prototype&&e!=Object.prototype&&(e[p]=d.value)};$jscomp.getGlobal=function(e){return"undefined"!=typeof window&&window===e?e:"undefined"!=typeof global&&null!=global?global:e};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
  $jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(e){return $jscomp.SYMBOL_PREFIX+(e||"")+$jscomp.symbolCounter_++};
  $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var e=$jscomp.global.Symbol.iterator;e||(e=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[e]&&$jscomp.defineProperty(Array.prototype,e,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(e){var p=0;return $jscomp.iteratorPrototype(function(){return p<e.length?{done:!1,value:e[p++]}:{done:!0}})};
  $jscomp.iteratorPrototype=function(e){$jscomp.initSymbolIterator();e={next:e};e[$jscomp.global.Symbol.iterator]=function(){return this};return e};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(e,p){$jscomp.initSymbolIterator();e instanceof String&&(e+="");var d=0,b={next:function(){if(d<e.length){var t=d++;return{value:p(t,e[t]),done:!1}}b.next=function(){return{done:!0,value:void 0}};return b.next()}};b[Symbol.iterator]=function(){return b};return b};
  $jscomp.polyfill=function(e,p,d,b){if(p){d=$jscomp.global;e=e.split(".");for(b=0;b<e.length-1;b++){var t=e[b];t in d||(d[t]={});d=d[t]}e=e[e.length-1];b=d[e];p=p(b);p!=b&&null!=p&&$jscomp.defineProperty(d,e,{configurable:!0,writable:!0,value:p})}};$jscomp.polyfill("Array.prototype.keys",function(e){return e?e:function(){return $jscomp.iteratorFromArray(this,function(e){return e})}},"es6-impl","es3");
  $jscomp.polyfill("Array.prototype.entries",function(e){return e?e:function(){return $jscomp.iteratorFromArray(this,function(e,d){return[e,d]})}},"es6-impl","es3");$jscomp.polyfill("Array.prototype.values",function(e){return e?e:function(){return $jscomp.iteratorFromArray(this,function(e,d){return d})}},"es6","es3");
  (function(e,p){"function"===typeof define&&define.amd?define(["bytebuffer"],p):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=p(require("bytebuffer"),!0):(e.dcodeIO=e.dcodeIO||{}).ProtoBuf=p(e.dcodeIO.ByteBuffer)})(this,function(e,p){var d={};d.ByteBuffer=e;d.Long=e.Long||null;d.VERSION="5.0.2";d.WIRE_TYPES={};d.WIRE_TYPES.VARINT=0;d.WIRE_TYPES.BITS64=1;d.WIRE_TYPES.LDELIM=2;d.WIRE_TYPES.STARTGROUP=3;d.WIRE_TYPES.ENDGROUP=4;d.WIRE_TYPES.BITS32=5;d.PACKABLE_WIRE_TYPES=
  [d.WIRE_TYPES.VARINT,d.WIRE_TYPES.BITS64,d.WIRE_TYPES.BITS32];d.TYPES={int32:{name:"int32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:d.WIRE_TYPES.VARINT,defaultValue:d.Long?d.Long.ZERO:void 0},uint64:{name:"uint64",wireType:d.WIRE_TYPES.VARINT,defaultValue:d.Long?d.Long.UZERO:void 0},sint64:{name:"sint64",wireType:d.WIRE_TYPES.VARINT,
  defaultValue:d.Long?d.Long.ZERO:void 0},bool:{name:"bool",wireType:d.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:d.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:d.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:d.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:d.WIRE_TYPES.BITS64,
  defaultValue:d.Long?d.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:d.WIRE_TYPES.BITS64,defaultValue:d.Long?d.Long.ZERO:void 0},"float":{name:"float",wireType:d.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:d.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:d.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:d.WIRE_TYPES.STARTGROUP,defaultValue:null}};d.MAP_KEY_TYPES=[d.TYPES.int32,d.TYPES.sint32,d.TYPES.sfixed32,d.TYPES.uint32,d.TYPES.fixed32,
  d.TYPES.int64,d.TYPES.sint64,d.TYPES.sfixed64,d.TYPES.uint64,d.TYPES.fixed64,d.TYPES.bool,d.TYPES.string,d.TYPES.bytes];d.ID_MIN=1;d.ID_MAX=536870911;d.convertFieldsToCamelCase=!1;d.populateAccessors=!0;d.populateDefaults=!0;d.Util=function(){var b={};b.IS_NODE=!("object"!==typeof process||"[object process]"!==process+""||process.browser);b.XHR=function(){for(var b=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},
  function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null,e=0;e<b.length;e++){try{d=b[e]()}catch(m){continue}break}if(!d)throw Error("XMLHttpRequest is not supported");return d};b.fetch=function(d,e){e&&"function"!=typeof e&&(e=null);if(b.IS_NODE){var t=require("fs");if(e)t.readFile(d,function(b,a){b?e(null):e(""+a)});else try{return t.readFileSync(d)}catch(n){return null}}else{var m=b.XHR();m.open("GET",d,e?!0:!1);m.setRequestHeader("Accept","text/plain");"function"===typeof m.overrideMimeType&&
  m.overrideMimeType("text/plain");if(e)m.onreadystatechange=function(){4==m.readyState&&(200==m.status||0==m.status&&"string"===typeof m.responseText?e(m.responseText):e(null))},4!=m.readyState&&m.send(null);else return m.send(null),200==m.status||0==m.status&&"string"===typeof m.responseText?m.responseText:null}};b.toCamelCase=function(b){return b.replace(/_([a-zA-Z])/g,function(b,d){return d.toUpperCase()})};return b}();d.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,
  TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,
  BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g};d.DotProto=function(b,d){function e(b,c){var l,a=1;"-"==b.charAt(0)&&(a=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))l=parseInt(b);else if(d.NUMBER_HEX.test(b))l=parseInt(b.substring(2),16);else if(d.NUMBER_OCT.test(b))l=
  parseInt(b.substring(1),8);else throw Error("illegal id value: "+(0>a?"-":"")+b);l=a*l|0;if(!c&&0>l)throw Error("illegal id value: "+(0>a?"-":"")+b);return l}function t(b){var c=1;"-"==b.charAt(0)&&(c=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))return c*parseInt(b,10);if(d.NUMBER_HEX.test(b))return c*parseInt(b.substring(2),16);if(d.NUMBER_OCT.test(b))return c*parseInt(b.substring(1),8);if("inf"===b)return Infinity*c;if("nan"===b)return NaN;if(d.NUMBER_FLT.test(b))return c*parseFloat(b);throw Error("illegal number value: "+
  (0>c?"-":"")+b);}function m(b,c,d){"undefined"===typeof b[c]?b[c]=d:(Array.isArray(b[c])||(b[c]=[b[c]]),b[c].push(d))}var n={},a=function(b){this.source=b+"";this.index=0;this.line=1;this.stack=[];this._stringOpen=null},g=a.prototype;g._readString=function(){var b='"'===this._stringOpen?d.STRING_DQ:d.STRING_SQ;b.lastIndex=this.index-1;var c=b.exec(this.source);if(!c)throw Error("unterminated string");this.index=b.lastIndex;this.stack.push(this._stringOpen);this._stringOpen=null;return c[1]};g.next=
  function(){if(0<this.stack.length)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var b,c;do{for(b=!1;d.WHITESPACE.test(c=this.source.charAt(this.index));)if("\n"===c&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index;
  ++this.line;b=!0}else if("*"===(c=this.source.charAt(this.index))){do{"\n"===c&&++this.line;if(++this.index===this.source.length)return null;b=c;c=this.source.charAt(this.index)}while("*"!==b||"/"!==c);++this.index;b=!0}else return"/"}while(b);if(this.index===this.source.length)return null;c=this.index;d.DELIM.lastIndex=0;if(!d.DELIM.test(this.source.charAt(c++)))for(;c<this.source.length&&!d.DELIM.test(this.source.charAt(c));)++c;c=this.source.substring(this.index,this.index=c);if('"'===c||"'"===
  c)this._stringOpen=c;return c};g.peek=function(){if(0===this.stack.length){var b=this.next();if(null===b)return null;this.stack.push(b)}return this.stack[0]};g.skip=function(b){var c=this.next();if(c!==b)throw Error("illegal '"+c+"', '"+b+"' expected");};g.omit=function(b){return this.peek()===b?(this.next(),!0):!1};g.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"};n.Tokenizer=a;var h=function(b){this.tn=new a(b);this.proto3=!1},g=h.prototype;g.parse=
  function(){var b={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{},services:[]},c,a=!0,e;try{for(;c=this.tn.next();)switch(c){case "package":if(!a||null!==b["package"])throw Error("unexpected 'package'");c=this.tn.next();if(!d.TYPEREF.test(c))throw Error("illegal package name: "+c);this.tn.skip(";");b["package"]=c;break;case "import":if(!a)throw Error("unexpected 'import'");c=this.tn.peek();("public"===c||(e="weak"===c))&&this.tn.next();c=this._readString();this.tn.skip(";");
  e||b.imports.push(c);break;case "syntax":if(!a)throw Error("unexpected 'syntax'");this.tn.skip("=");"proto3"===(b.syntax=this._readString())&&(this.proto3=!0);this.tn.skip(";");break;case "message":this._parseMessage(b,null);a=!1;break;case "enum":this._parseEnum(b);a=!1;break;case "option":this._parseOption(b);break;case "service":this._parseService(b);break;case "extend":this._parseExtend(b);break;default:throw Error("unexpected '"+c+"'");}}catch(u){throw u.message="Parse error at line "+this.tn.line+
  ": "+u.message,u;}delete b.name;return b};h.parse=function(b){return(new h(b)).parse()};g._readString=function(){var b="",c;do{c=this.tn.next();if("'"!==c&&'"'!==c)throw Error("illegal string delimiter: "+c);b+=this.tn.next();this.tn.skip(c);c=this.tn.peek()}while('"'===c||'"'===c);return b};g._readValue=function(b){var c=this.tn.peek();if('"'===c||"'"===c)return this._readString();this.tn.next();if(d.NUMBER.test(c))return t(c);if(d.BOOL.test(c))return"true"===c.toLowerCase();if(b&&d.TYPEREF.test(c))return c;
  throw Error("illegal value: "+c);};g._parseOption=function(b,c){var a=this.tn.next(),e=!1;"("===a&&(e=!0,a=this.tn.next());if(!d.TYPEREF.test(a))throw Error("illegal option name: "+a);var g=a;e&&(this.tn.skip(")"),g="("+g+")",a=this.tn.peek(),d.FQTYPEREF.test(a)&&(g+=a,this.tn.next()));this.tn.skip("=");this._parseOptionValue(b,g);c||this.tn.skip(";")};g._parseOptionValue=function(b,c){var a=this.tn.peek();if("{"!==a)m(b.options,c,this._readValue(!0));else for(this.tn.skip("{");"}"!==(a=this.tn.next());){if(!d.NAME.test(a))throw Error("illegal option name: "+
  c+"."+a);this.tn.omit(":")?m(b.options,c+"."+a,this._readValue(!0)):this._parseOptionValue(b,c+"."+a)}};g._parseService=function(b){var c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal service name at line "+this.tn.line+": "+c);var a={name:c,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(c=this.tn.next());)if("option"===c)this._parseOption(a);else if("rpc"===c)this._parseServiceRPC(a);else throw Error("illegal service token: "+c);this.tn.omit(";");b.services.push(a)};g._parseServiceRPC=
  function(b){var c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal rpc service method name: "+c);var a=c,e={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};this.tn.skip("(");c=this.tn.next();"stream"===c.toLowerCase()&&(e.request_stream=!0,c=this.tn.next());if(!d.TYPEREF.test(c))throw Error("illegal rpc service request type: "+c);e.request=c;this.tn.skip(")");c=this.tn.next();if("returns"!==c.toLowerCase())throw Error("illegal rpc service request type delimiter: "+
  c);this.tn.skip("(");c=this.tn.next();"stream"===c.toLowerCase()&&(e.response_stream=!0,c=this.tn.next());e.response=c;this.tn.skip(")");c=this.tn.peek();if("{"===c){for(this.tn.next();"}"!==(c=this.tn.next());)if("option"===c)this._parseOption(e);else throw Error("illegal rpc service token: "+c);this.tn.omit(";")}else this.tn.skip(";");"undefined"===typeof b.rpc&&(b.rpc={});b.rpc[a]=e};g._parseMessage=function(b,c){var a=!!c,g=this.tn.next(),h={name:"",fields:[],enums:[],messages:[],options:{},services:[],
  oneofs:{}};if(!d.NAME.test(g))throw Error("illegal "+(a?"group":"message")+" name: "+g);h.name=g;a&&(this.tn.skip("="),c.id=e(this.tn.next()),h.isGroup=!0);g=this.tn.peek();"["===g&&c&&this._parseFieldOptions(c);for(this.tn.skip("{");"}"!==(g=this.tn.next());)if(d.RULE.test(g))this._parseMessageField(h,g);else if("oneof"===g)this._parseMessageOneOf(h);else if("enum"===g)this._parseEnum(h);else if("message"===g)this._parseMessage(h);else if("option"===g)this._parseOption(h);else if("service"===g)this._parseService(h);
  else if("extensions"===g)h.hasOwnProperty("extensions")?h.extensions=h.extensions.concat(this._parseExtensionRanges()):h.extensions=this._parseExtensionRanges();else if("reserved"===g)this._parseIgnored();else if("extend"===g)this._parseExtend(h);else if(d.TYPEREF.test(g)){if(!this.proto3)throw Error("illegal field rule: "+g);this._parseMessageField(h,"optional",g)}else throw Error("illegal message token: "+g);this.tn.omit(";");b.messages.push(h);return h};g._parseIgnored=function(){for(;";"!==this.tn.peek();)this.tn.next();
  this.tn.skip(";")};g._parseMessageField=function(b,c,a){if(!d.RULE.test(c))throw Error("illegal message field rule: "+c);var g={rule:c,type:"",name:"",options:{},id:0};if("map"===c){if(a)throw Error("illegal type: "+a);this.tn.skip("<");c=this.tn.next();if(!d.TYPE.test(c)&&!d.TYPEREF.test(c))throw Error("illegal message field type: "+c);g.keytype=c;this.tn.skip(",");c=this.tn.next();if(!d.TYPE.test(c)&&!d.TYPEREF.test(c))throw Error("illegal message field: "+c);g.type=c;this.tn.skip(">");c=this.tn.next();
  if(!d.NAME.test(c))throw Error("illegal message field name: "+c);g.name=c;this.tn.skip("=");g.id=e(this.tn.next());c=this.tn.peek();"["===c&&this._parseFieldOptions(g);this.tn.skip(";")}else if(a="undefined"!==typeof a?a:this.tn.next(),"group"===a){c=this._parseMessage(b,g);if(!/^[A-Z]/.test(c.name))throw Error("illegal group name: "+c.name);g.type=c.name;g.name=c.name.toLowerCase();this.tn.omit(";")}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("illegal message field type: "+a);g.type=
  a;c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal message field name: "+c);g.name=c;this.tn.skip("=");g.id=e(this.tn.next());c=this.tn.peek();"["===c&&this._parseFieldOptions(g);this.tn.skip(";")}b.fields.push(g);return g};g._parseMessageOneOf=function(b){var c=this.tn.next();if(!d.NAME.test(c))throw Error("illegal oneof name: "+c);var a=c,g=[];for(this.tn.skip("{");"}"!==(c=this.tn.next());)c=this._parseMessageField(b,"optional",c),c.oneof=a,g.push(c.id);this.tn.omit(";");b.oneofs[a]=g};
  g._parseFieldOptions=function(b){this.tn.skip("[");for(var c=!0;"]"!==this.tn.peek();)c||this.tn.skip(","),this._parseOption(b,!0),c=!1;this.tn.next()};g._parseEnum=function(b){var c={name:"",values:[],options:{}},a=this.tn.next();if(!d.NAME.test(a))throw Error("illegal name: "+a);c.name=a;for(this.tn.skip("{");"}"!==(a=this.tn.next());)if("option"===a)this._parseOption(c);else{if(!d.NAME.test(a))throw Error("illegal name: "+a);this.tn.skip("=");var g={name:a,id:e(this.tn.next(),!0)},a=this.tn.peek();
  "["===a&&this._parseFieldOptions({options:{}});this.tn.skip(";");c.values.push(g)}this.tn.omit(";");b.enums.push(c)};g._parseExtensionRanges=function(){var a=[],c,d;do{for(d=[];;){c=this.tn.next();switch(c){case "min":c=b.ID_MIN;break;case "max":c=b.ID_MAX;break;default:c=t(c)}d.push(c);if(2===d.length)break;if("to"!==this.tn.peek()){d.push(c);break}this.tn.next()}a.push(d)}while(this.tn.omit(","));this.tn.skip(";");return a};g._parseExtend=function(b){var a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("illegal extend reference: "+
  a);var g={ref:a,fields:[]};for(this.tn.skip("{");"}"!==(a=this.tn.next());)if(d.RULE.test(a))this._parseMessageField(g,a);else if(d.TYPEREF.test(a)){if(!this.proto3)throw Error("illegal field rule: "+a);this._parseMessageField(g,"optional",a)}else throw Error("illegal extend token: "+a);this.tn.omit(";");b.messages.push(g);return g};g.toString=function(){return"Parser at line "+this.tn.line};n.Parser=h;return n}(d,d.Lang);d.Reflect=function(b){function d(f,k){if(f&&"number"===typeof f.low&&"number"===
  typeof f.high&&"boolean"===typeof f.unsigned&&f.low===f.low&&f.high===f.high)return new b.Long(f.low,f.high,"undefined"===typeof k?f.unsigned:k);if("string"===typeof f)return b.Long.fromString(f,k||!1,10);if("number"===typeof f)return b.Long.fromNumber(f,k||!1);throw Error("not convertible to Long");}function y(f,k){var a=k.readVarint32(),c=a&7,a=a>>>3;switch(c){case b.WIRE_TYPES.VARINT:do a=k.readUint8();while(128===(a&128));break;case b.WIRE_TYPES.BITS64:k.offset+=8;break;case b.WIRE_TYPES.LDELIM:a=
  k.readVarint32();k.offset+=a;break;case b.WIRE_TYPES.STARTGROUP:y(a,k);break;case b.WIRE_TYPES.ENDGROUP:if(a===f)return!1;throw Error("Illegal GROUPEND after unknown group: "+a+" ("+f+" expected)");case b.WIRE_TYPES.BITS32:k.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+f+": "+c);}return!0}var r={},m=function(b,k,a){this.builder=b;this.parent=k;this.name=a},n=m.prototype;n.fqn=function(){var b=this.name,k=this;do{k=k.parent;if(null==k)break;b=k.name+"."+b}while(1);return b};
  n.toString=function(b){return(b?this.className+" ":"")+this.fqn()};n.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};r.T=m;var a=function(b,k,a,c,d){m.call(this,b,k,a);this.className="Namespace";this.children=[];this.options=c||{};this.syntax=d||"proto2"},n=a.prototype=Object.create(m.prototype);n.getChildren=function(b){b=b||null;if(null==b)return this.children.slice();for(var f=[],a=0,c=this.children.length;a<c;++a)this.children[a]instanceof b&&f.push(this.children[a]);
  return f};n.addChild=function(b){var f;if(f=this.getChild(b.name))if(f instanceof l.Field&&f.name!==f.originalName&&null===this.getChild(f.originalName))f.name=f.originalName;else if(b instanceof l.Field&&b.name!==b.originalName&&null===this.getChild(b.originalName))b.name=b.originalName;else throw Error("Duplicate name in namespace "+this.toString(!0)+": "+b.name);this.children.push(b)};n.getChild=function(b){for(var f="number"===typeof b?"id":"name",a=0,c=this.children.length;a<c;++a)if(this.children[a][f]===
  b)return this.children[a];return null};n.resolve=function(b,a){var f="string"===typeof b?b.split("."):b,k=this,c=0;if(""===f[c]){for(;null!==k.parent;)k=k.parent;c++}do{do{if(!(k instanceof r.Namespace)){k=null;break}k=k.getChild(f[c]);if(!(k&&k instanceof r.T)||a&&!(k instanceof r.Namespace)){k=null;break}c++}while(c<f.length);if(null!=k)break;if(null!==this.parent)return this.parent.resolve(b,a)}while(null!=k);return k};n.qn=function(b){var f=[],a=b;do f.unshift(a.name),a=a.parent;while(null!==
  a);for(a=1;a<=f.length;a++){var c=f.slice(f.length-a);if(b===this.resolve(c,b instanceof r.Namespace))return c.join(".")}return b.fqn()};n.build=function(){for(var b={},k=this.children,c=0,d=k.length,g;c<d;++c)g=k[c],g instanceof a&&(b[g.name]=g.build());Object.defineProperty&&Object.defineProperty(b,"$options",{value:this.buildOpt()});return b};n.buildOpt=function(){for(var b={},a=Object.keys(this.options),c=0,d=a.length;c<d;++c)b[a[c]]=this.options[a[c]];return b};n.getOption=function(b){return"undefined"===
  typeof b?this.options:"undefined"!==typeof this.options[b]?this.options[b]:null};r.Namespace=a;var g=function(f,a,c,d,g){this.type=f;this.resolvedType=a;this.isMapKey=c;this.syntax=d;this.name=g;if(c&&0>b.MAP_KEY_TYPES.indexOf(f))throw Error("Invalid map key type: "+f.name);},h=g.prototype;g.defaultFieldValue=function(f){"string"===typeof f&&(f=b.TYPES[f]);if("undefined"===typeof f.defaultValue)throw Error("default value for type "+f.name+" is not supported");return f==b.TYPES.bytes?new e(0):f.defaultValue};
  h.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"};h.verifyValue=function(f){function a(b,f){throw Error("Illegal value for "+c.toString(!0)+" of type "+c.type.name+": "+b+" ("+f+")");}var c=this;switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:return("number"!==typeof f||f===f&&0!==f%1)&&a(typeof f,"not an integer"),4294967295<f?f|0:f;case b.TYPES.uint32:case b.TYPES.fixed32:return("number"!==typeof f||f===f&&0!==f%1)&&a(typeof f,"not an integer"),
  0>f?f>>>0:f;case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:if(b.Long)try{return d(f,!1)}catch(x){a(typeof f,x.message)}else a(typeof f,"requires Long.js");case b.TYPES.uint64:case b.TYPES.fixed64:if(b.Long)try{return d(f,!0)}catch(x){a(typeof f,x.message)}else a(typeof f,"requires Long.js");case b.TYPES.bool:return"boolean"!==typeof f&&a(typeof f,"not a boolean"),f;case b.TYPES["float"]:case b.TYPES["double"]:return"number"!==typeof f&&a(typeof f,"not a number"),f;case b.TYPES.string:return"string"===
  typeof f||f&&f instanceof String||a(typeof f,"not a string"),""+f;case b.TYPES.bytes:return e.isByteBuffer(f)?f:e.wrap(f,"base64");case b.TYPES["enum"]:for(var g=this.resolvedType.getChildren(b.Reflect.Enum.Value),h=0;h<g.length;h++)if(g[h].name==f||g[h].id==f)return g[h].id;if("proto3"===this.syntax)return("number"!==typeof f||f===f&&0!==f%1)&&a(typeof f,"not an integer"),(4294967295<f||0>f)&&a(typeof f,"not in range for uint32"),f;a(f,"not a valid enum value");case b.TYPES.group:case b.TYPES.message:f&&
  "object"===typeof f||a(typeof f,"object expected");if(f instanceof this.resolvedType.clazz)return f;if(f instanceof b.Builder.Message){var g={},h;for(h in f)f.hasOwnProperty(h)&&(g[h]=f[h]);f=g}return new this.resolvedType.clazz(f)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+f+" (undefined type "+this.type+")");};h.calculateLength=function(f,a){if(null===a)return 0;var c;switch(this.type){case b.TYPES.int32:return 0>a?e.calculateVarint64(a):e.calculateVarint32(a);case b.TYPES.uint32:return e.calculateVarint32(a);
  case b.TYPES.sint32:return e.calculateVarint32(e.zigZagEncode32(a));case b.TYPES.fixed32:case b.TYPES.sfixed32:case b.TYPES["float"]:return 4;case b.TYPES.int64:case b.TYPES.uint64:return e.calculateVarint64(a);case b.TYPES.sint64:return e.calculateVarint64(e.zigZagEncode64(a));case b.TYPES.fixed64:case b.TYPES.sfixed64:return 8;case b.TYPES.bool:return 1;case b.TYPES["enum"]:return e.calculateVarint32(a);case b.TYPES["double"]:return 8;case b.TYPES.string:return c=e.calculateUTF8Bytes(a),e.calculateVarint32(c)+
  c;case b.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return e.calculateVarint32(a.remaining())+a.remaining();case b.TYPES.message:return c=this.resolvedType.calculate(a),e.calculateVarint32(c)+c;case b.TYPES.group:return c=this.resolvedType.calculate(a),c+e.calculateVarint32(f<<3|b.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};h.encodeValue=function(f,
  a,c){if(null===a)return c;switch(this.type){case b.TYPES.int32:0>a?c.writeVarint64(a):c.writeVarint32(a);break;case b.TYPES.uint32:c.writeVarint32(a);break;case b.TYPES.sint32:c.writeVarint32ZigZag(a);break;case b.TYPES.fixed32:c.writeUint32(a);break;case b.TYPES.sfixed32:c.writeInt32(a);break;case b.TYPES.int64:case b.TYPES.uint64:c.writeVarint64(a);break;case b.TYPES.sint64:c.writeVarint64ZigZag(a);break;case b.TYPES.fixed64:c.writeUint64(a);break;case b.TYPES.sfixed64:c.writeInt64(a);break;case b.TYPES.bool:"string"===
  typeof a?c.writeVarint32("false"===a.toLowerCase()?0:!!a):c.writeVarint32(a?1:0);break;case b.TYPES["enum"]:c.writeVarint32(a);break;case b.TYPES["float"]:c.writeFloat32(a);break;case b.TYPES["double"]:c.writeFloat64(a);break;case b.TYPES.string:c.writeVString(a);break;case b.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");f=a.offset;c.writeVarint32(a.remaining());c.append(a);a.offset=f;break;case b.TYPES.message:f=(new e).LE();
  this.resolvedType.encode(a,f);c.writeVarint32(f.offset);c.append(f.flip());break;case b.TYPES.group:this.resolvedType.encode(a,c);c.writeVarint32(f<<3|b.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return c};h.decode=function(a,c,d){if(c!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case b.TYPES.int32:return a.readVarint32()|0;case b.TYPES.uint32:return a.readVarint32()>>>
  0;case b.TYPES.sint32:return a.readVarint32ZigZag()|0;case b.TYPES.fixed32:return a.readUint32()>>>0;case b.TYPES.sfixed32:return a.readInt32()|0;case b.TYPES.int64:return a.readVarint64();case b.TYPES.uint64:return a.readVarint64().toUnsigned();case b.TYPES.sint64:return a.readVarint64ZigZag();case b.TYPES.fixed64:return a.readUint64();case b.TYPES.sfixed64:return a.readInt64();case b.TYPES.bool:return!!a.readVarint32();case b.TYPES["enum"]:return a.readVarint32();case b.TYPES["float"]:return a.readFloat();
  case b.TYPES["double"]:return a.readDouble();case b.TYPES.string:return a.readVString();case b.TYPES.bytes:d=a.readVarint32();if(a.remaining()<d)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+d+" required but got only "+a.remaining());c=a.clone();c.limit=c.offset+d;a.offset+=d;return c;case b.TYPES.message:return d=a.readVarint32(),this.resolvedType.decode(a,d);case b.TYPES.group:return this.resolvedType.decode(a,-1,d)}throw Error("[INTERNAL] Illegal decode type");};h.valueFromString=
  function(a){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:case b.TYPES.uint32:case b.TYPES.fixed32:return this.verifyValue(parseInt(a));case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:case b.TYPES.uint64:case b.TYPES.fixed64:return this.verifyValue(a);case b.TYPES.bool:return"true"===a;case b.TYPES.string:return this.verifyValue(a);case b.TYPES.bytes:return e.fromBinary(a)}};
  h.valueToString=function(a){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===b.TYPES.bytes?a.toString("binary"):a.toString()};r.Element=g;var l=function(b,c,d,g,e,h){a.call(this,b,c,d,g,h);this.className="Message";this.extensions=void 0;this.clazz=null;this.isGroup=!!e;this._fieldsByName=this._fieldsById=this._fields=null},h=l.prototype=Object.create(a.prototype);h.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(b,a){function f(a,c,
  d,g){if(null===a||"object"!==typeof a){if(g&&g instanceof b.Reflect.Enum){var k=b.Reflect.Enum.getName(g.object,a);if(null!==k)return k}return a}if(e.isByteBuffer(a))return c?a.toBase64():a.toBuffer();if(b.Long.isLong(a))return d?a.toString():b.Long.fromValue(a);var h;if(Array.isArray(a))return h=[],a.forEach(function(b,a){h[a]=f(b,c,d,g)}),h;h={};if(a instanceof b.Map){for(var k=a.entries(),q=k.next();!q.done;q=k.next())h[a.keyElem.valueToString(q.value[0])]=f(q.value[1],c,d,a.valueElem.resolvedType);
  return h}var k=a.$type,q=void 0,l;for(l in a)a.hasOwnProperty(l)&&(k&&(q=k.getChild(l))?h[l]=f(a[l],c,d,q.resolvedType):h[l]=f(a[l],c,d));return h}var c=a.getChildren(b.Reflect.Message.Field),d=a.getChildren(b.Reflect.Message.OneOf),g=function(f,k){b.Builder.Message.call(this);for(var h=0,q=d.length;h<q;++h)this[d[h].name]=null;h=0;for(q=c.length;h<q;++h){var l=c[h];this[l.name]=l.repeated?[]:l.map?new b.Map(l):null;!l.required&&"proto3"!==a.syntax||null===l.defaultValue||(this[l.name]=l.defaultValue)}if(0<
  arguments.length)if(1!==arguments.length||null===f||"object"!==typeof f||!("function"!==typeof f.encode||f instanceof g)||Array.isArray(f)||f instanceof b.Map||e.isByteBuffer(f)||f instanceof ArrayBuffer||b.Long&&f instanceof b.Long)for(h=0,q=arguments.length;h<q;++h)"undefined"!==typeof(l=arguments[h])&&this.$set(c[h].name,l);else this.$set(f)},k=g.prototype=Object.create(b.Builder.Message.prototype);k.add=function(f,c,d){var g=a._fieldsByName[f];if(!d){if(!g)throw Error(this+"#"+f+" is undefined");
  if(!(g instanceof b.Reflect.Message.Field))throw Error(this+"#"+f+" is not a field: "+g.toString(!0));if(!g.repeated)throw Error(this+"#"+f+" is not a repeated field");c=g.verifyValue(c,!0)}null===this[f]&&(this[f]=[]);this[f].push(c);return this};k.$add=k.add;k.set=function(f,c,d){if(f&&"object"===typeof f){d=c;for(var g in f)f.hasOwnProperty(g)&&"undefined"!==typeof(c=f[g])&&void 0===a._oneofsByName[g]&&this.$set(g,c,d);return this}g=a._fieldsByName[f];if(d)this[f]=c;else{if(!g)throw Error(this+
  "#"+f+" is not a field: undefined");if(!(g instanceof b.Reflect.Message.Field))throw Error(this+"#"+f+" is not a field: "+g.toString(!0));this[g.name]=c=g.verifyValue(c)}g&&g.oneof&&(d=this[g.oneof.name],null!==c?(null!==d&&d!==g.name&&(this[d]=null),this[g.oneof.name]=g.name):d===f&&(this[g.oneof.name]=null));return this};k.$set=k.set;k.get=function(f,c){if(c)return this[f];var d=a._fieldsByName[f];if(!(d&&d instanceof b.Reflect.Message.Field))throw Error(this+"#"+f+" is not a field: undefined");
  if(!(d instanceof b.Reflect.Message.Field))throw Error(this+"#"+f+" is not a field: "+d.toString(!0));return this[d.name]};k.$get=k.get;for(var h=0;h<c.length;h++){var l=c[h];l instanceof b.Reflect.Message.ExtensionField||a.builder.options.populateAccessors&&function(b){var f=b.originalName.replace(/(_[a-zA-Z])/g,function(b){return b.toUpperCase().replace("_","")}),f=f.substring(0,1).toUpperCase()+f.substring(1),c=b.originalName.replace(/([A-Z])/g,function(b){return"_"+b}),d=function(a,f){this[b.name]=
  f?a:b.verifyValue(a);return this},g=function(){return this[b.name]};null===a.getChild("set"+f)&&(k["set"+f]=d);null===a.getChild("set_"+c)&&(k["set_"+c]=d);null===a.getChild("get"+f)&&(k["get"+f]=g);null===a.getChild("get_"+c)&&(k["get_"+c]=g)}(l)}k.encode=function(b,f){"boolean"===typeof b&&(f=b,b=void 0);var c=!1;b||(b=new e,c=!0);var d=b.littleEndian;try{return a.encode(this,b.LE(),f),(c?b.flip():b).LE(d)}catch(A){throw b.LE(d),A;}};g.encode=function(b,a,f){return(new g(b)).encode(a,f)};k.calculate=
  function(){return a.calculate(this)};k.encodeDelimited=function(b,f){var c=!1;b||(b=new e,c=!0);var d=(new e).LE();a.encode(this,d,f).flip();b.writeVarint32(d.remaining());b.append(d);return c?b.flip():b};k.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(q){throw q.encoded&&(q.encoded=q.encoded.toArrayBuffer()),q;}};k.toArrayBuffer=k.encodeAB;k.encodeNB=function(){try{return this.encode().toBuffer()}catch(q){throw q.encoded&&(q.encoded=q.encoded.toBuffer()),q;}};k.toBuffer=k.encodeNB;
  k.encode64=function(){try{return this.encode().toBase64()}catch(q){throw q.encoded&&(q.encoded=q.encoded.toBase64()),q;}};k.toBase64=k.encode64;k.encodeHex=function(){try{return this.encode().toHex()}catch(q){throw q.encoded&&(q.encoded=q.encoded.toHex()),q;}};k.toHex=k.encodeHex;k.toRaw=function(b,a){return f(this,!!b,!!a,this.$type)};k.encodeJSON=function(){return JSON.stringify(f(this,!0,!0,this.$type))};g.decode=function(b,f,c){"string"===typeof f&&(c=f,f=-1);"string"===typeof b?b=e.wrap(b,c?
  c:"base64"):e.isByteBuffer(b)||(b=e.wrap(b));c=b.littleEndian;try{var d=a.decode(b.LE(),f);b.LE(c);return d}catch(A){throw b.LE(c),A;}};g.decodeDelimited=function(b,f){"string"===typeof b?b=e.wrap(b,f?f:"base64"):e.isByteBuffer(b)||(b=e.wrap(b));if(1>b.remaining())return null;var c=b.offset,d=b.readVarint32();if(b.remaining()<d)return b.offset=c,null;try{var g=a.decode(b.slice(b.offset,b.offset+d).LE());b.offset+=d;return g}catch(B){throw b.offset+=d,B;}};g.decode64=function(b){return g.decode(b,
  "base64")};g.decodeHex=function(b){return g.decode(b,"hex")};g.decodeJSON=function(b){return new g(JSON.parse(b))};k.toString=function(){return a.toString()};Object.defineProperty&&(Object.defineProperty(g,"$options",{value:a.buildOpt()}),Object.defineProperty(k,"$options",{value:g.$options}),Object.defineProperty(g,"$type",{value:a}),Object.defineProperty(k,"$type",{value:a}));return g}(b,this);this._fields=[];this._fieldsById={};this._fieldsByName={};this._oneofsByName={};for(var f=0,c=this.children.length,
  d;f<c;f++)if(d=this.children[f],d instanceof v||d instanceof l||d instanceof u){if(a.hasOwnProperty(d.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+d.toString(!0)+" cannot override static property '"+d.name+"'");a[d.name]=d.build()}else if(d instanceof l.Field)d.build(),this._fields.push(d),this._fieldsById[d.id]=d,this._fieldsByName[d.name]=d;else if(d instanceof l.OneOf)this._oneofsByName[d.name]=d;else if(!(d instanceof l.OneOf||d instanceof w))throw Error("Illegal reflect child of "+
  this.toString(!0)+": "+this.children[f].toString(!0));return this.clazz=a};h.encode=function(b,a,c){for(var f=null,d,g=0,k=this._fields.length,h;g<k;++g)d=this._fields[g],h=b[d.name],d.required&&null===h?null===f&&(f=d):d.encode(c?h:d.verifyValue(h),a,b);if(null!==f)throw b=Error("Missing at least one required field for "+this.toString(!0)+": "+f),b.encoded=a,b;return a};h.calculate=function(b){for(var a=0,f=0,c=this._fields.length,d,g;f<c;++f){d=this._fields[f];g=b[d.name];if(d.required&&null===
  g)throw Error("Missing at least one required field for "+this.toString(!0)+": "+d);a+=d.calculate(g,b)}return a};h.decode=function(a,c,d){"number"!==typeof c&&(c=-1);for(var f=a.offset,g=new this.clazz,k,h,e;a.offset<f+c||-1===c&&0<a.remaining();){k=a.readVarint32();h=k&7;e=k>>>3;if(h===b.WIRE_TYPES.ENDGROUP){if(e!==d)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+e+" ("+(d?d+" expected":"not a group")+")");break}if(k=this._fieldsById[e])k.repeated&&!k.options.packed?g[k.name].push(k.decode(h,
  a)):k.map?(h=k.decode(h,a),g[k.name].set(h[0],h[1])):(g[k.name]=k.decode(h,a),k.oneof&&(h=g[k.oneof.name],null!==h&&h!==k.name&&(g[h]=null),g[k.oneof.name]=k.name));else switch(h){case b.WIRE_TYPES.VARINT:a.readVarint32();break;case b.WIRE_TYPES.BITS32:a.offset+=4;break;case b.WIRE_TYPES.BITS64:a.offset+=8;break;case b.WIRE_TYPES.LDELIM:k=a.readVarint32();a.offset+=k;break;case b.WIRE_TYPES.STARTGROUP:for(;y(e,a););break;default:throw Error("Illegal wire type for unknown field "+e+" in "+this.toString(!0)+
  "#decode: "+h);}}a=0;for(c=this._fields.length;a<c;++a)if(k=this._fields[a],null===g[k.name])if("proto3"===this.syntax)g[k.name]=k.defaultValue;else{if(k.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+k.name),a.decoded=g,a;b.populateDefaults&&null!==k.defaultValue&&(g[k.name]=k.defaultValue)}return g};r.Message=l;var c=function(a,c,d,g,h,e,n,t,w,y){m.call(this,a,c,e);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;
  this.map="map"===d;this.keyType=g||null;this.type=h;this.resolvedType=null;this.id=n;this.options=t||{};this.defaultValue=null;this.oneof=w||null;this.syntax=y||"proto2";this.originalName=this.name;this.keyElement=this.element=null;!this.builder.options.convertFieldsToCamelCase||this instanceof l.ExtensionField||(this.name=b.Util.toCamelCase(this.name))},h=c.prototype=Object.create(m.prototype);h.build=function(){this.element=new g(this.type,this.resolvedType,!1,this.syntax,this.name);this.map&&(this.keyElement=
  new g(this.keyType,void 0,!0,this.syntax,this.name));"proto3"!==this.syntax||this.repeated||this.map?"undefined"!==typeof this.options["default"]&&(this.defaultValue=this.verifyValue(this.options["default"])):this.defaultValue=g.defaultFieldValue(this.type)};h.verifyValue=function(a,c){function f(b,a){throw Error("Illegal value for "+d.toString(!0)+" of type "+d.type.name+": "+b+" ("+a+")");}c=c||!1;var d=this;if(null===a)return this.required&&f(typeof a,"required"),"proto3"===this.syntax&&this.type!==
  b.TYPES.message&&f(typeof a,"proto3 field without field presence cannot be null"),null;var g;if(this.repeated&&!c){Array.isArray(a)||(a=[a]);var k=[];for(g=0;g<a.length;g++)k.push(this.element.verifyValue(a[g]));return k}if(this.map&&!c){if(a instanceof b.Map)return a;a instanceof Object||f(typeof a,"expected ProtoBuf.Map or raw object for map field");return new b.Map(this,a)}!this.repeated&&Array.isArray(a)&&f(typeof a,"no array expected");return this.element.verifyValue(a)};h.hasWirePresence=function(a,
  c){if("proto3"!==this.syntax)return null!==a;if(this.oneof&&c[this.oneof.name]===this.name)return!0;switch(this.type){case b.TYPES.int32:case b.TYPES.sint32:case b.TYPES.sfixed32:case b.TYPES.uint32:case b.TYPES.fixed32:return 0!==a;case b.TYPES.int64:case b.TYPES.sint64:case b.TYPES.sfixed64:case b.TYPES.uint64:case b.TYPES.fixed64:return 0!==a.low||0!==a.high;case b.TYPES.bool:return a;case b.TYPES["float"]:case b.TYPES["double"]:return 0!==a;case b.TYPES.string:return 0<a.length;case b.TYPES.bytes:return 0<
  a.remaining();case b.TYPES["enum"]:return 0!==a;case b.TYPES.message:return null!==a;default:return!0}};h.encode=function(a,c,d){if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return c;try{if(this.repeated){var f;if(this.options.packed&&0<=b.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){c.writeVarint32(this.id<<3|b.WIRE_TYPES.LDELIM);c.ensureCapacity(c.offset+=1);var g=c.offset;
  for(f=0;f<a.length;f++)this.element.encodeValue(this.id,a[f],c);var h=c.offset-g,k=e.calculateVarint32(h);if(1<k){var l=c.slice(g,c.offset),g=g+(k-1);c.offset=g;c.append(l)}c.writeVarint32(h,g-k)}else for(f=0;f<a.length;f++)c.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,a[f],c)}else this.map?a.forEach(function(a,d,f){f=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,d)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,
  a);c.writeVarint32(this.id<<3|b.WIRE_TYPES.LDELIM);c.writeVarint32(f);c.writeVarint32(8|this.keyType.wireType);this.keyElement.encodeValue(1,d,c);c.writeVarint32(16|this.type.wireType);this.element.encodeValue(2,a,c)},this):this.hasWirePresence(a,d)&&(c.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,a,c))}catch(C){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+C+")");}return c};h.calculate=function(a,c){a=this.verifyValue(a);if(null===this.type||"object"!==
  typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var d=0;try{if(this.repeated){var f,g;if(this.options.packed&&0<=b.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){d+=e.calculateVarint32(this.id<<3|b.WIRE_TYPES.LDELIM);for(f=g=0;f<a.length;f++)g+=this.element.calculateLength(this.id,a[f]);d+=e.calculateVarint32(g);d+=g}else for(f=0;f<a.length;f++)d+=e.calculateVarint32(this.id<<3|this.type.wireType),d+=
  this.element.calculateLength(this.id,a[f])}else this.map?a.forEach(function(a,c,f){a=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,c)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,a);d+=e.calculateVarint32(this.id<<3|b.WIRE_TYPES.LDELIM);d+=e.calculateVarint32(a);d+=a},this):this.hasWirePresence(a,c)&&(d+=e.calculateVarint32(this.id<<3|this.type.wireType),d+=this.element.calculateLength(this.id,a))}catch(x){throw Error("Illegal value for "+
  this.toString(!0)+": "+a+" ("+x+")");}return d};h.decode=function(a,c,d){if(!(!this.map&&a==this.type.wireType||!d&&this.repeated&&this.options.packed&&a==b.WIRE_TYPES.LDELIM||this.map&&a==b.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==b.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=b.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!d){a=c.readVarint32();a=c.offset+a;for(d=[];c.offset<a;)d.push(this.decode(this.type.wireType,
  c,!0));return d}if(this.map){var f=g.defaultFieldValue(this.keyType);d=g.defaultFieldValue(this.type);a=c.readVarint32();if(c.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+c.remaining());var h=c.clone();h.limit=h.offset+a;for(c.offset+=a;0<h.remaining();)if(c=h.readVarint32(),a=c&7,c>>>=3,1===c)f=this.keyElement.decode(h,a,c);else if(2===c)d=this.element.decode(h,a,c);else throw Error("Unexpected tag in map field key/value submessage");
  return[f,d]}return this.element.decode(c,a,this.id)};r.Message.Field=c;h=function(a,b,d,g,h,e,l){c.call(this,a,b,d,null,g,h,e,l)};h.prototype=Object.create(c.prototype);r.Message.ExtensionField=h;r.Message.OneOf=function(a,b,c){m.call(this,a,b,c);this.fields=[]};var v=function(b,c,d,g,h){a.call(this,b,c,d,g,h);this.className="Enum";this.object=null};v.getName=function(a,b){for(var c=Object.keys(a),d=0,g;d<c.length;++d)if(a[g=c[d]]===b)return g;return null};(v.prototype=Object.create(a.prototype)).build=
  function(a){if(this.object&&!a)return this.object;a=new b.Builder.Enum;for(var c=this.getChildren(v.Value),d=0,g=c.length;d<g;++d)a[c[d].name]=c[d].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1});return this.object=a};r.Enum=v;h=function(a,b,c,d){m.call(this,a,b,c);this.className="Enum.Value";this.id=d};h.prototype=Object.create(m.prototype);r.Enum.Value=h;var w=function(a,b,c,d){m.call(this,a,b,c);this.field=d};w.prototype=Object.create(m.prototype);
  r.Extension=w;var u=function(b,c,d,g){a.call(this,b,c,d,g);this.className="Service";this.clazz=null};(u.prototype=Object.create(a.prototype)).build=function(a){return this.clazz&&!a?this.clazz:this.clazz=function(a,b){for(var c=function(b){a.Builder.Service.call(this);this.rpcImpl=b||function(a,b,c){setTimeout(c.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},d=c.prototype=Object.create(a.Builder.Service.prototype),g=b.getChildren(a.Reflect.Service.RPCMethod),
  f=0;f<g.length;f++)(function(a){d[a.name]=function(c,d){try{try{c=a.resolvedRequestType.clazz.decode(e.wrap(c))}catch(z){if(!(z instanceof TypeError))throw z;}if(null===c||"object"!==typeof c)throw Error("Illegal arguments");c instanceof a.resolvedRequestType.clazz||(c=new a.resolvedRequestType.clazz(c));this.rpcImpl(a.fqn(),c,function(c,g){if(c)d(c);else{null===g&&(g="");try{g=a.resolvedResponseType.clazz.decode(g)}catch(D){}g&&g instanceof a.resolvedResponseType.clazz?d(null,g):d(Error("Illegal response type received in service method "+
  b.name+"#"+a.name))}})}catch(z){setTimeout(d.bind(this,z),0)}};c[a.name]=function(b,d,g){(new c(b))[a.name](d,g)};Object.defineProperty&&(Object.defineProperty(c[a.name],"$options",{value:a.buildOpt()}),Object.defineProperty(d[a.name],"$options",{value:c[a.name].$options}))})(g[f]);Object.defineProperty&&(Object.defineProperty(c,"$options",{value:b.buildOpt()}),Object.defineProperty(d,"$options",{value:c.$options}),Object.defineProperty(c,"$type",{value:b}),Object.defineProperty(d,"$type",{value:b}));
  return c}(b,this)};r.Service=u;var p=function(a,b,c,d){m.call(this,a,b,c);this.className="Service.Method";this.options=d||{}};(p.prototype=Object.create(m.prototype)).buildOpt=n.buildOpt;r.Service.Method=p;n=function(a,b,c,d,g,h,e,l){p.call(this,a,b,c,l);this.className="Service.RPCMethod";this.requestName=d;this.responseName=g;this.requestStream=h;this.responseStream=e;this.resolvedResponseType=this.resolvedRequestType=null};n.prototype=Object.create(p.prototype);r.Service.RPCMethod=n;return r}(d);
  d.Builder=function(b,d,e){function t(a){a.messages&&a.messages.forEach(function(b){b.syntax=a.syntax;t(b)});a.enums&&a.enums.forEach(function(b){b.syntax=a.syntax})}var m=function(a){this.ptr=this.ns=new e.Namespace(this,null,"");this.resolved=!1;this.result=null;this.files={};this.importRoot=null;this.options=a||{}},n=m.prototype;m.isMessage=function(a){return"string"!==typeof a.name||"undefined"!==typeof a.values||"undefined"!==typeof a.rpc?!1:!0};m.isMessageField=function(a){return"string"!==typeof a.rule||
  "string"!==typeof a.name||"string"!==typeof a.type||"undefined"===typeof a.id?!1:!0};m.isEnum=function(a){return"string"===typeof a.name&&"undefined"!==typeof a.values&&Array.isArray(a.values)&&0!==a.values.length?!0:!1};m.isService=function(a){return"string"===typeof a.name&&"object"===typeof a.rpc&&a.rpc?!0:!1};m.isExtend=function(a){return"string"!==typeof a.ref?!1:!0};n.reset=function(){this.ptr=this.ns;return this};n.define=function(a){if("string"!==typeof a||!d.TYPEREF.test(a))throw Error("illegal namespace: "+
  a);a.split(".").forEach(function(a){var b=this.ptr.getChild(a);null===b&&this.ptr.addChild(b=new e.Namespace(this,this.ptr,a));this.ptr=b},this);return this};n.create=function(a){if(!a)return this;if(Array.isArray(a)){if(0===a.length)return this;a=a.slice()}else a=[a];for(var d=[a];0<d.length;){a=d.pop();if(!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;0<a.length;){var h=a.shift();if(m.isMessage(h)){var l=new e.Message(this,this.ptr,h.name,h.options,h.isGroup,h.syntax),
  c={};h.oneofs&&Object.keys(h.oneofs).forEach(function(a){l.addChild(c[a]=new e.Message.OneOf(this,l,a))},this);h.fields&&h.fields.forEach(function(a){if(null!==l.getChild(a.id|0))throw Error("duplicate or invalid field id in "+l.name+": "+a.id);if(a.options&&"object"!==typeof a.options)throw Error("illegal field options in "+l.name+"#"+a.name);var b=null;if("string"===typeof a.oneof&&!(b=c[a.oneof]))throw Error("illegal oneof in "+l.name+"#"+a.name+": "+a.oneof);a=new e.Message.Field(this,l,a.rule,
  a.keytype,a.type,a.name,a.id,a.options,b,h.syntax);b&&b.fields.push(a);l.addChild(a)},this);var n=[];h.enums&&h.enums.forEach(function(a){n.push(a)});h.messages&&h.messages.forEach(function(a){n.push(a)});h.services&&h.services.forEach(function(a){n.push(a)});h.extensions&&(l.extensions="number"===typeof h.extensions[0]?[h.extensions]:h.extensions);this.ptr.addChild(l);if(0<n.length){d.push(a);a=n;n=null;this.ptr=l;l=null;continue}n=null}else if(m.isEnum(h))l=new e.Enum(this,this.ptr,h.name,h.options,
  h.syntax),h.values.forEach(function(a){l.addChild(new e.Enum.Value(this,l,a.name,a.id))},this),this.ptr.addChild(l);else if(m.isService(h))l=new e.Service(this,this.ptr,h.name,h.options),Object.keys(h.rpc).forEach(function(a){var b=h.rpc[a];l.addChild(new e.Service.RPCMethod(this,l,a,b.request,b.response,!!b.request_stream,!!b.response_stream,b.options))},this),this.ptr.addChild(l);else if(m.isExtend(h))if(l=this.ptr.resolve(h.ref,!0))h.fields.forEach(function(a){if(null!==l.getChild(a.id|0))throw Error("duplicate extended field id in "+
  l.name+": "+a.id);if(l.extensions){var c=!1;l.extensions.forEach(function(b){a.id>=b[0]&&a.id<=b[1]&&(c=!0)});if(!c)throw Error("illegal extended field id in "+l.name+": "+a.id+" (not within valid ranges)");}var d=a.name;this.options.convertFieldsToCamelCase&&(d=b.Util.toCamelCase(d));var d=new e.Message.ExtensionField(this,l,a.rule,a.type,this.ptr.fqn()+"."+d,a.id,a.options),g=new e.Extension(this,this.ptr,a.name,d);d.extension=g;this.ptr.addChild(g);l.addChild(d)},this);else{if(!/\.?google\.protobuf\./.test(h.ref))throw Error("extended message "+
  h.ref+" is not defined");}else throw Error("not a valid definition: "+JSON.stringify(h));l=h=null}a=null;this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(a,d){var g="/";if("string"===typeof d){b.Util.IS_NODE&&(d=require("path").resolve(d));if(!0===this.files[d])return this.reset();this.files[d]=!0}else if("object"===typeof d){var e=d.root;b.Util.IS_NODE&&(e=require("path").resolve(e));if(0<=e.indexOf("\\")||0<=d.file.indexOf("\\"))g="\\";e=b.Util.IS_NODE?
  require("path").join(e,d.file):e+g+d.file;if(!0===this.files[e])return this.reset();this.files[e]=!0}if(a.imports&&0<a.imports.length){var c=!1;if("object"===typeof d){if(this.importRoot=d.root,c=!0,e=this.importRoot,d=d.file,0<=e.indexOf("\\")||0<=d.indexOf("\\"))g="\\"}else"string"===typeof d?this.importRoot?e=this.importRoot:0<=d.indexOf("/")?(e=d.replace(/\/[^\/]*$/,""),""===e&&(e="/")):0<=d.indexOf("\\")?(e=d.replace(/\\[^\\]*$/,""),g="\\"):e=".":e=null;for(var n=0;n<a.imports.length;n++)if("string"===
  typeof a.imports[n]){if(!e)throw Error("cannot determine import root");var m=a.imports[n];if("google/protobuf/descriptor.proto"!==m&&(m=b.Util.IS_NODE?require("path").join(e,m):e+g+m,!0!==this.files[m])){/\.proto$/i.test(m)&&!b.DotProto&&(m=m.replace(/\.proto$/,".json"));var r=b.Util.fetch(m);if(null===r)throw Error("failed to import '"+m+"' in '"+d+"': file not found");if(/\.json$/i.test(m))this["import"](JSON.parse(r+""),m);else this["import"](b.DotProto.Parser.parse(r),m)}}else if(d)if(/\.(\w+)$/.test(d))this["import"](a.imports[n],
  d.replace(/^(.+)\.(\w+)$/,function(a,b,c){return b+"_import"+n+"."+c}));else this["import"](a.imports[n],d+"_import"+n);else this["import"](a.imports[n]);c&&(this.importRoot=null)}a["package"]&&this.define(a["package"]);a.syntax&&t(a);var p=this.ptr;a.options&&Object.keys(a.options).forEach(function(b){p.options[b]=a.options[b]});a.messages&&(this.create(a.messages),this.ptr=p);a.enums&&(this.create(a.enums),this.ptr=p);a.services&&(this.create(a.services),this.ptr=p);a["extends"]&&this.create(a["extends"]);
  return this.reset()};n.resolveAll=function(){var a;if(null==this.ptr||"object"===typeof this.ptr.type)return this;if(this.ptr instanceof e.Namespace)this.ptr.children.forEach(function(a){this.ptr=a;this.resolveAll()},this);else if(this.ptr instanceof e.Message.Field){if(d.TYPE.test(this.ptr.type))this.ptr.type=b.TYPES[this.ptr.type];else{if(!d.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);a=(this.ptr instanceof e.Message.ExtensionField?
  this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0);if(!a)throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=a;if(a instanceof e.Enum){if(this.ptr.type=b.TYPES["enum"],"proto3"===this.ptr.syntax&&"proto3"!==a.syntax)throw Error("proto3 message cannot reference proto2 enum");}else if(a instanceof e.Message)this.ptr.type=a.isGroup?b.TYPES.group:b.TYPES.message;else throw Error("illegal type reference in "+this.ptr.toString(!0)+
  ": "+this.ptr.type);}if(this.ptr.map){if(!d.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=b.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==b.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof b.Reflect.Service.Method)if(this.ptr instanceof b.Reflect.Service.RPCMethod){a=this.ptr.parent.resolve(this.ptr.requestName,
  !0);if(!(a&&a instanceof b.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=a;a=this.ptr.parent.resolve(this.ptr.responseName,!0);if(!(a&&a instanceof b.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=a}else throw Error("illegal service type in "+this.ptr.toString(!0));else if(!(this.ptr instanceof b.Reflect.Message.OneOf||
  this.ptr instanceof b.Reflect.Extension||this.ptr instanceof b.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()};n.build=function(a){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null===this.result&&(this.result=this.ns.build());if(!a)return this.result;a="string"===typeof a?a.split("."):a;for(var b=this.result,d=0;d<a.length;d++)if(b[a[d]])b=b[a[d]];else{b=null;break}return b};n.lookup=function(a,
  b){return a?this.ns.resolve(a,b):this.ns};n.toString=function(){return"Builder"};m.Message=function(){};m.Enum=function(){};m.Service=function(){};return m}(d,d.Lang,d.Reflect);d.Map=function(b,d){function e(b){var a=0;return{next:function(){return a<b.length?{done:!1,value:b[a++]}:{done:!0}}}}var t=function(b,a){if(!b.map)throw Error("field is not a map");this.field=b;this.keyElem=new d.Element(b.keyType,null,!0,b.syntax);this.valueElem=new d.Element(b.type,b.resolvedType,!1,b.syntax);this.map={};
  Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}});if(a)for(var g=Object.keys(a),e=0;e<g.length;e++){var l=this.keyElem.valueFromString(g[e]),c=this.valueElem.verifyValue(a[g[e]]);this.map[this.keyElem.valueToString(l)]={key:l,value:c}}},m=t.prototype;m.clear=function(){this.map={}};m["delete"]=function(b){b=this.keyElem.valueToString(this.keyElem.verifyValue(b));var a=b in this.map;delete this.map[b];return a};m.entries=function(){for(var b=[],a=Object.keys(this.map),
  d=0,h;d<a.length;d++)b.push([(h=this.map[a[d]]).key,h.value]);return e(b)};m.keys=function(){for(var b=[],a=Object.keys(this.map),d=0;d<a.length;d++)b.push(this.map[a[d]].key);return e(b)};m.values=function(){for(var b=[],a=Object.keys(this.map),d=0;d<a.length;d++)b.push(this.map[a[d]].value);return e(b)};m.forEach=function(b,a){for(var d=Object.keys(this.map),e=0,l;e<d.length;e++)b.call(a,(l=this.map[d[e]]).value,l.key,this)};m.set=function(b,a){var d=this.keyElem.verifyValue(b),e=this.valueElem.verifyValue(a);
  this.map[this.keyElem.valueToString(d)]={key:d,value:e};return this};m.get=function(b){b=this.keyElem.valueToString(this.keyElem.verifyValue(b));if(b in this.map)return this.map[b].value};m.has=function(b){return this.keyElem.valueToString(this.keyElem.verifyValue(b))in this.map};return t}(d,d.Reflect);d.loadProto=function(b,e,p){if("string"===typeof e||e&&"string"===typeof e.file&&"string"===typeof e.root)p=e,e=void 0;return d.loadJson(d.DotProto.Parser.parse(b),e,p)};d.protoFromString=d.loadProto;
  d.loadProtoFile=function(b,e,p){e&&"object"===typeof e?(p=e,e=null):e&&"function"===typeof e||(e=null);if(e)return d.Util.fetch("string"===typeof b?b:b.root+"/"+b.file,function(m){if(null===m)e(Error("Failed to fetch file"));else try{e(null,d.loadProto(m,p,b))}catch(n){e(n)}});var t=d.Util.fetch("object"===typeof b?b.root+"/"+b.file:b);return null===t?null:d.loadProto(t,p,b)};d.protoFromFile=d.loadProtoFile;d.newBuilder=function(b){b=b||{};"undefined"===typeof b.convertFieldsToCamelCase&&(b.convertFieldsToCamelCase=
  d.convertFieldsToCamelCase);"undefined"===typeof b.populateAccessors&&(b.populateAccessors=d.populateAccessors);return new d.Builder(b)};d.loadJson=function(b,e,p){if("string"===typeof e||e&&"string"===typeof e.file&&"string"===typeof e.root)p=e,e=null;e&&"object"===typeof e||(e=d.newBuilder());"string"===typeof b&&(b=JSON.parse(b));e["import"](b,p);e.resolveAll();return e};d.loadJsonFile=function(b,e,p){e&&"object"===typeof e?(p=e,e=null):e&&"function"===typeof e||(e=null);if(e)return d.Util.fetch("string"===
  typeof b?b:b.root+"/"+b.file,function(m){if(null===m)e(Error("Failed to fetch file"));else try{e(null,d.loadJson(JSON.parse(m),p,b))}catch(n){e(n)}});var r=d.Util.fetch("object"===typeof b?b.root+"/"+b.file:b);return null===r?null:d.loadJson(JSON.parse(r),p,b)};return d});
  