colyseus.js 64.1 KB
Newer Older
Alexander Bazo committed
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Colyseus=t():e.Colyseus=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=13)}([function(e,t,n){"use strict";function r(e,t,n,r){var i,o=!1;switch(t){case"number":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":case"int64":case"uint64":case"float32":case"float64":i="number",isNaN(e)&&console.log('trying to encode "NaN" in '+n.constructor.name+"#"+r);break;case"string":i="string",o=!0;break;case"boolean":return}if(typeof e!==i&&(!o||o&&null!==e)){var s="'"+JSON.stringify(e)+"'"+(e&&e.constructor&&" ("+e.constructor.name+")");throw new d("a '"+i+"' was expected, but "+s+" was provided in "+n.constructor.name+"#"+r)}}function i(e,t,n,r){if(!(e instanceof t))throw new d("a '"+t.name+"' was expected, but '"+e.constructor.name+"' was provided in "+n.constructor.name+"#"+r)}function o(e,t,n,i,o){var s=u[e];return void 0===n?t.push(c.NIL):r(n,e,i,o),!!s&&(s(t,n),!0)}function s(e,t,n){var r=h[e];return r?r(t,n):null}var a=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var c=n(10),u=n(31),h=n(32),f=n(1),l=n(2),p=n(11),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t}(Error),v=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];Object.defineProperties(this,{$changes:{value:new p.ChangeTree,enumerable:!1,writable:!0}});var n=this._descriptors;n&&Object.defineProperties(this,n)}return e.onError=function(e){console.error(e)},Object.defineProperty(e.prototype,"_schema",{get:function(){return this.constructor._schema},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_descriptors",{get:function(){return this.constructor._descriptors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_indexes",{get:function(){return this.constructor._indexes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_filters",{get:function(){return this.constructor._filters},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"$changed",{get:function(){return this.$changes.changed},enumerable:!0,configurable:!0}),e.prototype.decode=function(t,n){void 0===n&&(n={offset:0});var r=[],i=this._schema,o=this._indexes,a={};Object.keys(o).forEach(function(e){var t=o[e];a[t]=e});var u=t.length;t[n.offset]===c.TYPE_ID&&(n.offset+=2);for(var p=this;n.offset<u;){if("break"===function(){var o=t[n.offset++];if(o===c.END_OF_STRUCTURE)return"break";var u=a[o],d=i[u],v=void 0,y=void 0,g=!1;if(d._schema)h.nilCheck(t,n)?(n.offset++,v=null):(v=p["_"+u]||p.createTypeInstance(t,n,d),v.decode(t,n)),g=!0;else if(Array.isArray(d)){d=d[0],y=[];var _=p["_"+u]||new f.ArraySchema;v=_.clone();var b=h.number(t,n),w=Math.min(h.number(t,n),b);g=w>0;var m=!1;v.length>b&&Array.prototype.splice.call(v,b).forEach(function(t,n){if(t&&t.onRemove)try{t.onRemove()}catch(t){e.onError(t)}if(_.onRemove)try{_.onRemove(t,b+n)}catch(t){e.onError(t)}});for(var C=0;C<w;C++){var O=h.number(t,n),S=void 0;h.indexChangeCheck(t,n)&&(h.uint8(t,n),S=h.number(t,n),m=!0);var A=!m&&void 0===v[O]||m&&void 0===S;if(d.prototype instanceof e){var k=void 0;if(k=A?p.createTypeInstance(t,n,d):void 0!==S?_[S]:_[O],k||(k=p.createTypeInstance(t,n,d),A=!0),h.nilCheck(t,n)){if(n.offset++,_.onRemove)try{_.onRemove(k,O)}catch(t){e.onError(t)}continue}k.decode(t,n),v[O]=k}else v[O]=s(d,t,n);if(A){if(_.onAdd)try{_.onAdd(v[O],O)}catch(t){e.onError(t)}}else if(_.onChange)try{_.onChange(v[O],O)}catch(t){e.onError(t)}y.push(v[O])}}else if(d.map){d=d.map;var I=p["_"+u]||new l.MapSchema;v=I.clone();var E=h.number(t,n);g=E>0;for(var m=!1,P=Object.keys(I),C=0;C<E&&(void 0!==t[n.offset]&&t[n.offset]!==c.END_OF_STRUCTURE);C++){var x=void 0;h.indexChangeCheck(t,n)&&(h.uint8(t,n),x=P[h.number(t,n)],m=!0);var M=h.numberCheck(t,n),R="string"!=typeof d,j=M?P[h.number(t,n)]:h.string(t,n),k=void 0,A=!m&&void 0===I[j]||m&&void 0===x&&M;if(k=A&&R?p.createTypeInstance(t,n,d):void 0!==x?I[x]:I[j],h.nilCheck(t,n)){if(n.offset++,k&&k.onRemove)try{k.onRemove()}catch(t){e.onError(t)}if(I.onRemove)try{I.onRemove(k,j)}catch(t){e.onError(t)}delete v[j]}else if(R?(k.decode(t,n),v[j]=k):v[j]=s(d,t,n),A){if(I.onAdd)try{I.onAdd(v[j],j)}catch(t){e.onError(t)}}else if(I.onChange)try{I.onChange(v[j],j)}catch(t){e.onError(t)}}}else v=s(d,t,n),g=!0;g&&p.onChange&&r.push({field:u,value:y||v,previousValue:p["_"+u]}),p["_"+u]=v}())break}if(this.onChange&&r.length>0)try{this.onChange(r)}catch(t){e.onError(t)}return this},e.prototype.encode=function(e,t,n){var r=this;void 0===e&&(e=this),void 0===t&&(t=!1);var s=[],a=function(){r!==e&&s.push(c.END_OF_STRUCTURE)};if(!this.$changes.changed&&!t)return a(),s;for(var h=this._schema,p=this._indexes,d=this._filters,v=t||n?this.$changes.allChanges:this.$changes.changes,y=this,g=0,_=v.length;g<_;g++)!function(a,g){var _=v[a],b=h[_],w=d&&d[_],m=y["_"+_],C=p[_];if(void 0===m)return"continue";var O=[];if(b._schema){if(n&&w&&!w.call(y,n,m,e))return"continue";u.number(O,C),m?(i(m,b,y,_),y.tryEncodeTypeId(O,b,m.constructor),O=O.concat(m.encode(e,t,n))):u.uint8(O,c.NIL)}else if(Array.isArray(b)){u.number(O,C),u.number(O,m.length);var S=(t||n?m.$changes.allChanges:m.$changes.changes).filter(function(e){return void 0!==r["_"+_][e]}).sort(function(e,t){return e-t}),A=S.length;u.number(O,A);var k="string"!=typeof b[0];i(y["_"+_],f.ArraySchema,y,_);for(var I=0;I<A;I++){var E=S[I],P=y["_"+_][E];if(!n||!w||w.call(y,n,P,e))if(k){if(u.number(O,E),!t){var x=m.$changes.getIndexChange(P);void 0!==x&&(u.uint8(O,c.INDEX_CHANGE),u.number(O,x))}i(P,b[0],y,_),y.tryEncodeTypeId(O,b[0],P.constructor),O=O.concat(P.encode(e,t,n))}else if(u.number(O,E),!o(b[0],O,P,y,_)){console.log("cannot encode",h[_]);continue}}t||m.$changes.discard()}else if(b.map){u.number(O,C);var M=t||n?m.$changes.allChanges:m.$changes.changes;u.number(O,M.length);var R=Object.keys(y["_"+_]),k="string"!=typeof b.map;i(y["_"+_],l.MapSchema,y,_);for(var j=0;j<M.length;j++){var T="number"==typeof M[j]&&R[M[j]]||M[j],P=y["_"+_][T],N=void 0;if(!n||!w||w.call(y,n,P,e)){if(t){if(void 0===P)continue}else{var x=m.$changes.getIndexChange(P);P&&void 0!==x&&(u.uint8(O,c.INDEX_CHANGE),u.number(O,y["_"+_]._indexes.get(x))),N=y["_"+_]._indexes.get(T)}void 0!==N?u.number(O,N):u.string(O,T),P&&k?(i(P,b.map,y,_),y.tryEncodeTypeId(O,b.map,P.constructor),O=O.concat(P.encode(e,t,n))):void 0!==P?o(b.map,O,P,y,_):u.uint8(O,c.NIL)}}t||(m.$changes.discard(),n||y["_"+_]._updateIndexes())}else{if(n&&w&&!w.call(y,n,m,e))return"continue";if(u.number(O,C),!o(b,O,m,y,_))return console.log("cannot encode",h[_]),"continue"}s=s.concat(O)}(g);return a(),t||n||this.$changes.discard(),s},e.prototype.encodeFiltered=function(e){return this.encode(this,!1,e)},e.prototype.encodeAll=function(){return this.encode(this,!0)},e.prototype.encodeAllFiltered=function(e){return this.encode(this,!0,e)},e.prototype.clone=function(){var e=new this.constructor,t=this._schema;for(var n in t)e[n]=this[n];return e},e.prototype.triggerAll=function(){if(this.onChange){var t=[],n=this._schema;for(var r in n)void 0!==this[r]&&t.push({field:r,value:this[r],previousValue:void 0});try{this.onChange(t)}catch(t){e.onError(t)}}},e.prototype.toJSON=function(){var e=this._schema,t={};for(var n in e)void 0!==this[n]&&(t[n]="function"==typeof this[n].toJSON?this[n].toJSON():this["_"+n]);return t},e.prototype.tryEncodeTypeId=function(e,t,n){t._typeid!==n._typeid&&(u.uint8(e,c.TYPE_ID),u.uint8(e,n._typeid))},e.prototype.createTypeInstance=function(e,t,n){if(e[t.offset]===c.TYPE_ID){t.offset++;return new(this.constructor._context.get(h.uint8(e,t)))}return new n},e}();t.Schema=v},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=e.apply(this,n)||this;return Object.setPrototypeOf(i,Object.create(t.prototype)),Object.defineProperties(i,{$sorting:{value:void 0,enumerable:!1,writable:!0},$changes:{value:void 0,enumerable:!1,writable:!0},onAdd:{value:void 0,enumerable:!1,writable:!0},onRemove:{value:void 0,enumerable:!1,writable:!0},onChange:{value:void 0,enumerable:!1,writable:!0},triggerAll:{value:function(){if(i.onAdd)for(var e=0;e<i.length;e++)i.onAdd(i[e],e)}},toJSON:{value:function(){for(var e=[],t=0;t<i.length;t++){var n=i[t];e.push("function"==typeof n.toJSON?n.toJSON():n)}return e}},clone:{value:function(){var e=new(t.bind.apply(t,[void 0].concat(i)));return e.onAdd=i.onAdd,e.onRemove=i.onRemove,e.onChange=i.onChange,e}}}),i}return r(t,e),t.prototype.sort=function(t){this.$sorting=!0,e.prototype.sort.call(this,t);for(var n=this.$changes.changes,r=0,i=n;r<i.length;r++){var o=i[r],s=this.$changes.getIndex(this[o]);void 0!==s&&this.$changes.mapIndexChange(this[o],s),this.$changes.mapIndex(this[o],o)}return this.$sorting=!1,this},t.prototype.splice=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=Array.prototype.splice.apply(this,arguments),o=this.filter(function(n,r){return r>=e+t-1});return i.map(function(e){e&&e.$changes&&(e.$changes.parent.deleteIndex(e),e.$changes.parent.deleteIndexChange(e),delete e.$changes.parent)}),o.forEach(function(e){e&&e.$changes&&e.$changes.parentField--}),i},t}(Array);t.ArraySchema=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(t){var n=this;void 0===t&&(t={});for(var r in t)this[r]=t[r];Object.defineProperties(this,{$changes:{value:void 0,enumerable:!1,writable:!0},onAdd:{value:void 0,enumerable:!1,writable:!0},onRemove:{value:void 0,enumerable:!1,writable:!0},onChange:{value:void 0,enumerable:!1,writable:!0},clone:{value:function(){var t=Object.assign(new e,n);return t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.onChange=n.onChange,t}},triggerAll:{value:function(){if(n.onAdd)for(var e in n)n.onAdd(n[e],e)}},toJSON:{value:function(){var e={};for(var t in n)e[t]="function"==typeof n[t].toJSON?n[t].toJSON():n[t];return e}},_indexes:{value:new Map,enumerable:!1,writable:!0},_updateIndexes:{value:function(){var e=0,t=new Map;for(var r in n)t.set(r,e++);n._indexes=t}}})}return e}();t.MapSchema=r},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(16)),o=r(n(17));t.decode=i.default,t.encode=o.default},function(e,t,n){"use strict";function r(e,t){t.headers=e.headers||{},t.statusMessage=e.statusText,t.statusCode=e.status,t.data=e.response}function i(e,t,n){return new Promise(function(i,o){n=n||{};var s,a,c,u,h=new XMLHttpRequest,f=n.headers||{};h.timeout=n.timeout,h.ontimeout=h.onerror=function(e){e.timeout="timeout"==e.type,o(e)},h.open(e,t),h.onload=function(){for(u=h.getAllResponseHeaders().trim().split(/[\r\n]+/),r(h,h);c=u.shift();)c=c.split(": "),h.headers[c.shift().toLowerCase()]=c.join(": ");if((c=h.headers["content-type"])&&~c.indexOf("application/json"))try{h.data=JSON.parse(h.data,n.reviver)}catch(e){return r(h,e),o(e)}(h.status>=400?o:i)(h)},(a=n.body)&&/Array|Object/.test(a.constructor)&&(f["content-type"]="application/json",a=JSON.stringify(a));for(s in f)h.setRequestHeader(s,f[s]);h.send(a)})}Object.defineProperty(t,"__esModule",{value:!0}),t.send=i,n.d(t,"get",function(){return o}),n.d(t,"post",function(){return s}),n.d(t,"patch",function(){return a}),n.d(t,"del",function(){return c}),n.d(t,"put",function(){return u});var o=i.bind(i,"GET"),s=i.bind(i,"POST"),a=i.bind(i,"PATCH"),c=i.bind(i,"DELETE"),u=i.bind(i,"PUT")},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(3)),o=n(18),s=n(19),a=n(6),c=n(7),u=function(){function e(e,t){var n=this;this.onJoin=o.createSignal(),this.onStateChange=o.createSignal(),this.onMessage=o.createSignal(),this.onError=o.createSignal(),this.onLeave=o.createSignal(),this.id=null,this.name=e,t?(this.serializer=new(a.getSerializer("schema")),this.rootSchema=t,this.serializer.state=new t):this.serializer=new(a.getSerializer("fossil-delta")),this.onError(function(e){return console.error(e)}),this.onLeave(function(){return n.removeAllListeners()})}return e.prototype.connect=function(e){var t=this;this.connection=new s.Connection(e,!1),this.connection.reconnectEnabled=!1,this.connection.onmessage=this.onMessageCallback.bind(this),this.connection.onclose=function(e){t.onLeave.invoke(e.code)},this.connection.onerror=function(e){console.warn("Room, onError ("+e.code+"): "+e.reason),t.onError.invoke(e.reason)},this.connection.open()},e.prototype.leave=function(e){void 0===e&&(e=!0),this.connection?e?this.connection.send([c.Protocol.LEAVE_ROOM]):this.connection.close():this.onLeave.invoke(4e3)},e.prototype.send=function(e){this.connection.send([c.Protocol.ROOM_DATA,e])},Object.defineProperty(e.prototype,"state",{get:function(){return this.serializer.getState()},enumerable:!0,configurable:!0}),e.prototype.listen=function(e,t,n){return"schema"===this.serializerId?void console.error("'"+this.serializerId+"' serializer doesn't support .listen() method."):(this.serializerId||console.warn("room.Listen() should be called after room.onJoin has been called (DEPRECATION WARNING)"),this.serializer.api.listen(e,t,n))},e.prototype.removeListener=function(e){return this.serializer.api.removeListener(e)},e.prototype.removeAllListeners=function(){this.serializer&&this.serializer.teardown(),this.onJoin.clear(),this.onStateChange.clear(),this.onMessage.clear(),this.onError.clear(),this.onLeave.clear()},e.prototype.onMessageCallback=function(e){if(this.previousCode)this.previousCode===c.Protocol.ROOM_STATE?this.setState(Array.from(new Uint8Array(e.data))):this.previousCode===c.Protocol.ROOM_STATE_PATCH?this.patch(Array.from(new Uint8Array(e.data))):this.previousCode===c.Protocol.ROOM_DATA&&this.onMessage.invoke(i.decode(e.data)),this.previousCode=void 0;else{var t=new DataView(e.data),n=t.getUint8(0);if(n===c.Protocol.JOIN_ROOM){var r=1;this.serializerId=c.utf8Read(t,r),r+=c.utf8Length(this.serializerId);var o=a.getSerializer(this.serializerId);if(!o)throw new Error("missing serializer: "+this.serializerId);if("fossil-delta"===this.serializerId||this.rootSchema||(this.serializer=new o),t.buffer.byteLength>r&&this.serializer.handshake){var s=Array.from(new Uint8Array(t.buffer.slice(r)));this.serializer.handshake(s)}this.onJoin.invoke()}else n===c.Protocol.JOIN_ERROR?this.onError.invoke(c.utf8Read(t,1)):n===c.Protocol.LEAVE_ROOM?this.leave():this.previousCode=n}},e.prototype.setState=function(e){this.serializer.setState(e),this.onStateChange.invoke(this.serializer.getState())},e.prototype.patch=function(e){this.serializer.patch(e),this.onStateChange.invoke(this.serializer.getState())},e}();t.Room=u},function(e,t,n){"use strict";function r(e,t){o[e]=t}function i(e){return o[e]}Object.defineProperty(t,"__esModule",{value:!0});var o={};t.registerSerializer=r,t.getSerializer=i},function(e,t,n){"use strict";function r(e,t){for(var n=e.getUint8(t++),r="",i=0,o=t,s=t+n;o<s;o++){var a=e.getUint8(o);if(0!=(128&a))if(192!=(224&a))if(224!=(240&a)){if(240!=(248&a))throw new Error("Invalid byte "+a.toString(16));i=(7&a)<<18|(63&e.getUint8(++o))<<12|(63&e.getUint8(++o))<<6|(63&e.getUint8(++o))<<0,i>=65536?(i-=65536,r+=String.fromCharCode(55296+(i>>>10),56320+(1023&i))):r+=String.fromCharCode(i)}else r+=String.fromCharCode((15&a)<<12|(63&e.getUint8(++o))<<6|(63&e.getUint8(++o))<<0);else r+=String.fromCharCode((31&a)<<6|63&e.getUint8(++o));else r+=String.fromCharCode(a)}return r}function i(e){void 0===e&&(e="");for(var t=0,n=0,r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n+1}Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.JOIN_ROOM=10]="JOIN_ROOM",e[e.JOIN_ERROR=11]="JOIN_ERROR",e[e.LEAVE_ROOM=12]="LEAVE_ROOM",e[e.ROOM_DATA=13]="ROOM_DATA",e[e.ROOM_STATE=14]="ROOM_STATE",e[e.ROOM_STATE_PATCH=15]="ROOM_STATE_PATCH"}(t.Protocol||(t.Protocol={})),t.utf8Read=r,t.utf8Length=i},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,o&&(s=2&n[0]?o.return:n[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,n[1])).done)return s;switch(o=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,o=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){c.label=n[1];break}if(6===n[0]&&c.label<s[1]){c.label=s[1],s=n;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(n);break}s[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],o=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var i,o,s,a,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var s=o(n(4)),a=n(23),c="colyseus-auth-token";!function(e){e.ios="ios",e.android="android"}(t.Platform||(t.Platform={}));var u=function(){function e(e){var t=this;this._id=void 0,this.username=void 0,this.displayName=void 0,this.avatarUrl=void 0,this.isAnonymous=void 0,this.email=void 0,this.lang=void 0,this.location=void 0,this.timezone=void 0,this.metadata=void 0,this.devices=void 0,this.facebookId=void 0,this.twitterId=void 0,this.googleId=void 0,this.gameCenterId=void 0,this.steamId=void 0,this.friendIds=void 0,this.blockedUserIds=void 0,this.createdAt=void 0,this.updatedAt=void 0,this.token=void 0,this.endpoint=e.replace("ws","http"),a.getItem(c,function(e){return t.token=e})}return Object.defineProperty(e.prototype,"hasToken",{get:function(){return!!this.token},enumerable:!0,configurable:!0}),e.prototype.login=function(e){return void 0===e&&(e={}),r(this,void 0,void 0,function(){var t,n,r;return i(this,function(i){switch(i.label){case 0:return t=Object.assign({},e),this.hasToken&&(t.token=this.token),[4,this.request("post","/auth",t)];case 1:n=i.sent(),this.token=n.token,a.setItem(c,this.token);for(r in n)this.hasOwnProperty(r)&&(this[r]=n[r]);return this.registerPingService(),[2,this]}})})},e.prototype.save=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.request("put","/auth",{},{username:this.username,displayName:this.displayName,avatarUrl:this.avatarUrl,lang:this.lang,location:this.location,timezone:this.timezone})];case 1:return e.sent(),[2,this]}})})},e.prototype.getFriends=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.request("get","/friends/all")];case 1:return[2,e.sent()]}})})},e.prototype.getOnlineFriends=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.request("get","/friends/online")];case 1:return[2,e.sent()]}})})},e.prototype.getFriendRequests=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.request("get","/friends/requests")];case 1:return[2,e.sent()]}})})},e.prototype.sendFriendRequest=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.request("post","/friends/requests",{userId:e})];case 1:return[2,t.sent()]}})})},e.prototype.acceptFriendRequest=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.request("put","/friends/requests",{userId:e})];case 1:return[2,t.sent()]}})})},e.prototype.declineFriendRequest=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.request("del","/friends/requests",{userId:e})];case 1:return[2,t.sent()]}})})},e.prototype.blockUser=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.request("post","/friends/block",{userId:e})];case 1:return[2,t.sent()]}})})},e.prototype.unblockUser=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.request("put","/friends/block",{userId:e})];case 1:return[2,t.sent()]}})})},e.prototype.request=function(e,t,n,o,a){return void 0===n&&(n={}),void 0===a&&(a={}),r(this,void 0,void 0,function(){var r,c,u,h;return i(this,function(i){switch(i.label){case 0:a.Accept="application/json",this.hasToken&&(a.Authorization="Bearer "+this.token),r=[];for(c in n)r.push(c+"="+n[c]);return u=r.length>0?"?"+r.join("&"):"",h={headers:a},o&&(h.body=o),[4,s[e](""+this.endpoint+t+u,h)];case 1:return[2,i.sent().data]}})})},e.prototype.logout=function(){this.token=void 0,a.removeItem(c),this.unregisterPingService()},e.prototype.registerPingService=function(e){var t=this;void 0===e&&(e=15e3),this.unregisterPingService(),this.keepOnlineInterval=setInterval(function(){return t.request("get","/auth")},e)},e.prototype.unregisterPingService=function(){clearInterval(this.keepOnlineInterval)},e}();t.Auth=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.Schema=r.Schema;var i=n(2);t.MapSchema=i.MapSchema;var o=n(1);t.ArraySchema=o.ArraySchema;var s=n(33);t.Reflection=s.Reflection,t.ReflectionType=s.ReflectionType,t.ReflectionField=s.ReflectionField;var a=n(12);t.type=a.type,t.filter=a.filter,t.defineTypes=a.defineTypes,t.Context=a.Context},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.END_OF_STRUCTURE=193,t.NIL=192,t.INDEX_CHANGE=212,t.TYPE_ID=213},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(1),o=n(2),s=function(){function e(e,t,n){void 0===e&&(e=null),void 0===n&&(n=!1),this.changed=!1,this.changes=[],this.allChanges=[],this.linkedTrees=[],this.parent=t,this.parentField=e,this.trackAllChanges=n}return e.prototype.link=function(e){this.linkedTrees.push(e)},e.prototype.change=function(e,t){void 0===t&&(t=!1),this.changed=!0,-1===this.changes.indexOf(e)&&this.changes.push(e);var n=this.allChanges.indexOf(e);t||-1!==n?t&&n>=0&&this.allChanges.splice(n,1):this.allChanges.push(e),this.parent&&this.parent.change(this.parentField)},e.prototype.mapIndex=function(e,t){this.indexMap||(this.indexMap=new Map,this.indexChange=new Map),this.indexMap.set(e,t)},e.prototype.getIndex=function(e){return this.indexMap&&this.indexMap.get(e)},e.prototype.deleteIndex=function(e){this.indexMap.delete(e)},e.prototype.mapIndexChange=function(e,t){this.indexChange.set(e,t)},e.prototype.getIndexChange=function(e){return this.indexChange&&this.indexChange.get(e)},e.prototype.deleteIndexChange=function(e){this.indexChange.delete(e)},e.prototype.changeAll=function(e){if(e instanceof r.Schema){var t=e._schema;for(var n in t)(e[n]instanceof r.Schema||e[n]instanceof i.ArraySchema||e[n]instanceof o.MapSchema)&&!e[n].$changes.parent.parent&&(e[n].$changes.parent=this),this.change(n)}else for(var s=Object.keys(e),a=0,c=s;a<c.length;a++){var u=c[a];this.change(u)}},e.prototype.discard=function(){this.changed=!1,this.changes=[],this.indexChange&&this.indexChange.clear()},e}();t.ChangeTree=s},function(e,t,n){"use strict";function r(e,n){return void 0===n&&(n=t.globalContext),function(t,r){var i=t.constructor;i._context=n,n.has(i)||(n.add(i),i._schema=Object.assign({},i._schema||{}),i._indexes=Object.assign({},i._indexes||{}),i._descriptors=Object.assign({},i._descriptors||{})),i._indexes[r]=Object.keys(i._schema).length,i._schema[r]=e;var o=Array.isArray(e),c=!o&&e.map,u="_"+r;i._descriptors[u]={enumerable:!1,configurable:!1,writable:!0},i._descriptors[r]={get:function(){return this[u]},set:function(e){if((o||c)&&(e=new Proxy(e,{get:function(e,t){return e[t]},set:function(e,t,n){if("length"!==t&&0!==t.indexOf("$")){var r=o?Number(t):String(t);if(!e.$sorting){var i=e.$changes.getIndex(n);void 0!==i&&e.$changes.mapIndexChange(n,i),e.$changes.mapIndex(n,r)}n instanceof a.Schema?n.$changes.parent||(n.$changes=new s.ChangeTree(r,e.$changes),n.$changes.changeAll(n)):e[t]=n,e.$changes.change(r)}else e[t];return e[t]=n,!0},deleteProperty:function(e,t){var n=e[t];c&&void 0!==n&&(e.$changes.deleteIndex(n),e.$changes.deleteIndexChange(n),n.$changes&&delete n.$changes.parent,e._indexes.delete(t)),delete e[t];var r=o?Number(t):String(t);return e.$changes.change(r,!0),!0}})),e!==this[u])if(this[u]=e,Array.isArray(i._schema[r])){this.$changes.change(r),e.$changes=new s.ChangeTree(r,this.$changes);for(var t=0;t<e.length;t++)e[t]instanceof a.Schema&&(e[t].$changes=new s.ChangeTree(t,e.$changes),e[t].$changes.changeAll(e[t])),e.$changes.mapIndex(e[t],t),e.$changes.change(t)}else if(i._schema[r].map){e.$changes=new s.ChangeTree(r,this.$changes),this.$changes.change(r);for(var n in e)e[n]instanceof a.Schema&&(e[n].$changes=new s.ChangeTree(n,e.$changes),e[n].$changes.changeAll(e[n])),e.$changes.mapIndex(e[n],n),e.$changes.change(n)}else"function"==typeof i._schema[r]?(this.$changes.change(r),e&&(e.$changes=new s.ChangeTree(r,this.$changes),e.$changes.changeAll(e))):this.$changes.change(r)},enumerable:!0,configurable:!0}}}function i(e){return function(t,n){var r=t.constructor;r._filters||(r._filters={}),r._filters[n]=e}}function o(e,t){for(var n in t)r(t[n])(e.prototype,n);return e}Object.defineProperty(t,"__esModule",{value:!0});var s=n(11),a=n(0),c=function(){function e(){this.types={},this.schemas=new Map}return e.prototype.has=function(e){return this.schemas.has(e)},e.prototype.get=function(e){return this.types[e]},e.prototype.add=function(e){e._typeid=this.schemas.size,this.types[e._typeid]=e,this.schemas.set(e,e._typeid)},e}();t.Context=c,t.globalContext=new c,t.type=r,t.filter=i,t.defineTypes=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n(14);var r=n(15);t.Client=r.Client;var i=n(7);t.Protocol=i.Protocol;var o=n(5);t.Room=o.Room;var s=n(8);t.Auth=s.Auth,t.Platform=s.Platform;var a=n(25);t.FossilDeltaSerializer=a.FossilDeltaSerializer;var c=n(30);t.SchemaSerializer=c.SchemaSerializer;var u=n(6);t.registerSerializer=u.registerSerializer;var h=n(9);t.Schema=h.Schema,t.type=h.type,u.registerSerializer("fossil-delta",a.FossilDeltaSerializer),u.registerSerializer("schema",c.SchemaSerializer)},function(e,t){ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return null!==e&&"object"==typeof e&&e.buffer instanceof ArrayBuffer})},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,o&&(s=2&n[0]?o.return:n[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,n[1])).done)return s;switch(o=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,o=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){c.label=n[1];break}if(6===n[0]&&c.label<s[1]){c.label=s[1],s=n;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(n);break}s[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],o=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var i,o,s,a,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a};Object.defineProperty(t,"__esModule",{value:!0});var s=n(4),a=n(5),c=n(8),u=n(24),h=function(e){function t(n,r){var i=e.call(this,n)||this;return i.code=r,Object.setPrototypeOf(i,t.prototype),i}return r(t,e),t}(Error);t.MatchMakeError=h;var f=function(){function e(e){void 0===e&&(e=location.protocol.replace("http","ws")+"//"+location.hostname+(location.port&&":"+location.port)),this.endpoint=e,this.auth=new c.Auth(this.endpoint),this.push=new u.Push(this.endpoint)}return e.prototype.joinOrCreate=function(e,t,n){return void 0===t&&(t={}),i(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.createMatchMakeRequest("joinOrCreate",e,t,n)];case 1:return[2,r.sent()]}})})},e.prototype.create=function(e,t,n){return void 0===t&&(t={}),i(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.createMatchMakeRequest("create",e,t,n)];case 1:return[2,r.sent()]}})})},e.prototype.join=function(e,t,n){return void 0===t&&(t={}),i(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.createMatchMakeRequest("join",e,t,n)];case 1:return[2,r.sent()]}})})},e.prototype.joinById=function(e,t,n){return void 0===t&&(t={}),i(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.createMatchMakeRequest("joinById",e,t,n)];case 1:return[2,r.sent()]}})})},e.prototype.reconnect=function(e,t,n){return i(this,void 0,void 0,function(){return o(this,function(r){switch(r.label){case 0:return[4,this.createMatchMakeRequest("joinById",e,{sessionId:t},n)];case 1:return[2,r.sent()]}})})},e.prototype.getAvailableRooms=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return t=this.endpoint.replace("ws","http")+"/matchmake/"+e,[4,s.get(t,{headers:{Accept:"application/json"}})];case 1:return[2,n.sent().data]}})})},e.prototype.createMatchMakeRequest=function(e,t,n,r){return void 0===n&&(n={}),i(this,void 0,void 0,function(){var i,a,c;return o(this,function(o){switch(o.label){case 0:return i=this.endpoint.replace("ws","http")+"/matchmake/"+e+"/"+t,this.auth.hasToken&&(n.token=this.auth.token),[4,s.post(i,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)})];case 1:if(a=o.sent().data,a.error)throw new h(a.error,a.code);return c=this.createRoom(t,r),c.id=a.room.roomId,c.sessionId=a.sessionId,c.connect(this.buildEndpoint(a.room,{sessionId:c.sessionId})),[2,new Promise(function(e,t){var n=function(e){return t(e)};c.onError.once(n),c.onJoin.once(function(){c.onError.remove(n),e(c)})})]}})})},e.prototype.createRoom=function(e,t){return new a.Room(e,t)},e.prototype.buildEndpoint=function(e,t){void 0===t&&(t={});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(r+"="+t[r]);return this.endpoint+"/"+e.processId+"/"+e.roomId+"?"+n.join("&")},e}();t.Client=f},function(e,t,n){"use strict";function r(e){if(this._offset=0,e instanceof ArrayBuffer)this._buffer=e,this._view=new DataView(this._buffer);else{if(!ArrayBuffer.isView(e))throw new Error("Invalid argument");this._buffer=e.buffer,this._view=new DataView(this._buffer,e.byteOffset,e.byteLength)}}function i(e,t,n){for(var r="",i=0,o=t,s=t+n;o<s;o++){var a=e.getUint8(o);if(0!=(128&a))if(192!=(224&a))if(224!=(240&a)){if(240!=(248&a))throw new Error("Invalid byte "+a.toString(16));i=(7&a)<<18|(63&e.getUint8(++o))<<12|(63&e.getUint8(++o))<<6|(63&e.getUint8(++o))<<0,i>=65536?(i-=65536,r+=String.fromCharCode(55296+(i>>>10),56320+(1023&i))):r+=String.fromCharCode(i)}else r+=String.fromCharCode((15&a)<<12|(63&e.getUint8(++o))<<6|(63&e.getUint8(++o))<<0);else r+=String.fromCharCode((31&a)<<6|63&e.getUint8(++o));else r+=String.fromCharCode(a)}return r}function o(e){var t=new r(e),n=t._parse();if(t._offset!==e.byteLength)throw new Error(e.byteLength-t._offset+" trailing bytes");return n}r.prototype._array=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=this._parse();return t},r.prototype._map=function(e){for(var t="",n={},r=0;r<e;r++)t=this._parse(),n[t]=this._parse();return n},r.prototype._str=function(e){var t=i(this._view,this._offset,e);return this._offset+=e,t},r.prototype._bin=function(e){var t=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,t},r.prototype._parse=function(){var e,t=this._view.getUint8(this._offset++),n=0,r=0,i=0,o=0;if(t<192)return t<128?t:t<144?this._map(15&t):t<160?this._array(15&t):this._str(31&t);if(t>223)return-1*(255-t+1);switch(t){case 192:return null;case 194:return!1;case 195:return!0;case 196:return n=this._view.getUint8(this._offset),this._offset+=1,this._bin(n);case 197:return n=this._view.getUint16(this._offset),this._offset+=2,this._bin(n);case 198:return n=this._view.getUint32(this._offset),this._offset+=4,this._bin(n);case 199:return n=this._view.getUint8(this._offset),r=this._view.getInt8(this._offset+1),this._offset+=2,[r,this._bin(n)];case 200:return n=this._view.getUint16(this._offset),r=this._view.getInt8(this._offset+2),this._offset+=3,[r,this._bin(n)];case 201:return n=this._view.getUint32(this._offset),r=this._view.getInt8(this._offset+4),this._offset+=5,[r,this._bin(n)];case 202:return e=this._view.getFloat32(this._offset),this._offset+=4,e;case 203:return e=this._view.getFloat64(this._offset),this._offset+=8,e;case 204:return e=this._view.getUint8(this._offset),this._offset+=1,e;case 205:return e=this._view.getUint16(this._offset),this._offset+=2,e;case 206:return e=this._view.getUint32(this._offset),this._offset+=4,e;case 207:return i=this._view.getUint32(this._offset)*Math.pow(2,32),o=this._view.getUint32(this._offset+4),this._offset+=8,i+o;case 208:return e=this._view.getInt8(this._offset),this._offset+=1,e;case 209:return e=this._view.getInt16(this._offset),this._offset+=2,e;case 210:return e=this._view.getInt32(this._offset),this._offset+=4,e;case 211:return i=this._view.getInt32(this._offset)*Math.pow(2,32),o=this._view.getUint32(this._offset+4),this._offset+=8,i+o;case 212:return r=this._view.getInt8(this._offset),this._offset+=1,0===r?void(this._offset+=1):[r,this._bin(1)];case 213:return r=this._view.getInt8(this._offset),this._offset+=1,[r,this._bin(2)];case 214:return r=this._view.getInt8(this._offset),this._offset+=1,[r,this._bin(4)];case 215:return r=this._view.getInt8(this._offset),this._offset+=1,0===r?(i=this._view.getInt32(this._offset)*Math.pow(2,32),o=this._view.getUint32(this._offset+4),this._offset+=8,new Date(i+o)):[r,this._bin(8)];case 216:return r=this._view.getInt8(this._offset),this._offset+=1,[r,this._bin(16)];case 217:return n=this._view.getUint8(this._offset),this._offset+=1,this._str(n);case 218:return n=this._view.getUint16(this._offset),this._offset+=2,this._str(n);case 219:return n=this._view.getUint32(this._offset),this._offset+=4,this._str(n);case 220:return n=this._view.getUint16(this._offset),this._offset+=2,this._array(n);case 221:return n=this._view.getUint32(this._offset),this._offset+=4,this._array(n);case 222:return n=this._view.getUint16(this._offset),this._offset+=2,this._map(n);case 223:return n=this._view.getUint32(this._offset),this._offset+=4,this._map(n)}throw new Error("Could not parse")},e.exports=o},function(e,t,n){"use strict";function r(e,t,n){for(var r=0,i=0,o=n.length;i<o;i++)r=n.charCodeAt(i),r<128?e.setUint8(t++,r):r<2048?(e.setUint8(t++,192|r>>6),e.setUint8(t++,128|63&r)):r<55296||r>=57344?(e.setUint8(t++,224|r>>12),e.setUint8(t++,128|r>>6&63),e.setUint8(t++,128|63&r)):(i++,r=65536+((1023&r)<<10|1023&n.charCodeAt(i)),e.setUint8(t++,240|r>>18),e.setUint8(t++,128|r>>12&63),e.setUint8(t++,128|r>>6&63),e.setUint8(t++,128|63&r))}function i(e){for(var t=0,n=0,r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function o(e,t,n){var r=typeof n,s=0,a=0,c=0,u=0,h=0,f=0;if("string"===r){if((h=i(n))<32)e.push(160|h),f=1;else if(h<256)e.push(217,h),f=2;else if(h<65536)e.push(218,h>>8,h),f=3;else{if(!(h<4294967296))throw new Error("String too long");e.push(219,h>>24,h>>16,h>>8,h),f=5}return t.push({_str:n,_length:h,_offset:e.length}),f+h}if("number"===r)return Math.floor(n)===n&&isFinite(n)?n>=0?n<128?(e.push(n),1):n<256?(e.push(204,n),2):n<65536?(e.push(205,n>>8,n),3):n<4294967296?(e.push(206,n>>24,n>>16,n>>8,n),5):(c=n/Math.pow(2,32)>>0,u=n>>>0,e.push(207,c>>24,c>>16,c>>8,c,u>>24,u>>16,u>>8,u),9):n>=-32?(e.push(n),1):n>=-128?(e.push(208,n),2):n>=-32768?(e.push(209,n>>8,n),3):n>=-2147483648?(e.push(210,n>>24,n>>16,n>>8,n),5):(c=Math.floor(n/Math.pow(2,32)),u=n>>>0,e.push(211,c>>24,c>>16,c>>8,c,u>>24,u>>16,u>>8,u),9):(e.push(203),t.push({_float:n,_length:8,_offset:e.length}),9);if("object"===r){if(null===n)return e.push(192),1;if(Array.isArray(n)){if((h=n.length)<16)e.push(144|h),f=1;else if(h<65536)e.push(220,h>>8,h),f=3;else{if(!(h<4294967296))throw new Error("Array too large");e.push(221,h>>24,h>>16,h>>8,h),f=5}for(s=0;s<h;s++)f+=o(e,t,n[s]);return f}if(n instanceof Date){var l=n.getTime();return c=Math.floor(l/Math.pow(2,32)),u=l>>>0,e.push(215,0,c>>24,c>>16,c>>8,c,u>>24,u>>16,u>>8,u),10}if(n instanceof ArrayBuffer){if((h=n.byteLength)<256)e.push(196,h),f=2;else if(h<65536)e.push(197,h>>8,h),f=3;else{if(!(h<4294967296))throw new Error("Buffer too large");e.push(198,h>>24,h>>16,h>>8,h),f=5}return t.push({_bin:n,_length:h,_offset:e.length}),f+h}if("function"==typeof n.toJSON)return o(e,t,n.toJSON());var p=[],d="",v=Object.keys(n);for(s=0,a=v.length;s<a;s++)d=v[s],"function"!=typeof n[d]&&p.push(d);if((h=p.length)<16)e.push(128|h),f=1;else if(h<65536)e.push(222,h>>8,h),f=3;else{if(!(h<4294967296))throw new Error("Object too large");e.push(223,h>>24,h>>16,h>>8,h),f=5}for(s=0;s<h;s++)d=p[s],f+=o(e,t,d),f+=o(e,t,n[d]);return f}if("boolean"===r)return e.push(n?195:194),1;if("undefined"===r)return e.push(212,0,0),3;throw new Error("Could not encode")}function s(e){var t=[],n=[],i=o(t,n,e),s=new ArrayBuffer(i),a=new DataView(s),c=0,u=0,h=-1;n.length>0&&(h=n[0]._offset);for(var f,l=0,p=0,d=0,v=t.length;d<v;d++)if(a.setUint8(u+d,t[d]),d+1===h){if(f=n[c],l=f._length,p=u+h,f._bin)for(var y=new Uint8Array(f._bin),g=0;g<l;g++)a.setUint8(p+g,y[g]);else f._str?r(a,p,f._str):void 0!==f._float&&a.setFloat64(p,f._float);c++,u+=l,n[c]&&(h=n[c]._offset)}return s}e.exports=s},function(e,t,n){"use strict";function r(){function e(e){return t.register(e,null===this)}var t=new i;return e.once=function(e){var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];e.apply(void 0,r),t.remove(n)};t.register(n)},e.remove=function(e){return t.remove(e)},e.invoke=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.invoke.apply(t,e)},e.clear=function(){return t.clear()},e}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.handlers=[]}return e.prototype.register=function(e,t){return void 0===t&&(t=!1),this.handlers.push(e),this},e.prototype.invoke=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.handlers.forEach(function(t){return t.apply(void 0,e)})},e.prototype.remove=function(e){var t=this.handlers.indexOf(e);this.handlers[t]=this.handlers[this.handlers.length-1],this.handlers.pop()},e.prototype.clear=function(){this.handlers=[]},e}();t.EventEmitter=i,t.createSignal=r},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var s=i(n(20)),a=o(n(3)),c=function(e){function t(t,n){void 0===n&&(n=!0);var r=e.call(this,t,void 0,{connect:n})||this;return r._enqueuedCalls=[],r}return r(t,e),t.prototype.onOpenCallback=function(t){if(e.prototype.onOpenCallback.call(this),this.binaryType="arraybuffer",this._enqueuedCalls.length>0){for(var n=0,r=this._enqueuedCalls;n<r.length;n++){var i=r[n],o=i[0],s=i[1];this[o].apply(this,s)}this._enqueuedCalls=[]}},t.prototype.send=function(t){if(this.ws.readyState===s.default.OPEN)return e.prototype.send.call(this,a.encode(t));this._enqueuedCalls.push(["send",[t]])},t}(s.default);t.Connection=c},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(21).createBackoff,s="undefined"!=typeof WebSocket?WebSocket:n(22),a=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r(this,e),this.url=t,this.protocols=n,this.reconnectEnabled=!0,this.listeners={},this.backoff=o(i.backoff||"exponential",i),this.backoff.onReady=this.onBackoffReady.bind(this),(void 0===i.connect||i.connect)&&this.open()}return i(e,[{key:"open",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isReconnect=e;var t=this.ws&&this.ws.binaryType;this.ws=new s(this.url,this.protocols),this.ws.onclose=this.onCloseCallback.bind(this),this.ws.onerror=this.onErrorCallback.bind(this),this.ws.onmessage=this.onMessageCallback.bind(this),this.ws.onopen=this.onOpenCallback.bind(this),t&&(this.ws.binaryType=t)}},{key:"onBackoffReady",value:function(e,t){this.open(!0)}},{key:"onCloseCallback",value:function(e){!this.isReconnect&&this.listeners.onclose&&this.listeners.onclose.apply(null,arguments),this.reconnectEnabled&&e.code<3e3&&this.backoff.backoff()}},{key:"onErrorCallback",value:function(){this.listeners.onerror&&this.listeners.onerror.apply(null,arguments)}},{key:"onMessageCallback",value:function(){this.listeners.onmessage&&this.listeners.onmessage.apply(null,arguments)}},{key:"onOpenCallback",value:function(){this.listeners.onopen&&this.listeners.onopen.apply(null,arguments),this.isReconnect&&this.listeners.onreconnect&&this.listeners.onreconnect.apply(null,arguments),this.isReconnect=!1}},{key:"close",value:function(e,t){void 0===e&&(e=1e3),this.reconnectEnabled=!1,this.ws.close(e,t)}},{key:"send",value:function(e){this.ws.send(e)}},{key:"bufferedAmount",get:function(){return this.ws.bufferedAmount}},{key:"readyState",get:function(){return this.ws.readyState}},{key:"binaryType",get:function(){return this.ws.binaryType},set:function(e){this.ws.binaryType=e}},{key:"extensions",get:function(){return this.ws.extensions},set:function(e){this.ws.extensions=e}},{key:"protocol",get:function(){return this.ws.protocol},set:function(e){this.ws.protocol=e}},{key:"onclose",set:function(e){this.listeners.onclose=e},get:function(){return this.listeners.onclose}},{key:"onerror",set:function(e){this.listeners.onerror=e},get:function(){return this.listeners.onerror}},{key:"onmessage",set:function(e){this.listeners.onmessage=e},get:function(){return this.listeners.onmessage}},{key:"onopen",set:function(e){this.listeners.onopen=e},get:function(){return this.listeners.onopen}},{key:"onreconnect",set:function(e){this.listeners.onreconnect=e},get:function(){return this.listeners.onreconnect}}]),e}();a.CONNECTING=s.CONNECTING,a.OPEN=s.OPEN,a.CLOSING=s.CLOSING,a.CLOSED=s.CLOSED,t.default=a},function(e,t,n){"use strict";function r(e,t){return new i(o[e],t)}function i(e,t){this.func=e,this.attempts=0,this.delay=void 0!==t.initialDelay?t.initialDelay:100}Object.defineProperty(t,"__esModule",{value:!0}),t.createBackoff=r;var o={exponential:function(e,t){return Math.floor(Math.random()*Math.pow(2,e)*t)},fibonacci:function(e,t){var n=1;if(e>n)for(var r=1,n=2,i=2;i<e;i++){var o=r+n;r=n,n=o}return Math.floor(Math.random()*n*t)}};i.prototype.backoff=function(){setTimeout(this.onReady,this.func(++this.attempts,this.delay))}},function(e,t){},function(e,t,n){"use strict";function r(){return a||(a="undefined"!=typeof cc&&cc.sys&&cc.sys.localStorage?cc.sys.localStorage:"undefined"!=typeof window&&window.localStorage?window.localStorage:{cache:{},setItem:function(e,t){this.cache[e]=t},getItem:function(e){this.cache[e]},removeItem:function(e){delete this.cache[e]}}),a}function i(e,t){r().setItem(e,t)}function o(e){r().removeItem(e)}function s(e,t){var n=r().getItem(e);"undefined"!=typeof Promise&&n instanceof Promise?n.then(function(e){return t(e)}):t(n)}Object.defineProperty(t,"__esModule",{value:!0});var a;t.setItem=i,t.removeItem=o,t.getItem=s},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,o&&(s=2&n[0]?o.return:n[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,n[1])).done)return s;switch(o=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,o=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){c.label=n[1];break}if(6===n[0]&&c.label<s[1]){c.label=s[1],s=n;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(n);break}s[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],o=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var i,o,s,a,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a};Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){this.endpoint=e.replace("ws","http")}return e.prototype.register=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return this.check(),[4,this.registerServiceWorker()];case 1:return e.sent(),[4,this.requestNotificationPermission()];case 2:return e.sent(),[2]}})})},e.prototype.registerServiceWorker=function(){return r(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,navigator.serviceWorker.register(this.endpoint+"/push")];case 1:return[2,e.sent()]}})})},e.prototype.requestNotificationPermission=function(){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,window.Notification.requestPermission()];case 1:if("granted"!==(e=t.sent()))throw new Error("Permission not granted for Notification");return[2]}})})},e.prototype.check=function(){if(!("serviceWorker"in navigator))throw new Error("No Service Worker support!");if(!("PushManager"in window))throw new Error("No Push API Support!")},e}();t.Push=o},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=n(26),o=r(n(29)),s=r(n(3)),a=function(){function e(){this.api=new i.StateContainer({})}return e.prototype.getState=function(){return this.api.state},e.prototype.setState=function(e){this.previousState=new Uint8Array(e),this.api.set(s.decode(this.previousState))},e.prototype.patch=function(e){this.previousState=new Uint8Array(o.apply(this.previousState,e)),this.api.set(s.decode(this.previousState))},e.prototype.teardown=function(){this.api.removeAllListeners()},e}();t.FossilDeltaSerializer=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(27);t.StateContainer=r.StateContainer},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(28),i=function(){function e(e){this.listeners=[],this.matcherPlaceholders={":id":/^([a-zA-Z0-9\-_]+)$/,":number":/^([0-9]+)$/,":string":/^(\w+)$/,":axis":/^([xyz])$/,":*":/(.*)/},this.state=e,this.reset()}return e.prototype.set=function(e){var t=r.compare(this.state,e);return this.state=e,this.checkPatches(t,this.listeners,this.defaultListener),t},e.prototype.registerPlaceholder=function(e,t){this.matcherPlaceholders[e]=t},e.prototype.listen=function(e,t,n){var i,o=this;"function"==typeof e?(i=[],t=e):i=e.split("/"),t.length>1&&console.warn(".listen() accepts only one parameter.");var s={callback:t,rawRules:i,rules:i.map(function(e){return"string"==typeof e?0===e.indexOf(":")?o.matcherPlaceholders[e]||o.matcherPlaceholders[":*"]:new RegExp("^"+e+"$"):e})};return 0===i.length?this.defaultListener=s:this.listeners.push(s),n&&this.checkPatches(r.compare({},this.state),[s]),s},e.prototype.removeListener=function(e){for(var t=this.listeners.length-1;t>=0;t--)this.listeners[t]===e&&this.listeners.splice(t,1)},e.prototype.removeAllListeners=function(){this.reset()},e.prototype.checkPatches=function(e,t,n){for(var r=0,i=t.length;r<i;r++)for(var o=t[r],s=e.length-1;s>=0;s--){var a=o&&this.getPathVariables(e[s],o);a&&(o.callback({path:a,rawPath:e[s].path,operation:e[s].operation,value:e[s].value}),e[s].matched=!0)}if(n)for(var s=e.length-1;s>=0;s--)e[s].matched||n.callback(e[s])},e.prototype.getPathVariables=function(e,t){if(e.path.length!==t.rules.length)return!1;for(var n={},r=0,i=t.rules.length;r<i;r++){var o=e.path[r].match(t.rules[r]);if(!o||0===o.length||o.length>2)return!1;":"===t.rawRules[r].substr(0,1)&&(n[t.rawRules[r].substr(1)]=o[1])}return n},e.prototype.reset=function(){this.listeners=[]},e}();t.StateContainer=i},function(e,t,n){"use strict";function r(e,t){var n=[];return s(e,t,n,[]),n}function i(e,t){var n=e.slice();return n.push(t),n}function o(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)e.hasOwnProperty(i)&&r.push(i);return r}function s(e,t,n,r){for(var a=o(t),c=o(e),u=!1,h=c.length-1;h>=0;h--){var f=c[h],l=e[f];if(!t.hasOwnProperty(f)||void 0===t[f]&&void 0!==l&&!1===Array.isArray(t))n.push({operation:"remove",path:i(r,f)}),u=!0;else{var p=t[f];"object"==typeof l&&null!=l&&"object"==typeof p&&null!=p?s(l,p,n,i(r,f)):l!==p&&n.push({operation:"replace",path:i(r,f),value:p,previousValue:l})}}if(u||a.length!=c.length)for(var h=a.length-1;h>=0;h--){var f=a[h];if(!e.hasOwnProperty(f)&&void 0!==t[f]){var p=t[f],d=i(r,f);"object"==typeof p&&null!=p&&s({},p,n,d),n.push({operation:"add",path:d,value:p})}}}Object.defineProperty(t,"__esModule",{value:!0}),t.compare=r},function(e,t){!function(t,n){void 0!==e&&e.exports?e.exports=n():t.fossilDelta=n()}(this,function(){"use strict";function e(){this.a=0,this.b=0,this.i=0,this.z=new Array(s)}function t(e){this.a=e,this.pos=0}function n(){this.a=[]}function r(e){var t,n;for(t=1,n=64;e>=n;t++,n<<=6);return t}function i(e){for(var t=0,n=0,r=0,i=0,o=0,s=e.length;s>=16;)t=t+e[o+0]|0,n=n+e[o+1]|0,r=r+e[o+2]|0,i=i+e[o+3]|0,t=t+e[o+4]|0,n=n+e[o+5]|0,r=r+e[o+6]|0,i=i+e[o+7]|0,t=t+e[o+8]|0,n=n+e[o+9]|0,r=r+e[o+10]|0,i=i+e[o+11]|0,t=t+e[o+12]|0,n=n+e[o+13]|0,r=r+e[o+14]|0,i=i+e[o+15]|0,o+=16,s-=16;for(;s>=4;)t=t+e[o+0]|0,n=n+e[o+1]|0,r=r+e[o+2]|0,i=i+e[o+3]|0,o+=4,s-=4;switch(i=((i+(r<<8)|0)+(n<<16)|0)+(t<<24)|0,s){case 3:i=i+(e[o+2]<<8)|0;case 2:i=i+(e[o+1]<<16)|0;case 1:i=i+(e[o+0]<<24)|0}return i>>>0}var o={},s=16;e.prototype.init=function(e,t){var n,r,i=0,o=0;for(n=0;n<s;n++)r=e[t+n],i=i+r&65535,o=o+(s-n)*r&65535,this.z[n]=r;this.a=65535&i,this.b=65535&o,this.i=0},e.prototype.next=function(e){var t=this.z[this.i];this.z[this.i]=e,this.i=this.i+1&s-1,this.a=this.a-t+e&65535,this.b=this.b-s*t+this.a&65535},e.prototype.value=function(){return(65535&this.a|(65535&this.b)<<16)>>>0};var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~".split("").map(function(e){return e.charCodeAt(0)}),c=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,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,-1,-1,-1,-1,36,-1,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,-1,-1,-1,63,-1];return t.prototype.haveBytes=function(){return this.pos<this.a.length},t.prototype.getByte=function(){var e=this.a[this.pos];if(++this.pos>this.a.length)throw new RangeError("out of bounds");return e},t.prototype.getChar=function(){return String.fromCharCode(this.getByte())},t.prototype.getInt=function(){for(var e,t=0;this.haveBytes()&&(e=c[127&this.getByte()])>=0;)t=(t<<6)+e;return this.pos--,t>>>0},n.prototype.toArray=function(){return this.a},n.prototype.putByte=function(e){this.a.push(255&e)},n.prototype.putChar=function(e){this.putByte(e.charCodeAt(0))},n.prototype.putInt=function(e){var t,n,r=[];if(0===e)return void this.putChar("0");for(t=0;e>0;t++,e>>>=6)r.push(a[63&e]);for(n=t-1;n>=0;n--)this.putByte(r[n])},n.prototype.putArray=function(e,t,n){for(var r=t;r<n;r++)this.a.push(e[r])},o.create=function(t,o){var a,c=new n,u=o.length,h=t.length,f=-1;if(c.putInt(u),c.putChar("\n"),h<=s)return c.putInt(u),c.putChar(":"),c.putArray(o,0,u),c.putInt(i(o)),c.putChar(";"),c.toArray();var l=Math.ceil(h/s),p=new Array(l),d=new Array(l);for(a=0;a<p.length;a++)p[a]=-1;for(a=0;a<d.length;a++)d[a]=-1;var v,y=new e;for(a=0;a<h-s;a+=s)y.init(t,a),v=y.value()%l,p[a/s]=d[v],d[v]=a/s;for(var g,_,b,w,m,C=0;C+s<u;)for(w=0,m=0,y.init(o,C),a=0,b=0;;){var O=250;for(v=y.value()%l,_=d[v];_>=0&&O-- >0;){var S,A,k,I,E,P,x,M;for(g=_*s,I=0,P=g,x=C+a;P<h&&x<u&&t[P]===o[x];I++,P++,x++);for(I--,E=1;E<g&&E<=a&&t[g-E]===o[C+a-E];E++);E--,A=g-E,S=I+E+1,k=a-E,M=r(a-E)+r(S)+r(A)+3,S>=M&&S>b&&(b=S,w=g-E,m=k),_=p[_]}if(b>0){m>0&&(c.putInt(m),c.putChar(":"),c.putArray(o,C,C+m),C+=m),C+=b,c.putInt(b),c.putChar("@"),c.putInt(w),c.putChar(","),w+b-1>f&&(f=w+b-1),b=0;break}if(C+a+s>=u){c.putInt(u-C),c.putChar(":"),c.putArray(o,C,C+u-C),C=u;break}y.next(o[C+a+s]),a++}return C<u&&(c.putInt(u-C),c.putChar(":"),c.putArray(o,C,C+u-C)),c.putInt(i(o)),c.putChar(";"),c.toArray()},o.outputSize=function(e){var n=new t(e),r=n.getInt();if("\n"!==n.getChar())throw new Error("size integer not terminated by '\\n'");return r},o.apply=function(e,r,o){var s,a=0,c=new t(r),u=e.length,h=r.length;if(s=c.getInt(),"\n"!==c.getChar())throw new Error("size integer not terminated by '\\n'");for(var f=new n;c.haveBytes();){var l,p;switch(l=c.getInt(),c.getChar()){case"@":if(p=c.getInt(),c.haveBytes()&&","!==c.getChar())throw new Error("copy command not terminated by ','");if((a+=l)>s)throw new Error("copy exceeds output file size");if(p+l>u)throw new Error("copy extends past end of input");f.putArray(e,p,p+l);break;case":":if((a+=l)>s)throw new Error("insert command gives an output larger than predicted");if(l>h)throw new Error("insert count exceeds size of delta");f.putArray(c.a,c.pos,c.pos+l),c.pos+=l;break;case";":var d=f.toArray();if((!o||!1!==o.verifyChecksum)&&l!==i(d))throw new Error("bad checksum");if(a!==s)throw new Error("generated size does not match predicted size");return d;default:throw new Error("unknown delta operator")}}throw new Error("unterminated delta")},o})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=function(){function e(){}return e.prototype.setState=function(e){this.state.decode(e)},e.prototype.getState=function(){return this.state},e.prototype.patch=function(e){this.state.decode(e)},e.prototype.teardown=function(){},e.prototype.handshake=function(e){if(this.state){(new r.Reflection).decode(e)}else this.state=r.Reflection.decode(e)},e}();t.SchemaSerializer=i},function(e,t,n){"use strict";function r(e){for(var t=0,n=0,r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function i(e,t,n){for(var r=0,i=0,o=n.length;i<o;i++)r=n.charCodeAt(i),r<128?e[t++]=r:r<2048?(e[t++]=192|r>>6,e[t++]=128|63&r):r<55296||r>=57344?(e[t++]=224|r>>12,e[t++]=128|r>>6&63,e[t++]=128|63&r):(i++,r=65536+((1023&r)<<10|1023&n.charCodeAt(i)),e[t++]=240|r>>18,e[t++]=128|r>>12&63,e[t++]=128|r>>6&63,e[t++]=128|63&r)}function o(e,t){e.push(t)}function s(e,t){e.push(t)}function a(e,t){e.push(t),e.push(t>>8)}function c(e,t){e.push(t),e.push(t>>8)}function u(e,t){e.push(t),e.push(t>>8),e.push(t>>16),e.push(t>>24)}function h(e,t){var n=t>>24,r=t>>16,i=t>>8,o=t;e.push(o),e.push(i),e.push(r),e.push(n)}function f(e,t){var n=Math.floor(t/Math.pow(2,32));h(e,t>>>0),h(e,n)}function l(e,t){var n=t/Math.pow(2,32)>>0;h(e,t>>>0),h(e,n)}function p(e,t){v(e,t)}function d(e,t){y(e,t)}function v(e,t){C[0]=t,u(e,m[0])}function y(e,t){O[0]=t,u(e,m[w?0:1]),u(e,m[w?1:0])}function g(e,t){return s(e,t?1:0)}function _(e,t){t||(t="");var n=r(t),o=0;if(n<32)e.push(160|n),o=1;else if(n<256)e.push(217),s(e,n),o=2;else if(n<65536)e.push(218),c(e,n),o=3;else{if(!(n<4294967296))throw new Error("String too long");e.push(219),h(e,n),o=5}return i(e,e.length,t),o+n}function b(e,t){return isNaN(t)?b(e,0):isFinite(t)?t!==(0|t)?(e.push(203),y(e,t),9):t>=0?t<128?(s(e,t),1):t<256?(e.push(204),s(e,t),2):t<65536?(e.push(205),c(e,t),3):t<4294967296?(e.push(206),h(e,t),5):(e.push(207),l(e,t),9):t>=-32?(e.push(t),1):t>=-128?(e.push(208),o(e,t),2):t>=-32768?(e.push(209),a(e,t),3):t>=-2147483648?(e.push(210),u(e,t),5):(e.push(211),f(e,t),9):b(e,t>0?Number.MAX_SAFE_INTEGER:-Number.MAX_SAFE_INTEGER)}Object.defineProperty(t,"__esModule",{value:!0}),t.utf8Write=i,t.int8=o,t.uint8=s,t.int16=a,t.uint16=c,t.int32=u,t.uint32=h,t.int64=f,t.uint64=l,t.float32=p,t.float64=d;var w=!0,m=new Int32Array(2),C=new Float32Array(m.buffer),O=new Float64Array(m.buffer);t.writeFloat32=v,t.writeFloat64=y,t.boolean=g,t.string=_,t.number=b},function(e,t,n){"use strict";function r(e,t,n){for(var r="",i=0,o=t,s=t+n;o<s;o++){var a=e[o];if(0!=(128&a))if(192!=(224&a))if(224!=(240&a)){if(240!=(248&a))throw new Error("Invalid byte "+a.toString(16));i=(7&a)<<18|(63&e[++o])<<12|(63&e[++o])<<6|(63&e[++o])<<0,i>=65536?(i-=65536,r+=String.fromCharCode(55296+(i>>>10),56320+(1023&i))):r+=String.fromCharCode(i)}else r+=String.fromCharCode((15&a)<<12|(63&e[++o])<<6|(63&e[++o])<<0);else r+=String.fromCharCode((31&a)<<6|63&e[++o]);else r+=String.fromCharCode(a)}return r}function i(e,t){return o(e,t)<<24>>24}function o(e,t){return e[t.offset++]}function s(e,t){return a(e,t)<<16>>16}function a(e,t){return e[t.offset++]|e[t.offset++]<<8}function c(e,t){return e[t.offset++]|e[t.offset++]<<8|e[t.offset++]<<16|e[t.offset++]<<24}function u(e,t){return c(e,t)>>>0}function h(e,t){return d(e,t)}function f(e,t){return v(e,t)}function l(e,t){var n=u(e,t);return c(e,t)*Math.pow(2,32)+n}function p(e,t){var n=u(e,t);return u(e,t)*Math.pow(2,32)+n}function d(e,t){return k[0]=c(e,t),I[0]}function v(e,t){return k[A?0:1]=c(e,t),k[A?1:0]=c(e,t),E[0]}function y(e,t){return o(e,t)>0}function g(e,t){var n,i=e[t.offset++];i<192?n=31&i:217===i?n=o(e,t):218===i?n=a(e,t):219===i&&(n=u(e,t));var s=r(e,t.offset,n);return t.offset+=n,s}function _(e,t){var n=e[t.offset];return n<192&&n>160||217===n||218===n||219===n}function b(e,t){var n=e[t.offset++];return n<128?n:202===n?d(e,t):203===n?v(e,t):204===n?o(e,t):205===n?a(e,t):206===n?u(e,t):207===n?p(e,t):208===n?i(e,t):209===n?s(e,t):210===n?c(e,t):211===n?l(e,t):n>223?-1*(255-n+1):void 0}function w(e,t){var n=e[t.offset];return n<128||n>=202&&n<=211}function m(e,t){return e[t.offset]<160}function C(e,t){return e[t.offset]===S.NIL}function O(e,t){return e[t.offset]===S.INDEX_CHANGE}Object.defineProperty(t,"__esModule",{value:!0});var S=n(10);t.int8=i,t.uint8=o,t.int16=s,t.uint16=a,t.int32=c,t.uint32=u,t.float32=h,t.float64=f,t.int64=l,t.uint64=p;var A=!0,k=new Int32Array(2),I=new Float32Array(k.buffer),E=new Float64Array(k.buffer);t.readFloat32=d,t.readFloat64=v,t.boolean=y,t.string=g,t.stringCheck=_,t.number=b,t.numberCheck=w,t.arrayCheck=m,t.nilCheck=C,t.indexChangeCheck=O},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),i=this&&this.__decorate||function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};Object.defineProperty(t,"__esModule",{value:!0});var o=n(12),s=n(0),a=n(1),c=n(2),u=new o.Context,h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),i([o.type("string",u)],t.prototype,"name",void 0),i([o.type("string",u)],t.prototype,"type",void 0),i([o.type("uint8",u)],t.prototype,"referencedType",void 0),t}(s.Schema);t.ReflectionField=h;var f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.fields=new a.ArraySchema,t}return r(t,e),i([o.type("uint8",u)],t.prototype,"id",void 0),i([o.type([h],u)],t.prototype,"fields",void 0),t}(s.Schema);t.ReflectionType=f;var l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.types=new a.ArraySchema,t}return r(t,e),t.encode=function(e){var n=e.constructor,r=new t;r.rootType=n._typeid;var i=n._context.types;for(var o in i){var s=new f;s.id=Number(o),function(e,t){for(var n in t){var i=new h;i.name=n;var o=void 0;if("string"==typeof t[n])o=t[n];else{var s="function"==typeof t[n],a=Array.isArray(t[n]),c=!a&&t[n].map,u=void 0;s?(o="ref",u=t[n]):a?(o="array","string"==typeof t[n][0]?o+=":"+t[n][0]:u=t[n][0]):c&&(o="map","string"==typeof t[n].map?o+=":"+t[n].map:u=t[n].map),i.referencedType=u?u._typeid:255}i.type=o,e.fields.push(i)}r.types.push(e)}(s,i[o]._schema)}return r.encodeAll()},t.decode=function(e){var n=new o.Context,i=new t;i.decode(e);var u=i.types.reduce(function(e,t){return e[t.id]=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(s.Schema),e},{});i.types.forEach(function(e,t){e.fields.forEach(function(t){var r=u[e.id];if(void 0!==t.referencedType){var i=u[t.referencedType];i||(i=t.type.split(":")[1]),0===t.type.indexOf("array")?o.type([i],n)(r.prototype,t.name):0===t.type.indexOf("map")?o.type({map:i},n)(r.prototype,t.name):"ref"===t.type&&o.type(i,n)(r.prototype,t.name)}else o.type(t.type,n)(r.prototype,t.name)})});var h=u[i.rootType],f=new h;for(var l in h._schema){var p=h._schema[l];if("string"!=typeof p){var d="function"==typeof p,v=Array.isArray(p),y=!v&&p.map;f[l]=v?new a.ArraySchema:y?new c.MapSchema:d?new p:void 0}}return f},i([o.type([f],u)],t.prototype,"types",void 0),i([o.type("uint8",u)],t.prototype,"rootType",void 0),t}(s.Schema);t.Reflection=l}])});