UNPKG

centrifuge

Version:

JavaScript client SDK for bidirectional communication with Centrifugo and Centrifuge-based server from browser, NodeJS and React Native

32 lines 204 kB
"use strict";(()=>{var jn=Object.create;var pe=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,In=Object.prototype.hasOwnProperty;var B=(l,o)=>()=>(o||l((o={exports:{}}).exports,o),o.exports);var Ln=(l,o,i,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Dn(o))!In.call(l,r)&&r!==i&&pe(l,r,{get:()=>o[r],enumerable:!(n=En(o,r))||n.enumerable});return l};var Pt=(l,o,i)=>(i=l!=null?jn(Cn(l)):{},Ln(o||!l||!l.__esModule?pe(i,"default",{value:l,enumerable:!0}):i,l));var Ht=B((ci,Wt)=>{"use strict";var at=typeof Reflect=="object"?Reflect:null,de=at&&typeof at.apply=="function"?at.apply:function(o,i,n){return Function.prototype.apply.call(o,i,n)},wt;at&&typeof at.ownKeys=="function"?wt=at.ownKeys:Object.getOwnPropertySymbols?wt=function(o){return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o))}:wt=function(o){return Object.getOwnPropertyNames(o)};function Bn(l){console&&console.warn&&console.warn(l)}var ye=Number.isNaN||function(o){return o!==o};function T(){T.init.call(this)}Wt.exports=T;Wt.exports.once=Un;T.EventEmitter=T;T.prototype._events=void 0;T.prototype._eventsCount=0;T.prototype._maxListeners=void 0;var be=10;function Ot(l){if(typeof l!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof l)}Object.defineProperty(T,"defaultMaxListeners",{enumerable:!0,get:function(){return be},set:function(l){if(typeof l!="number"||l<0||ye(l))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+l+".");be=l}});T.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};T.prototype.setMaxListeners=function(o){if(typeof o!="number"||o<0||ye(o))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+o+".");return this._maxListeners=o,this};function _e(l){return l._maxListeners===void 0?T.defaultMaxListeners:l._maxListeners}T.prototype.getMaxListeners=function(){return _e(this)};T.prototype.emit=function(o){for(var i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);var r=o==="error",t=this._events;if(t!==void 0)r=r&&t.error===void 0;else if(!r)return!1;if(r){var e;if(i.length>0&&(e=i[0]),e instanceof Error)throw e;var c=new Error("Unhandled error."+(e?" ("+e.message+")":""));throw c.context=e,c}var s=t[o];if(s===void 0)return!1;if(typeof s=="function")de(s,this,i);else for(var u=s.length,d=Pe(s,u),n=0;n<u;++n)de(d[n],this,i);return!0};function ge(l,o,i,n){var r,t,e;if(Ot(i),t=l._events,t===void 0?(t=l._events=Object.create(null),l._eventsCount=0):(t.newListener!==void 0&&(l.emit("newListener",o,i.listener?i.listener:i),t=l._events),e=t[o]),e===void 0)e=t[o]=i,++l._eventsCount;else if(typeof e=="function"?e=t[o]=n?[i,e]:[e,i]:n?e.unshift(i):e.push(i),r=_e(l),r>0&&e.length>r&&!e.warned){e.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+e.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=l,c.type=o,c.count=e.length,Bn(c)}return l}T.prototype.addListener=function(o,i){return ge(this,o,i,!1)};T.prototype.on=T.prototype.addListener;T.prototype.prependListener=function(o,i){return ge(this,o,i,!0)};function Mn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ve(l,o,i){var n={fired:!1,wrapFn:void 0,target:l,type:o,listener:i},r=Mn.bind(n);return r.listener=i,n.wrapFn=r,r}T.prototype.once=function(o,i){return Ot(i),this.on(o,ve(this,o,i)),this};T.prototype.prependOnceListener=function(o,i){return Ot(i),this.prependListener(o,ve(this,o,i)),this};T.prototype.removeListener=function(o,i){var n,r,t,e,c;if(Ot(i),r=this._events,r===void 0)return this;if(n=r[o],n===void 0)return this;if(n===i||n.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete r[o],r.removeListener&&this.emit("removeListener",o,n.listener||i));else if(typeof n!="function"){for(t=-1,e=n.length-1;e>=0;e--)if(n[e]===i||n[e].listener===i){c=n[e].listener,t=e;break}if(t<0)return this;t===0?n.shift():qn(n,t),n.length===1&&(r[o]=n[0]),r.removeListener!==void 0&&this.emit("removeListener",o,c||i)}return this};T.prototype.off=T.prototype.removeListener;T.prototype.removeAllListeners=function(o){var i,n,r;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[o]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[o]),this;if(arguments.length===0){var t=Object.keys(n),e;for(r=0;r<t.length;++r)e=t[r],e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(i=n[o],typeof i=="function")this.removeListener(o,i);else if(i!==void 0)for(r=i.length-1;r>=0;r--)this.removeListener(o,i[r]);return this};function ke(l,o,i){var n=l._events;if(n===void 0)return[];var r=n[o];return r===void 0?[]:typeof r=="function"?i?[r.listener||r]:[r]:i?An(r):Pe(r,r.length)}T.prototype.listeners=function(o){return ke(this,o,!0)};T.prototype.rawListeners=function(o){return ke(this,o,!1)};T.listenerCount=function(l,o){return typeof l.listenerCount=="function"?l.listenerCount(o):Se.call(l,o)};T.prototype.listenerCount=Se;function Se(l){var o=this._events;if(o!==void 0){var i=o[l];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}T.prototype.eventNames=function(){return this._eventsCount>0?wt(this._events):[]};function Pe(l,o){for(var i=new Array(o),n=0;n<o;++n)i[n]=l[n];return i}function qn(l,o){for(;o+1<l.length;o++)l[o]=l[o+1];l.pop()}function An(l){for(var o=new Array(l.length),i=0;i<o.length;++i)o[i]=l[i].listener||l[i];return o}function Un(l,o){return new Promise(function(i,n){function r(e){l.removeListener(o,t),n(e)}function t(){typeof l.removeListener=="function"&&l.removeListener("error",r),i([].slice.call(arguments))}we(l,o,t,{once:!0}),o!=="error"&&Nn(l,r,{once:!0})})}function Nn(l,o,i){typeof l.on=="function"&&we(l,"error",o,i)}function we(l,o,i,n){if(typeof l.on=="function")n.once?l.once(o,i):l.on(o,i);else if(typeof l.addEventListener=="function")l.addEventListener(o,function r(t){n.once&&l.removeEventListener(o,r),i(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof l)}});var De=B((wr,Ee)=>{"use strict";Ee.exports=Kn;function Kn(l,o){for(var i=new Array(arguments.length-1),n=0,r=2,t=!0;r<arguments.length;)i[n++]=arguments[r++];return new Promise(function(c,s){i[n]=function(d){if(t)if(t=!1,d)s(d);else{for(var g=new Array(arguments.length-1),k=0;k<g.length;)g[k++]=arguments[k];c.apply(null,g)}};try{l.apply(o||null,i)}catch(u){t&&(t=!1,s(u))}})}});var Be=B(Le=>{"use strict";var Bt=Le;Bt.length=function(o){var i=o.length;if(!i)return 0;for(var n=0;--i%4>1&&o.charAt(i)==="=";)++n;return Math.ceil(o.length*3)/4-n};var pt=new Array(64),Ie=new Array(123);for(K=0;K<64;)Ie[pt[K]=K<26?K+65:K<52?K+71:K<62?K-4:K-59|43]=K++;var K;Bt.encode=function(o,i,n){for(var r=null,t=[],e=0,c=0,s;i<n;){var u=o[i++];switch(c){case 0:t[e++]=pt[u>>2],s=(u&3)<<4,c=1;break;case 1:t[e++]=pt[s|u>>4],s=(u&15)<<2,c=2;break;case 2:t[e++]=pt[s|u>>6],t[e++]=pt[u&63],c=0;break}e>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,t)),e=0)}return c&&(t[e++]=pt[s],t[e++]=61,c===1&&(t[e++]=61)),r?(e&&r.push(String.fromCharCode.apply(String,t.slice(0,e))),r.join("")):String.fromCharCode.apply(String,t.slice(0,e))};var Ce="invalid encoding";Bt.decode=function(o,i,n){for(var r=n,t=0,e,c=0;c<o.length;){var s=o.charCodeAt(c++);if(s===61&&t>1)break;if((s=Ie[s])===void 0)throw Error(Ce);switch(t){case 0:e=s,t=1;break;case 1:i[n++]=e<<2|(s&48)>>4,e=s,t=2;break;case 2:i[n++]=(e&15)<<4|(s&60)>>2,e=s,t=3;break;case 3:i[n++]=(e&3)<<6|s,t=0;break}}if(t===1)throw Error(Ce);return n-r};Bt.test=function(o){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o)}});var qe=B((mr,Me)=>{"use strict";Me.exports=Mt;function Mt(){this._listeners=Object.create(null)}Mt.prototype.on=function(o,i,n){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:i,ctx:n||this}),this};Mt.prototype.off=function(o,i){if(o===void 0)this._listeners=Object.create(null);else if(i===void 0)this._listeners[o]=[];else{var n=this._listeners[o];if(!n)return this;for(var r=0;r<n.length;)n[r].fn===i?n.splice(r,1):++r}return this};Mt.prototype.emit=function(o){var i=this._listeners[o];if(i){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<i.length;)i[r].fn.apply(i[r++].ctx,n)}return this}});var He=B((xr,We)=>{"use strict";We.exports=Ae(Ae);function Ae(l){return typeof Float32Array<"u"?(function(){var o=new Float32Array([-0]),i=new Uint8Array(o.buffer),n=i[3]===128;function r(s,u,d){o[0]=s,u[d]=i[0],u[d+1]=i[1],u[d+2]=i[2],u[d+3]=i[3]}function t(s,u,d){o[0]=s,u[d]=i[3],u[d+1]=i[2],u[d+2]=i[1],u[d+3]=i[0]}l.writeFloatLE=n?r:t,l.writeFloatBE=n?t:r;function e(s,u){return i[0]=s[u],i[1]=s[u+1],i[2]=s[u+2],i[3]=s[u+3],o[0]}function c(s,u){return i[3]=s[u],i[2]=s[u+1],i[1]=s[u+2],i[0]=s[u+3],o[0]}l.readFloatLE=n?e:c,l.readFloatBE=n?c:e})():(function(){function o(n,r,t,e){var c=r<0?1:0;if(c&&(r=-r),r===0)n(1/r>0?0:2147483648,t,e);else if(isNaN(r))n(2143289344,t,e);else if(r>34028234663852886e22)n((c<<31|2139095040)>>>0,t,e);else if(r<11754943508222875e-54)n((c<<31|Math.round(r/1401298464324817e-60))>>>0,t,e);else{var s=Math.floor(Math.log(r)/Math.LN2),u=Math.round(r*Math.pow(2,-s)*8388608)&8388607;n((c<<31|s+127<<23|u)>>>0,t,e)}}l.writeFloatLE=o.bind(null,Ue),l.writeFloatBE=o.bind(null,Ne);function i(n,r,t){var e=n(r,t),c=(e>>31)*2+1,s=e>>>23&255,u=e&8388607;return s===255?u?NaN:c*(1/0):s===0?c*1401298464324817e-60*u:c*Math.pow(2,s-150)*(u+8388608)}l.readFloatLE=i.bind(null,Fe),l.readFloatBE=i.bind(null,ze)})(),typeof Float64Array<"u"?(function(){var o=new Float64Array([-0]),i=new Uint8Array(o.buffer),n=i[7]===128;function r(s,u,d){o[0]=s,u[d]=i[0],u[d+1]=i[1],u[d+2]=i[2],u[d+3]=i[3],u[d+4]=i[4],u[d+5]=i[5],u[d+6]=i[6],u[d+7]=i[7]}function t(s,u,d){o[0]=s,u[d]=i[7],u[d+1]=i[6],u[d+2]=i[5],u[d+3]=i[4],u[d+4]=i[3],u[d+5]=i[2],u[d+6]=i[1],u[d+7]=i[0]}l.writeDoubleLE=n?r:t,l.writeDoubleBE=n?t:r;function e(s,u){return i[0]=s[u],i[1]=s[u+1],i[2]=s[u+2],i[3]=s[u+3],i[4]=s[u+4],i[5]=s[u+5],i[6]=s[u+6],i[7]=s[u+7],o[0]}function c(s,u){return i[7]=s[u],i[6]=s[u+1],i[5]=s[u+2],i[4]=s[u+3],i[3]=s[u+4],i[2]=s[u+5],i[1]=s[u+6],i[0]=s[u+7],o[0]}l.readDoubleLE=n?e:c,l.readDoubleBE=n?c:e})():(function(){function o(n,r,t,e,c,s){var u=e<0?1:0;if(u&&(e=-e),e===0)n(0,c,s+r),n(1/e>0?0:2147483648,c,s+t);else if(isNaN(e))n(0,c,s+r),n(2146959360,c,s+t);else if(e>17976931348623157e292)n(0,c,s+r),n((u<<31|2146435072)>>>0,c,s+t);else{var d;if(e<22250738585072014e-324)d=e/5e-324,n(d>>>0,c,s+r),n((u<<31|d/4294967296)>>>0,c,s+t);else{var g=Math.floor(Math.log(e)/Math.LN2);g===1024&&(g=1023),d=e*Math.pow(2,-g),n(d*4503599627370496>>>0,c,s+r),n((u<<31|g+1023<<20|d*1048576&1048575)>>>0,c,s+t)}}}l.writeDoubleLE=o.bind(null,Ue,0,4),l.writeDoubleBE=o.bind(null,Ne,4,0);function i(n,r,t,e,c){var s=n(e,c+r),u=n(e,c+t),d=(u>>31)*2+1,g=u>>>20&2047,k=4294967296*(u&1048575)+s;return g===2047?k?NaN:d*(1/0):g===0?d*5e-324*k:d*Math.pow(2,g-1075)*(k+4503599627370496)}l.readDoubleLE=i.bind(null,Fe,0,4),l.readDoubleBE=i.bind(null,ze,4,0)})(),l}function Ue(l,o,i){o[i]=l&255,o[i+1]=l>>>8&255,o[i+2]=l>>>16&255,o[i+3]=l>>>24}function Ne(l,o,i){o[i]=l>>>24,o[i+1]=l>>>16&255,o[i+2]=l>>>8&255,o[i+3]=l&255}function Fe(l,o){return(l[o]|l[o+1]<<8|l[o+2]<<16|l[o+3]<<24)>>>0}function ze(l,o){return(l[o]<<24|l[o+1]<<16|l[o+2]<<8|l[o+3])>>>0}});var Ge=B(Ve=>{"use strict";var Zt=Ve,Jt="\uFFFD";Zt.length=function(o){for(var i=0,n=0,r=0;r<o.length;++r)n=o.charCodeAt(r),n<128?i+=1:n<2048?i+=2:(n&64512)===55296&&(o.charCodeAt(r+1)&64512)===56320?(++r,i+=4):i+=3;return i};Zt.read=function(o,i,n){if(n-i<1)return"";for(var r="",t=i;t<n;){var e=o[t++];if(e<=127)r+=String.fromCharCode(e);else if(e>=192&&e<224){var c=(e&31)<<6|o[t++]&63;r+=c>=128?String.fromCharCode(c):Jt}else if(e>=224&&e<240){var s=(e&15)<<12|(o[t++]&63)<<6|o[t++]&63;r+=s>=2048?String.fromCharCode(s):Jt}else if(e>=240){var u=(e&7)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63;u<65536||u>1114111?r+=Jt:(u-=65536,r+=String.fromCharCode(55296+(u>>10)),r+=String.fromCharCode(56320+(u&1023)))}}return r};Zt.write=function(o,i,n){for(var r=n,t,e,c=0;c<o.length;++c)t=o.charCodeAt(c),t<128?i[n++]=t:t<2048?(i[n++]=t>>6|192,i[n++]=t&63|128):(t&64512)===55296&&((e=o.charCodeAt(c+1))&64512)===56320?(t=65536+((t&1023)<<10)+(e&1023),++c,i[n++]=t>>18|240,i[n++]=t>>12&63|128,i[n++]=t>>6&63|128,i[n++]=t&63|128):(i[n++]=t>>12|224,i[n++]=t>>6&63|128,i[n++]=t&63|128);return n-r}});var Ze=B((Rr,Je)=>{"use strict";Je.exports=$n;function $n(l,o,i){var n=i||8192,r=n>>>1,t=null,e=n;return function(s){if(s<1||s>r)return l(s);e+s>n&&(t=l(n),e=0);var u=o.call(t,e,e+=s);return e&7&&(e=(e|7)+1),u}}});var $e=B((jr,Ke)=>{"use strict";Ke.exports=q;var _t=nt();function q(l,o){this.lo=l>>>0,this.hi=o>>>0}var ct=q.zero=new q(0,0);ct.toNumber=function(){return 0};ct.zzEncode=ct.zzDecode=function(){return this};ct.length=function(){return 1};var Xn=q.zeroHash="\0\0\0\0\0\0\0\0";q.fromNumber=function(o){if(o===0)return ct;var i=o<0;i&&(o=-o);var n=o>>>0,r=(o-n)/4294967296>>>0;return i&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new q(n,r)};q.from=function(o){if(typeof o=="number")return q.fromNumber(o);if(_t.isString(o))if(_t.Long)o=_t.Long.fromString(o);else return q.fromNumber(parseInt(o,10));return o.low||o.high?new q(o.low>>>0,o.high>>>0):ct};q.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var i=~this.lo+1>>>0,n=~this.hi>>>0;return i||(n=n+1>>>0),-(i+n*4294967296)}return this.lo+this.hi*4294967296};q.prototype.toLong=function(o){return _t.Long?new _t.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var et=String.prototype.charCodeAt;q.fromHash=function(o){return o===Xn?ct:new q((et.call(o,0)|et.call(o,1)<<8|et.call(o,2)<<16|et.call(o,3)<<24)>>>0,(et.call(o,4)|et.call(o,5)<<8|et.call(o,6)<<16|et.call(o,7)<<24)>>>0)};q.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};q.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this};q.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this};q.prototype.length=function(){var o=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?i===0?o<16384?o<128?1:2:o<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:n<128?9:10}});var Xe=B((gt,Kt)=>{(function(l,o){function i(n){return n.default||n}typeof define=="function"&&define.amd?define([],function(){var n={};return o(n),i(n)}):typeof gt=="object"?(o(gt),typeof Kt=="object"&&(Kt.exports=i(gt))):(function(){var n={};o(n),l.Long=i(n)})()})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:gt,function(l){"use strict";Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var o=null;try{o=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function i(b,f,_){this.low=b|0,this.high=f|0,this.unsigned=!!_}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0});function n(b){return(b&&b.__isLong__)===!0}function r(b){var f=Math.clz32(b&-b);return b?31-f:f}i.isLong=n;var t={},e={};function c(b,f){var _,O,j;return f?(b>>>=0,(j=0<=b&&b<256)&&(O=e[b],O)?O:(_=u(b,0,!0),j&&(e[b]=_),_)):(b|=0,(j=-128<=b&&b<128)&&(O=t[b],O)?O:(_=u(b,b<0?-1:0,!1),j&&(t[b]=_),_))}i.fromInt=c;function s(b,f){if(isNaN(b))return f?Q:Z;if(f){if(b<0)return Q;if(b>=D)return he}else{if(b<=-C)return U;if(b+1>=C)return ae}return b<0?s(-b,f).neg():u(b%w|0,b/w|0,f)}i.fromNumber=s;function u(b,f,_){return new i(b,f,_)}i.fromBits=u;var d=Math.pow;function g(b,f,_){if(b.length===0)throw Error("empty string");if(typeof f=="number"?(_=f,f=!1):f=!!f,b==="NaN"||b==="Infinity"||b==="+Infinity"||b==="-Infinity")return f?Q:Z;if(_=_||10,_<2||36<_)throw RangeError("radix");var O;if((O=b.indexOf("-"))>0)throw Error("interior hyphen");if(O===0)return g(b.substring(1),f,_).neg();for(var j=s(d(_,8)),R=Z,L=0;L<b.length;L+=8){var N=Math.min(8,b.length-L),W=parseInt(b.substring(L,L+N),_);if(N<8){var A=s(d(_,N));R=R.mul(A).add(s(W))}else R=R.mul(j),R=R.add(s(W))}return R.unsigned=f,R}i.fromString=g;function k(b,f){return typeof b=="number"?s(b,f):typeof b=="string"?g(b,f):u(b.low,b.high,typeof f=="boolean"?f:b.unsigned)}i.fromValue=k;var P=65536,x=1<<24,w=P*P,D=w*w,C=D/2,ut=c(x),Z=c(0);i.ZERO=Z;var Q=c(0,!0);i.UZERO=Q;var ft=c(1);i.ONE=ft;var fe=c(1,!0);i.UONE=fe;var zt=c(-1);i.NEG_ONE=zt;var ae=u(-1,2147483647,!1);i.MAX_VALUE=ae;var he=u(-1,-1,!0);i.MAX_UNSIGNED_VALUE=he;var U=u(0,-2147483648,!1);i.MIN_VALUE=U;var y=i.prototype;y.toInt=function(){return this.unsigned?this.low>>>0:this.low},y.toNumber=function(){return this.unsigned?(this.high>>>0)*w+(this.low>>>0):this.high*w+(this.low>>>0)},y.toString=function(f){if(f=f||10,f<2||36<f)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(U)){var _=s(f),O=this.div(_),j=O.mul(_).sub(this);return O.toString(f)+j.toInt().toString(f)}else return"-"+this.neg().toString(f);for(var R=s(d(f,6),this.unsigned),L=this,N="";;){var W=L.div(R),A=L.sub(W.mul(R)).toInt()>>>0,I=A.toString(f);if(L=W,L.isZero())return I+N;for(;I.length<6;)I="0"+I;N=""+I+N}},y.getHighBits=function(){return this.high},y.getHighBitsUnsigned=function(){return this.high>>>0},y.getLowBits=function(){return this.low},y.getLowBitsUnsigned=function(){return this.low>>>0},y.getNumBitsAbs=function(){if(this.isNegative())return this.eq(U)?64:this.neg().getNumBitsAbs();for(var f=this.high!=0?this.high:this.low,_=31;_>0&&(f&1<<_)==0;_--);return this.high!=0?_+33:_+1},y.isSafeInteger=function(){var f=this.high>>21;return f?this.unsigned?!1:f===-1&&!(this.low===0&&this.high===-2097152):!0},y.isZero=function(){return this.high===0&&this.low===0},y.eqz=y.isZero,y.isNegative=function(){return!this.unsigned&&this.high<0},y.isPositive=function(){return this.unsigned||this.high>=0},y.isOdd=function(){return(this.low&1)===1},y.isEven=function(){return(this.low&1)===0},y.equals=function(f){return n(f)||(f=k(f)),this.unsigned!==f.unsigned&&this.high>>>31===1&&f.high>>>31===1?!1:this.high===f.high&&this.low===f.low},y.eq=y.equals,y.notEquals=function(f){return!this.eq(f)},y.neq=y.notEquals,y.ne=y.notEquals,y.lessThan=function(f){return this.comp(f)<0},y.lt=y.lessThan,y.lessThanOrEqual=function(f){return this.comp(f)<=0},y.lte=y.lessThanOrEqual,y.le=y.lessThanOrEqual,y.greaterThan=function(f){return this.comp(f)>0},y.gt=y.greaterThan,y.greaterThanOrEqual=function(f){return this.comp(f)>=0},y.gte=y.greaterThanOrEqual,y.ge=y.greaterThanOrEqual,y.compare=function(f){if(n(f)||(f=k(f)),this.eq(f))return 0;var _=this.isNegative(),O=f.isNegative();return _&&!O?-1:!_&&O?1:this.unsigned?f.high>>>0>this.high>>>0||f.high===this.high&&f.low>>>0>this.low>>>0?-1:1:this.sub(f).isNegative()?-1:1},y.comp=y.compare,y.negate=function(){return!this.unsigned&&this.eq(U)?U:this.not().add(ft)},y.neg=y.negate,y.add=function(f){n(f)||(f=k(f));var _=this.high>>>16,O=this.high&65535,j=this.low>>>16,R=this.low&65535,L=f.high>>>16,N=f.high&65535,W=f.low>>>16,A=f.low&65535,I=0,H=0,M=0,z=0;return z+=R+A,M+=z>>>16,z&=65535,M+=j+W,H+=M>>>16,M&=65535,H+=O+N,I+=H>>>16,H&=65535,I+=_+L,I&=65535,u(M<<16|z,I<<16|H,this.unsigned)},y.subtract=function(f){return n(f)||(f=k(f)),this.add(f.neg())},y.sub=y.subtract,y.multiply=function(f){if(this.isZero())return this;if(n(f)||(f=k(f)),o){var _=o.mul(this.low,this.high,f.low,f.high);return u(_,o.get_high(),this.unsigned)}if(f.isZero())return this.unsigned?Q:Z;if(this.eq(U))return f.isOdd()?U:Z;if(f.eq(U))return this.isOdd()?U:Z;if(this.isNegative())return f.isNegative()?this.neg().mul(f.neg()):this.neg().mul(f).neg();if(f.isNegative())return this.mul(f.neg()).neg();if(this.lt(ut)&&f.lt(ut))return s(this.toNumber()*f.toNumber(),this.unsigned);var O=this.high>>>16,j=this.high&65535,R=this.low>>>16,L=this.low&65535,N=f.high>>>16,W=f.high&65535,A=f.low>>>16,I=f.low&65535,H=0,M=0,z=0,St=0;return St+=L*I,z+=St>>>16,St&=65535,z+=R*I,M+=z>>>16,z&=65535,z+=L*A,M+=z>>>16,z&=65535,M+=j*I,H+=M>>>16,M&=65535,M+=R*A,H+=M>>>16,M&=65535,M+=L*W,H+=M>>>16,M&=65535,H+=O*I+j*A+R*W+L*N,H&=65535,u(z<<16|St,H<<16|M,this.unsigned)},y.mul=y.multiply,y.divide=function(f){if(n(f)||(f=k(f)),f.isZero())throw Error("division by zero");if(o){if(!this.unsigned&&this.high===-2147483648&&f.low===-1&&f.high===-1)return this;var _=(this.unsigned?o.div_u:o.div_s)(this.low,this.high,f.low,f.high);return u(_,o.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Q:Z;var O,j,R;if(this.unsigned){if(f.unsigned||(f=f.toUnsigned()),f.gt(this))return Q;if(f.gt(this.shru(1)))return fe;R=Q}else{if(this.eq(U)){if(f.eq(ft)||f.eq(zt))return U;if(f.eq(U))return ft;var L=this.shr(1);return O=L.div(f).shl(1),O.eq(Z)?f.isNegative()?ft:zt:(j=this.sub(f.mul(O)),R=O.add(j.div(f)),R)}else if(f.eq(U))return this.unsigned?Q:Z;if(this.isNegative())return f.isNegative()?this.neg().div(f.neg()):this.neg().div(f).neg();if(f.isNegative())return this.div(f.neg()).neg();R=Z}for(j=this;j.gte(f);){O=Math.max(1,Math.floor(j.toNumber()/f.toNumber()));for(var N=Math.ceil(Math.log(O)/Math.LN2),W=N<=48?1:d(2,N-48),A=s(O),I=A.mul(f);I.isNegative()||I.gt(j);)O-=W,A=s(O,this.unsigned),I=A.mul(f);A.isZero()&&(A=ft),R=R.add(A),j=j.sub(I)}return R},y.div=y.divide,y.modulo=function(f){if(n(f)||(f=k(f)),o){var _=(this.unsigned?o.rem_u:o.rem_s)(this.low,this.high,f.low,f.high);return u(_,o.get_high(),this.unsigned)}return this.sub(this.div(f).mul(f))},y.mod=y.modulo,y.rem=y.modulo,y.not=function(){return u(~this.low,~this.high,this.unsigned)},y.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},y.clz=y.countLeadingZeros,y.countTrailingZeros=function(){return this.low?r(this.low):r(this.high)+32},y.ctz=y.countTrailingZeros,y.and=function(f){return n(f)||(f=k(f)),u(this.low&f.low,this.high&f.high,this.unsigned)},y.or=function(f){return n(f)||(f=k(f)),u(this.low|f.low,this.high|f.high,this.unsigned)},y.xor=function(f){return n(f)||(f=k(f)),u(this.low^f.low,this.high^f.high,this.unsigned)},y.shiftLeft=function(f){return n(f)&&(f=f.toInt()),(f&=63)===0?this:f<32?u(this.low<<f,this.high<<f|this.low>>>32-f,this.unsigned):u(0,this.low<<f-32,this.unsigned)},y.shl=y.shiftLeft,y.shiftRight=function(f){return n(f)&&(f=f.toInt()),(f&=63)===0?this:f<32?u(this.low>>>f|this.high<<32-f,this.high>>f,this.unsigned):u(this.high>>f-32,this.high>=0?0:-1,this.unsigned)},y.shr=y.shiftRight,y.shiftRightUnsigned=function(f){return n(f)&&(f=f.toInt()),(f&=63)===0?this:f<32?u(this.low>>>f|this.high<<32-f,this.high>>>f,this.unsigned):f===32?u(this.high,0,this.unsigned):u(this.high>>>f-32,0,this.unsigned)},y.shru=y.shiftRightUnsigned,y.shr_u=y.shiftRightUnsigned,y.rotateLeft=function(f){var _;return n(f)&&(f=f.toInt()),(f&=63)===0?this:f===32?u(this.high,this.low,this.unsigned):f<32?(_=32-f,u(this.low<<f|this.high>>>_,this.high<<f|this.low>>>_,this.unsigned)):(f-=32,_=32-f,u(this.high<<f|this.low>>>_,this.low<<f|this.high>>>_,this.unsigned))},y.rotl=y.rotateLeft,y.rotateRight=function(f){var _;return n(f)&&(f=f.toInt()),(f&=63)===0?this:f===32?u(this.high,this.low,this.unsigned):f<32?(_=32-f,u(this.high<<_|this.low>>>f,this.low<<_|this.high>>>f,this.unsigned)):(f-=32,_=32-f,u(this.low<<_|this.high>>>f,this.high<<_|this.low>>>f,this.unsigned))},y.rotr=y.rotateRight,y.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},y.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},y.toBytes=function(f){return f?this.toBytesLE():this.toBytesBE()},y.toBytesLE=function(){var f=this.high,_=this.low;return[_&255,_>>>8&255,_>>>16&255,_>>>24,f&255,f>>>8&255,f>>>16&255,f>>>24]},y.toBytesBE=function(){var f=this.high,_=this.low;return[f>>>24,f>>>16&255,f>>>8&255,f&255,_>>>24,_>>>16&255,_>>>8&255,_&255]},i.fromBytes=function(f,_,O){return O?i.fromBytesLE(f,_):i.fromBytesBE(f,_)},i.fromBytesLE=function(f,_){return new i(f[0]|f[1]<<8|f[2]<<16|f[3]<<24,f[4]|f[5]<<8|f[6]<<16|f[7]<<24,_)},i.fromBytesBE=function(f,_){return new i(f[4]<<24|f[5]<<16|f[6]<<8|f[7],f[0]<<24|f[1]<<16|f[2]<<8|f[3],_)},typeof BigInt=="function"&&(i.fromBigInt=function(f,_){var O=Number(BigInt.asIntN(32,f)),j=Number(BigInt.asIntN(32,f>>BigInt(32)));return u(O,j,_)},i.fromValue=function(f,_){return typeof f=="bigint"?i.fromBigInt(f,_):k(f,_)},y.toBigInt=function(){var f=BigInt(this.low>>>0),_=BigInt(this.unsigned?this.high>>>0:this.high);return _<<BigInt(32)|f});var oi=l.default=i})});var nt=B($t=>{"use strict";var v=$t;v.asPromise=De();v.base64=Be();v.EventEmitter=qe();v.float=He();v.utf8=Ge();v.pool=Ze();v.LongBits=$e();function Qe(l){return l==="__proto__"||l==="prototype"||l==="constructor"}v.isUnsafeProperty=Qe;v.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node);v.global=v.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||$t;v.emptyArray=Object.freeze?Object.freeze([]):[];v.emptyObject=Object.freeze?Object.freeze({}):{};v.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o};v.isString=function(o){return typeof o=="string"||o instanceof String};v.isObject=function(o){return o&&typeof o=="object"};v.isset=v.isSet=function(o,i){var n=o[i];return n!=null&&Object.hasOwnProperty.call(o,i)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};v.Buffer=(function(){try{var l=v.global.Buffer;return l.prototype.utf8Write?l:null}catch{return null}})();v._Buffer_from=null;v._Buffer_allocUnsafe=null;v.newBuffer=function(o){return typeof o=="number"?v.Buffer?v._Buffer_allocUnsafe(o):new v.Array(o):v.Buffer?v._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)};v.Array=typeof Uint8Array<"u"?Uint8Array:Array;v.Long=v.global.dcodeIO&&v.global.dcodeIO.Long||v.global.Long||(function(){try{var l=Xe();return l&&l.isLong?l:null}catch{return null}})();v.key2Re=/^true|false|0|1$/;v.key32Re=/^-?(?:0|[1-9][0-9]*)$/;v.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;v.longToHash=function(o){return o?v.LongBits.from(o).toHash():v.LongBits.zeroHash};v.longFromHash=function(o,i){var n=v.LongBits.fromHash(o);return v.Long?v.Long.fromBits(n.lo,n.hi,i):n.toNumber(!!i)};function Ye(l){var o=typeof arguments[arguments.length-1]=="boolean",i=o?arguments.length-1:arguments.length;o=o&&arguments[arguments.length-1];for(var n=1;n<i;++n){var r=arguments[n];if(r)for(var t=Object.keys(r),e=0;e<t.length;++e)!Qe(t[e])&&(l[t[e]]===void 0||!o)&&(l[t[e]]=r[t[e]])}return l}v.merge=Ye;v.nestingLimit=32;v.recursionLimit=100;v.makeProp=function(o,i){Object.defineProperty(o,i,{enumerable:!0,configurable:!0,writable:!0})};v.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function tn(l){function o(i,n){if(!(this instanceof o))return new o(i,n);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&Ye(this,n)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return l},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}v.newError=tn;v.ProtocolError=tn("ProtocolError");v.oneOfGetter=function(o){for(var i={},n=0;n<o.length;++n)i[o[n]]=1;return function(){for(var r=Object.keys(this),t=r.length-1;t>-1;--t)if(i[r[t]]===1&&this[r[t]]!==void 0&&this[r[t]]!==null)return r[t]}};v.oneOfSetter=function(o){return function(i){for(var n=0;n<o.length;++n)o[n]!==i&&delete this[o[n]]}};v.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};v._configure=function(){var l=v.Buffer;if(!l){v._Buffer_from=v._Buffer_allocUnsafe=null;return}v._Buffer_from=l.from!==Uint8Array.from&&l.from||function(i,n){return new l(i,n)},v._Buffer_allocUnsafe=l.allocUnsafe||function(i){return new l(i)}}});var ie=B((Dr,on)=>{"use strict";on.exports=m;var G=nt(),Xt,qt=G.LongBits,en=G.base64,nn=G.utf8;function vt(l,o,i){this.fn=l,this.len=o,this.next=void 0,this.val=i}function Yt(){}function Qn(l){this.head=l.head,this.tail=l.tail,this.len=l.len,this.next=l.states}function m(){this.len=0,this.head=new vt(Yt,0,0),this.tail=this.head,this.states=null}var rn=function(){return G.Buffer?function(){return(m.create=function(){return new Xt})()}:function(){return new m}};m.create=rn();m.alloc=function(o){return new G.Array(o)};G.Array!==Array&&(m.alloc=G.pool(m.alloc,G.Array.prototype.subarray));m.prototype._push=function(o,i,n){return this.tail=this.tail.next=new vt(o,i,n),this.len+=i,this};function te(l,o,i){o[i]=l&255}function Yn(l,o,i){for(;l>127;)o[i++]=l&127|128,l>>>=7;o[i]=l}function ee(l,o){this.len=l,this.next=void 0,this.val=o}ee.prototype=Object.create(vt.prototype);ee.prototype.fn=Yn;m.prototype.uint32=function(o){return this.len+=(this.tail=this.tail.next=new ee((o=o>>>0)<128?1:o<16384?2:o<2097152?3:o<268435456?4:5,o)).len,this};m.prototype.int32=function(o){return(o|=0)<0?this._push(ne,10,qt.fromNumber(o)):this.uint32(o)};m.prototype.sint32=function(o){return this.uint32((o<<1^o>>31)>>>0)};function ne(l,o,i){for(var n=l.lo,r=l.hi;r;)o[i++]=n&127|128,n=(n>>>7|r<<25)>>>0,r>>>=7;for(;n>127;)o[i++]=n&127|128,n=n>>>7;o[i++]=n}m.prototype.uint64=function(o){var i=qt.from(o);return this._push(ne,i.length(),i)};m.prototype.int64=m.prototype.uint64;m.prototype.sint64=function(o){var i=qt.from(o).zzEncode();return this._push(ne,i.length(),i)};m.prototype.bool=function(o){return this._push(te,1,o?1:0)};function Qt(l,o,i){o[i]=l&255,o[i+1]=l>>>8&255,o[i+2]=l>>>16&255,o[i+3]=l>>>24}m.prototype.fixed32=function(o){return this._push(Qt,4,o>>>0)};m.prototype.sfixed32=m.prototype.fixed32;m.prototype.fixed64=function(o){var i=qt.from(o);return this._push(Qt,4,i.lo)._push(Qt,4,i.hi)};m.prototype.sfixed64=m.prototype.fixed64;m.prototype.float=function(o){return this._push(G.float.writeFloatLE,4,o)};m.prototype.double=function(o){return this._push(G.float.writeDoubleLE,8,o)};var ti=G.Array.prototype.set?function(o,i,n){i.set(o,n)}:function(o,i,n){for(var r=0;r<o.length;++r)i[n+r]=o[r]};m.prototype.bytes=function(o){var i=o.length>>>0;if(!i)return this._push(te,1,0);if(G.isString(o)){var n=m.alloc(i=en.length(o));en.decode(o,n,0),o=n}return this.uint32(i)._push(ti,i,o)};m.prototype.string=function(o){var i=nn.length(o);return i?this.uint32(i)._push(nn.write,i,o):this._push(te,1,0)};m.prototype.fork=function(){return this.states=new Qn(this),this.head=this.tail=new vt(Yt,0,0),this.len=0,this};m.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new vt(Yt,0,0),this.len=0),this};m.prototype.ldelim=function(){var o=this.head,i=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=o.next,this.tail=i,this.len+=n),this};m.prototype.finish=function(){for(var o=this.head.next,i=this.constructor.alloc(this.len),n=0;o;)o.fn(o.val,i,n),n+=o.len,o=o.next;return i};m._configure=function(l){Xt=l,m.create=rn(),Xt._configure()}});var ln=B((Cr,cn)=>{"use strict";cn.exports=X;var sn=ie();(X.prototype=Object.create(sn.prototype)).constructor=X;var it=nt();function X(){sn.call(this)}X._configure=function(){X.alloc=it._Buffer_allocUnsafe,X.writeBytesBuffer=it.Buffer&&it.Buffer.prototype instanceof Uint8Array&&it.Buffer.prototype.set.name==="set"?function(o,i,n){i.set(o,n)}:function(o,i,n){if(o.copy)o.copy(i,n,0,o.length);else for(var r=0;r<o.length;)i[n++]=o[r++]}};X.prototype.bytes=function(o){it.isString(o)&&(o=it._Buffer_from(o,"base64"));var i=o.length>>>0;return this.uint32(i),i&&this._push(X.writeBytesBuffer,i,o),this};function ei(l,o,i){l.length<40?it.utf8.write(l,o,i):o.utf8Write?o.utf8Write(l,i):o.write(l,i)}X.prototype.string=function(o){var i=it.Buffer.byteLength(o);return this.uint32(i),i&&this._push(ei,i,o),this};X._configure()});var se=B((Ir,pn)=>{"use strict";pn.exports=E;var J=nt(),oe,an=J.LongBits,ni=J.utf8;function $(l,o){return RangeError("index out of range: "+l.pos+" + "+(o||1)+" > "+l.len)}function E(l){this.buf=l,this.pos=0,this.len=l.length}var un=typeof Uint8Array<"u"?function(o){if(o instanceof Uint8Array||Array.isArray(o))return new E(o);throw Error("illegal buffer")}:function(o){if(Array.isArray(o))return new E(o);throw Error("illegal buffer")},hn=function(){return J.Buffer?function(i){return(E.create=function(r){return J.Buffer.isBuffer(r)?new oe(r):un(r)})(i)}:un};E.create=hn();E.prototype._slice=J.Array.prototype.subarray||J.Array.prototype.slice;E.prototype.uint32=(function(){var o=4294967295;return function(){if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return o;if((this.pos+=5)>this.len)throw this.pos=this.len,$(this,10);return o}})();E.prototype.int32=function(){return this.uint32()|0};E.prototype.sint32=function(){var o=this.uint32();return o>>>1^-(o&1)|0};function re(){var l=new an(0,0),o=0;if(this.len-this.pos>4){for(;o<4;++o)if(l.lo=(l.lo|(this.buf[this.pos]&127)<<o*7)>>>0,this.buf[this.pos++]<128)return l;if(l.lo=(l.lo|(this.buf[this.pos]&127)<<28)>>>0,l.hi=(l.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return l;o=0}else{for(;o<3;++o){if(this.pos>=this.len)throw $(this);if(l.lo=(l.lo|(this.buf[this.pos]&127)<<o*7)>>>0,this.buf[this.pos++]<128)return l}return l.lo=(l.lo|(this.buf[this.pos++]&127)<<o*7)>>>0,l}if(this.len-this.pos>4){for(;o<5;++o)if(l.hi=(l.hi|(this.buf[this.pos]&127)<<o*7+3)>>>0,this.buf[this.pos++]<128)return l}else for(;o<5;++o){if(this.pos>=this.len)throw $(this);if(l.hi=(l.hi|(this.buf[this.pos]&127)<<o*7+3)>>>0,this.buf[this.pos++]<128)return l}throw Error("invalid varint encoding")}E.prototype.bool=function(){return this.uint32()!==0};function At(l,o){return(l[o-4]|l[o-3]<<8|l[o-2]<<16|l[o-1]<<24)>>>0}E.prototype.fixed32=function(){if(this.pos+4>this.len)throw $(this,4);return At(this.buf,this.pos+=4)};E.prototype.sfixed32=function(){if(this.pos+4>this.len)throw $(this,4);return At(this.buf,this.pos+=4)|0};function fn(){if(this.pos+8>this.len)throw $(this,8);return new an(At(this.buf,this.pos+=4),At(this.buf,this.pos+=4))}E.prototype.float=function(){if(this.pos+4>this.len)throw $(this,4);var o=J.float.readFloatLE(this.buf,this.pos);return this.pos+=4,o};E.prototype.double=function(){if(this.pos+8>this.len)throw $(this,4);var o=J.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,o};E.prototype.bytes=function(){var o=this.uint32(),i=this.pos,n=this.pos+o;if(n>this.len)throw $(this,o);if(this.pos+=o,Array.isArray(this.buf))return this.buf.slice(i,n);if(i===n){var r=J.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,i,n)};E.prototype.string=function(){var o=this.bytes();return ni.read(o,0,o.length)};E.prototype.skip=function(o){if(typeof o=="number"){if(this.pos+o>this.len)throw $(this,o);this.pos+=o}else do if(this.pos>=this.len)throw $(this);while(this.buf[this.pos++]&128);return this};E.recursionLimit=J.recursionLimit;E.prototype.skipType=function(l,o){if(o===void 0&&(o=0),o>E.recursionLimit)throw Error("maximum nesting depth exceeded");switch(l){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(l=this.uint32()&7)!==4;)this.skipType(l,o+1);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+l+" at offset "+this.pos)}return this};E._configure=function(l){oe=l,E.create=hn(),oe._configure();var o=J.Long?"toLong":"toNumber";J.merge(E.prototype,{int64:function(){return re.call(this)[o](!1)},uint64:function(){return re.call(this)[o](!0)},sint64:function(){return re.call(this).zzDecode()[o](!1)},fixed64:function(){return fn.call(this)[o](!0)},sfixed64:function(){return fn.call(this)[o](!1)}})}});var _n=B((Lr,yn)=>{"use strict";yn.exports=lt;var bn=se();(lt.prototype=Object.create(bn.prototype)).constructor=lt;var dn=nt();function lt(l){bn.call(this,l)}lt._configure=function(){dn.Buffer&&(lt.prototype._slice=dn.Buffer.prototype.slice)};lt.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))};lt._configure()});var vn=B((Br,gn)=>{"use strict";gn.exports=kt;var ce=nt();(kt.prototype=Object.create(ce.EventEmitter.prototype)).constructor=kt;function kt(l,o,i){if(typeof l!="function")throw TypeError("rpcImpl must be a function");ce.EventEmitter.call(this),this.rpcImpl=l,this.requestDelimited=!!o,this.responseDelimited=!!i}kt.prototype.rpcCall=function l(o,i,n,r,t){if(!r)throw TypeError("request must be specified");var e=this;if(!t)return ce.asPromise(l,e,o,i,n,r);if(!e.rpcImpl){setTimeout(function(){t(Error("already ended"))},0);return}try{return e.rpcImpl(o,i[e.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(s,u){if(s)return e.emit("error",s,o),t(s);if(u===null){e.end(!0);return}if(!(u instanceof n))try{u=n[e.responseDelimited?"decodeDelimited":"decode"](u)}catch(d){return e.emit("error",d,o),t(d)}return e.emit("data",u,o),t(null,u)})}catch(c){e.emit("error",c,o),setTimeout(function(){t(c)},0);return}};kt.prototype.end=function(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Sn=B(kn=>{"use strict";var ii=kn;ii.Service=vn()});var wn=B((qr,Pn)=>{"use strict";Pn.exports=Object.create(null)});var xn=B(mn=>{"use strict";var F=mn;F.build="minimal";F.Writer=ie();F.BufferWriter=ln();F.Reader=se();F.BufferReader=_n();F.util=nt();F.rpc=Sn();F.roots=wn();F.configure=On;function On(){F.util._configure(),F.Writer._configure(F.BufferWriter),F.Reader._configure(F.BufferReader)}On()});var le=B((Ur,Tn)=>{"use strict";Tn.exports=xn()});var Re=Pt(Ht());var mt=(n=>(n.Disconnected="disconnected",n.Connecting="connecting",n.Connected="connected",n))(mt||{}),xt=(n=>(n.Unsubscribed="unsubscribed",n.Subscribing="subscribing",n.Subscribed="subscribed",n))(xt||{});function Oe(l,o){return l.lastIndexOf(o,0)===0}function Tt(l){return l==null?!1:typeof l=="function"}function me(l,o){if(globalThis.console){let i=globalThis.console[l];Tt(i)&&i.apply(globalThis.console,o)}}function Fn(l,o){return Math.floor(Math.random()*(o-l+1)+l)}function Y(l,o,i){l>31&&(l=31);let n=Fn(0,Math.min(i,o*Math.pow(2,l)));return Math.min(i,o+n)}function xe(l){return"error"in l&&l.error!==null}function ot(l){return Math.min(l*1e3,2147483647)}function Te(l){try{return typeof localStorage>"u"||localStorage===null||!Tt(localStorage.getItem)?null:localStorage.getItem(l)}catch{return null}}var dt=class extends Re.default{constructor(i,n,r){super();this._resubscribeTimeout=null;this._refreshTimeout=null;this._getState=null;this._map=!1;this._mapPresenceType=1;this._mapPhase=null;this._mapStateBuffer=[];this._mapStreamBuffer=[];this._mapCursor="";this._mapPageSize=0;this._mapUnrecoverableStrategy="from_scratch";this._debounceMs=0;this._debouncePending=new Map;this._sharedPoll=!1;this._sharedPollEpoch="";this._sharedPollTrackedItems=new Map;this._sharedPollGetSignature=null;this._sharedPollSignatureRefreshTimeout=null;this._sharedPollSignatureRefreshAttempts=0;this._sharedPollTrackRetryTimeout=null;this._sharedPollTrackRetryAttempts=0;this._sharedPollReplayRetryTimeout=null;this._sharedPollReplayRetryAttempts=0;this._sharedPollSignatures=[];this._sharedPollSignatureRefreshTargetMs=null;this._sharedPollSignatureRefreshInFlight=!1;this.channel=n,this.state="unsubscribed",this._centrifuge=i,this._token="",this._getToken=null,this._data=null,this._getData=null,this._recover=!1,this._offset=null,this._epoch=null,this._id=0,this._recoverable=!1,this._positioned=!1,this._joinLeave=!1,this._minResubscribeDelay=500,this._maxResubscribeDelay=2e4,this._resubscribeTimeout=null,this._resubscribeAttempts=0,this._promises={},this._promiseId=0,this._inflight=!1,this._refreshTimeout=null,this._delta="",this._delta_negotiated=!1,this._tagsFilter=null,this._prevValueMap=new Map,this._unsubPromise=Promise.resolve(),this._deltaNumPubs=0,this._deltaNumFull=0,this._deltaNumDelta=0,this._deltaBytesReceived=0,this._deltaBytesDecoded=0,this._setOptions(r),this.type=this._sharedPoll?"shared_poll":this._map?"map":"stream",this._centrifuge._debugEnabled?(this.on("state",t=>{this._debug("subscription state",n,t.oldState,"->",t.newState)}),this.on("error",t=>{this._debug("subscription error",n,t)})):this.on("error",function(){Function.prototype()})}ready(i){return this.state==="unsubscribed"?Promise.reject({code:7,message:this.state}):this.state==="subscribed"?Promise.resolve():new Promise((n,r)=>{let t={resolve:n,reject:r};i&&(t.timeout=setTimeout(function(){r({code:1,message:"timeout"})},i)),this._promises[this._nextPromiseId()]=t})}subscribe(){this._isSubscribed()||(this._resubscribeAttempts=0,this._setSubscribing(0,"subscribe called"))}unsubscribe(){this._unsubPromise=this._setUnsubscribed(0,"unsubscribe called",!0)}_debouncedPublish(i,n,r){let t=this._debouncePending.get(i);if(t)return t.data=n,t.dirty=!0,Promise.resolve({});let e={data:n,dirty:!1,timer:null};return e.timer=setTimeout(()=>{let s=this._debouncePending.get(i);if(!s||!s.dirty){this._debouncePending.delete(i);return}s.dirty=!1;let u=s.data;(r?this._centrifuge.mapPublish(this.channel,i,u):this._centrifuge.publish(this.channel,u)).catch(()=>{}),s.timer=setTimeout(()=>{let g=this._debouncePending.get(i);if(!g||!g.dirty){this._debouncePending.delete(i);return}this._debouncePending.delete(i),this._debouncedPublish(i,g.data,r)},this._debounceMs)},this._debounceMs),this._debouncePending.set(i,e),r?this._centrifuge.mapPublish(this.channel,i,n):this._centrifuge.publish(this.channel,n)}_cancelDebounce(i){let n=this._debouncePending.get(i);n&&(clearTimeout(n.timer),this._debouncePending.delete(i))}_cancelAllDebounce(){for(let[,i]of this._debouncePending)clearTimeout(i.timer);this._debouncePending.clear()}async presence(){return await this._methodCall(),this._centrifuge.presence(this.channel)}async presenceStats(){return await this._methodCall(),this._centrifuge.presenceStats(this.channel)}setTagsFilter(i){if(i&&this._delta)throw new Error("cannot use delta and tagsFilter together");this._tagsFilter=i,this._map&&(this._recover=!1,this._offset=null,this._epoch=null)}setData(i){this._data=i}deltaStats(){let i=this._deltaBytesDecoded;return{numPublications:this._deltaNumPubs,numFullPayloads:this._deltaNumFull,numDeltaPayloads:this._deltaNumDelta,bytesReceived:this._deltaBytesReceived,bytesDecoded:i,compressionRatio:i>0?1-this._deltaBytesReceived/i:0}}_methodCall(){return this._isSubscribed()?Promise.resolve():this._isUnsubscribed()?Promise.reject({code:7,message:this.state}):new Promise((i,n)=>{let r=this._centrifuge._config.timeout,t=setTimeout(()=>{n({code:1,message:"timeout"})},r);this._promises[this._nextPromiseId()]={timeout:t,resolve:i,reject:n}})}_nextPromiseId(){return++this._promiseId}_needRecover(){return this._recover===!0}_isUnsubscribed(){return this.state==="unsubscribed"}_isSubscribing(){return this.state==="subscribing"}_isSubscribed(){return this.state==="subscribed"}_setState(i){if(this.state!==i){let n=this.state;return this.state=i,this.emit("state",{newState:i,oldState:n,channel:this.channel}),!0}return!1}_usesToken(){return this._token!==""||this._getToken!==null}_clearSubscribingState(){this._resubscribeAttempts=0,this._clearResubscribeTimeout()}_clearSubscribedState(){this._clearRefreshTimeout(),this._clearSharedPollSignatureRefresh(),this._clearSharedPollTrackRetry(),this._clearSharedPollReplayRetry(),this._sharedPollSignatureRefreshTargetMs=null,this._sharedPollSignatureRefreshInFlight=!1}_invalidateState(){this._token="",this._prevValueMap=new Map,this._map?(this._offset=null,this._epoch=null,this._recover=!1,this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapCursor="",this._mapPhase=null):(this._offset=0,this._epoch="_")}_setSubscribed(i){if(!this._isSubscribing())return;if(this._clearSubscribingState(),i.id&&(this._id=i.id),i.recoverable&&(this._recover=!0,this._offset=i.offset||0,this._epoch=i.epoch||""),i.delta?this._delta_negotiated=!0:this._delta_negotiated=!1,i.publish_debounce&&(this._debounceMs=i.publish_debounce),this._sharedPoll){let t=i.epoch||"";if(this._sharedPollEpoch!==""&&this._sharedPollEpoch!==t)for(let e of this._sharedPollTrackedItems.keys())this._sharedPollTrackedItems.set(e,0);this._sharedPollEpoch=t}this._setState("subscribed");let n=this._centrifuge._getSubscribeContext(this.channel,i);this.emit("subscribed",n),this._resolvePromises();let r=i.publications;if(r&&r.length>0)for(let t in r)r.hasOwnProperty(t)&&this._handlePublication(r[t]);i.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),ot(i.ttl)))}async _setSubscribing(i,n){this._isSubscribing()||(this._isSubscribed()&&this._clearSubscribedState(),this._id=0,this._setState("subscribing")&&this.emit("subscribing",{channel:this.channel,code:i,reason:n}),this._centrifuge._transport&&this._centrifuge._transport.emulation()&&await this._unsubPromise,this._isSubscribing()&&this._subscribe())}_subscribe(){return this._debug("subscribing on",this.channel),this._isTransportOpen()?this._inflight?null:(this._inflight=!0,this._map?(this._mapSubscribe(),null):this._getState&&this._offset===null?(this._loadStreamState(),null):this._canSubscribeWithoutGettingToken()?this._subscribeWithoutToken():(this._getSubscriptionToken().then(i=>this._handleTokenResponse(i)).catch(i=>this._handleTokenError(i)),null)):(this._debug("delay subscribe on",this.channel,"till connected"),null)}_isTransportOpen(){return this._centrifuge._transportIsOpen}_canSubscribeWithoutGettingToken(){return!this._usesToken()||!!this._token}_subscribeWithoutToken(){return this._getData?(this._getDataAndSubscribe(this._token),null):this._sendSubscribe(this._token)}_loadStreamState(){if(!this._isSubscribing()){this._inflight=!1;return}this._getState().then(i=>{if(!this._isSubscribing()){this._inflight=!1;return}this._offset=i.offset,this._epoch=i.epoch,this._recover=!0,this._canSubscribeWithoutGettingToken()?this._subscribeWithoutToken():this._getSubscriptionToken().then(n=>this._handleTokenResponse(n)).catch(n=>this._handleTokenError(n))}).catch(i=>{if(!this._isSubscribing()){this._inflight=!1;return}this._inflight=!1,this._subscribeError({code:13,message:i?.toString()||"getState failed",temporary:!0})})}_getDataAndSubscribe(i){if(!this._getData){this._inflight=!1;return}this._getData({channel:this.channel}).then(n=>{if(!this._isSubscribing()){this._inflight=!1;return}this._data=n,this._sendSubscribe(i)}).catch(n=>this._handleGetDataError(n))}_handleGetDataError(i){if(!this._isSubscribing()){this._inflight=!1;return}if(i instanceof V){this._inflight=!1,this._failUnauthorized();return}this.emit("error",{type:"subscribeData",channel:this.channel,error:{code:12,message:i?.toString()||""}}),this._inflight=!1,this._scheduleResubscribe()}_handleTokenResponse(i){if(!this._isSubscribing()){this._inflight=!1;return}if(!i){this._inflight=!1,this._failUnauthorized();return}this._token=i,this._getData?this._getDataAndSubscribe(i):this._sendSubscribe(i)}_handleTokenError(i){if(!this._isSubscribing()){this._inflight=!1;return}if(i instanceof V){this._inflight=!1,this._failUnauthorized();return}this.emit("error",{type:"subscribeToken",channel:this.channel,error:{code:8,message:i?.toString()||""}}),this._inflight=!1,this._scheduleResubscribe()}_sendSubscribe(i){if(!this._isTransportOpen())return this._inflight=!1,null;let n=this._buildSubscribeCommand(i);return this._centrifuge._call(n).then(r=>{this._inflight=!1;let t=r.reply.subscribe;this._handleSubscribeResponse(t),r.next&&r.next()},r=>{this._inflight=!1,this._handleSubscribeError(r.error),r.next&&r.next()}),n}_buildSubscribeCommand(i){let n={channel:this.channel};if(i&&(n.token=i),this._data&&(n.data=this._data),this._sharedPoll)return n.type=4,this._delta&&(n.delta=this._delta),{subscribe:n};if(this._positioned&&(n.positioned=!0),this._recoverable&&(n.recoverable=!0),this._joinLeave&&(n.join_leave=!0),n.flag=1,this._getState&&(n.flag|=2),this._needRecover()){n.recover=!0;let r=this._getOffset();r&&(n.offset=r);let t=this._getEpoch();t&&(n.epoch=t)}return this._delta&&(n.delta=this._delta),this._tagsFilter&&(n.tf=this._tagsFilter),{subscribe:n}}_debug(...i){this._centrifuge._debug(...i)}_handleSubscribeError(i){if(this._isSubscribing()){if(i.code===1){this._centrifuge._disconnect(3,"subscribe timeout",!0);return}if(i.code===112&&this._getState){this._offset=null,this._epoch=null,this._recover=!1,this._prevValueMap=new Map,this._scheduleResubscribe();return}this._subscribeError(i)}}_handleSubscribeResponse(i){this._isSubscribing()&&(this._setSubscribed(i),this._sharedPoll&&this._sharedPollReplayTrack())}_setUnsubscribed(i,n,r){if(this._isUnsubscribed())return Promise.resolve();let t=Promise.resolve();return this._isSubscribed()?(r&&(t=this._centrifuge._unsubscribe(this)),this._clearSubscribedState()):this._isSubscribing()&&(this._inflight&&r&&(t=this._centrifuge._unsubscribe(this)),this._clearSubscribingState()),this._inflight=!1,this._id=0,this._sharedPollEpoch="",this._sharedPollSignatures=[],this._sharedPollTrackedItems.clear(),this._sharedPollSignatureRefreshInFlight=!1,this._sharedPollSignatureRefreshTargetMs=null,this._cancelAllDebounce(),this._setState("unsubscribed")&&this.emit("unsubscribed",{channel:this.channel,code:i,reason:n}),this._rejectPromises({code:7,message:this.state}),t}_handlePublication(i){if(this._delta&&this._delta_negotiated){let r=(this._map||this._sharedPoll)&&i.key||"",{newData:t,newPrevValue:e,isDelta:c,wireBytes:s,fullBytes:u}=this._centrifuge._codec.applyDeltaIfNeeded(i,this._prevValueMap.get(r));i.data=t,this._deltaNumPubs++,this._deltaBytesReceived+=s,this._deltaBytesDecoded+=u,c?this._deltaNumDelta++:this._deltaNumFull++,i.removed?this._prevValueMap.delete(r):this._prevValueMap.set(r,e)}let n;if(this._sharedPoll){if(i.key&&!this._sharedPollTrackedItems.has(i.key))return;i.key&&(i.removed?this._sharedPollTrackedItems.delete(i.key):i.version&&this._sharedPollTrackedItems.set(i.key,i.version)),n=this._getSharedPollUpdateContext(i)}else this._map?n=this._getMapUpdateContext(i):n=this._centrifuge._getPublicationContext(this.channel,i);this.emit("publication",n),(this._map||this._sharedPoll)&&this.emit("update",n),i.offset&&(this._offset=i.offset),i.epoch&&(this._epoch=i.epoch)}_seedDeltaTracking(i){if(!(!this._delta||!i.key)){if(typeof i.data=="string"){let n=i.data;i.removed?this._prevValueMap.delete(i.key):this._prevValueMap.set(i.key,new TextEncoder().encode(n));let r=n.length;this._deltaNumPubs++,this._deltaNumFull++,this._deltaBytesReceived+=r,this._deltaBytesDecoded+=r,i.data=JSON.parse(n)}else if(i.data instanceof Uint8Array){i.removed?this._prevValueMap.delete(i.key):this._prevValueMap.set(i.key,i.data);let n=i.data.length;this._deltaNumPubs++,this._deltaNumFull++,this._deltaBytesReceived+=n,this._deltaBytesDecoded+=n}}}_handleJoin(i){let n=this._centrifuge._getJoinLeaveContext(i.info);this.emit("join",{channel:this.channel,info:n})}_handleLeave(i){let n=this._centrifuge._getJoinLeaveContext(i.info);this.emit("leave",{channel:this.channel,info:n})}_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])}_scheduleResubscribe(){if(!this._isSubscribing()){this._debug("not in subscribing state, skip resubscribe scheduling",this.channel);return}let i=this,n=this._getResubscribeDelay();this._resubscribeTimeout=setTimeout(function(){i._isSubscribing()&&i._subscribe()},n),this._debug("resubscribe scheduled after "+n,this.channel)}_subscribeError(i){if(this._isSubscribing())if(i.code<100||i.code===109||i.temporary===!0){i.code===109&&(this._token="");let n={channel:this.channel,type:"subscribe",error:i};this._centrifuge.state==="connected"&&this.emit("error",n),this._scheduleResubscribe()}else this._setUnsubscribed(i.code,i.message,!1)}_getResubscribeDelay(){let i=Y(this._resubscribeAttempts,this._minResubscribeDelay,this._maxResubscribeDelay);return this._resubscribeAttempts++,i}_setOptions(i){if(i){if(i.since&&(this._offset=i.since.offset||0,this._epoch=i.since.epoch||"",this._recover=!0),i.data&&(this._data=i.data),i.getData&&(this._getData=i.getData),i.minResubscribeDelay!==void 0&&(this._minResubscribeDelay=i.minResubscribeDelay),i.maxResubscribeDelay!==void 0&&(this._maxResubscribeDelay=i.maxResubscribeDelay),i.token&&(this._token=i.token),i.getToken&&(this._getToken=i.getToken),i.positioned===!0&&(this._positioned=!0),i.recoverable===!0&&(this._recoverable=!0),i.joinLeave===!0&&(this._joinLeave=!0),i.delta){if(i.delta!=="fossil")throw new Error("unsupported delta format");this._delta=i.delta}if(i.tagsFilter&&(this._tagsFilter=i.tagsFilter),this._tagsFilter&&this._delta)throw new Error("cannot use delta and tagsFilter together");i.getState&&(this._getState=i.getState,this._recover=!0),i.map===!0&&(this._map=!0),i.mapPageSize!==void 0&&(this._mapPageSize=i.mapPageSize),i.mapPresenceType!==void 0&&(this._mapPresenceType=i.mapPresenceType,this._map=!0),i.mapUnrecoverableStrategy&&(this._mapUnrecoverableStrategy=i.mapUnrecoverableStrategy),i.sharedPoll===!0&&(this._sharedPoll=!0),i.sharedPollGetSignature&&(this._sharedPollGetSignature=i.sharedPollGetSignature)}}_getOffset(){let i=this._offset;return i!==null?i:0}_getEpoch(){let i=this._epoch;return i!==null?i:""}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearResubscribeTimeout(){this._resubscribeTimeout!==null&&(clearTimeout(this._resubscribeTimeout),this._resubscribeTimeout=null)}_getSubscriptionToken(){this._debug("get subscription token for channel",this.channel);let i={channel:this.channel},n=this._getToken;return n===null?(this.emit("error",{type:"configuration",channel:this.channel,error:{code:12,message:"provide a function to get channel subscription token"}}),Promise.reject(new V(""))):n(i)}_refresh(){this._clearRefreshTimeout();let i=this;this._getSubscriptionToken().then(function(n){if(!i._isSubscribed())return;if(!n){i._failUnauthorized();return}i._token=n;let t={sub_refresh:{channel:i.channel,token:n}};i._centrifuge._call(t).then(e=>{let c=e.reply.sub_refresh;i._refreshResponse(c),e.next&&e.next()},e=>{i._refreshError(e.error),e.next&&e.next()})}).catch(function(n){if(n instanceof V){i._failUnauthorized();return}i.emit("error",{type:"refreshToken",channel:i.channel,error:{code:9,message:n!==void 0?n.toString():""}}),i._refreshTimeout=setTimeout(()=>i._refresh(),i._getRefreshRetryDelay())})}_refreshResponse(i){this._isSubscribed()&&(this._debug("subscription token refreshed, channel",this.channel),this._clearRefreshTimeout(),i.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),ot(i.ttl))))}_refreshError(i){this._isSubscribed()&&(i.code<100||i.temporary===!0?(this.emit("error",{type:"refresh",channel:this.channel,error:i}),this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())):this._setUnsubscribed(i.code,i.message,!0))}_getRefreshRetryDelay(){return Y(0,1e4,2e4)}_failUnauthorized(){this._setUnsubscribed(1,"unauthorized",!0)}_sendTrackRequest(i,n){if(i.length===0)return Promise.resolve();let r=6e4,t=[],e=[],c=100;if(n&&n.length>0)for(let u of n)c+=u.length+4;for(let u of i){let d=100;for(let g of u.items)d+=g.key.length+16;e.length>0&&c+d>r&&(t.push(e),e=[],c=100),e.push(u),c+=d}e.length>0&&t.push(e);let s=(u,d)=>new Promise((g,k)=>{let P={channel:this.channel,type:1,track:u.map(w=>({signature:w.signature,items:w.items.map(D=>D.version>0?D:{key:D.key})}))};d&&d.length>0&&(P.untrack=d);let x={sub_refresh:P};this._centrifuge._call(x).then(w=>{this._handleTrackResponse(w.reply.sub_refresh),w.next&&w.next(),g()},w=>{w.next&&w.next(),k(w.error)})});return t.reduce((u,d,g)=>u.then(()=>s(d,g===0?n:void 0)),Promise.resolve())}_sendUntrackRequest(i){return new Promise((n,r)=>{let e={sub_refresh:{channel:this.channel,type:2,untrack:i}};this._centrifuge._call(e).then(c=>{c.next&&c.next(),n()},c=>{c.next&&c.next(),r(c.error)})})}_handleTrackResponse(i){if(this._clearSharedPollTrackRetry(),i&&i.items&&i.items.length>0)for(let n of i.items)this._handlePublication(n);if(i&&i.expires===!0&&i.ttl>0){let n=Date.now()+i.ttl*1e3;this._maybeScheduleSharedPollSignatureRefresh(n)}}_maybeScheduleSharedPollSignatureRefresh(i){if(i===null){this._sharedPollSignatureRefreshTargetMs=null,this._clearSharedPollSignatureRefresh();return}this._isSubscribed()&&(this._sharedPollSignatureRefreshTargetMs!==null&&i>=this._sharedPollSignatureRefreshTargetMs||(this._sharedPollSignatureRefreshTargetMs=i,this._clearSharedPollSignatureRefresh(),this._sharedPollSignatureRefreshTimeout=setTimeout(()=>this._sharedPollRefreshSignature(),Math.max(0,i-Date.now()))))}_clearSharedPollSignatureRefresh(){this._sharedPollSignatureRefreshTimeout!==null&&(clearTimeout(this._sharedPollSignatureRefreshTimeout),this._sharedPollSignatureRefreshTimeout=null),this._sharedPollSignatureRefreshAttempts=0}_clearSharedPollTrackRetry(){this._sharedPollTrackRetryTimeout!==null&&(clearTimeout(this._sharedPollTrackRetryTimeout),this._sharedPollTrackRetryTimeout=null),this._sharedPollTrackRetryAttempts=0}_clearSharedPollReplayRetry(){this._sharedPollReplayRetryTimeout!==null&&(clearTimeout(this._sharedPollReplayRetryTimeout),this._sharedPollReplayRetryTimeout=null),this._sharedPollReplayRetryAttempts=0}_handleTrackError(i){if(this._isSubscribed()){if(this.emit("error",{type:"track",channel:this.channel,error:i}),i.code===109){this._sharedPollRefreshSignature();return}(i.code<100||i.temporary===!0)&&(this._sharedPollTrackRetryTimeout=setTimeout(()=>this._sharedPollReplayTrack(),Y(this._sharedPollTrackRetryAttempts++,1e3,15e3)))}}_sharedPollRefreshSignature(){if(this._clearSharedPollSignatureRefresh(),!this._isSubscribed()||!this._sharedPollGetSignature||this._sharedPollTrackedItems.size===0||this._sharedPollSignatureRefreshInFlight)return;this._sharedPollSignatureRefreshTargetMs=null,this._sharedPollSignatureRefreshInFlight=!0;let i=Array.from(this._sharedPollTrackedItems.keys()),n=this;this._sharedPollGetSignature({keys:i}).then(r=>{if(n._sharedPollSignatureRefreshInFlight=!1,!n._isSubscribed())return;n._sharedPollSignatureRefreshAttempts=0;let t=new Set(r.keys),e=[];for(let d of i)t.has(d)||(n._sharedPollTrackedItems.delete(d),e.push(d),n.emit("update",{channel:n.channel,key:d,data:null,removed:!0}));e.length>0&&n._sendUntrackRequest(e).catch(d=>{n.emit("error",{type:"untrack",channel:n.channel,error:d})});let c=[];for(let d of r.keys){let g=n._sharedPollTrackedItems.get(d);g!==void 0&&c.push({key:d,version:g})}let s=new Set(r.keys),u=n._sharedPollSignatures.filter(d=>d.keys.some(g=>n._sharedPollTrackedItems.has(g)&&!s.has(g)));n._sharedPollSignatures=c.length>0?[{keys:r.keys,signature:r.signature},...u]:u,c.length!==0&&n._sendTrackRequest([{items:c,signature:r.signature}]).catch(d=>{n._handleTrackError(d)})}).catch(r=>{n._sharedPollSignatureRefreshInFlight=!1,n.emit("error",{type:"signatureRefresh",channel:n.channel,error:{code:14,message:r!==void 0?r.toString():""}}),n._sharedPollSignatureRefreshTimeout=setTimeout(()=>n._sharedPollRefreshSignature(),Y(n._sharedPollSignatureRefreshAttempts++,5e3,3e4))})}_sharedPollReplayTrack(){if(!this._isSubscribed()||this._sharedPollTrackedItems.size===0&&this._sharedPollSignatures.length===0)return;let i=new Set,n=[],r=[];for(let c of this._sharedPollSignatures){let s=c.keys.map(u=>({key:u,version:this._sharedPollTrackedItems.get(u)??0}));n.push({items:s,signature:c.signature});for(let u of c.keys)this._sharedPollTrackedItems.has(u)?i.add(u):r.push(u)}n.length>0&&this._sendTrackRequest(n,r).catch(c=>{this._handleTrackError(c)});let t=[];for(let c of this._sharedPollTrackedItems.keys())i.has(c)||t.push(c);if(t.length===0)return;if(!this._sharedPollGetSignature){this.emit("error",{type:"track",channel:this.channel,error:{code:14,message:"getSignature callback required for tracked keys without an explicit signature"}});return}let e=this;this._sharedPollGetSignature({keys:t}).then(c=>{if(!e._isSubscribed())return;e._clearSharedPollReplayRetry();let s=new Set(c.keys),u=[];for(let g of t)s.has(g)||(e._sharedPollTrackedItems.delete(g),u.push(g),e.emit("update",{channel:e.channel,key:g,data:null,removed:!0}));u.length>0&&e._sendUntrackRequest(u).catch(g=>{e.emit("error",{type:"untrack",channel:e.channel,error:g})});let d=[];for(let g of c.keys){let k=e._sharedPollTrackedItems.get(g);k!==void 0&&d.push({key:g,version:k})}d.length!==0&&(e._sharedPollSignatures.push({keys:c.keys,signature:c.signature}),e._sendTrackRequest([{items:d,signature:c.signature}]).catch(g=>{e._handleTrackError(g)}))}).catch(c=>{e.emit("error",{type:"signatureRefresh",channel:e.channel,error:{code:14,message:c!==void 0?c.toString():""}}),e._sharedPollReplayRetryTimeout=setTimeout(()=>e._sharedPollReplayTrack(),Y(e._sharedPollReplayRetryAttempts++,5e3,3e4))})}_mapSubscribe(){if(this._debug("starting map subscribe on",this.channel),this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapCursor="",this._recover&&this._offset!==null&&this._epoch!==null||(this._prevValueMap=new Map),this._mapPhase=2,this._recover&&this._offset!==null&&this._epoch!==null){this._debug("map subscribe: recovering from position, skipping to stream phase"),this._mapPhase=1,this._fetchStream();return}this._canSubscribeWithoutGettingToken()?this._fetchSnapshot():this._getSubscriptionToken().then(i=>{if(!this._isSubscribing()){this._inflight=!1;return}if(!i){this._inflight=!1,this._failUnauthorized();return}this._token=i,this._fetchSnapshot()}).catch(i=>this._handleTokenError(i))}_fetchSnapshot(i){if(!this._isSubscribing()||!this._isTransportOpen()){this._inflight=!1;return}let n=this._buildMapSubscribeCommand(2,i);this._debug("map subscribe: fetching snapshot page",i?`cursor=${i}`:"initial"),this._centrifuge._call(n).then(r=>{let t=r.reply.subscribe;this._handleMapStateResponse(t),r.next&&r.next()},r=>{this._handleMapSubscribeError(r.error),r.next&&r.next()})}_handleMapStateResponse(i){if(!this._isSubscribing()){this._inflight=!1;return}if(!i.phase){this._debug("map subscribe: server forced LIVE transition during state pagination"),this._handleMapLiveResponse(i);return}if(!this._epoch&&i.epoch&&(this._epoch=i.epoch,this._offset=i.offset||0),this._epoch&&i.epoch&&this._epoch!==i.epoch){this._debug("map subscribe: epoch changed during snapshot pagination, restarting"),this._mapStateBuffer=[],this._mapCursor="",this._epoch=null,this._offset=null,this._prevValueMap=new Map,this._fetchSnapshot();return}if(i.state&&i.state.length>0)for(let n of i.state)this._seedDeltaTracking(n),this._mapStateBuffer.push(this._getMapUpdateContext(n));if(i.cursor){this._mapCursor=i.cursor,this._fetchSnapshot(this._mapCursor);return}this._transitionFromSnapshot()}_transitionFromSnapshot(){this._debug("map subscribe: snapshot complete, transitioning to stream phase"),this._mapPhase=1,this._fetchStream()}_fetchStream(){if(!this._isSubscribing()||!this._isTransportOpen()){this._inflight=!1;return}let i=this._buildMapSubscribeCommand(1);this._debug("map subscribe: fetching stream from offset",this._offset),this._centrifuge._call(i).then(n=>{let r=n.reply.subscribe;this._handleMapStreamResponse(r),n.next&&n.next()},n=>{this._handleMapSubscribeError(n.error),n.next&&n.next()})}_handleMapStreamResponse(i){if(!this._isSubscribing()){this._inflight=!1;return}if(!i.phase){this._debug("map subscribe: server forced LIVE transition during stream"),this._handleMapLiveResponse(i);return}if(this._epoch&&i.epoch&&this._epoch!==i.epoch){this._debug("map subscribe: epoch changed during stream, restarting"),this._mapStateBuffer=[],this._mapStreamBuffer=[],this._epoch=null,this._offset=null,this._prevValueMap=new Map,this._mapPhase=2,this._fetchSnapshot();return}if(i.publications&&i.publications.length>0)for(let n of i.publications)this._seedDeltaTracking(n),this._mapStreamBuffer.push(this._getMapUpdateContext(n));i.offset!==void 0&&(this._offset=i.offset),this._fetchStream()}_handleMapLiveResponse(i){if(!this._isSubscribing()){this._inflight=!1;return}if(this._inflight=!1,this._epoch&&i.epoch&&this._epoch!==i.epoch){this._debug("map subscribe: epoch changed during live transition, restarting"),this._mapStateBuffer=[],this._mapStreamBuffer=[],this._epoch=null,this._offset=null,this._prevValueMap=new Map,this._inflight=!0,this._mapPhase=2,this._fetchSnapshot();return}if(i.state&&i.state.length>0)for(let r of i.state)this._seedDeltaTracking(r),this._mapStateBuffer.push(this._getMapUpdateContext(r));if(i.publications&&i.publications.length>0)for(let r of i.publications){if(this._delta&&i.delta){let t=r.key||"",{newData:e,newPrevValue:c,isDelta:s,wireBytes:u,fullBytes:d}=this._centrifuge._codec.applyDeltaIfNeeded(r,this._prevValueMap.get(t));r.data=e,this._deltaNumPubs++,this._deltaBytesReceived+=u,this._deltaBytesDecoded+=d,s?this._deltaNumDelta++:this._deltaNumFull++,r.removed?this._prevValueMap.delete(t):this._prevValueMap.set(t,c)}else this._delta&&r.key&&(r.removed?this._prevValueMap.delete(r.key):this._prevValueMap.set(r.key,r.data));this._mapStreamBuffer.push(this._getMapUpdateContext(r))}this._offset=i.offset||0,this._epoch=i.epoch||"",this._clearSubscribingState(),i.id&&(this._id=i.id),this._recover=i.recoverable===!0,i.delta?this._delta_negotiated=!0:this._delta_negotiated=!1,i.publish_debounce&&(this._debounceMs=i.publish_debounce),this._setState("subscribed");let n=this._centrifuge._getSubscribeContext(this.channel,i);if(n.state=this._mapStateBuffer,this.emit("subscribed",n),this._resolvePromises(),!n.recovered){if(this._mapStreamBuffer.length>0){let r=new Map;for(let t of this._mapStateBuffer)r.set(t.key,t);for(let t of this._mapStreamBuffer)t.removed?r.delete(t.key):r.set(t.key,t);this._mapStateBuffer=Array.from(r.values()),this._mapStreamBuffer=[]}this.emit("sync",{entries:this._mapStateBuffer})}for(let r of this._mapStreamBuffer)this.emit("publication",r),this.emit("update",r);this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapPhase=null,i.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),ot(i.ttl)))}_handleMapSubscribeError(i){if(this._inflight=!1,!!this._isSubscribing()){if(i.code===1){this._centrifuge._disconnect(3,"subscribe timeout",!0);return}if(this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapPhase=null,this._prevValueMap=new Map,i.code===112&&this._mapUnrecoverableStrategy==="from_scratch"){this._debug("map subscribe: unrecoverable position, restarting from scratch"),this._offset=null,this._epoch=null,this._recover=!1,this._scheduleResubscribe();return}this._subscribeError(i)}}_buildMapSubscribeCommand(i,n){let r={channel:this.channel,type:this._mapPresenceType||1,phase:i};return this._token&&(r.token=this._token),this._tagsFilter&&(r.tf=this._tagsFilter),this._delta&&(r.delta=this._delta),r.flag=1,i===2&&(this._mapPageSize>0&&(r.limit=this._mapPageSize),n&&(r.cursor=n),this._epoch?(r.offset=this._offset,r.epoch=this._epoch):this._data&&(r.data=this._data)),i===1&&(this._mapPageSize>0&&(r.limit=this._mapPageSize),r.offset=this._offset,r.epoch=this._epoch,this._recover&&(r.recover=!0,this._mapStreamBuffer.length===0&&this._data&&(r.data=this._data))),{subscribe:r}}_getMapUpdateContext(i){let n={channel:this.channel,data:i.data,key:i.key||""};return i.removed===!0&&(n.removed=!0),i.offset!==void 0&&(n.offset=i.offset),i.info&&(n.info=this._centrifuge._getJoinLeaveContext(i.info)),i.tags&&(n.tags=i.tags),n}_getSharedPollUpdateContext(i){let n={channel:this.channel,key:i.key||"",data:i.data};return i.removed===!0&&(n.removed=!0),i.version!==void 0&&(n.version=i.version),n}},Rt=class extends dt{async publish(o){return await this._methodCall(),this._debounceMs>0?this._debouncedPublish("",o,!1):this._centrifuge.publish(this.channel,o)}async history(o){return await this._methodCall(),this._centrifuge.history(this.channel,o)}},ht=class extends dt{async publish(o,i){return await this._methodCall(),this._debounceMs>0?this._debouncedPublish(o,i,!0):this._centrifuge.mapPublish(this.channel,o,i)}async remove(o){return await this._methodCall(),this._cancelDebounce(o),this._centrifuge.mapRemove(this.channel,o)}},jt=class extends dt{track(o,i){if(o.length===0)return;let n,r=i;typeof o[0]=="string"?n=o.map(c=>({key:c,version:0})):n=o;for(let e of n){let c=this._sharedPollTrackedItems.get(e.key);(c===void 0||e.version>c)&&this._sharedPollTrackedItems.set(e.key,e.version)}if(r!==void 0){this._sharedPollSignatures.push({keys:n.map(e=>e.key),signature:r}),this._isSubscribed()&&this._sendTrackRequest([{items:n,signature:r}]).catch(e=>{this._handleTrackError(e)});return}if(!this._sharedPollGetSignature){this.emit("error",{type:"track",channel:this.channel,error:{code:14,message:"getSignature callback required for track(keys)"}});return}if(!this._isSubscribed())return;let t=n.map(e=>e.key);this._sharedPollGetSignature({keys:t}).then(e=>{if(!this._isSubscribed())return;let c=new Set(e.keys),s=[];for(let d of t)c.has(d)||(this._sharedPollTrackedItems.delete(d),s.push(d),this.emit("update",{channel:this.channel,key:d,data:null,removed:!0}));s.length>0&&this._sendUntrackRequest(s).catch(d=>{this.emit("error",{type:"untrack",channel:this.channel,error:d})});let u=[];for(let d of e.keys){let g=this._sharedPollTrackedItems.get(d);g!==void 0&&u.push({key:d,version:g})}u.length!==0&&(this._sharedPollSignatures.push({keys:e.keys,signature:e.signature}),this._sendTrackRequest([{items:u,signature:e.signature}]).catch(d=>{this._handleTrackError(d)}))}).catch(e=>{this.emit("error",{type:"track",channel:this.channel,error:{code:14,message:e!==void 0?e.toString():"getSignature failed"}})})}untrack(o){for(let i of o)this._sharedPollTrackedItems.delete(i);this._sharedPollSignatures=this._sharedPollSignatures.filter(i=>i.keys.some(n=>this._sharedPollTrackedItems.has(n))),this._isSubscribed()&&this._sendUntrackRequest(o).catch(i=>{this.emit("error",{type:"untrack",channel:this.channel,error:i})})}trackedKeys(){return new Set(this._sharedPollTrackedItems.keys())}};var Et=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null}name(){return"sockjs"}subName(){return"sockjs-"+this._transport.transport}emulation(){return!1}supported(){return this.options.sockjs!==null}initialize(o,i){this._transport=new this.options.sockjs(this.endpoint,null,this.options.sockjsOptions),this._transport.onopen=()=>{i.onOpen()},this._transport.onerror=n=>{i.onError(n)},this._transport.onclose=n=>{i.onClose(n)},this._transport.onmessage=n=>{i.onMessage(n.data)}}close(){this._transport.close()}send(o){this._transport.send(o)}};var bt=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null}name(){return"websocket"}subName(){return"websocket"}emulation(){return!1}supported(){return this.options.websocket!==void 0&&this.options.websocket!==null}initialize(o,i){let n="";o==="protobuf"&&(n="centrifuge-protobuf"),n!==""?this._transport=new this.options.websocket(this.endpoint,n):this._transport=new this.options.websocket(this.endpoint),o==="protobuf"&&(this._transport.binaryType="arraybuffer"),this._transport.onopen=()=>{i.onOpen()},this._transport.onerror=r=>{i.onError(r)},this._transport.onclose=r=>{i.onClose(r)},this._transport.onmessage=r=>{i.onMessage(r.data)}}close(){this._transport.close()}send(o){this._transport.send(o)}};var Dt=class{constructor(o,i){this.endpoint=o,this.options=i,this._abortController=null,this._utf8decoder=new TextDecoder,this._protocol="json"}name(){return"http_stream"}subName(){return"http_stream"}emulation(){return!0}_handleErrors(o){if(!o.ok)throw new Error(o.status);return o}_fetchEventTarget(o,i,n){let r=new EventTarget,t=o.options.fetch;return t(i,n).then(o._handleErrors).then(e=>{r.dispatchEvent(new Event("open"));let c="",s=0,u=new Uint8Array,d=e.body.getReader();return new o.options.readableStream({start(g){function k(){return d.read().then(({done:P,value:x})=>{if(P){r.dispatchEvent(new Event("close")),g.close();return}try{if(o._protocol==="json")for(c+=o._utf8decoder.decode(x);s<c.length;)if(c[s]===`
`){let w=c.substring(0,s);r.dispatchEvent(new MessageEvent("message",{data:w})),c=c.substring(s+1),s=0}else++s;else{let w=new Uint8Array(u.length+x.length);for(w.set(u),w.set(x,u.length),u=w;;){let D=o.options.decoder.decodeReply(u);if(D.ok){let C=u.slice(0,D.pos);r.dispatchEvent(new MessageEvent("message",{data:C})),u=u.slice(D.pos);continue}break}}}catch(w){r.dispatchEvent(new Event("error",{detail:w})),r.dispatchEvent(new Event("close")),g.close();return}k()}).catch(function(P){r.dispatchEvent(new Event("error",{detail:P})),r.dispatchEvent(new Event("close")),g.close()})}return k()}})}).catch(e=>{r.dispatchEvent(new Event("error",{detail:e})),r.dispatchEvent(new Event("close"))}),r}supported(){return this.options.fetch!==null&&this.options.readableStream!==null&&typeof TextDecoder<"u"&&typeof AbortController<"u"&&typeof EventTarget<"u"&&typeof Event<"u"&&typeof MessageEvent<"u"&&typeof Error<"u"}initialize(o,i,n){this._protocol=o,this._abortController=new AbortController;let r,t;o==="json"?(r={Accept:"application/json","Content-Type":"application/json"},t=n):(r={Accept:"application/octet-stream","Content-Type":"application/octet-stream"},t=n);let e={method:"POST",headers:r,body:t,mode:"cors",credentials:"same-origin",signal:this._abortController.signal},c=this._fetchEventTarget(this,this.endpoint,e);c.addEventListener("open",()=>{i.onOpen()}),c.addEventListener("error",s=>{this._abortController.abort(),i.onError(s)}),c.addEventListener("close",()=>{this._abortController.abort(),i.onClose({code:4,reason:"connection closed"})}),c.addEventListener("message",s=>{i.onMessage(s.data)})}close(){this._abortController.abort()}send(o,i,n){let r,t,e={session:i,node:n,data:o};this._protocol==="json"?(r={"Content-Type":"application/json"},t=JSON.stringify(e)):(r={"Content-Type":"application/octet-stream"},t=this.options.encoder.encodeEmulationRequest(e));let c=this.options.fetch,s={method:"POST",headers:r,body:t,mode:"cors",credentials:"same-origin"};c(this.options.emulationEndpoint,s)}};var Ct=class{constructor(o,i){this.endpoint=o,this.options=i,this._protocol="json",this._transport=null,this._onClose=null}name(){return"sse"}subName(){return"sse"}emulation(){return!0}supported(){return this.options.eventsource!==null&&this.options.fetch!==null}initialize(o,i,n){let r;globalThis&&globalThis.document&&globalThis.document.baseURI?r=new URL(this.endpoint,globalThis.document.baseURI):r=new URL(this.endpoint),r.searchParams.append("cf_connect",n);let t={},e=new this.options.eventsource(r.toString(),t);this._transport=e;let c=this;e.onopen=function(){i.onOpen()},e.onerror=function(s){e.close(),i.onError(s),i.onClose({code:4,reason:"connection closed"})},e.onmessage=function(s){i.onMessage(s.data)},c._onClose=function(){i.onClose({code:4,reason:"connection closed"})}}close(){this._transport.close(),this._onClose!==null&&this._onClose()}send(o,i,n){let r={session:i,node:n,data:o},t={"Content-Type":"application/json"},e=JSON.stringify(r),c=this.options.fetch,s={method:"POST",headers:t,body:e,mode:"cors",credentials:"same-origin"};c(this.options.emulationEndpoint,s)}};var It=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null,this._stream=null,this._writer=null,this._utf8decoder=new TextDecoder,this._protocol="json"}name(){return"webtransport"}subName(){return"webtransport"}emulation(){return!1}supported(){return this.options.webtransport!==void 0&&this.options.webtransport!==null}async initialize(o,i){let n;globalThis&&globalThis.document&&globalThis.document.baseURI?n=new URL(this.endpoint,globalThis.document.baseURI):n=new URL(this.endpoint),o==="protobuf"&&n.searchParams.append("cf_protocol","protobuf"),this._protocol=o;let r=new EventTarget;this._transport=new this.options.webtransport(n.toString()),this._transport.closed.then(()=>{i.onClose({code:4,reason:"connection closed"})}).catch(()=>{i.onClose({code:4,reason:"connection closed"})});try{await this._transport.ready}catch{this.close();return}let t;try{t=await this._transport.createBidirectionalStream()}catch{this.close();return}this._stream=t,this._writer=this._stream.writable.getWriter(),r.addEventListener("close",()=>{i.onClose({code:4,reason:"connection closed"})}),r.addEventListener("message",e=>{i.onMessage(e.data)}),this._startReading(r),i.onOpen()}async _startReading(o){let i=this._stream.readable.getReader(),n="",r=0,t=new Uint8Array;try{for(;;){let{done:e,value:c}=await i.read();if(c.length>0)if(this._protocol==="json")for(n+=this._utf8decoder.decode(c);r<n.length;)if(n[r]===`
`){let s=n.substring(0,r);o.dispatchEvent(new MessageEvent("message",{data:s})),n=n.substring(r+1),r=0}else++r;else{let s=new Uint8Array(t.length+c.length);for(s.set(t),s.set(c,t.length),t=s;;){let u=this.options.decoder.decodeReply(t);if(u.ok){let d=t.slice(0,u.pos);o.dispatchEvent(new MessageEvent("message",{data:d})),t=t.slice(u.pos);continue}break}}if(e)break}}catch{o.dispatchEvent(new Event("close"))}}async close(){try{this._writer&&await this._writer.close(),this._transport.close()}catch{}}async send(o){let i;this._protocol==="json"?i=new TextEncoder().encode(o+`
`):i=o;try{await this._writer.write(i)}catch{this.close()}}};var Gn=[-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],Vt=class{constructor(o){this.a=o,this.pos=0}haveBytes(){return this.pos<this.a.length}getByte(){let o=this.a[this.pos];if(this.pos++,this.pos>this.a.length)throw new RangeError("out of bounds");return o}getChar(){return String.fromCharCode(this.getByte())}getInt(){let o=0,i;for(;this.haveBytes()&&(i=Gn[127&this.getByte()])>=0;)o=(o<<6)+i;return this.pos--,o>>>0}},Gt=class{constructor(){this.a=[]}toByteArray(o){return Array.isArray(o)?this.a:new Uint8Array(this.a)}putArray(o,i,n){for(let r=i;r<n;r++)this.a.push(o[r])}};function Jn(l){let o=0,i=0,n=0,r=0,t=0,e=l.length;for(;e>=16;)o=o+l[t+0]|0,i=i+l[t+1]|0,n=n+l[t+2]|0,r=r+l[t+3]|0,o=o+l[t+4]|0,i=i+l[t+5]|0,n=n+l[t+6]|0,r=r+l[t+7]|0,o=o+l[t+8]|0,i=i+l[t+9]|0,n=n+l[t+10]|0,r=r+l[t+11]|0,o=o+l[t+12]|0,i=i+l[t+13]|0,n=n+l[t+14]|0,r=r+l[t+15]|0,t+=16,e-=16;for(;e>=4;)o=o+l[t+0]|0,i=i+l[t+1]|0,n=n+l[t+2]|0,r=r+l[t+3]|0,t+=4,e-=4;switch(r=((r+(n<<8)|0)+(i<<16)|0)+(o<<24)|0,e){case 3:r=r+(l[t+2]<<8)|0;case 2:r=r+(l[t+1]<<16)|0;case 1:r=r+(l[t+0]<<24)|0}return r>>>0}function Lt(l,o){let i=0,n=new Vt(o),r=l.length,t=o.length,e=n.getInt();if(n.getChar()!==`
`)throw new Error("size integer not terminated by '\\n'");let c=new Gt;for(;n.haveBytes();){let s=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+=s,i>e)throw new Error("copy exceeds output file size");if(u+s>r)throw new Error("copy extends past end of input");c.putArray(l,u,u+s);break;case":":if(i+=s,i>e)throw new Error("insert command gives an output larger than predicted");if(s>t)throw new Error("insert count exceeds size of delta");c.putArray(n.a,n.pos,n.pos+s),n.pos+=s;break;case";":{let d=c.toByteArray(l);if(s!==Jn(d))throw new Error("bad checksum");if(i!==e)throw new Error("generated size does not match predicted size");return d}default:throw new Error("unknown delta operator")}}throw new Error("unterminated delta")}var yt=class{name(){return"json"}encodeCommands(o){return o.map(i=>JSON.stringify(i)).join(`
`)}decodeReplies(o){return o.trim().split(`
`).map(i=>JSON.parse(i))}applyDeltaIfNeeded(o,i){let n,r,t;if(o.delta){t=!0;let e=new TextEncoder().encode(o.data),c=Lt(i,e);n=JSON.parse(new TextDecoder().decode(c)),r=c}else t=!1,n=JSON.parse(o.data),r=new TextEncoder().encode(o.data);return{newData:n,newPrevValue:r,isDelta:t,wireBytes:o.data.length,fullBytes:r.length}}};var je=Pt(Ht()),Zn={headers:{},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},V=class extends Error{constructor(o){super(o),this.name=this.constructor.name}},st=class extends je.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 yt,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={...Zn,...n},this._configure(),this._debugEnabled?(this.on("state",r=>{this._debug("client state",r.oldState,"->",r.newState)}),this.on("error",r=>{this._debug("client error",r)})):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 r=new Rt(this,i,n);return this._subs[i]=r,r}newMapSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new ht(this,i,{token:n?.token,getToken:n?.getToken,data:n?.data,minResubscribeDelay:n?.minResubscribeDelay,maxResubscribeDelay:n?.maxResubscribeDelay,delta:n?.delta,tagsFilter:n?.tagsFilter,map:!0,mapPageSize:n?.pageSize,mapUnrecoverableStrategy:n?.unrecoverableStrategy});return this._subs[i]=r,r}newMapClientsSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new ht(this,i,{token:n?.token,getToken:n?.getToken,data:n?.data,minResubscribeDelay:n?.minResubscribeDelay,maxResubscribeDelay:n?.maxResubscribeDelay,delta:n?.delta,tagsFilter:n?.tagsFilter,map:!0,mapPresenceType:2,mapPageSize:n?.pageSize,mapUnrecoverableStrategy:n?.unrecoverableStrategy});return this._subs[i]=r,r}newMapUsersSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new ht(this,i,{token:n?.token,getToken:n?.getToken,data:n?.data,minResubscribeDelay:n?.minResubscribeDelay,maxResubscribeDelay:n?.maxResubscribeDelay,delta:n?.delta,tagsFilter:n?.tagsFilter,map:!0,mapPresenceType:3,mapPageSize:n?.pageSize,mapUnrecoverableStrategy:n?.unrecoverableStrategy});return this._subs[i]=r,r}newSharedPollSubscription(i,n){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new jt(this,i,{token:n?.token,getToken:n?.getToken,data:n?.data,minResubscribeDelay:n?.minResubscribeDelay,maxResubscribeDelay:n?.maxResubscribeDelay,delta:n?.delta,sharedPoll:!0,sharedPollGetSignature:n?.getSignature});return this._subs[i]=r,r}getSubscription(i){return this._getSub(i)}getMapSubscription(i){return this._getSub(i)}getSharedPollSubscription(i){return this._getSub(i)}removeSubscription(i){i&&(i.state!=="unsubscribed"&&i.unsubscribe(),this._removeSubscription(i))}removeMapSubscription(i){this.removeSubscription(i)}removeSharedPollSubscription(i){this.removeSubscription(i)}subscriptions(){return this._subs}mapSubscriptions(){let i={};for(let[n,r]of Object.entries(this._subs))r.type==="map"&&(i[n]=r);return i}sharedPollSubscriptions(){let i={};for(let[n,r]of Object.entries(this._subs))r.type==="shared_poll"&&(i[n]=r);return i}async ready(i){switch(this.state){case"disconnected":throw{code:3,message:"client disconnected"};case"connected":return;default:return new Promise((n,r)=>{let t={resolve:n,reject:r};i&&(t.timeout=setTimeout(()=>{r({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}setData(i){this._data=i}setHeaders(i){this._config.headers=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 r={rpc:{method:i,data:n}};return await this._methodCall(),{data:(await this._callPromise(r,e=>e.rpc)).data}}async publish(i,n){let r={publish:{channel:i,data:n}};return await this._methodCall(),await this._callPromise(r,()=>({})),{}}async mapPublish(i,n,r){let t={publish:{channel:i,type:1,key:n,data:r}};return await this._methodCall(),await this._callPromise(t,()=>({})),{}}async mapRemove(i,n){let r={publish:{channel:i,type:1,key:n,removed:!0}};return await this._methodCall(),await this._callPromise(r,()=>({})),{}}async history(i,n){let r={history:this._getHistoryRequest(i,n)};await this._methodCall();let t=await this._callPromise(r,c=>c.history),e=[];if(t.publications)for(let c=0;c<t.publications.length;c++)e.push(this._getPublicationContext(i,t.publications[c]));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 c=t[e],s=c.conn_info,u=c.chan_info;s&&(c.connInfo=s),u&&(c.chanInfo=u)}return{clients:t}}async presenceStats(i){let n={presence_stats:{channel:i}};await this._methodCall();let r=await this._callPromise(n,t=>t.presence_stats);return{numUsers:r.num_users,numClients:r.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&&me("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 yt,this._formatOverride(),(this._config.debug===!0||Te("centrifuge.debug"))&&(this._debugEnabled=!0),this._debug("config",this._config),typeof this._endpoint!="string")if(Array.isArray(this._endpoint)){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 r=n.transport;if(["websocket","http_stream","sse","sockjs","webtransport"].indexOf(r)<0)throw new Error("unsupported transport name: "+r)}}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=Y(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 r=n.errback;if(!r)continue;r({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 r=n.id;if(!(r in this._callbacks))continue;let t=this._callbacks[r];clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r];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 r=null;this._config.eventsource!==null?r=this._config.eventsource:typeof globalThis.EventSource<"u"&&(r=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 x=0;for(;;){if(x>=this._transports.length)throw new Error("no supported transport found");let w=this._transports[this._currentTransportIndex],D=w.transport,C=w.endpoint;if(D==="websocket"){if(this._debug("trying websocket transport"),this._transport=new bt(C,{websocket:i}),!this._transport.supported()){this._debug("websocket transport not available"),this._currentTransportIndex++,x++;continue}}else if(D==="webtransport"){if(this._debug("trying webtransport transport"),this._transport=new It(C,{webtransport:globalThis.WebTransport,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("webtransport transport not available"),this._currentTransportIndex++,x++;continue}}else if(D==="http_stream"){if(this._debug("trying http_stream transport"),this._transport=new Dt(C,{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++,x++;continue}}else if(D==="sse"){if(this._debug("trying sse transport"),this._transport=new Ct(C,{eventsource:r,fetch:t,emulationEndpoint:this._config.emulationEndpoint}),!this._transport.supported()){this._debug("sse transport not available"),this._currentTransportIndex++,x++;continue}}else if(D==="sockjs"){if(this._debug("trying sockjs"),this._transport=new Et(C,{sockjs:n,sockjsOptions:this._config.sockjsOptions}),!this._transport.supported()){this._debug("sockjs transport not available"),this._currentTransportIndex++,x++;continue}}else throw new Error("unknown transport "+D);break}}else{if(Oe(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 bt(this._endpoint,{websocket:i}),!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 c=this,s=this._transport,u=this._nextTransportId();c._debug("id of transport",u);let d=!1,g=[];if(this._transport.emulation()){let x=c._sendConnect(!0);g.push(x)}this._setNetworkEvents();let k=this._codec.encodeCommands(g);this._transportClosed=!1;let P;P=setTimeout(function(){s.close()},this._config.timeout),this._transport.initialize(this._codecName(),{onOpen:function(){if(P&&(clearTimeout(P),P=null),c._transportId!=u){c._debug("open callback from non-actual transport"),s.close();return}d=!0,c._debug(s.subName(),"transport open"),!s.emulation()&&(c._transportIsOpen=!0,c._transportWasOpen=!0,c.startBatching(),c._sendConnect(!1),c._sendSubscribeCommands(),c.stopBatching(),c.emit("__centrifuge_debug:connect_frame_sent",{}))},onError:function(x){if(c._transportId!=u){c._debug("error callback from non-actual transport");return}c._debug("transport level error",x)},onClose:function(x){if(P&&(clearTimeout(P),P=null),c._transportId!=u){c._debug("close callback from non-actual transport");return}c._debug(s.subName(),"transport closed"),c._transportClosed=!0,c._transportIsOpen=!1;let w="connection closed",D=!0,C=0;if(x&&"code"in x&&x.code&&(C=x.code),x&&x.reason)try{let ut=JSON.parse(x.reason);w=ut.reason,D=ut.reconnect}catch{w=x.reason,(C>=3500&&C<4e3||C>=4500&&C<5e3)&&(D=!1)}C<3e3?(C===1009?(C=3,w="message size limit exceeded",D=!1):(C=1,w="transport closed"),c._emulation&&!c._transportWasOpen&&(c._currentTransportIndex++,c._currentTransportIndex>=c._transports.length&&(c._triedAllTransports=!0,c._currentTransportIndex=0))):c._transportWasOpen=!0,c._isConnecting()&&!d&&c.emit("error",{type:"transport",error:{code:2,message:"transport closed"},transport:s.name()}),c._reconnecting=!1,c._disconnect(C,w,D)},onMessage:function(x){c._dataReceived(x)}},k),c.emit("__centrifuge_debug:transport_initialized",{})}_sendConnect(i){let n=this._constructConnectCommand(),r=this;return this._call(n,i).then(t=>{let e=t.reply.connect;r._connectResponse(e),t.next&&t.next()},t=>{r._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 r=this;this._getToken().then(function(t){if(r._isConnecting()){if(t==null||t==null){r._failUnauthorized();return}r._token=t,r._debug("connection token refreshed"),r._config.getData?r._config.getData().then(function(e){r._isConnecting()&&(r._data=e,r._initializeTransport())}).catch(e=>r._handleGetDataError(e)):r._initializeTransport()}}).catch(function(t){if(!r._isConnecting())return;if(t instanceof V){r._failUnauthorized();return}r.emit("error",{type:"connectToken",error:{code:5,message:t!==void 0?t.toString():""}});let e=r._getReconnectDelay();r._debug("error on getting connection token, reconnect after "+e+" milliseconds",t),r._reconnecting=!1,r._reconnectTimeout=setTimeout(()=>{r._startReconnecting()},e)})}_handleGetDataError(i){if(i instanceof V){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={},r=!1;for(let t in this._serverSubs)if(this._serverSubs.hasOwnProperty(t)&&this._serverSubs[t].recoverable){r=!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 r&&(i.subs=n),{connect:i}}_getHistoryRequest(i,n){let r={channel:i};return n!==void 0&&(n.since&&(r.since={offset:n.since.offset},n.since.epoch&&(r.since.epoch=n.since.epoch)),n.limit!==void 0&&(r.limit=n.limit),n.reverse===!0&&(r.reverse=!0)),r}_methodCall(){return this._isConnected()?Promise.resolve():new Promise((i,n)=>{let r=setTimeout(function(){n({code:1,message:"timeout"})},this._config.timeout);this._promises[this._nextPromiseId()]={timeout:r,resolve:i,reject:n}})}_callPromise(i,n){return new Promise((r,t)=>{this._call(i,!1).then(e=>{let c=n(e.reply);r(c),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 r;this._dispatchPromise=new Promise(t=>{r=t}),this._dispatchSynchronized(n,r)})}_dispatchSynchronized(i,n){let r=Promise.resolve();for(let t in i)i.hasOwnProperty(t)&&(r=r.then(()=>this._dispatchReply(i[t])));r=r.then(()=>{n()})}_dispatchReply(i){let n,r=new Promise(e=>{n=e});if(i==null)return this._debug("dispatch: got undefined or null reply"),n(),r;let t=i.id;return t&&t>0?this._handleReply(i,n):i.push?this._handlePush(i.push,n):this._handleServerPing(n),r}_call(i,n){return new Promise((r,t)=>{i.id=this._nextCommandId(),this._registerCall(i.id,r,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,r){if(i===3014){this._token="",this._refreshRequired=!0;for(let s in this._subs)this._subs.hasOwnProperty(s)&&this._subs[s]._invalidateState()}if(this._isDisconnected())return;this._transportIsOpen=!1;let t=this.state;this._reconnecting=!1;let e={code:i,reason:n},c=!1;if(r?c=this._setState("connecting"):(c=this._setState("disconnected"),this._rejectPromises({code:3,message:"disconnected"})),this._clearOutgoingRequests(),t==="connecting"&&this._clearReconnectTimeout(),t==="connected"&&this._clearConnectedState(),c&&(this._isConnecting()?this.emit("connecting",e):this.emit("disconnected",e)),this._transport){this._debug("closing existing transport");let s=this._transport;this._transport=null,s.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 V("")))}_refresh(){let i=this._client,n=this;this._getToken().then(function(r){if(i!==n._client)return;if(!r){n._failUnauthorized();return}if(n._token=r,n._debug("connection token refreshed"),!n._isConnected())return;let t={refresh:{token:n._token}};n._call(t,!1).then(e=>{let c=e.reply.refresh;n._refreshResponse(c),e.next&&e.next()},e=>{n._refreshError(e.error),e.next&&e.next()})}).catch(function(r){if(n._isConnected()){if(r instanceof V){n._failUnauthorized();return}n.emit("error",{type:"refreshToken",error:{code:6,message:r!==void 0?r.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 Y(0,5e3,1e4)}_refreshResponse(i){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),i.expires&&(this._client=i.client,this._refreshTimeout=setTimeout(()=>this._refresh(),ot(i.ttl)))}_removeSubscription(i){i!==null&&delete this._subs[i.channel]}_unsubscribe(i){if(!this._transportIsOpen)return Promise.resolve();let r={unsubscribe:{channel:i.channel}},t=this;return new Promise((c,s)=>{this._call(r,!1).then(u=>{c(),u.next&&u.next()},u=>{c(),u.next&&u.next(),t._disconnect(4,"unsubscribe error",!0)})})}_getSub(i,n){if(n&&n>0){for(let t in this._subs)if(this._subs.hasOwnProperty(t)){let e=this._subs[t];if(e._id===n)return e}return null}let r=this._subs[i];return r||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 r=this._subs[n];if(r._inflight!==!0&&r.state==="subscribing"){let t=r._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(),ot(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 r=i[n];this._serverSubs[n]={offset:r.offset,epoch:r.epoch,recoverable:r.recoverable||!1};let t=this._getSubscribeContext(n,r);this.emit("subscribed",t)}for(let n in i){if(!i.hasOwnProperty(n))continue;let r=i[n];if(r.recovered){let t=r.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 r={channel:i,positioned:!1,recoverable:!1,wasRecovering:!1,recovered:!1,hasRecoveredPublications:!1};n.recovered&&(r.recovered=!0),n.positioned&&(r.positioned=!0),n.recoverable&&(r.recoverable=!0),n.was_recovering&&(r.wasRecovering=!0);let t="";"epoch"in n&&(t=n.epoch);let e=0;return"offset"in n&&(e=n.offset),(r.positioned||r.recoverable)&&(r.streamPosition={offset:e,epoch:t}),Array.isArray(n.publications)&&n.publications.length>0&&(r.hasRecoveredPublications=!0),n.data&&(r.data=n.data),r}_handleReply(i,n){let r=i.id;if(!(r in this._callbacks)){n();return}let t=this._callbacks[r];if(clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r],xe(i)){let e=t.errback;if(!e){n();return}let c={code:i.error.code,message:i.error.message||"",temporary:i.error.temporary||!1};e({error:c,next:n})}else{let e=t.callback;if(!e)return;e({reply:i,next:n})}}_handleJoin(i,n,r){let t=this._getSub(i,r);if(!t){if(i&&this._isServerSub(i)){let e={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("join",e)}return}t._handleJoin(n)}_handleLeave(i,n,r){let t=this._getSub(i,r);if(!t){if(i&&this._isServerSub(i)){let e={channel:i,info:this._getJoinLeaveContext(n.info)};this.emit("leave",e)}return}t._handleLeave(n)}_handleUnsubscribe(i,n){let r=this._getSub(i,0);if(!r&&i){this._isServerSub(i)&&(delete this._serverSubs[i],this.emit("unsubscribed",{channel:i}));return}n.code<2500?r._setUnsubscribed(n.code,n.reason,!1):(n.code===2502&&r._invalidateState(),r._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,r=!0;(n>=3500&&n<4e3||n>=4500&&n<5e3)&&(r=!1),this._disconnect(n,i.reason,r)}_getPublicationContext(i,n){let r={channel:i,data:n.data};return n.offset&&(r.offset=n.offset),n.info&&(r.info=this._getJoinLeaveContext(n.info)),n.tags&&(r.tags=n.tags),r}_getJoinLeaveContext(i){let n={client:i.client,user:i.user},r=i.conn_info;r&&(n.connInfo=r);let t=i.chan_info;return t&&(n.chanInfo=t),n}_handlePublication(i,n,r){let t=this._getSub(i,r);if(!t){if(i&&this._isServerSub(i)){let e=this._getPublicationContext(i,n);this.emit("publication",e),n.offset!==void 0&&(this._serverSubs[i].offset=n.offset)}return}t._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 r=i.channel,t=i.id;i.pub?this._handlePublication(r,i.pub,t):i.message?this._handleMessage(i.message):i.join?this._handleJoin(r,i.join,t):i.leave?this._handleLeave(r,i.leave,t):i.unsubscribe?this._handleUnsubscribe(r,i.unsubscribe):i.subscribe?this._handleSubscribe(r,i.subscribe):i.disconnect&&this._handleDisconnect(i.disconnect),n()}_flush(){let i=this._commands.slice(0);this._commands=[],this._transportSendCommands(i)}_createErrorObject(i,n,r){let t={code:i,message:n};return r&&(t.temporary=!0),t}_registerCall(i,n,r){this._callbacks[i]={callback:n,errback:r,timeout:null},this._callbacks[i].timeout=setTimeout(()=>{delete this._callbacks[i],Tt(r)&&r({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])}};st.SubscriptionState=xt;st.State=mt;st.UnauthorizedError=V;var rt=Pt(le());var tt=Pt(le()),p=tt.Reader,S=tt.Writer,a=tt.util,h=tt.roots.default||(tt.roots.default={}),Ut=h.centrifugal=(()=>{let l={};return l.centrifuge=(function(){let o={};return o.protocol=(function(){let i={};return i.Error=(function(){function n(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.code=0,n.prototype.message="",n.prototype.temporary=!1,n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Error;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.code=t.uint32();break}case 2:{s.message=t.string();break}case 3:{s.temporary=t.bool();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!a.isInteger(t.code)?"code: integer expected":t.message!=null&&t.hasOwnProperty("message")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.node="",n.prototype.session="",n.prototype.data=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.EmulationRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.node=t.string();break}case 2:{s.session=t.string();break}case 3:{s.data=t.bytes();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.node!=null&&t.hasOwnProperty("node")&&!a.isString(t.node)?"node: string expected":t.session!=null&&t.hasOwnProperty("session")&&!a.isString(t.session)?"session: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[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=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.ConnectRequest.encode(t.connect,e.uint32(34).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subscribe,e.uint32(42).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.UnsubscribeRequest.encode(t.unsubscribe,e.uint32(50).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&h.centrifugal.centrifuge.protocol.PublishRequest.encode(t.publish,e.uint32(58).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&h.centrifugal.centrifuge.protocol.PresenceRequest.encode(t.presence,e.uint32(66).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&h.centrifugal.centrifuge.protocol.PresenceStatsRequest.encode(t.presence_stats,e.uint32(74).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&h.centrifugal.centrifuge.protocol.HistoryRequest.encode(t.history,e.uint32(82).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&h.centrifugal.centrifuge.protocol.PingRequest.encode(t.ping,e.uint32(90).fork()).ldelim(),t.send!=null&&Object.hasOwnProperty.call(t,"send")&&h.centrifugal.centrifuge.protocol.SendRequest.encode(t.send,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&h.centrifugal.centrifuge.protocol.RPCRequest.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.centrifugal.centrifuge.protocol.RefreshRequest.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Command;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.uint32();break}case 4:{s.connect=h.centrifugal.centrifuge.protocol.ConnectRequest.decode(t,t.uint32());break}case 5:{s.subscribe=h.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break}case 6:{s.unsubscribe=h.centrifugal.centrifuge.protocol.UnsubscribeRequest.decode(t,t.uint32());break}case 7:{s.publish=h.centrifugal.centrifuge.protocol.PublishRequest.decode(t,t.uint32());break}case 8:{s.presence=h.centrifugal.centrifuge.protocol.PresenceRequest.decode(t,t.uint32());break}case 9:{s.presence_stats=h.centrifugal.centrifuge.protocol.PresenceStatsRequest.decode(t,t.uint32());break}case 10:{s.history=h.centrifugal.centrifuge.protocol.HistoryRequest.decode(t,t.uint32());break}case 11:{s.ping=h.centrifugal.centrifuge.protocol.PingRequest.decode(t,t.uint32());break}case 12:{s.send=h.centrifugal.centrifuge.protocol.SendRequest.decode(t,t.uint32());break}case 13:{s.rpc=h.centrifugal.centrifuge.protocol.RPCRequest.decode(t,t.uint32());break}case 14:{s.refresh=h.centrifugal.centrifuge.protocol.RefreshRequest.decode(t,t.uint32());break}case 15:{s.sub_refresh=h.centrifugal.centrifuge.protocol.SubRefreshRequest.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isInteger(t.id))return"id: integer expected";if(t.connect!=null&&t.hasOwnProperty("connect")){let e=h.centrifugal.centrifuge.protocol.ConnectRequest.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=h.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=h.centrifugal.centrifuge.protocol.UnsubscribeRequest.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=h.centrifugal.centrifuge.protocol.PublishRequest.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=h.centrifugal.centrifuge.protocol.PresenceRequest.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=h.centrifugal.centrifuge.protocol.PresenceStatsRequest.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=h.centrifugal.centrifuge.protocol.HistoryRequest.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=h.centrifugal.centrifuge.protocol.PingRequest.verify(t.ping);if(e)return"ping."+e}if(t.send!=null&&t.hasOwnProperty("send")){let e=h.centrifugal.centrifuge.protocol.SendRequest.verify(t.send);if(e)return"send."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=h.centrifugal.centrifuge.protocol.RPCRequest.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=h.centrifugal.centrifuge.protocol.RefreshRequest.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=h.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[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=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).uint32(t.id),t.error!=null&&Object.hasOwnProperty.call(t,"error")&&h.centrifugal.centrifuge.protocol.Error.encode(t.error,e.uint32(18).fork()).ldelim(),t.push!=null&&Object.hasOwnProperty.call(t,"push")&&h.centrifugal.centrifuge.protocol.Push.encode(t.push,e.uint32(34).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.ConnectResult.encode(t.connect,e.uint32(42).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subscribe,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.UnsubscribeResult.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&h.centrifugal.centrifuge.protocol.PublishResult.encode(t.publish,e.uint32(66).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&h.centrifugal.centrifuge.protocol.PresenceResult.encode(t.presence,e.uint32(74).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&h.centrifugal.centrifuge.protocol.PresenceStatsResult.encode(t.presence_stats,e.uint32(82).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&h.centrifugal.centrifuge.protocol.HistoryResult.encode(t.history,e.uint32(90).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&h.centrifugal.centrifuge.protocol.PingResult.encode(t.ping,e.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&h.centrifugal.centrifuge.protocol.RPCResult.encode(t.rpc,e.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.centrifugal.centrifuge.protocol.RefreshResult.encode(t.refresh,e.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Reply;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.uint32();break}case 2:{s.error=h.centrifugal.centrifuge.protocol.Error.decode(t,t.uint32());break}case 4:{s.push=h.centrifugal.centrifuge.protocol.Push.decode(t,t.uint32());break}case 5:{s.connect=h.centrifugal.centrifuge.protocol.ConnectResult.decode(t,t.uint32());break}case 6:{s.subscribe=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break}case 7:{s.unsubscribe=h.centrifugal.centrifuge.protocol.UnsubscribeResult.decode(t,t.uint32());break}case 8:{s.publish=h.centrifugal.centrifuge.protocol.PublishResult.decode(t,t.uint32());break}case 9:{s.presence=h.centrifugal.centrifuge.protocol.PresenceResult.decode(t,t.uint32());break}case 10:{s.presence_stats=h.centrifugal.centrifuge.protocol.PresenceStatsResult.decode(t,t.uint32());break}case 11:{s.history=h.centrifugal.centrifuge.protocol.HistoryResult.decode(t,t.uint32());break}case 12:{s.ping=h.centrifugal.centrifuge.protocol.PingResult.decode(t,t.uint32());break}case 13:{s.rpc=h.centrifugal.centrifuge.protocol.RPCResult.decode(t,t.uint32());break}case 14:{s.refresh=h.centrifugal.centrifuge.protocol.RefreshResult.decode(t,t.uint32());break}case 15:{s.sub_refresh=h.centrifugal.centrifuge.protocol.SubRefreshResult.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isInteger(t.id))return"id: integer expected";if(t.error!=null&&t.hasOwnProperty("error")){let e=h.centrifugal.centrifuge.protocol.Error.verify(t.error);if(e)return"error."+e}if(t.push!=null&&t.hasOwnProperty("push")){let e=h.centrifugal.centrifuge.protocol.Push.verify(t.push);if(e)return"push."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=h.centrifugal.centrifuge.protocol.ConnectResult.verify(t.connect);if(e)return"connect."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subscribe);if(e)return"subscribe."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=h.centrifugal.centrifuge.protocol.UnsubscribeResult.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.publish!=null&&t.hasOwnProperty("publish")){let e=h.centrifugal.centrifuge.protocol.PublishResult.verify(t.publish);if(e)return"publish."+e}if(t.presence!=null&&t.hasOwnProperty("presence")){let e=h.centrifugal.centrifuge.protocol.PresenceResult.verify(t.presence);if(e)return"presence."+e}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let e=h.centrifugal.centrifuge.protocol.PresenceStatsResult.verify(t.presence_stats);if(e)return"presence_stats."+e}if(t.history!=null&&t.hasOwnProperty("history")){let e=h.centrifugal.centrifuge.protocol.HistoryResult.verify(t.history);if(e)return"history."+e}if(t.ping!=null&&t.hasOwnProperty("ping")){let e=h.centrifugal.centrifuge.protocol.PingResult.verify(t.ping);if(e)return"ping."+e}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let e=h.centrifugal.centrifuge.protocol.RPCResult.verify(t.rpc);if(e)return"rpc."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=h.centrifugal.centrifuge.protocol.RefreshResult.verify(t.refresh);if(e)return"refresh."+e}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let e=h.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.id=a.Long?a.Long.fromBits(0,0,!1):0,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=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(8).int64(t.id),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(18).string(t.channel),t.pub!=null&&Object.hasOwnProperty.call(t,"pub")&&h.centrifugal.centrifuge.protocol.Publication.encode(t.pub,e.uint32(34).fork()).ldelim(),t.join!=null&&Object.hasOwnProperty.call(t,"join")&&h.centrifugal.centrifuge.protocol.Join.encode(t.join,e.uint32(42).fork()).ldelim(),t.leave!=null&&Object.hasOwnProperty.call(t,"leave")&&h.centrifugal.centrifuge.protocol.Leave.encode(t.leave,e.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.Unsubscribe.encode(t.unsubscribe,e.uint32(58).fork()).ldelim(),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&h.centrifugal.centrifuge.protocol.Message.encode(t.message,e.uint32(66).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.Subscribe.encode(t.subscribe,e.uint32(74).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.Connect.encode(t.connect,e.uint32(82).fork()).ldelim(),t.disconnect!=null&&Object.hasOwnProperty.call(t,"disconnect")&&h.centrifugal.centrifuge.protocol.Disconnect.encode(t.disconnect,e.uint32(90).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Push;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.int64();break}case 2:{s.channel=t.string();break}case 4:{s.pub=h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32());break}case 5:{s.join=h.centrifugal.centrifuge.protocol.Join.decode(t,t.uint32());break}case 6:{s.leave=h.centrifugal.centrifuge.protocol.Leave.decode(t,t.uint32());break}case 7:{s.unsubscribe=h.centrifugal.centrifuge.protocol.Unsubscribe.decode(t,t.uint32());break}case 8:{s.message=h.centrifugal.centrifuge.protocol.Message.decode(t,t.uint32());break}case 9:{s.subscribe=h.centrifugal.centrifuge.protocol.Subscribe.decode(t,t.uint32());break}case 10:{s.connect=h.centrifugal.centrifuge.protocol.Connect.decode(t,t.uint32());break}case 11:{s.disconnect=h.centrifugal.centrifuge.protocol.Disconnect.decode(t,t.uint32());break}case 12:{s.refresh=h.centrifugal.centrifuge.protocol.Refresh.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isInteger(t.id)&&!(t.id&&a.isInteger(t.id.low)&&a.isInteger(t.id.high)))return"id: integer|Long expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!a.isString(t.channel))return"channel: string expected";if(t.pub!=null&&t.hasOwnProperty("pub")){let e=h.centrifugal.centrifuge.protocol.Publication.verify(t.pub);if(e)return"pub."+e}if(t.join!=null&&t.hasOwnProperty("join")){let e=h.centrifugal.centrifuge.protocol.Join.verify(t.join);if(e)return"join."+e}if(t.leave!=null&&t.hasOwnProperty("leave")){let e=h.centrifugal.centrifuge.protocol.Leave.verify(t.leave);if(e)return"leave."+e}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let e=h.centrifugal.centrifuge.protocol.Unsubscribe.verify(t.unsubscribe);if(e)return"unsubscribe."+e}if(t.message!=null&&t.hasOwnProperty("message")){let e=h.centrifugal.centrifuge.protocol.Message.verify(t.message);if(e)return"message."+e}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let e=h.centrifugal.centrifuge.protocol.Subscribe.verify(t.subscribe);if(e)return"subscribe."+e}if(t.connect!=null&&t.hasOwnProperty("connect")){let e=h.centrifugal.centrifuge.protocol.Connect.verify(t.connect);if(e)return"connect."+e}if(t.disconnect!=null&&t.hasOwnProperty("disconnect")){let e=h.centrifugal.centrifuge.protocol.Disconnect.verify(t.disconnect);if(e)return"disconnect."+e}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let e=h.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.user="",n.prototype.client="",n.prototype.conn_info=a.newBuffer([]),n.prototype.chan_info=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.ClientInfo;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.user=t.string();break}case 2:{s.client=t.string();break}case 3:{s.conn_info=t.bytes();break}case 4:{s.chan_info=t.bytes();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.user!=null&&t.hasOwnProperty("user")&&!a.isString(t.user)?"user: string expected":t.client!=null&&t.hasOwnProperty("client")&&!a.isString(t.client)?"client: string expected":t.conn_info!=null&&t.hasOwnProperty("conn_info")&&!(t.conn_info&&typeof t.conn_info.length=="number"||a.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"||a.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(r){if(this.tags={},r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.data=a.newBuffer([]),n.prototype.info=null,n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.prototype.tags=a.emptyObject,n.prototype.delta=!1,n.prototype.time=a.Long?a.Long.fromBits(0,0,!1):0,n.prototype.channel="",n.prototype.key="",n.prototype.removed=!1,n.prototype.score=a.Long?a.Long.fromBits(0,0,!1):0,n.prototype.epoch="",n.prototype.prev_data=a.newBuffer([]),n.prototype.version=a.Long?a.Long.fromBits(0,0,!0):0,n.encode=function(t,e){if(e||(e=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&e.uint32(34).bytes(t.data),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.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 c=Object.keys(t.tags),s=0;s<c.length;++s)e.uint32(58).fork().uint32(10).string(c[s]).uint32(18).string(t.tags[c[s]]).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),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&e.uint32(90).string(t.key),t.removed!=null&&Object.hasOwnProperty.call(t,"removed")&&e.uint32(96).bool(t.removed),t.score!=null&&Object.hasOwnProperty.call(t,"score")&&e.uint32(104).sint64(t.score),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&e.uint32(114).string(t.epoch),t.prev_data!=null&&Object.hasOwnProperty.call(t,"prev_data")&&e.uint32(122).bytes(t.prev_data),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(128).uint64(t.version),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Publication,u,d;for(;t.pos<c;){let g=t.uint32();switch(g>>>3){case 4:{s.data=t.bytes();break}case 5:{s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}case 6:{s.offset=t.uint64();break}case 7:{s.tags===a.emptyObject&&(s.tags={});let k=t.uint32()+t.pos;for(u="",d="";t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=t.string();break;default:t.skipType(P&7);break}}s.tags[u]=d;break}case 8:{s.delta=t.bool();break}case 9:{s.time=t.int64();break}case 10:{s.channel=t.string();break}case 11:{s.key=t.string();break}case 12:{s.removed=t.bool();break}case 13:{s.score=t.sint64();break}case 14:{s.epoch=t.string();break}case 15:{s.prev_data=t.bytes();break}case 16:{s.version=t.uint64();break}default:t.skipType(g&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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"||a.isString(t.data)))return"data: buffer expected";if(t.info!=null&&t.hasOwnProperty("info")){let e=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(e)return"info."+e}if(t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.tags!=null&&t.hasOwnProperty("tags")){if(!a.isObject(t.tags))return"tags: object expected";let e=Object.keys(t.tags);for(let c=0;c<e.length;++c)if(!a.isString(t.tags[e[c]]))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")&&!a.isInteger(t.time)&&!(t.time&&a.isInteger(t.time.low)&&a.isInteger(t.time.high))?"time: integer|Long expected":t.channel!=null&&t.hasOwnProperty("channel")&&!a.isString(t.channel)?"channel: string expected":t.key!=null&&t.hasOwnProperty("key")&&!a.isString(t.key)?"key: string expected":t.removed!=null&&t.hasOwnProperty("removed")&&typeof t.removed!="boolean"?"removed: boolean expected":t.score!=null&&t.hasOwnProperty("score")&&!a.isInteger(t.score)&&!(t.score&&a.isInteger(t.score.low)&&a.isInteger(t.score.high))?"score: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!a.isString(t.epoch)?"epoch: string expected":t.prev_data!=null&&t.hasOwnProperty("prev_data")&&!(t.prev_data&&typeof t.prev_data.length=="number"||a.isString(t.prev_data))?"prev_data: buffer expected":t.version!=null&&t.hasOwnProperty("version")&&!a.isInteger(t.version)&&!(t.version&&a.isInteger(t.version.low)&&a.isInteger(t.version.high))?"version: integer|Long 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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=S.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Join;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32()):t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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=h.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.info=null,n.encode=function(t,e){return e||(e=S.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Leave;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32()):t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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=h.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Unsubscribe;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 2:{s.code=t.uint32();break}case 3:{s.reason=t.string();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!a.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Subscribe;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.recoverable=t.bool();break}case 4:{s.epoch=t.string();break}case 5:{s.offset=t.uint64();break}case 6:{s.positioned=t.bool();break}case 7:{s.data=t.bytes();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.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"||a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.data=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Message;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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"||a.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(r){if(this.subs={},r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.data=a.newBuffer([]),n.prototype.subs=a.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=a.Long?a.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=S.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 c=Object.keys(t.subs),s=0;s<c.length;++s)e.uint32(34).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[c[s]],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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Connect,u,d;for(;t.pos<c;){let g=t.uint32();switch(g>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.data=t.bytes();break}case 4:{s.subs===a.emptyObject&&(s.subs={});let k=t.uint32()+t.pos;for(u="",d=null;t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(P&7);break}}s.subs[u]=d;break}case 5:{s.expires=t.bool();break}case 6:{s.ttl=t.uint32();break}case 7:{s.ping=t.uint32();break}case 8:{s.pong=t.bool();break}case 9:{s.session=t.string();break}case 10:{s.node=t.string();break}case 11:{s.time=t.int64();break}default:t.skipType(g&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!a.isString(t.version))return"version: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!a.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let c=0;c<e.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[c]]);if(s)return"subs."+s}}return t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!a.isInteger(t.ttl)?"ttl: integer expected":t.ping!=null&&t.hasOwnProperty("ping")&&!a.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")&&!a.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!a.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!a.isInteger(t.time)&&!(t.time&&a.isInteger(t.time.low)&&a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.code=0,n.prototype.reason="",n.prototype.reconnect=!1,n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Disconnect;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.code=t.uint32();break}case 2:{s.reason=t.string();break}case 3:{s.reconnect=t.bool();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!a.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.Refresh;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.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(r){if(this.subs={},this.headers={},r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.token="",n.prototype.data=a.newBuffer([]),n.prototype.subs=a.emptyObject,n.prototype.name="",n.prototype.version="",n.prototype.headers=a.emptyObject,n.prototype.flag=a.Long?a.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=S.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 c=Object.keys(t.subs),s=0;s<c.length;++s)e.uint32(26).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subs[c[s]],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 c=Object.keys(t.headers),s=0;s<c.length;++s)e.uint32(50).fork().uint32(10).string(c[s]).uint32(18).string(t.headers[c[s]]).ldelim();return t.flag!=null&&Object.hasOwnProperty.call(t,"flag")&&e.uint32(56).int64(t.flag),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.ConnectRequest,u,d;for(;t.pos<c;){let g=t.uint32();switch(g>>>3){case 1:{s.token=t.string();break}case 2:{s.data=t.bytes();break}case 3:{s.subs===a.emptyObject&&(s.subs={});let k=t.uint32()+t.pos;for(u="",d=null;t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break;default:t.skipType(P&7);break}}s.subs[u]=d;break}case 4:{s.name=t.string();break}case 5:{s.version=t.string();break}case 6:{s.headers===a.emptyObject&&(s.headers={});let k=t.uint32()+t.pos;for(u="",d="";t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=t.string();break;default:t.skipType(P&7);break}}s.headers[u]=d;break}case 7:{s.flag=t.int64();break}default:t.skipType(g&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.token))return"token: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!a.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let c=0;c<e.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subs[e[c]]);if(s)return"subs."+s}}if(t.name!=null&&t.hasOwnProperty("name")&&!a.isString(t.name))return"name: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!a.isString(t.version))return"version: string expected";if(t.headers!=null&&t.hasOwnProperty("headers")){if(!a.isObject(t.headers))return"headers: object expected";let e=Object.keys(t.headers);for(let c=0;c<e.length;++c)if(!a.isString(t.headers[e[c]]))return"headers: string{k:string} expected"}return t.flag!=null&&t.hasOwnProperty("flag")&&!a.isInteger(t.flag)&&!(t.flag&&a.isInteger(t.flag.low)&&a.isInteger(t.flag.high))?"flag: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectRequest"},n})(),i.ConnectResult=(function(){function n(r){if(this.subs={},r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.client="",n.prototype.version="",n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.data=a.newBuffer([]),n.prototype.subs=a.emptyObject,n.prototype.ping=0,n.prototype.pong=!1,n.prototype.session="",n.prototype.node="",n.prototype.time=a.Long?a.Long.fromBits(0,0,!1):0,n.encode=function(t,e){if(e||(e=S.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 c=Object.keys(t.subs),s=0;s<c.length;++s)e.uint32(50).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[c[s]],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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.ConnectResult,u,d;for(;t.pos<c;){let g=t.uint32();switch(g>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.expires=t.bool();break}case 4:{s.ttl=t.uint32();break}case 5:{s.data=t.bytes();break}case 6:{s.subs===a.emptyObject&&(s.subs={});let k=t.uint32()+t.pos;for(u="",d=null;t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(P&7);break}}s.subs[u]=d;break}case 7:{s.ping=t.uint32();break}case 8:{s.pong=t.bool();break}case 9:{s.session=t.string();break}case 10:{s.node=t.string();break}case 11:{s.time=t.int64();break}default:t.skipType(g&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!a.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")&&!a.isInteger(t.ttl))return"ttl: integer expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!a.isObject(t.subs))return"subs: object expected";let e=Object.keys(t.subs);for(let c=0;c<e.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[e[c]]);if(s)return"subs."+s}}return t.ping!=null&&t.hasOwnProperty("ping")&&!a.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")&&!a.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!a.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!a.isInteger(t.time)&&!(t.time&&a.isInteger(t.time.low)&&a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.token="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.RefreshRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.token=t.string():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.token!=null&&t.hasOwnProperty("token")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[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=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.RefreshResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.expires=t.bool();break}case 4:{s.ttl=t.uint32();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.client!=null&&t.hasOwnProperty("client")&&!a.isString(t.client)?"client: string expected":t.version!=null&&t.hasOwnProperty("version")&&!a.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")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.prototype.token="",n.prototype.recover=!1,n.prototype.epoch="",n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.prototype.data=a.newBuffer([]),n.prototype.positioned=!1,n.prototype.recoverable=!1,n.prototype.join_leave=!1,n.prototype.delta="",n.prototype.tf=null,n.prototype.flag=a.Long?a.Long.fromBits(0,0,!1):0,n.prototype.type=0,n.prototype.phase=0,n.prototype.cursor="",n.prototype.limit=0,n.prototype.asc=!1,n.encode=function(t,e){return e||(e=S.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),t.tf!=null&&Object.hasOwnProperty.call(t,"tf")&&h.centrifugal.centrifuge.protocol.FilterNode.encode(t.tf,e.uint32(106).fork()).ldelim(),t.flag!=null&&Object.hasOwnProperty.call(t,"flag")&&e.uint32(112).int64(t.flag),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(120).int32(t.type),t.phase!=null&&Object.hasOwnProperty.call(t,"phase")&&e.uint32(128).int32(t.phase),t.cursor!=null&&Object.hasOwnProperty.call(t,"cursor")&&e.uint32(138).string(t.cursor),t.limit!=null&&Object.hasOwnProperty.call(t,"limit")&&e.uint32(144).int32(t.limit),t.asc!=null&&Object.hasOwnProperty.call(t,"asc")&&e.uint32(152).bool(t.asc),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.SubscribeRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.token=t.string();break}case 3:{s.recover=t.bool();break}case 6:{s.epoch=t.string();break}case 7:{s.offset=t.uint64();break}case 8:{s.data=t.bytes();break}case 9:{s.positioned=t.bool();break}case 10:{s.recoverable=t.bool();break}case 11:{s.join_leave=t.bool();break}case 12:{s.delta=t.string();break}case 13:{s.tf=h.centrifugal.centrifuge.protocol.FilterNode.decode(t,t.uint32());break}case 14:{s.flag=t.int64();break}case 15:{s.type=t.int32();break}case 16:{s.phase=t.int32();break}case 17:{s.cursor=t.string();break}case 18:{s.limit=t.int32();break}case 19:{s.asc=t.bool();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.channel))return"channel: string expected";if(t.token!=null&&t.hasOwnProperty("token")&&!a.isString(t.token))return"token: string expected";if(t.recover!=null&&t.hasOwnProperty("recover")&&typeof t.recover!="boolean")return"recover: boolean expected";if(t.epoch!=null&&t.hasOwnProperty("epoch")&&!a.isString(t.epoch))return"epoch: string expected";if(t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data)))return"data: buffer expected";if(t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean")return"positioned: boolean expected";if(t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean")return"recoverable: boolean expected";if(t.join_leave!=null&&t.hasOwnProperty("join_leave")&&typeof t.join_leave!="boolean")return"join_leave: boolean expected";if(t.delta!=null&&t.hasOwnProperty("delta")&&!a.isString(t.delta))return"delta: string expected";if(t.tf!=null&&t.hasOwnProperty("tf")){let e=h.centrifugal.centrifuge.protocol.FilterNode.verify(t.tf);if(e)return"tf."+e}return t.flag!=null&&t.hasOwnProperty("flag")&&!a.isInteger(t.flag)&&!(t.flag&&a.isInteger(t.flag.low)&&a.isInteger(t.flag.high))?"flag: integer|Long expected":t.type!=null&&t.hasOwnProperty("type")&&!a.isInteger(t.type)?"type: integer expected":t.phase!=null&&t.hasOwnProperty("phase")&&!a.isInteger(t.phase)?"phase: integer expected":t.cursor!=null&&t.hasOwnProperty("cursor")&&!a.isString(t.cursor)?"cursor: string expected":t.limit!=null&&t.hasOwnProperty("limit")&&!a.isInteger(t.limit)?"limit: integer expected":t.asc!=null&&t.hasOwnProperty("asc")&&typeof t.asc!="boolean"?"asc: boolean 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(r){if(this.publications=[],this.state=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.recoverable=!1,n.prototype.epoch="",n.prototype.publications=a.emptyArray,n.prototype.recovered=!1,n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.prototype.positioned=!1,n.prototype.data=a.newBuffer([]),n.prototype.was_recovering=!1,n.prototype.delta=!1,n.prototype.id=a.Long?a.Long.fromBits(0,0,!1):0,n.prototype.type=0,n.prototype.phase=0,n.prototype.cursor="",n.prototype.state=a.emptyArray,n.prototype.publish_debounce=0,n.encode=function(t,e){if(e||(e=S.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 c=0;c<t.publications.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.publications[c],e.uint32(58).fork()).ldelim();if(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),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(112).int64(t.id),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(120).int32(t.type),t.phase!=null&&Object.hasOwnProperty.call(t,"phase")&&e.uint32(128).int32(t.phase),t.cursor!=null&&Object.hasOwnProperty.call(t,"cursor")&&e.uint32(138).string(t.cursor),t.state!=null&&t.state.length)for(let c=0;c<t.state.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.state[c],e.uint32(146).fork()).ldelim();return t.publish_debounce!=null&&Object.hasOwnProperty.call(t,"publish_debounce")&&e.uint32(152).uint32(t.publish_debounce),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.SubscribeResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}case 3:{s.recoverable=t.bool();break}case 6:{s.epoch=t.string();break}case 7:{s.publications&&s.publications.length||(s.publications=[]),s.publications.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 8:{s.recovered=t.bool();break}case 9:{s.offset=t.uint64();break}case 10:{s.positioned=t.bool();break}case 11:{s.data=t.bytes();break}case 12:{s.was_recovering=t.bool();break}case 13:{s.delta=t.bool();break}case 14:{s.id=t.int64();break}case 15:{s.type=t.int32();break}case 16:{s.phase=t.int32();break}case 17:{s.cursor=t.string();break}case 18:{s.state&&s.state.length||(s.state=[]),s.state.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 19:{s.publish_debounce=t.uint32();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.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")&&!a.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 c=h.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(c)return"publications."+c}}if(t.recovered!=null&&t.hasOwnProperty("recovered")&&typeof t.recovered!="boolean")return"recovered: boolean expected";if(t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean")return"positioned: boolean expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data)))return"data: buffer expected";if(t.was_recovering!=null&&t.hasOwnProperty("was_recovering")&&typeof t.was_recovering!="boolean")return"was_recovering: boolean expected";if(t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean")return"delta: boolean expected";if(t.id!=null&&t.hasOwnProperty("id")&&!a.isInteger(t.id)&&!(t.id&&a.isInteger(t.id.low)&&a.isInteger(t.id.high)))return"id: integer|Long expected";if(t.type!=null&&t.hasOwnProperty("type")&&!a.isInteger(t.type))return"type: integer expected";if(t.phase!=null&&t.hasOwnProperty("phase")&&!a.isInteger(t.phase))return"phase: integer expected";if(t.cursor!=null&&t.hasOwnProperty("cursor")&&!a.isString(t.cursor))return"cursor: string expected";if(t.state!=null&&t.hasOwnProperty("state")){if(!Array.isArray(t.state))return"state: array expected";for(let e=0;e<t.state.length;++e){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.state[e]);if(c)return"state."+c}}return t.publish_debounce!=null&&t.hasOwnProperty("publish_debounce")&&!a.isInteger(t.publish_debounce)?"publish_debounce: integer expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeResult"},n})(),i.KeyedItem=(function(){function n(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.key="",n.prototype.version=a.Long?a.Long.fromBits(0,0,!0):0,n.encode=function(t,e){return e||(e=S.create()),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&e.uint32(10).string(t.key),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&e.uint32(16).uint64(t.version),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.KeyedItem;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.key=t.string();break}case 2:{s.version=t.uint64();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!a.isString(t.key)?"key: string expected":t.version!=null&&t.hasOwnProperty("version")&&!a.isInteger(t.version)&&!(t.version&&a.isInteger(t.version.low)&&a.isInteger(t.version.high))?"version: integer|Long expected":null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.KeyedItem"},n})(),i.TrackBatch=(function(){function n(r){if(this.items=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.signature="",n.prototype.items=a.emptyArray,n.encode=function(t,e){if(e||(e=S.create()),t.signature!=null&&Object.hasOwnProperty.call(t,"signature")&&e.uint32(10).string(t.signature),t.items!=null&&t.items.length)for(let c=0;c<t.items.length;++c)h.centrifugal.centrifuge.protocol.KeyedItem.encode(t.items[c],e.uint32(18).fork()).ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.TrackBatch;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.signature=t.string();break}case 2:{s.items&&s.items.length||(s.items=[]),s.items.push(h.centrifugal.centrifuge.protocol.KeyedItem.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.signature!=null&&t.hasOwnProperty("signature")&&!a.isString(t.signature))return"signature: string expected";if(t.items!=null&&t.hasOwnProperty("items")){if(!Array.isArray(t.items))return"items: array expected";for(let e=0;e<t.items.length;++e){let c=h.centrifugal.centrifuge.protocol.KeyedItem.verify(t.items[e]);if(c)return"items."+c}}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.TrackBatch"},n})(),i.SubRefreshRequest=(function(){function n(r){if(this.track=[],this.untrack=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.prototype.token="",n.prototype.type=0,n.prototype.track=a.emptyArray,n.prototype.untrack=a.emptyArray,n.encode=function(t,e){if(e||(e=S.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.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(24).int32(t.type),t.track!=null&&t.track.length)for(let c=0;c<t.track.length;++c)h.centrifugal.centrifuge.protocol.TrackBatch.encode(t.track[c],e.uint32(34).fork()).ldelim();if(t.untrack!=null&&t.untrack.length)for(let c=0;c<t.untrack.length;++c)e.uint32(42).string(t.untrack[c]);return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.SubRefreshRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.token=t.string();break}case 3:{s.type=t.int32();break}case 4:{s.track&&s.track.length||(s.track=[]),s.track.push(h.centrifugal.centrifuge.protocol.TrackBatch.decode(t,t.uint32()));break}case 5:{s.untrack&&s.untrack.length||(s.untrack=[]),s.untrack.push(t.string());break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.channel))return"channel: string expected";if(t.token!=null&&t.hasOwnProperty("token")&&!a.isString(t.token))return"token: string expected";if(t.type!=null&&t.hasOwnProperty("type")&&!a.isInteger(t.type))return"type: integer expected";if(t.track!=null&&t.hasOwnProperty("track")){if(!Array.isArray(t.track))return"track: array expected";for(let e=0;e<t.track.length;++e){let c=h.centrifugal.centrifuge.protocol.TrackBatch.verify(t.track[e]);if(c)return"track."+c}}if(t.untrack!=null&&t.hasOwnProperty("untrack")){if(!Array.isArray(t.untrack))return"untrack: array expected";for(let e=0;e<t.untrack.length;++e)if(!a.isString(t.untrack[e]))return"untrack: string[] expected"}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshRequest"},n})(),i.SubRefreshResult=(function(){function n(r){if(this.items=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.expires=!1,n.prototype.ttl=0,n.prototype.items=a.emptyArray,n.encode=function(t,e){if(e||(e=S.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.items!=null&&t.items.length)for(let c=0;c<t.items.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.items[c],e.uint32(26).fork()).ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.SubRefreshResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}case 3:{s.items&&s.items.length||(s.items=[]),s.items.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isInteger(t.ttl))return"ttl: integer expected";if(t.items!=null&&t.hasOwnProperty("items")){if(!Array.isArray(t.items))return"items: array expected";for(let e=0;e<t.items.length;++e){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.items[e]);if(c)return"items."+c}}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshResult"},n})(),i.UnsubscribeRequest=(function(){function n(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.UnsubscribeRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.encode=function(t,e){return e||(e=S.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.UnsubscribeResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.prototype.data=a.newBuffer([]),n.prototype.type=0,n.prototype.key="",n.prototype.removed=!1,n.encode=function(t,e){return e||(e=S.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),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(24).int32(t.type),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&e.uint32(34).string(t.key),t.removed!=null&&Object.hasOwnProperty.call(t,"removed")&&e.uint32(40).bool(t.removed),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PublishRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.data=t.bytes();break}case 3:{s.type=t.int32();break}case 4:{s.key=t.string();break}case 5:{s.removed=t.bool();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!a.isString(t.channel)?"channel: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||a.isString(t.data))?"data: buffer expected":t.type!=null&&t.hasOwnProperty("type")&&!a.isInteger(t.type)?"type: integer expected":t.key!=null&&t.hasOwnProperty("key")&&!a.isString(t.key)?"key: string expected":t.removed!=null&&t.hasOwnProperty("removed")&&typeof t.removed!="boolean"?"removed: boolean 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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.encode=function(t,e){return e||(e=S.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PublishResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PresenceRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!a.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(r){if(this.presence={},r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.presence=a.emptyObject,n.encode=function(t,e){if(e||(e=S.create()),t.presence!=null&&Object.hasOwnProperty.call(t,"presence"))for(let c=Object.keys(t.presence),s=0;s<c.length;++s)e.uint32(10).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.ClientInfo.encode(t.presence[c[s]],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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PresenceResult,u,d;for(;t.pos<c;){let g=t.uint32();switch(g>>>3){case 1:{s.presence===a.emptyObject&&(s.presence={});let k=t.uint32()+t.pos;for(u="",d=null;t.pos<k;){let P=t.uint32();switch(P>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break;default:t.skipType(P&7);break}}s.presence[u]=d;break}default:t.skipType(g&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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(!a.isObject(t.presence))return"presence: object expected";let e=Object.keys(t.presence);for(let c=0;c<e.length;++c){let s=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.presence[e[c]]);if(s)return"presence."+s}}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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.channel="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PresenceStatsRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.num_clients=0,n.prototype.num_users=0,n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PresenceStatsResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.num_clients=t.uint32();break}case 2:{s.num_users=t.uint32();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isInteger(t.num_clients)?"num_clients: integer expected":t.num_users!=null&&t.hasOwnProperty("num_users")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.prototype.epoch="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.StreamPosition;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.offset=t.uint64();break}case 2:{s.epoch=t.string();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){return typeof t!="object"||t===null?"object expected":t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.isInteger(t.offset.high))?"offset: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[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=S.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")&&h.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.HistoryRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 7:{s.limit=t.int32();break}case 8:{s.since=h.centrifugal.centrifuge.protocol.StreamPosition.decode(t,t.uint32());break}case 9:{s.reverse=t.bool();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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")&&!a.isString(t.channel))return"channel: string expected";if(t.limit!=null&&t.hasOwnProperty("limit")&&!a.isInteger(t.limit))return"limit: integer expected";if(t.since!=null&&t.hasOwnProperty("since")){let e=h.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(r){if(this.publications=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.publications=a.emptyArray,n.prototype.epoch="",n.prototype.offset=a.Long?a.Long.fromBits(0,0,!0):0,n.encode=function(t,e){if(e||(e=S.create()),t.publications!=null&&t.publications.length)for(let c=0;c<t.publications.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.publications[c],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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.HistoryResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.publications&&s.publications.length||(s.publications=[]),s.publications.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 2:{s.epoch=t.string();break}case 3:{s.offset=t.uint64();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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 c=h.centrifugal.centrifuge.protocol.Publication.verify(t.publications[e]);if(c)return"publications."+c}}return t.epoch!=null&&t.hasOwnProperty("epoch")&&!a.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!a.isInteger(t.offset)&&!(t.offset&&a.isInteger(t.offset.low)&&a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.encode=function(t,e){return e||(e=S.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PingRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.encode=function(t,e){return e||(e=S.create()),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.PingResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.data=a.newBuffer([]),n.prototype.method="",n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.RPCRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.data=t.bytes();break}case 2:{s.method=t.string();break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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"||a.isString(t.data))?"data: buffer expected":t.method!=null&&t.hasOwnProperty("method")&&!a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.data=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.RPCResult;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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"||a.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(r){if(r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.data=a.newBuffer([]),n.encode=function(t,e){return e||(e=S.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 p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.SendRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(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"||a.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.FilterNode=(function(){function n(r){if(this.vals=[],this.nodes=[],r)for(let t=Object.keys(r),e=0;e<t.length;++e)r[t[e]]!=null&&(this[t[e]]=r[t[e]])}return n.prototype.op="",n.prototype.key="",n.prototype.cmp="",n.prototype.val="",n.prototype.vals=a.emptyArray,n.prototype.nodes=a.emptyArray,n.encode=function(t,e){if(e||(e=S.create()),t.op!=null&&Object.hasOwnProperty.call(t,"op")&&e.uint32(10).string(t.op),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&e.uint32(18).string(t.key),t.cmp!=null&&Object.hasOwnProperty.call(t,"cmp")&&e.uint32(26).string(t.cmp),t.val!=null&&Object.hasOwnProperty.call(t,"val")&&e.uint32(34).string(t.val),t.vals!=null&&t.vals.length)for(let c=0;c<t.vals.length;++c)e.uint32(42).string(t.vals[c]);if(t.nodes!=null&&t.nodes.length)for(let c=0;c<t.nodes.length;++c)h.centrifugal.centrifuge.protocol.FilterNode.encode(t.nodes[c],e.uint32(50).fork()).ldelim();return e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e){t instanceof p||(t=p.create(t));let c=e===void 0?t.len:t.pos+e,s=new h.centrifugal.centrifuge.protocol.FilterNode;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.op=t.string();break}case 2:{s.key=t.string();break}case 3:{s.cmp=t.string();break}case 4:{s.val=t.string();break}case 5:{s.vals&&s.vals.length||(s.vals=[]),s.vals.push(t.string());break}case 6:{s.nodes&&s.nodes.length||(s.nodes=[]),s.nodes.push(h.centrifugal.centrifuge.protocol.FilterNode.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},n.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.op!=null&&t.hasOwnProperty("op")&&!a.isString(t.op))return"op: string expected";if(t.key!=null&&t.hasOwnProperty("key")&&!a.isString(t.key))return"key: string expected";if(t.cmp!=null&&t.hasOwnProperty("cmp")&&!a.isString(t.cmp))return"cmp: string expected";if(t.val!=null&&t.hasOwnProperty("val")&&!a.isString(t.val))return"val: string expected";if(t.vals!=null&&t.hasOwnProperty("vals")){if(!Array.isArray(t.vals))return"vals: array expected";for(let e=0;e<t.vals.length;++e)if(!a.isString(t.vals[e]))return"vals: string[] expected"}if(t.nodes!=null&&t.hasOwnProperty("nodes")){if(!Array.isArray(t.nodes))return"nodes: array expected";for(let e=0;e<t.nodes.length;++e){let c=h.centrifugal.centrifuge.protocol.FilterNode.verify(t.nodes[e]);if(c)return"nodes."+c}}return null},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.FilterNode"},n})(),i})(),o})(),l})();var Rn=Ut.centrifuge.protocol.Command,ue=Ut.centrifuge.protocol.Reply,ri=Ut.centrifuge.protocol.EmulationRequest,Nt=class{name(){return"protobuf"}encodeEmulationRequest(o){let i=rt.Writer.create();return ri.encode(o,i),i.finish()}encodeCommands(o){let i=rt.Writer.create();for(let n of o)i.fork(),Rn.encodeDelimited(n,i);return i.finish()}encodeReplies(o){let i=rt.Writer.create();for(let n of o)i.fork(),ue.encodeDelimited(n,i);return i.finish()}decodeReplies(o){let i=[],n=rt.Reader.create(new Uint8Array(o));for(;n.pos<n.len;){let r=ue.decodeDelimited(n);i.push(r)}return i}decodeCommands(o){let i=[],n=rt.Reader.create(new Uint8Array(o));for(;n.pos<n.len;){let r=Rn.decodeDelimited(n);i.push(r)}return i}decodeReply(o){let i=rt.Reader.create(new Uint8Array(o));for(;i.pos<i.len;)return ue.decodeDelimited(i),{ok:!0,pos:i.pos};return{ok:!1}}applyDeltaIfNeeded(o,i){let n,r,t;if(o.delta){t=!0;let e=Lt(i,o.data);n=new Uint8Array(e),r=e}else t=!1,n=o.data,r=o.data;return{newData:n,newPrevValue:r,isDelta:t,wireBytes:o.data.length,fullBytes:r.length}}};var Ft=class extends st{_formatOverride(){this._codec=new Nt}};globalThis.Centrifuge=Ft;})();
/*! Bundled license information:

long/umd/index.js:
  (**
   * @license
   * Copyright 2009 The Closure Library Authors
   * Copyright 2020 Daniel Wirtz / The long.js Authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   *
   * SPDX-License-Identifier: Apache-2.0
   *)
*/
//# sourceMappingURL=centrifuge.protobuf.js.map