UNPKG

dota2-fork

Version:

A node-steam plugin for Dota 2. Fork with fresh updates

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