protobufjs 3.6.0 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/bin/proto2js +16 -4
  2. package/bower.json +1 -1
  3. package/dist/ProtoBuf.js +645 -441
  4. package/dist/ProtoBuf.min.js +96 -96
  5. package/dist/ProtoBuf.min.js.gz +0 -0
  6. package/dist/ProtoBuf.min.map +2 -2
  7. package/dist/ProtoBuf.noparse.js +520 -357
  8. package/dist/ProtoBuf.noparse.min.js +68 -66
  9. package/dist/ProtoBuf.noparse.min.js.gz +0 -0
  10. package/dist/ProtoBuf.noparse.min.map +3 -3
  11. package/docs/ProtoBuf.Builder.Message.html +673 -135
  12. package/docs/ProtoBuf.Builder.Service.html +58 -19
  13. package/docs/ProtoBuf.Builder.html +374 -46
  14. package/docs/ProtoBuf.DotProto.Parser.html +58 -19
  15. package/docs/ProtoBuf.DotProto.Tokenizer.html +104 -19
  16. package/docs/ProtoBuf.DotProto.html +16 -10
  17. package/docs/ProtoBuf.Reflect.Enum.Value.html +207 -33
  18. package/docs/ProtoBuf.Reflect.Enum.html +318 -56
  19. package/docs/ProtoBuf.Reflect.Extension.html +53 -13
  20. package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +450 -68
  21. package/docs/ProtoBuf.Reflect.Message.Field.html +454 -51
  22. package/docs/ProtoBuf.Reflect.Message.OneOf.html +1044 -0
  23. package/docs/ProtoBuf.Reflect.Message.html +378 -64
  24. package/docs/ProtoBuf.Reflect.Namespace.html +333 -51
  25. package/docs/ProtoBuf.Reflect.Service.Method.html +228 -35
  26. package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +262 -41
  27. package/docs/ProtoBuf.Reflect.Service.html +318 -56
  28. package/docs/ProtoBuf.Reflect.T.html +210 -25
  29. package/docs/ProtoBuf.Reflect.html +17 -11
  30. package/docs/ProtoBuf.Util.html +59 -13
  31. package/docs/ProtoBuf.html +235 -67
  32. package/docs/ProtoBuf.js.html +648 -443
  33. package/docs/index.html +4 -2
  34. package/docs/styles/jsdoc-default.css +2 -2
  35. package/examples/protoify/.npmignore +2 -0
  36. package/examples/protoify/README.md +28 -0
  37. package/examples/protoify/index.js +147 -0
  38. package/examples/protoify/json.js +123 -0
  39. package/examples/protoify/json.json +123 -0
  40. package/examples/protoify/json.proto +30 -0
  41. package/examples/protoify/package.json +15 -0
  42. package/examples/protoify/test.js +56 -0
  43. package/examples/websocket/README.md +1 -0
  44. package/examples/websocket/package.json +1 -1
  45. package/externs/ProtoBuf.js +922 -922
  46. package/package.json +3 -3
  47. package/scripts/build.js +58 -58
  48. package/src/ProtoBuf/Builder/Message.js +107 -77
  49. package/src/ProtoBuf/Builder/Service.js +8 -5
  50. package/src/ProtoBuf/Builder.js +71 -37
  51. package/src/ProtoBuf/DotProto/Parser.js +108 -72
  52. package/src/ProtoBuf/DotProto/Tokenizer.js +17 -11
  53. package/src/ProtoBuf/Lang.js +1 -1
  54. package/src/ProtoBuf/Reflect/Enum/Value.js +3 -2
  55. package/src/ProtoBuf/Reflect/Enum.js +9 -5
  56. package/src/ProtoBuf/Reflect/Extension.js +4 -3
  57. package/src/ProtoBuf/Reflect/Message/ExtensionField.js +4 -3
  58. package/src/ProtoBuf/Reflect/Message/Field.js +45 -26
  59. package/src/ProtoBuf/Reflect/Message/OneOf.js +19 -0
  60. package/src/ProtoBuf/Reflect/Message.js +36 -19
  61. package/src/ProtoBuf/Reflect/Namespace.js +19 -15
  62. package/src/ProtoBuf/Reflect/Service/Method.js +9 -5
  63. package/src/ProtoBuf/Reflect/Service/RPCMethod.js +3 -2
  64. package/src/ProtoBuf/Reflect/Service.js +9 -5
  65. package/src/ProtoBuf/Reflect/T.js +20 -6
  66. package/src/ProtoBuf/Reflect.js +9 -0
  67. package/src/ProtoBuf/Util.js +132 -132
  68. package/src/ProtoBuf.js +15 -17
  69. package/src/google/protobuf/descriptor.json +33 -13
  70. package/tests/bench.txt +373 -373
  71. package/tests/complex.json +8 -4
  72. package/tests/custom-options.json +169 -169
  73. package/tests/extend.json +71 -71
  74. package/tests/nodeunit-browser/nodeunit.css +70 -70
  75. package/tests/nodeunit-browser/nodeunit.js +2108 -2108
  76. package/tests/oneof.proto +6 -0
  77. package/tests/options.json +32 -32
  78. package/tests/options.proto +2 -0
  79. package/tests/proto2js/Bar.json +46 -46
  80. package/tests/suite.js +83 -12
  81. package/.idea/.name +0 -1
  82. package/.idea/ProtoBuf.iml +0 -9
  83. package/.idea/dictionaries/Daniel.xml +0 -7
  84. package/.idea/encodings.xml +0 -5
  85. package/.idea/misc.xml +0 -5
  86. package/.idea/modules.xml +0 -9
  87. package/.idea/scopes/scope_settings.xml +0 -5
  88. package/.idea/vcs.xml +0 -7
  89. package/.idea/workspace.xml +0 -551
  90. package/NOTICE +0 -2
  91. package/sandbox/issue146/MyOptions.proto +0 -28
  92. package/sandbox/issue146/Sample.proto +0 -21
  93. package/sandbox/issue146/main.js +0 -3
  94. package/sandbox/issue147/enum.proto +0 -8
  95. package/sandbox/issue147/main.js +0 -3
  96. package/sandbox/issue42/innerextend.proto +0 -18
  97. package/sandbox/issue42/main.js +0 -8
  98. package/sandbox/issue42/outerextend.proto +0 -17
  99. package/v8.log +0 -3828
@@ -3,101 +3,101 @@
3
3
  Released under the Apache License, Version 2.0
4
4
  see: https://github.com/dcodeIO/ProtoBuf.js for details
5
5
  */
