forked from protobufjs/protobuf.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProtoBuf.min.js
84 lines (84 loc) · 39.7 KB
/
ProtoBuf.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
ProtoBuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
Released under the Apache License, Version 2.0
see: https://github.com/dcodeIO/ProtoBuf.js for details
*/
(function(r){function s(p){var h={VERSION:"1.2.0",WIRE_TYPES:{}};h.WIRE_TYPES.VARINT=0;h.WIRE_TYPES.BITS64=1;h.WIRE_TYPES.LDELIM=2;h.WIRE_TYPES.STARTGROUP=3;h.WIRE_TYPES.ENDGROUP=4;h.WIRE_TYPES.BITS32=5;h.TYPES={int32:{name:"int32",wireType:h.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:h.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:h.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:h.WIRE_TYPES.VARINT},uint64:{name:"uint64",wireType:h.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:h.WIRE_TYPES.VARINT},
bool:{name:"bool",wireType:h.WIRE_TYPES.VARINT},"double":{name:"double",wireType:h.WIRE_TYPES.BITS64},string:{name:"string",wireType:h.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:h.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:h.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:h.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:h.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:h.WIRE_TYPES.BITS64},"float":{name:"float",wireType:h.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:h.WIRE_TYPES.VARINT},
message:{name:"message",wireType:h.WIRE_TYPES.LDELIM}};h.Long=p.Long;h.Util=function(){Object.create||(Object.create=function(b){function c(){}if(1<arguments.length)throw Error("Object.create implementation only accepts the first parameter.");c.prototype=b;return new c});var c={};c.IS_NODE=("undefined"==typeof window||!window.window)&&"function"==typeof require&&"undefined"!==typeof process&&"function"===typeof process.nextTick;c.XHR=function(){for(var b=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},
function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],c=null,f=0;f<b.length;f++){try{c=b[f]()}catch(a){continue}break}if(!c)throw Error("XMLHttpRequest is not supported");return c};c.fetch=function(b,l){l&&"function"!=typeof l&&(l=null);if(c.IS_NODE)if(l)require("fs").readFile(b,function(a,b){a?l(null):l(""+b)});else try{return require("fs").readFileSync(b)}catch(f){return null}else{var a=c.XHR();a.open("GET",b,l?!0:!1);a.setRequestHeader("Accept",
"text/plain");if(l)a.onreadystatechange=function(){4==a.readyState&&(200==a.status?l(a.responseText):l(null))},4!=a.readyState&&a.send(null);else return a.send(null),a.responseText}};c.isArray=function(b){return b?b instanceof Array?!0:Array.isArray?Array.isArray(b):"[object Array]"===Object.prototype.toString.call(b):!1};return c}();h.Lang={OPEN:"{",CLOSE:"}",OPTOPEN:"[",OPTCLOSE:"]",OPTEND:",",EQUAL:"=",END:";",STRINGOPEN:'"',STRINGCLOSE:'"',COPTOPEN:"(",COPTCLOSE:")",DELIM:/[\s\{\}=;\[\],"\(\)]/g,
KEYWORD:/package|option|import|message|enum|extend|service|syntax|extensions/,RULE:/required|optional|repeated/,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]+)$/,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]+$/,ID:/^(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0x[0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/"([^"\\]*(\\.[^"\\]*)*)"/g};h.DotProto={};h.DotProto.Tokenizer=function(c){var b=function(b){this.source=""+b;this.index=0;this.line=1;this.stack=[];this.readingString=!1};b.prototype._readString=function(){c.STRING.lastIndex=this.index-1;var b;if(null!==(b=c.STRING.exec(this.source)))return b=b[1],this.index=c.STRING.lastIndex,this.stack.push(c.STRINGCLOSE),
b;throw Error("Illegal string value at line "+this.line+", index "+this.index);};b.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,f;do{for(b=!1;c.WHITESPACE.test(f=this.source.charAt(this.index));)if(this.index++,"\n"==f&&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++,this.index==this.source.length)return null;this.index++;this.line++;b=!0}else if("*"==this.source.charAt(this.index)){for(f="";"*/"!=f+(f=this.source.charAt(this.index));)if(this.index++,"\n"==f&&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;
c.DELIM.lastIndex=0;if(c.DELIM.test(this.source.charAt(b)))b++;else for(b++;b<this.source.length&&!c.DELIM.test(this.source.charAt(b));)b++;b=this.source.substring(this.index,this.index=b);b==c.STRINGOPEN&&(this.readingString=!0);return b};b.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]};b.prototype.toString=function(){return"Tokenizer("+this.index+"/"+this.source.length+")"};return b}(h.Lang);h.DotProto.Parser=
function(c,b,h){c=function(b){this.tn=new h(b)};c.prototype.parse=function(){var b={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{},services:[]},a,d=!0;do{a=this.tn.next();if(null==a)break;if("package"==a){if(!d)throw Error("Illegal package definition at line "+this.tn.line+": Must be declared before the first message or enum");if(null!==b["package"])throw Error("Illegal package definition at line "+this.tn.line+": Package already declared");b["package"]=this._parsePackage(a)}else if("import"==
a){if(!d)throw Error("Illegal import definition at line "+this.tn.line+": Must be declared before the first message or enum");b.imports.push(this._parseImport(a))}else if("message"==a)this._parseMessage(b,a),d=!1;else if("enum"==a)this._parseEnum(b,a),d=!1;else if("option"==a){if(!d)throw Error("Illegal option definition at line "+this.tn.line+": Must be declared before the first message or enum");this._parseOption(b,a)}else if("service"==a)this._parseService(b,a);else if("extend"==a)this._parseIgnoredBlock(b,
a);else if("syntax"==a)this._parseIgnoredStatement(b,a);else throw Error("Illegal top level declaration at line "+this.tn.line+": "+a);}while(1);delete b.name;return b};c.prototype._parseNumber=function(c){var a=1;"-"==c.charAt(0)&&(a=-1,c=c.substring(1));if(b.NUMBER_DEC.test(c))return a*parseInt(c,10);if(b.NUMBER_HEX.test(c))return a*parseInt(c.substring(2),16);if(b.NUMBER_OCT.test(c))return a*parseInt(c.substring(1),8);if(b.NUMBER_FLT.test(c))return a*parseFloat(c);throw Error("Illegal number value at line "+
this.tn.line+": "+(0>a?"-":"")+c);};c.prototype._parseId=function(c,a){var d=-1,e=1;"-"==c.charAt(0)&&(e=-1,c=c.substring(1));if(b.NUMBER_DEC.test(c))d=parseInt(c);else if(b.NUMBER_HEX.test(c))d=parseInt(c.substring(2),16);else if(b.NUMBER_OCT.test(c))d=parseInt(c.substring(1),8);else throw Error("Illegal ID value at line "+this.tn.line+": "+(0>e?"-":"")+c);d=e*d|0;if(!a&&0>d)throw Error("Illegal ID range at line "+this.tn.line+": "+(0>e?"-":"")+c);return d};c.prototype._parsePackage=function(c){c=
this.tn.next();if(!b.TYPEDEF.test(c))throw Error("Illegal package name at line "+this.tn.line+": "+c);var a=c;c=this.tn.next();if(c!=b.END)throw Error("Illegal end of package definition at line "+this.tn.line+": "+c+" ('"+b.END+"' expected)");return a};c.prototype._parseImport=function(c){c=this.tn.next();"public"==c&&(c=this.tn.next());if(c!=b.STRINGOPEN)throw Error("Illegal begin of import value at line "+this.tn.line+": "+c+" ('"+b.STRINGOPEN+"' expected)");var a=this.tn.next();c=this.tn.next();
if(c!=b.STRINGCLOSE)throw Error("Illegal end of import value at line "+this.tn.line+": "+c+" ('"+b.STRINGCLOSE+"' expected)");c=this.tn.next();if(c!=b.END)throw Error("Illegal end of import definition at line "+this.tn.line+": "+c+" ('"+b.END+"' expected)");return a};c.prototype._parseOption=function(c,a){a=this.tn.next();var d=!1;a==b.COPTOPEN&&(d=!0,a=this.tn.next());if(!b.NAME.test(a))throw Error("Illegal option name in message "+c.name+" at line "+this.tn.line+": "+a);var e=a;a=this.tn.next();
if(d){if(a!=b.COPTCLOSE)throw Error("Illegal custom option name delimiter in message "+c.name+", option "+e+" at line "+this.tn.line+": "+a+" ('"+b.COPTCLOSE+"' expected)");e="("+e+")";a=this.tn.next();b.FQTYPEREF.test(a)&&(e+=a,a=this.tn.next())}if(a!=b.EQUAL)throw Error("Illegal option operator in message "+c.name+", option "+e+" at line "+this.tn.line+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();if(a==b.STRINGOPEN){if(d=this.tn.next(),a=this.tn.next(),a!=b.STRINGCLOSE)throw Error("Illegal end of option value in message "+
c.name+", option "+e+" at line "+this.tn.line+": "+a+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(a))d=this._parseNumber(a,!0);else if(b.NAME.test(a))d=a;else throw Error("Illegal option value in message "+c.name+", option "+e+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=b.END)throw Error("Illegal end of option in message "+c.name+", option "+e+" at line "+this.tn.line+": "+a+" ('"+b.END+"' expected)");c.options[e]=d};c.prototype._parseIgnoredBlock=function(c,a){var d=this.tn.next();
if(!b.TYPEREF.test(d))throw Error("Illegal "+a+" type in "+c.name+": "+d);var e=d,d=this.tn.next();if(d!=b.OPEN)throw Error("Illegal OPEN in "+c.name+" after "+a+" "+e+" at line "+this.tn.line+": "+d);var k=1;do{d=this.tn.next();if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored) at line "+this.tn.line+": "+e);if(d==b.OPEN)k++;else if(d==b.CLOSE&&(d=this.tn.peek(),d==b.END&&this.tn.next(),k--,0==k))break}while(1)};c.prototype._parseIgnoredStatement=function(c,a){do{var d=this.tn.next();
if(null===d)throw Error("Unexpected EOF in "+c.name+", "+a+" (ignored) at line "+this.tn.line);if(d==b.END)break}while(1)};c.prototype._parseService=function(c,a){var d=this.tn.next();if(!b.NAME.test(d))throw Error("Illegal service name at line "+this.tn.line+": "+d);var e=d,k={name:e,rpc:{},options:{}},d=this.tn.next();if(d!=b.OPEN)throw Error("Illegal OPEN after service "+e+" at line "+this.tn.line+": "+d+" ('"+b.OPEN+"' expected)");do if(d=this.tn.next(),"option"==d)this._parseOption(k,d);else if("rpc"==
d)this._parseServiceRPC(k,d);else if(d!=b.CLOSE)throw Error("Illegal type for service "+e+" at line "+this.tn.line+": "+d);while(d!=b.CLOSE);c.services.push(k)};c.prototype._parseServiceRPC=function(c,a){var d=a;a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal RPC method name in service "+c.name+" at line "+this.tn.line+": "+a);var e=a,k={request:null,response:null,options:{}};a=this.tn.next();if(a!=b.COPTOPEN)throw Error("Illegal start of request type in RPC service "+c.name+"#"+e+" at line "+
this.tn.line+": "+a+" ('"+b.COPTOPEN+"' expected)");a=this.tn.next();if(!b.TYPEREF.test(a))throw Error("Illegal request type in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a);k.request=a;a=this.tn.next();if(a!=b.COPTCLOSE)throw Error("Illegal end of request type in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a+" ('"+b.COPTCLOSE+"' expected)");a=this.tn.next();if("returns"!=a.toLowerCase())throw Error("Illegal request/response delimiter in RPC service "+c.name+"#"+e+" at line "+
this.tn.line+": "+a+" ('returns' expected)");a=this.tn.next();if(a!=b.COPTOPEN)throw Error("Illegal start of response type in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a+" ('"+b.COPTOPEN+"' expected)");a=this.tn.next();k.response=a;a=this.tn.next();if(a!=b.COPTCLOSE)throw Error("Illegal end of response type in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a+" ('"+b.COPTCLOSE+"' expected)");a=this.tn.next();if(a==b.OPEN){do if(a=this.tn.next(),"option"==a)this._parseOption(k,
a);else if(a!=b.CLOSE)throw Error("Illegal start of option in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a+" ('option' expected)");while(a!=b.CLOSE)}else if(a!=b.END)throw Error("Illegal method delimiter in RPC service "+c.name+"#"+e+" at line "+this.tn.line+": "+a+" ('"+b.END+"' or '"+b.OPEN+"' expected)");"undefined"===typeof c[d]&&(c[d]={});c[d][e]=k};c.prototype._parseMessage=function(c,a){var d={};a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal message name"+(c?" in message "+
c.name:"")+" at line "+this.tn.line+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after message "+d.name+" at line "+this.tn.line+": "+a+" ('"+b.OPEN+"' expected)");d.fields=[];d.enums=[];d.messages=[];d.options={};do if(a=this.tn.next(),a==b.CLOSE){a=this.tn.peek();a==b.END&&this.tn.next();break}else if(b.RULE.test(a))this._parseMessageField(d,a);else if("enum"==a)this._parseEnum(d,a);else if("message"==a)this._parseMessage(d,a);else if("option"==a)this._parseOption(d,
a);else if("extensions"==a)this._parseIgnoredStatement(d,a);else throw Error("Illegal token in message "+d.name+" at line "+this.tn.line+": "+a+" (type or '"+b.CLOSE+"' expected)");while(1);c.messages.push(d);return d};c.prototype._parseMessageField=function(c,a){var d={};d.rule=a;a=this.tn.next();if(!b.TYPE.test(a)&&!b.TYPEREF.test(a))throw Error("Illegal field type in message "+c.name+" at line "+this.tn.line+": "+a);d.type=a;a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal field name in message "+
c.name+" at line "+this.tn.line+": "+a);d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal field number operator in message "+c.name+"#"+d.name+" at line "+this.tn.line+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a)}catch(e){throw Error("Illegal field id in message "+c.name+"#"+d.name+" at line "+this.tn.line+": "+a);}d.options={};a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,d,a),a=this.tn.next());if(a!=b.END)throw Error("Illegal field delimiter in message "+
c.name+"#"+d.name+" at line "+this.tn.line+": "+a+" ('"+b.END+"' expected)");c.fields.push(d)};c.prototype._parseFieldOptions=function(c,a,d){var e=!0;do{d=this.tn.next();if(d==b.OPTCLOSE)break;else if(d==b.OPTEND){if(e)throw Error("Illegal start of message field options in message "+c.name+"#"+a.name+" at line "+this.tn.line+": "+d);d=this.tn.next()}this._parseFieldOption(c,a,d);e=!1}while(1)};c.prototype._parseFieldOption=function(c,a,d){var e=!1;d==b.COPTOPEN&&(d=this.tn.next(),e=!0);if(!b.NAME.test(d))throw Error("Illegal field option in message "+
c.name+"#"+a.name+" at line "+this.tn.line+": "+d);var k=d;d=this.tn.next();if(e){if(d!=b.COPTCLOSE)throw Error("Illegal custom field option name delimiter in message "+c.name+"#"+a.name+" at line "+this.tn.line+": "+d+" (')' expected)");k="("+k+")";d=this.tn.next();b.FQTYPEREF.test(d)&&(k+=d,d=this.tn.next())}if(d!=b.EQUAL)throw Error("Illegal field option operation in message "+c.name+"#"+a.name+" at line "+this.tn.line+": "+d+" ('=' expected)");d=this.tn.next();if(d==b.STRINGOPEN){if(e=this.tn.next(),
d=this.tn.next(),d!=b.STRINGCLOSE)throw Error("Illegal end of field value in message "+c.name+"#"+a.name+", option "+k+" at line "+this.tn.line+": "+d+" ('"+b.STRINGCLOSE+"' expected)");}else if(b.NUMBER.test(d,!0))e=this._parseNumber(d,!0);else if(b.TYPEREF.test(d))e=d;else throw Error("Illegal field option value in message "+c.name+"#"+a.name+", option "+k+" at line "+this.tn.line+": "+d);a.options[k]=e};c.prototype._parseEnum=function(c,a){var d={};a=this.tn.next();if(!b.NAME.test(a))throw Error("Illegal enum name in message "+
c.name+" at line "+this.tn.line+": "+a);d.name=a;a=this.tn.next();if(a!=b.OPEN)throw Error("Illegal OPEN after enum "+d.name+" at line "+this.tn.line+": "+a);d.values=[];d.options={};do{a=this.tn.next();if(a==b.CLOSE){a=this.tn.peek();a==b.END&&this.tn.next();break}if("option"==a)this._parseOption(d,a);else{if(!b.NAME.test(a))throw Error("Illegal enum value name in enum "+d.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(d,a)}}while(1);c.enums.push(d)};c.prototype._parseEnumValue=function(c,
a){var d={};d.name=a;a=this.tn.next();if(a!=b.EQUAL)throw Error("Illegal enum value operator in enum "+c.name+" at line "+this.tn.line+": "+a+" ('"+b.EQUAL+"' expected)");a=this.tn.next();try{d.id=this._parseId(a,!0)}catch(e){throw Error("Illegal enum value id in enum "+c.name+" at line "+this.tn.line+": "+a);}c.values.push(d);a=this.tn.next();a==b.OPTOPEN&&(this._parseFieldOptions(c,{options:{}},a),a=this.tn.next());if(a!=b.END)throw Error("Illegal enum value delimiter in enum "+c.name+" at line "+
this.tn.line+": "+a+" ('"+b.END+"' expected)");};c.prototype.toString=function(){return"Parser"};return c}(h,h.Lang,h.DotProto.Tokenizer);h.Reflect=function(c){var b={},h=function(a,c){this.parent=a;this.name=c};h.prototype.toString=function(c){var b=this.name,d=this;do{d=d.parent;if(null==d)break;b=d.name+"."+b}while(1);c&&(this instanceof a?b="Message "+b:this instanceof a.Field?b="Message.Field "+b:this instanceof e?b="Enum "+b:this instanceof e.Value?b="Enum.Value "+b:this instanceof k?b="Service "+
b:this instanceof k.Method?b=this instanceof k.RPCMethod?"Service.RPCMethod "+b:"Service.Method "+b:this instanceof f&&(b="Namespace "+b));return b};h.prototype.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};b.T=h;var f=function(a,c,b){h.call(this,a,c);this.children=[];this.options=b||{}};f.prototype=Object.create(h.prototype);f.prototype.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var c=[],b=0;b<this.children.length;b++)this.children[b]instanceof
a&&c.push(this.children[b]);return c};f.prototype.addChild=function(a){if(this.hasChild(a.name))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+a.name);this.children.push(a)};f.prototype.hasChild=function(a){var c;if("number"==typeof a)for(c=0;c<this.children.length;c++){if("undefined"!==typeof this.children[c].id&&this.children[c].id==a)return!0}else for(c=0;c<this.children.length;c++)if("undefined"!==typeof this.children[c].name&&this.children[c].name==a)return!0;return!1};f.prototype.getChild=
function(a){var c;if("number"==typeof a)for(c=0;c<this.children.length;c++){if("undefined"!==typeof this.children[c].id&&this.children[c].id==a)return this.children[c]}else for(c=0;c<this.children.length;c++)if("undefined"!==typeof this.children[c].name&&this.children[c].name==a)return this.children[c];return null};f.prototype.resolve=function(a){var c=a.split("."),d=this,e=0;if(""==c[e]){for(;null!=d.parent;)d=d.parent;e++}do{do{d=d.getChild(c[e]);if(!(d&&d instanceof b.T)){d=null;break}e++}while(e<
c.length);if(null!=d)break;if(null!==this.parent)return this.parent.resolve(a)}while(null!=d);return d};f.prototype.build=function(){for(var a={},c=this.getChildren(),b,d=0;d<c.length;d++)b=c[d],b instanceof f&&(a[b.name]=b.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return a};f.prototype.buildOpt=function(){for(var a={},c=Object.keys(this.options),b=0;b<c.length;b++)a[c[b]]=this.options[c[b]];return a};f.prototype.getOption=
function(a){return"undefined"==typeof a?this.options:"undefined"!=typeof this.options[a]?this.options[a]:null};b.Namespace=f;var a=function(a,c,b){f.call(this,a,c,b);this.clazz=null};a.prototype=Object.create(f.prototype);a.prototype.build=function(){for(var d=function(a,b){var d=b.getChildren(a.Message.Field),g;try{g=eval("0, (function "+b.name+"() { ProtoBuf.Builder.Message.call(this); this.__construct.apply(this, arguments); })")}catch(m){g=function(){c.Builder.Message.call(this);this.__construct.apply(this,
arguments)}}g.prototype=Object.create(c.Builder.Message.prototype);g.prototype.__construct=function(a){var b,g;for(b=0;b<d.length;b++)g=d[b],this[g.name]=g.repeated?[]:null;for(b=0;b<d.length;b++)if(g=d[b],"undefined"!=typeof g.options["default"])try{this.set(g.name,g.options["default"])}catch(e){throw Error("[INTERNAL] "+e);}if(1!=arguments.length||"object"!=typeof a||"function"==typeof a.encode||c.Util.isArray(a)||a instanceof p||a instanceof ArrayBuffer||c.Long&&a instanceof c.Long)for(b=0;b<arguments.length;b++)b<
d.length&&this.set(d[b].name,arguments[b]);else for(g=Object.keys(a),b=0;b<g.length;b++)this.set(g[b],a[g[b]])};g.prototype.add=function(c,d){var g=b.getChild(c);if(!g)throw Error(this+"#"+c+" is undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));if(!g.repeated)throw Error(this+"#"+c+" is not a repeated field");null===this[g.name]&&(this[g.name]=[]);this[g.name].push(g.verifyValue(d,!0))};g.prototype.set=function(c,d){var g=b.getChild(c);if(!g)throw Error(this+
"#"+c+" is not a field: undefined");if(!(g instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+g.toString(!0));this[g.name]=g.verifyValue(d)};g.prototype.get=function(c){var d=b.getChild(c);if(!(d&&d instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: undefined");if(!(d instanceof a.Message.Field))throw Error(this+"#"+c+" is not a field: "+d.toString(!0));return this[d.name]};for(var e=0;e<d.length;e++)(function(a){var c=a.name.replace(/(_[a-zA-Z])/g,function(a){return a.toUpperCase().replace("_",
"")}),c=c.substring(0,1).toUpperCase()+c.substring(1),d=a.name.replace(/([A-Z])/g,function(a){return"_"+a});b.hasChild("set"+c)||(g.prototype["set"+c]=function(c){this.set(a.name,c)});b.hasChild("set_"+d)||(g.prototype["set_"+d]=function(c){this.set(a.name,c)});b.hasChild("get"+c)||(g.prototype["get"+c]=function(){return this.get(a.name)});b.hasChild("get_"+d)||(g.prototype["get_"+d]=function(){return this.get(a.name)})})(d[e]);g.prototype.encode=function(a){a=a||new p;var c=a.littleEndian;try{var d=
b.encode(this,a.LE()).flip();a.littleEndian=c;return d}catch(g){throw a.littleEndian=c,g;}};g.prototype.toArrayBuffer=function(){return this.encode().toArrayBuffer()};g.prototype.toBuffer=function(){return this.encode().toBuffer()};g.prototype.toBase64=function(){return this.encode().toBase64()};g.decode=function(a){a=a?a instanceof p?a:p.wrap(a):new p;var c=a.littleEndian;try{var d=b.decode(a.LE());a.littleEndian=c;return d}catch(g){throw a.littleEndian=c,g;}};g.decode64=function(a){return g.decode(p.decode64(a))};
g.prototype.toString=function(){return b.toString()};Object.defineProperty&&Object.defineProperty(g,"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return g}(b,this),m=this.getChildren(),q=0;q<m.length;q++)if(m[q]instanceof e)d[m[q].name]=m[q].build();else if(m[q]instanceof a)d[m[q].name]=m[q].build();else if(!(m[q]instanceof a.Field))throw Error("Illegal reflect child of "+this.toString(!0)+": "+m[q].toString(!0));return this.clazz=d};a.prototype.encode=function(c,b){for(var d=
this.getChildren(a.Field),e=0;e<d.length;e++)d[e].encode(c.get(d[e].name),b);return b};a.prototype.decode=function(a,d){d="number"===typeof d?d:-1;for(var e=a.offset,k=new this.clazz;a.offset<e+d||-1==d&&0<a.remaining();){var h=a.readVarint32(),f=h&7,h=h>>3,l=this.getChild(h);if(l)l.repeated&&!l.options.packed?k.add(l.name,l.decode(f,a)):k.set(l.name,l.decode(f,a));else switch(f){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:f=a.readVarint32();a.offset+=f;break;default:throw Error("Illegal wire type of unknown field "+h+" in "+this.toString(!0)+"#decode: "+f);}}e=this.getChildren(b.Field);for(f=0;f<e.length;f++)if(e[f].required&&null===k[e[f].name])throw e=Error("Missing field "+e[f].toString(!0)+" in "+this.toString(!0)+"#decode"),e.msg=k,e;return k};b.Message=a;var d=function(a,c,b,d,e,f){h.call(this,a,d);this.required="required"==c;this.repeated="repeated"==c;this.type=b;this.resolvedType=
null;this.id=e;this.options=f||{}};d.prototype=Object.create(h.prototype);d.prototype.verifyValue=function(a,b){b=b||!1;if(null===a){if(this.required)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (required)");return null}var d;if(this.repeated&&!b){c.Util.isArray(a)||(a=[a]);var f=[];for(d=0;d<a.length;d++)f.push(this.verifyValue(a[d],!0));return f}if(!this.repeated&&c.Util.isArray(a))throw Error("Illegal value for "+this.toString(!0)+": "+a+" (no array expected)");if(this.type==c.TYPES.int32||
this.type==c.TYPES.sint32||this.type==c.TYPES.sfixed32){d=parseInt(a,10);if(isNaN(d))throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a number)");return d|0}if(this.type==c.TYPES.uint32||this.type==c.TYPES.fixed32){d=parseInt(a,10);if(isNaN(d))throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a number)");return d>>>0}if(c.Long){if(this.type==c.TYPES.int64||this.type==c.TYPES.sint64||this.type==c.TYPES.sfixed64)return"object"==typeof a&&a instanceof c.Long?a.unsigned?
a.toSigned():a:c.Long.fromNumber(a,!1);if(this.type==c.TYPES.uint64||this.type==c.TYPES.fixed64)return"object"==typeof a&&a instanceof c.Long?a.unsigned?a:a.toUnsigned():c.Long.fromNumber(a,!0)}if(this.type==c.TYPES.bool)return!!a;if(this.type==c.TYPES["float"]||this.type==c.TYPES["double"]){d=parseFloat(a);if(isNaN(d))throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a number)");return d}if(this.type==c.TYPES.string)return""+a;if(this.type==c.TYPES.bytes)return"object"==typeof a&&
a instanceof p?a:p.wrap(a);if(this.type==c.TYPES["enum"]){f=this.resolvedType.getChildren(e.Value);for(d=0;d<f.length;d++)if(f[d].name==a||f[d].id==a)return f[d].id;throw Error("Illegal value for "+this.toString(!0)+": "+a+" (not a valid enum value)");}if(this.type==c.TYPES.message){if("object"!=typeof a)throw Error("Illegal value for "+this.toString(!0)+": "+a+" (object expected)");return a instanceof this.resolvedType.clazz?a:new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+
this.toString(!0)+": "+a+" (undefined type "+this.type+")");};d.prototype.encode=function(a,b){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 b;try{if(this.repeated){var d;if(this.options.packed){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,
k=p.calculateVarint32(f);if(1<k){var h=b.slice(e,b.offset),e=e+(k-1);b.offset=e;b.append(h)}b.writeVarint32(f,e-k)}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<<3|this.type.wireType),this.encodeValue(a,b)}catch(l){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+l+")");}return b};d.prototype.encodeValue=function(a,b){if(null!==a){if(this.type==c.TYPES.int32||this.type==c.TYPES.uint32)b.writeVarint32(a);
else if(this.type==c.TYPES.sint32)b.writeZigZagVarint32(a);else if(this.type==c.TYPES.fixed32)b.writeUint32(a);else if(this.type==c.TYPES.sfixed32)b.writeInt32(a);else if(this.type==c.TYPES.int64||this.type==c.TYPES.uint64)b.writeVarint64(a);else if(this.type==c.TYPES.sint64)b.writeZigZagVarint64(a);else if(this.type==c.TYPES.fixed64)b.writeUint64(a);else if(this.type==c.TYPES.sfixed64)b.writeInt64(a);else if(this.type==c.TYPES.bool)b.writeVarint32(a?1:0);else if(this.type==c.TYPES["enum"])b.writeVarint32(a);
else if(this.type==c.TYPES["float"])b.writeFloat32(a);else if(this.type==c.TYPES["double"])b.writeFloat64(a);else if(this.type==c.TYPES.string)b.writeVString(a);else if(this.type==c.TYPES.bytes)a.offset>a.length&&(b=b.clone().flip()),b.writeVarint32(a.remaining()),b.append(a);else if(this.type==c.TYPES.message){var d=(new p).LE();this.resolvedType.encode(a,d);b.writeVarint32(d.offset);b.append(d.flip())}else throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");
return b}};d.prototype.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)+": "+a+" ("+this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&(this.repeated&&this.options.packed)&&!d){a=b.readVarint32();a=b.offset+a;for(d=[];b.offset<a;)d.push(this.decode(this.type.wireType,b,!0));return d}if(this.type==c.TYPES.int32)return b.readVarint32()|0;if(this.type==c.TYPES.uint32)return b.readVarint32()>>>
0;if(this.type==c.TYPES.sint32)return b.readZigZagVarint32()|0;if(this.type==c.TYPES.fixed32)return b.readUint32()>>>0;if(this.type==c.TYPES.sfixed32)return b.readInt32()|0;if(this.type==c.TYPES.int64)return b.readVarint64();if(this.type==c.TYPES.uint64)return b.readVarint64().toUnsigned();if(this.type==c.TYPES.sint64)return b.readZigZagVarint64();if(this.type==c.TYPES.fixed64)return b.readUint64();if(this.type==c.TYPES.sfixed64)return b.readInt64();if(this.type==c.TYPES.bool)return!!b.readVarint32();
if(this.type==c.TYPES["enum"])return b.readVarint32();if(this.type==c.TYPES["float"])return b.readFloat();if(this.type==c.TYPES["double"])return b.readDouble();if(this.type==c.TYPES.string)return b.readVString();if(this.type==c.TYPES.bytes){a=b.readVarint32();if(b.remaining()<a)throw Error("Prematurely terminated bytes: at least "+a+" are required but only "+b.remaining()+" are available");d=b.clone();d.length=d.offset+a;b.offset+=a;return d}if(this.type==c.TYPES.message)return a=b.readVarint32(),
this.resolvedType.decode(b,a);throw Error("[INTERNAL] Illegal wire type for "+this.toString(!0)+": "+a);};b.Message.Field=d;var e=function(a,b,c){f.call(this,a,b,c);this.object=null};e.prototype=Object.create(f.prototype);e.prototype.build=function(){for(var a={},b=this.getChildren(e.Value),c=0;c<b.length;c++)a[b[c].name]=b[c].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1,configurable:!1,writable:!1});return this.object=a};b.Enum=e;d=function(a,
b,c){h.call(this,a,b);this.id=c};d.prototype=Object.create(h.prototype);b.Enum.Value=d;var k=function(a,b,c){f.call(this,a,b,c);this.clazz=null};k.prototype=Object.create(f.prototype);k.prototype.build=function(){return this.clazz=function(a){var d;try{d=eval("0, (function "+a.name+"() { ProtoBuf.Builder.Service.call(this); this.__construct.apply(this, arguments); })")}catch(e){d=function(){c.Builder.Service.call(this);this.__construct.apply(this,arguments)}}d.prototype=Object.create(c.Builder.Service.prototype);
d.prototype.__construct=function(a){this.rpcImpl=a||function(a,b,c){setTimeout(c.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}};Object.defineProperty&&(Object.defineProperty(d,"$options",{value:a.buildOpt(),enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(d.prototype,"$options",{value:d.$options,enumerable:!1,configurable:!1,writable:!1}));for(var f=a.getChildren(b.Service.RPCMethod),k=0;k<f.length;k++)(function(b){d.prototype[b.name]=
function(c,d){try{c&&c instanceof b.resolvedRequestType.clazz||setTimeout(d.bind(this,Error("Illegal request type provided to service method "+a.name+"#"+b.name))),this.rpcImpl(b.name,c,function(c,e){if(c)d(c);else{try{e=b.resolvedResponseType.clazz.decode(e)}catch(f){}e&&e instanceof b.resolvedResponseType.clazz?d(null,e):d(Error("Illegal response type received in service method "+a.name+"#"+b.name))}})}catch(e){setTimeout(d.bind(this,e),0)}};d[b.name]=function(a,c,e){(new d(a))[b.name](c,e)};Object.defineProperty&&
(Object.defineProperty(d[b.name],"$options",{value:b.buildOpt(),enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(d.prototype[b.name],"$options",{value:d[b.name].$options,enumerable:!1,configurable:!1,writable:!1}))})(f[k]);return d}(this)};b.Service=k;var n=function(a,b,c){h.call(this,a,b);this.options=c||{}};n.prototype=Object.create(h.prototype);n.prototype.buildOpt=f.prototype.buildOpt;b.Service.Method=n;d=function(a,b,c,d,e){n.call(this,a,b,e);this.requestName=c;this.responseName=
d;this.resolvedResponseType=this.resolvedRequestType=null};d.prototype=Object.create(n.prototype);b.Service.RPCMethod=d;return b}(h);h.Builder=function(c,b,h){var f=function(){this.ptr=this.ns=new h.Namespace(null,"");this.resolved=!1;this.result=null;this.files={}};f.prototype.reset=function(){this.ptr=this.ns};f.prototype.define=function(a,c){if("string"!=typeof a||!b.TYPEDEF.test(a))throw Error("Illegal package name: "+a);var e=a.split("."),f;for(f=0;f<e.length;f++)if(!b.NAME.test(e[f]))throw Error("Illegal package name: "+
e[f]);for(f=0;f<e.length;f++)this.ptr.hasChild(e[f])||this.ptr.addChild(new h.Namespace(this.ptr,e[f],c)),this.ptr=this.ptr.getChild(e[f]);return this};f.isValidMessage=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"!=typeof a.values||"undefined"!=typeof a.rpc)return!1;var d;if("undefined"!=typeof a.fields){if(!c.Util.isArray(a.fields))return!1;var e=[],h;for(d=0;d<a.fields.length;d++){if(!f.isValidMessageField(a.fields[d]))return!1;h=parseInt(a.id,10);if(0<=e.indexOf(h))return!1;
e.push(h)}}if("undefined"!=typeof a.enums){if(!c.Util.isArray(a.enums))return!1;for(d=0;d<a.enums.length;d++)if(!f.isValidEnum(a.enums[d]))return!1}if("undefined"!=typeof a.messages){if(!c.Util.isArray(a.messages))return!1;for(d=0;d<a.messages.length;d++)if(!f.isValidMessage(a.messages[d]))return!1}return!0};f.isValidMessageField=function(a){if("string"!=typeof a.rule||("string"!=typeof a.name||"string"!=typeof a.type||"undefined"==typeof a.id)||!(b.RULE.test(a.rule)&&b.NAME.test(a.name)&&b.TYPEREF.test(a.type)&&
b.ID.test(""+a.id)))return!1;if("undefined"!=typeof a.options){if("object"!=typeof a.options)return!1;for(var c=Object.keys(a.options),e=0;e<c.length;e++)if(!b.NAME.test(c[e])||"string"!=typeof a.options[c[e]]&&"number"!=typeof a.options[c[e]])return!1}return!0};f.isValidEnum=function(a){if("string"!=typeof a.name||!b.NAME.test(a.name)||"undefined"==typeof a.values||!c.Util.isArray(a.values)||0==a.values.length)return!1;for(var d=0;d<a.values.length;d++)if("object"!=typeof a.values[d]||"string"!=
typeof a.values[d].name||"undefined"==typeof a.values[d].id||!b.NAME.test(a.values[d].name)||!b.NEGID.test(""+a.values[d].id))return!1;return!0};f.prototype.create=function(a){if(a&&(c.Util.isArray(a)||(a=[a]),0!=a.length)){var d=[],e,k,n,g,m;for(d.push(a);0<d.length;){a=d.pop();if(c.Util.isArray(a))for(;0<a.length;)if(e=a.shift(),f.isValidMessage(e)){k=new h.Message(this.ptr,e.name,e.options);if(e.fields&&0<e.fields.length)for(g=0;g<e.fields.length;g++){if(!f.isValidMessageField(e.fields[g]))throw Error("Not a valid message field definition in message "+
k.name+": "+JSON.stringify(e.fields[g]));if(k.hasChild(e.fields[g].id))throw Error("Duplicate field id in message "+k.name+": "+e.fields[g].id);if(e.fields[g].options)for(n=Object.keys(e.fields[g].options),m=0;m<n.length;m++){if(!b.NAME.test(n[m]))throw Error("Illegal field option name in message "+k.name+"#"+e.fields[g].name+": "+n[m]);if("string"!=typeof e.fields[g].options[n[m]]&&"number"!=typeof e.fields[g].options[n[m]])throw Error("Illegal field option value in message "+k.name+"#"+e.fields[g].name+
"#"+n[m]+": "+e.fields[g].options[n[m]]);}k.addChild(new h.Message.Field(k,e.fields[g].rule,e.fields[g].type,e.fields[g].name,e.fields[g].id,e.fields[g].options))}n=[];if("undefined"!=typeof e.enums&&0<e.enums.length)for(g=0;g<e.enums.length;g++)n.push(e.enums[g]);if(e.messages&&0<e.messages.length)for(g=0;g<e.messages.length;g++)n.push(e.messages[g]);this.ptr.addChild(k);0<n.length&&(d.push(a),a=n,this.ptr=k)}else if(f.isValidEnum(e)){k=new h.Enum(this.ptr,e.name,e.options);for(g=0;g<e.values.length;g++)k.addChild(new h.Enum.Value(k,
e.values[g].name,e.values[g].id));this.ptr.addChild(k)}else if(f.isValidService(e)){k=new h.Service(this.ptr,e.name,e.options);for(g in e.rpc)e.rpc.hasOwnProperty(g)&&k.addChild(new h.Service.RPCMethod(k,g,e.rpc[g].request,e.rpc[g].response,e.rpc[g].options));this.ptr.addChild(k)}else throw Error("Not a valid message, enum or service definition: "+JSON.stringify(e));else throw Error("Not a valid namespace definition: "+JSON.stringify(a));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;
return this}};f.isValidImport=function(a){return!/google\/protobuf\//.test(a)};f.prototype["import"]=function(a,b){if("string"===typeof b){c.Util.IS_NODE&&(b=require("path").resolve(b));if(this.files[b])return this.reset(),this;this.files[b]=!0}a.messages&&(a["package"]&&this.define(a["package"],a.options),this.create(a.messages),this.reset());a.enums&&(a["package"]&&this.define(a["package"],a.options),this.create(a.enums),this.reset());a.services&&(a["package"]&&this.define(a["package"],a.options),
this.create(a.services),this.reset());if(a.imports&&0<a.imports.length){if(!b)throw Error("Cannot determine import root: File name is unknown");for(var e=b.replace(/[\/\\][^\/\\]*$/,""),h=0;h<a.imports.length;h++){var l=e+"/"+a.imports[h];if(/\.json$/i.test(l)){var g=c.Util.fetch(l);if(null===g)throw Error("Failed to import '"+l+"' in '"+b+"': File not found");this["import"](JSON.parse(g),l)}else if(f.isValidImport(l)){g=c.Util.fetch(l);if(null===g)throw Error("Failed to import '"+l+"' in '"+b+"': File not found");
g=new c.DotProto.Parser(g+"");this["import"](g.parse(),l)}}}return this};f.isValidService=function(a){return"string"==typeof a.name&&b.NAME.test(a.name)&&"object"==typeof a.rpc?!0:!1};f.prototype.resolveAll=function(){var a;if(null!=this.ptr&&"object"!=typeof this.ptr.type){if(this.ptr instanceof h.Namespace){a=this.ptr.getChildren();for(var d=0;d<a.length;d++)this.ptr=a[d],this.resolveAll()}else if(this.ptr instanceof h.Message.Field)if(b.TYPE.test(this.ptr.type))this.ptr.type=c.TYPES[this.ptr.type];
else{if(!b.TYPEREF.test(this.ptr.type))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);a=this.ptr.parent.resolve(this.ptr.type);if(!a)throw Error("Unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=a;if(a instanceof h.Enum)this.ptr.type=c.TYPES["enum"];else if(a instanceof h.Message)this.ptr.type=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){a=this.ptr.parent.resolve(this.ptr.requestName);if(!(a&&a instanceof c.Reflect.Message))throw Error("Illegal request type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=a;a=this.ptr.parent.resolve(this.ptr.responseName);if(!(a&&a instanceof c.Reflect.Message))throw Error("Illegal response type reference in "+this.ptr.toString(!0)+": "+
this.ptr.responseName);this.ptr.resolvedResponseType=a}else throw Error("Illegal service method type in "+this.ptr.toString(!0));else throw Error("Illegal object type in namespace: "+typeof this.ptr+":"+this.ptr);this.reset()}};f.prototype.build=function(a){this.reset();this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null);null==this.result&&(this.result=this.ns.build());if(a){a=a.split(".");for(var b=this.result,c=0;c<a.length;c++)if(b[a[c]])b=b[a[c]];else{b=null;break}return b}return this.result};
f.prototype.lookup=function(a){return a?this.ns.resolve(a):this.ns};f.prototype.toString=function(){return"Builder"};f.Message=function(){};f.Service=function(){};return f}(h,h.Lang,h.Reflect);h.protoFromString=function(c,b,l){"string"==typeof b&&(l=b,b=null);c=(new h.DotProto.Parser(c+"")).parse();b="object"==typeof b?b:new h.Builder;0<c.messages.length&&(null!==c["package"]&&b.define(c["package"],c.options),b.create(c.messages),b.reset());0<c.enums.length&&(null!==c["package"]&&b.define(c["package"],
c.options),b.create(c.enums),b.reset());0<c.services.length&&(null!==c["package"]&&b.define(c["package"],c.options),b.create(c.services),b.reset());if(l&&0<c.imports.length)b["import"]({imports:c.imports},l);b.resolveAll();b.build();return b};h.protoFromFile=function(c,b,l){b&&"object"==typeof b?(l=b,b=null):b&&"function"==typeof b||(b=null);if(b)h.Util.fetch(c,function(a){b(h.protoFromString(a,l,c))});else{var f=h.Util.fetch(c);return null!==f?h.protoFromString(f,l,c):null}};h.newBuilder=function(c,
b){var l=new h.Builder;"undefined"!=typeof c&&l.define(c,b);return l};return h}"undefined"!=typeof module&&module.exports?module.exports=s(require("bytebuffer")):"undefined"!=typeof define&&define.amd?define("ProtoBuf",["ByteBuffer"],s):(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ProtoBuf=s(r.dcodeIO.ByteBuffer))})(this);