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,71 +3,73 @@
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(t){function u(l){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(w){function x(k){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=l;g.Long=l.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(d){function m(){}if(1<arguments.length)throw Error("Object.create polyfill only accepts the first parameter.");m.prototype=
9
- d;return new m});var d={IS_NODE:!1};try{d.IS_NODE="function"===typeof require&&"function"===typeof require("fs").readFileSync&&"function"===typeof require("path").resolve}catch(g){}d.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")}],m=null,b=0;b<d.length;b++){try{m=d[b]()}catch(e){continue}break}if(!m)throw Error("XMLHttpRequest is not supported");
10
- return m};d.fetch=function(g,m){m&&"function"!=typeof m&&(m=null);if(d.IS_NODE)if(m)require("fs").readFile(g,function(d,b){d?m(null):m(""+b)});else try{return require("fs").readFileSync(g)}catch(b){return null}else{var e=d.XHR();e.open("GET",g,m?!0:!1);e.setRequestHeader("Accept","text/plain");"function"===typeof e.overrideMimeType&&e.overrideMimeType("text/plain");if(m)e.onreadystatechange=function(){4==e.readyState&&(200==e.status||0==e.status&&"string"===typeof e.responseText?m(e.responseText):
11
- m(null))},4!=e.readyState&&e.send(null);else return e.send(null),200==e.status||0==e.status&&"string"===typeof e.responseText?e.responseText:null}};d.isArray=Array.isArray||function(d){return"[object Array]"===Object.prototype.toString.call(d)};return d}();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=k;g.Long=k.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(c){function g(){}if(1<arguments.length)throw Error("Object.create polyfill only accepts the first parameter.");g.prototype=
9
+ c;return new g});var c={IS_NODE:!1};try{c.IS_NODE="function"===typeof require&&"function"===typeof require("fs").readFileSync&&"function"===typeof require("path").resolve}catch(g){}c.XHR=function(){for(var c=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],g=null,s=0;s<c.length;s++){try{g=c[s]()}catch(b){continue}break}if(!g)throw Error("XMLHttpRequest is not supported");
10
+ return g};c.fetch=function(g,p){p&&"function"!=typeof p&&(p=null);if(c.IS_NODE)if(p)require("fs").readFile(g,function(b,c){b?p(null):p(""+c)});else try{return require("fs").readFileSync(g)}catch(s){return null}else{var b=c.XHR();b.open("GET",g,p?!0:!1);b.setRequestHeader("Accept","text/plain");"function"===typeof b.overrideMimeType&&b.overrideMimeType("text/plain");if(p)b.onreadystatechange=function(){4==b.readyState&&(200==b.status||0==b.status&&"string"===typeof b.responseText?p(b.responseText):
11
+ p(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(c){return"[object Array]"===Object.prototype.toString.call(c)};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)$/,
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.Reflect=function(d){function g(a,k){var b=k.readVarint32(),c=b&7,b=b>>3;switch(c){case d.WIRE_TYPES.VARINT:do b=k.readUint8();while(128===(b&128));break;case d.WIRE_TYPES.BITS64:k.offset+=8;break;case d.WIRE_TYPES.LDELIM:b=k.readVarint32();k.offset+=b;break;case d.WIRE_TYPES.STARTGROUP:g(b,k);break;case d.WIRE_TYPES.ENDGROUP:if(b===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+
14
- b+" ("+a+" expected)");case d.WIRE_TYPES.BITS32:k.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+c);}return!0}function q(a,k){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new d.Long(a.low,a.high,"undefined"===typeof k?a.unsigned:k);if("string"===typeof a)return d.Long.fromString(a,k||!1,10);if("number"===typeof a)return d.Long.fromNumber(a,k||!1);throw Error("not convertible to Long");
15
- }var m={},b=function(a,k){this.parent=a;this.name=k};b.prototype.fqn=function(){var a=this.name,k=this;do{k=k.parent;if(null==k)break;a=k.name+"."+a}while(1);return a};b.prototype.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};m.T=b;var e=function(a,k,d){b.call(this,a,k);this.className="Namespace";this.children=[];this.options=d||{}};e.prototype=Object.create(b.prototype);e.prototype.getChildren=
16
- function(a){a=a||null;if(null==a)return this.children.slice();for(var k=[],b=0,d=this.children.length;b<d;++b)this.children[b]instanceof a&&k.push(this.children[b]);return k};e.prototype.addChild=function(a){var k;if(k=this.getChild(a.name))if(k instanceof c.Field&&k.name!==k.originalName&&null===this.getChild(k.originalName))k.name=k.originalName;else if(a instanceof c.Field&&a.name!==a.originalName&&null===this.getChild(a.originalName))a.name=a.originalName;else throw Error("Duplicate name in namespace "+
17
- this.toString(!0)+": "+a.name);this.children.push(a)};e.prototype.getChild=function(a){for(var k="number"===typeof a?"id":"name",b=0,d=this.children.length;b<d;++b)if(this.children[b][k]===a)return this.children[b];return null};e.prototype.resolve=function(a,k){var b=a.split("."),d=this,c=0;if(""===b[c]){for(;null!==d.parent;)d=d.parent;c++}do{do{d=d.getChild(b[c]);if(!(d&&d instanceof m.T)||k&&d instanceof m.Message.Field){d=null;break}c++}while(c<b.length);if(null!=d)break;if(null!==this.parent)return this.parent.resolve(a,
18
- k)}while(null!=d);return d};e.prototype.build=function(){for(var a={},k=this.children,d=0,b=k.length,c;d<b;++d)c=k[d],c instanceof e&&(a[c.name]=c.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return a};e.prototype.buildOpt=function(){for(var a={},d=Object.keys(this.options),b=0,c=d.length;b<c;++b)a[d[b]]=this.options[d[b]];return a};e.prototype.getOption=function(a){return"undefined"===typeof a?this.options:"undefined"!==typeof this.options[a]?this.options[a]:
19
- null};m.Namespace=e;var c=function(a,b,c,f){e.call(this,a,b,c);this.className="Message";this.extensions=[d.ID_MIN,d.ID_MAX];this.clazz=null;this.isGroup=!!f;this._fieldsById=this._fields=null};c.prototype=Object.create(e.prototype);c.prototype.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(a,b){function d(a,b){var k={},c;for(c in a)a.hasOwnProperty(c)&&(null===a[c]||"object"!==typeof a[c]?k[c]=a[c]:a[c]instanceof l?b&&(k[c]=a.toBuffer()):k[c]=d(a[c],b));return k}var k=b.getChildren(a.Reflect.Message.Field),
20
- c=function(b,d){a.Builder.Message.call(this);for(var c=0,e=k.length,p;c<e;++c)this[(p=k[c]).name]=p.repeated?[]:null,p.required&&null!==p.defaultValue&&(this[p.name]=p.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(c=0,e=arguments.length;c<e;++c)this.$set(k[c].name,arguments[c]);else for(p=Object.keys(b),c=0,e=p.length;c<e;++c)this.$set(p[c],
21
- b[p[c]])};c.prototype=Object.create(a.Builder.Message.prototype);c.prototype.add=function(d,c,k){var e=b.getChild(d);if(!e)throw Error(this+"#"+d+" is undefined");if(!(e instanceof a.Reflect.Message.Field))throw Error(this+"#"+d+" is not a field: "+e.toString(!0));if(!e.repeated)throw Error(this+"#"+d+" is not a repeated field");null===this[e.name]&&(this[e.name]=[]);this[e.name].push(k?c:e.verifyValue(c,!0))};c.prototype.$add=c.prototype.add;c.prototype.set=function(d,c,k){if(d&&"object"===typeof d){for(var e in d)d.hasOwnProperty(e)&&
22
- this.$set(e,d[e],k);return this}if(k)return this[d]=c,this;k=b.getChild(d);if(!k)throw Error(this+"#"+d+" is not a field: undefined");if(!(k instanceof a.Reflect.Message.Field))throw Error(this+"#"+d+" is not a field: "+k.toString(!0));this[k.name]=k.verifyValue(c);return this};c.prototype.$set=c.prototype.set;c.prototype.get=function(d,c){if(c)return this[d];var k=b.getChild(d);if(!(k&&k instanceof a.Reflect.Message.Field))throw Error(this+"#"+d+" is not a field: undefined");if(!(k instanceof a.Reflect.Message.Field))throw Error(this+
23
- "#"+d+" is not a field: "+k.toString(!0));return this[k.name]};c.prototype.$get=c.prototype.get;for(var e=0;e<k.length;e++){var p=k[e];p instanceof a.Reflect.Message.ExtensionField||a.populateAccessors&&function(a){var d=a.originalName.replace(/(_[a-zA-Z])/g,function(a){return a.toUpperCase().replace("_","")}),d=d.substring(0,1).toUpperCase()+d.substring(1),k=a.originalName.replace(/([A-Z])/g,function(a){return"_"+a});null===b.getChild("set"+d)&&(c.prototype["set"+d]=function(b){this.$set(a.name,
24
- b)});null===b.getChild("set_"+k)&&(c.prototype["set_"+k]=function(b){this.$set(a.name,b)});null===b.getChild("get"+d)&&(c.prototype["get"+d]=function(){return this.$get(a.name)});null===b.getChild("get_"+k)&&(c.prototype["get_"+k]=function(){return this.$get(a.name)})}(p)}c.prototype.encode=function(a,d){"boolean"===typeof a&&(d=a,a=void 0);var k=!1;a||(a=new l,k=!0);var c=a.littleEndian;try{return b.encode(this,a.LE(),d),(k?a.flip():a).LE(c)}catch(e){throw a.LE(c),e;}};c.prototype.calculate=function(){return b.calculate(this)};
25
- c.prototype.encodeDelimited=function(a){var d=!1;a||(a=new l,d=!0);var k=(new l).LE();b.encode(this,k).flip();a.writeVarint32(k.remaining());a.append(k);return d?a.flip():a};c.prototype.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toArrayBuffer()),a;}};c.prototype.toArrayBuffer=c.prototype.encodeAB;c.prototype.encodeNB=function(){try{return this.encode().toBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBuffer()),a;}};c.prototype.toBuffer=
26
- c.prototype.encodeNB;c.prototype.encode64=function(){try{return this.encode().toBase64()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBase64()),a;}};c.prototype.toBase64=c.prototype.encode64;c.prototype.encodeHex=function(){try{return this.encode().toHex()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toHex()),a;}};c.prototype.toHex=c.prototype.encodeHex;c.prototype.toRaw=function(a){return d(this,!!a)};c.decode=function(a,d){"string"===typeof a&&(a=l.wrap(a,d?d:"base64"));a=a instanceof l?a:
27
- l.wrap(a);var k=a.littleEndian;try{var c=b.decode(a.LE());a.LE(k);return c}catch(e){throw a.LE(k),e;}};c.decodeDelimited=function(a,d){"string"===typeof a&&(a=l.wrap(a,d?d:"base64"));a=a instanceof l?a:l.wrap(a);if(1>a.remaining())return null;var k=a.offset,c=a.readVarint32();if(a.remaining()<c)return a.offset=k,null;try{var e=b.decode(a.slice(a.offset,a.offset+c).LE());a.offset+=c;return e}catch(p){throw a.offset+=c,p;}};c.decode64=function(a){return c.decode(a,"base64")};c.decodeHex=function(a){return c.decode(a,
28
- "hex")};c.prototype.toString=function(){return b.toString()};Object.defineProperty&&(Object.defineProperty(c,"$options",{value:b.buildOpt()}),Object.defineProperty(c.prototype,"$type",{get:function(){return b}}));return c}(d,this);this._fields=[];this._fieldsById=[];for(var b=0,e=this.children.length,f;b<e;b++)if(f=this.children[b],f instanceof h)a[f.name]=f.build();else if(f instanceof c)a[f.name]=f.build();else if(f instanceof c.Field)f.build(),this._fields.push(f),this._fieldsById[f.id]=f;else if(!(f instanceof
29
- n))throw Error("Illegal reflect child of "+this.toString(!0)+": "+children[b].toString(!0));return this.clazz=a};c.prototype.encode=function(a,d,b){for(var c=null,e,f=0,h=this._fields.length,g;f<h;++f)e=this.children[f],g=a[e.name],e.required&&null===g?null===c&&(c=e):e.encode(b?g:e.verifyValue(g),d);if(null!==c)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+c),a.encoded=d,a;return d};c.prototype.calculate=function(a){for(var d=0,b=0,c=this._fields.length,e,f;b<c;++b){e=
30
- this._fields[b];f=a[e.name];if(e.required&&null===f)throw Error("Missing at least one required field for "+this.toString(!0)+": "+e);d+=e.calculate(f)}return d};c.prototype.decode=function(a,b,c){b="number"===typeof b?b:-1;for(var e=a.offset,f=new this.clazz,h,m,l;a.offset<e+b||-1===b&&0<a.remaining();){h=a.readVarint32();m=h&7;l=h>>3;if(m===d.WIRE_TYPES.ENDGROUP){if(l!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+l+" ("+(c?c+" expected":"not a group")+")");break}if(h=
31
- this._fieldsById[l])h.repeated&&!h.options.packed?f[h.name].push(h.decode(m,a)):f[h.name]=h.decode(m,a);else switch(m){case d.WIRE_TYPES.VARINT:a.readVarint32();break;case d.WIRE_TYPES.BITS32:a.offset+=4;break;case d.WIRE_TYPES.BITS64:a.offset+=8;break;case d.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case d.WIRE_TYPES.STARTGROUP:for(;g(l,a););break;default:throw Error("Illegal wire type for unknown field "+l+" in "+this.toString(!0)+"#decode: "+m);}}a=0;for(b=this._fields.length;a<b;++a)if(h=
32
- this._fields[a],null===f[h.name]){if(h.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+h.name),a.decoded=f,a;null!==h.defaultValue&&(f[h.name]=h.defaultValue)}return f};m.Message=c;var f=function(a,k,e,f,h,m){b.call(this,a,f);this.className="Message.Field";this.required="required"===k;this.repeated="repeated"===k;this.type=e;this.resolvedType=null;this.id=h;this.options=m||{};this.defaultValue=null;this.originalName=this.name;!d.convertFieldsToCamelCase||this instanceof
33
- c.ExtensionField||(this.name=this.name.replace(/_([a-zA-Z])/g,function(a,d){return d.toUpperCase()}))};f.prototype=Object.create(b.prototype);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 c=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);if(null===a)return this.required&&c(typeof a,
34
- "required"),null;var e;if(this.repeated&&!b){d.Util.isArray(a)||(a=[a]);c=[];for(e=0;e<a.length;e++)c.push(this.verifyValue(a[e],!0));return c}!this.repeated&&d.Util.isArray(a)&&c(typeof a,"no array expected");switch(this.type){case d.TYPES.int32:case d.TYPES.sint32:case d.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&c(typeof a,"not an integer"),4294967295<a?a|0:a;case d.TYPES.uint32:case d.TYPES.fixed32:return("number"!==typeof a||a===a&&0!==a%1)&&c(typeof a,"not an integer"),0>a?
35
- a>>>0:a;case d.TYPES.int64:case d.TYPES.sint64:case d.TYPES.sfixed64:if(d.Long)try{return q(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case d.TYPES.uint64:case d.TYPES.fixed64:if(d.Long)try{return q(a,!0)}catch(m){c(typeof a,m.message)}else c(typeof a,"requires Long.js");case d.TYPES.bool:return"boolean"!==typeof a&&c(typeof a,"not a boolean"),a;case d.TYPES["float"]:case d.TYPES["double"]:return"number"!==typeof a&&c(typeof a,"not a number"),a;case d.TYPES.string:return"string"===
36
- typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case d.TYPES.bytes:return a&&a instanceof l?a:l.wrap(a);case d.TYPES["enum"]:var g=this.resolvedType.getChildren(h.Value);for(e=0;e<g.length;e++)if(g[e].name==a||g[e].id==a)return g[e].id;c(a,"not a valid enum value");case d.TYPES.group:case d.TYPES.message:a&&"object"===typeof a||c(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof d.Builder.Message){c={};for(e in a)a.hasOwnProperty(e)&&(c[e]=
37
- a[e]);a=c}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,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<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b.writeVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);
38
- b.ensureCapacity(b.offset+=1);var e=b.offset;for(c=0;c<a.length;c++)this.encodeValue(a[c],b);var f=b.offset-e,h=l.calculateVarint32(f);if(1<h){var m=b.slice(e,b.offset),e=e+(h-1);b.offset=e;b.append(m)}b.writeVarint32(f,e-h)}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(g){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+g+")");}return b};f.prototype.encodeValue=
39
- function(a,b){if(null===a)return b;switch(this.type){case d.TYPES.int32:0>a?b.writeVarint64(a):b.writeVarint32(a);break;case d.TYPES.uint32:b.writeVarint32(a);break;case d.TYPES.sint32:b.writeVarint32ZigZag(a);break;case d.TYPES.fixed32:b.writeUint32(a);break;case d.TYPES.sfixed32:b.writeInt32(a);break;case d.TYPES.int64:case d.TYPES.uint64:b.writeVarint64(a);break;case d.TYPES.sint64:b.writeVarint64ZigZag(a);break;case d.TYPES.fixed64:b.writeUint64(a);break;case d.TYPES.sfixed64:b.writeInt64(a);
40
- break;case d.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case d.TYPES["enum"]:b.writeVarint32(a);break;case d.TYPES["float"]:b.writeFloat32(a);break;case d.TYPES["double"]:b.writeFloat64(a);break;case d.TYPES.string:b.writeVString(a);break;case d.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;
41
- break;case d.TYPES.message:c=(new l).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case d.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|d.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)+
42
- ": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,e;if(this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=l.calculateVarint32(this.id<<3|d.WIRE_TYPES.LDELIM);for(c=e=0;c<a.length;c++)e+=this.calculateValue(a[c]);b+=l.calculateVarint32(e);b+=e}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 "+
43
- this.toString(!0)+": "+a+" ("+f+")");}return b};f.prototype.calculateValue=function(a){if(null===a)return 0;switch(this.type){case d.TYPES.int32:return 0>a?l.calculateVarint64(a):l.calculateVarint32(a);case d.TYPES.uint32:return l.calculateVarint32(a);case d.TYPES.sint32:return l.calculateVarint32(l.zigZagEncode32(a));case d.TYPES.fixed32:case d.TYPES.sfixed32:case d.TYPES["float"]:return 4;case d.TYPES.int64:case d.TYPES.uint64:return l.calculateVarint64(a);case d.TYPES.sint64:return l.calculateVarint64(l.zigZagEncode64(a));
44
- case d.TYPES.fixed64:case d.TYPES.sfixed64:return 8;case d.TYPES.bool:return 1;case d.TYPES["enum"]:return l.calculateVarint32(a);case d.TYPES["double"]:return 8;case d.TYPES.string:return a=l.calculateUTF8Bytes(a),l.calculateVarint32(a)+a;case d.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 d.TYPES.message:return a=this.resolvedType.calculate(a),l.calculateVarint32(a)+
45
- a;case d.TYPES.group:return a=this.resolvedType.calculate(a),a+l.calculateVarint32(this.id<<3|d.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};f.prototype.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=d.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==d.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=d.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&
46
- !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 d.TYPES.int32:return b.readVarint32()|0;case d.TYPES.uint32:return b.readVarint32()>>>0;case d.TYPES.sint32:return b.readVarint32ZigZag()|0;case d.TYPES.fixed32:return b.readUint32()>>>0;case d.TYPES.sfixed32:return b.readInt32()|0;case d.TYPES.int64:return b.readVarint64();case d.TYPES.uint64:return b.readVarint64().toUnsigned();case d.TYPES.sint64:return b.readVarint64ZigZag();
47
- case d.TYPES.fixed64:return b.readUint64();case d.TYPES.sfixed64:return b.readInt64();case d.TYPES.bool:return!!b.readVarint32();case d.TYPES["enum"]:return b.readVarint32();case d.TYPES["float"]:return b.readFloat();case d.TYPES["double"]:return b.readDouble();case d.TYPES.string:return b.readVString();case d.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;
48
- b.offset+=a;return c;case d.TYPES.message:return a=b.readVarint32(),this.resolvedType.decode(b,a);case d.TYPES.group:return this.resolvedType.decode(b,-1,this.id)}throw Error("[INTERNAL] Illegal wire type for "+this.toString(!0)+": "+a);};m.Message.Field=f;var r=function(a,b,c,d,e,h){f.call(this,a,b,c,d,e,h)};r.prototype=Object.create(f.prototype);m.Message.ExtensionField=r;var h=function(a,b,c){e.call(this,a,b,c);this.className="Enum";this.object=null};h.prototype=Object.create(e.prototype);h.prototype.build=
49
- function(){for(var a={},b=this.getChildren(h.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};m.Enum=h;r=function(a,c,d){b.call(this,a,c);this.className="Enum.Value";this.id=d};r.prototype=Object.create(b.prototype);m.Enum.Value=r;var n=function(a,c,d){b.call(this,a,c);this.field=d};n.prototype=Object.create(b.prototype);m.Extension=n;r=function(a,b,c){e.call(this,a,b,c);this.className="Service";
50
- this.clazz=null};r.prototype=Object.create(e.prototype);r.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)}};c.prototype=Object.create(a.Builder.Service.prototype);Object.defineProperty&&(Object.defineProperty(c,"$options",{value:b.buildOpt()}),Object.defineProperty(c.prototype,
51
- "$options",{value:c.$options}));for(var d=b.getChildren(a.Reflect.Service.RPCMethod),e=0;e<d.length;e++)(function(a){c.prototype[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,Error("Illegal request type provided to service method "+
52
- 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(c.prototype[a.name],"$options",{value:c[a.name].$options}))})(d[e]);return c}(d,this)};m.Service=r;var s=function(a,c,d){b.call(this,a,c);this.className="Service.Method";this.options=d||{}};s.prototype=Object.create(b.prototype);s.prototype.buildOpt=e.prototype.buildOpt;m.Service.Method=
53
- s;r=function(a,b,c,d,e){s.call(this,a,b,e);this.className="Service.RPCMethod";this.requestName=c;this.responseName=d;this.resolvedResponseType=this.resolvedRequestType=null};r.prototype=Object.create(s.prototype);m.Service.RPCMethod=r;return m}(g);g.Builder=function(d,g,l){var m=function(){this.ptr=this.ns=new l.Namespace(null,"");this.resolved=!1;this.result=null;this.files={};this.importRoot=null};m.prototype.reset=function(){this.ptr=this.ns};m.prototype.define=function(b,d){if("string"!==typeof b||
54
- !g.TYPEREF.test(b))throw Error("Illegal package: "+b);var c=b.split("."),f;for(f=0;f<c.length;f++)if(!g.NAME.test(c[f]))throw Error("Illegal package: "+c[f]);for(f=0;f<c.length;f++)null===this.ptr.getChild(c[f])&&this.ptr.addChild(new l.Namespace(this.ptr,c[f],d)),this.ptr=this.ptr.getChild(c[f]);return this};m.isValidMessage=function(b){if("string"!==typeof b.name||!g.NAME.test(b.name)||"undefined"!==typeof b.values||"undefined"!==typeof b.rpc)return!1;var e;if("undefined"!==typeof b.fields){if(!d.Util.isArray(b.fields))return!1;
55
- var c=[],f;for(e=0;e<b.fields.length;e++){if(!m.isValidMessageField(b.fields[e]))return!1;f=parseInt(b.fields[e].id,10);if(0<=c.indexOf(f))return!1;c.push(f)}}if("undefined"!==typeof b.enums){if(!d.Util.isArray(b.enums))return!1;for(e=0;e<b.enums.length;e++)if(!m.isValidEnum(b.enums[e]))return!1}if("undefined"!==typeof b.messages){if(!d.Util.isArray(b.messages))return!1;for(e=0;e<b.messages.length;e++)if(!m.isValidMessage(b.messages[e])&&!m.isValidExtend(b.messages[e]))return!1}return"undefined"===
56
- typeof b.extensions||d.Util.isArray(b.extensions)&&2===b.extensions.length&&"number"===typeof b.extensions[0]&&"number"===typeof b.extensions[1]?!0:!1};m.isValidMessageField=function(b){if("string"!==typeof b.rule||"string"!==typeof b.name||"string"!==typeof b.type||"undefined"===typeof b.id||!(g.RULE.test(b.rule)&&g.NAME.test(b.name)&&g.TYPEREF.test(b.type)&&g.ID.test(""+b.id)))return!1;if("undefined"!==typeof b.options){if("object"!==typeof b.options)return!1;for(var d=Object.keys(b.options),c=
57
- 0,f;c<d.length;c++)if("string"!==typeof(f=d[c])||"string"!==typeof b.options[f]&&"number"!==typeof b.options[f]&&"boolean"!==typeof b.options[f])return!1}return!0};m.isValidEnum=function(b){if("string"!==typeof b.name||!g.NAME.test(b.name)||"undefined"===typeof b.values||!d.Util.isArray(b.values)||0==b.values.length)return!1;for(var e=0;e<b.values.length;e++)if("object"!=typeof b.values[e]||"string"!==typeof b.values[e].name||"undefined"===typeof b.values[e].id||!g.NAME.test(b.values[e].name)||!g.NEGID.test(""+
58
- b.values[e].id))return!1;return!0};m.prototype.create=function(b){if(!b)return this;d.Util.isArray(b)||(b=[b]);if(0==b.length)return this;var e=[],c,f,g,h,n;for(e.push(b);0<e.length;){b=e.pop();if(d.Util.isArray(b))for(;0<b.length;)if(c=b.shift(),m.isValidMessage(c)){f=new l.Message(this.ptr,c.name,c.options,c.isGroup);if(c.fields&&0<c.fields.length)for(h=0;h<c.fields.length;h++){if(null!==f.getChild(c.fields[h].id))throw Error("Duplicate field id in message "+f.name+": "+c.fields[h].id);if(c.fields[h].options)for(g=
59
- Object.keys(c.fields[h].options),n=0;n<g.length;n++){if("string"!==typeof g[n])throw Error("Illegal field option name in message "+f.name+"#"+c.fields[h].name+": "+g[n]);if("string"!==typeof c.fields[h].options[g[n]]&&"number"!==typeof c.fields[h].options[g[n]]&&"boolean"!==typeof c.fields[h].options[g[n]])throw Error("Illegal field option value in message "+f.name+"#"+c.fields[h].name+"#"+g[n]+": "+c.fields[h].options[g[n]]);}f.addChild(new l.Message.Field(f,c.fields[h].rule,c.fields[h].type,c.fields[h].name,
60
- c.fields[h].id,c.fields[h].options))}g=[];if("undefined"!==typeof c.enums&&0<c.enums.length)for(h=0;h<c.enums.length;h++)g.push(c.enums[h]);if(c.messages&&0<c.messages.length)for(h=0;h<c.messages.length;h++)g.push(c.messages[h]);c.extensions&&(f.extensions=c.extensions,f.extensions[0]<d.ID_MIN&&(f.extensions[0]=d.ID_MIN),f.extensions[1]>d.ID_MAX&&(f.extensions[1]=d.ID_MAX));this.ptr.addChild(f);0<g.length&&(e.push(b),b=g,this.ptr=f)}else if(m.isValidEnum(c)){f=new l.Enum(this.ptr,c.name,c.options);
61
- for(h=0;h<c.values.length;h++)f.addChild(new l.Enum.Value(f,c.values[h].name,c.values[h].id));this.ptr.addChild(f)}else if(m.isValidService(c)){f=new l.Service(this.ptr,c.name,c.options);for(h in c.rpc)c.rpc.hasOwnProperty(h)&&f.addChild(new l.Service.RPCMethod(f,h,c.rpc[h].request,c.rpc[h].response,c.rpc[h].options));this.ptr.addChild(f)}else if(m.isValidExtend(c))if(f=this.ptr.resolve(c.ref))for(h=0;h<c.fields.length;h++){if(null!==f.getChild(c.fields[h].id))throw Error("Duplicate extended field id in message "+
62
- f.name+": "+c.fields[h].id);if(c.fields[h].id<f.extensions[0]||c.fields[h].id>f.extensions[1])throw Error("Illegal extended field id in message "+f.name+": "+c.fields[h].id+" ("+f.extensions.join(" to ")+" expected)");g=new l.Message.ExtensionField(f,c.fields[h].rule,c.fields[h].type,this.ptr.fqn()+"."+c.fields[h].name,c.fields[h].id,c.fields[h].options);n=new l.Extension(this.ptr,c.fields[h].name,g);g.extension=n;this.ptr.addChild(n);f.addChild(g)}else{if(!/\.?google\.protobuf\./.test(c.ref))throw Error("Extended message "+
63
- c.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(c));else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};m.prototype["import"]=function(b,e){if("string"===typeof e){d.Util.IS_NODE&&(e=require("path").resolve(e));if(!0===this.files[e])return this.reset(),this;this.files[e]=!0}if(b.imports&&0<b.imports.length){var c,f="/",g=!1;if("object"===typeof e){if(this.importRoot=e.root,g=!0,c=
64
- this.importRoot,e=e.file,0<=c.indexOf("\\")||0<=e.indexOf("\\"))f="\\"}else"string"===typeof e?this.importRoot?c=this.importRoot:0<=e.indexOf("/")?(c=e.replace(/\/[^\/]*$/,""),""===c&&(c="/")):0<=e.indexOf("\\")?(c=e.replace(/\\[^\\]*$/,""),f="\\"):c=".":c=null;for(var h=0;h<b.imports.length;h++)if("string"===typeof b.imports[h]){if(!c)throw Error("Cannot determine import root: File name is unknown");var m=b.imports[h];if(!/^google\/protobuf\//.test(m)&&(m=c+f+m,!0!==this.files[m])){/\.proto$/i.test(m)&&
65
- !d.DotProto&&(m=m.replace(/\.proto$/,".json"));var l=d.Util.fetch(m);if(null===l)throw Error("Failed to import '"+m+"' in '"+e+"': File not found");if(/\.json$/i.test(m))this["import"](JSON.parse(l+""),m);else this["import"]((new d.DotProto.Parser(l+"")).parse(),m)}}else if(e)if(/\.(\w+)$/.test(e))this["import"](b.imports[h],e.replace(/^(.+)\.(\w+)$/,function(a,b,c){return b+"_import"+h+"."+c}));else this["import"](b.imports[h],e+"_import"+h);else this["import"](b.imports[h]);g&&(this.importRoot=
66
- null)}b.messages&&(b["package"]&&this.define(b["package"],b.options),this.create(b.messages),this.reset());b.enums&&(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};m.isValidService=function(b){return!("string"!==typeof b.name||!g.NAME.test(b.name)||
67
- "object"!==typeof b.rpc)};m.isValidExtend=function(b){if("string"!==typeof b.ref||!g.TYPEREF.test(b.ref))return!1;var e;if("undefined"!==typeof b.fields){if(!d.Util.isArray(b.fields))return!1;var c=[],f;for(e=0;e<b.fields.length;e++){if(!m.isValidMessageField(b.fields[e]))return!1;f=parseInt(b.id,10);if(0<=c.indexOf(f))return!1;c.push(f)}}return!0};m.prototype.resolveAll=function(){var b;if(null!=this.ptr&&"object"!==typeof this.ptr.type){if(this.ptr instanceof l.Namespace){b=this.ptr.children;for(var e=
68
- 0,c=b.length;e<c;++e)this.ptr=b[e],this.resolveAll()}else if(this.ptr instanceof l.Message.Field)if(g.TYPE.test(this.ptr.type))this.ptr.type=d.TYPES[this.ptr.type];else{if(!g.TYPEREF.test(this.ptr.type))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);b=(this.ptr instanceof l.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=
69
- b;if(b instanceof l.Enum)this.ptr.type=d.TYPES["enum"];else if(b instanceof l.Message)this.ptr.type=b.isGroup?d.TYPES.group:d.TYPES.message;else throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}else if(!(this.ptr instanceof d.Reflect.Enum.Value))if(this.ptr instanceof d.Reflect.Service.Method)if(this.ptr instanceof d.Reflect.Service.RPCMethod){b=this.ptr.parent.resolve(this.ptr.requestName);if(!(b&&b instanceof d.Reflect.Message))throw Error("Illegal type reference in "+
70
- this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=b;b=this.ptr.parent.resolve(this.ptr.responseName);if(!(b&&b instanceof d.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 d.Reflect.Extension))throw Error("Illegal object in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};m.prototype.build=
71
- function(b){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null==this.result&&(this.result=this.ns.build());if(b){b=b.split(".");for(var d=this.result,c=0;c<b.length;c++)if(d[b[c]])d=d[b[c]];else{d=null;break}return d}return this.result};m.prototype.lookup=function(b){return b?this.ns.resolve(b):this.ns};m.prototype.toString=function(){return"Builder"};m.Message=function(){};m.Service=function(){};return m}(g,g.Lang,g.Reflect);g.newBuilder=function(d,l){var q=new g.Builder;
72
- "undefined"!==typeof d&&null!==d&&q.define(d,l);return q};g.loadJson=function(d,l,q){if("string"===typeof l||l&&"string"===typeof l.file&&"string"===typeof l.root)q=l,l=null;l&&"object"===typeof l||(l=g.newBuilder());"string"===typeof d&&(d=JSON.parse(d));l["import"](d,q);l.resolveAll();l.build();return l};g.loadJsonFile=function(d,l,q){l&&"object"===typeof l?(q=l,l=null):l&&"function"===typeof l||(l=null);if(l)return g.Util.fetch("string"===typeof d?d:d.root+"/"+d.file,function(b){if(null===b)l(Error("Failed to fetch file"));
73
- else try{l(null,g.loadJson(JSON.parse(b),q,d))}catch(e){l(e)}});var m=g.Util.fetch("object"===typeof d?d.root+"/"+d.file:d);return null===m?null:g.loadJson(JSON.parse(m),q,d)};return g}"undefined"!==typeof module&&module.exports?module.exports=u(require("bytebuffer")):"function"===typeof define&&define.amd?define(["ByteBuffer"],u):(t.dcodeIO=t.dcodeIO||{}).ProtoBuf=u(t.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.Reflect=function(c){function g(a,h){var b=h.readVarint32(),e=b&7,b=b>>3;switch(e){case c.WIRE_TYPES.VARINT:do b=h.readUint8();while(128===(b&128));break;case c.WIRE_TYPES.BITS64:h.offset+=8;break;case c.WIRE_TYPES.LDELIM:b=h.readVarint32();h.offset+=b;break;case c.WIRE_TYPES.STARTGROUP:g(b,h);break;case c.WIRE_TYPES.ENDGROUP:if(b===
14
+ a)return!1;throw Error("Illegal GROUPEND after unknown group: "+b+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:h.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+e);}return!0}function t(a,h){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof h?a.unsigned:h);if("string"===typeof a)return c.Long.fromString(a,h||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,
15
+ h||!1);throw Error("not convertible to Long");}var p={},r=function(a,h,b){this.builder=a;this.parent=h;this.name=b},b=r.prototype;b.fqn=function(){var a=this.name,h=this;do{h=h.parent;if(null==h)break;a=h.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");};p.T=r;var m=function(a,h,b,c){r.call(this,a,h,b);this.className="Namespace";this.children=[];this.options=c||{}},b=m.prototype=
16
+ Object.create(r.prototype);b.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var h=[],b=0,c=this.children.length;b<c;++b)this.children[b]instanceof a&&h.push(this.children[b]);return h};b.addChild=function(a){var h;if(h=this.getChild(a.name))if(h instanceof f.Field&&h.name!==h.originalName&&null===this.getChild(h.originalName))h.name=h.originalName;else if(a instanceof f.Field&&a.name!==a.originalName&&null===this.getChild(a.originalName))a.name=a.originalName;else throw Error("Duplicate name in namespace "+
17
+ this.toString(!0)+": "+a.name);this.children.push(a)};b.getChild=function(a){for(var h="number"===typeof a?"id":"name",b=0,c=this.children.length;b<c;++b)if(this.children[b][h]===a)return this.children[b];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 p.T)||b&&e instanceof p.Message.Field){e=null;break}f++}while(f<c.length);if(null!=e)break;if(null!==this.parent)return this.parent.resolve(a,
18
+ b)}while(null!=e);return e};b.build=function(){for(var a={},b=this.children,c=0,f=b.length,d;c<f;++c)d=b[c],d instanceof m&&(a[d.name]=d.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return a};b.buildOpt=function(){for(var a={},b=Object.keys(this.options),c=0,f=b.length;c<f;++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};p.Namespace=m;
19
+ var f=function(a,b,f,e,d){m.call(this,a,b,f,e);this.className="Message";this.extensions=[c.ID_MIN,c.ID_MAX];this.clazz=null;this.isGroup=!!d;this._fieldsByName=this._fieldsById=this._fields=null},d=f.prototype=Object.create(m.prototype);d.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(a,b){function c(a,b){var h={},e;for(e in a)a.hasOwnProperty(e)&&(null===a[e]||"object"!==typeof a[e]?h[e]=a[e]:a[e]instanceof k?b&&(h[e]=a[e].toBase64()):h[e]=c(a[e],b));return h}var h=b.getChildren(a.Reflect.Message.Field),
20
+ f=b.getChildren(a.Reflect.Message.OneOf),l=function(b,c){a.Builder.Message.call(this);for(var e=0,l=f.length;e<l;++e)this[f[e].name]=null;e=0;for(l=h.length;e<l;++e){var d=h[e];this[d.name]=d.repeated?[]:null;d.required&&null!==d.defaultValue&&(this[d.name]=d.defaultValue)}if(0<arguments.length)if(1!==arguments.length||"object"!==typeof b||"function"===typeof b.encode||a.Util.isArray(b)||b instanceof k||b instanceof ArrayBuffer||a.Long&&b instanceof a.Long)for(e=0,l=arguments.length;e<l;++e)this.$set(h[e].name,
21
+ arguments[e]);else for(d=Object.keys(b),e=0,l=d.length;e<l;++e)this.$set(d[e],b[d[e]])},e=l.prototype=Object.create(a.Builder.Message.prototype);e.add=function(c,h,e){var l=b._fieldsByName[c];if(!e){if(!l)throw Error(this+"#"+c+" is undefined");if(!(l instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+l.toString(!0));if(!l.repeated)throw Error(this+"#"+c+" is not a repeated field");}null===this[l.name]&&(this[l.name]=[]);this[l.name].push(e?h:l.verifyValue(h,!0))};e.$add=
22
+ e.add;e.set=function(c,h,e){if(c&&"object"===typeof c){for(var l in c)c.hasOwnProperty(l)&&this.$set(l,c[l],e);return this}l=b._fieldsByName[c];if(e)this[l.name]=h;else{if(!l)throw Error(this+"#"+c+" is not a field: undefined");if(!(l instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+l.toString(!0));this[l.name]=h=l.verifyValue(h)}l.oneof&&(null!==h?(null!==this[l.oneof.name]&&(this[this[l.oneof.name]]=null),this[l.oneof.name]=l.name):l.oneof.name===c&&(this[l.oneof.name]=
23
+ null));return this};e.$set=e.set;e.get=function(c,h){if(h)return this[c];var e=b._fieldsByName[c];if(!(e&&e instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: undefined");if(!(e instanceof a.Reflect.Message.Field))throw Error(this+"#"+c+" is not a field: "+e.toString(!0));return this[e.name]};e.$get=e.get;for(var d=0;d<h.length;d++){var m=h[d];m instanceof a.Reflect.Message.ExtensionField||b.builder.options.populateAccessors&&function(a){var c=a.originalName.replace(/(_[a-zA-Z])/g,
24
+ function(a){return a.toUpperCase().replace("_","")}),c=c.substring(0,1).toUpperCase()+c.substring(1),h=a.originalName.replace(/([A-Z])/g,function(a){return"_"+a}),l=function(b,c){this[a.name]=c?b:a.verifyValue(b);return this},f=function(){return this[a.name]};null===b.getChild("set"+c)&&(e["set"+c]=l);null===b.getChild("set_"+h)&&(e["set_"+h]=l);null===b.getChild("get"+c)&&(e["get"+c]=f);null===b.getChild("get_"+h)&&(e["get_"+h]=f)}(m)}e.encode=function(a,c){"boolean"===typeof a&&(c=a,a=void 0);var h=
25
+ !1;a||(a=new k,h=!0);var e=a.littleEndian;try{return b.encode(this,a.LE(),c),(h?a.flip():a).LE(e)}catch(l){throw a.LE(e),l;}};e.calculate=function(){return b.calculate(this)};e.encodeDelimited=function(a){var c=!1;a||(a=new k,c=!0);var h=(new k).LE();b.encode(this,h).flip();a.writeVarint32(h.remaining());a.append(h);return c?a.flip():a};e.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toArrayBuffer()),a;}};e.toArrayBuffer=e.encodeAB;e.encodeNB=
26
+ function(){try{return this.encode().toBuffer()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBuffer()),a;}};e.toBuffer=e.encodeNB;e.encode64=function(){try{return this.encode().toBase64()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toBase64()),a;}};e.toBase64=e.encode64;e.encodeHex=function(){try{return this.encode().toHex()}catch(a){throw a.encoded&&(a.encoded=a.encoded.toHex()),a;}};e.toHex=e.encodeHex;e.toRaw=function(a){return c(this,!!a)};l.decode=function(a,c){"string"===typeof a&&(a=
27
+ k.wrap(a,c?c:"base64"));a=a instanceof k?a:k.wrap(a);var h=a.littleEndian;try{var e=b.decode(a.LE());a.LE(h);return e}catch(l){throw a.LE(h),l;}};l.decodeDelimited=function(a,c){"string"===typeof a&&(a=k.wrap(a,c?c:"base64"));a=a instanceof k?a:k.wrap(a);if(1>a.remaining())return null;var h=a.offset,e=a.readVarint32();if(a.remaining()<e)return a.offset=h,null;try{var l=b.decode(a.slice(a.offset,a.offset+e).LE());a.offset+=e;return l}catch(f){throw a.offset+=e,f;}};l.decode64=function(a){return l.decode(a,
28
+ "base64")};l.decodeHex=function(a){return l.decode(a,"hex")};e.toString=function(){return b.toString()};Object.defineProperty&&(Object.defineProperty(l,"$options",{value:b.buildOpt()}),Object.defineProperty(e,"$type",{get:function(){return b}}));return l}(c,this);this._fields=[];this._fieldsById={};this._fieldsByName={};for(var b=0,l=this.children.length,e;b<l;b++)if(e=this.children[b],e instanceof q)a[e.name]=e.build();else if(e instanceof f)a[e.name]=e.build();else if(e instanceof f.Field)e.build(),
29
+ this._fields.push(e),this._fieldsById[e.id]=e,this._fieldsByName[e.name]=e;else if(!(e instanceof f.OneOf||e instanceof n))throw Error("Illegal reflect child of "+this.toString(!0)+": "+children[b].toString(!0));return this.clazz=a};d.encode=function(a,b,c){for(var e=null,f,d=0,m=this._fields.length,g;d<m;++d)f=this._fields[d],g=a[f.name],f.required&&null===g?null===e&&(e=f):f.encode(c?g:f.verifyValue(g),b);if(null!==e)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+
30
+ e),a.encoded=b,a;return b};d.calculate=function(a){for(var b=0,c=0,e=this._fields.length,f,d;c<e;++c){f=this._fields[c];d=a[f.name];if(f.required&&null===d)throw Error("Missing at least one required field for "+this.toString(!0)+": "+f);b+=f.calculate(d)}return b};d.decode=function(a,b,l){b="number"===typeof b?b:-1;for(var e=a.offset,f=new this.clazz,d,m,n;a.offset<e+b||-1===b&&0<a.remaining();){d=a.readVarint32();m=d&7;n=d>>3;if(m===c.WIRE_TYPES.ENDGROUP){if(n!==l)throw Error("Illegal group end indicator for "+
31
+ this.toString(!0)+": "+n+" ("+(l?l+" expected":"not a group")+")");break}if(d=this._fieldsById[n])d.repeated&&!d.options.packed?f[d.name].push(d.decode(m,a)):(f[d.name]=d.decode(m,a),d.oneof&&(null!==this[d.oneof.name]&&(this[this[d.oneof.name]]=null),f[d.oneof.name]=d.name));else switch(m){case c.WIRE_TYPES.VARINT:a.readVarint32();break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:d=a.readVarint32();a.offset+=d;break;case c.WIRE_TYPES.STARTGROUP:for(;g(n,
32
+ a););break;default:throw Error("Illegal wire type for unknown field "+n+" in "+this.toString(!0)+"#decode: "+m);}}a=0;for(b=this._fields.length;a<b;++a)if(d=this._fields[a],null===f[d.name]){if(d.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+d.name),a.decoded=f,a;null!==d.defaultValue&&(f[d.name]=d.defaultValue)}return f};p.Message=f;var u=function(a,b,c,e,d,m,g,n){r.call(this,a,b,d);this.className="Message.Field";this.required="required"===c;this.repeated=
33
+ "repeated"===c;this.type=e;this.resolvedType=null;this.id=m;this.options=g||{};this.defaultValue=null;this.oneof=n||null;this.originalName=this.name;!this.builder.options.convertFieldsToCamelCase||this instanceof f.ExtensionField||(this.name=u._toCamelCase(this.name))};u._toCamelCase=function(a){return a.replace(/_([a-zA-Z])/g,function(a,b){return b.toUpperCase()})};d=u.prototype=Object.create(r.prototype);d.build=function(){this.defaultValue="undefined"!==typeof this.options["default"]?this.verifyValue(this.options["default"]):
34
+ null};d.verifyValue=function(a,b){b=b||!1;var l=function(a,b){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+a+" ("+b+")");}.bind(this);if(null===a)return this.required&&l(typeof a,"required"),null;var e;if(this.repeated&&!b){c.Util.isArray(a)||(a=[a]);l=[];for(e=0;e<a.length;e++)l.push(this.verifyValue(a[e],!0));return l}!this.repeated&&c.Util.isArray(a)&&l(typeof a,"no array expected");switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:return("number"!==
35
+ typeof a||a===a&&0!==a%1)&&l(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)&&l(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 t(a,!1)}catch(d){l(typeof a,d.message)}else l(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return t(a,!0)}catch(f){l(typeof a,f.message)}else l(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!==
36
+ typeof a&&l(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&l(typeof a,"not a number"),a;case c.TYPES.string:return"string"===typeof a||a&&a instanceof String||l(typeof a,"not a string"),""+a;case c.TYPES.bytes:return k.isByteBuffer(a)?a:k.wrap(a,"base64");case c.TYPES["enum"]:var m=this.resolvedType.getChildren(q.Value);for(e=0;e<m.length;e++)if(m[e].name==a||m[e].id==a)return m[e].id;l(a,"not a valid enum value");case c.TYPES.group:case c.TYPES.message:a&&
37
+ "object"===typeof a||l(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof c.Builder.Message){l={};for(e in a)a.hasOwnProperty(e)&&(l[e]=a[e]);a=l}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.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&&
38
+ 0==a.length)return b;try{if(this.repeated){var d;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 e=b.offset;for(d=0;d<a.length;d++)this.encodeValue(a[d],b);var f=b.offset-e,m=k.calculateVarint32(f);if(1<m){var g=b.slice(e,b.offset),e=e+(m-1);b.offset=e;b.append(g)}b.writeVarint32(f,e-m)}else for(d=0;d<a.length;d++)b.writeVarint32(this.id<<3|this.type.wireType),this.encodeValue(a[d],b)}else b.writeVarint32(this.id<<
39
+ 3|this.type.wireType),this.encodeValue(a,b)}catch(n){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+n+")");}return b};d.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);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);
40
+ 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);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 "+
41
+ this.toString(!0)+": "+a.remaining()+" bytes remaining");var d=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=d;break;case c.TYPES.message:d=(new k).LE();this.resolvedType.encode(a,d);b.writeVarint32(d.offset);b.append(d.flip());break;case c.TYPES.group:this.resolvedType.encode(a,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};d.calculate=function(a){a=this.verifyValue(a);
42
+ 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 d,e;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=k.calculateVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);for(d=e=0;d<a.length;d++)e+=this.calculateValue(a[d]);b+=k.calculateVarint32(e);b+=e}else for(d=0;d<a.length;d++)b+=k.calculateVarint32(this.id<<3|this.type.wireType),
43
+ b+=this.calculateValue(a[d])}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};d.calculateValue=function(a){if(null===a)return 0;switch(this.type){case c.TYPES.int32:return 0>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;
44
+ 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);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");
45
+ 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 "+this.toString(!0)+": "+a+" (unknown type)");};d.decode=function(a,b,d){if(a!=this.type.wireType&&(d||a!=c.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+
46
+ ": "+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)&&!d){a=b.readVarint32();a=b.offset+a;for(d=[];b.offset<a;)d.push(this.decode(this.type.wireType,b,!0));return d}switch(this.type){case c.TYPES.int32:return b.readVarint32()|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()|
47
+ 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();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()<
48
+ a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+b.remaining());d=b.clone();d.limit=d.offset+a;b.offset+=a;return d;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 "+this.toString(!0)+": "+a);};p.Message.Field=u;d=function(a,b,c,e,d,f,m){u.call(this,a,b,c,e,d,f,m)};d.prototype=Object.create(u.prototype);p.Message.ExtensionField=
49
+ d;p.Message.OneOf=function(a,b,c){r.call(this,a,b,c);this.fields=[]};var q=function(a,b,c,e){m.call(this,a,b,c,e);this.className="Enum";this.object=null};(q.prototype=Object.create(m.prototype)).build=function(){for(var a={},b=this.getChildren(q.Value),c=0,e=b.length;c<e;++c)a[b[c].name]=b[c].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return this.object=a};p.Enum=q;d=function(a,b,c,e){r.call(this,a,b,c);this.className="Enum.Value";this.id=e};d.prototype=
50
+ Object.create(r.prototype);p.Enum.Value=d;var n=function(a,b,c,e){r.call(this,a,b,c);this.field=e};n.prototype=Object.create(r.prototype);p.Extension=n;d=function(a,b,c,e){m.call(this,a,b,c,e);this.className="Service";this.clazz=null};(d.prototype=Object.create(m.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")),
51
+ 0)}},d=c.prototype=Object.create(a.Builder.Service.prototype);Object.defineProperty&&(Object.defineProperty(c,"$options",{value:b.buildOpt()}),Object.defineProperty(d,"$options",{value:c.$options}));for(var f=b.getChildren(a.Reflect.Service.RPCMethod),m=0;m<f.length;m++)(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?
52
+ d(null,e):d(Error("Illegal response type received in service method "+b.name+"#"+a.name))}}):setTimeout(d.bind(this,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,f){(new c(b))[a.name](d,f)};Object.defineProperty&&(Object.defineProperty(c[a.name],"$options",{value:a.buildOpt()}),Object.defineProperty(d[a.name],"$options",{value:c[a.name].$options}))})(f[m]);return c}(c,this)};p.Service=d;var v=function(a,
53
+ b,c,d){r.call(this,a,b,c);this.className="Service.Method";this.options=d||{}};(v.prototype=Object.create(r.prototype)).buildOpt=b.buildOpt;p.Service.Method=v;b=function(a,b,c,d,f,m){v.call(this,a,b,c,m);this.className="Service.RPCMethod";this.requestName=d;this.responseName=f;this.resolvedResponseType=this.resolvedRequestType=null};b.prototype=Object.create(v.prototype);p.Service.RPCMethod=b;return p}(g);g.Builder=function(c,g,k){var p=function(b){this.ptr=this.ns=new k.Namespace(this,null,"");this.resolved=
54
+ !1;this.result=null;this.files={};this.importRoot=null;this.options=b||{}},r=p.prototype;r.reset=function(){this.ptr=this.ns};r.define=function(b,c){if("string"!==typeof b||!g.TYPEREF.test(b))throw Error("Illegal package: "+b);var f=b.split("."),d;for(d=0;d<f.length;d++)if(!g.NAME.test(f[d]))throw Error("Illegal package: "+f[d]);for(d=0;d<f.length;d++)null===this.ptr.getChild(f[d])&&this.ptr.addChild(new k.Namespace(this,this.ptr,f[d],c)),this.ptr=this.ptr.getChild(f[d]);return this};p.isValidMessage=
55
+ function(b){if("string"!==typeof b.name||!g.NAME.test(b.name)||"undefined"!==typeof b.values||"undefined"!==typeof b.rpc)return!1;var m;if("undefined"!==typeof b.fields){if(!c.Util.isArray(b.fields))return!1;var f=[],d;for(m=0;m<b.fields.length;m++){if(!p.isValidMessageField(b.fields[m]))return!1;d=parseInt(b.fields[m].id,10);if(0<=f.indexOf(d))return!1;f.push(d)}}if("undefined"!==typeof b.enums){if(!c.Util.isArray(b.enums))return!1;for(m=0;m<b.enums.length;m++)if(!p.isValidEnum(b.enums[m]))return!1}if("undefined"!==
56
+ typeof b.messages){if(!c.Util.isArray(b.messages))return!1;for(m=0;m<b.messages.length;m++)if(!p.isValidMessage(b.messages[m])&&!p.isValidExtend(b.messages[m]))return!1}return"undefined"===typeof b.extensions||c.Util.isArray(b.extensions)&&2===b.extensions.length&&"number"===typeof b.extensions[0]&&"number"===typeof b.extensions[1]?!0:!1};p.isValidMessageField=function(b){if("string"!==typeof b.rule||"string"!==typeof b.name||"string"!==typeof b.type||"undefined"===typeof b.id||!(g.RULE.test(b.rule)&&
57
+ g.NAME.test(b.name)&&g.TYPEREF.test(b.type)&&g.ID.test(""+b.id)))return!1;if("undefined"!==typeof b.options){if("object"!==typeof b.options)return!1;for(var c=Object.keys(b.options),f=0,d;f<c.length;f++)if("string"!==typeof(d=c[f])||"string"!==typeof b.options[d]&&"number"!==typeof b.options[d]&&"boolean"!==typeof b.options[d])return!1}return!0};p.isValidEnum=function(b){if("string"!==typeof b.name||!g.NAME.test(b.name)||"undefined"===typeof b.values||!c.Util.isArray(b.values)||0==b.values.length)return!1;
58
+ for(var m=0;m<b.values.length;m++)if("object"!=typeof b.values[m]||"string"!==typeof b.values[m].name||"undefined"===typeof b.values[m].id||!g.NAME.test(b.values[m].name)||!g.NEGID.test(""+b.values[m].id))return!1;return!0};r.create=function(b){if(!b)return this;c.Util.isArray(b)||(b=[b]);if(0==b.length)return this;var m=[];for(m.push(b);0<m.length;){b=m.pop();if(c.Util.isArray(b))for(;0<b.length;){var f=b.shift();if(p.isValidMessage(f)){var d=new k.Message(this,this.ptr,f.name,f.options,f.isGroup),
59
+ g={};if(f.oneofs)for(var q=Object.keys(f.oneofs),n=0,s=q.length;n<s;++n)d.addChild(g[q[n]]=new k.Message.OneOf(this,d,q[n]));if(f.fields&&0<f.fields.length)for(n=0,s=f.fields.length;n<s;++n){q=f.fields[n];if(null!==d.getChild(q.id))throw Error("Duplicate field id in message "+d.name+": "+q.id);if(q.options)for(var a=Object.keys(q.options),h=0,l=a.length;h<l;++h){if("string"!==typeof a[h])throw Error("Illegal field option name in message "+d.name+"#"+q.name+": "+a[h]);if("string"!==typeof q.options[a[h]]&&
60
+ "number"!==typeof q.options[a[h]]&&"boolean"!==typeof q.options[a[h]])throw Error("Illegal field option value in message "+d.name+"#"+q.name+"#"+a[h]+": "+q.options[a[h]]);}a=null;if("string"===typeof q.oneof&&(a=g[q.oneof],"undefined"===typeof a))throw Error("Illegal oneof in message "+d.name+"#"+q.name+": "+q.oneof);q=new k.Message.Field(this,d,q.rule,q.type,q.name,q.id,q.options,a);a&&a.fields.push(q);d.addChild(q)}g=[];if("undefined"!==typeof f.enums&&0<f.enums.length)for(n=0;n<f.enums.length;n++)g.push(f.enums[n]);
61
+ if(f.messages&&0<f.messages.length)for(n=0;n<f.messages.length;n++)g.push(f.messages[n]);f.extensions&&(d.extensions=f.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<g.length&&(m.push(b),b=g,this.ptr=d)}else if(p.isValidEnum(f)){d=new k.Enum(this,this.ptr,f.name,f.options);for(n=0;n<f.values.length;n++)d.addChild(new k.Enum.Value(this,d,f.values[n].name,f.values[n].id));this.ptr.addChild(d)}else if(p.isValidService(f)){d=
62
+ new k.Service(this,this.ptr,f.name,f.options);for(n in f.rpc)f.rpc.hasOwnProperty(n)&&d.addChild(new k.Service.RPCMethod(this,d,n,f.rpc[n].request,f.rpc[n].response,f.rpc[n].options));this.ptr.addChild(d)}else if(p.isValidExtend(f))if(d=this.ptr.resolve(f.ref))for(n=0;n<f.fields.length;n++){if(null!==d.getChild(f.fields[n].id))throw Error("Duplicate extended field id in message "+d.name+": "+f.fields[n].id);if(f.fields[n].id<d.extensions[0]||f.fields[n].id>d.extensions[1])throw Error("Illegal extended field id in message "+
63
+ d.name+": "+f.fields[n].id+" ("+d.extensions.join(" to ")+" expected)");g=f.fields[n].name;this.options.convertFieldsToCamelCase&&(g=k.Message.Field._toCamelCase(f.fields[n].name));q=new k.Message.ExtensionField(this,d,f.fields[n].rule,f.fields[n].type,this.ptr.fqn()+"."+g,f.fields[n].id,f.fields[n].options);g=new k.Extension(this,this.ptr,f.fields[n].name,q);q.extension=g;this.ptr.addChild(g);d.addChild(q)}else{if(!/\.?google\.protobuf\./.test(f.ref))throw Error("Extended message "+f.ref+" is not defined");
64
+ }else throw Error("Not a valid definition: "+JSON.stringify(f));}else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};r["import"]=function(b,g){if("string"===typeof g){c.Util.IS_NODE&&(g=require("path").resolve(g));if(!0===this.files[g])return this.reset(),this;this.files[g]=!0}if(b.imports&&0<b.imports.length){var f,d="/",k=!1;if("object"===typeof g){if(this.importRoot=g.root,k=!0,f=this.importRoot,g=g.file,0<=f.indexOf("\\")||
65
+ 0<=g.indexOf("\\"))d="\\"}else"string"===typeof g?this.importRoot?f=this.importRoot:0<=g.indexOf("/")?(f=g.replace(/\/[^\/]*$/,""),""===f&&(f="/")):0<=g.indexOf("\\")?(f=g.replace(/\\[^\\]*$/,""),d="\\"):f=".":f=null;for(var p=0;p<b.imports.length;p++)if("string"===typeof b.imports[p]){if(!f)throw Error("Cannot determine import root: File name is unknown");var n=b.imports[p];if(!/^google\/protobuf\//.test(n)&&(n=f+d+n,!0!==this.files[n])){/\.proto$/i.test(n)&&!c.DotProto&&(n=n.replace(/\.proto$/,
66
+ ".json"));var s=c.Util.fetch(n);if(null===s)throw Error("Failed to import '"+n+"' in '"+g+"': File not found");if(/\.json$/i.test(n))this["import"](JSON.parse(s+""),n);else this["import"]((new c.DotProto.Parser(s+"")).parse(),n)}}else if(g)if(/\.(\w+)$/.test(g))this["import"](b.imports[p],g.replace(/^(.+)\.(\w+)$/,function(a,b,c){return b+"_import"+p+"."+c}));else this["import"](b.imports[p],g+"_import"+p);else this["import"](b.imports[p]);k&&(this.importRoot=null)}b.messages&&(b["package"]&&this.define(b["package"],
67
+ b.options),this.create(b.messages),this.reset());b.enums&&(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};p.isValidService=function(b){return!("string"!==typeof b.name||!g.NAME.test(b.name)||"object"!==typeof b.rpc)};p.isValidExtend=function(b){if("string"!==
68
+ typeof b.ref||!g.TYPEREF.test(b.ref))return!1;var m;if("undefined"!==typeof b.fields){if(!c.Util.isArray(b.fields))return!1;var f=[],d;for(m=0;m<b.fields.length;m++){if(!p.isValidMessageField(b.fields[m]))return!1;d=parseInt(b.id,10);if(0<=f.indexOf(d))return!1;f.push(d)}}return!0};r.resolveAll=function(){var b;if(null!=this.ptr&&"object"!==typeof this.ptr.type){if(this.ptr instanceof k.Namespace){b=this.ptr.children;for(var m=0,f=b.length;m<f;++m)this.ptr=b[m],this.resolveAll()}else if(this.ptr instanceof
69
+ k.Message.Field)if(g.TYPE.test(this.ptr.type))this.ptr.type=c.TYPES[this.ptr.type];else{if(!g.TYPEREF.test(this.ptr.type))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);b=(this.ptr instanceof k.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 k.Enum)this.ptr.type=c.TYPES["enum"];else if(b instanceof
70
+ k.Message)this.ptr.type=b.isGroup?c.TYPES.group: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){b=this.ptr.parent.resolve(this.ptr.requestName);if(!(b&&b instanceof c.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=
71
+ b;b=this.ptr.parent.resolve(this.ptr.responseName);if(!(b&&b instanceof c.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 c.Reflect.Message.OneOf||this.ptr instanceof c.Reflect.Extension))throw Error("Illegal object in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};r.build=function(b){this.reset();this.resolved||
72
+ (this.resolveAll(),this.resolved=!0,this.result=null);null==this.result&&(this.result=this.ns.build());if(b){b=b.split(".");for(var c=this.result,f=0;f<b.length;f++)if(c[b[f]])c=c[b[f]];else{c=null;break}return c}return this.result};r.lookup=function(b){return b?this.ns.resolve(b):this.ns};r.toString=function(){return"Builder"};p.Message=function(){};p.Service=function(){};return p}(g,g.Lang,g.Reflect);g.newBuilder=function(c){c=c||{};"undefined"===typeof c.convertFieldsToCamelCase&&(c.convertFieldsToCamelCase=
73
+ g.convertFieldsToCamelCase);"undefined"===typeof c.populateAccessors&&(c.populateAccessors=g.populateAccessors);return new g.Builder(c)};g.loadJson=function(c,k,t){if("string"===typeof k||k&&"string"===typeof k.file&&"string"===typeof k.root)t=k,k=null;k&&"object"===typeof k||(k=g.newBuilder());"string"===typeof c&&(c=JSON.parse(c));k["import"](c,t);k.resolveAll();return k};g.loadJsonFile=function(c,k,t){k&&"object"===typeof k?(t=k,k=null):k&&"function"===typeof k||(k=null);if(k)return g.Util.fetch("string"===
74
+ typeof c?c:c.root+"/"+c.file,function(p){if(null===p)k(Error("Failed to fetch file"));else try{k(null,g.loadJson(JSON.parse(p),t,c))}catch(b){k(b)}});var p=g.Util.fetch("object"===typeof c?c.root+"/"+c.file:c);return null===p?null:g.loadJson(JSON.parse(p),t,c)};return g}"function"===typeof require&&"object"===typeof module&&module&&"object"===typeof exports&&exports?module.exports=x(require("bytebuffer")):"function"===typeof define&&define.amd?define(["ByteBuffer"],x):(w.dcodeIO=w.dcodeIO||{}).ProtoBuf=
75
+ x(w.dcodeIO.ByteBuffer)})(this);
Binary file