6
- (function(r){function s(k){var g={VERSION:"3.6.0",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64",
6
+ (function(s){function u(l){var g={VERSION:"3.8.2",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64",
7
7
  wireType:g.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:g.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:g.WIRE_TYPES.VARINT},"double":{name:"double",wireType:g.WIRE_TYPES.BITS64},string:{name:"string",wireType:g.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:g.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:g.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:g.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:g.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:g.WIRE_TYPES.BITS64},
8
- "float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=k;g.Long=k.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(d){function c(){}if(1<arguments.length)throw Error("Object.create polyfill only accepts the first parameter.");c.prototype=
9
- d;return new c});var c={IS_NODE:!1};try{c.IS_NODE="function"===typeof require&&"function"===typeof require("fs").readFileSync&&"function"===typeof require("path").resolve}catch(d){}c.XHR=function(){for(var d=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],c=null,e=0;e<d.length;e++){try{c=d[e]()}catch(b){continue}break}if(!c)throw Error("XMLHttpRequest is not supported");
10
- return c};c.fetch=function(d,g){g&&"function"!=typeof g&&(g=null);if(c.IS_NODE)if(g)require("fs").readFile(d,function(a,b){a?g(null):g(""+b)});else try{return require("fs").readFileSync(d)}catch(e){return null}else{var b=c.XHR();b.open("GET",d,g?!0:!1);b.setRequestHeader("Accept","text/plain");"function"===typeof b.overrideMimeType&&b.overrideMimeType("text/plain");if(g)b.onreadystatechange=function(){4==b.readyState&&(200==b.status||0==b.status&&"string"===typeof b.responseText?g(b.responseText):
11
- g(null))},4!=b.readyState&&b.send(null);else return b.send(null),200==b.status||0==b.status&&"string"===typeof b.responseText?b.responseText:null}};c.isArray=Array.isArray||function(d){return"[object Array]"===Object.prototype.toString.call(d)};return c}();g.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",STRINGOPEN:'"',STRINGCLOSE:'"',STRINGOPEN_SQ:"'",STRINGCLOSE_SQ:"'",COPTOPEN:"(",COPTCLOSE:")",DELIM:/[\s\{\}=;\[\],'"\(\)]/g,RULE:/^(?:required|optional|repeated)$/,
8
+ "float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=l;g.Long=l.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(e){function d(){}if(1<arguments.length)throw Error("Object.create polyfill only accepts the first parameter.");d.prototype=
9
+ e;return new d});var e={IS_NODE:!1};try{e.IS_NODE="function"===typeof require&&"function"===typeof require("fs").readFileSync&&"function"===typeof require("path").resolve}catch(d){}e.XHR=function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null,g=0;g<e.length;g++){try{d=e[g]()}catch(b){continue}break}if(!d)throw Error("XMLHttpRequest is not supported");
10
+ return d};e.fetch=function(d,g){g&&"function"!=typeof g&&(g=null);if(e.IS_NODE)if(g)require("fs").readFile(d,function(f,a){f?g(null):g(""+a)});else try{return require("fs").readFileSync(d)}catch(n){return null}else{var b=e.XHR();b.open("GET",d,g?!0:!1);b.setRequestHeader("Accept","text/plain");"function"===typeof b.overrideMimeType&&b.overrideMimeType("text/plain");if(g)b.onreadystatechange=function(){4==b.readyState&&(200==b.status||0==b.status&&"string"===typeof b.responseText?g(b.responseText):
11
+ g(null))},4!=b.readyState&&b.send(null);else return b.send(null),200==b.status||0==b.status&&"string"===typeof b.responseText?b.responseText:null}};e.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};return e}();g.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",STRINGOPEN:'"',STRINGCLOSE:'"',STRINGOPEN_SQ:"'",STRINGCLOSE_SQ:"'",COPTOPEN:"(",COPTCLOSE:")",DELIM:/[\s\{\}=;\[\],'"\(\)]/g,RULE:/^(?:required|optional|repeated)$/,
12
12
  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|0x[0-9a-fA-F]+|0[0-7]+|([0-9]*\.[0-9]+([Ee][+-]?[0-9]+)?))$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0x[0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^[0-9]*\.[0-9]+([Ee][+-]?[0-9]+)?$/,ID:/^(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,
13
- NEGID:/^\-?(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/['"]([^'"\\]*(\\.[^"\\]*)*)['"]/g,BOOL:/^(?:true|false)$/i};g.DotProto=function(c,d){var g={},l=function(b){this.source=""+b;this.index=0;this.line=1;this.stack=[];this.readingString=!1;this.stringEndsWith=d.STRINGCLOSE};l.prototype._readString=function(){d.STRING.lastIndex=this.index-1;var b;if(null!==(b=d.STRING.exec(this.source)))return b=b[1],this.index=d.STRING.lastIndex,this.stack.push(this.stringEndsWith),b;throw Error("Illegal string value at line "+
14
- this.line+", index "+this.index);};l.prototype.next=function(){if(0<this.stack.length)return this.stack.shift();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var b,a;do{for(b=!1;d.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,
15
- this.index==this.source.length)return null;this.index++;this.line++;b=!0}else if("*"===this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;this.index++;b=!0}else throw Error("Invalid comment at line "+this.line+": /"+this.source.charAt(this.index)+" ('/' or '*' expected)");}while(b);if(this.index===this.source.length)return null;b=this.index;d.DELIM.lastIndex=0;if(d.DELIM.test(this.source.charAt(b)))++b;
16
- else for(++b;b<this.source.length&&!d.DELIM.test(this.source.charAt(b));)b++;b=this.source.substring(this.index,this.index=b);b===d.STRINGOPEN?(this.readingString=!0,this.stringEndsWith=d.STRINGCLOSE):b===d.STRINGOPEN_SQ&&(this.readingString=!0,this.stringEndsWith=d.STRINGCLOSE_SQ);return b};l.prototype.peek=function(){if(0===this.stack.length){var b=this.next();if(null===b)return null;this.stack.push(b)}return this.stack[0]};l.prototype.toString=function(){return"Tokenizer("+this.index+"/"+this.source.length+
17
- " at line "+this.line+")"};g.Tokenizer=l;var e=function(b){this.tn=new l(b)};e.prototype.parse=function(){for(var b={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{},services:[]},a,f=!0;a=this.tn.next();)switch(a){case "package":if(!f||null!==b["package"])throw Error("Illegal package at line "+this.tn.line);b["package"]=this._parsePackage(a);break;case "import":if(!f)throw Error("Illegal import at line "+this.tn.line);b.imports.push(this._parseImport(a));break;case "message":this._parseMessage(b,
18
- null,a);f=!1;break;case "enum":this._parseEnum(b,a);f=!1;break;case "option":if(!f)throw Error("Illegal option at line "+this.tn.line);this._parseOption(b,a);break;case "service":this._parseService(b,a);break;case "extend":this._parseExtend(b,a);break;case "syntax":this._parseIgnoredStatement(b,a);break;default:throw Error("Illegal token at line "+this.tn.line+": "+a);}delete b.name;return b};e.prototype._parseNumber=function(b){var a=1;"-"==b.charAt(0)&&(a=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))return a*
19
- parseInt(b,10);if(d.NUMBER_HEX.test(b))return a*parseInt(b.substring(2),16);if(d.NUMBER_OCT.test(b))return a*parseInt(b.substring(1),8);if(d.NUMBER_FLT.test(b))return a*parseFloat(b);throw Error("Illegal number at line "+this.tn.line+": "+(0>a?"-":"")+b);};e.prototype._parseString=function(b){var a="",f;do{this.tn.next();a+=this.tn.next();f=this.tn.next();if(f!==this.tn.stringEndsWith)throw Error("Illegal end of string in "+b+" at line "+this.tn.line+": "+f+" ('"+this.tn.stringEndsWith+"' expected)");
20
- f=this.tn.peek()}while(f===d.STRINGOPEN||f===d.STRINGOPEN_SQ);return a};e.prototype._parseId=function(b,a){var f=-1,c=1;"-"==b.charAt(0)&&(c=-1,b=b.substring(1));if(d.NUMBER_DEC.test(b))f=parseInt(b);else if(d.NUMBER_HEX.test(b))f=parseInt(b.substring(2),16);else if(d.NUMBER_OCT.test(b))f=parseInt(b.substring(1),8);else throw Error("Illegal ID at line "+this.tn.line+": "+(0>c?"-":"")+b);f=c*f|0;if(!a&&0>f)throw Error("Illegal ID at line "+this.tn.line+": "+(0>c?"-":"")+b);return f};e.prototype._parsePackage=
21
- function(b){b=this.tn.next();if(!d.TYPEREF.test(b))throw Error("Illegal package at line "+this.tn.line+": "+b);var a=b;b=this.tn.next();if(b!=d.END)throw Error("Illegal end of package at line "+this.tn.line+": "+b+" ('"+d.END+"' expected)");return a};e.prototype._parseImport=function(b){b=this.tn.peek();"public"===b&&(this.tn.next(),b=this.tn.peek());if(b!==d.STRINGOPEN&&b!==d.STRINGOPEN_SQ)throw Error("Illegal import at line "+this.tn.line+": "+b+" ('"+d.STRINGOPEN+"' or '"+d.STRINGOPEN_SQ+"' expected)");
22
- var a=this._parseString("root");b=this.tn.next();if(b!==d.END)throw Error("Illegal import at line "+this.tn.line+": "+b+" ('"+d.END+"' expected)");return a};e.prototype._parseOption=function(b,a){a=this.tn.next();var f=!1;a==d.COPTOPEN&&(f=!0,a=this.tn.next());if(!d.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option in message "+b.name+" at line "+this.tn.line+": "+a);var c=a;a=this.tn.next();if(f){if(a!==d.COPTCLOSE)throw Error("Illegal option in message "+b.name+", option "+
23
- c+" at line "+this.tn.line+": "+a+" ('"+d.COPTCLOSE+"' expected)");c="("+c+")";a=this.tn.next();d.FQTYPEREF.test(a)&&(c+=a,a=this.tn.next())}if(a!==d.EQUAL)throw Error("Illegal option operator in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a+" ('"+d.EQUAL+"' expected)");a=this.tn.peek();if(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ)f=this._parseString("message "+b.name+", option "+c);else if(this.tn.next(),d.NUMBER.test(a))f=this._parseNumber(a,!0);else if(d.BOOL.test(a))f="true"===a;
24
- else if(d.TYPEREF.test(a))f=a;else throw Error("Illegal option value in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!==d.END)throw Error("Illegal end of option in message "+b.name+", option "+c+" at line "+this.tn.line+": "+a+" ('"+d.END+"' expected)");b.options[c]=f};e.prototype._parseIgnoredStatement=function(b,a){var f;do{f=this.tn.next();if(null===f)throw Error("Unexpected EOF in "+b.name+", "+a+" (ignored) at line "+this.tn.line);if(f===d.END)break}while(1)};
25
- e.prototype._parseService=function(b,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var f=a,c={name:f,rpc:{},options:{}};a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal OPEN after service "+f+" at line "+this.tn.line+": "+a+" ('"+d.OPEN+"' expected)");do if(a=this.tn.next(),"option"===a)this._parseOption(c,a);else if("rpc"===a)this._parseServiceRPC(c,a);else if(a!==d.CLOSE)throw Error("Illegal type for service "+f+" at line "+this.tn.line+
26
- ": "+a);while(a!==d.CLOSE);b.services.push(c)};e.prototype._parseServiceRPC=function(b,a){var f=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal RPC method name in service "+b.name+" at line "+this.tn.line+": "+a);var c=a,e={request:null,response:null,options:{}};a=this.tn.next();if(a!==d.COPTOPEN)throw Error("Illegal start of request type in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('"+d.COPTOPEN+"' expected)");a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal request type in RPC service "+
27
- b.name+"#"+c+" at line "+this.tn.line+": "+a);e.request=a;a=this.tn.next();if(a!=d.COPTCLOSE)throw Error("Illegal end of request type in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('"+d.COPTCLOSE+"' expected)");a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal request/response delimiter in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('returns' expected)");a=this.tn.next();if(a!=d.COPTOPEN)throw Error("Illegal start of response type in RPC service "+
28
- b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('"+d.COPTOPEN+"' expected)");a=this.tn.next();e.response=a;a=this.tn.next();if(a!==d.COPTCLOSE)throw Error("Illegal end of response type in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('"+d.COPTCLOSE+"' expected)");a=this.tn.next();if(a===d.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(e,a);else if(a!==d.CLOSE)throw Error("Illegal start of option in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('option' expected)");
29
- while(a!==d.CLOSE);this.tn.peek()===d.END&&this.tn.next()}else if(a!==d.END)throw Error("Illegal method delimiter in RPC service "+b.name+"#"+c+" at line "+this.tn.line+": "+a+" ('"+d.END+"' or '"+d.OPEN+"' expected)");"undefined"===typeof b[f]&&(b[f]={});b[f][c]=e};e.prototype._parseMessage=function(b,a,f){var c={},e="group"===f;f=this.tn.next();if(!d.NAME.test(f))throw Error("Illegal "+(e?"group":"message")+" name"+(b?" in message "+b.name:"")+" at line "+this.tn.line+": "+f);c.name=f;if(e){f=this.tn.next();
30
- if(f!==d.EQUAL)throw Error("Illegal id assignment after group "+c.name+" at line "+this.tn.line+": "+f+" ('"+d.EQUAL+"' expected)");f=this.tn.next();try{a.id=this._parseId(f)}catch(g){throw Error("Illegal field id value for group "+c.name+"#"+a.name+" at line "+this.tn.line+": "+f);}c.isGroup=!0}c.fields=[];c.enums=[];c.messages=[];c.options={};f=this.tn.next();f===d.OPTOPEN&&a&&(this._parseFieldOptions(c,a,f),f=this.tn.next());if(f!==d.OPEN)throw Error("Illegal OPEN after "+(e?"group":"message")+
31
- " "+c.name+" at line "+this.tn.line+": "+f+" ('"+d.OPEN+"' expected)");do if(f=this.tn.next(),f===d.CLOSE){f=this.tn.peek();f===d.END&&this.tn.next();break}else if(d.RULE.test(f))this._parseMessageField(c,f);else if("enum"===f)this._parseEnum(c,f);else if("message"===f)this._parseMessage(c,null,f);else if("option"===f)this._parseOption(c,f);else if("extensions"===f)c.extensions=this._parseExtensions(c,f);else if("extend"===f)this._parseExtend(c,f);else throw Error("Illegal token in message "+c.name+
32
- " at line "+this.tn.line+": "+f+" (type or '"+d.CLOSE+"' expected)");while(1);b.messages.push(c);return c};e.prototype._parseMessageField=function(b,a){var c={},e=null;c.rule=a;c.options={};a=this.tn.next();if("group"===a){e=this._parseMessage(b,c,a);if(!/^[A-Z]/.test(e.name))throw Error("Group names must start with a capital letter");c.type=e.name;c.name=e.name.toLowerCase();a=this.tn.peek();a===d.END&&this.tn.next()}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("Illegal field type in message "+
33
- b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal field name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal field id assignment in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a+" ('"+d.EQUAL+"' expected)");a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id value in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();
34
- a===d.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==d.END)throw Error("Illegal field delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a+" ('"+d.END+"' expected)");}b.fields.push(c)};e.prototype._parseFieldOptions=function(b,a,c){var e=!0;do{c=this.tn.next();if(c===d.OPTCLOSE)break;else if(c===d.OPTEND){if(e)throw Error("Illegal start of message field options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.next()}this._parseFieldOption(b,
35
- a,c);e=!1}while(1)};e.prototype._parseFieldOption=function(b,a,c){var e=!1;c===d.COPTOPEN&&(c=this.tn.next(),e=!0);if(!d.TYPEREF.test(c))throw Error("Illegal field option in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);var g=c;c=this.tn.next();if(e){if(c!==d.COPTCLOSE)throw Error("Illegal custom field option name delimiter in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c+" (')' expected)");g="("+g+")";c=this.tn.next();d.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==
36
- d.EQUAL)throw Error("Illegal field option operation in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c+" ('=' expected)");c=this.tn.peek();if(c===d.STRINGOPEN||c===d.STRINGOPEN_SQ)b=this._parseString("message "+b.name+"#"+a.name);else if(d.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(d.BOOL.test(c))b="true"===this.tn.next().toLowerCase();else if(d.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal field option value in message "+b.name+"#"+a.name+", option "+
37
- g+" at line "+this.tn.line+": "+c);a.options[g]=b};e.prototype._parseEnum=function(c,a){var e={};a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal enum name in message "+c.name+" at line "+this.tn.line+": "+a);e.name=a;a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal OPEN after enum "+e.name+" at line "+this.tn.line+": "+a);e.values=[];e.options={};do{a=this.tn.next();if(a===d.CLOSE){a=this.tn.peek();a===d.END&&this.tn.next();break}if("option"==a)this._parseOption(e,a);else{if(!d.NAME.test(a))throw Error("Illegal enum value name in enum "+
38
- e.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(e,a)}}while(1);c.enums.push(e)};e.prototype._parseEnumValue=function(c,a){var e={};e.name=a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal enum value operator in enum "+c.name+" at line "+this.tn.line+": "+a+" ('"+d.EQUAL+"' expected)");a=this.tn.next();try{e.id=this._parseId(a,!0)}catch(g){throw Error("Illegal enum value id in enum "+c.name+" at line "+this.tn.line+": "+a);}c.values.push(e);a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(c,
39
- {options:{}},a),a=this.tn.next());if(a!==d.END)throw Error("Illegal enum value delimiter in enum "+c.name+" at line "+this.tn.line+": "+a+" ('"+d.END+"' expected)");};e.prototype._parseExtensions=function(b,a){var e=[];a=this.tn.next();"min"===a?e.push(c.ID_MIN):"max"===a?e.push(c.ID_MAX):e.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+" ('to' expected)");a=this.tn.next();"min"===a?e.push(c.ID_MIN):"max"===
40
- a?e.push(c.ID_MAX):e.push(this._parseNumber(a));a=this.tn.next();if(a!==d.END)throw Error("Illegal extension delimiter in message "+b.name+" at line "+this.tn.line+": "+a+" ('"+d.END+"' expected)");return e};e.prototype._parseExtend=function(c,a){a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal extended message name at line "+this.tn.line+": "+a);var e={};e.ref=a;e.fields=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal OPEN in extend "+e.name+" at line "+this.tn.line+": "+a+" ('"+
41
- d.OPEN+"' expected)");do if(a=this.tn.next(),a===d.CLOSE){a=this.tn.peek();a==d.END&&this.tn.next();break}else if(d.RULE.test(a))this._parseMessageField(e,a);else throw Error("Illegal token in extend "+e.name+" at line "+this.tn.line+": "+a+" (rule or '"+d.CLOSE+"' expected)");while(1);c.messages.push(e);return e};e.prototype.toString=function(){return"Parser"};g.Parser=e;return g}(g,g.Lang);g.Reflect=function(c){function d(a,b){var e=b.readVarint32(),f=e&7,e=e>>3;switch(f){case c.WIRE_TYPES.VARINT:do e=
42
- b.readUint8();while(128===(e&128));break;case c.WIRE_TYPES.BITS64:b.offset+=8;break;case c.WIRE_TYPES.LDELIM:e=b.readVarint32();b.offset+=e;break;case c.WIRE_TYPES.STARTGROUP:d(e,b);break;case c.WIRE_TYPES.ENDGROUP:if(e===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+e+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+f);}return!0}function g(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&
43
- "boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return c.Long.fromString(a,b||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}var l={},e=function(a,c){this.parent=a;this.name=c};e.prototype.fqn=function(){var a=this.name,c=this;do{c=c.parent;if(null==c)break;a=c.name+"."+a}while(1);return a};e.prototype.toString=function(a){return(a?this.className+
44
- " ":"")+this.fqn()};e.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};l.T=e;var b=function(a,c,b){e.call(this,a,c);this.className="Namespace";this.children=[];this.options=b||{}};b.prototype=Object.create(e.prototype);b.prototype.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var c=[],b=0,e=this.children.length;b<e;++b)this.children[b]instanceof a&&c.push(this.children[b]);return c};b.prototype.addChild=function(c){var b;if(b=
45
- this.getChild(c.name))if(b instanceof a.Field&&b.name!==b.originalName&&null===this.getChild(b.originalName))b.name=b.originalName;else if(c instanceof a.Field&&c.name!==c.originalName&&null===this.getChild(c.originalName))c.name=c.originalName;else throw Error("Duplicate name in namespace "+this.toString(!0)+": "+c.name);this.children.push(c)};b.prototype.getChild=function(a){for(var c="number"===typeof a?"id":"name",b=0,e=this.children.length;b<e;++b)if(this.children[b][c]===a)return this.children[b];
46
- return null};b.prototype.resolve=function(a,c){var b=a.split("."),e=this,d=0;if(""===b[d]){for(;null!==e.parent;)e=e.parent;d++}do{do{e=e.getChild(b[d]);if(!(e&&e instanceof l.T)||c&&e instanceof l.Message.Field){e=null;break}d++}while(d<b.length);if(null!=e)break;if(null!==this.parent)return this.parent.resolve(a,c)}while(null!=e);return e};b.prototype.build=function(){for(var a={},c=this.children,e=0,d=c.length,f;e<d;++e)f=c[e],f instanceof b&&(a[f.name]=f.build());Object.defineProperty&&Object.defineProperty(a,
47
- "$options",{value:this.buildOpt()});return a};b.prototype.buildOpt=function(){for(var a={},c=Object.keys(this.options),b=0,e=c.length;b<e;++b)a[c[b]]=this.options[c[b]];return a};b.prototype.getOption=function(a){return"undefined"===typeof a?this.options:"undefined"!==typeof this.options[a]?this.options[a]:null};l.Namespace=b;var a=function(a,e,d,f){b.call(this,a,e,d);this.className="Message";this.extensions=[c.ID_MIN,c.ID_MAX];this.clazz=null;this.isGroup=!!f;this._fieldsById=this._fields=null};
48
- a.prototype=Object.create(b.prototype);a.prototype.build=function(b){if(this.clazz&&!b)return this.clazz;b=function(a,c){function b(a,c){var e={},d;for(d in a)a.hasOwnProperty(d)&&(null===a[d]||"object"!==typeof a[d]?e[d]=a[d]:a[d]instanceof k?c&&(e[d]=a.toBuffer()):e[d]=b(a[d],c));return e}var e=c.getChildren(a.Reflect.Message.Field),d=function(c,b){a.Builder.Message.call(this);for(var d=0,m=e.length,f;d<m;++d)this[(f=e[d]).name]=f.repeated?[]:null,f.required&&null!==f.defaultValue&&(this[f.name]=
49
- f.defaultValue);if(0<arguments.length)if(1!==arguments.length||"object"!==typeof c||"function"===typeof c.encode||a.Util.isArray(c)||c instanceof k||c instanceof ArrayBuffer||a.Long&&c instanceof a.Long)for(d=0,m=arguments.length;d<m;++d)this.$set(e[d].name,arguments[d]);else for(f=Object.keys(c),d=0,m=f.length;d<m;++d)this.$set(f[d],c[f[d]])};d.prototype=Object.create(a.Builder.Message.prototype);d.prototype.add=function(b,e,d){var m=c.getChild(b);if(!m)throw Error(this+"#"+b+" is undefined");if(!(m instanceof
50
- a.Reflect.Message.Field))throw Error(this+"#"+b+" is not a field: "+m.toString(!0));if(!m.repeated)throw Error(this+"#"+b+" is not a repeated field");null===this[m.name]&&(this[m.name]=[]);this[m.name].push(d?e:m.verifyValue(e,!0))};d.prototype.$add=d.prototype.add;d.prototype.set=function(b,e,d){if(b&&"object"===typeof b){for(var m in b)b.hasOwnProperty(m)&&this.$set(m,b[m],d);return this}if(d)return this[b]=e,this;d=c.getChild(b);if(!d)throw Error(this+"#"+b+" is not a field: undefined");if(!(d instanceof
51
- a.Reflect.Message.Field))throw Error(this+"#"+b+" is not a field: "+d.toString(!0));this[d.name]=d.verifyValue(e);return this};d.prototype.$set=d.prototype.set;d.prototype.get=function(b,e){if(e)return this[b];var d=c.getChild(b);if(!(d&&d instanceof a.Reflect.Message.Field))throw Error(this+"#"+b+" is not a field: undefined");if(!(d instanceof a.Reflect.Message.Field))throw Error(this+"#"+b+" is not a field: "+d.toString(!0));return this[d.name]};d.prototype.$get=d.prototype.get;for(var m=0;m<e.length;m++){var f=
52
- e[m];f instanceof a.Reflect.Message.ExtensionField||a.populateAccessors&&function(a){var b=a.originalName.replace(/(_[a-zA-Z])/g,function(a){return a.toUpperCase().replace("_","")}),b=b.substring(0,1).toUpperCase()+b.substring(1),e=a.originalName.replace(/([A-Z])/g,function(a){return"_"+a});null===c.getChild("set"+b)&&(d.prototype["set"+b]=function(c){this.$set(a.name,c)});null===c.getChild("set_"+e)&&(d.prototype["set_"+e]=function(c){this.$set(a.name,c)});null===c.getChild("get"+b)&&(d.prototype["get"+
53
- b]=function(){return this.$get(a.name)});null===c.getChild("get_"+e)&&(d.prototype["get_"+e]=function(){return this.$get(a.name)})}(f)}d.prototype.encode=function(a,b){"boolean"===typeof a&&(b=a,a=void 0);var e=!1;a||(a=new k,e=!0);var d=a.littleEndian;try{return c.encode(this,a.LE(),b),(e?a.flip():a).LE(d)}catch(m){throw a.LE(d),m;}};d.prototype.calculate=function(){return c.calculate(this)};d.prototype.encodeDelimited=function(a){var b=!1;a||(a=new k,b=!0);var e=(new k).LE();c.encode(this,e).flip();
54
- a.writeVarint32(e.remaining());a.append(e);return b?a.flip():a};d.prototype.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toArrayBuffer()),a;}};d.prototype.toArrayBuffer=d.prototype.encodeAB;d.prototype.encodeNB=function(){try{return this.encode().toBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBuffer()),a;}};d.prototype.toBuffer=d.prototype.encodeNB;d.prototype.encode64=function(){try{return this.encode().toBase64()}catch(a){throw a.encoded&&
55
- (a.encoded=a.encoded.toBase64()),a;}};d.prototype.toBase64=d.prototype.encode64;d.prototype.encodeHex=function(){try{return this.encode().toHex()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toHex()),a;}};d.prototype.toHex=d.prototype.encodeHex;d.prototype.toRaw=function(a){return b(this,!!a)};d.decode=function(a,b){"string"===typeof a&&(a=k.wrap(a,b?b:"base64"));a=a instanceof k?a:k.wrap(a);var e=a.littleEndian;try{var d=c.decode(a.LE());a.LE(e);return d}catch(m){throw a.LE(e),m;}};d.decodeDelimited=
56
- function(a,b){"string"===typeof a&&(a=k.wrap(a,b?b:"base64"));a=a instanceof k?a:k.wrap(a);if(1>a.remaining())return null;var e=a.offset,d=a.readVarint32();if(a.remaining()<d)return a.offset=e,null;try{var m=c.decode(a.slice(a.offset,a.offset+d).LE());a.offset+=d;return m}catch(f){throw a.offset+=d,f;}};d.decode64=function(a){return d.decode(a,"base64")};d.decodeHex=function(a){return d.decode(a,"hex")};d.prototype.toString=function(){return c.toString()};Object.defineProperty&&(Object.defineProperty(d,
57
- "$options",{value:c.buildOpt()}),Object.defineProperty(d.prototype,"$type",{get:function(){return c}}));return d}(c,this);this._fields=[];this._fieldsById=[];for(var e=0,d=this.children.length,f;e<d;e++)if(f=this.children[e],f instanceof h)b[f.name]=f.build();else if(f instanceof a)b[f.name]=f.build();else if(f instanceof a.Field)f.build(),this._fields.push(f),this._fieldsById[f.id]=f;else if(!(f instanceof p))throw Error("Illegal reflect child of "+this.toString(!0)+": "+children[e].toString(!0));
58
- return this.clazz=b};a.prototype.encode=function(a,c,b){for(var e=null,d,f=0,g=this._fields.length,h;f<g;++f)d=this.children[f],h=a[d.name],d.required&&null===h?null===e&&(e=d):d.encode(b?h:d.verifyValue(h),c);if(null!==e)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+e),a.encoded=c,a;return c};a.prototype.calculate=function(a){for(var c=0,b=0,e=this._fields.length,d,f;b<e;++b){d=this._fields[b];f=a[d.name];if(d.required&&null===f)throw Error("Missing at least one required field for "+
59
- this.toString(!0)+": "+d);c+=d.calculate(f)}return c};a.prototype.decode=function(a,b,e){b="number"===typeof b?b:-1;for(var f=a.offset,g=new this.clazz,h,l,k;a.offset<f+b||-1===b&&0<a.remaining();){h=a.readVarint32();l=h&7;k=h>>3;if(l===c.WIRE_TYPES.ENDGROUP){if(k!==e)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(e?e+" expected":"not a group")+")");break}if(h=this._fieldsById[k])h.repeated&&!h.options.packed?g[h.name].push(h.decode(l,a)):g[h.name]=h.decode(l,a);else switch(l){case c.WIRE_TYPES.VARINT:a.readVarint32();
60
- break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case c.WIRE_TYPES.STARTGROUP:for(;d(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+l);}}a=0;for(b=this._fields.length;a<b;++a)if(h=this._fields[a],null===g[h.name]){if(h.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+h.name),a.decoded=g,a;null!==
61
- h.defaultValue&&(g[h.name]=h.defaultValue)}return g};l.Message=a;var f=function(b,d,f,g,h,l){e.call(this,b,g);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;this.type=f;this.resolvedType=null;this.id=h;this.options=l||{};this.defaultValue=null;this.originalName=this.name;!c.convertFieldsToCamelCase||this instanceof a.ExtensionField||(this.name=this.name.replace(/_([a-zA-Z])/g,function(a,c){return c.toUpperCase()}))};f.prototype=Object.create(e.prototype);
62
- f.prototype.build=function(){this.defaultValue="undefined"!==typeof this.options["default"]?this.verifyValue(this.options["default"]):null};f.prototype.verifyValue=function(a,b){b=b||!1;var e=function(a,c){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+c+")");}.bind(this);if(null===a)return this.required&&e(typeof a,"required"),null;var d;if(this.repeated&&!b){c.Util.isArray(a)||(a=[a]);e=[];for(d=0;d<a.length;d++)e.push(this.verifyValue(a[d],!0));return e}!this.repeated&&
63
- c.Util.isArray(a)&&e(typeof a,"no array expected");switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&e(typeof a,"not an integer"),4294967295<a?a|0:a;case c.TYPES.uint32:case c.TYPES.fixed32:return("number"!==typeof a||a===a&&0!==a%1)&&e(typeof a,"not an integer"),0>a?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return g(a,!1)}catch(f){e(typeof a,f.message)}else e(typeof a,"requires Long.js");
64
- case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return g(a,!0)}catch(l){e(typeof a,l.message)}else e(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!==typeof a&&e(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&e(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||e(typeof a,"not a string"),""+a;case c.TYPES.bytes:return a&&a instanceof k?a:k.wrap(a);case c.TYPES["enum"]:var n=this.resolvedType.getChildren(h.Value);
65
- for(d=0;d<n.length;d++)if(n[d].name==a||n[d].id==a)return n[d].id;e(a,"not a valid enum value");case c.TYPES.group:case c.TYPES.message:a&&"object"===typeof a||e(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof c.Builder.Message){e={};for(d in a)a.hasOwnProperty(d)&&(e[d]=a[d]);a=e}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};f.prototype.encode=function(a,
66
- b){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 b;try{if(this.repeated){var e;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b.writeVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var d=b.offset;for(e=0;e<a.length;e++)this.encodeValue(a[e],b);var f=b.offset-d,g=k.calculateVarint32(f);if(1<g){var h=b.slice(d,b.offset),
67
- d=d+(g-1);b.offset=d;b.append(h)}b.writeVarint32(f,d-g)}else for(e=0;e<a.length;e++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a[e],b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a,b)}catch(l){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+l+")");}return b};f.prototype.encodeValue=function(a,b){if(null===a)return b;switch(this.type){case c.TYPES.int32:0>a?b.writeVarint64(a):b.writeVarint32(a);break;case c.TYPES.uint32:b.writeVarint32(a);
68
- break;case c.TYPES.sint32:b.writeVarint32ZigZag(a);break;case c.TYPES.fixed32:b.writeUint32(a);break;case c.TYPES.sfixed32:b.writeInt32(a);break;case c.TYPES.int64:case c.TYPES.uint64:b.writeVarint64(a);break;case c.TYPES.sint64:b.writeVarint64ZigZag(a);break;case c.TYPES.fixed64:b.writeUint64(a);break;case c.TYPES.sfixed64:b.writeInt64(a);break;case c.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case c.TYPES["enum"]:b.writeVarint32(a);
69
- break;case c.TYPES["float"]:b.writeFloat32(a);break;case c.TYPES["double"]:b.writeFloat64(a);break;case c.TYPES.string:b.writeVString(a);break;case c.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var e=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=e;break;case c.TYPES.message:e=(new k).LE();this.resolvedType.encode(a,e);b.writeVarint32(e.offset);b.append(e.flip());break;case c.TYPES.group:this.resolvedType.encode(a,
70
- b);b.writeVarint32(this.id<<3|c.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return b};f.prototype.calculate=function(a){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 b=0;try{if(this.repeated){var e,d;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=
71
- k.calculateVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);for(e=d=0;e<a.length;e++)d+=this.calculateValue(a[e]);b+=k.calculateVarint32(d);b+=d}else for(e=0;e<a.length;e++)b+=k.calculateVarint32(this.id<<3|this.type.wireType),b+=this.calculateValue(a[e])}else b+=k.calculateVarint32(this.id<<3|this.type.wireType),b+=this.calculateValue(a)}catch(f){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+f+")");}return b};f.prototype.calculateValue=function(a){if(null===a)return 0;switch(this.type){case c.TYPES.int32:return 0>
72
- a?k.calculateVarint64(a):k.calculateVarint32(a);case c.TYPES.uint32:return k.calculateVarint32(a);case c.TYPES.sint32:return k.calculateVarint32(k.zigZagEncode32(a));case c.TYPES.fixed32:case c.TYPES.sfixed32:case c.TYPES["float"]:return 4;case c.TYPES.int64:case c.TYPES.uint64:return k.calculateVarint64(a);case c.TYPES.sint64:return k.calculateVarint64(k.zigZagEncode64(a));case c.TYPES.fixed64:case c.TYPES.sfixed64:return 8;case c.TYPES.bool:return 1;case c.TYPES["enum"]:return k.calculateVarint32(a);
73
- case c.TYPES["double"]:return 8;case c.TYPES.string:return a=k.calculateUTF8Bytes(a),k.calculateVarint32(a)+a;case c.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return k.calculateVarint32(a.remaining())+a.remaining();case c.TYPES.message:return a=this.resolvedType.calculate(a),k.calculateVarint32(a)+a;case c.TYPES.group:return a=this.resolvedType.calculate(a),a+k.calculateVarint32(this.id<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+
74
- this.toString(!0)+": "+a+" (unknown type)");};f.prototype.decode=function(a,b,e){if(a!=this.type.wireType&&(e||a!=c.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!e){a=b.readVarint32();a=b.offset+a;for(e=[];b.offset<a;)e.push(this.decode(this.type.wireType,b,!0));return e}switch(this.type){case c.TYPES.int32:return b.readVarint32()|
75
- 0;case c.TYPES.uint32:return b.readVarint32()>>>0;case c.TYPES.sint32:return b.readVarint32ZigZag()|0;case c.TYPES.fixed32:return b.readUint32()>>>0;case c.TYPES.sfixed32:return b.readInt32()|0;case c.TYPES.int64:return b.readVarint64();case c.TYPES.uint64:return b.readVarint64().toUnsigned();case c.TYPES.sint64:return b.readVarint64ZigZag();case c.TYPES.fixed64:return b.readUint64();case c.TYPES.sfixed64:return b.readInt64();case c.TYPES.bool:return!!b.readVarint32();case c.TYPES["enum"]:return b.readVarint32();
76
- case c.TYPES["float"]:return b.readFloat();case c.TYPES["double"]:return b.readDouble();case c.TYPES.string:return b.readVString();case c.TYPES.bytes:a=b.readVarint32();if(b.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+b.remaining());e=b.clone();e.limit=e.offset+a;b.offset+=a;return e;case c.TYPES.message:return a=b.readVarint32(),this.resolvedType.decode(b,a);case c.TYPES.group:return this.resolvedType.decode(b,-1,this.id)}throw Error("[INTERNAL] Illegal wire type for "+
77
- this.toString(!0)+": "+a);};l.Message.Field=f;var n=function(a,b,e,c,d,g){f.call(this,a,b,e,c,d,g)};n.prototype=Object.create(f.prototype);l.Message.ExtensionField=n;var h=function(a,e,c){b.call(this,a,e,c);this.className="Enum";this.object=null};h.prototype=Object.create(b.prototype);h.prototype.build=function(){for(var a={},b=this.getChildren(h.Value),e=0,c=b.length;e<c;++e)a[b[e].name]=b[e].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return this.object=
78
- a};l.Enum=h;n=function(a,b,c){e.call(this,a,b);this.className="Enum.Value";this.id=c};n.prototype=Object.create(e.prototype);l.Enum.Value=n;var p=function(a,b,c){e.call(this,a,b);this.field=c};p.prototype=Object.create(e.prototype);l.Extension=p;n=function(a,e,c){b.call(this,a,e,c);this.className="Service";this.clazz=null};n.prototype=Object.create(b.prototype);n.prototype.build=function(a){return this.clazz&&!a?this.clazz:this.clazz=function(a,b){var e=function(b){a.Builder.Service.call(this);this.rpcImpl=
79
- b||function(a,b,e){setTimeout(e.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}};e.prototype=Object.create(a.Builder.Service.prototype);Object.defineProperty&&(Object.defineProperty(e,"$options",{value:b.buildOpt()}),Object.defineProperty(e.prototype,"$options",{value:e.$options}));for(var c=b.getChildren(a.Reflect.Service.RPCMethod),d=0;d<c.length;d++)(function(a){e.prototype[a.name]=function(e,c){try{e&&e instanceof a.resolvedRequestType.clazz?
80
- this.rpcImpl(a.fqn(),e,function(e,d){if(e)c(e);else{try{d=a.resolvedResponseType.clazz.decode(d)}catch(f){}d&&d instanceof a.resolvedResponseType.clazz?c(null,d):c(Error("Illegal response type received in service method "+b.name+"#"+a.name))}}):setTimeout(c.bind(this,Error("Illegal request type provided to service method "+b.name+"#"+a.name)),0)}catch(d){setTimeout(c.bind(this,d),0)}};e[a.name]=function(b,c,d){(new e(b))[a.name](c,d)};Object.defineProperty&&(Object.defineProperty(e[a.name],"$options",
81
- {value:a.buildOpt()}),Object.defineProperty(e.prototype[a.name],"$options",{value:e[a.name].$options}))})(c[d]);return e}(c,this)};l.Service=n;var q=function(a,b,c){e.call(this,a,b);this.className="Service.Method";this.options=c||{}};q.prototype=Object.create(e.prototype);q.prototype.buildOpt=b.prototype.buildOpt;l.Service.Method=q;n=function(a,b,e,c,d){q.call(this,a,b,d);this.className="Service.RPCMethod";this.requestName=e;this.responseName=c;this.resolvedResponseType=this.resolvedRequestType=null};
82
- n.prototype=Object.create(q.prototype);l.Service.RPCMethod=n;return l}(g);g.Builder=function(c,d,g){var l=function(){this.ptr=this.ns=new g.Namespace(null,"");this.resolved=!1;this.result=null;this.files={};this.importRoot=null};l.prototype.reset=function(){this.ptr=this.ns};l.prototype.define=function(e,b){if("string"!==typeof e||!d.TYPEREF.test(e))throw Error("Illegal package: "+e);var a=e.split("."),c;for(c=0;c<a.length;c++)if(!d.NAME.test(a[c]))throw Error("Illegal package: "+a[c]);for(c=0;c<
83
- a.length;c++)null===this.ptr.getChild(a[c])&&this.ptr.addChild(new g.Namespace(this.ptr,a[c],b)),this.ptr=this.ptr.getChild(a[c]);return this};l.isValidMessage=function(e){if("string"!==typeof e.name||!d.NAME.test(e.name)||"undefined"!==typeof e.values||"undefined"!==typeof e.rpc)return!1;var b;if("undefined"!==typeof e.fields){if(!c.Util.isArray(e.fields))return!1;var a=[],f;for(b=0;b<e.fields.length;b++){if(!l.isValidMessageField(e.fields[b]))return!1;f=parseInt(e.fields[b].id,10);if(0<=a.indexOf(f))return!1;
84
- a.push(f)}}if("undefined"!==typeof e.enums){if(!c.Util.isArray(e.enums))return!1;for(b=0;b<e.enums.length;b++)if(!l.isValidEnum(e.enums[b]))return!1}if("undefined"!==typeof e.messages){if(!c.Util.isArray(e.messages))return!1;for(b=0;b<e.messages.length;b++)if(!l.isValidMessage(e.messages[b])&&!l.isValidExtend(e.messages[b]))return!1}return"undefined"===typeof e.extensions||c.Util.isArray(e.extensions)&&2===e.extensions.length&&"number"===typeof e.extensions[0]&&"number"===typeof e.extensions[1]?!0:
85
- !1};l.isValidMessageField=function(e){if("string"!==typeof e.rule||"string"!==typeof e.name||"string"!==typeof e.type||"undefined"===typeof e.id||!(d.RULE.test(e.rule)&&d.NAME.test(e.name)&&d.TYPEREF.test(e.type)&&d.ID.test(""+e.id)))return!1;if("undefined"!==typeof e.options){if("object"!==typeof e.options)return!1;for(var b=Object.keys(e.options),a=0,c;a<b.length;a++)if("string"!==typeof(c=b[a])||"string"!==typeof e.options[c]&&"number"!==typeof e.options[c]&&"boolean"!==typeof e.options[c])return!1}return!0};
86
- l.isValidEnum=function(e){if("string"!==typeof e.name||!d.NAME.test(e.name)||"undefined"===typeof e.values||!c.Util.isArray(e.values)||0==e.values.length)return!1;for(var b=0;b<e.values.length;b++)if("object"!=typeof e.values[b]||"string"!==typeof e.values[b].name||"undefined"===typeof e.values[b].id||!d.NAME.test(e.values[b].name)||!d.NEGID.test(""+e.values[b].id))return!1;return!0};l.prototype.create=function(e){if(!e)return this;c.Util.isArray(e)||(e=[e]);if(0==e.length)return this;var b=[],a,
87
- d,k,h,p;for(b.push(e);0<b.length;){e=b.pop();if(c.Util.isArray(e))for(;0<e.length;)if(a=e.shift(),l.isValidMessage(a)){d=new g.Message(this.ptr,a.name,a.options,a.isGroup);if(a.fields&&0<a.fields.length)for(h=0;h<a.fields.length;h++){if(null!==d.getChild(a.fields[h].id))throw Error("Duplicate field id in message "+d.name+": "+a.fields[h].id);if(a.fields[h].options)for(k=Object.keys(a.fields[h].options),p=0;p<k.length;p++){if("string"!==typeof k[p])throw Error("Illegal field option name in message "+
88
- d.name+"#"+a.fields[h].name+": "+k[p]);if("string"!==typeof a.fields[h].options[k[p]]&&"number"!==typeof a.fields[h].options[k[p]]&&"boolean"!==typeof a.fields[h].options[k[p]])throw Error("Illegal field option value in message "+d.name+"#"+a.fields[h].name+"#"+k[p]+": "+a.fields[h].options[k[p]]);}d.addChild(new g.Message.Field(d,a.fields[h].rule,a.fields[h].type,a.fields[h].name,a.fields[h].id,a.fields[h].options))}k=[];if("undefined"!==typeof a.enums&&0<a.enums.length)for(h=0;h<a.enums.length;h++)k.push(a.enums[h]);
89
- if(a.messages&&0<a.messages.length)for(h=0;h<a.messages.length;h++)k.push(a.messages[h]);a.extensions&&(d.extensions=a.extensions,d.extensions[0]<c.ID_MIN&&(d.extensions[0]=c.ID_MIN),d.extensions[1]>c.ID_MAX&&(d.extensions[1]=c.ID_MAX));this.ptr.addChild(d);0<k.length&&(b.push(e),e=k,this.ptr=d)}else if(l.isValidEnum(a)){d=new g.Enum(this.ptr,a.name,a.options);for(h=0;h<a.values.length;h++)d.addChild(new g.Enum.Value(d,a.values[h].name,a.values[h].id));this.ptr.addChild(d)}else if(l.isValidService(a)){d=
90
- new g.Service(this.ptr,a.name,a.options);for(h in a.rpc)a.rpc.hasOwnProperty(h)&&d.addChild(new g.Service.RPCMethod(d,h,a.rpc[h].request,a.rpc[h].response,a.rpc[h].options));this.ptr.addChild(d)}else if(l.isValidExtend(a))if(d=this.ptr.resolve(a.ref))for(h=0;h<a.fields.length;h++){if(null!==d.getChild(a.fields[h].id))throw Error("Duplicate extended field id in message "+d.name+": "+a.fields[h].id);if(a.fields[h].id<d.extensions[0]||a.fields[h].id>d.extensions[1])throw Error("Illegal extended field id in message "+
91
- d.name+": "+a.fields[h].id+" ("+d.extensions.join(" to ")+" expected)");k=new g.Message.ExtensionField(d,a.fields[h].rule,a.fields[h].type,this.ptr.fqn()+"."+a.fields[h].name,a.fields[h].id,a.fields[h].options);p=new g.Extension(this.ptr,a.fields[h].name,k);k.extension=p;this.ptr.addChild(p);d.addChild(k)}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a));else throw Error("Not a valid namespace: "+
92
- JSON.stringify(e));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};l.prototype["import"]=function(e,b){if("string"===typeof b){c.Util.IS_NODE&&(b=require("path").resolve(b));if(!0===this.files[b])return this.reset(),this;this.files[b]=!0}if(e.imports&&0<e.imports.length){var a,d="/",g=!1;if("object"===typeof b){if(this.importRoot=b.root,g=!0,a=this.importRoot,b=b.file,0<=a.indexOf("\\")||0<=b.indexOf("\\"))d="\\"}else"string"===typeof b?this.importRoot?a=this.importRoot:0<=
93
- b.indexOf("/")?(a=b.replace(/\/[^\/]*$/,""),""===a&&(a="/")):0<=b.indexOf("\\")?(a=b.replace(/\\[^\\]*$/,""),d="\\"):a=".":a=null;for(var h=0;h<e.imports.length;h++)if("string"===typeof e.imports[h]){if(!a)throw Error("Cannot determine import root: File name is unknown");var l=e.imports[h];if(!/^google\/protobuf\//.test(l)&&(l=a+d+l,!0!==this.files[l])){/\.proto$/i.test(l)&&!c.DotProto&&(l=l.replace(/\.proto$/,".json"));var k=c.Util.fetch(l);if(null===k)throw Error("Failed to import '"+l+"' in '"+
94
- b+"': File not found");if(/\.json$/i.test(l))this["import"](JSON.parse(k+""),l);else this["import"]((new c.DotProto.Parser(k+"")).parse(),l)}}else if(b)if(/\.(\w+)$/.test(b))this["import"](e.imports[h],b.replace(/^(.+)\.(\w+)$/,function(a,b,c){return b+"_import"+h+"."+c}));else this["import"](e.imports[h],b+"_import"+h);else this["import"](e.imports[h]);g&&(this.importRoot=null)}e.messages&&(e["package"]&&this.define(e["package"],e.options),this.create(e.messages),this.reset());e.enums&&(e["package"]&&
95
- this.define(e["package"],e.options),this.create(e.enums),this.reset());e.services&&(e["package"]&&this.define(e["package"],e.options),this.create(e.services),this.reset());e["extends"]&&(e["package"]&&this.define(e["package"],e.options),this.create(e["extends"]),this.reset());return this};l.isValidService=function(c){return!("string"!==typeof c.name||!d.NAME.test(c.name)||"object"!==typeof c.rpc)};l.isValidExtend=function(e){if("string"!==typeof e.ref||!d.TYPEREF.test(e.ref))return!1;var b;if("undefined"!==
96
- typeof e.fields){if(!c.Util.isArray(e.fields))return!1;var a=[],f;for(b=0;b<e.fields.length;b++){if(!l.isValidMessageField(e.fields[b]))return!1;f=parseInt(e.id,10);if(0<=a.indexOf(f))return!1;a.push(f)}}return!0};l.prototype.resolveAll=function(){var e;if(null!=this.ptr&&"object"!==typeof this.ptr.type){if(this.ptr instanceof g.Namespace){e=this.ptr.children;for(var b=0,a=e.length;b<a;++b)this.ptr=e[b],this.resolveAll()}else if(this.ptr instanceof g.Message.Field)if(d.TYPE.test(this.ptr.type))this.ptr.type=
97
- c.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);e=(this.ptr instanceof g.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0);if(!e)throw Error("Unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=e;if(e instanceof g.Enum)this.ptr.type=c.TYPES["enum"];else if(e instanceof g.Message)this.ptr.type=e.isGroup?c.TYPES.group:
98
- c.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}else if(!(this.ptr instanceof c.Reflect.Enum.Value))if(this.ptr instanceof c.Reflect.Service.Method)if(this.ptr instanceof c.Reflect.Service.RPCMethod){e=this.ptr.parent.resolve(this.ptr.requestName);if(!(e&&e instanceof c.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=e;e=this.ptr.parent.resolve(this.ptr.responseName);
99
- if(!(e&&e instanceof c.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=e}else throw Error("Illegal service type in "+this.ptr.toString(!0));else if(!(this.ptr instanceof c.Reflect.Extension))throw Error("Illegal object in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};l.prototype.build=function(c){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null==this.result&&
100
- (this.result=this.ns.build());if(c){c=c.split(".");for(var b=this.result,a=0;a<c.length;a++)if(b[c[a]])b=b[c[a]];else{b=null;break}return b}return this.result};l.prototype.lookup=function(c){return c?this.ns.resolve(c):this.ns};l.prototype.toString=function(){return"Builder"};l.Message=function(){};l.Service=function(){};return l}(g,g.Lang,g.Reflect);g.loadProto=function(c,d,k){if("string"===typeof d||d&&"string"===typeof d.file&&"string"===typeof d.root)k=d,d=null;return g.loadJson((new g.DotProto.Parser(c)).parse(),
101
- d,k)};g.protoFromString=g.loadProto;g.loadProtoFile=function(c,d,k){d&&"object"===typeof d?(k=d,d=null):d&&"function"===typeof d||(d=null);if(d)return g.Util.fetch("string"===typeof c?c:c.root+"/"+c.file,function(e){if(null===e)d(Error("Failed to fetch file"));else try{d(null,g.loadProto(e,k,c))}catch(b){d(b)}});var l=g.Util.fetch("object"===typeof c?c.root+"/"+c.file:c);return null===l?null:g.loadProto(l,k,c)};g.protoFromFile=g.loadProtoFile;g.newBuilder=function(c,d){var k=new g.Builder;"undefined"!==
102
- typeof c&&null!==c&&k.define(c,d);return k};g.loadJson=function(c,d,k){if("string"===typeof d||d&&"string"===typeof d.file&&"string"===typeof d.root)k=d,d=null;d&&"object"===typeof d||(d=g.newBuilder());"string"===typeof c&&(c=JSON.parse(c));d["import"](c,k);d.resolveAll();d.build();return d};g.loadJsonFile=function(c,d,k){d&&"object"===typeof d?(k=d,d=null):d&&"function"===typeof d||(d=null);if(d)return g.Util.fetch("string"===typeof c?c:c.root+"/"+c.file,function(e){if(null===e)d(Error("Failed to fetch file"));
103
- else try{d(null,g.loadJson(JSON.parse(e),k,c))}catch(b){d(b)}});var l=g.Util.fetch("object"===typeof c?c.root+"/"+c.file:c);return null===l?null:g.loadJson(JSON.parse(l),k,c)};return g}"undefined"!==typeof module&&module.exports?module.exports=s(require("bytebuffer")):"function"===typeof define&&define.amd?define(["ByteBuffer"],s):(r.dcodeIO=r.dcodeIO||{}).ProtoBuf=s(r.dcodeIO.ByteBuffer)})(this);
13
+ NEGID:/^\-?(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,BOOL:/^(?:true|false)$/i};g.DotProto=function(e,d){var g={},k=function(f){this.source=""+f;this.index=0;this.line=1;this.stack=[];this.readingString=!1;this.stringEndsWith=d.STRINGCLOSE},n=k.prototype;n._readString=function(){d.STRING.lastIndex=this.index-1;var f;if(null!==(f=d.STRING.exec(this.source)))return f="undefined"!==typeof f[1]?f[1]:f[2],this.index=
14
+ d.STRING.lastIndex,this.stack.push(this.stringEndsWith),f;throw Error("Unterminated string at line "+this.line+", index "+this.index);};n.next=function(){if(0<this.stack.length)return this.stack.shift();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var f,a;do{for(f=!1;d.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===
15
+ this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,this.index==this.source.length)return null;this.index++;this.line++;f=!0}else if("*"===this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;this.index++;f=!0}else throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));}while(f);if(this.index===this.source.length)return null;
16
+ f=this.index;d.DELIM.lastIndex=0;if(d.DELIM.test(this.source.charAt(f)))++f;else for(++f;f<this.source.length&&!d.DELIM.test(this.source.charAt(f));)f++;f=this.source.substring(this.index,this.index=f);f===d.STRINGOPEN?(this.readingString=!0,this.stringEndsWith=d.STRINGCLOSE):f===d.STRINGOPEN_SQ&&(this.readingString=!0,this.stringEndsWith=d.STRINGCLOSE_SQ);return f};n.peek=function(){if(0===this.stack.length){var f=this.next();if(null===f)return null;this.stack.push(f)}return this.stack[0]};n.toString=
17
+ function(){return"Tokenizer("+this.index+"/"+this.source.length+" at line "+this.line+")"};g.Tokenizer=k;var n=function(f){this.tn=new k(f)},b=n.prototype;b.parse=function(){for(var f={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{},services:[]},a,c=!0;a=this.tn.next();)switch(a){case "package":if(!c||null!==f["package"])throw Error("Unexpected package at line "+this.tn.line);f["package"]=this._parsePackage(a);break;case "import":if(!c)throw Error("Unexpected import at line "+
18
+ this.tn.line);f.imports.push(this._parseImport(a));break;case "message":this._parseMessage(f,null,a);c=!1;break;case "enum":this._parseEnum(f,a);c=!1;break;case "option":if(!c)throw Error("Unexpected option at line "+this.tn.line);this._parseOption(f,a);break;case "service":this._parseService(f,a);break;case "extend":this._parseExtend(f,a);break;case "syntax":this._parseIgnoredStatement(f,a);break;default:throw Error("Unexpected token at line "+this.tn.line+": "+a);}delete f.name;return f};b._parseNumber=
19
+ function(f){var a=1;"-"==f.charAt(0)&&(a=-1,f=f.substring(1));if(d.NUMBER_DEC.test(f))return a*parseInt(f,10);if(d.NUMBER_HEX.test(f))return a*parseInt(f.substring(2),16);if(d.NUMBER_OCT.test(f))return a*parseInt(f.substring(1),8);if(d.NUMBER_FLT.test(f))return a*parseFloat(f);throw Error("Illegal number at line "+this.tn.line+": "+(0>a?"-":"")+f);};b._parseString=function(){var f="",a;do{this.tn.next();f+=this.tn.next();a=this.tn.next();if(a!==this.tn.stringEndsWith)throw Error("Illegal end of string at line "+
20
+ this.tn.line+": "+a);a=this.tn.peek()}while(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ);return f};b._parseId=function(f,a){var c=-1,b=1;"-"==f.charAt(0)&&(b=-1,f=f.substring(1));if(d.NUMBER_DEC.test(f))c=parseInt(f);else if(d.NUMBER_HEX.test(f))c=parseInt(f.substring(2),16);else if(d.NUMBER_OCT.test(f))c=parseInt(f.substring(1),8);else throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);c=b*c|0;if(!a&&0>c)throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);return c};b._parsePackage=
21
+ function(f){f=this.tn.next();if(!d.TYPEREF.test(f))throw Error("Illegal package name at line "+this.tn.line+": "+f);var a=f;f=this.tn.next();if(f!=d.END)throw Error("Illegal end of package at line "+this.tn.line+": "+f);return a};b._parseImport=function(f){f=this.tn.peek();"public"===f&&(this.tn.next(),f=this.tn.peek());if(f!==d.STRINGOPEN&&f!==d.STRINGOPEN_SQ)throw Error("Illegal start of import at line "+this.tn.line+": "+f);var a=this._parseString();f=this.tn.next();if(f!==d.END)throw Error("Illegal end of import at line "+
22
+ this.tn.line+": "+f);return a};b._parseOption=function(f,a){a=this.tn.next();var c=!1;a==d.COPTOPEN&&(c=!0,a=this.tn.next());if(!d.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option name in message "+f.name+" at line "+this.tn.line+": "+a);var b=a;a=this.tn.next();if(c){if(a!==d.COPTCLOSE)throw Error("Illegal end in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);b="("+b+")";a=this.tn.next();d.FQTYPEREF.test(a)&&(b+=a,a=this.tn.next())}if(a!==d.EQUAL)throw Error("Illegal operator in message "+
23
+ f.name+", option "+b+" at line "+this.tn.line+": "+a);a=this.tn.peek();if(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ)c=this._parseString();else if(this.tn.next(),d.NUMBER.test(a))c=this._parseNumber(a,!0);else if(d.BOOL.test(a))c="true"===a;else if(d.TYPEREF.test(a))c=a;else throw Error("Illegal option value in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!==d.END)throw Error("Illegal end of option in message "+f.name+", option "+b+" at line "+this.tn.line+": "+
24
+ a);f.options[b]=c};b._parseIgnoredStatement=function(f,a){var c;do{c=this.tn.next();if(null===c)throw Error("Unexpected EOF in "+f.name+", "+a+" at line "+this.tn.line);if(c===d.END)break}while(1)};b._parseService=function(f,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var c=a,b={name:c,rpc:{},options:{}};a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of service "+c+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),"option"===
25
+ a)this._parseOption(b,a);else if("rpc"===a)this._parseServiceRPC(b,a);else if(a!==d.CLOSE)throw Error("Illegal type of service "+c+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);f.services.push(b)};b._parseServiceRPC=function(f,a){var c=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal method name in service "+f.name+" at line "+this.tn.line+": "+a);var b=a,e={request:null,response:null,options:{}};a=this.tn.next();if(a!==d.COPTOPEN)throw Error("Illegal start of request type in service "+
26
+ f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);e.request=a;a=this.tn.next();if(a!=d.COPTCLOSE)throw Error("Illegal end of request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal delimiter in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=d.COPTOPEN)throw Error("Illegal start of response type in service "+
27
+ f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();e.response=a;a=this.tn.next();if(a!==d.COPTCLOSE)throw Error("Illegal end of response type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a===d.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(e,a);else if(a!==d.CLOSE)throw Error("Illegal start of option inservice "+f.name+"#"+b+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);this.tn.peek()===d.END&&this.tn.next()}else if(a!==d.END)throw Error("Illegal delimiter in service "+
28
+ f.name+"#"+b+" at line "+this.tn.line+": "+a);"undefined"===typeof f[c]&&(f[c]={});f[c][b]=e};b._parseMessage=function(f,a,c){var b={},e="group"===c;c=this.tn.next();if(!d.NAME.test(c))throw Error("Illegal "+(e?"group":"message")+" name"+(f?" in message "+f.name:"")+" at line "+this.tn.line+": "+c);b.name=c;if(e){c=this.tn.next();if(c!==d.EQUAL)throw Error("Illegal id assignment after group "+b.name+" at line "+this.tn.line+": "+c);c=this.tn.next();try{a.id=this._parseId(c)}catch(g){throw Error("Illegal field id value for group "+
29
+ b.name+"#"+a.name+" at line "+this.tn.line+": "+c);}b.isGroup=!0}b.fields=[];b.enums=[];b.messages=[];b.options={};b.oneofs={};c=this.tn.next();c===d.OPTOPEN&&a&&(this._parseFieldOptions(b,a,c),c=this.tn.next());if(c!==d.OPEN)throw Error("Illegal start of "+(e?"group":"message")+" "+b.name+" at line "+this.tn.line+": "+c);do if(c=this.tn.next(),c===d.CLOSE){c=this.tn.peek();c===d.END&&this.tn.next();break}else if(d.RULE.test(c))this._parseMessageField(b,c);else if("oneof"===c)this._parseMessageOneOf(b,
30
+ c);else if("enum"===c)this._parseEnum(b,c);else if("message"===c)this._parseMessage(b,null,c);else if("option"===c)this._parseOption(b,c);else if("extensions"===c)b.extensions=this._parseExtensions(b,c);else if("extend"===c)this._parseExtend(b,c);else throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+c);while(1);f.messages.push(b);return b};b._parseMessageField=function(b,a){var c={},e=null;c.rule=a;c.options={};a=this.tn.next();if("group"===a){e=this._parseMessage(b,c,
31
+ a);if(!/^[A-Z]/.test(e.name))throw Error("Group names must start with a capital letter");c.type=e.name;c.name=e.name.toLowerCase();a=this.tn.peek();a===d.END&&this.tn.next()}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("Illegal field type in message "+b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal field name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in field "+
32
+ b.name+"#"+c.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}b.fields.push(c);return c};b._parseMessageOneOf=function(b,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal oneof name in message "+
33
+ b.name+" at line "+this.tn.line+": "+a);var c=a,e,g=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of oneof "+c+" at line "+this.tn.line+": "+a);for(;this.tn.peek()!==d.CLOSE;)e=this._parseMessageField(b,"optional"),e.oneof=c,g.push(e.id);this.tn.next();b.oneofs[c]=g};b._parseFieldOptions=function(b,a,c){var e=!0;do{c=this.tn.next();if(c===d.OPTCLOSE)break;else if(c===d.OPTEND){if(e)throw Error("Illegal start of options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);
34
+ c=this.tn.next()}this._parseFieldOption(b,a,c);e=!1}while(1)};b._parseFieldOption=function(b,a,c){var e=!1;c===d.COPTOPEN&&(c=this.tn.next(),e=!0);if(!d.TYPEREF.test(c))throw Error("Illegal field option in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);var g=c;c=this.tn.next();if(e){if(c!==d.COPTCLOSE)throw Error("Illegal delimiter in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);g="("+g+")";c=this.tn.next();d.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==d.EQUAL)throw Error("Illegal token in "+
35
+ b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.peek();if(c===d.STRINGOPEN||c===d.STRINGOPEN_SQ)b=this._parseString();else if(d.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(d.BOOL.test(c))b="true"===this.tn.next().toLowerCase();else if(d.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal value in message "+b.name+"#"+a.name+", option "+g+" at line "+this.tn.line+": "+c);a.options[g]=b};b._parseEnum=function(b,a){var c={};a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal enum name in message "+
36
+ b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of enum "+c.name+" at line "+this.tn.line+": "+a);c.values=[];c.options={};do{a=this.tn.next();if(a===d.CLOSE){a=this.tn.peek();a===d.END&&this.tn.next();break}if("option"==a)this._parseOption(c,a);else{if(!d.NAME.test(a))throw Error("Illegal name in enum "+c.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(c,a)}}while(1);b.enums.push(c)};b._parseEnumValue=function(b,a){var c={};c.name=
37
+ a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in enum "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a,!0)}catch(e){throw Error("Illegal id in enum "+b.name+" at line "+this.tn.line+": "+a);}b.values.push(c);a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,{options:{}},a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in enum "+b.name+" at line "+this.tn.line+": "+a);};b._parseExtensions=function(b,a){var c=[];a=this.tn.next();
38
+ "min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();"min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if(a!==d.END)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);return c};b._parseExtend=function(b,a){a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal message name at line "+
39
+ this.tn.line+": "+a);var c={};c.ref=a;c.fields=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of extend "+c.name+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),a===d.CLOSE){a=this.tn.peek();a==d.END&&this.tn.next();break}else if(d.RULE.test(a))this._parseMessageField(c,a);else throw Error("Illegal token in extend "+c.name+" at line "+this.tn.line+": "+a);while(1);b.messages.push(c);return c};b.toString=function(){return"Parser"};g.Parser=n;return g}(g,g.Lang);g.Reflect=function(e){function d(a,
40
+ b){var c=b.readVarint32(),f=c&7,c=c>>3;switch(f){case e.WIRE_TYPES.VARINT:do c=b.readUint8();while(128===(c&128));break;case e.WIRE_TYPES.BITS64:b.offset+=8;break;case e.WIRE_TYPES.LDELIM:c=b.readVarint32();b.offset+=c;break;case e.WIRE_TYPES.STARTGROUP:d(c,b);break;case e.WIRE_TYPES.ENDGROUP:if(c===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+c+" ("+a+" expected)");case e.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+f);}return!0}
41
+ function g(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new e.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return e.Long.fromString(a,b||!1,10);if("number"===typeof a)return e.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}var k={},n=function(a,b,c){this.builder=a;this.parent=b;this.name=c},b=n.prototype;b.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null==
42
+ b)break;a=b.name+"."+a}while(1);return a};b.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};k.T=n;var f=function(a,b,c,e){n.call(this,a,b,c);this.className="Namespace";this.children=[];this.options=e||{}},b=f.prototype=Object.create(n.prototype);b.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],c=0,e=this.children.length;c<e;++c)this.children[c]instanceof a&&b.push(this.children[c]);
43
+ return b};b.addChild=function(b){var c;if(c=this.getChild(b.name))if(c instanceof a.Field&&c.name!==c.originalName&&null===this.getChild(c.originalName))c.name=c.originalName;else if(b instanceof a.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)};b.getChild=function(a){for(var b="number"===typeof a?"id":"name",c=0,e=this.children.length;c<e;++c)if(this.children[c][b]===
44
+ a)return this.children[c];return null};b.resolve=function(a,b){var c=a.split("."),e=this,f=0;if(""===c[f]){for(;null!==e.parent;)e=e.parent;f++}do{do{e=e.getChild(c[f]);if(!(e&&e instanceof k.T)||b&&e instanceof k.Message.Field){e=null;break}f++}while(f<c.length);if(null!=e)break;if(null!==this.parent)return this.parent.resolve(a,b)}while(null!=e);return e};b.build=function(){for(var a={},b=this.children,c=0,e=b.length,d;c<e;++c)d=b[c],d instanceof f&&(a[d.name]=d.build());Object.defineProperty&&
45
+ Object.defineProperty(a,"$options",{value:this.buildOpt()});return a};b.buildOpt=function(){for(var a={},b=Object.keys(this.options),c=0,e=b.length;c<e;++c)a[b[c]]=this.options[b[c]];return a};b.getOption=function(a){return"undefined"===typeof a?this.options:"undefined"!==typeof this.options[a]?this.options[a]:null};k.Namespace=f;var a=function(a,b,c,d,g){f.call(this,a,b,c,d);this.className="Message";this.extensions=[e.ID_MIN,e.ID_MAX];this.clazz=null;this.isGroup=!!g;this._fieldsByName=this._fieldsById=
46
+ this._fields=null},c=a.prototype=Object.create(f.prototype);c.build=function(b){if(this.clazz&&!b)return this.clazz;b=function(a,b){function c(a,b){var e={},m;for(m in a)a.hasOwnProperty(m)&&(null===a[m]||"object"!==typeof a[m]?e[m]=a[m]:a[m]instanceof l?b&&(e[m]=a[m].toBase64()):e[m]=c(a[m],b));return e}var e=b.getChildren(a.Reflect.Message.Field),m=b.getChildren(a.Reflect.Message.OneOf),f=function(b,c){a.Builder.Message.call(this);for(var d=0,f=m.length;d<f;++d)this[m[d].name]=null;d=0;for(f=e.length;d<
47
+ f;++d){var q=e[d];this[q.name]=q.repeated?[]:null;q.required&&null!==q.defaultValue&&(this[q.name]=q.defaultValue)}if(0<arguments.length)if(1!==arguments.length||"object"!==typeof b||"function"===typeof b.encode||a.Util.isArray(b)||b instanceof l||b instanceof ArrayBuffer||a.Long&&b instanceof a.Long)for(d=0,f=arguments.length;d<f;++d)this.$set(e[d].name,arguments[d]);else for(q=Object.keys(b),d=0,f=q.length;d<f;++d)this.$set(q[d],b[q[d]])},d=f.prototype=Object.create(a.Builder.Message.prototype);
48
+ d.add=function(c,e,d){var m=b._fieldsByName[c];if(!d){if(!m)throw Error(this+"#"+c+" is undefined");if(!(m instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+m.toString(!0));if(!m.repeated)throw Error(this+"#"+c+" is not a repeated field");}null===this[m.name]&&(this[m.name]=[]);this[m.name].push(d?e:m.verifyValue(e,!0))};d.$add=d.add;d.set=function(c,e,m){if(c&&"object"===typeof c){for(var d in c)c.hasOwnProperty(d)&&this.$set(d,c[d],m);return this}d=b._fieldsByName[c];
49
+ if(m)this[d.name]=e;else{if(!d)throw Error(this+"#"+c+" is not a field: undefined");if(!(d instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+d.toString(!0));this[d.name]=e=d.verifyValue(e)}d.oneof&&(null!==e?(null!==this[d.oneof.name]&&(this[this[d.oneof.name]]=null),this[d.oneof.name]=d.name):d.oneof.name===c&&(this[d.oneof.name]=null));return this};d.$set=d.set;d.get=function(c,d){if(d)return this[c];var e=b._fieldsByName[c];if(!(e&&e instanceof a.Reflect.Message.Field))throw Error(this+
50
+ "#"+c+" is not a field: undefined");if(!(e instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+e.toString(!0));return this[e.name]};d.$get=d.get;for(var q=0;q<e.length;q++){var g=e[q];g 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),e=a.originalName.replace(/([A-Z])/g,function(a){return"_"+
51
+ a}),m=function(b,c){this[a.name]=c?b:a.verifyValue(b);return this},f=function(){return this[a.name]};null===b.getChild("set"+c)&&(d["set"+c]=m);null===b.getChild("set_"+e)&&(d["set_"+e]=m);null===b.getChild("get"+c)&&(d["get"+c]=f);null===b.getChild("get_"+e)&&(d["get_"+e]=f)}(g)}d.encode=function(a,c){"boolean"===typeof a&&(c=a,a=void 0);var e=!1;a||(a=new l,e=!0);var d=a.littleEndian;try{return b.encode(this,a.LE(),c),(e?a.flip():a).LE(d)}catch(m){throw a.LE(d),m;}};d.calculate=function(){return b.calculate(this)};
52
+ d.encodeDelimited=function(a){var c=!1;a||(a=new l,c=!0);var e=(new l).LE();b.encode(this,e).flip();a.writeVarint32(e.remaining());a.append(e);return c?a.flip():a};d.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toArrayBuffer()),a;}};d.toArrayBuffer=d.encodeAB;d.encodeNB=function(){try{return this.encode().toBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBuffer()),a;}};d.toBuffer=d.encodeNB;d.encode64=function(){try{return this.encode().toBase64()}catch(a){throw a.encoded&&
53
+ (a.encoded=a.encoded.toBase64()),a;}};d.toBase64=d.encode64;d.encodeHex=function(){try{return this.encode().toHex()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toHex()),a;}};d.toHex=d.encodeHex;d.toRaw=function(a){return c(this,!!a)};f.decode=function(a,c){"string"===typeof a&&(a=l.wrap(a,c?c:"base64"));a=a instanceof l?a:l.wrap(a);var e=a.littleEndian;try{var d=b.decode(a.LE());a.LE(e);return d}catch(m){throw a.LE(e),m;}};f.decodeDelimited=function(a,c){"string"===typeof a&&(a=l.wrap(a,c?c:"base64"));
54
+ a=a instanceof l?a:l.wrap(a);if(1>a.remaining())return null;var e=a.offset,d=a.readVarint32();if(a.remaining()<d)return a.offset=e,null;try{var m=b.decode(a.slice(a.offset,a.offset+d).LE());a.offset+=d;return m}catch(f){throw a.offset+=d,f;}};f.decode64=function(a){return f.decode(a,"base64")};f.decodeHex=function(a){return f.decode(a,"hex")};d.toString=function(){return b.toString()};Object.defineProperty&&(Object.defineProperty(f,"$options",{value:b.buildOpt()}),Object.defineProperty(d,"$type",
55
+ {get:function(){return b}}));return f}(e,this);this._fields=[];this._fieldsById={};this._fieldsByName={};for(var c=0,f=this.children.length,d;c<f;c++)if(d=this.children[c],d instanceof p)b[d.name]=d.build();else if(d instanceof a)b[d.name]=d.build();else if(d instanceof a.Field)d.build(),this._fields.push(d),this._fieldsById[d.id]=d,this._fieldsByName[d.name]=d;else if(!(d instanceof a.OneOf||d instanceof h))throw Error("Illegal reflect child of "+this.toString(!0)+": "+children[c].toString(!0));
56
+ return this.clazz=b};c.encode=function(a,b,c){for(var e=null,d,f=0,g=this._fields.length,h;f<g;++f)d=this._fields[f],h=a[d.name],d.required&&null===h?null===e&&(e=d):d.encode(c?h:d.verifyValue(h),b);if(null!==e)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+e),a.encoded=b,a;return b};c.calculate=function(a){for(var b=0,c=0,e=this._fields.length,d,f;c<e;++c){d=this._fields[c];f=a[d.name];if(d.required&&null===f)throw Error("Missing at least one required field for "+
57
+ this.toString(!0)+": "+d);b+=d.calculate(f)}return b};c.decode=function(a,b,c){b="number"===typeof b?b:-1;for(var f=a.offset,g=new this.clazz,h,p,k;a.offset<f+b||-1===b&&0<a.remaining();){h=a.readVarint32();p=h&7;k=h>>3;if(p===e.WIRE_TYPES.ENDGROUP){if(k!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(c?c+" expected":"not a group")+")");break}if(h=this._fieldsById[k])h.repeated&&!h.options.packed?g[h.name].push(h.decode(p,a)):(g[h.name]=h.decode(p,a),h.oneof&&(null!==
58
+ this[h.oneof.name]&&(this[this[h.oneof.name]]=null),g[h.oneof.name]=h.name));else switch(p){case e.WIRE_TYPES.VARINT:a.readVarint32();break;case e.WIRE_TYPES.BITS32:a.offset+=4;break;case e.WIRE_TYPES.BITS64:a.offset+=8;break;case e.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case e.WIRE_TYPES.STARTGROUP:for(;d(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+p);}}a=0;for(b=this._fields.length;a<b;++a)if(h=this._fields[a],null===
59
+ g[h.name]){if(h.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+h.name),a.decoded=g,a;null!==h.defaultValue&&(g[h.name]=h.defaultValue)}return g};k.Message=a;var r=function(b,c,d,e,f,g,h,p){n.call(this,b,c,f);this.className="Message.Field";this.required="required"===d;this.repeated="repeated"===d;this.type=e;this.resolvedType=null;this.id=g;this.options=h||{};this.defaultValue=null;this.oneof=p||null;this.originalName=this.name;!this.builder.options.convertFieldsToCamelCase||
60
+ this instanceof a.ExtensionField||(this.name=r._toCamelCase(this.name))};r._toCamelCase=function(a){return a.replace(/_([a-zA-Z])/g,function(a,b){return b.toUpperCase()})};c=r.prototype=Object.create(n.prototype);c.build=function(){this.defaultValue="undefined"!==typeof this.options["default"]?this.verifyValue(this.options["default"]):null};c.verifyValue=function(a,b){b=b||!1;var c=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);
61
+ if(null===a)return this.required&&c(typeof a,"required"),null;var d;if(this.repeated&&!b){e.Util.isArray(a)||(a=[a]);c=[];for(d=0;d<a.length;d++)c.push(this.verifyValue(a[d],!0));return c}!this.repeated&&e.Util.isArray(a)&&c(typeof a,"no array expected");switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&c(typeof a,"not an integer"),4294967295<a?a|0:a;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!==typeof a||a===a&&
62
+ 0!==a%1)&&c(typeof a,"not an integer"),0>a?a>>>0:a;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return g(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return g(a,!0)}catch(h){c(typeof a,h.message)}else c(typeof a,"requires Long.js");case e.TYPES.bool:return"boolean"!==typeof a&&c(typeof a,"not a boolean"),a;case e.TYPES["float"]:case e.TYPES["double"]:return"number"!==typeof a&&c(typeof a,
63
+ "not a number"),a;case e.TYPES.string:return"string"===typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case e.TYPES.bytes:return l.isByteBuffer(a)?a:l.wrap(a,"base64");case e.TYPES["enum"]:var k=this.resolvedType.getChildren(p.Value);for(d=0;d<k.length;d++)if(k[d].name==a||k[d].id==a)return k[d].id;c(a,"not a valid enum value");case e.TYPES.group:case e.TYPES.message:a&&"object"===typeof a||c(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof
64
+ e.Builder.Message){c={};for(d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);a=c}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};c.encode=function(a,b){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 b;try{if(this.repeated){var c;if(this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b.writeVarint32(this.id<<
65
+ 3|e.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var d=b.offset;for(c=0;c<a.length;c++)this.encodeValue(a[c],b);var f=b.offset-d,g=l.calculateVarint32(f);if(1<g){var h=b.slice(d,b.offset),d=d+(g-1);b.offset=d;b.append(h)}b.writeVarint32(f,d-g)}else for(c=0;c<a.length;c++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a[c],b)}else b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a,b)}catch(k){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+k+")");
66
+ }return b};c.encodeValue=function(a,b){if(null===a)return b;switch(this.type){case e.TYPES.int32:0>a?b.writeVarint64(a):b.writeVarint32(a);break;case e.TYPES.uint32:b.writeVarint32(a);break;case e.TYPES.sint32:b.writeVarint32ZigZag(a);break;case e.TYPES.fixed32:b.writeUint32(a);break;case e.TYPES.sfixed32:b.writeInt32(a);break;case e.TYPES.int64:case e.TYPES.uint64:b.writeVarint64(a);break;case e.TYPES.sint64:b.writeVarint64ZigZag(a);break;case e.TYPES.fixed64:b.writeUint64(a);break;case e.TYPES.sfixed64:b.writeInt64(a);
67
+ break;case e.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case e.TYPES["enum"]:b.writeVarint32(a);break;case e.TYPES["float"]:b.writeFloat32(a);break;case e.TYPES["double"]:b.writeFloat64(a);break;case e.TYPES.string:b.writeVString(a);break;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var c=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=c;
68
+ break;case e.TYPES.message:c=(new l).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case e.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return b};c.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+
69
+ ": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,d;if(this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=l.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM);for(c=d=0;c<a.length;c++)d+=this.calculateValue(a[c]);b+=l.calculateVarint32(d);b+=d}else for(c=0;c<a.length;c++)b+=l.calculateVarint32(this.id<<3|this.type.wireType),b+=this.calculateValue(a[c])}else b+=l.calculateVarint32(this.id<<3|this.type.wireType),b+=this.calculateValue(a)}catch(f){throw Error("Illegal value for "+
70
+ this.toString(!0)+": "+a+" ("+f+")");}return b};c.calculateValue=function(a){if(null===a)return 0;switch(this.type){case e.TYPES.int32:return 0>a?l.calculateVarint64(a):l.calculateVarint32(a);case e.TYPES.uint32:return l.calculateVarint32(a);case e.TYPES.sint32:return l.calculateVarint32(l.zigZagEncode32(a));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES["float"]:return 4;case e.TYPES.int64:case e.TYPES.uint64:return l.calculateVarint64(a);case e.TYPES.sint64:return l.calculateVarint64(l.zigZagEncode64(a));
71
+ case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES["enum"]:return l.calculateVarint32(a);case e.TYPES["double"]:return 8;case e.TYPES.string:return a=l.calculateUTF8Bytes(a),l.calculateVarint32(a)+a;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return l.calculateVarint32(a.remaining())+a.remaining();case e.TYPES.message:return a=this.resolvedType.calculate(a),l.calculateVarint32(a)+
72
+ a;case e.TYPES.group:return a=this.resolvedType.calculate(a),a+l.calculateVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};c.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=e.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&
73
+ !c){a=b.readVarint32();a=b.offset+a;for(c=[];b.offset<a;)c.push(this.decode(this.type.wireType,b,!0));return c}switch(this.type){case e.TYPES.int32:return b.readVarint32()|0;case e.TYPES.uint32:return b.readVarint32()>>>0;case e.TYPES.sint32:return b.readVarint32ZigZag()|0;case e.TYPES.fixed32:return b.readUint32()>>>0;case e.TYPES.sfixed32:return b.readInt32()|0;case e.TYPES.int64:return b.readVarint64();case e.TYPES.uint64:return b.readVarint64().toUnsigned();case e.TYPES.sint64:return b.readVarint64ZigZag();
74
+ case e.TYPES.fixed64:return b.readUint64();case e.TYPES.sfixed64:return b.readInt64();case e.TYPES.bool:return!!b.readVarint32();case e.TYPES["enum"]:return b.readVarint32();case e.TYPES["float"]:return b.readFloat();case e.TYPES["double"]:return b.readDouble();case e.TYPES.string:return b.readVString();case e.TYPES.bytes:a=b.readVarint32();if(b.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+b.remaining());c=b.clone();c.limit=c.offset+a;
75
+ b.offset+=a;return c;case e.TYPES.message:return a=b.readVarint32(),this.resolvedType.decode(b,a);case e.TYPES.group:return this.resolvedType.decode(b,-1,this.id)}throw Error("[INTERNAL] Illegal wire type for "+this.toString(!0)+": "+a);};k.Message.Field=r;c=function(a,b,c,d,e,f,g){r.call(this,a,b,c,d,e,f,g)};c.prototype=Object.create(r.prototype);k.Message.ExtensionField=c;k.Message.OneOf=function(a,b,c){n.call(this,a,b,c);this.fields=[]};var p=function(a,b,c,d){f.call(this,a,b,c,d);this.className=
76
+ "Enum";this.object=null};(p.prototype=Object.create(f.prototype)).build=function(){for(var a={},b=this.getChildren(p.Value),c=0,d=b.length;c<d;++c)a[b[c].name]=b[c].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return this.object=a};k.Enum=p;c=function(a,b,c,d){n.call(this,a,b,c);this.className="Enum.Value";this.id=d};c.prototype=Object.create(n.prototype);k.Enum.Value=c;var h=function(a,b,c,d){n.call(this,a,b,c);this.field=d};h.prototype=Object.create(n.prototype);
77
+ k.Extension=h;c=function(a,b,c,d){f.call(this,a,b,c,d);this.className="Service";this.clazz=null};(c.prototype=Object.create(f.prototype)).build=function(a){return this.clazz&&!a?this.clazz:this.clazz=function(a,b){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);Object.defineProperty&&(Object.defineProperty(c,
78
+ "$options",{value:b.buildOpt()}),Object.defineProperty(d,"$options",{value:c.$options}));for(var e=b.getChildren(a.Reflect.Service.RPCMethod),f=0;f<e.length;f++)(function(a){d[a.name]=function(c,d){try{c&&c instanceof a.resolvedRequestType.clazz?this.rpcImpl(a.fqn(),c,function(c,e){if(c)d(c);else{try{e=a.resolvedResponseType.clazz.decode(e)}catch(f){}e&&e instanceof a.resolvedResponseType.clazz?d(null,e):d(Error("Illegal response type received in service method "+b.name+"#"+a.name))}}):setTimeout(d.bind(this,
79
+ Error("Illegal request type provided to service method "+b.name+"#"+a.name)),0)}catch(e){setTimeout(d.bind(this,e),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[f]);return c}(e,this)};k.Service=c;var t=function(a,b,c,d){n.call(this,a,b,c);this.className="Service.Method";this.options=d||{}};(t.prototype=Object.create(n.prototype)).buildOpt=
80
+ b.buildOpt;k.Service.Method=t;b=function(a,b,c,d,e,f){t.call(this,a,b,c,f);this.className="Service.RPCMethod";this.requestName=d;this.responseName=e;this.resolvedResponseType=this.resolvedRequestType=null};b.prototype=Object.create(t.prototype);k.Service.RPCMethod=b;return k}(g);g.Builder=function(e,d,g){var k=function(b){this.ptr=this.ns=new g.Namespace(this,null,"");this.resolved=!1;this.result=null;this.files={};this.importRoot=null;this.options=b||{}},n=k.prototype;n.reset=function(){this.ptr=
81
+ this.ns};n.define=function(b,e){if("string"!==typeof b||!d.TYPEREF.test(b))throw Error("Illegal package: "+b);var a=b.split("."),c;for(c=0;c<a.length;c++)if(!d.NAME.test(a[c]))throw Error("Illegal package: "+a[c]);for(c=0;c<a.length;c++)null===this.ptr.getChild(a[c])&&this.ptr.addChild(new g.Namespace(this,this.ptr,a[c],e)),this.ptr=this.ptr.getChild(a[c]);return this};k.isValidMessage=function(b){if("string"!==typeof b.name||!d.NAME.test(b.name)||"undefined"!==typeof b.values||"undefined"!==typeof b.rpc)return!1;
82
+ var f;if("undefined"!==typeof b.fields){if(!e.Util.isArray(b.fields))return!1;var a=[],c;for(f=0;f<b.fields.length;f++){if(!k.isValidMessageField(b.fields[f]))return!1;c=parseInt(b.fields[f].id,10);if(0<=a.indexOf(c))return!1;a.push(c)}}if("undefined"!==typeof b.enums){if(!e.Util.isArray(b.enums))return!1;for(f=0;f<b.enums.length;f++)if(!k.isValidEnum(b.enums[f]))return!1}if("undefined"!==typeof b.messages){if(!e.Util.isArray(b.messages))return!1;for(f=0;f<b.messages.length;f++)if(!k.isValidMessage(b.messages[f])&&
83
+ !k.isValidExtend(b.messages[f]))return!1}return"undefined"===typeof b.extensions||e.Util.isArray(b.extensions)&&2===b.extensions.length&&"number"===typeof b.extensions[0]&&"number"===typeof b.extensions[1]?!0:!1};k.isValidMessageField=function(b){if("string"!==typeof b.rule||"string"!==typeof b.name||"string"!==typeof b.type||"undefined"===typeof b.id||!(d.RULE.test(b.rule)&&d.NAME.test(b.name)&&d.TYPEREF.test(b.type)&&d.ID.test(""+b.id)))return!1;if("undefined"!==typeof b.options){if("object"!==
84
+ typeof b.options)return!1;for(var e=Object.keys(b.options),a=0,c;a<e.length;a++)if("string"!==typeof(c=e[a])||"string"!==typeof b.options[c]&&"number"!==typeof b.options[c]&&"boolean"!==typeof b.options[c])return!1}return!0};k.isValidEnum=function(b){if("string"!==typeof b.name||!d.NAME.test(b.name)||"undefined"===typeof b.values||!e.Util.isArray(b.values)||0==b.values.length)return!1;for(var f=0;f<b.values.length;f++)if("object"!=typeof b.values[f]||"string"!==typeof b.values[f].name||"undefined"===
85
+ typeof b.values[f].id||!d.NAME.test(b.values[f].name)||!d.NEGID.test(""+b.values[f].id))return!1;return!0};n.create=function(b){if(!b)return this;e.Util.isArray(b)||(b=[b]);if(0==b.length)return this;var d=[];for(d.push(b);0<d.length;){b=d.pop();if(e.Util.isArray(b))for(;0<b.length;){var a=b.shift();if(k.isValidMessage(a)){var c=new g.Message(this,this.ptr,a.name,a.options,a.isGroup),n={};if(a.oneofs)for(var p=Object.keys(a.oneofs),h=0,l=p.length;h<l;++h)c.addChild(n[p[h]]=new g.Message.OneOf(this,
86
+ c,p[h]));if(a.fields&&0<a.fields.length)for(h=0,l=a.fields.length;h<l;++h){p=a.fields[h];if(null!==c.getChild(p.id))throw Error("Duplicate field id in message "+c.name+": "+p.id);if(p.options)for(var m=Object.keys(p.options),q=0,s=m.length;q<s;++q){if("string"!==typeof m[q])throw Error("Illegal field option name in message "+c.name+"#"+p.name+": "+m[q]);if("string"!==typeof p.options[m[q]]&&"number"!==typeof p.options[m[q]]&&"boolean"!==typeof p.options[m[q]])throw Error("Illegal field option value in message "+
87
+ c.name+"#"+p.name+"#"+m[q]+": "+p.options[m[q]]);}m=null;if("string"===typeof p.oneof&&(m=n[p.oneof],"undefined"===typeof m))throw Error("Illegal oneof in message "+c.name+"#"+p.name+": "+p.oneof);p=new g.Message.Field(this,c,p.rule,p.type,p.name,p.id,p.options,m);m&&m.fields.push(p);c.addChild(p)}n=[];if("undefined"!==typeof a.enums&&0<a.enums.length)for(h=0;h<a.enums.length;h++)n.push(a.enums[h]);if(a.messages&&0<a.messages.length)for(h=0;h<a.messages.length;h++)n.push(a.messages[h]);a.extensions&&
88
+ (c.extensions=a.extensions,c.extensions[0]<e.ID_MIN&&(c.extensions[0]=e.ID_MIN),c.extensions[1]>e.ID_MAX&&(c.extensions[1]=e.ID_MAX));this.ptr.addChild(c);0<n.length&&(d.push(b),b=n,this.ptr=c)}else if(k.isValidEnum(a)){c=new g.Enum(this,this.ptr,a.name,a.options);for(h=0;h<a.values.length;h++)c.addChild(new g.Enum.Value(this,c,a.values[h].name,a.values[h].id));this.ptr.addChild(c)}else if(k.isValidService(a)){c=new g.Service(this,this.ptr,a.name,a.options);for(h in a.rpc)a.rpc.hasOwnProperty(h)&&
89
+ c.addChild(new g.Service.RPCMethod(this,c,h,a.rpc[h].request,a.rpc[h].response,a.rpc[h].options));this.ptr.addChild(c)}else if(k.isValidExtend(a))if(c=this.ptr.resolve(a.ref))for(h=0;h<a.fields.length;h++){if(null!==c.getChild(a.fields[h].id))throw Error("Duplicate extended field id in message "+c.name+": "+a.fields[h].id);if(a.fields[h].id<c.extensions[0]||a.fields[h].id>c.extensions[1])throw Error("Illegal extended field id in message "+c.name+": "+a.fields[h].id+" ("+c.extensions.join(" to ")+
90
+ " expected)");n=a.fields[h].name;this.options.convertFieldsToCamelCase&&(n=g.Message.Field._toCamelCase(a.fields[h].name));p=new g.Message.ExtensionField(this,c,a.fields[h].rule,a.fields[h].type,this.ptr.fqn()+"."+n,a.fields[h].id,a.fields[h].options);n=new g.Extension(this,this.ptr,a.fields[h].name,p);p.extension=n;this.ptr.addChild(n);c.addChild(p)}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a));
91
+ }else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(b,d){if("string"===typeof d){e.Util.IS_NODE&&(d=require("path").resolve(d));if(!0===this.files[d])return this.reset(),this;this.files[d]=!0}if(b.imports&&0<b.imports.length){var a,c="/",g=!1;if("object"===typeof d){if(this.importRoot=d.root,g=!0,a=this.importRoot,d=d.file,0<=a.indexOf("\\")||0<=d.indexOf("\\"))c="\\"}else"string"===typeof d?this.importRoot?
92
+ a=this.importRoot:0<=d.indexOf("/")?(a=d.replace(/\/[^\/]*$/,""),""===a&&(a="/")):0<=d.indexOf("\\")?(a=d.replace(/\\[^\\]*$/,""),c="\\"):a=".":a=null;for(var k=0;k<b.imports.length;k++)if("string"===typeof b.imports[k]){if(!a)throw Error("Cannot determine import root: File name is unknown");var h=b.imports[k];if(!/^google\/protobuf\//.test(h)&&(h=a+c+h,!0!==this.files[h])){/\.proto$/i.test(h)&&!e.DotProto&&(h=h.replace(/\.proto$/,".json"));var n=e.Util.fetch(h);if(null===n)throw Error("Failed to import '"+
93
+ h+"' in '"+d+"': File not found");if(/\.json$/i.test(h))this["import"](JSON.parse(n+""),h);else this["import"]((new e.DotProto.Parser(n+"")).parse(),h)}}else if(d)if(/\.(\w+)$/.test(d))this["import"](b.imports[k],d.replace(/^(.+)\.(\w+)$/,function(a,b,c){return b+"_import"+k+"."+c}));else this["import"](b.imports[k],d+"_import"+k);else this["import"](b.imports[k]);g&&(this.importRoot=null)}b.messages&&(b["package"]&&this.define(b["package"],b.options),this.create(b.messages),this.reset());b.enums&&
94
+ (b["package"]&&this.define(b["package"],b.options),this.create(b.enums),this.reset());b.services&&(b["package"]&&this.define(b["package"],b.options),this.create(b.services),this.reset());b["extends"]&&(b["package"]&&this.define(b["package"],b.options),this.create(b["extends"]),this.reset());return this};k.isValidService=function(b){return!("string"!==typeof b.name||!d.NAME.test(b.name)||"object"!==typeof b.rpc)};k.isValidExtend=function(b){if("string"!==typeof b.ref||!d.TYPEREF.test(b.ref))return!1;
95
+ var f;if("undefined"!==typeof b.fields){if(!e.Util.isArray(b.fields))return!1;var a=[],c;for(f=0;f<b.fields.length;f++){if(!k.isValidMessageField(b.fields[f]))return!1;c=parseInt(b.id,10);if(0<=a.indexOf(c))return!1;a.push(c)}}return!0};n.resolveAll=function(){var b;if(null!=this.ptr&&"object"!==typeof this.ptr.type){if(this.ptr instanceof g.Namespace){b=this.ptr.children;for(var f=0,a=b.length;f<a;++f)this.ptr=b[f],this.resolveAll()}else if(this.ptr instanceof g.Message.Field)if(d.TYPE.test(this.ptr.type))this.ptr.type=
96
+ e.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 g.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 g.Enum)this.ptr.type=e.TYPES["enum"];else if(b instanceof g.Message)this.ptr.type=b.isGroup?e.TYPES.group:
97
+ e.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}else if(!(this.ptr instanceof e.Reflect.Enum.Value))if(this.ptr instanceof e.Reflect.Service.Method)if(this.ptr instanceof e.Reflect.Service.RPCMethod){b=this.ptr.parent.resolve(this.ptr.requestName);if(!(b&&b instanceof e.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);
98
+ if(!(b&&b instanceof e.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 e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension))throw Error("Illegal object in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};n.build=function(b){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=
99
+ null);null==this.result&&(this.result=this.ns.build());if(b){b=b.split(".");for(var d=this.result,a=0;a<b.length;a++)if(d[b[a]])d=d[b[a]];else{d=null;break}return d}return this.result};n.lookup=function(b){return b?this.ns.resolve(b):this.ns};n.toString=function(){return"Builder"};k.Message=function(){};k.Service=function(){};return k}(g,g.Lang,g.Reflect);g.loadProto=function(e,d,l){if("string"===typeof d||d&&"string"===typeof d.file&&"string"===typeof d.root)l=d,d=void 0;return g.loadJson((new g.DotProto.Parser(e)).parse(),
100
+ d,l)};g.protoFromString=g.loadProto;g.loadProtoFile=function(e,d,l){d&&"object"===typeof d?(l=d,d=null):d&&"function"===typeof d||(d=null);if(d)return g.Util.fetch("string"===typeof e?e:e.root+"/"+e.file,function(k){if(null===k)d(Error("Failed to fetch file"));else try{d(null,g.loadProto(k,l,e))}catch(b){d(b)}});var k=g.Util.fetch("object"===typeof e?e.root+"/"+e.file:e);return null===k?null:g.loadProto(k,l,e)};g.protoFromFile=g.loadProtoFile;g.newBuilder=function(e){e=e||{};"undefined"===typeof e.convertFieldsToCamelCase&&
101
+ (e.convertFieldsToCamelCase=g.convertFieldsToCamelCase);"undefined"===typeof e.populateAccessors&&(e.populateAccessors=g.populateAccessors);return new g.Builder(e)};g.loadJson=function(e,d,l){if("string"===typeof d||d&&"string"===typeof d.file&&"string"===typeof d.root)l=d,d=null;d&&"object"===typeof d||(d=g.newBuilder());"string"===typeof e&&(e=JSON.parse(e));d["import"](e,l);d.resolveAll();return d};g.loadJsonFile=function(e,d,l){d&&"object"===typeof d?(l=d,d=null):d&&"function"===typeof d||(d=
102
+ null);if(d)return g.Util.fetch("string"===typeof e?e:e.root+"/"+e.file,function(k){if(null===k)d(Error("Failed to fetch file"));else try{d(null,g.loadJson(JSON.parse(k),l,e))}catch(b){d(b)}});var k=g.Util.fetch("object"===typeof e?e.root+"/"+e.file:e);return null===k?null:g.loadJson(JSON.parse(k),l,e)};return g}"function"===typeof require&&"object"===typeof module&&module&&"object"===typeof exports&&exports?module.exports=u(require("bytebuffer")):"function"===typeof define&&define.amd?define(["ByteBuffer"],
103
+ u):(s.dcodeIO=s.dcodeIO||{}).ProtoBuf=u(s.dcodeIO.ByteBuffer)})(this);