pomelo-cocos2d-js
Version:
pomelo-cocos2d-js client
2 lines • 44.2 kB
JavaScript
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a){function b(){return"undefined"!=typeof cc&&cc&&cc.sys&&cc.sys.isNative?!0:!1}var c,d=a("util");if(function(){c=this}(),b()){var e=cc;c.console=e,cc.formatStr=d.format}var f=a("events").EventEmitter;c.EventEmitter=f;var g=a("pomelo-protobuf");c.protobuf=g;var h=a("pomelo-protocol");c.Protocol=h;var i=a("pomelo-jsclient-websocket");c.pomelo=i},{events:6,"pomelo-jsclient-websocket":11,"pomelo-protobuf":17,"pomelo-protocol":19,util:10}],2:[function(a,b,c){function d(a,b){var c=this;if(!(c instanceof d))return new d(a,b);var e,f=typeof a;if("number"===f)e=+a;else if("string"===f)e=d.byteLength(a,b);else{if("object"!==f||null===a)throw new TypeError("must start with number, buffer, array or string");"Buffer"===a.type&&K(a.data)&&(a=a.data),e=+a.length}if(e>L)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+L.toString(16)+" bytes");0>e?e=0:e>>>=0,d.TYPED_ARRAY_SUPPORT?c=d._augment(new Uint8Array(e)):(c.length=e,c._isBuffer=!0);var g;if(d.TYPED_ARRAY_SUPPORT&&"number"==typeof a.byteLength)c._set(a);else if(A(a))if(d.isBuffer(a))for(g=0;e>g;g++)c[g]=a.readUInt8(g);else for(g=0;e>g;g++)c[g]=(a[g]%256+256)%256;else if("string"===f)c.write(a,0,b);else if("number"===f&&!d.TYPED_ARRAY_SUPPORT)for(g=0;e>g;g++)c[g]=0;return e>0&&e<=d.poolSize&&(c.parent=M),c}function e(a,b){if(!(this instanceof e))return new e(a,b);var c=new d(a,b);return delete c.parent,c}function f(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function g(a,b,c,d){var e=G(C(b,a.length-c),a,c,d);return e}function h(a,b,c,d){var e=G(D(b),a,c,d);return e}function i(a,b,c,d){return h(a,b,c,d)}function j(a,b,c,d){var e=G(F(b),a,c,d);return e}function k(a,b,c,d){var e=G(E(b,a.length-c),a,c,d);return e}function l(a,b,c){return I.fromByteArray(0===b&&c===a.length?a:a.slice(b,c))}function m(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=H(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+H(e)}function n(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function o(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function p(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=B(a[f]);return e}function q(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function r(a,b,c){if(a%1!==0||0>a)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function s(a,b,c,e,f,g){if(!d.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>f||g>b)throw new RangeError("value is out of bounds");if(c+e>a.length)throw new RangeError("index out of range")}function t(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function u(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function v(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function w(a,b,c,d,e){return e||v(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(a,b,c,d,23,4),c+4}function x(a,b,c,d,e){return e||v(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(a,b,c,d,52,8),c+8}function y(a){if(a=z(a).replace(O,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function z(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function A(a){return K(a)||d.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function B(a){return 16>a?"0"+a.toString(16):a.toString(16)}function C(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=e-55296<<10|c-56320|65536,e=null}else e&&((b-=3)>-1&&f.push(239,191,189),e=null);if(128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(2097152>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function D(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function E(a,b){for(var c,d,e,f=[],g=0;g<a.length&&!((b-=2)<0);g++)c=a.charCodeAt(g),d=c>>8,e=c%256,f.push(e),f.push(d);return f}function F(a){return I.toByteArray(y(a))}function G(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function H(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}var I=a("base64-js"),J=a("ieee754"),K=a("is-array");c.Buffer=d,c.SlowBuffer=e,c.INSPECT_MAX_BYTES=50,d.poolSize=8192;var L=1073741823,M={};d.TYPED_ARRAY_SUPPORT=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(c){return!1}}(),d.isBuffer=function(a){return!(null==a||!a._isBuffer)},d.compare=function(a,b){if(!d.isBuffer(a)||!d.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,e=b.length,f=0,g=Math.min(c,e);g>f&&a[f]===b[f];f++);return f!==g&&(c=a[f],e=b[f]),e>c?-1:c>e?1:0},d.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(a,b){if(!K(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new d(0);if(1===a.length)return a[0];var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var e=new d(b),f=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(e,f),f+=g.length}return e},d.byteLength=function(a,b){var c;switch(a+="",b||"utf8"){case"ascii":case"binary":case"raw":c=a.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":c=2*a.length;break;case"hex":c=a.length>>>1;break;case"utf8":case"utf-8":c=C(a).length;break;case"base64":c=F(a).length;break;default:c=a.length}return c},d.prototype.length=void 0,d.prototype.parent=void 0,d.prototype.toString=function(a,b,c){var d=!1;if(b>>>=0,c=void 0===c||c===1/0?this.length:c>>>0,a||(a="utf8"),0>b&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return p(this,b,c);case"utf8":case"utf-8":return m(this,b,c);case"ascii":return n(this,b,c);case"binary":return o(this,b,c);case"base64":return l(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}},d.prototype.equals=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:0===d.compare(this,a)},d.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),"<Buffer "+a+">"},d.prototype.compare=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:d.compare(this,a)},d.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e<a.length;e++)if(a[c+e]===b[-1===d?0:e-d]){if(-1===d&&(d=e),e-d+1===b.length)return c+d}else d=-1;return-1}if(b>2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(d.isBuffer(a))return c(this,a,b);if("number"==typeof a)return d.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},d.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},d.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},d.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}if(b=Number(b)||0,0>c||0>b||b>this.length)throw new RangeError("attempt to write outside buffer bounds");var l=this.length-b;c?(c=Number(c),c>l&&(c=l)):c=l,d=String(d||"utf8").toLowerCase();var m;switch(d){case"hex":m=f(this,a,b,c);break;case"utf8":case"utf-8":m=g(this,a,b,c);break;case"ascii":m=h(this,a,b,c);break;case"binary":m=i(this,a,b,c);break;case"base64":m=j(this,a,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":m=k(this,a,b,c);break;default:throw new TypeError("Unknown encoding: "+d)}return m},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var e;if(d.TYPED_ARRAY_SUPPORT)e=d._augment(this.subarray(a,b));else{var f=b-a;e=new d(f,void 0);for(var g=0;f>g;g++)e[g]=this[g+a]}return e.length&&(e.parent=this.parent||this),e},d.prototype.readUIntLE=function(a,b,c){a>>>=0,b>>>=0,c||r(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return d},d.prototype.readUIntBE=function(a,b,c){a>>>=0,b>>>=0,c||r(a,b,this.length);for(var d=this[a+--b],e=1;b>0&&(e*=256);)d+=this[a+--b]*e;return d},d.prototype.readUInt8=function(a,b){return b||r(a,1,this.length),this[a]},d.prototype.readUInt16LE=function(a,b){return b||r(a,2,this.length),this[a]|this[a+1]<<8},d.prototype.readUInt16BE=function(a,b){return b||r(a,2,this.length),this[a]<<8|this[a+1]},d.prototype.readUInt32LE=function(a,b){return b||r(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},d.prototype.readUInt32BE=function(a,b){return b||r(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},d.prototype.readIntLE=function(a,b,c){a>>>=0,b>>>=0,c||r(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return e*=128,d>=e&&(d-=Math.pow(2,8*b)),d},d.prototype.readIntBE=function(a,b,c){a>>>=0,b>>>=0,c||r(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},d.prototype.readInt8=function(a,b){return b||r(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},d.prototype.readInt16LE=function(a,b){b||r(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt16BE=function(a,b){b||r(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt32LE=function(a,b){return b||r(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},d.prototype.readInt32BE=function(a,b){return b||r(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},d.prototype.readFloatLE=function(a,b){return b||r(a,4,this.length),J.read(this,a,!0,23,4)},d.prototype.readFloatBE=function(a,b){return b||r(a,4,this.length),J.read(this,a,!1,23,4)},d.prototype.readDoubleLE=function(a,b){return b||r(a,8,this.length),J.read(this,a,!0,52,8)},d.prototype.readDoubleBE=function(a,b){return b||r(a,8,this.length),J.read(this,a,!1,52,8)},d.prototype.writeUIntLE=function(a,b,c,d){a=+a,b>>>=0,c>>>=0,d||s(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f<c&&(e*=256);)this[b+f]=a/e>>>0&255;return b+c},d.prototype.writeUIntBE=function(a,b,c,d){a=+a,b>>>=0,c>>>=0,d||s(this,a,b,c,Math.pow(2,8*c),0);var e=c-1,f=1;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=a/f>>>0&255;return b+c},d.prototype.writeUInt8=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,1,255,0),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=a,b+1},d.prototype.writeUInt16LE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):t(this,a,b,!0),b+2},d.prototype.writeUInt16BE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):t(this,a,b,!1),b+2},d.prototype.writeUInt32LE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=a):u(this,a,b,!0),b+4},d.prototype.writeUInt32BE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):u(this,a,b,!1),b+4},d.prototype.writeIntLE=function(a,b,c,d){a=+a,b>>>=0,d||s(this,a,b,c,Math.pow(2,8*c-1)-1,-Math.pow(2,8*c-1));var e=0,f=1,g=0>a?1:0;for(this[b]=255&a;++e<c&&(f*=256);)this[b+e]=(a/f>>0)-g&255;return b+c},d.prototype.writeIntBE=function(a,b,c,d){a=+a,b>>>=0,d||s(this,a,b,c,Math.pow(2,8*c-1)-1,-Math.pow(2,8*c-1));var e=c-1,f=1,g=0>a?1:0;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=(a/f>>0)-g&255;return b+c},d.prototype.writeInt8=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,1,127,-128),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=a,b+1},d.prototype.writeInt16LE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):t(this,a,b,!0),b+2},d.prototype.writeInt16BE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):t(this,a,b,!1),b+2},d.prototype.writeInt32LE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):u(this,a,b,!0),b+4},d.prototype.writeInt32BE=function(a,b,c){return a=+a,b>>>=0,c||s(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):u(this,a,b,!1),b+4},d.prototype.writeFloatLE=function(a,b,c){return w(this,a,b,!0,c)},d.prototype.writeFloatBE=function(a,b,c){return w(this,a,b,!1,c)},d.prototype.writeDoubleLE=function(a,b,c){return x(this,a,b,!0,c)},d.prototype.writeDoubleBE=function(a,b,c){return x(this,a,b,!1,c)},d.prototype.copy=function(a,b,c,e){if(c||(c=0),e||0===e||(e=this.length),b>=a.length&&(b=a.length),b||(b=0),e>0&&c>e&&(e=c),e===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>e)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),a.length-b<e-c&&(e=a.length-b+c);var f=e-c;if(1e3>f||!d.TYPED_ARRAY_SUPPORT)for(var g=0;f>g;g++)a[g+b]=this[g+c];else a._set(this.subarray(c,c+f),b);return f},d.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=C(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},d.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(d.TYPED_ARRAY_SUPPORT)return new d(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var N=d.prototype;d._augment=function(a){return a.constructor=d,a._isBuffer=!0,a._set=a.set,a.get=N.get,a.set=N.set,a.write=N.write,a.toString=N.toString,a.toLocaleString=N.toString,a.toJSON=N.toJSON,a.equals=N.equals,a.compare=N.compare,a.indexOf=N.indexOf,a.copy=N.copy,a.slice=N.slice,a.readUIntLE=N.readUIntLE,a.readUIntBE=N.readUIntBE,a.readUInt8=N.readUInt8,a.readUInt16LE=N.readUInt16LE,a.readUInt16BE=N.readUInt16BE,a.readUInt32LE=N.readUInt32LE,a.readUInt32BE=N.readUInt32BE,a.readIntLE=N.readIntLE,a.readIntBE=N.readIntBE,a.readInt8=N.readInt8,a.readInt16LE=N.readInt16LE,a.readInt16BE=N.readInt16BE,a.readInt32LE=N.readInt32LE,a.readInt32BE=N.readInt32BE,a.readFloatLE=N.readFloatLE,a.readFloatBE=N.readFloatBE,a.readDoubleLE=N.readDoubleLE,a.readDoubleBE=N.readDoubleBE,a.writeUInt8=N.writeUInt8,a.writeUIntLE=N.writeUIntLE,a.writeUIntBE=N.writeUIntBE,a.writeUInt16LE=N.writeUInt16LE,a.writeUInt16BE=N.writeUInt16BE,a.writeUInt32LE=N.writeUInt32LE,a.writeUInt32BE=N.writeUInt32BE,a.writeIntLE=N.writeIntLE,a.writeIntBE=N.writeIntBE,a.writeInt8=N.writeInt8,a.writeInt16LE=N.writeInt16LE,a.writeInt16BE=N.writeInt16BE,a.writeInt32LE=N.writeInt32LE,a.writeInt32BE=N.writeInt32BE,a.writeFloatLE=N.writeFloatLE,a.writeFloatBE=N.writeFloatBE,a.writeDoubleLE=N.writeDoubleLE,a.writeDoubleBE=N.writeDoubleBE,a.fill=N.fill,a.inspect=N.inspect,a.toArrayBuffer=N.toArrayBuffer,a};var O=/[^+\/0-9A-z\-]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],4:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],5:[function(a,b){var c=Array.isArray,d=Object.prototype.toString;b.exports=c||function(a){return!!a&&"[object Array]"==d.call(a)}},{}],6:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],7:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],8:[function(a,b){function c(){if(!g){g=!0;for(var a,b=f.length;b;){a=f,f=[];for(var c=-1;++c<b;)a[c]();b=f.length}g=!1}}function d(){}var e=b.exports={},f=[],g=!1;e.nextTick=function(a){f.push(a),g||setTimeout(c,0)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},{}],9:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],10:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c<arguments.length;c++)b.push(e(arguments[c]));return b.join(" ")}for(var c=1,d=arguments,f=d.length,g=String(a).replace(G,function(a){if("%%"===a)return"%";if(c>=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":9,_process:8,inherits:7}],11:[function(a,b){!function(){var a="js-websocket",c="0.0.1",d=window.Protocol,e=window.protobuf,f=window.decodeIO_protobuf,g=null,h=null,i=d.Package,j=d.Message,k=window.EventEmitter,l=window.rsa;"undefined"!=typeof window&&"undefined"!=typeof sys&&sys.localStorage&&(window.localStorage=sys.localStorage);var m=200,n=501;"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b});var o=window,p=Object.create(k.prototype);o.pomelo=p;var q,r=null,s=0,t={},u={},v={},w={},x={},y={},z={},A=0,B=0,C=0,D=0,E=100,F=null,G=null,H=null,I=null,J=null,K=!1,L=null,M=null,N=0,O=5e3,P=10,Q={sys:{type:a,version:c,rsa:{}},user:{}},R=null;p.init=function(a,b){R=b;var c=a.host,d=a.port;J=a.encode||T,I=a.decode||S;var e="ws://"+c;if(d&&(e+=":"+d),Q.user=a.user,a.encrypt){q=!0,l.generate(1024,"10001");var f={rsa_n:l.n.toString(16),rsa_e:l.e};Q.sys.rsa=f}H=a.handshakeCallback,U(a,e,b)};var S=p.decode=function(a){var b=j.decode(a);if(!(b.id>0)||(b.route=v[b.id],delete v[b.id],
b.route))return b.body=da(b),b},T=p.encode=function(a,b,c){var f=a?j.TYPE_REQUEST:j.TYPE_NOTIFY;if(e&&z[b])c=e.encode(b,c);else if(g&&g.lookup(b)){var h=g.build(b);c=new h(c).encodeNB()}else c=d.strencode(JSON.stringify(c));var i=0;return w&&w[b]&&(b=w[b],i=1),j.encode(a,f,i,b,c)},U=function(a,b,c){console.log("connect to "+b);var a=a||{},j=a.maxReconnectAttempts||P;if(M=b,window.localStorage&&window.localStorage.getItem("protos")&&0===A){var k=JSON.parse(window.localStorage.getItem("protos"));A=k.version||0,y=k.server||{},z=k.client||{},e&&e.init({encoderProtos:z,decoderProtos:y}),f&&(g=f.loadJson(z),h=f.loadJson(y))}Q.sys.protoVersion=A;var l=function(){K&&p.emit("reconnect"),V();var a=i.encode(i.TYPE_HANDSHAKE,d.strencode(JSON.stringify(Q)));X(a)},m=function(a){ba(i.decode(a.data),c),C&&(D=Date.now()+C)},n=function(a){p.emit("io-error",a),console.error("socket error: ",a)},o=function(b){p.emit("close",b),p.emit("disconnect",b),console.error("socket close: ",b),a.reconnect&&j>N&&(K=!0,N++,L=setTimeout(function(){U(a,M,c)},O),O*=2)};r=new WebSocket(b),r.binaryType="arraybuffer",r.onopen=l,r.onmessage=m,r.onerror=n,r.onclose=o};p.disconnect=function(){r&&(r.disconnect&&r.disconnect(),r.close&&r.close(),console.log("disconnect"),r=null),F&&(clearTimeout(F),F=null),G&&(clearTimeout(G),G=null)};var V=function(){K=!1,O=5e3,N=0,clearTimeout(L)};p.request=function(a,b,c){2===arguments.length&&"function"==typeof b?(c=b,b={}):b=b||{},a=a||b.route,a&&(s++,W(s,a,b),t[s]=c,v[s]=a)},p.notify=function(a,b){b=b||{},W(0,a,b)};var W=function(a,b,c){if(q){c=JSON.stringify(c);var d=l.signString(c,"sha256");c=JSON.parse(c),c.__crypto__=d}J&&(c=J(a,b,c));var e=i.encode(i.TYPE_DATA,c);X(e)},X=function(a){r&&r.send(a.buffer)},Y=function(){if(B){var a=i.encode(i.TYPE_HEARTBEAT);G&&(clearTimeout(G),G=null),F||(F=setTimeout(function(){F=null,X(a),D=Date.now()+C,G=setTimeout(Z,C)},B))}},Z=function(){var a=D-Date.now();a>E?G=setTimeout(Z,a):(console.error("server heartbeat timeout"),p.emit("heartbeat timeout"),p.disconnect())},$=function(a){if(a=JSON.parse(d.strdecode(a)),a.code===n)return void p.emit("error","client version not fullfill");if(a.code!==m)return void p.emit("error","handshake fail");ea(a);var b=i.encode(i.TYPE_HANDSHAKE_ACK);X(b),R&&R(r)},_=function(a){var b=a;I&&(b=I(b)),ca(p,b)},aa=function(a){a=JSON.parse(d.strdecode(a)),p.emit("onKick",a)};u[i.TYPE_HANDSHAKE]=$,u[i.TYPE_HEARTBEAT]=Y,u[i.TYPE_DATA]=_,u[i.TYPE_KICK]=aa;var ba=function(a){if(Array.isArray(a))for(var b=0;b<a.length;b++){var c=a[b];u[c.type](c.body)}else u[a.type](a.body)},ca=function(a,b){if(!b.id)return void a.emit(b.route,b.body);var c=t[b.id];delete t[b.id],"function"==typeof c&&c(b.body)},da=function(a){var b=a.route;if(a.compressRoute){if(!x[b])return{};b=a.route=x[b]}return e&&y[b]?e.decodeStr(b,a.body):h&&h.lookup(b)?h.build(b).decode(a.body):JSON.parse(d.strdecode(a.body))},ea=function(a){a.sys&&a.sys.heartbeat?(B=1e3*a.sys.heartbeat,C=2*B):(B=0,C=0),fa(a),"function"==typeof H&&H(a.user)},fa=function(a){if(a&&a.sys){w=a.sys.dict;var b=a.sys.protos;if(w){w=w,x={};for(var c in w)x[w[c]]=c}b&&(A=b.version||0,y=b.server||{},z=b.client||{},window.localStorage.setItem("protos",JSON.stringify(b)),e&&e.init({encoderProtos:b.client,decoderProtos:b.server}),f&&(g=f.loadJson(z),h=f.loadJson(y)))}};b.exports=p}()},{}],12:[function(a,b){var c=b.exports;c.encodeUInt32=function(a){var b=parseInt(a);if(isNaN(b)||0>b)return console.log(b),null;var c=[];do{var d=b%128,e=Math.floor(b/128);0!==e&&(d+=128),c.push(d),b=e}while(0!==b);return c},c.encodeSInt32=function(a){var b=parseInt(a);return isNaN(b)?null:(b=0>b?2*Math.abs(b)-1:2*b,c.encodeUInt32(b))},c.decodeUInt32=function(a){for(var b=0,c=0;c<a.length;c++){var d=parseInt(a[c]);if(b+=(127&d)*Math.pow(2,7*c),128>d)return b}return b},c.decodeSInt32=function(a){var b=this.decodeUInt32(a),c=b%2===1?-1:1;return b=(b%2+b)/2*c}},{}],13:[function(a,b){b.exports={TYPES:{uInt32:0,sInt32:0,int32:0,"double":1,string:2,message:2,"float":5}}},{}],14:[function(a,b){function c(a,b,c){for(;c>l;){var g=d(),h=(g.type,g.tag),i=b.__tags[h];switch(b[i].option){case"optional":case"required":a[i]=e(b[i].type,b);break;case"repeated":a[i]||(a[i]=[]),f(a[i],b[i].type,b)}}return a}function d(){var a=i.decodeUInt32(g());return{type:7&a,tag:a>>3}}function e(a,b){switch(a){case"uInt32":return i.decodeUInt32(g());case"int32":case"sInt32":return i.decodeSInt32(g());case"float":var d=h.readFloatLE(l);return l+=4,d;case"double":var e=h.readDoubleLE(l);return l+=8,e;case"string":var f=i.decodeUInt32(g()),j=h.toString("utf8",l,l+f);return l+=f,j;default:var m=b&&(b.__messages[a]||k.protos["message "+a]);if(m){var f=i.decodeUInt32(g()),n={};return c(n,m,l+f),n}}}function f(a,b,c){if(j.isSimpleType(b))for(var d=i.decodeUInt32(g()),f=0;d>f;f++)a.push(e(b));else a.push(e(b,c))}function g(a){var b=[],c=l;a=a||!1;var d;do{var d=h.readUInt8(c);b.push(d),c++}while(d>=128);return a||(l=c),b}var h,i=a("./codec"),j=a("./util"),k=b.exports,l=0;k.init=function(a){this.protos=a||{}},k.setProtos=function(a){a&&(this.protos=a)},k.decode=function(a,b){var d=this.protos[a];return h=b,l=0,d?c({},d,h.length):null}},{"./codec":12,"./util":18}],15:[function(a,b){(function(c){function d(a,b){if(!b||!a)return console.warn("no protos or msg exist! msg : %j, protos : %j",a,b),!1;for(var c in b){var e=b[c];switch(e.option){case"required":if("undefined"==typeof a[c])return console.warn("no property exist for required! name: %j, proto: %j, msg: %j",c,e,a),!1;case"optional":if("undefined"!=typeof a[c]){var f=b.__messages[e.type]||m.protos["message "+e.type];if(f&&!d(a[c],f))return console.warn("inner proto error! name: %j, proto: %j, msg: %j",c,e,a),!1}break;case"repeated":var f=b.__messages[e.type]||m.protos["message "+e.type];if(a[c]&&f)for(var g=0;g<a[c].length;g++)if(!d(a[c][g],f))return!1}}return!0}function e(a,b,c,d){for(var e in d)if(c[e]){var j=c[e];switch(j.option){case"required":case"optional":b=h(a,b,i(j.type,j.tag)),b=f(d[e],j.type,b,a,c);break;case"repeated":d[e]&&d[e].length>0&&(b=g(d[e],j,b,a,c))}}return b}function f(a,b,d,f,g){var i=0;switch(b){case"uInt32":d=h(f,d,j.encodeUInt32(a));break;case"int32":case"sInt32":d=h(f,d,j.encodeSInt32(a));break;case"float":f.writeFloatLE(a,d),d+=4;break;case"double":f.writeDoubleLE(a,d),d+=8;break;case"string":i=c.byteLength(a),d=h(f,d,j.encodeUInt32(i)),f.write(a,d,i),d+=i;break;default:var k=g.__messages[b]||m.protos["message "+b];if(k){var l=new c(2*c.byteLength(JSON.stringify(a)));i=0,i=e(l,i,k,a),d=h(f,d,j.encodeUInt32(i)),l.copy(f,d,0,i),d+=i}}return d}function g(a,b,c,d,e){var g=0;if(l.isSimpleType(b.type))for(c=h(d,c,i(b.type,b.tag)),c=h(d,c,j.encodeUInt32(a.length)),g=0;g<a.length;g++)c=f(a[g],b.type,c,d);else for(g=0;g<a.length;g++)c=h(d,c,i(b.type,b.tag)),c=f(a[g],b.type,c,d,e);return c}function h(a,b,c){for(var d=0;d<c.length;d++)a.writeUInt8(c[d],b),b++;return b}function i(a,b){var c=k.TYPES[a];return void 0===c&&(c=2),j.encodeUInt32(b<<3|c)}var j=a("./codec"),k=a("./constant"),l=a("./util"),m=b.exports;m.init=function(a){this.protos=a||{}},m.encode=function(a,b){if(!a||!b)return console.warn("Route or msg can not be null! route : %j, msg %j",a,b),null;var f=this.protos[a];if(!d(b,f))return console.warn("check msg failed! msg : %j, proto : %j",b,f),null;var g=2*c.byteLength(JSON.stringify(b)),h=new c(g),i=0;return f&&(i=e(h,i,f,b),i>0)?h.slice(0,i):null}}).call(this,a("buffer").Buffer)},{"./codec":12,"./constant":13,"./util":18,buffer:2}],16:[function(a,b){function c(a){var b={},d={},e={};for(var f in a){var g=a[f],h=f.split(" ");switch(h[0]){case"message":if(2!==h.length)continue;d[h[1]]=c(g);continue;case"required":case"optional":case"repeated":if(3!==h.length||e[g])continue;b[h[2]]={option:h[0],type:h[1],tag:g},e[g]=h[2]}}return b.__messages=d,b.__tags=e,b}var d=b.exports;d.parse=function(a){var b={};for(var d in a)b[d]=c(a[d]);return b}},{}],17:[function(a,b){(function(c){var d=a("./encoder"),e=a("./decoder"),f=a("./parser"),g=b.exports;g.encode=function(a,b){return d.encode(a,b)},g.encode2Bytes=function(a,b){var c=this.encode(a,b);if(!c||!c.length)return console.warn("encode msg failed! key : %j, msg : %j",a,b),null;for(var d=new Uint8Array(c.length),e=0;e<c.length;e++)d[e]=c.readUInt8(e);return d},g.encodeStr=function(a,b,c){c=c||"base64";var d=g.encode(a,b);return d?d.toString(c):d},g.decode=function(a,b){return e.decode(a,b)},g.decodeStr=function(a,b,d){d=d||"base64";var e=new c(b,d);return e?g.decode(a,e):e},g.parse=function(a){return f.parse(a)},g.setEncoderProtos=function(a){d.init(a)},g.setDecoderProtos=function(a){e.init(a)},g.init=function(a){d.init(a.encoderProtos),e.init(a.decoderProtos)}}).call(this,a("buffer").Buffer)},{"./decoder":14,"./encoder":15,"./parser":16,buffer:2}],18:[function(a,b){var c=b.exports;c.isSimpleType=function(a){return"uInt32"===a||"sInt32"===a||"int32"===a||"uInt64"===a||"sInt64"===a||"float"===a||"double"===a},c.equal=function(a,b){for(var d in a){var e=a[d],f=b[d];if("object"==typeof e){if(!c.equal(e,f))return!1}else if(e!==f)return!1}return!0}},{}],19:[function(a,b){b.exports=a("./lib/protocol")},{"./lib/protocol":20}],20:[function(a,b){(function(a){!function(c,d){var e=c,f=4,g=1,h=2,i=1,j=65535,k=1,l=7,m=e.Package={},n=e.Message={};m.TYPE_HANDSHAKE=1,m.TYPE_HANDSHAKE_ACK=2,m.TYPE_HEARTBEAT=3,m.TYPE_DATA=4,m.TYPE_KICK=5,n.TYPE_REQUEST=0,n.TYPE_NOTIFY=1,n.TYPE_RESPONSE=2,n.TYPE_PUSH=3,e.strencode=function(b){if("undefined"!=typeof a&&d===a)return new a(b);for(var c=new d(3*b.length),e=0,f=0;f<b.length;f++){var g=b.charCodeAt(f),h=null;h=127>=g?[g]:2047>=g?[192|g>>6,128|63&g]:[224|g>>12,128|(4032&g)>>6,128|63&g];for(var i=0;i<h.length;i++)c[e]=h[i],++e}var j=new d(e);return o(j,0,c,0,e),j},e.strdecode=function(b){if("undefined"!=typeof a&&d===a)return b.toString();for(var c=new d(b),e=[],f=0,g=0,h=c.length;h>f;)c[f]<128?(g=c[f],f+=1):c[f]<224?(g=((31&c[f])<<6)+(63&c[f+1]),f+=2):(g=((15&c[f])<<12)+((63&c[f+1])<<6)+(63&c[f+2]),f+=3),e.push(g);return String.fromCharCode.apply(null,e)},m.encode=function(a,b){var c=b?b.length:0,e=new d(f+c),g=0;return e[g++]=255&a,e[g++]=c>>16&255,e[g++]=c>>8&255,e[g++]=255&c,b&&o(e,g,b,0,c),e},m.decode=function(a){for(var b=0,c=new d(a),e=0,f=[];b<c.length;){var g=c[b++];e=(c[b++]<<16|c[b++]<<8|c[b++])>>>0;var h=e?new d(e):null;h&&o(h,0,c,b,e),b+=e,f.push({type:g,body:h})}return 1===f.length?f[0]:f},n.encode=function(a,b,c,f,j){var k=p(b)?r(a):0,l=g+k;if(q(b))if(c){if("number"!=typeof f)throw new Error("error flag for number route!");l+=h}else if(l+=i,f){if(f=e.strencode(f),f.length>255)throw new Error("route maxlength is overflow");l+=f.length}j&&(l+=j.length);var m=new d(l),n=0;return n=s(b,c,m,n),p(b)&&(n=t(a,m,n)),q(b)&&(n=u(c,f,m,n)),j&&(n=v(j,m,n)),m},n.decode=function(a){var b=new d(a),c=b.length||b.byteLength,f=0,g=0,h=null,i=b[f++],j=i&k,m=i>>1&l;if(p(m)){var n=0,r=0;do n=parseInt(b[f]),g+=(127&n)<<7*r,f++,r++;while(n>=128)}if(q(m))if(j)h=b[f++]<<8|b[f++];else{var s=b[f++];s?(h=new d(s),o(h,0,b,f,s),h=e.strdecode(h)):h="",f+=s}var t=c-f,u=new d(t);return o(u,0,b,f,t),{id:g,type:m,compressRoute:j,route:h,body:u}};var o=function(a,b,c,d,e){if("function"==typeof c.copy)c.copy(a,b,d,d+e);else for(var f=0;e>f;f++)a[b++]=c[d++]},p=function(a){return a===n.TYPE_REQUEST||a===n.TYPE_RESPONSE},q=function(a){return a===n.TYPE_REQUEST||a===n.TYPE_NOTIFY||a===n.TYPE_PUSH},r=function(a){var b=0;do b+=1,a>>=7;while(a>0);return b},s=function(a,b,c,d){if(a!==n.TYPE_REQUEST&&a!==n.TYPE_NOTIFY&&a!==n.TYPE_RESPONSE&&a!==n.TYPE_PUSH)throw new Error("unkonw message type: "+a);return c[d]=a<<1|(b?1:0),d+g},t=function(a,b,c){do{var d=a%128,e=Math.floor(a/128);0!==e&&(d+=128),b[c++]=d,a=e}while(0!==a);return c},u=function(a,b,c,d){if(a){if(b>j)throw new Error("route number is overflow");c[d++]=b>>8&255,c[d++]=255&b}else b?(c[d++]=255&b.length,o(c,d,b,0,b.length),d+=b.length):c[d++]=0;return d},v=function(a,b,c){return o(b,c,a,0,a.length),c+a.length};b.exports=e,"undefined"!=typeof window&&(window.Protocol=e)}("undefined"==typeof window?b.exports:this.Protocol={},"undefined"==typeof window?a:Uint8Array,this)}).call(this,a("buffer").Buffer)},{buffer:2}]},{},[1]);