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