@chainstream-io/centrifuge 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,5 @@
4
4
  `):i=r;try{await this._writer.write(i)}catch{this.close()}}};var pn=[-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],kt=class{constructor(r){this.a=r,this.pos=0}haveBytes(){return this.pos<this.a.length}getByte(){let r=this.a[this.pos];if(this.pos++,this.pos>this.a.length)throw new RangeError("out of bounds");return r}getChar(){return String.fromCharCode(this.getByte())}getInt(){let r=0,i;for(;this.haveBytes()&&(i=pn[127&this.getByte()])>=0;)r=(r<<6)+i;return this.pos--,r>>>0}},wt=class{constructor(){this.a=[]}toByteArray(r){return Array.isArray(r)?this.a:new Uint8Array(this.a)}putArray(r,i,n){for(let o=i;o<n;o++)this.a.push(r[o])}};function dn(s){let r=0,i=0,n=0,o=0,t=0,e=s.length;for(;e>=16;)r=r+s[t+0]|0,i=i+s[t+1]|0,n=n+s[t+2]|0,o=o+s[t+3]|0,r=r+s[t+4]|0,i=i+s[t+5]|0,n=n+s[t+6]|0,o=o+s[t+7]|0,r=r+s[t+8]|0,i=i+s[t+9]|0,n=n+s[t+10]|0,o=o+s[t+11]|0,r=r+s[t+12]|0,i=i+s[t+13]|0,n=n+s[t+14]|0,o=o+s[t+15]|0,t+=16,e-=16;for(;e>=4;)r=r+s[t+0]|0,i=i+s[t+1]|0,n=n+s[t+2]|0,o=o+s[t+3]|0,t+=4,e-=4;switch(o=((o+(n<<8)|0)+(i<<16)|0)+(r<<24)|0,e){case 3:o=o+(s[t+2]<<8)|0;case 2:o=o+(s[t+1]<<16)|0;case 1:o=o+(s[t+0]<<24)|0}return o>>>0}function lt(s,r){let i=0,n=new kt(r),o=s.length,t=r.length,e=n.getInt();if(n.getChar()!==`
5
5
  `)throw new Error("size integer not terminated by '\\n'");let l=new wt;for(;n.haveBytes();){let c=n.getInt(),u;switch(n.getChar()){case"@":if(u=n.getInt(),n.haveBytes()&&n.getChar()!==",")throw new Error("copy command not terminated by ','");if(i+=c,i>e)throw new Error("copy exceeds output file size");if(u+c>o)throw new Error("copy extends past end of input");l.putArray(s,u,u+c);break;case":":if(i+=c,i>e)throw new Error("insert command gives an output larger than predicted");if(c>t)throw new Error("insert count exceeds size of delta");l.putArray(n.a,n.pos,n.pos+c),n.pos+=c;break;case";":{let p=l.toByteArray(s);if(c!==dn(p))throw new Error("bad checksum");if(i!==e)throw new Error("generated size does not match predicted size");return p}default:throw new Error("unknown delta operator")}}throw new Error("unterminated delta")}var G=class{name(){return"json"}encodeCommands(r){return r.map(i=>JSON.stringify(i)).join(`
6
6
  `)}decodeReplies(r){return r.trim().split(`
7
- `).map(i=>JSON.parse(i))}applyDeltaIfNeeded(r,i){let n,o;if(r.delta){let t=lt(i,new TextEncoder().encode(r.data));n=JSON.parse(new TextDecoder().decode(t)),o=t}else n=JSON.parse(r.data),o=new TextEncoder().encode(r.data);return{newData:n,newPrevValue:o}}};var Qt=Q(gt()),bn={headers:{},httpHeaders:{},token:"",getToken:null,data:null,getData:null,debug:!1,name:"js",version:"",fetch:null,readableStream:null,websocket:null,eventsource:null,sockjs:null,sockjsOptions:{},emulationEndpoint:"/emulation",minReconnectDelay:500,maxReconnectDelay:2e4,timeout:5e3,maxServerPingDelay:1e4,networkEventTarget:null},T=class extends Error{constructor(r){super(r),this.name=this.constructor.name}},N=class extends Qt.default{constructor(i,n){super();this._reconnectTimeout=null;this._refreshTimeout=null;this._serverPingTimeout=null;this.state="disconnected",this._transportIsOpen=!1,this._endpoint=i,this._emulation=!1,this._transports=[],this._currentTransportIndex=0,this._triedAllTransports=!1,this._transportWasOpen=!1,this._transport=null,this._transportId=0,this._deviceWentOffline=!1,this._transportClosed=!0,this._codec=new G,this._reconnecting=!1,this._reconnectTimeout=null,this._reconnectAttempts=0,this._client=null,this._session="",this._node="",this._subs={},this._serverSubs={},this._commandId=0,this._commands=[],this._batching=!1,this._refreshRequired=!1,this._refreshTimeout=null,this._callbacks={},this._token="",this._data=null,this._dispatchPromise=Promise.resolve(),this._serverPing=0,this._serverPingTimeout=null,this._sendPong=!1,this._promises={},this._promiseId=0,this._debugEnabled=!1,this._networkEventsSet=!1,this._config={...bn,...n},this._configure(),this._debugEnabled?(this.on("state",o=>{this._debug("client state",o.oldState,"->",o.newState)}),this.on("error",o=>{this._debug("client error",o)})):this.on("error",function(){Function.prototype()})}newSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let o=new it(this,i,n);return this._subs[i]=o,o}getSubscription(i){return this._getSub(i)}removeSubscription(i){i&&(i.state!=="unsubscribed"&&i.unsubscribe(),this._removeSubscription(i))}subscriptions(){return this._subs}ready(i){switch(this.state){case"disconnected":return Promise.reject({code:3,message:"client disconnected"});case"connected":return Promise.resolve();default:return new Promise((n,o)=>{let t={resolve:n,reject:o};i&&(t.timeout=setTimeout(()=>{o({code:1,message:"timeout"})},i)),this._promises[this._nextPromiseId()]=t})}}connect(){if(this._isConnected()){this._debug("connect called when already connected");return}if(this._isConnecting()){this._debug("connect called when already connecting");return}this._debug("connect called"),this._reconnectAttempts=0,this._startConnecting()}disconnect(){this._disconnect(0,"disconnect called",!1)}setToken(i){this._token=i}setHeaders(i){this._config.headers=i}setHttpHeaders(i){this._config.httpHeaders=i}async send(i){let n={send:{data:i}};if(await this._methodCall(),!this._transportSendCommands([n]))throw this._createErrorObject(10,"transport write error")}async rpc(i,n){let o={rpc:{method:i,data:n}};return await this._methodCall(),{data:(await this._callPromise(o,e=>e.rpc)).data}}async publish(i,n){let o={publish:{channel:i,data:n}};return await this._methodCall(),await this._callPromise(o,()=>({})),{}}async history(i,n){let o={history:this._getHistoryRequest(i,n)};await this._methodCall();let t=await this._callPromise(o,l=>l.history),e=[];if(t.publications)for(let l=0;l<t.publications.length;l++)e.push(this._getPublicationContext(i,t.publications[l]));return{publications:e,epoch:t.epoch||"",offset:t.offset||0}}async presence(i){let n={presence:{channel:i}};await this._methodCall();let t=(await this._callPromise(n,e=>e.presence)).presence;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let l=t[e],c=l.conn_info,u=l.chan_info;c&&(l.connInfo=c),u&&(l.chanInfo=u)}return{clients:t}}async presenceStats(i){let n={presence_stats:{channel:i}};await this._methodCall();let o=await this._callPromise(n,t=>t.presence_stats);return{numUsers:o.num_users,numClients:o.num_clients}}startBatching(){this._batching=!0}stopBatching(){let i=this;Promise.resolve().then(function(){Promise.resolve().then(function(){i._batching=!1,i._flush()})})}_debug(...i){this._debugEnabled&&Kt("debug",i)}_codecName(){return this._codec.name()}_formatOverride(){}_configure(){if(!("Promise"in globalThis))throw new Error("Promise polyfill required");if(!this._endpoint)throw new Error("endpoint configuration required");if(this._config.token!==null&&(this._token=this._config.token),this._config.data!==null&&(this._data=this._config.data),this._codec=new G,this._formatOverride(),(this._config.debug===!0||typeof localStorage<"u"&&localStorage.getItem("centrifuge.debug"))&&(this._debugEnabled=!0),this._debug("config",this._config),typeof this._endpoint!="string")if(typeof this._endpoint=="object"&&this._endpoint instanceof Array){this._transports=this._endpoint,this._emulation=!0;for(let i in this._transports)if(this._transports.hasOwnProperty(i)){let n=this._transports[i];if(!n.endpoint||!n.transport)throw new Error("malformed transport configuration");let o=n.transport;if(["websocket","http_stream","sse","sockjs","webtransport"].indexOf(o)<0)throw new Error("unsupported transport name: "+o)}}else throw new Error("unsupported url configuration type: only string or array of objects are supported")}_setState(i){if(this.state!==i){this._reconnecting=!1;let n=this.state;return this.state=i,this.emit("state",{newState:i,oldState:n}),!0}return!1}_isDisconnected(){return this.state==="disconnected"}_isConnecting(){return this.state==="connecting"}_isConnected(){return this.state==="connected"}_nextCommandId(){return++this._commandId}_setNetworkEvents(){if(this._networkEventsSet)return;let i=null;this._config.networkEventTarget!==null?i=this._config.networkEventTarget:typeof globalThis.addEventListener<"u"&&(i=globalThis),i&&(i.addEventListener("offline",()=>{this._debug("offline event triggered"),(this.state==="connected"||this.state==="connecting")&&(this._disconnect(1,"transport closed",!0),this._deviceWentOffline=!0)}),i.addEventListener("online",()=>{this._debug("online event triggered"),this.state==="connecting"&&(this._deviceWentOffline&&!this._transportClosed&&(this._deviceWentOffline=!1,this._transportClosed=!0),this._clearReconnectTimeout(),this._startReconnecting())}),this._networkEventsSet=!0)}_getReconnectDelay(){let i=W(this._reconnectAttempts,this._config.minReconnectDelay,this._config.maxReconnectDelay);return this._reconnectAttempts+=1,i}_clearOutgoingRequests(){for(let i in this._callbacks)if(this._callbacks.hasOwnProperty(i)){let n=this._callbacks[i];clearTimeout(n.timeout);let o=n.errback;if(!o)continue;o({error:this._createErrorObject(11,"connection closed")})}this._callbacks={}}_clearConnectedState(){this._client=null,this._clearServerPingTimeout(),this._clearRefreshTimeout();for(let i in this._subs){if(!this._subs.hasOwnProperty(i))continue;let n=this._subs[i];n.state==="subscribed"&&n._setSubscribing(1,"transport closed")}for(let i in this._serverSubs)this._serverSubs.hasOwnProperty(i)&&this.emit("subscribing",{channel:i})}_handleWriteError(i){for(let n of i){let o=n.id;if(!(o in this._callbacks))continue;let t=this._callbacks[o];clearTimeout(this._callbacks[o].timeout),delete this._callbacks[o];let e=t.errback;e({error:this._createErrorObject(10,"transport write error")})}}_transportSendCommands(i){if(!i.length)return!0;if(!this._transport)return!1;try{this._transport.send(this._codec.encodeCommands(i),this._session,this._node)}catch(n){return this._debug("error writing commands",n),this._handleWriteError(i),!1}return!0}_initializeTransport(){let i;this._config.websocket!==null?i=this._config.websocket:typeof globalThis.WebSocket!="function"&&typeof globalThis.WebSocket!="object"||(i=globalThis.WebSocket);let n=null;this._config.sockjs!==null?n=this._config.sockjs:typeof globalThis.SockJS<"u"&&(n=globalThis.SockJS);let o=null;this._config.eventsource!==null?o=this._config.eventsource:typeof globalThis.EventSource<"u"&&(o=globalThis.EventSource);let t=null;this._config.fetch!==null?t=this._config.fetch:typeof globalThis.fetch<"u"&&(t=globalThis.fetch);let e=null;if(this._config.readableStream!==null?e=this._config.readableStream:typeof globalThis.ReadableStream<"u"&&(e=globalThis.ReadableStream),this._emulation){this._currentTransportIndex>=this._transports.length&&(this._triedAllTransports=!0,this._currentTransportIndex=0);let k=0;for(;;){if(k>=this._transports.length)throw new Error("no supported transport found");let x=this._transports[this._currentTransportIndex],R=x.transport,S=x.endpoint;if(R==="websocket"){if(this._debug("trying websocket transport"),this._transport=new V(S,{websocket:i,httpHeaders:this._config.httpHeaders}),!this._transport.supported()){this._debug("websocket transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="webtransport"){if(this._debug("trying webtransport transport"),this._transport=new st(S,{webtransport:globalThis.WebTransport,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("webtransport transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="http_stream"){if(this._debug("trying http_stream transport"),this._transport=new rt(S,{fetch:t,readableStream:e,emulationEndpoint:this._config.emulationEndpoint,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("http_stream transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="sse"){if(this._debug("trying sse transport"),this._transport=new ct(S,{eventsource:o,fetch:t,emulationEndpoint:this._config.emulationEndpoint}),!this._transport.supported()){this._debug("sse transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="sockjs"){if(this._debug("trying sockjs"),this._transport=new ot(S,{sockjs:n,sockjsOptions:this._config.sockjsOptions}),!this._transport.supported()){this._debug("sockjs transport not available"),this._currentTransportIndex++,k++;continue}}else throw new Error("unknown transport "+R);break}}else{if(Gt(this._endpoint,"http"))throw new Error("Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport");if(this._debug("client will use websocket"),this._transport=new V(this._endpoint,{websocket:i,httpHeaders:this._config.httpHeaders}),!this._transport.supported())throw new Error("WebSocket constructor not found, make sure it is available globally or passed as a dependency in Centrifuge options")}let l=this,c=this._transport,u=this._nextTransportId();l._debug("id of transport",u);let p=!1,y=[];if(this._transport.emulation()){let k=l._sendConnect(!0);y.push(k)}this._setNetworkEvents();let w=this._codec.encodeCommands(y);this._transportClosed=!1;let g;g=setTimeout(function(){c.close()},this._config.timeout),this._transport.initialize(this._codecName(),{onOpen:function(){if(g&&(clearTimeout(g),g=null),l._transportId!=u){l._debug("open callback from non-actual transport"),c.close();return}p=!0,l._debug(c.subName(),"transport open"),!c.emulation()&&(l._transportIsOpen=!0,l._transportWasOpen=!0,l.startBatching(),l._sendConnect(!1),l._sendSubscribeCommands(),l.stopBatching(),l.emit("__centrifuge_debug:connect_frame_sent",{}))},onError:function(k){if(l._transportId!=u){l._debug("error callback from non-actual transport");return}l._debug("transport level error",k)},onClose:function(k){if(g&&(clearTimeout(g),g=null),l._transportId!=u){l._debug("close callback from non-actual transport");return}l._debug(c.subName(),"transport closed"),l._transportClosed=!0,l._transportIsOpen=!1;let x="connection closed",R=!0,S=0;if(k&&"code"in k&&k.code&&(S=k.code),k&&k.reason)try{let yt=JSON.parse(k.reason);x=yt.reason,R=yt.reconnect}catch{x=k.reason,(S>=3500&&S<4e3||S>=4500&&S<5e3)&&(R=!1)}S<3e3?(S===1009?(S=3,x="message size limit exceeded",R=!1):(S=1,x="transport closed"),l._emulation&&!l._transportWasOpen&&(l._currentTransportIndex++,l._currentTransportIndex>=l._transports.length&&(l._triedAllTransports=!0,l._currentTransportIndex=0))):l._transportWasOpen=!0,l._isConnecting()&&!p&&l.emit("error",{type:"transport",error:{code:2,message:"transport closed"},transport:c.name()}),l._reconnecting=!1,l._disconnect(S,x,R)},onMessage:function(k){l._dataReceived(k)}},w),l.emit("__centrifuge_debug:transport_initialized",{})}_sendConnect(i){let n=this._constructConnectCommand(),o=this;return this._call(n,i).then(t=>{let e=t.reply.connect;o._connectResponse(e),t.next&&t.next()},t=>{o._connectError(t.error),t.next&&t.next()}),n}_startReconnecting(){if(this._debug("start reconnecting"),!this._isConnecting()){this._debug("stop reconnecting: client not in connecting state");return}if(this._reconnecting){this._debug("reconnect already in progress, return from reconnect routine");return}if(this._transportClosed===!1){this._debug("waiting for transport close");return}this._reconnecting=!0;let i=this._token==="";if(!(this._refreshRequired||i&&this._config.getToken!==null)){this._config.getData?this._config.getData().then(t=>{this._isConnecting()&&(this._data=t,this._initializeTransport())}).catch(t=>this._handleGetDataError(t)):this._initializeTransport();return}let o=this;this._getToken().then(function(t){if(o._isConnecting()){if(t==null||t==null){o._failUnauthorized();return}o._token=t,o._debug("connection token refreshed"),o._config.getData?o._config.getData().then(function(e){o._isConnecting()&&(o._data=e,o._initializeTransport())}).catch(e=>o._handleGetDataError(e)):o._initializeTransport()}}).catch(function(t){if(!o._isConnecting())return;if(t instanceof T){o._failUnauthorized();return}o.emit("error",{type:"connectToken",error:{code:5,message:t!==void 0?t.toString():""}});let e=o._getReconnectDelay();o._debug("error on getting connection token, reconnect after "+e+" milliseconds",t),o._reconnecting=!1,o._reconnectTimeout=setTimeout(()=>{o._startReconnecting()},e)})}_handleGetDataError(i){if(i instanceof T){this._failUnauthorized();return}this.emit("error",{type:"connectData",error:{code:12,message:i?.toString()||""}});let n=this._getReconnectDelay();this._debug("error on getting connect data, reconnect after "+n+" milliseconds",i),this._reconnecting=!1,this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},n)}_connectError(i){this.state==="connecting"&&(i.code===109&&(this._refreshRequired=!0),i.code<100||i.temporary===!0||i.code===109?(this.emit("error",{type:"connect",error:i}),this._debug("closing transport due to connect error"),this._disconnect(i.code,i.message,!0)):this._disconnect(i.code,i.message,!1))}_scheduleReconnect(){if(!this._isConnecting())return;let i=!1;this._emulation&&!this._transportWasOpen&&!this._triedAllTransports&&(i=!0);let n=this._getReconnectDelay();i&&(n=0),this._debug("reconnect after "+n+" milliseconds"),this._clearReconnectTimeout(),this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},n)}_constructConnectCommand(){let i={};this._token&&(i.token=this._token),this._data&&(i.data=this._data),this._config.name&&(i.name=this._config.name),this._config.version&&(i.version=this._config.version),Object.keys(this._config.headers).length>0&&(i.headers=this._config.headers);let n={},o=!1;for(let t in this._serverSubs)if(this._serverSubs.hasOwnProperty(t)&&this._serverSubs[t].recoverable){o=!0;let e={recover:!0};this._serverSubs[t].offset&&(e.offset=this._serverSubs[t].offset),this._serverSubs[t].epoch&&(e.epoch=this._serverSubs[t].epoch),n[t]=e}return o&&(i.subs=n),{connect:i}}_getHistoryRequest(i,n){let o={channel:i};return n!==void 0&&(n.since&&(o.since={offset:n.since.offset},n.since.epoch&&(o.since.epoch=n.since.epoch)),n.limit!==void 0&&(o.limit=n.limit),n.reverse===!0&&(o.reverse=!0)),o}_methodCall(){return this._isConnected()?Promise.resolve():new Promise((i,n)=>{let o=setTimeout(function(){n({code:1,message:"timeout"})},this._config.timeout);this._promises[this._nextPromiseId()]={timeout:o,resolve:i,reject:n}})}_callPromise(i,n){return new Promise((o,t)=>{this._call(i,!1).then(e=>{let l=n(e.reply);o(l),e.next?.()},e=>{t(e.error),e.next?.()})})}_dataReceived(i){this._serverPing>0&&this._waitServerPing();let n=this._codec.decodeReplies(i);this._dispatchPromise=this._dispatchPromise.then(()=>{let o;this._dispatchPromise=new Promise(t=>{o=t}),this._dispatchSynchronized(n,o)})}_dispatchSynchronized(i,n){let o=Promise.resolve();for(let t in i)i.hasOwnProperty(t)&&(o=o.then(()=>this._dispatchReply(i[t])));o=o.then(()=>{n()})}_dispatchReply(i){let n,o=new Promise(e=>{n=e});if(i==null)return this._debug("dispatch: got undefined or null reply"),n(),o;let t=i.id;return t&&t>0?this._handleReply(i,n):i.push?this._handlePush(i.push,n):this._handleServerPing(n),o}_call(i,n){return new Promise((o,t)=>{i.id=this._nextCommandId(),this._registerCall(i.id,o,t),n||this._addCommand(i)})}_startConnecting(){this._debug("start connecting"),this._setState("connecting")&&this.emit("connecting",{code:0,reason:"connect called"}),this._client=null,this._startReconnecting()}_disconnect(i,n,o){if(this._isDisconnected())return;this._transportIsOpen=!1;let t=this.state;this._reconnecting=!1;let e={code:i,reason:n},l=!1;if(o?l=this._setState("connecting"):(l=this._setState("disconnected"),this._rejectPromises({code:3,message:"disconnected"})),this._clearOutgoingRequests(),t==="connecting"&&this._clearReconnectTimeout(),t==="connected"&&this._clearConnectedState(),l&&(this._isConnecting()?this.emit("connecting",e):this.emit("disconnected",e)),this._transport){this._debug("closing existing transport");let c=this._transport;this._transport=null,c.close(),this._transportClosed=!0,this._nextTransportId()}else this._debug("no transport to close");this._scheduleReconnect()}_failUnauthorized(){this._disconnect(1,"unauthorized",!1)}_getToken(){return this._debug("get connection token"),this._config.getToken?this._config.getToken({}):(this.emit("error",{type:"configuration",error:{code:12,message:"token expired but no getToken function set in the configuration"}}),Promise.reject(new T("")))}_refresh(){let i=this._client,n=this;this._getToken().then(function(o){if(i!==n._client)return;if(!o){n._failUnauthorized();return}if(n._token=o,n._debug("connection token refreshed"),!n._isConnected())return;let t={refresh:{token:n._token}};n._call(t,!1).then(e=>{let l=e.reply.refresh;n._refreshResponse(l),e.next&&e.next()},e=>{n._refreshError(e.error),e.next&&e.next()})}).catch(function(o){if(n._isConnected()){if(o instanceof T){n._failUnauthorized();return}n.emit("error",{type:"refreshToken",error:{code:6,message:o!==void 0?o.toString():""}}),n._refreshTimeout=setTimeout(()=>n._refresh(),n._getRefreshRetryDelay())}})}_refreshError(i){i.code<100||i.temporary===!0?(this.emit("error",{type:"refresh",error:i}),this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())):this._disconnect(i.code,i.message,!1)}_getRefreshRetryDelay(){return W(0,5e3,1e4)}_refreshResponse(i){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),i.expires&&(this._client=i.client,this._refreshTimeout=setTimeout(()=>this._refresh(),J(i.ttl)))}_removeSubscription(i){i!==null&&delete this._subs[i.channel]}_unsubscribe(i){if(!this._transportIsOpen)return Promise.resolve();let o={unsubscribe:{channel:i.channel}},t=this;return new Promise((l,c)=>{this._call(o,!1).then(u=>{l(),u.next&&u.next()},u=>{l(),u.next&&u.next(),t._disconnect(4,"unsubscribe error",!0)})})}_getSub(i){let n=this._subs[i];return n||null}_isServerSub(i){return this._serverSubs[i]!==void 0}_sendSubscribeCommands(){let i=[];for(let n in this._subs){if(!this._subs.hasOwnProperty(n))continue;let o=this._subs[n];if(o._inflight!==!0&&o.state==="subscribing"){let t=o._subscribe();t&&i.push(t)}}return i}_connectResponse(i){if(this._transportIsOpen=!0,this._transportWasOpen=!0,this._reconnectAttempts=0,this._refreshRequired=!1,this._isConnected())return;this._client=i.client,this._setState("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout),i.expires&&(this._refreshTimeout=setTimeout(()=>this._refresh(),J(i.ttl))),this._session=i.session,this._node=i.node,this.startBatching(),this._sendSubscribeCommands(),this.stopBatching();let n={client:i.client,transport:this._transport.subName()};i.data&&(n.data=i.data),this.emit("connected",n),this._resolvePromises(),this._processServerSubs(i.subs||{}),i.ping&&i.ping>0?(this._serverPing=i.ping*1e3,this._sendPong=i.pong===!0,this._waitServerPing()):this._serverPing=0}_processServerSubs(i){for(let n in i){if(!i.hasOwnProperty(n))continue;let o=i[n];this._serverSubs[n]={offset:o.offset,epoch:o.epoch,recoverable:o.recoverable||!1};let t=this._getSubscribeContext(n,o);this.emit("subscribed",t)}for(let n in i){if(!i.hasOwnProperty(n))continue;let o=i[n];if(o.recovered){let t=o.publications;if(t&&t.length>0)for(let e in t)t.hasOwnProperty(e)&&this._handlePublication(n,t[e])}}for(let n in this._serverSubs)this._serverSubs.hasOwnProperty(n)&&(i[n]||(this.emit("unsubscribed",{channel:n}),delete this._serverSubs[n]))}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearReconnectTimeout(){this._reconnectTimeout!==null&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=null)}_clearServerPingTimeout(){this._serverPingTimeout!==null&&(clearTimeout(this._serverPingTimeout),this._serverPingTimeout=null)}_waitServerPing(){this._config.maxServerPingDelay!==0&&this._isConnected()&&(this._clearServerPingTimeout(),this._serverPingTimeout=setTimeout(()=>{this._isConnected()&&this._disconnect(2,"no ping",!0)},this._serverPing+this._config.maxServerPingDelay))}_getSubscribeContext(i,n){let o={channel:i,positioned:!1,recoverable:!1,wasRecovering:!1,recovered:!1,hasRecoveredPublications:!1};n.recovered&&(o.recovered=!0),n.positioned&&(o.positioned=!0),n.recoverable&&(o.recoverable=!0),n.was_recovering&&(o.wasRecovering=!0);let t="";"epoch"in n&&(t=n.epoch);let e=0;return"offset"in n&&(e=n.offset),(o.positioned||o.recoverable)&&(o.streamPosition={offset:e,epoch:t}),Array.isArray(n.publications)&&n.publications.length>0&&(o.hasRecoveredPublications=!0),n.data&&(o.data=n.data),o}_handleReply(i,n){let o=i.id;if(!(o in this._callbacks)){n();return}let t=this._callbacks[o];if(clearTimeout(this._callbacks[o].timeout),delete this._callbacks[o],Zt(i)){let e=t.errback;if(!e){n();return}let l={code:i.error.code,message:i.error.message||"",temporary:i.error.temporary||!1};e({error:l,next:n})}else{let e=t.callback;if(!e)return;e({reply:i,next:n})}}_handleJoin(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("join",t)}return}o._handleJoin(n)}_handleLeave(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("leave",t)}return}o._handleLeave(n)}_handleUnsubscribe(i,n){let o=this._getSub(i);if(!o){this._isServerSub(i)&&(delete this._serverSubs[i],this.emit("unsubscribed",{channel:i}));return}n.code<2500?o._setUnsubscribed(n.code,n.reason,!1):o._setSubscribing(n.code,n.reason)}_handleSubscribe(i,n){this._serverSubs[i]={offset:n.offset,epoch:n.epoch,recoverable:n.recoverable||!1},this.emit("subscribed",this._getSubscribeContext(i,n))}_handleDisconnect(i){let n=i.code,o=!0;(n>=3500&&n<4e3||n>=4500&&n<5e3)&&(o=!1),this._disconnect(n,i.reason,o)}_getPublicationContext(i,n){let o={channel:i,data:n.data};return n.offset&&(o.offset=n.offset),n.info&&(o.info=this._getJoinLeaveContext(n.info)),n.tags&&(o.tags=n.tags),o}_getJoinLeaveContext(i){let n={client:i.client,user:i.user},o=i.conn_info;o&&(n.connInfo=o);let t=i.chan_info;return t&&(n.chanInfo=t),n}_handlePublication(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t=this._getPublicationContext(i,n);this.emit("publication",t),n.offset!==void 0&&(this._serverSubs[i].offset=n.offset)}return}o._handlePublication(n)}_handleMessage(i){this.emit("message",{data:i.data})}_handleServerPing(i){if(this._sendPong){let n={};this._transportSendCommands([n])}i()}_handlePush(i,n){let o=i.channel;i.pub?this._handlePublication(o,i.pub):i.message?this._handleMessage(i.message):i.join?this._handleJoin(o,i.join):i.leave?this._handleLeave(o,i.leave):i.unsubscribe?this._handleUnsubscribe(o,i.unsubscribe):i.subscribe?this._handleSubscribe(o,i.subscribe):i.disconnect&&this._handleDisconnect(i.disconnect),n()}_flush(){let i=this._commands.slice(0);this._commands=[],this._transportSendCommands(i)}_createErrorObject(i,n,o){let t={code:i,message:n};return o&&(t.temporary=!0),t}_registerCall(i,n,o){this._callbacks[i]={callback:n,errback:o,timeout:null},this._callbacks[i].timeout=setTimeout(()=>{delete this._callbacks[i],vt(o)&&o({error:this._createErrorObject(1,"timeout")})},this._config.timeout)}_addCommand(i){this._batching?this._commands.push(i):this._transportSendCommands([i])}_nextPromiseId(){return++this._promiseId}_nextTransportId(){return++this._transportId}_resolvePromises(){for(let i in this._promises)this._promises.hasOwnProperty(i)&&(this._promises[i].timeout&&clearTimeout(this._promises[i].timeout),this._promises[i].resolve(),delete this._promises[i])}_rejectPromises(i){for(let n in this._promises)this._promises.hasOwnProperty(n)&&(this._promises[n].timeout&&clearTimeout(this._promises[n].timeout),this._promises[n].reject(i),delete this._promises[n])}};N.SubscriptionState=nt;N.State=et;N.UnauthorizedError=T;var z=Q(qt());var q=Q(qt()),a=q.Reader,b=q.Writer,h=q.util,f=q.roots.default||(q.roots.default={}),pt=f.centrifugal=(()=>{let s={};return s.centrifuge=function(){let r={};return r.protocol=function(){let i={};return i.Error=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.message="",n.prototype.temporary=!1,n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(8).uint32(t.code),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&e.uint32(18).string(t.message),t.temporary!=null&&Object.hasOwnProperty.call(t,"temporary")&&e.uint32(24).bool(t.temporary),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Error;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.code=t.uint32();break}case 2:{c.message=t.string();break}case 3:{c.temporary=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.message!=null&&t.hasOwnProperty("message")&&!h.isString(t.message)?"message: string expected":t.temporary!=null&&t.hasOwnProperty("temporary")&&typeof t.temporary!="boolean"?"temporary: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Error"},n}(),i.EmulationRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.node="",n.prototype.session="",n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(10).string(t.node),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(18).string(t.session),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(26).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.EmulationRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.node=t.string();break}case 2:{c.session=t.string();break}case 3:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.EmulationRequest"},n}(),i.Command=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.id=0,n.prototype.connect=null,n.prototype.subscribe=null,n.prototype.unsubscribe=null,n.prototype.publish=null,n.prototype.presence=null,n.prototype.presence_stats=null,n.prototype.history=null,n.prototype.ping=null,n.prototype.send=null,n.prototype.rpc=null,n.prototype.refresh=null,n.prototype.sub_refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.ConnectRequest.encode(t.connect,e.uint32(34).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subscribe,e.uint32(42).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.UnsubscribeRequest.encode(t.unsubscribe,e.uint32(50).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&f.centrifugal.centrifuge.protocol.PublishRequest.encode(t.publish,e.uint32(58).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&f.centrifugal.centrifuge.protocol.PresenceRequest.encode(t.presence,e.uint32(66).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&f.centrifugal.centrifuge.protocol.PresenceStatsRequest.encode(t.presence_stats,e.uint32(74).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&f.centrifugal.centrifuge.protocol.HistoryRequest.encode(t.history,e.uint32(82).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&f.centrifugal.centrifuge.protocol.PingRequest.encode(t.ping,e.uint32(90).fork()).ldelim(),t.send!=null&&Object.hasOwnProperty.call(t,"send")&&f.centrifugal.centrifuge.protocol.SendRequest.encode(t.send,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&f.centrifugal.centrifuge.protocol.RPCRequest.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.RefreshRequest.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&f.centrifugal.centrifuge.protocol.SubRefreshRequest.encode(t.sub_refresh,e.uint32(122).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Command;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.id=t.uint32();break}case 4:{c.connect=f.centrifugal.centrifuge.protocol.ConnectRequest.decode(t,t.uint32());break}case 5:{c.subscribe=f.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break}case 6:{c.unsubscribe=f.centrifugal.centrifuge.protocol.UnsubscribeRequest.decode(t,t.uint32());break}case 7:{c.publish=f.centrifugal.centrifuge.protocol.PublishRequest.decode(t,t.uint32());break}case 8:{c.presence=f.centrifugal.centrifuge.protocol.PresenceRequest.decode(t,t.uint32());break}case 9:{c.presence_stats=f.centrifugal.centrifuge.protocol.PresenceStatsRequest.decode(t,t.uint32());break}case 10:{c.history=f.centrifugal.centrifuge.protocol.HistoryRequest.decode(t,t.uint32());break}case 11:{c.ping=f.centrifugal.centrifuge.protocol.PingRequest.decode(t,t.uint32());break}case 12:{c.send=f.centrifugal.centrifuge.protocol.SendRequest.decode(t,t.uint32());break}case 13:{c.rpc=f.centrifugal.centrifuge.protocol.RPCRequest.decode(t,t.uint32());break}case 14:{c.refresh=f.centrifugal.centrifuge.protocol.RefreshRequest.decode(t,t.uint32());break}case 15:{c.sub_refresh=f.centrifugal.centrifuge.protocol.SubRefreshRequest.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!h.isInteger(t.id))return"id: integer expected";if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.ConnectRequest.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.UnsubscribeRequest.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=f.centrifugal.centrifuge.protocol.PublishRequest.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=f.centrifugal.centrifuge.protocol.PresenceRequest.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=f.centrifugal.centrifuge.protocol.PresenceStatsRequest.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=f.centrifugal.centrifuge.protocol.HistoryRequest.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=f.centrifugal.centrifuge.protocol.PingRequest.verify(t.ping);if(e)return"ping."+e}if(t.send!=null&&t.hasOwnProperty("send")){let e=f.centrifugal.centrifuge.protocol.SendRequest.verify(t.send);if(e)return"send."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=f.centrifugal.centrifuge.protocol.RPCRequest.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.RefreshRequest.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=f.centrifugal.centrifuge.protocol.SubRefreshRequest.verify(t.sub_refresh);if(e)return"sub_refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Command"},n}(),i.Reply=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.id=0,n.prototype.error=null,n.prototype.push=null,n.prototype.connect=null,n.prototype.subscribe=null,n.prototype.unsubscribe=null,n.prototype.publish=null,n.prototype.presence=null,n.prototype.presence_stats=null,n.prototype.history=null,n.prototype.ping=null,n.prototype.rpc=null,n.prototype.refresh=null,n.prototype.sub_refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.error!=null&&Object.hasOwnProperty.call(t,"error")&&f.centrifugal.centrifuge.protocol.Error.encode(t.error,e.uint32(18).fork()).ldelim(),t.push!=null&&Object.hasOwnProperty.call(t,"push")&&f.centrifugal.centrifuge.protocol.Push.encode(t.push,e.uint32(34).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.ConnectResult.encode(t.connect,e.uint32(42).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subscribe,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.UnsubscribeResult.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&f.centrifugal.centrifuge.protocol.PublishResult.encode(t.publish,e.uint32(66).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&f.centrifugal.centrifuge.protocol.PresenceResult.encode(t.presence,e.uint32(74).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&f.centrifugal.centrifuge.protocol.PresenceStatsResult.encode(t.presence_stats,e.uint32(82).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&f.centrifugal.centrifuge.protocol.HistoryResult.encode(t.history,e.uint32(90).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&f.centrifugal.centrifuge.protocol.PingResult.encode(t.ping,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&f.centrifugal.centrifuge.protocol.RPCResult.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.RefreshResult.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&f.centrifugal.centrifuge.protocol.SubRefreshResult.encode(t.sub_refresh,e.uint32(122).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Reply;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.id=t.uint32();break}case 2:{c.error=f.centrifugal.centrifuge.protocol.Error.decode(t,t.uint32());break}case 4:{c.push=f.centrifugal.centrifuge.protocol.Push.decode(t,t.uint32());break}case 5:{c.connect=f.centrifugal.centrifuge.protocol.ConnectResult.decode(t,t.uint32());break}case 6:{c.subscribe=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break}case 7:{c.unsubscribe=f.centrifugal.centrifuge.protocol.UnsubscribeResult.decode(t,t.uint32());break}case 8:{c.publish=f.centrifugal.centrifuge.protocol.PublishResult.decode(t,t.uint32());break}case 9:{c.presence=f.centrifugal.centrifuge.protocol.PresenceResult.decode(t,t.uint32());break}case 10:{c.presence_stats=f.centrifugal.centrifuge.protocol.PresenceStatsResult.decode(t,t.uint32());break}case 11:{c.history=f.centrifugal.centrifuge.protocol.HistoryResult.decode(t,t.uint32());break}case 12:{c.ping=f.centrifugal.centrifuge.protocol.PingResult.decode(t,t.uint32());break}case 13:{c.rpc=f.centrifugal.centrifuge.protocol.RPCResult.decode(t,t.uint32());break}case 14:{c.refresh=f.centrifugal.centrifuge.protocol.RefreshResult.decode(t,t.uint32());break}case 15:{c.sub_refresh=f.centrifugal.centrifuge.protocol.SubRefreshResult.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!h.isInteger(t.id))return"id: integer expected";if(t.error!=null&&t.hasOwnProperty("error")){let e=f.centrifugal.centrifuge.protocol.Error.verify(t.error);if(e)return"error."+e}if(t.push!=null&&t.hasOwnProperty("push")){let e=f.centrifugal.centrifuge.protocol.Push.verify(t.push);if(e)return"push."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.ConnectResult.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.UnsubscribeResult.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=f.centrifugal.centrifuge.protocol.PublishResult.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=f.centrifugal.centrifuge.protocol.PresenceResult.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=f.centrifugal.centrifuge.protocol.PresenceStatsResult.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=f.centrifugal.centrifuge.protocol.HistoryResult.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=f.centrifugal.centrifuge.protocol.PingResult.verify(t.ping);if(e)return"ping."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=f.centrifugal.centrifuge.protocol.RPCResult.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.RefreshResult.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=f.centrifugal.centrifuge.protocol.SubRefreshResult.verify(t.sub_refresh);if(e)return"sub_refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Reply"},n}(),i.Push=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.pub=null,n.prototype.join=null,n.prototype.leave=null,n.prototype.unsubscribe=null,n.prototype.message=null,n.prototype.subscribe=null,n.prototype.connect=null,n.prototype.disconnect=null,n.prototype.refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(18).string(t.channel),t.pub!=null&&Object.hasOwnProperty.call(t,"pub")&&f.centrifugal.centrifuge.protocol.Publication.encode(t.pub,e.uint32(34).fork()).ldelim(),t.join!=null&&Object.hasOwnProperty.call(t,"join")&&f.centrifugal.centrifuge.protocol.Join.encode(t.join,e.uint32(42).fork()).ldelim(),t.leave!=null&&Object.hasOwnProperty.call(t,"leave")&&f.centrifugal.centrifuge.protocol.Leave.encode(t.leave,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.Unsubscribe.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&f.centrifugal.centrifuge.protocol.Message.encode(t.message,e.uint32(66).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.Subscribe.encode(t.subscribe,e.uint32(74).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.Connect.encode(t.connect,e.uint32(82).fork()).ldelim(),t.disconnect!=null&&Object.hasOwnProperty.call(t,"disconnect")&&f.centrifugal.centrifuge.protocol.Disconnect.encode(t.disconnect,e.uint32(90).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.Refresh.encode(t.refresh,e.uint32(98).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Push;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 2:{c.channel=t.string();break}case 4:{c.pub=f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32());break}case 5:{c.join=f.centrifugal.centrifuge.protocol.Join.decode(t,t.uint32());break}case 6:{c.leave=f.centrifugal.centrifuge.protocol.Leave.decode(t,t.uint32());break}case 7:{c.unsubscribe=f.centrifugal.centrifuge.protocol.Unsubscribe.decode(t,t.uint32());break}case 8:{c.message=f.centrifugal.centrifuge.protocol.Message.decode(t,t.uint32());break}case 9:{c.subscribe=f.centrifugal.centrifuge.protocol.Subscribe.decode(t,t.uint32());break}case 10:{c.connect=f.centrifugal.centrifuge.protocol.Connect.decode(t,t.uint32());break}case 11:{c.disconnect=f.centrifugal.centrifuge.protocol.Disconnect.decode(t,t.uint32());break}case 12:{c.refresh=f.centrifugal.centrifuge.protocol.Refresh.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel))return"channel: string expected";if(t.pub!=null&&t.hasOwnProperty("pub")){let e=f.centrifugal.centrifuge.protocol.Publication.verify(t.pub);if(e)return"pub."+e}if(t.join!=null&&t.hasOwnProperty("join")){let e=f.centrifugal.centrifuge.protocol.Join.verify(t.join);if(e)return"join."+e}if(t.leave!=null&&t.hasOwnProperty("leave")){let e=f.centrifugal.centrifuge.protocol.Leave.verify(t.leave);if(e)return"leave."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.Unsubscribe.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.message!=null&&t.hasOwnProperty("message")){let e=f.centrifugal.centrifuge.protocol.Message.verify(t.message);if(e)return"message."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.Subscribe.verify(t.subscribe);if(e)return"subscribe."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.Connect.verify(t.connect);if(e)return"connect."+e}if(t.disconnect!=null&&t.hasOwnProperty("disconnect")){let e=f.centrifugal.centrifuge.protocol.Disconnect.verify(t.disconnect);if(e)return"disconnect."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.Refresh.verify(t.refresh);if(e)return"refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Push"},n}(),i.ClientInfo=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.user="",n.prototype.client="",n.prototype.conn_info=h.newBuffer([]),n.prototype.chan_info=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.user!=null&&Object.hasOwnProperty.call(t,"user")&&e.uint32(10).string(t.user),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(18).string(t.client),t.conn_info!=null&&Object.hasOwnProperty.call(t,"conn_info")&&e.uint32(26).bytes(t.conn_info),t.chan_info!=null&&Object.hasOwnProperty.call(t,"chan_info")&&e.uint32(34).bytes(t.chan_info),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ClientInfo;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.user=t.string();break}case 2:{c.client=t.string();break}case 3:{c.conn_info=t.bytes();break}case 4:{c.chan_info=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.user!=null&&t.hasOwnProperty("user")&&!h.isString(t.user)?"user: string expected":t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client)?"client: string expected":t.conn_info!=null&&t.hasOwnProperty("conn_info")&&!(t.conn_info&&typeof t.conn_info.length=="number"||h.isString(t.conn_info))?"conn_info: buffer expected":t.chan_info!=null&&t.hasOwnProperty("chan_info")&&!(t.chan_info&&typeof t.chan_info.length=="number"||h.isString(t.chan_info))?"chan_info: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ClientInfo"},n}(),i.Publication=function(){function n(o){if(this.tags={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.prototype.info=null,n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.tags=h.emptyObject,n.prototype.delta=!1,n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.prototype.channel="",n.encode=function(t,e){if(e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(34).bytes(t.data),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(42).fork()).ldelim(),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(48).uint64(t.offset),t.tags!=null&&Object.hasOwnProperty.call(t,"tags"))for(let l=Object.keys(t.tags),c=0;c<l.length;++c)e.uint32(58).fork().uint32(10).string(l[c]).uint32(18).string(t.tags[l[c]]).ldelim();return t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(64).bool(t.delta),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(72).int64(t.time),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(82).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Publication,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 4:{c.data=t.bytes();break}case 5:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}case 6:{c.offset=t.uint64();break}case 7:{c.tags===h.emptyObject&&(c.tags={});let w=t.uint32()+t.pos;for(u="",p="";t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=t.string();break;default:t.skipType(g&7);break}}c.tags[u]=p;break}case 8:{c.delta=t.bool();break}case 9:{c.time=t.int64();break}case 10:{c.channel=t.string();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}if(t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.tags!=null&&t.hasOwnProperty("tags")){if(!h.isObject(t.tags))return"tags: object expected";let e=Object.keys(t.tags);for(let l=0;l<e.length;++l)if(!h.isString(t.tags[e[l]]))return"tags: string{k:string} expected"}return t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean"?"delta: boolean expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Publication"},n}(),i.Join=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=b.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(10).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Join;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Join"},n}(),i.Leave=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=b.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(10).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Leave;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Leave"},n}(),i.Unsubscribe=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(16).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&e.uint32(26).string(t.reason),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Unsubscribe;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 2:{c.code=t.uint32();break}case 3:{c.reason=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!h.isString(t.reason)?"reason: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Unsubscribe"},n}(),i.Subscribe=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(8).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(34).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(40).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(48).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(58).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Subscribe;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.recoverable=t.bool();break}case 4:{c.epoch=t.string();break}case 5:{c.offset=t.uint64();break}case 6:{c.positioned=t.bool();break}case 7:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean"?"recoverable: boolean expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Subscribe"},n}(),i.Message=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Message;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Message"},n}(),i.Connect=function(){function n(o){if(this.subs={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.ping=0,n.prototype.pong=!1,n.prototype.session="",n.prototype.node="",n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(26).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(34).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();return t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(40).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(48).uint32(t.ttl),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&e.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&e.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(88).int64(t.time),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Connect,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.data=t.bytes();break}case 4:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 5:{c.expires=t.bool();break}case 6:{c.ttl=t.uint32();break}case 7:{c.ping=t.uint32();break}case 8:{c.pong=t.bool();break}case 9:{c.session=t.string();break}case 10:{c.node=t.string();break}case 11:{c.time=t.int64();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[l]]);if(c)return"subs."+c}}return t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":t.ping!=null&&t.hasOwnProperty("ping")&&!h.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Connect"},n}(),i.Disconnect=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.prototype.reconnect=!1,n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(8).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&e.uint32(18).string(t.reason),t.reconnect!=null&&Object.hasOwnProperty.call(t,"reconnect")&&e.uint32(24).bool(t.reconnect),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Disconnect;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.code=t.uint32();break}case 2:{c.reason=t.string();break}case 3:{c.reconnect=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!h.isString(t.reason)?"reason: string expected":t.reconnect!=null&&t.hasOwnProperty("reconnect")&&typeof t.reconnect!="boolean"?"reconnect: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Disconnect"},n}(),i.Refresh=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Refresh;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Refresh"},n}(),i.ConnectRequest=function(){function n(o){if(this.subs={},this.headers={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.token="",n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.name="",n.prototype.version="",n.prototype.headers=h.emptyObject,n.encode=function(t,e){if(e||(e=b.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(10).string(t.token),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(18).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(26).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&e.uint32(34).string(t.name),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(42).string(t.version),t.headers!=null&&Object.hasOwnProperty.call(t,"headers"))for(let l=Object.keys(t.headers),c=0;c<l.length;++c)e.uint32(50).fork().uint32(10).string(l[c]).uint32(18).string(t.headers[l[c]]).ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ConnectRequest,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.token=t.string();break}case 2:{c.data=t.bytes();break}case 3:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 4:{c.name=t.string();break}case 5:{c.version=t.string();break}case 6:{c.headers===h.emptyObject&&(c.headers={});let w=t.uint32()+t.pos;for(u="",p="";t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=t.string();break;default:t.skipType(g&7);break}}c.headers[u]=p;break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token))return"token: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subs[e[l]]);if(c)return"subs."+c}}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.headers!=null&&t.hasOwnProperty("headers")){if(!h.isObject(t.headers))return"headers: object expected";let e=Object.keys(t.headers);for(let l=0;l<e.length;++l)if(!h.isString(t.headers[e[l]]))return"headers: string{k:string} expected"}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectRequest"},n}(),i.ConnectResult=function(){function n(o){if(this.subs={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.ping=0,n.prototype.pong=!1,n.prototype.session="",n.prototype.node="",n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(32).uint32(t.ttl),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(42).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(50).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();return t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&e.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&e.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(88).int64(t.time),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ConnectResult,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.expires=t.bool();break}case 4:{c.ttl=t.uint32();break}case 5:{c.data=t.bytes();break}case 6:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 7:{c.ping=t.uint32();break}case 8:{c.pong=t.bool();break}case 9:{c.session=t.string();break}case 10:{c.node=t.string();break}case 11:{c.time=t.int64();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl))return"ttl: integer expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[l]]);if(c)return"subs."+c}}return t.ping!=null&&t.hasOwnProperty("ping")&&!h.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectResult"},n}(),i.RefreshRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.token="",n.encode=function(t,e){return e||(e=b.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(10).string(t.token),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RefreshRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.token=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshRequest"},n}(),i.RefreshResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(32).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RefreshResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.expires=t.bool();break}case 4:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client)?"client: string expected":t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version)?"version: string expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshResult"},n}(),i.SubscribeRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.token="",n.prototype.recover=!1,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.data=h.newBuffer([]),n.prototype.positioned=!1,n.prototype.recoverable=!1,n.prototype.join_leave=!1,n.prototype.delta="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(18).string(t.token),t.recover!=null&&Object.hasOwnProperty.call(t,"recover")&&e.uint32(24).bool(t.recover),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(50).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(56).uint64(t.offset),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(66).bytes(t.data),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(72).bool(t.positioned),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(80).bool(t.recoverable),t.join_leave!=null&&Object.hasOwnProperty.call(t,"join_leave")&&e.uint32(88).bool(t.join_leave),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(98).string(t.delta),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubscribeRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.token=t.string();break}case 3:{c.recover=t.bool();break}case 6:{c.epoch=t.string();break}case 7:{c.offset=t.uint64();break}case 8:{c.data=t.bytes();break}case 9:{c.positioned=t.bool();break}case 10:{c.recoverable=t.bool();break}case 11:{c.join_leave=t.bool();break}case 12:{c.delta=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":t.recover!=null&&t.hasOwnProperty("recover")&&typeof t.recover!="boolean"?"recover: boolean expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean"?"recoverable: boolean expected":t.join_leave!=null&&t.hasOwnProperty("join_leave")&&typeof t.join_leave!="boolean"?"join_leave: boolean expected":t.delta!=null&&t.hasOwnProperty("delta")&&!h.isString(t.delta)?"delta: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeRequest"},n}(),i.SubscribeResult=function(){function n(o){if(this.publications=[],o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.publications=h.emptyArray,n.prototype.recovered=!1,n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=h.newBuffer([]),n.prototype.was_recovering=!1,n.prototype.delta=!1,n.encode=function(t,e){if(e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(24).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(50).string(t.epoch),t.publications!=null&&t.publications.length)for(let l=0;l<t.publications.length;++l)f.centrifugal.centrifuge.protocol.Publication.encode(t.publications[l],e.uint32(58).fork()).ldelim();return t.recovered!=null&&Object.hasOwnProperty.call(t,"recovered")&&e.uint32(64).bool(t.recovered),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(72).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(80).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(90).bytes(t.data),t.was_recovering!=null&&Object.hasOwnProperty.call(t,"was_recovering")&&e.uint32(96).bool(t.was_recovering),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(104).bool(t.delta),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubscribeResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}case 3:{c.recoverable=t.bool();break}case 6:{c.epoch=t.string();break}case 7:{c.publications&&c.publications.length||(c.publications=[]),c.publications.push(f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 8:{c.recovered=t.bool();break}case 9:{c.offset=t.uint64();break}case 10:{c.positioned=t.bool();break}case 11:{c.data=t.bytes();break}case 12:{c.was_recovering=t.bool();break}case 13:{c.delta=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl))return"ttl: integer expected";if(t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean")return"recoverable: boolean expected";if(t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch))return"epoch: string expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let e=0;e<t.publications.length;++e){let l=f.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(l)return"publications."+l}}return t.recovered!=null&&t.hasOwnProperty("recovered")&&typeof t.recovered!="boolean"?"recovered: boolean expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.was_recovering!=null&&t.hasOwnProperty("was_recovering")&&typeof t.was_recovering!="boolean"?"was_recovering: boolean expected":t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean"?"delta: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeResult"},n}(),i.SubRefreshRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.token="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(18).string(t.token),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubRefreshRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.token=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshRequest"},n}(),i.SubRefreshResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubRefreshResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshResult"},n}(),i.UnsubscribeRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.UnsubscribeRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeRequest"},n}(),i.UnsubscribeResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.UnsubscribeResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeResult"},n}(),i.PublishRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(18).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PublishRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishRequest"},n}(),i.PublishResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PublishResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishResult"},n}(),i.PresenceRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceRequest"},n}(),i.PresenceResult=function(){function n(o){if(this.presence={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.presence=h.emptyObject,n.encode=function(t,e){if(e||(e=b.create()),t.presence!=null&&Object.hasOwnProperty.call(t,"presence"))for(let l=Object.keys(t.presence),c=0;c<l.length;++c)e.uint32(10).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.presence[l[c]],e.uint32(18).fork()).ldelim().ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceResult,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.presence===h.emptyObject&&(c.presence={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.presence[u]=p;break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.presence!=null&&t.hasOwnProperty("presence")){if(!h.isObject(t.presence))return"presence: object expected";let e=Object.keys(t.presence);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.presence[e[l]]);if(c)return"presence."+c}}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceResult"},n}(),i.PresenceStatsRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceStatsRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsRequest"},n}(),i.PresenceStatsResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.num_clients=0,n.prototype.num_users=0,n.encode=function(t,e){return e||(e=b.create()),t.num_clients!=null&&Object.hasOwnProperty.call(t,"num_clients")&&e.uint32(8).uint32(t.num_clients),t.num_users!=null&&Object.hasOwnProperty.call(t,"num_users")&&e.uint32(16).uint32(t.num_users),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceStatsResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.num_clients=t.uint32();break}case 2:{c.num_users=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.num_clients!=null&&t.hasOwnProperty("num_clients")&&!h.isInteger(t.num_clients)?"num_clients: integer expected":t.num_users!=null&&t.hasOwnProperty("num_users")&&!h.isInteger(t.num_users)?"num_users: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsResult"},n}(),i.StreamPosition=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.epoch="",n.encode=function(t,e){return e||(e=b.create()),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(8).uint64(t.offset),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(18).string(t.epoch),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.StreamPosition;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.offset=t.uint64();break}case 2:{c.epoch=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.StreamPosition"},n}(),i.HistoryRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.limit=0,n.prototype.since=null,n.prototype.reverse=!1,n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.limit!=null&&Object.hasOwnProperty.call(t,"limit")&&e.uint32(56).int32(t.limit),t.since!=null&&Object.hasOwnProperty.call(t,"since")&&f.centrifugal.centrifuge.protocol.StreamPosition.encode(t.since,e.uint32(66).fork()).ldelim(),t.reverse!=null&&Object.hasOwnProperty.call(t,"reverse")&&e.uint32(72).bool(t.reverse),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.HistoryRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 7:{c.limit=t.int32();break}case 8:{c.since=f.centrifugal.centrifuge.protocol.StreamPosition.decode(t,t.uint32());break}case 9:{c.reverse=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel))return"channel: string expected";if(t.limit!=null&&t.hasOwnProperty("limit")&&!h.isInteger(t.limit))return"limit: integer expected";if(t.since!=null&&t.hasOwnProperty("since")){let e=f.centrifugal.centrifuge.protocol.StreamPosition.verify(t.since);if(e)return"since."+e}return t.reverse!=null&&t.hasOwnProperty("reverse")&&typeof t.reverse!="boolean"?"reverse: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryRequest"},n}(),i.HistoryResult=function(){function n(o){if(this.publications=[],o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.publications=h.emptyArray,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.encode=function(t,e){if(e||(e=b.create()),t.publications!=null&&t.publications.length)for(let l=0;l<t.publications.length;++l)f.centrifugal.centrifuge.protocol.Publication.encode(t.publications[l],e.uint32(10).fork()).ldelim();return t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(18).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(24).uint64(t.offset),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.HistoryResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.publications&&c.publications.length||(c.publications=[]),c.publications.push(f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 2:{c.epoch=t.string();break}case 3:{c.offset=t.uint64();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let e=0;e<t.publications.length;++e){let l=f.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(l)return"publications."+l}}return t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryResult"},n}(),i.PingRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PingRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingRequest"},n}(),i.PingResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PingResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingResult"},n}(),i.RPCRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.prototype.method="",n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),t.method!=null&&Object.hasOwnProperty.call(t,"method")&&e.uint32(18).string(t.method),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RPCRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}case 2:{c.method=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.method!=null&&t.hasOwnProperty("method")&&!h.isString(t.method)?"method: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCRequest"},n}(),i.RPCResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RPCResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCResult"},n}(),i.SendRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SendRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SendRequest"},n}(),i}(),r}(),s})();var Ke=pt.centrifuge.protocol.Command,At=pt.centrifuge.protocol.Reply,mn=pt.centrifuge.protocol.EmulationRequest,dt=class{name(){return"protobuf"}encodeEmulationRequest(r){let i=z.Writer.create();return mn.encode(r,i),i.finish()}encodeCommands(r){let i=z.Writer.create();for(let n of r)i.fork(),Ke.encodeDelimited(n,i);return i.finish()}encodeReplies(r){let i=z.Writer.create();for(let n of r)i.fork(),At.encodeDelimited(n,i);return i.finish()}decodeReplies(r){let i=[],n=z.Reader.create(new Uint8Array(r));for(;n.pos<n.len;){let o=At.decodeDelimited(n);i.push(o)}return i}decodeCommands(r){let i=[],n=z.Reader.create(new Uint8Array(r));for(;n.pos<n.len;){let o=Ke.decodeDelimited(n);i.push(o)}return i}decodeReply(r){let i=z.Reader.create(new Uint8Array(r));for(;i.pos<i.len;)return At.decodeDelimited(i),{ok:!0,pos:i.pos};return{ok:!1}}applyDeltaIfNeeded(r,i){let n,o;if(r.delta){let t=lt(i,r.data);n=new Uint8Array(t),o=t}else n=r.data,o=r.data;return{newData:n,newPrevValue:o}}};var bt=class extends N{_formatOverride(){this._codec=new dt}};globalThis.Centrifuge=bt;})();
7
+ `).map(i=>JSON.parse(i))}applyDeltaIfNeeded(r,i){let n,o;if(r.delta){let t=lt(i,new TextEncoder().encode(r.data));n=JSON.parse(new TextDecoder().decode(t)),o=t}else n=JSON.parse(r.data),o=new TextEncoder().encode(r.data);return{newData:n,newPrevValue:o}}};var Qt=Q(gt()),bn={headers:{},httpHeaders:{},token:"",getToken:null,data:null,getData:null,debug:!1,name:"js",version:"",fetch:null,readableStream:null,websocket:null,eventsource:null,sockjs:null,sockjsOptions:{},emulationEndpoint:"/emulation",minReconnectDelay:500,maxReconnectDelay:2e4,timeout:5e3,maxServerPingDelay:1e4,networkEventTarget:null},T=class extends Error{constructor(r){super(r),this.name=this.constructor.name}},N=class extends Qt.default{constructor(i,n){super();this._reconnectTimeout=null;this._refreshTimeout=null;this._serverPingTimeout=null;this.state="disconnected",this._transportIsOpen=!1,this._endpoint=i,this._emulation=!1,this._transports=[],this._currentTransportIndex=0,this._triedAllTransports=!1,this._transportWasOpen=!1,this._transport=null,this._transportId=0,this._deviceWentOffline=!1,this._transportClosed=!0,this._codec=new G,this._reconnecting=!1,this._reconnectTimeout=null,this._reconnectAttempts=0,this._client=null,this._session="",this._node="",this._subs={},this._serverSubs={},this._commandId=0,this._commands=[],this._batching=!1,this._refreshRequired=!1,this._refreshTimeout=null,this._callbacks={},this._token="",this._data=null,this._dispatchPromise=Promise.resolve(),this._serverPing=0,this._serverPingTimeout=null,this._sendPong=!1,this._promises={},this._promiseId=0,this._debugEnabled=!1,this._networkEventsSet=!1,this._config={...bn,...n},this._configure(),this._debugEnabled?(this.on("state",o=>{this._debug("client state",o.oldState,"->",o.newState)}),this.on("error",o=>{this._debug("client error",o)})):this.on("error",function(){Function.prototype()})}newSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let o=new it(this,i,n);return this._subs[i]=o,o}getSubscription(i){return this._getSub(i)}removeSubscription(i){i&&(i.state!=="unsubscribed"&&i.unsubscribe(),this._removeSubscription(i))}subscriptions(){return this._subs}ready(i){switch(this.state){case"disconnected":return Promise.reject({code:3,message:"client disconnected"});case"connected":return Promise.resolve();default:return new Promise((n,o)=>{let t={resolve:n,reject:o};i&&(t.timeout=setTimeout(()=>{o({code:1,message:"timeout"})},i)),this._promises[this._nextPromiseId()]=t})}}connect(){if(this._isConnected()){this._debug("connect called when already connected");return}if(this._isConnecting()){this._debug("connect called when already connecting");return}this._debug("connect called"),this._reconnectAttempts=0,this._startConnecting()}disconnect(){this._disconnect(0,"disconnect called",!1)}setToken(i){this._token=i}setHeaders(i){this._config.headers=i}setHttpHeaders(i){this._config.httpHeaders=i}setWebsocket(i){this._config.websocket=i}async send(i){let n={send:{data:i}};if(await this._methodCall(),!this._transportSendCommands([n]))throw this._createErrorObject(10,"transport write error")}async rpc(i,n){let o={rpc:{method:i,data:n}};return await this._methodCall(),{data:(await this._callPromise(o,e=>e.rpc)).data}}async publish(i,n){let o={publish:{channel:i,data:n}};return await this._methodCall(),await this._callPromise(o,()=>({})),{}}async history(i,n){let o={history:this._getHistoryRequest(i,n)};await this._methodCall();let t=await this._callPromise(o,l=>l.history),e=[];if(t.publications)for(let l=0;l<t.publications.length;l++)e.push(this._getPublicationContext(i,t.publications[l]));return{publications:e,epoch:t.epoch||"",offset:t.offset||0}}async presence(i){let n={presence:{channel:i}};await this._methodCall();let t=(await this._callPromise(n,e=>e.presence)).presence;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let l=t[e],c=l.conn_info,u=l.chan_info;c&&(l.connInfo=c),u&&(l.chanInfo=u)}return{clients:t}}async presenceStats(i){let n={presence_stats:{channel:i}};await this._methodCall();let o=await this._callPromise(n,t=>t.presence_stats);return{numUsers:o.num_users,numClients:o.num_clients}}startBatching(){this._batching=!0}stopBatching(){let i=this;Promise.resolve().then(function(){Promise.resolve().then(function(){i._batching=!1,i._flush()})})}_debug(...i){this._debugEnabled&&Kt("debug",i)}_codecName(){return this._codec.name()}_formatOverride(){}_configure(){if(!("Promise"in globalThis))throw new Error("Promise polyfill required");if(!this._endpoint)throw new Error("endpoint configuration required");if(this._config.token!==null&&(this._token=this._config.token),this._config.data!==null&&(this._data=this._config.data),this._codec=new G,this._formatOverride(),(this._config.debug===!0||typeof localStorage<"u"&&localStorage.getItem("centrifuge.debug"))&&(this._debugEnabled=!0),this._debug("config",this._config),typeof this._endpoint!="string")if(typeof this._endpoint=="object"&&this._endpoint instanceof Array){this._transports=this._endpoint,this._emulation=!0;for(let i in this._transports)if(this._transports.hasOwnProperty(i)){let n=this._transports[i];if(!n.endpoint||!n.transport)throw new Error("malformed transport configuration");let o=n.transport;if(["websocket","http_stream","sse","sockjs","webtransport"].indexOf(o)<0)throw new Error("unsupported transport name: "+o)}}else throw new Error("unsupported url configuration type: only string or array of objects are supported")}_setState(i){if(this.state!==i){this._reconnecting=!1;let n=this.state;return this.state=i,this.emit("state",{newState:i,oldState:n}),!0}return!1}_isDisconnected(){return this.state==="disconnected"}_isConnecting(){return this.state==="connecting"}_isConnected(){return this.state==="connected"}_nextCommandId(){return++this._commandId}_setNetworkEvents(){if(this._networkEventsSet)return;let i=null;this._config.networkEventTarget!==null?i=this._config.networkEventTarget:typeof globalThis.addEventListener<"u"&&(i=globalThis),i&&(i.addEventListener("offline",()=>{this._debug("offline event triggered"),(this.state==="connected"||this.state==="connecting")&&(this._disconnect(1,"transport closed",!0),this._deviceWentOffline=!0)}),i.addEventListener("online",()=>{this._debug("online event triggered"),this.state==="connecting"&&(this._deviceWentOffline&&!this._transportClosed&&(this._deviceWentOffline=!1,this._transportClosed=!0),this._clearReconnectTimeout(),this._startReconnecting())}),this._networkEventsSet=!0)}_getReconnectDelay(){let i=W(this._reconnectAttempts,this._config.minReconnectDelay,this._config.maxReconnectDelay);return this._reconnectAttempts+=1,i}_clearOutgoingRequests(){for(let i in this._callbacks)if(this._callbacks.hasOwnProperty(i)){let n=this._callbacks[i];clearTimeout(n.timeout);let o=n.errback;if(!o)continue;o({error:this._createErrorObject(11,"connection closed")})}this._callbacks={}}_clearConnectedState(){this._client=null,this._clearServerPingTimeout(),this._clearRefreshTimeout();for(let i in this._subs){if(!this._subs.hasOwnProperty(i))continue;let n=this._subs[i];n.state==="subscribed"&&n._setSubscribing(1,"transport closed")}for(let i in this._serverSubs)this._serverSubs.hasOwnProperty(i)&&this.emit("subscribing",{channel:i})}_handleWriteError(i){for(let n of i){let o=n.id;if(!(o in this._callbacks))continue;let t=this._callbacks[o];clearTimeout(this._callbacks[o].timeout),delete this._callbacks[o];let e=t.errback;e({error:this._createErrorObject(10,"transport write error")})}}_transportSendCommands(i){if(!i.length)return!0;if(!this._transport)return!1;try{this._transport.send(this._codec.encodeCommands(i),this._session,this._node)}catch(n){return this._debug("error writing commands",n),this._handleWriteError(i),!1}return!0}_initializeTransport(){let i;this._config.websocket!==null?i=this._config.websocket:typeof globalThis.WebSocket!="function"&&typeof globalThis.WebSocket!="object"||(i=globalThis.WebSocket);let n=null;this._config.sockjs!==null?n=this._config.sockjs:typeof globalThis.SockJS<"u"&&(n=globalThis.SockJS);let o=null;this._config.eventsource!==null?o=this._config.eventsource:typeof globalThis.EventSource<"u"&&(o=globalThis.EventSource);let t=null;this._config.fetch!==null?t=this._config.fetch:typeof globalThis.fetch<"u"&&(t=globalThis.fetch);let e=null;if(this._config.readableStream!==null?e=this._config.readableStream:typeof globalThis.ReadableStream<"u"&&(e=globalThis.ReadableStream),this._emulation){this._currentTransportIndex>=this._transports.length&&(this._triedAllTransports=!0,this._currentTransportIndex=0);let k=0;for(;;){if(k>=this._transports.length)throw new Error("no supported transport found");let x=this._transports[this._currentTransportIndex],R=x.transport,S=x.endpoint;if(R==="websocket"){if(this._debug("trying websocket transport"),this._transport=new V(S,{websocket:i,httpHeaders:this._config.httpHeaders}),!this._transport.supported()){this._debug("websocket transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="webtransport"){if(this._debug("trying webtransport transport"),this._transport=new st(S,{webtransport:globalThis.WebTransport,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("webtransport transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="http_stream"){if(this._debug("trying http_stream transport"),this._transport=new rt(S,{fetch:t,readableStream:e,emulationEndpoint:this._config.emulationEndpoint,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("http_stream transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="sse"){if(this._debug("trying sse transport"),this._transport=new ct(S,{eventsource:o,fetch:t,emulationEndpoint:this._config.emulationEndpoint}),!this._transport.supported()){this._debug("sse transport not available"),this._currentTransportIndex++,k++;continue}}else if(R==="sockjs"){if(this._debug("trying sockjs"),this._transport=new ot(S,{sockjs:n,sockjsOptions:this._config.sockjsOptions}),!this._transport.supported()){this._debug("sockjs transport not available"),this._currentTransportIndex++,k++;continue}}else throw new Error("unknown transport "+R);break}}else{if(Gt(this._endpoint,"http"))throw new Error("Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport");if(this._debug("client will use websocket"),this._transport=new V(this._endpoint,{websocket:i,httpHeaders:this._config.httpHeaders}),!this._transport.supported())throw new Error("WebSocket constructor not found, make sure it is available globally or passed as a dependency in Centrifuge options")}let l=this,c=this._transport,u=this._nextTransportId();l._debug("id of transport",u);let p=!1,y=[];if(this._transport.emulation()){let k=l._sendConnect(!0);y.push(k)}this._setNetworkEvents();let w=this._codec.encodeCommands(y);this._transportClosed=!1;let g;g=setTimeout(function(){c.close()},this._config.timeout),this._transport.initialize(this._codecName(),{onOpen:function(){if(g&&(clearTimeout(g),g=null),l._transportId!=u){l._debug("open callback from non-actual transport"),c.close();return}p=!0,l._debug(c.subName(),"transport open"),!c.emulation()&&(l._transportIsOpen=!0,l._transportWasOpen=!0,l.startBatching(),l._sendConnect(!1),l._sendSubscribeCommands(),l.stopBatching(),l.emit("__centrifuge_debug:connect_frame_sent",{}))},onError:function(k){if(l._transportId!=u){l._debug("error callback from non-actual transport");return}l._debug("transport level error",k)},onClose:function(k){if(g&&(clearTimeout(g),g=null),l._transportId!=u){l._debug("close callback from non-actual transport");return}l._debug(c.subName(),"transport closed"),l._transportClosed=!0,l._transportIsOpen=!1;let x="connection closed",R=!0,S=0;if(k&&"code"in k&&k.code&&(S=k.code),k&&k.reason)try{let yt=JSON.parse(k.reason);x=yt.reason,R=yt.reconnect}catch{x=k.reason,(S>=3500&&S<4e3||S>=4500&&S<5e3)&&(R=!1)}S<3e3?(S===1009?(S=3,x="message size limit exceeded",R=!1):(S=1,x="transport closed"),l._emulation&&!l._transportWasOpen&&(l._currentTransportIndex++,l._currentTransportIndex>=l._transports.length&&(l._triedAllTransports=!0,l._currentTransportIndex=0))):l._transportWasOpen=!0,l._isConnecting()&&!p&&l.emit("error",{type:"transport",error:{code:2,message:"transport closed"},transport:c.name()}),l._reconnecting=!1,l._disconnect(S,x,R)},onMessage:function(k){l._dataReceived(k)}},w),l.emit("__centrifuge_debug:transport_initialized",{})}_sendConnect(i){let n=this._constructConnectCommand(),o=this;return this._call(n,i).then(t=>{let e=t.reply.connect;o._connectResponse(e),t.next&&t.next()},t=>{o._connectError(t.error),t.next&&t.next()}),n}_startReconnecting(){if(this._debug("start reconnecting"),!this._isConnecting()){this._debug("stop reconnecting: client not in connecting state");return}if(this._reconnecting){this._debug("reconnect already in progress, return from reconnect routine");return}if(this._transportClosed===!1){this._debug("waiting for transport close");return}this._reconnecting=!0;let i=this._token==="";if(!(this._refreshRequired||i&&this._config.getToken!==null)){this._config.getData?this._config.getData().then(t=>{this._isConnecting()&&(this._data=t,this._initializeTransport())}).catch(t=>this._handleGetDataError(t)):this._initializeTransport();return}let o=this;this._getToken().then(function(t){if(o._isConnecting()){if(t==null||t==null){o._failUnauthorized();return}o._token=t,o._debug("connection token refreshed"),o._config.getData?o._config.getData().then(function(e){o._isConnecting()&&(o._data=e,o._initializeTransport())}).catch(e=>o._handleGetDataError(e)):o._initializeTransport()}}).catch(function(t){if(!o._isConnecting())return;if(t instanceof T){o._failUnauthorized();return}o.emit("error",{type:"connectToken",error:{code:5,message:t!==void 0?t.toString():""}});let e=o._getReconnectDelay();o._debug("error on getting connection token, reconnect after "+e+" milliseconds",t),o._reconnecting=!1,o._reconnectTimeout=setTimeout(()=>{o._startReconnecting()},e)})}_handleGetDataError(i){if(i instanceof T){this._failUnauthorized();return}this.emit("error",{type:"connectData",error:{code:12,message:i?.toString()||""}});let n=this._getReconnectDelay();this._debug("error on getting connect data, reconnect after "+n+" milliseconds",i),this._reconnecting=!1,this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},n)}_connectError(i){this.state==="connecting"&&(i.code===109&&(this._refreshRequired=!0),i.code<100||i.temporary===!0||i.code===109?(this.emit("error",{type:"connect",error:i}),this._debug("closing transport due to connect error"),this._disconnect(i.code,i.message,!0)):this._disconnect(i.code,i.message,!1))}_scheduleReconnect(){if(!this._isConnecting())return;let i=!1;this._emulation&&!this._transportWasOpen&&!this._triedAllTransports&&(i=!0);let n=this._getReconnectDelay();i&&(n=0),this._debug("reconnect after "+n+" milliseconds"),this._clearReconnectTimeout(),this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},n)}_constructConnectCommand(){let i={};this._token&&(i.token=this._token),this._data&&(i.data=this._data),this._config.name&&(i.name=this._config.name),this._config.version&&(i.version=this._config.version),Object.keys(this._config.headers).length>0&&(i.headers=this._config.headers);let n={},o=!1;for(let t in this._serverSubs)if(this._serverSubs.hasOwnProperty(t)&&this._serverSubs[t].recoverable){o=!0;let e={recover:!0};this._serverSubs[t].offset&&(e.offset=this._serverSubs[t].offset),this._serverSubs[t].epoch&&(e.epoch=this._serverSubs[t].epoch),n[t]=e}return o&&(i.subs=n),{connect:i}}_getHistoryRequest(i,n){let o={channel:i};return n!==void 0&&(n.since&&(o.since={offset:n.since.offset},n.since.epoch&&(o.since.epoch=n.since.epoch)),n.limit!==void 0&&(o.limit=n.limit),n.reverse===!0&&(o.reverse=!0)),o}_methodCall(){return this._isConnected()?Promise.resolve():new Promise((i,n)=>{let o=setTimeout(function(){n({code:1,message:"timeout"})},this._config.timeout);this._promises[this._nextPromiseId()]={timeout:o,resolve:i,reject:n}})}_callPromise(i,n){return new Promise((o,t)=>{this._call(i,!1).then(e=>{let l=n(e.reply);o(l),e.next?.()},e=>{t(e.error),e.next?.()})})}_dataReceived(i){this._serverPing>0&&this._waitServerPing();let n=this._codec.decodeReplies(i);this._dispatchPromise=this._dispatchPromise.then(()=>{let o;this._dispatchPromise=new Promise(t=>{o=t}),this._dispatchSynchronized(n,o)})}_dispatchSynchronized(i,n){let o=Promise.resolve();for(let t in i)i.hasOwnProperty(t)&&(o=o.then(()=>this._dispatchReply(i[t])));o=o.then(()=>{n()})}_dispatchReply(i){let n,o=new Promise(e=>{n=e});if(i==null)return this._debug("dispatch: got undefined or null reply"),n(),o;let t=i.id;return t&&t>0?this._handleReply(i,n):i.push?this._handlePush(i.push,n):this._handleServerPing(n),o}_call(i,n){return new Promise((o,t)=>{i.id=this._nextCommandId(),this._registerCall(i.id,o,t),n||this._addCommand(i)})}_startConnecting(){this._debug("start connecting"),this._setState("connecting")&&this.emit("connecting",{code:0,reason:"connect called"}),this._client=null,this._startReconnecting()}_disconnect(i,n,o){if(this._isDisconnected())return;this._transportIsOpen=!1;let t=this.state;this._reconnecting=!1;let e={code:i,reason:n},l=!1;if(o?l=this._setState("connecting"):(l=this._setState("disconnected"),this._rejectPromises({code:3,message:"disconnected"})),this._clearOutgoingRequests(),t==="connecting"&&this._clearReconnectTimeout(),t==="connected"&&this._clearConnectedState(),l&&(this._isConnecting()?this.emit("connecting",e):this.emit("disconnected",e)),this._transport){this._debug("closing existing transport");let c=this._transport;this._transport=null,c.close(),this._transportClosed=!0,this._nextTransportId()}else this._debug("no transport to close");this._scheduleReconnect()}_failUnauthorized(){this._disconnect(1,"unauthorized",!1)}_getToken(){return this._debug("get connection token"),this._config.getToken?this._config.getToken({}):(this.emit("error",{type:"configuration",error:{code:12,message:"token expired but no getToken function set in the configuration"}}),Promise.reject(new T("")))}_refresh(){let i=this._client,n=this;this._getToken().then(function(o){if(i!==n._client)return;if(!o){n._failUnauthorized();return}if(n._token=o,n._debug("connection token refreshed"),!n._isConnected())return;let t={refresh:{token:n._token}};n._call(t,!1).then(e=>{let l=e.reply.refresh;n._refreshResponse(l),e.next&&e.next()},e=>{n._refreshError(e.error),e.next&&e.next()})}).catch(function(o){if(n._isConnected()){if(o instanceof T){n._failUnauthorized();return}n.emit("error",{type:"refreshToken",error:{code:6,message:o!==void 0?o.toString():""}}),n._refreshTimeout=setTimeout(()=>n._refresh(),n._getRefreshRetryDelay())}})}_refreshError(i){i.code<100||i.temporary===!0?(this.emit("error",{type:"refresh",error:i}),this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())):this._disconnect(i.code,i.message,!1)}_getRefreshRetryDelay(){return W(0,5e3,1e4)}_refreshResponse(i){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),i.expires&&(this._client=i.client,this._refreshTimeout=setTimeout(()=>this._refresh(),J(i.ttl)))}_removeSubscription(i){i!==null&&delete this._subs[i.channel]}_unsubscribe(i){if(!this._transportIsOpen)return Promise.resolve();let o={unsubscribe:{channel:i.channel}},t=this;return new Promise((l,c)=>{this._call(o,!1).then(u=>{l(),u.next&&u.next()},u=>{l(),u.next&&u.next(),t._disconnect(4,"unsubscribe error",!0)})})}_getSub(i){let n=this._subs[i];return n||null}_isServerSub(i){return this._serverSubs[i]!==void 0}_sendSubscribeCommands(){let i=[];for(let n in this._subs){if(!this._subs.hasOwnProperty(n))continue;let o=this._subs[n];if(o._inflight!==!0&&o.state==="subscribing"){let t=o._subscribe();t&&i.push(t)}}return i}_connectResponse(i){if(this._transportIsOpen=!0,this._transportWasOpen=!0,this._reconnectAttempts=0,this._refreshRequired=!1,this._isConnected())return;this._client=i.client,this._setState("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout),i.expires&&(this._refreshTimeout=setTimeout(()=>this._refresh(),J(i.ttl))),this._session=i.session,this._node=i.node,this.startBatching(),this._sendSubscribeCommands(),this.stopBatching();let n={client:i.client,transport:this._transport.subName()};i.data&&(n.data=i.data),this.emit("connected",n),this._resolvePromises(),this._processServerSubs(i.subs||{}),i.ping&&i.ping>0?(this._serverPing=i.ping*1e3,this._sendPong=i.pong===!0,this._waitServerPing()):this._serverPing=0}_processServerSubs(i){for(let n in i){if(!i.hasOwnProperty(n))continue;let o=i[n];this._serverSubs[n]={offset:o.offset,epoch:o.epoch,recoverable:o.recoverable||!1};let t=this._getSubscribeContext(n,o);this.emit("subscribed",t)}for(let n in i){if(!i.hasOwnProperty(n))continue;let o=i[n];if(o.recovered){let t=o.publications;if(t&&t.length>0)for(let e in t)t.hasOwnProperty(e)&&this._handlePublication(n,t[e])}}for(let n in this._serverSubs)this._serverSubs.hasOwnProperty(n)&&(i[n]||(this.emit("unsubscribed",{channel:n}),delete this._serverSubs[n]))}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearReconnectTimeout(){this._reconnectTimeout!==null&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=null)}_clearServerPingTimeout(){this._serverPingTimeout!==null&&(clearTimeout(this._serverPingTimeout),this._serverPingTimeout=null)}_waitServerPing(){this._config.maxServerPingDelay!==0&&this._isConnected()&&(this._clearServerPingTimeout(),this._serverPingTimeout=setTimeout(()=>{this._isConnected()&&this._disconnect(2,"no ping",!0)},this._serverPing+this._config.maxServerPingDelay))}_getSubscribeContext(i,n){let o={channel:i,positioned:!1,recoverable:!1,wasRecovering:!1,recovered:!1,hasRecoveredPublications:!1};n.recovered&&(o.recovered=!0),n.positioned&&(o.positioned=!0),n.recoverable&&(o.recoverable=!0),n.was_recovering&&(o.wasRecovering=!0);let t="";"epoch"in n&&(t=n.epoch);let e=0;return"offset"in n&&(e=n.offset),(o.positioned||o.recoverable)&&(o.streamPosition={offset:e,epoch:t}),Array.isArray(n.publications)&&n.publications.length>0&&(o.hasRecoveredPublications=!0),n.data&&(o.data=n.data),o}_handleReply(i,n){let o=i.id;if(!(o in this._callbacks)){n();return}let t=this._callbacks[o];if(clearTimeout(this._callbacks[o].timeout),delete this._callbacks[o],Zt(i)){let e=t.errback;if(!e){n();return}let l={code:i.error.code,message:i.error.message||"",temporary:i.error.temporary||!1};e({error:l,next:n})}else{let e=t.callback;if(!e)return;e({reply:i,next:n})}}_handleJoin(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("join",t)}return}o._handleJoin(n)}_handleLeave(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("leave",t)}return}o._handleLeave(n)}_handleUnsubscribe(i,n){let o=this._getSub(i);if(!o){this._isServerSub(i)&&(delete this._serverSubs[i],this.emit("unsubscribed",{channel:i}));return}n.code<2500?o._setUnsubscribed(n.code,n.reason,!1):o._setSubscribing(n.code,n.reason)}_handleSubscribe(i,n){this._serverSubs[i]={offset:n.offset,epoch:n.epoch,recoverable:n.recoverable||!1},this.emit("subscribed",this._getSubscribeContext(i,n))}_handleDisconnect(i){let n=i.code,o=!0;(n>=3500&&n<4e3||n>=4500&&n<5e3)&&(o=!1),this._disconnect(n,i.reason,o)}_getPublicationContext(i,n){let o={channel:i,data:n.data};return n.offset&&(o.offset=n.offset),n.info&&(o.info=this._getJoinLeaveContext(n.info)),n.tags&&(o.tags=n.tags),o}_getJoinLeaveContext(i){let n={client:i.client,user:i.user},o=i.conn_info;o&&(n.connInfo=o);let t=i.chan_info;return t&&(n.chanInfo=t),n}_handlePublication(i,n){let o=this._getSub(i);if(!o){if(this._isServerSub(i)){let t=this._getPublicationContext(i,n);this.emit("publication",t),n.offset!==void 0&&(this._serverSubs[i].offset=n.offset)}return}o._handlePublication(n)}_handleMessage(i){this.emit("message",{data:i.data})}_handleServerPing(i){if(this._sendPong){let n={};this._transportSendCommands([n])}i()}_handlePush(i,n){let o=i.channel;i.pub?this._handlePublication(o,i.pub):i.message?this._handleMessage(i.message):i.join?this._handleJoin(o,i.join):i.leave?this._handleLeave(o,i.leave):i.unsubscribe?this._handleUnsubscribe(o,i.unsubscribe):i.subscribe?this._handleSubscribe(o,i.subscribe):i.disconnect&&this._handleDisconnect(i.disconnect),n()}_flush(){let i=this._commands.slice(0);this._commands=[],this._transportSendCommands(i)}_createErrorObject(i,n,o){let t={code:i,message:n};return o&&(t.temporary=!0),t}_registerCall(i,n,o){this._callbacks[i]={callback:n,errback:o,timeout:null},this._callbacks[i].timeout=setTimeout(()=>{delete this._callbacks[i],vt(o)&&o({error:this._createErrorObject(1,"timeout")})},this._config.timeout)}_addCommand(i){this._batching?this._commands.push(i):this._transportSendCommands([i])}_nextPromiseId(){return++this._promiseId}_nextTransportId(){return++this._transportId}_resolvePromises(){for(let i in this._promises)this._promises.hasOwnProperty(i)&&(this._promises[i].timeout&&clearTimeout(this._promises[i].timeout),this._promises[i].resolve(),delete this._promises[i])}_rejectPromises(i){for(let n in this._promises)this._promises.hasOwnProperty(n)&&(this._promises[n].timeout&&clearTimeout(this._promises[n].timeout),this._promises[n].reject(i),delete this._promises[n])}};N.SubscriptionState=nt;N.State=et;N.UnauthorizedError=T;var z=Q(qt());var q=Q(qt()),a=q.Reader,b=q.Writer,h=q.util,f=q.roots.default||(q.roots.default={}),pt=f.centrifugal=(()=>{let s={};return s.centrifuge=function(){let r={};return r.protocol=function(){let i={};return i.Error=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.message="",n.prototype.temporary=!1,n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(8).uint32(t.code),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&e.uint32(18).string(t.message),t.temporary!=null&&Object.hasOwnProperty.call(t,"temporary")&&e.uint32(24).bool(t.temporary),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Error;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.code=t.uint32();break}case 2:{c.message=t.string();break}case 3:{c.temporary=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.message!=null&&t.hasOwnProperty("message")&&!h.isString(t.message)?"message: string expected":t.temporary!=null&&t.hasOwnProperty("temporary")&&typeof t.temporary!="boolean"?"temporary: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Error"},n}(),i.EmulationRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.node="",n.prototype.session="",n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(10).string(t.node),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(18).string(t.session),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(26).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.EmulationRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.node=t.string();break}case 2:{c.session=t.string();break}case 3:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.EmulationRequest"},n}(),i.Command=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.id=0,n.prototype.connect=null,n.prototype.subscribe=null,n.prototype.unsubscribe=null,n.prototype.publish=null,n.prototype.presence=null,n.prototype.presence_stats=null,n.prototype.history=null,n.prototype.ping=null,n.prototype.send=null,n.prototype.rpc=null,n.prototype.refresh=null,n.prototype.sub_refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.ConnectRequest.encode(t.connect,e.uint32(34).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subscribe,e.uint32(42).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.UnsubscribeRequest.encode(t.unsubscribe,e.uint32(50).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&f.centrifugal.centrifuge.protocol.PublishRequest.encode(t.publish,e.uint32(58).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&f.centrifugal.centrifuge.protocol.PresenceRequest.encode(t.presence,e.uint32(66).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&f.centrifugal.centrifuge.protocol.PresenceStatsRequest.encode(t.presence_stats,e.uint32(74).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&f.centrifugal.centrifuge.protocol.HistoryRequest.encode(t.history,e.uint32(82).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&f.centrifugal.centrifuge.protocol.PingRequest.encode(t.ping,e.uint32(90).fork()).ldelim(),t.send!=null&&Object.hasOwnProperty.call(t,"send")&&f.centrifugal.centrifuge.protocol.SendRequest.encode(t.send,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&f.centrifugal.centrifuge.protocol.RPCRequest.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.RefreshRequest.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&f.centrifugal.centrifuge.protocol.SubRefreshRequest.encode(t.sub_refresh,e.uint32(122).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Command;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.id=t.uint32();break}case 4:{c.connect=f.centrifugal.centrifuge.protocol.ConnectRequest.decode(t,t.uint32());break}case 5:{c.subscribe=f.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break}case 6:{c.unsubscribe=f.centrifugal.centrifuge.protocol.UnsubscribeRequest.decode(t,t.uint32());break}case 7:{c.publish=f.centrifugal.centrifuge.protocol.PublishRequest.decode(t,t.uint32());break}case 8:{c.presence=f.centrifugal.centrifuge.protocol.PresenceRequest.decode(t,t.uint32());break}case 9:{c.presence_stats=f.centrifugal.centrifuge.protocol.PresenceStatsRequest.decode(t,t.uint32());break}case 10:{c.history=f.centrifugal.centrifuge.protocol.HistoryRequest.decode(t,t.uint32());break}case 11:{c.ping=f.centrifugal.centrifuge.protocol.PingRequest.decode(t,t.uint32());break}case 12:{c.send=f.centrifugal.centrifuge.protocol.SendRequest.decode(t,t.uint32());break}case 13:{c.rpc=f.centrifugal.centrifuge.protocol.RPCRequest.decode(t,t.uint32());break}case 14:{c.refresh=f.centrifugal.centrifuge.protocol.RefreshRequest.decode(t,t.uint32());break}case 15:{c.sub_refresh=f.centrifugal.centrifuge.protocol.SubRefreshRequest.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!h.isInteger(t.id))return"id: integer expected";if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.ConnectRequest.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.UnsubscribeRequest.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=f.centrifugal.centrifuge.protocol.PublishRequest.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=f.centrifugal.centrifuge.protocol.PresenceRequest.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=f.centrifugal.centrifuge.protocol.PresenceStatsRequest.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=f.centrifugal.centrifuge.protocol.HistoryRequest.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=f.centrifugal.centrifuge.protocol.PingRequest.verify(t.ping);if(e)return"ping."+e}if(t.send!=null&&t.hasOwnProperty("send")){let e=f.centrifugal.centrifuge.protocol.SendRequest.verify(t.send);if(e)return"send."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=f.centrifugal.centrifuge.protocol.RPCRequest.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.RefreshRequest.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=f.centrifugal.centrifuge.protocol.SubRefreshRequest.verify(t.sub_refresh);if(e)return"sub_refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Command"},n}(),i.Reply=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.id=0,n.prototype.error=null,n.prototype.push=null,n.prototype.connect=null,n.prototype.subscribe=null,n.prototype.unsubscribe=null,n.prototype.publish=null,n.prototype.presence=null,n.prototype.presence_stats=null,n.prototype.history=null,n.prototype.ping=null,n.prototype.rpc=null,n.prototype.refresh=null,n.prototype.sub_refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.error!=null&&Object.hasOwnProperty.call(t,"error")&&f.centrifugal.centrifuge.protocol.Error.encode(t.error,e.uint32(18).fork()).ldelim(),t.push!=null&&Object.hasOwnProperty.call(t,"push")&&f.centrifugal.centrifuge.protocol.Push.encode(t.push,e.uint32(34).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.ConnectResult.encode(t.connect,e.uint32(42).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subscribe,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.UnsubscribeResult.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&f.centrifugal.centrifuge.protocol.PublishResult.encode(t.publish,e.uint32(66).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&f.centrifugal.centrifuge.protocol.PresenceResult.encode(t.presence,e.uint32(74).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&f.centrifugal.centrifuge.protocol.PresenceStatsResult.encode(t.presence_stats,e.uint32(82).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&f.centrifugal.centrifuge.protocol.HistoryResult.encode(t.history,e.uint32(90).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&f.centrifugal.centrifuge.protocol.PingResult.encode(t.ping,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&f.centrifugal.centrifuge.protocol.RPCResult.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.RefreshResult.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&f.centrifugal.centrifuge.protocol.SubRefreshResult.encode(t.sub_refresh,e.uint32(122).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Reply;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.id=t.uint32();break}case 2:{c.error=f.centrifugal.centrifuge.protocol.Error.decode(t,t.uint32());break}case 4:{c.push=f.centrifugal.centrifuge.protocol.Push.decode(t,t.uint32());break}case 5:{c.connect=f.centrifugal.centrifuge.protocol.ConnectResult.decode(t,t.uint32());break}case 6:{c.subscribe=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break}case 7:{c.unsubscribe=f.centrifugal.centrifuge.protocol.UnsubscribeResult.decode(t,t.uint32());break}case 8:{c.publish=f.centrifugal.centrifuge.protocol.PublishResult.decode(t,t.uint32());break}case 9:{c.presence=f.centrifugal.centrifuge.protocol.PresenceResult.decode(t,t.uint32());break}case 10:{c.presence_stats=f.centrifugal.centrifuge.protocol.PresenceStatsResult.decode(t,t.uint32());break}case 11:{c.history=f.centrifugal.centrifuge.protocol.HistoryResult.decode(t,t.uint32());break}case 12:{c.ping=f.centrifugal.centrifuge.protocol.PingResult.decode(t,t.uint32());break}case 13:{c.rpc=f.centrifugal.centrifuge.protocol.RPCResult.decode(t,t.uint32());break}case 14:{c.refresh=f.centrifugal.centrifuge.protocol.RefreshResult.decode(t,t.uint32());break}case 15:{c.sub_refresh=f.centrifugal.centrifuge.protocol.SubRefreshResult.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!h.isInteger(t.id))return"id: integer expected";if(t.error!=null&&t.hasOwnProperty("error")){let e=f.centrifugal.centrifuge.protocol.Error.verify(t.error);if(e)return"error."+e}if(t.push!=null&&t.hasOwnProperty("push")){let e=f.centrifugal.centrifuge.protocol.Push.verify(t.push);if(e)return"push."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.ConnectResult.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.UnsubscribeResult.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=f.centrifugal.centrifuge.protocol.PublishResult.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=f.centrifugal.centrifuge.protocol.PresenceResult.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=f.centrifugal.centrifuge.protocol.PresenceStatsResult.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=f.centrifugal.centrifuge.protocol.HistoryResult.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=f.centrifugal.centrifuge.protocol.PingResult.verify(t.ping);if(e)return"ping."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=f.centrifugal.centrifuge.protocol.RPCResult.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.RefreshResult.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=f.centrifugal.centrifuge.protocol.SubRefreshResult.verify(t.sub_refresh);if(e)return"sub_refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Reply"},n}(),i.Push=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.pub=null,n.prototype.join=null,n.prototype.leave=null,n.prototype.unsubscribe=null,n.prototype.message=null,n.prototype.subscribe=null,n.prototype.connect=null,n.prototype.disconnect=null,n.prototype.refresh=null,n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(18).string(t.channel),t.pub!=null&&Object.hasOwnProperty.call(t,"pub")&&f.centrifugal.centrifuge.protocol.Publication.encode(t.pub,e.uint32(34).fork()).ldelim(),t.join!=null&&Object.hasOwnProperty.call(t,"join")&&f.centrifugal.centrifuge.protocol.Join.encode(t.join,e.uint32(42).fork()).ldelim(),t.leave!=null&&Object.hasOwnProperty.call(t,"leave")&&f.centrifugal.centrifuge.protocol.Leave.encode(t.leave,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&f.centrifugal.centrifuge.protocol.Unsubscribe.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&f.centrifugal.centrifuge.protocol.Message.encode(t.message,e.uint32(66).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&f.centrifugal.centrifuge.protocol.Subscribe.encode(t.subscribe,e.uint32(74).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&f.centrifugal.centrifuge.protocol.Connect.encode(t.connect,e.uint32(82).fork()).ldelim(),t.disconnect!=null&&Object.hasOwnProperty.call(t,"disconnect")&&f.centrifugal.centrifuge.protocol.Disconnect.encode(t.disconnect,e.uint32(90).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&f.centrifugal.centrifuge.protocol.Refresh.encode(t.refresh,e.uint32(98).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Push;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 2:{c.channel=t.string();break}case 4:{c.pub=f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32());break}case 5:{c.join=f.centrifugal.centrifuge.protocol.Join.decode(t,t.uint32());break}case 6:{c.leave=f.centrifugal.centrifuge.protocol.Leave.decode(t,t.uint32());break}case 7:{c.unsubscribe=f.centrifugal.centrifuge.protocol.Unsubscribe.decode(t,t.uint32());break}case 8:{c.message=f.centrifugal.centrifuge.protocol.Message.decode(t,t.uint32());break}case 9:{c.subscribe=f.centrifugal.centrifuge.protocol.Subscribe.decode(t,t.uint32());break}case 10:{c.connect=f.centrifugal.centrifuge.protocol.Connect.decode(t,t.uint32());break}case 11:{c.disconnect=f.centrifugal.centrifuge.protocol.Disconnect.decode(t,t.uint32());break}case 12:{c.refresh=f.centrifugal.centrifuge.protocol.Refresh.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel))return"channel: string expected";if(t.pub!=null&&t.hasOwnProperty("pub")){let e=f.centrifugal.centrifuge.protocol.Publication.verify(t.pub);if(e)return"pub."+e}if(t.join!=null&&t.hasOwnProperty("join")){let e=f.centrifugal.centrifuge.protocol.Join.verify(t.join);if(e)return"join."+e}if(t.leave!=null&&t.hasOwnProperty("leave")){let e=f.centrifugal.centrifuge.protocol.Leave.verify(t.leave);if(e)return"leave."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=f.centrifugal.centrifuge.protocol.Unsubscribe.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.message!=null&&t.hasOwnProperty("message")){let e=f.centrifugal.centrifuge.protocol.Message.verify(t.message);if(e)return"message."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=f.centrifugal.centrifuge.protocol.Subscribe.verify(t.subscribe);if(e)return"subscribe."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=f.centrifugal.centrifuge.protocol.Connect.verify(t.connect);if(e)return"connect."+e}if(t.disconnect!=null&&t.hasOwnProperty("disconnect")){let e=f.centrifugal.centrifuge.protocol.Disconnect.verify(t.disconnect);if(e)return"disconnect."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=f.centrifugal.centrifuge.protocol.Refresh.verify(t.refresh);if(e)return"refresh."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Push"},n}(),i.ClientInfo=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.user="",n.prototype.client="",n.prototype.conn_info=h.newBuffer([]),n.prototype.chan_info=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.user!=null&&Object.hasOwnProperty.call(t,"user")&&e.uint32(10).string(t.user),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(18).string(t.client),t.conn_info!=null&&Object.hasOwnProperty.call(t,"conn_info")&&e.uint32(26).bytes(t.conn_info),t.chan_info!=null&&Object.hasOwnProperty.call(t,"chan_info")&&e.uint32(34).bytes(t.chan_info),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ClientInfo;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.user=t.string();break}case 2:{c.client=t.string();break}case 3:{c.conn_info=t.bytes();break}case 4:{c.chan_info=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.user!=null&&t.hasOwnProperty("user")&&!h.isString(t.user)?"user: string expected":t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client)?"client: string expected":t.conn_info!=null&&t.hasOwnProperty("conn_info")&&!(t.conn_info&&typeof t.conn_info.length=="number"||h.isString(t.conn_info))?"conn_info: buffer expected":t.chan_info!=null&&t.hasOwnProperty("chan_info")&&!(t.chan_info&&typeof t.chan_info.length=="number"||h.isString(t.chan_info))?"chan_info: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ClientInfo"},n}(),i.Publication=function(){function n(o){if(this.tags={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.prototype.info=null,n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.tags=h.emptyObject,n.prototype.delta=!1,n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.prototype.channel="",n.encode=function(t,e){if(e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(34).bytes(t.data),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(42).fork()).ldelim(),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(48).uint64(t.offset),t.tags!=null&&Object.hasOwnProperty.call(t,"tags"))for(let l=Object.keys(t.tags),c=0;c<l.length;++c)e.uint32(58).fork().uint32(10).string(l[c]).uint32(18).string(t.tags[l[c]]).ldelim();return t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(64).bool(t.delta),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(72).int64(t.time),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(82).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Publication,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 4:{c.data=t.bytes();break}case 5:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}case 6:{c.offset=t.uint64();break}case 7:{c.tags===h.emptyObject&&(c.tags={});let w=t.uint32()+t.pos;for(u="",p="";t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=t.string();break;default:t.skipType(g&7);break}}c.tags[u]=p;break}case 8:{c.delta=t.bool();break}case 9:{c.time=t.int64();break}case 10:{c.channel=t.string();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}if(t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.tags!=null&&t.hasOwnProperty("tags")){if(!h.isObject(t.tags))return"tags: object expected";let e=Object.keys(t.tags);for(let l=0;l<e.length;++l)if(!h.isString(t.tags[e[l]]))return"tags: string{k:string} expected"}return t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean"?"delta: boolean expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Publication"},n}(),i.Join=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=b.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(10).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Join;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Join"},n}(),i.Leave=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=b.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,e.uint32(10).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Leave;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.info=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Leave"},n}(),i.Unsubscribe=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(16).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&e.uint32(26).string(t.reason),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Unsubscribe;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 2:{c.code=t.uint32();break}case 3:{c.reason=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!h.isString(t.reason)?"reason: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Unsubscribe"},n}(),i.Subscribe=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(8).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(34).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(40).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(48).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(58).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Subscribe;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.recoverable=t.bool();break}case 4:{c.epoch=t.string();break}case 5:{c.offset=t.uint64();break}case 6:{c.positioned=t.bool();break}case 7:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean"?"recoverable: boolean expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Subscribe"},n}(),i.Message=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Message;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Message"},n}(),i.Connect=function(){function n(o){if(this.subs={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.ping=0,n.prototype.pong=!1,n.prototype.session="",n.prototype.node="",n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(26).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(34).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();return t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(40).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(48).uint32(t.ttl),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&e.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&e.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(88).int64(t.time),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Connect,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.data=t.bytes();break}case 4:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 5:{c.expires=t.bool();break}case 6:{c.ttl=t.uint32();break}case 7:{c.ping=t.uint32();break}case 8:{c.pong=t.bool();break}case 9:{c.session=t.string();break}case 10:{c.node=t.string();break}case 11:{c.time=t.int64();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[l]]);if(c)return"subs."+c}}return t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":t.ping!=null&&t.hasOwnProperty("ping")&&!h.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Connect"},n}(),i.Disconnect=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.prototype.reconnect=!1,n.encode=function(t,e){return e||(e=b.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&e.uint32(8).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&e.uint32(18).string(t.reason),t.reconnect!=null&&Object.hasOwnProperty.call(t,"reconnect")&&e.uint32(24).bool(t.reconnect),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Disconnect;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.code=t.uint32();break}case 2:{c.reason=t.string();break}case 3:{c.reconnect=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!h.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!h.isString(t.reason)?"reason: string expected":t.reconnect!=null&&t.hasOwnProperty("reconnect")&&typeof t.reconnect!="boolean"?"reconnect: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Disconnect"},n}(),i.Refresh=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.Refresh;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Refresh"},n}(),i.ConnectRequest=function(){function n(o){if(this.subs={},this.headers={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.token="",n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.name="",n.prototype.version="",n.prototype.headers=h.emptyObject,n.encode=function(t,e){if(e||(e=b.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(10).string(t.token),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(18).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(26).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&e.uint32(34).string(t.name),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(42).string(t.version),t.headers!=null&&Object.hasOwnProperty.call(t,"headers"))for(let l=Object.keys(t.headers),c=0;c<l.length;++c)e.uint32(50).fork().uint32(10).string(l[c]).uint32(18).string(t.headers[l[c]]).ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ConnectRequest,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.token=t.string();break}case 2:{c.data=t.bytes();break}case 3:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 4:{c.name=t.string();break}case 5:{c.version=t.string();break}case 6:{c.headers===h.emptyObject&&(c.headers={});let w=t.uint32()+t.pos;for(u="",p="";t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=t.string();break;default:t.skipType(g&7);break}}c.headers[u]=p;break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token))return"token: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subs[e[l]]);if(c)return"subs."+c}}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.headers!=null&&t.hasOwnProperty("headers")){if(!h.isObject(t.headers))return"headers: object expected";let e=Object.keys(t.headers);for(let l=0;l<e.length;++l)if(!h.isString(t.headers[e[l]]))return"headers: string{k:string} expected"}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectRequest"},n}(),i.ConnectResult=function(){function n(o){if(this.subs={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.data=h.newBuffer([]),n.prototype.subs=h.emptyObject,n.prototype.ping=0,n.prototype.pong=!1,n.prototype.session="",n.prototype.node="",n.prototype.time=h.Long?h.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(32).uint32(t.ttl),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(42).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let l=Object.keys(t.subs),c=0;c<l.length;++c)e.uint32(50).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[l[c]],e.uint32(18).fork()).ldelim().ldelim();return t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&e.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&e.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&e.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&e.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&e.uint32(88).int64(t.time),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.ConnectResult,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.expires=t.bool();break}case 4:{c.ttl=t.uint32();break}case 5:{c.data=t.bytes();break}case 6:{c.subs===h.emptyObject&&(c.subs={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.subs[u]=p;break}case 7:{c.ping=t.uint32();break}case 8:{c.pong=t.bool();break}case 9:{c.session=t.string();break}case 10:{c.node=t.string();break}case 11:{c.time=t.int64();break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version))return"version: string expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl))return"ttl: integer expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!h.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[l]]);if(c)return"subs."+c}}return t.ping!=null&&t.hasOwnProperty("ping")&&!h.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!h.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!h.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!h.isInteger(t.time)&&!(t.time&&h.isInteger(t.time.low)&&h.isInteger(t.time.high))?"time: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectResult"},n}(),i.RefreshRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.token="",n.encode=function(t,e){return e||(e=b.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(10).string(t.token),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RefreshRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.token=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshRequest"},n}(),i.RefreshResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&e.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(32).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RefreshResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.client=t.string();break}case 2:{c.version=t.string();break}case 3:{c.expires=t.bool();break}case 4:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.client!=null&&t.hasOwnProperty("client")&&!h.isString(t.client)?"client: string expected":t.version!=null&&t.hasOwnProperty("version")&&!h.isString(t.version)?"version: string expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshResult"},n}(),i.SubscribeRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.token="",n.prototype.recover=!1,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.data=h.newBuffer([]),n.prototype.positioned=!1,n.prototype.recoverable=!1,n.prototype.join_leave=!1,n.prototype.delta="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(18).string(t.token),t.recover!=null&&Object.hasOwnProperty.call(t,"recover")&&e.uint32(24).bool(t.recover),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(50).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(56).uint64(t.offset),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(66).bytes(t.data),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(72).bool(t.positioned),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(80).bool(t.recoverable),t.join_leave!=null&&Object.hasOwnProperty.call(t,"join_leave")&&e.uint32(88).bool(t.join_leave),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(98).string(t.delta),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubscribeRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.token=t.string();break}case 3:{c.recover=t.bool();break}case 6:{c.epoch=t.string();break}case 7:{c.offset=t.uint64();break}case 8:{c.data=t.bytes();break}case 9:{c.positioned=t.bool();break}case 10:{c.recoverable=t.bool();break}case 11:{c.join_leave=t.bool();break}case 12:{c.delta=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":t.recover!=null&&t.hasOwnProperty("recover")&&typeof t.recover!="boolean"?"recover: boolean expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean"?"recoverable: boolean expected":t.join_leave!=null&&t.hasOwnProperty("join_leave")&&typeof t.join_leave!="boolean"?"join_leave: boolean expected":t.delta!=null&&t.hasOwnProperty("delta")&&!h.isString(t.delta)?"delta: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeRequest"},n}(),i.SubscribeResult=function(){function n(o){if(this.publications=[],o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.publications=h.emptyArray,n.prototype.recovered=!1,n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=h.newBuffer([]),n.prototype.was_recovering=!1,n.prototype.delta=!1,n.encode=function(t,e){if(e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&e.uint32(24).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(50).string(t.epoch),t.publications!=null&&t.publications.length)for(let l=0;l<t.publications.length;++l)f.centrifugal.centrifuge.protocol.Publication.encode(t.publications[l],e.uint32(58).fork()).ldelim();return t.recovered!=null&&Object.hasOwnProperty.call(t,"recovered")&&e.uint32(64).bool(t.recovered),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(72).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&e.uint32(80).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(90).bytes(t.data),t.was_recovering!=null&&Object.hasOwnProperty.call(t,"was_recovering")&&e.uint32(96).bool(t.was_recovering),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&e.uint32(104).bool(t.delta),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubscribeResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}case 3:{c.recoverable=t.bool();break}case 6:{c.epoch=t.string();break}case 7:{c.publications&&c.publications.length||(c.publications=[]),c.publications.push(f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 8:{c.recovered=t.bool();break}case 9:{c.offset=t.uint64();break}case 10:{c.positioned=t.bool();break}case 11:{c.data=t.bytes();break}case 12:{c.was_recovering=t.bool();break}case 13:{c.delta=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl))return"ttl: integer expected";if(t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean")return"recoverable: boolean expected";if(t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch))return"epoch: string expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let e=0;e<t.publications.length;++e){let l=f.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(l)return"publications."+l}}return t.recovered!=null&&t.hasOwnProperty("recovered")&&typeof t.recovered!="boolean"?"recovered: boolean expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.was_recovering!=null&&t.hasOwnProperty("was_recovering")&&typeof t.was_recovering!="boolean"?"was_recovering: boolean expected":t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean"?"delta: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeResult"},n}(),i.SubRefreshRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.token="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&e.uint32(18).string(t.token),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubRefreshRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.token=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.token!=null&&t.hasOwnProperty("token")&&!h.isString(t.token)?"token: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshRequest"},n}(),i.SubRefreshResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=b.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&e.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&e.uint32(16).uint32(t.ttl),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SubRefreshResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.expires=t.bool();break}case 2:{c.ttl=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!h.isInteger(t.ttl)?"ttl: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshResult"},n}(),i.UnsubscribeRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.UnsubscribeRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeRequest"},n}(),i.UnsubscribeResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.UnsubscribeResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeResult"},n}(),i.PublishRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(18).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PublishRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 2:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishRequest"},n}(),i.PublishResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PublishResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishResult"},n}(),i.PresenceRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceRequest"},n}(),i.PresenceResult=function(){function n(o){if(this.presence={},o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.presence=h.emptyObject,n.encode=function(t,e){if(e||(e=b.create()),t.presence!=null&&Object.hasOwnProperty.call(t,"presence"))for(let l=Object.keys(t.presence),c=0;c<l.length;++c)e.uint32(10).fork().uint32(10).string(l[c]),f.centrifugal.centrifuge.protocol.ClientInfo.encode(t.presence[l[c]],e.uint32(18).fork()).ldelim().ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceResult,u,p;for(;t.pos<l;){let y=t.uint32();switch(y>>>3){case 1:{c.presence===h.emptyObject&&(c.presence={});let w=t.uint32()+t.pos;for(u="",p=null;t.pos<w;){let g=t.uint32();switch(g>>>3){case 1:u=t.string();break;case 2:p=f.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break;default:t.skipType(g&7);break}}c.presence[u]=p;break}default:t.skipType(y&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.presence!=null&&t.hasOwnProperty("presence")){if(!h.isObject(t.presence))return"presence: object expected";let e=Object.keys(t.presence);for(let l=0;l<e.length;++l){let c=f.centrifugal.centrifuge.protocol.ClientInfo.verify(t.presence[e[l]]);if(c)return"presence."+c}}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceResult"},n}(),i.PresenceStatsRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceStatsRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel)?"channel: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsRequest"},n}(),i.PresenceStatsResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.num_clients=0,n.prototype.num_users=0,n.encode=function(t,e){return e||(e=b.create()),t.num_clients!=null&&Object.hasOwnProperty.call(t,"num_clients")&&e.uint32(8).uint32(t.num_clients),t.num_users!=null&&Object.hasOwnProperty.call(t,"num_users")&&e.uint32(16).uint32(t.num_users),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PresenceStatsResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.num_clients=t.uint32();break}case 2:{c.num_users=t.uint32();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.num_clients!=null&&t.hasOwnProperty("num_clients")&&!h.isInteger(t.num_clients)?"num_clients: integer expected":t.num_users!=null&&t.hasOwnProperty("num_users")&&!h.isInteger(t.num_users)?"num_users: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsResult"},n}(),i.StreamPosition=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.prototype.epoch="",n.encode=function(t,e){return e||(e=b.create()),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(8).uint64(t.offset),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(18).string(t.epoch),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.StreamPosition;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.offset=t.uint64();break}case 2:{c.epoch=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.StreamPosition"},n}(),i.HistoryRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.channel="",n.prototype.limit=0,n.prototype.since=null,n.prototype.reverse=!1,n.encode=function(t,e){return e||(e=b.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(10).string(t.channel),t.limit!=null&&Object.hasOwnProperty.call(t,"limit")&&e.uint32(56).int32(t.limit),t.since!=null&&Object.hasOwnProperty.call(t,"since")&&f.centrifugal.centrifuge.protocol.StreamPosition.encode(t.since,e.uint32(66).fork()).ldelim(),t.reverse!=null&&Object.hasOwnProperty.call(t,"reverse")&&e.uint32(72).bool(t.reverse),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.HistoryRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.channel=t.string();break}case 7:{c.limit=t.int32();break}case 8:{c.since=f.centrifugal.centrifuge.protocol.StreamPosition.decode(t,t.uint32());break}case 9:{c.reverse=t.bool();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!h.isString(t.channel))return"channel: string expected";if(t.limit!=null&&t.hasOwnProperty("limit")&&!h.isInteger(t.limit))return"limit: integer expected";if(t.since!=null&&t.hasOwnProperty("since")){let e=f.centrifugal.centrifuge.protocol.StreamPosition.verify(t.since);if(e)return"since."+e}return t.reverse!=null&&t.hasOwnProperty("reverse")&&typeof t.reverse!="boolean"?"reverse: boolean expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryRequest"},n}(),i.HistoryResult=function(){function n(o){if(this.publications=[],o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.publications=h.emptyArray,n.prototype.epoch="",n.prototype.offset=h.Long?h.Long.fromBits(0,0,!0):0,n.encode=function(t,e){if(e||(e=b.create()),t.publications!=null&&t.publications.length)for(let l=0;l<t.publications.length;++l)f.centrifugal.centrifuge.protocol.Publication.encode(t.publications[l],e.uint32(10).fork()).ldelim();return t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(18).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&e.uint32(24).uint64(t.offset),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.HistoryResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.publications&&c.publications.length||(c.publications=[]),c.publications.push(f.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 2:{c.epoch=t.string();break}case 3:{c.offset=t.uint64();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let e=0;e<t.publications.length;++e){let l=f.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(l)return"publications."+l}}return t.epoch!=null&&t.hasOwnProperty("epoch")&&!h.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!h.isInteger(t.offset)&&!(t.offset&&h.isInteger(t.offset.low)&&h.isInteger(t.offset.high))?"offset: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryResult"},n}(),i.PingRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PingRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingRequest"},n}(),i.PingResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.encode=function(t,e){return e||(e=b.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.PingResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingResult"},n}(),i.RPCRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.prototype.method="",n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),t.method!=null&&Object.hasOwnProperty.call(t,"method")&&e.uint32(18).string(t.method),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RPCRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}case 2:{c.method=t.string();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":t.method!=null&&t.hasOwnProperty("method")&&!h.isString(t.method)?"method: string expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCRequest"},n}(),i.RPCResult=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.RPCResult;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCResult"},n}(),i.SendRequest=function(){function n(o){if(o)for(let t=Object.keys(o),e=0;e<t.length;++e)o[t[e]]!=null&&(this[t[e]]=o[t[e]])}return n.prototype.data=h.newBuffer([]),n.encode=function(t,e){return e||(e=b.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(10).bytes(t.data),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof a||(t=a.create(t));let l=e===void 0?t.len:t.pos+e,c=new f.centrifugal.centrifuge.protocol.SendRequest;for(;t.pos<l;){let u=t.uint32();switch(u>>>3){case 1:{c.data=t.bytes();break}default:t.skipType(u&7);break}}return c},n.decodeDelimited=function(t){return t instanceof a||(t=new a(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||h.isString(t.data))?"data: buffer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SendRequest"},n}(),i}(),r}(),s})();var Ke=pt.centrifuge.protocol.Command,At=pt.centrifuge.protocol.Reply,mn=pt.centrifuge.protocol.EmulationRequest,dt=class{name(){return"protobuf"}encodeEmulationRequest(r){let i=z.Writer.create();return mn.encode(r,i),i.finish()}encodeCommands(r){let i=z.Writer.create();for(let n of r)i.fork(),Ke.encodeDelimited(n,i);return i.finish()}encodeReplies(r){let i=z.Writer.create();for(let n of r)i.fork(),At.encodeDelimited(n,i);return i.finish()}decodeReplies(r){let i=[],n=z.Reader.create(new Uint8Array(r));for(;n.pos<n.len;){let o=At.decodeDelimited(n);i.push(o)}return i}decodeCommands(r){let i=[],n=z.Reader.create(new Uint8Array(r));for(;n.pos<n.len;){let o=Ke.decodeDelimited(n);i.push(o)}return i}decodeReply(r){let i=z.Reader.create(new Uint8Array(r));for(;i.pos<i.len;)return At.decodeDelimited(i),{ok:!0,pos:i.pos};return{ok:!1}}applyDeltaIfNeeded(r,i){let n,o;if(r.delta){let t=lt(i,r.data);n=new Uint8Array(t),o=t}else n=r.data,o=r.data;return{newData:n,newPrevValue:o}}};var bt=class extends N{_formatOverride(){this._codec=new dt}};globalThis.Centrifuge=bt;})();
8
8
  //# sourceMappingURL=centrifuge.protobuf.js.map