1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8105],{16191:function(e,t,n){e.exports=function(){"use strict";var e,t,s,r,i,a,o,u,l,c,h,p,d,g,y,f,m,b,v,S,k,E,O,C,w,N,P,M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var j={exports:{}};B={encode:function(e){var t,n=new ArrayBuffer(256),s=new DataView(n),r=0;function i(e){for(var i=n.byteLength,a=r+e;i<a;)i*=2;if(i!==n.byteLength){var o=s;s=new DataView(n=new ArrayBuffer(i));for(var u=r+3>>2,l=0;l<u;++l)s.setUint32(4*l,o.getUint32(4*l))}return t=e,s}function a(e){i(1).setUint8(r,e),r+=t}function o(e){for(var n=i(e.length),s=0;s<e.length;++s)n.setUint8(r+s,e[s]);r+=t}function u(e,n){var s,o;n<24?a(e<<5|n):n<256?(a(e<<5|24),a(n)):(n<65536?(a(e<<5|25),i(2).setUint16(r,n)):n<0x100000000?(a(e<<5|26),i(4).setUint32(r,n)):(a(e<<5|27),s=n%0x100000000,(o=i(8)).setUint32(r,(n-s)/0x100000000),o.setUint32(r+4,s)),r+=t)}if(function e(n){if(!1===n)return a(244);if(!0===n)return a(245);if(null===n)return a(246);if(void 0===n)return a(247);switch(typeof n){case"number":if(Math.floor(n)===n){if(0<=n&&n<=0x20000000000000)return u(0,n);if(-0x20000000000000<=n&&n<0)return u(1,-(n+1))}return a(251),void(i(8).setFloat64(r,n),r+=t);case"string":var s,l,c=[];for(s=0;s<n.length;++s){var h=n.charCodeAt(s);h<128?c.push(h):(h<2048?c.push(192|h>>6):(h<55296?c.push(224|h>>12):(h=((1023&h)<<10|1023&n.charCodeAt(++s))+65536,c.push(240|h>>18),c.push(128|h>>12&63)),c.push(128|h>>6&63)),c.push(128|63&h))}return u(3,c.length),o(c);default:if(Array.isArray(n))for(u(4,l=n.length),s=0;s<l;++s)e(n[s]);else if(n instanceof Uint8Array)u(2,n.length),o(n);else{var p=Object.keys(n);for(u(5,l=p.length),s=0;s<l;++s){var d=p[s];e(d),e(n[d])}}}}(e),"slice"in n)return n.slice(0,r);for(var l=new ArrayBuffer(r),c=new DataView(l),h=0;h<r;++h)c.setUint8(h,s.getUint8(h));return l},decode:function(e,t,n){var s=new DataView(e),r=0;function i(t){var n;return n=new Uint8Array(e,r,t),r+=t,n}function a(){var e;return e=s.getUint8(r),r+=1,e}function o(){var e;return e=s.getUint16(r),r+=2,e}function u(){var e;return e=s.getUint32(r),r+=4,e}function l(){return 255===s.getUint8(r)&&(r+=1,!0)}function c(e){if(e<24)return e;if(24===e)return a();if(25===e)return o();if(26===e)return u();if(27===e)return 0x100000000*u()+u();if(31===e)return -1;throw"Invalid length encoding"}function h(e){var t=a();if(255===t)return -1;var n=c(31&t);if(n<0||t>>5!==e)throw"Invalid indefinite length element";return n}function p(e,t){for(var n=0;n<t;++n){var s=a();128&s&&(s<224?(s=(31&s)<<6|63&a(),t-=1):s<240?(s=(15&s)<<12|(63&a())<<6|63&a(),t-=2):(s=(15&s)<<18|(63&a())<<12|(63&a())<<6|63&a(),t-=3)),s<65536?e.push(s):(s-=65536,e.push(55296|s>>10),e.push(56320|1023&s))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof n&&(n=function(){return L});var d=function e(){var u,d,g,y,f,m=a(),b=m>>5,v=31&m;if(7===b)switch(v){case 25:var S=new DataView(new ArrayBuffer(4)),k=o(),E=31744&k,O=1023&k;if(31744===E)E=261120;else if(0!==E)E+=114688;else if(0!==O)return 5960464477539063e-23*O;return S.setUint32(0,(32768&k)<<16|E<<13|O<<13),S.getFloat32(0);case 26:return u=s.getFloat32(r),r+=4,u;case 27:return d=s.getFloat64(r),r+=8,d}if((f=c(v))<0&&(b<2||6<b))throw"Invalid length";switch(b){case 0:return f;case 1:return -1-f;case 2:if(f<0){for(var C=[],w=0;(f=h(b))>=0;)w+=f,C.push(i(f));var N=new Uint8Array(w),P=0;for(y=0;y<C.length;++y)N.set(C[y],P),P+=C[y].length;return N}return i(f);case 3:var M=[];if(f<0)for(;(f=h(b))>=0;)p(M,f);else p(M,f);return String.fromCharCode.apply(null,M);case 4:if(f<0)for(g=[];!l();)g.push(e());else for(g=Array(f),y=0;y<f;++y)g[y]=e();return g;case 5:var _={};for(y=0;y<f||f<0&&!l();++y)_[e()]=e();return _;case 6:return t(e(),f);case 7:switch(f){case 20:return!1;case 21:return!0;case 22:return null;case 23:return L;default:return n(f)}}}();if(r!==e.byteLength)throw"Remaining bytes";return d}},j.exports?j.exports=B:M.CBOR||(M.CBOR=B);
1var A=_(j.exports);function I(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)0>t.indexOf(s[r])&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(n[s[r]]=e[s[r]])}return n}function F(e,t,n,s){return new(n||(n=Promise))(function(r,i){function a(e){try{u(s.next(e))}catch(e){i(e)}}function o(e){try{u(s.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,o)}u((s=s.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class T{static legacyCryptoModule(e){throw Error("Should be implemented by concrete crypto module implementation.")}static aesCbcCryptoModule(e){throw Error("Should be implemented by concrete crypto module implementation.")}constructor(e){var t;this.defaultCryptor=e.default,this.cryptors=null!=(t=e.cryptors)?t:[]}getAllCryptors(){return[this.defaultCryptor,...this.cryptors]}}T.encoder=new TextEncoder,T.decoder=new TextDecoder;class R{static create(e){return new R(e)}constructor(e){let t,n,s,r;if(e instanceof File)r=e,s=e.name,n=e.type,t=e.size;else if("data"in e){let i=e.data;n=e.mimeType,t=(r=new File([i],s=e.name,{type:n})).size}if(void 0===r)throw Error("Couldn't construct a file out of supplied options.");if(void 0===s)throw Error("Couldn't guess filename out of the options. Please provide one.");t&&(this.contentLength=t),this.mimeType=n,this.data=r,this.name=s}toBuffer(){return F(this,void 0,void 0,function*(){throw Error("This feature is only supported in Node.js environments.")})}toArrayBuffer(){return F(this,void 0,void 0,function*(){return new Promise((e,t)=>{let n=new FileReader;n.addEventListener("load",()=>{if(n.result instanceof ArrayBuffer)return e(n.result)}),n.addEventListener("error",()=>t(n.error)),n.readAsArrayBuffer(this.data)})})}toString(){return F(this,void 0,void 0,function*(){return new Promise((e,t)=>{let n=new FileReader;n.addEventListener("load",()=>{if("string"==typeof n.result)return e(n.result)}),n.addEventListener("error",()=>{t(n.error)}),n.readAsBinaryString(this.data)})})}toStream(){return F(this,void 0,void 0,function*(){throw Error("This feature is only supported in Node.js environments.")})}toFile(){return F(this,void 0,void 0,function*(){return this.data})}toFileUri(){return F(this,void 0,void 0,function*(){throw Error("This feature is only supported in React Native environments.")})}toBlob(){return F(this,void 0,void 0,function*(){return this.data})}}function x(e){let t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),s=new ArrayBuffer(n),r=new
1Uint8Array(s),i=0;function a(){let e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw Error(`Illegal character at ${i}: ${t.charAt(i-1)}`);return n}for(let e=0;e<n;e+=3){let t=a(),n=a(),s=a(),i=a(),o=(63&t)<<2|n>>4,u=(15&n)<<4|s>>2,l=(3&s)<<6|i;r[e]=o,64!=s&&(r[e+1]=u),64!=i&&(r[e+2]=l)}return s}function U(e){let t,n,s="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),a=i.byteLength,o=a%3,u=a-o;for(let e=0;e<u;e+=3)s+=r[t=(0xfc0000&(n=i[e]<<16|i[e+1]<<8|i[e+2]))>>18]+r[(258048&n)>>12]+r[(4032&n)>>6]+r[63&n];return 1==o?s+=r[t=(252&(n=i[u]))>>2]+r[(3&n)<<4]+"==":2==o&&(s+=r[t=(64512&(n=i[u]<<8|i[u+1]))>>10]+r[(1008&n)>>4]+r[(15&n)<<2]+"="),s}R.supportsBlob="undefined"!=typeof Blob,R.supportsFile="undefined"!=typeof File,R.supportsBuffer=!1,R.supportsStream=!1,R.supportsString=!0,R.supportsArrayBuffer=!0,R.supportsEncryptFile=!0,R.supportsFileUri=!1,(H=er||(er={})).PNNetworkIssuesCategory="PNNetworkIssuesCategory",H.PNTimeoutCategory="PNTimeoutCategory",H.PNCancelledCategory="PNCancelledCategory",H.PNBadRequestCategory="PNBadRequestCategory",H.PNAccessDeniedCategory="PNAccessDeniedCategory",H.PNValidationErrorCategory="PNValidationErrorCategory",H.PNAcknowledgmentCategory="PNAcknowledgmentCategory",H.PNMalformedResponseCategory="PNMalformedResponseCategory",H.PNUnknownCategory="PNUnknownCategory",H.PNNetworkUpCategory="PNNetworkUpCategory",H.PNNetworkDownCategory="PNNetworkDownCategory",H.PNReconnectedCategory="PNReconnectedCategory",H.PNConnectedCategory="PNConnectedCategory",H.PNRequestMessageCountExceededCategory="PNRequestMessageCountExceededCategory",H.PNDisconnectedCategory="PNDisconnectedCategory",H.PNConnectionErrorCategory="PNConnectionErrorCategory",H.PNDisconnectedUnexpectedlyCategory="PNDisconnectedUnexpectedlyCategory";var D=er;class q extends Error{constructor(e,t){super(e),this.status=t,this.name="PubNubError",this.message=e,Object.setPrototypeOf(this,new.target.prototype)}}function G(e,t){return null!=e.statusCode||(e.statusCode=0),Object.assign(Object.assign({},e),{statusCode:e.statusCode,category:t,error:!0})}function K(e,t){return G(Object.assign({message:e},{}),D.PNValidationErrorCategory)}function $(e,t){return G(Object.assign(Object.assign({message:"Unable to deserialize service response"},void 0!==e?{responseText:e}:{}),void 0!==t?{statusCode:t}:{}),D.PNMalformedResponseCategory)}var L,B,H,V,W,z,J,X,Q,Y,Z,ee,et,en,es,er,ei,ea,eo,eu=eu||(V=Math,z=(W={}).lib={},J=function(){},X=z.Base={extend:function(e){J.prototype=this;var t=new J;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},Q=z.WordArray=X.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||Z).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes;if(e=e.sigBytes,this.clamp(),s%4)for(var r=0;r<e;r++)t[s+r>>>2]|=(n[r>>>2]>>>24-r%4*8&255)<<24-(s+r)%4*8;else if(65535<n.length)for(r=0;r<e;r+=4)t[s+r>>>2]=n[r>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=0xffffffff<<32-t%4*8,e.length=V.ceil(t/4)},clone:function(){var e=X.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(0x100000000*V.random()|0);return new Q.init(t,e)}}),Z=(Y=W.enc={}).Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],s=0;s<e;s++){var r=t[s>>>2]>>>24-s%4*8&255;n.push((r>>>4).toString(16)),n.push((15&r).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new Q.init(n,t/2)}},ee=Y.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],s=0;s<e;s++)n.push(String.fromCharCode(t[s>>>2]>>>24-s%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new Q.init(n,t)}},et=Y.Utf8={stringify:function(e){try{return decodeURIComponent(escape(ee.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return ee.parse(unescape(encodeURIComponent(e)))}},en=z.BufferedBlockAlgorithm=X.extend({reset:function(){this._data=new Q.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=et.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,s=t.sigBytes,r=this.blockSize,i=s/(4*r);if(e=(i=e?V.ceil(i):V.max((0|i)-this._minBufferSize,0))*r,s=V.min(4*e,s),e){for(var a=0;a<e;a+=r)this._doProcessBlock(n,a);a=n.splice(0,e),t.sigBytes-=s}return new Q.init(a,s)},clone:function(){var e=X.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),z.Hasher=en.extend({cfg:X.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){en.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new es.HMAC.init(e,n).finalize(t)}}}),es=W.algo={},W);!function(e){for(var t,n=(r=eu.lib).WordArray,s=r.Hasher,r=eu.algo,i=[],a=[],o=function(e){return 0x100000000*(e-(0|e))|0},u=2,l=0;64>l;){e:{t=u;for(var c=e.sqrt(t),h=2;h<=c;
vendor: 11,523 bytes, line 1
1h++)if(!(t%h)){t=!1;break e}t=!0}t&&(8>l&&(i[l]=o(e.pow(u,.5))),a[l]=o(e.pow(u,1/3)),l++),u++}var p=[];r=r.SHA256=s.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,s=n[0],r=n[1],i=n[2],o=n[3],u=n[4],l=n[5],c=n[6],h=n[7],d=0;64>d;d++){if(16>d)p[d]=0|e[t+d];else{var g=p[d-15],y=p[d-2];p[d]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+p[d-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+p[d-16]}g=h+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&c)+a[d]+p[d],y=((s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22))+(s&r^s&i^r&i),h=c,c=l,l=u,u=o+g|0,o=i,i=r,r=s,s=g+y|0}n[0]=n[0]+s|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+c|0,n[7]=n[7]+h|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=e.floor(s/0x100000000),n[15+(r+64>>>9<<4)]=s,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),eu.SHA256=s._createHelper(r),eu.HmacSHA256=s._createHmacHelper(r)}(Math),ei=eu.enc.Utf8,eu.algo.HMAC=eu.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=ei.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,o=i.words,u=0;u<n;u++)a[u]^=0x5c5c5c5c,o[u]^=0x36363636;r.sigBytes=i.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}}),ea=eu.lib.WordArray,eu.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,s=this._map;e.clamp(),e=[];for(var r=0;r<n;r+=3)for(var i=(t[r>>>2]>>>24-r%4*8&255)<<16|(t[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|t[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;4>a&&r+.75*a<n;a++)e.push(s.charAt(i>>>6*(3-a)&63));if(t=s.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(s=n.charAt(64))&&-1!=(s=e.indexOf(s))&&(t=s);for(var s=[],r=0,i=0;i<t;i++)if(i%4){var a=n.indexOf(e.charAt(i-1))<<i%4*2,o=n.indexOf(e.charAt(i))>>>6-i%4*2;s[r>>>2]|=(a|o)<<24-r%4*8,r++}return ea.create(s,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,s,r,i,a){return((e=e+(t&n|~t&s)+r+a)<<i|e>>>32-i)+t}function n(e,t,n,s,r,i,a){return((e=e+(t&s|n&~s)+r+a)<<i|e>>>32-i)+t}function s(e,t,n,s,r,i,a){return((e=e+(t^n^s)+r+a)<<i|e>>>32-i)+t}function r(e,t,n,s,r,i,a){return((e=e+(n^(t|~s))+r+a)<<i|e>>>32-i)+t}for(var i=(o=eu.lib).WordArray,a=o.Hasher,o=eu.algo,u=[],l=0;64>l;l++)u[l]=0x100000000*e.abs(e.sin(l+1))|0;o=o.MD5=a.extend({_doReset:function(){this._hash=new i.init([0x67452301,0xefcdab89,0x98badcfe,0x10325476])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var o=e[l=i+a];e[l]=0xff00ff&(o<<8|o>>>24)|0xff00ff00&(o<<24|o>>>8)}a=this._hash.words;var l=e[i+0],c=(o=e[i+1],e[i+2]),h=e[i+3],p=e[i+4],d=e[i+5],g=e[i+6],y=e[i+7],f=e[i+8],m=e[i+9],b=e[i+10],v=e[i+11],S=e[i+12],k=e[i+13],E=e[i+14],O=e[i+15],C=t(C=a[0],P=a[1],N=a[2],w=a[3],l,7,u[0]),w=t(w,C,P,N,o,12,u[1]),N=t(N,w,C,P,c,17,u[2]),P=t(P,N,w,C,h,22,u[3]);C=t(C,P,N,w,p,7,u[4]),w=t(w,C,P,N,d,12,u[5]),N=t(N,w,C,P,g,17,u[6]),P=t(P,N,w,C,y,22,u[7]),C=t(C,P,N,w,f,7,u[8]),w=t(w,C,P,N,m,12,u[9]),N=t(N,w,C,P,b,17,u[10]),P=t(P,N,w,C,v,22,u[11]),C=t(C,P,N,w,S,7,u[12]),w=t(w,C,P,N,k,12,u[13]),N=t(N,w,C,P,E,17,u[14]),C=n(C,P=t(P,N,w,C,O,22,u[15]),N,w,o,5,u[16]),w=n(w,C,P,N,g,9,u[17]),N=n(N,w,C,P,v,14,u[18]),P=n(P,N,w,C,l,20,u[19]),C=n(C,P,N,w,d,5,u[20]),w=n(w,C,P,N,b,9,u[21]),N=n(N,w,C,P,O,14,u[22]),P=n(P,N,w,C,p,20,u[23]),C=n(C,P,N,w,m,5,u[24]),w=n(w,C,P,N,E,9,u[25]),N=n(N,w,C,P,h,14,u[26]),P=n(P,N,w,C,f,20,u[27]),C=n(C,P,N,w,k,5,u[28]),w=n(w,C,P,N,c,9,u[29]),N=n(N,w,C,P,y,14,u[30]),C=s(C,P=n(P,N,w,C,S,20,u[31]),N,w,d,4,u[32]),w=s(w,C,P,N,f,11,u[33]),N=s(N,w,C,P,v,16,u[34]),P=s(P,N,w,C,E,23,u[35]),C=s(C,P,N,w,o,4,u[36]),w=s(w,C,P,N,p,11,u[37]),N=s(N,w,C,P,y,16,u[38]),P=s(P,N,w,C,b,23,u[39]),C=s(C,P,N,w,k,4,u[40]),w=s(w,C,P,N,l,11,u[41]),N=s(N,w,C,P,h,16,u[42]),P=s(P,N,w,C,g,23,u[43]),C=s(C,P,N,w,m,4,u[44]),w=s(w,C,P,N,S,11,u[45]),N=s(N,w,C,P,O,16,u[46]),C=r(C,P=s(P,N,w,C,c,23,u[47]),N,w,l,6,u[48]),w=r(w,C,P,N,y,10,u[49]),N=r(N,w,C,P,E,15,u[50]),P=r(P,N,w,C,d,21,u[51]),C=r(C,P,N,w,S,6,u[52]),w=r(w,C,P,N,h,10,u[53]),N=r(N,w,C,P,b,15,u[54]),P=r(P,N,w,C,o,21,u[55]),C=r(C,P,N,w,f,6,u[56]),w=r(w,C,P,N,O,10,u[57]),N=r(N,w,C,P,g,15,u[58]),P=r(P,N,w,C,k,21,u[59]),C=r(C,P,N,w,p,6,u[60]),w=r(w,C,P,N,v,10,u[61]),N=r(N,w,C,P,c,15,u[62]),P=r(P,N,w,C,m,21,u[63]),a[0]=a[0]+C|0,a[1]=a[1]+P|0,a[2]=a[2]+N|0,a[3]=a[3]+w|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var i=e.floor(s/0x100000000);for(n[15+(r+64>>>9<<4)]=0xff00ff&(i<<8|i>>>24)|0xff00ff00&(i<<24|i>>>8),n[14+(r+64>>>9<<4)]=0xff00ff&(s<<8|s>>>24)|0xff00ff00&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,s=0;4>s;s++)r=n[s],n[s]=0xff00ff&(r<<8|r>>>24)|0xff00ff00&(r<<24|r>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),eu.MD5=a._createHelper(o),eu.HmacMD5=a._createHmacHelper(o)}(Math),t=(e=eu.lib).Base,s=e.WordArray,r=(e=eu.algo).EvpKDF=t.extend({cfg:t.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(o=this.cfg).hasher.create(),r=s.create(),i=r.words,a=o.keySize,o=o.iterations;i.length<a;){u&&n.update(u);var u=n.update(e).finalize(t);n.reset();for(var l=1;l<o;l++)u=n.finalize(u),n.reset();r.concat(u)}return r.sigBytes=4*a,r}}),eu.EvpKDF=function(e,t,n){return r.create(n).compute(e,t)},eu.lib.Cipher||(a=(i=(m=eu).lib).Base,o=i.WordArray,u=i.BufferedBlockAlgorithm,l=m.enc.Base64,c=m.algo.EvpKDF,h=i.Cipher=u.extend({cfg:a.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,n){this.cfg=this.cfg.extend(n),this._xformMode=e,this._key=t,this.reset()},reset:function(){u.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(e){return{encrypt:function(t,n,s){return("string"==typeof n?b:f).encrypt(e,t,n,s)},decrypt:function(t,n,s){return("string"==typeof n?b:f).decrypt(e,t,n,s)}}}}),i.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),p=m.mode={},d=function(e,t,n){var s=this._iv;s?this._iv=void 0:s=this._prevBlock;for(var r=0;r<n;r++)e[t+r]^=s[r]},(g=(i.BlockCipherMode=a.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}})).extend()).Encryptor=g.extend({processBlock:function(e,t){var n=this._cipher,s=n.blockSize;d.call(this,e,t,s),n.encryptBlock(e,t),this._prevBlock=e.slice(t,t+s)}}),g.Decryptor=g.extend({processBlock:function(e,t){var n=this._cipher,s=n.blockSize,r=e.slice(t,t+s);n.decryptBlock(e,t),d.call(this,e,t,s),this._prevBlock=r}}),p=p.CBC=g,g=(m.pad={}).Pkcs7={pad:function(e,t){for(var n,s=(n=(n=4*t)-e.sigBytes%n)<<24|n<<16|n<<8|n,r=[],i=0;i<n;i+=4)r.push(s);n=o.create(r,n),e.concat(n)},unpad:function(e){e.sigBytes-=255&e.words[e.sigBytes-1>>>2]}},i.BlockCipher=h.extend({cfg:h.cfg.extend({mode:p,padding:g}),reset:function(){h.reset.call(this);var e=(t=this.cfg).iv,t=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=t.createEncryptor;else n=t.createDecryptor,this._minBufferSize=1;this._mode=n.call(t,this,e&&e.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4}),y=i.CipherParams=a.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),p=(m.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?o.create([0x53616c74,0x65645f5f]).concat(e).concat(t):t).toString(l)},parse:function(e){var t=(e=l.parse(e)).words;if(0x53616c74==t[0]&&0x65645f5f==t[1]){var n=o.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return y.create({ciphertext:e,salt:n})}},f=i.SerializableCipher=a.extend({cfg:a.extend({format:p}),encrypt:function(e,t,n,s){s=this.cfg.extend(s);var r=e.createEncryptor(n,s);return t=r.finalize(t),r=r.cfg,y.create({ciphertext:t,key:n,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:s.format})},decrypt:function(e,t,n,s){return s=this.cfg.extend(s),t=this._parse(t,s.format),e.createDecryptor(n,s).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(m.kdf={}).OpenSSL={execute:function(e,t,n,s){return s||(s=o.random(8)),e=c.create({keySize:t+n}).compute(e,s),n=o.create(e.words.slice(t),4*n),e.sigBytes=4*t,y.create({key:e,iv:n,salt:s})}},b=i.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:m}),encrypt:function(e,t,n,s){return n=(s=this.cfg.extend(s)).kdf.execute(n,e.keySize,e.ivSize),s.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,s)).mixIn(n),e},decrypt:function(e,t,n,s){return s=this.cfg.extend(s),t=this._parse(t,s.format),n=s.kdf.execute(n,e.keySize,e.ivSize,t.salt),s.iv=n.iv,f.decrypt.call(this,e,t,n.key,s)}})),function(){for(var e=eu.lib.BlockCipher,t=eu.algo,n=[],s=[],r=[],i=[],a=[],o=[],u=[],l=[],c=[],h=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var f=(f=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&f^99;n[g]=f,s[f]=g;var m=p[g],b=p[m],v=p[b],S=257*p[f]^0x1010100*f;r[g]=S<<24|S>>>8,i[g]=S<<16|S>>>16,a[g]=S<<8|S>>>24,o[g]=S,S=0x1010101*v^65537*b^257*m^0x1010100*g,u[f]=S<<24|S>>>8,l[f]=S<<16|S>>>16,c[f]=S<<8|S>>>24,h[f]=S,g?(g=m^p[p[p[v^m]]],y^=p[p[y]]):g=y=1}var k=[0,1,2,4,8,16,32,64,128,27,54];t=t.AES=e.extend({_doReset:function(){for(var e=(s=this._key).words,t=s.sigBytes/4,s=4*((this._nRounds=t+6)+1),r=this._keySchedule=[],i=0;i<s;i++)if(i<t)r[i]=e[i];else{var a=r[i-1];i%t?6<t&&4==i%t&&(a=n[a>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a]):a=(n[(a=a<<8|a>>>24)>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a])^k[i/t|0]<<24,r[i]=r[i-t]^a}for(e=this._invKeySchedule=[],t=0;t<s;t++)i=s-t,a=t%4?r[i]:r[i-4],e[t]=4>t||4>=i?a:u[n[a>>>24]]^l[n[a>>>16&255]]^c[n[a>>>8&255]]^h[n[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,r,i,a,o,n)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,u,l,c,h,s),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,s,r,i,a,o){for(var u=this._nRounds,l=e[t]^n[0],c=e[t+1]^n[1],h=e[t+2]^n[2],p=e[t+3]^n[3],d=4,g=1;g<u;g++){var y=s[l>>>24]^r[c>>>16&255]^i[h>>>8&255]^a[255&p]^n[d++],f=s[c>>>24]^r[h>>>16&255]^i[p>>>8&255]^a[255&l]^n[d++],m=s[h>>>24]^r[p>>>16&255]^i[l>>>8&255]^a[255&c]^n[d++];p=s[p>>>24]^r[l>>>16&255]^i[c>>>8&255]^a[255&h]^n[d++],l=y,c=f,h=m}y=(o[l>>>24]<<24|o[c>>>16&255]<<16|o[h>>>8&255]<<8|o[255&p])^n[d++],f=(o[c>>>24]<<24|o[h>>>16&255]<<16|o[p>>>8&255]<<8|o[255&l])^n[d++],m=(o[h>>>24]<<24|o[p>>>16&255]<<16|o[l>>>8&255]<<8|o[255&c])^n[d++],p=(o[p>>>24]<<24|o[l>>>16&255]<<16|o[c>>>
18&255]<<8|o[255&h])^n[d++],e[t]=y,e[t+1]=f,e[t+2]=m,e[t+3]=p},keySize:8}),eu.AES=e._createHelper(t)}(),eu.mode.ECB=((eo=eu.lib.BlockCipherMode.extend()).Encryptor=eo.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),eo.Decryptor=eo.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),eo);var el=_(eu);class ec{constructor({cipherKey:e}){this.cipherKey=e,this.CryptoJS=el,this.encryptedKey=this.CryptoJS.SHA256(e)}encrypt(e){if(0===("string"==typeof e?e:ec.decoder.decode(e)).length)throw Error("encryption error. empty content");let t=this.getIv();return{metadata:t,data:x(this.CryptoJS.AES.encrypt(e,this.encryptedKey,{iv:this.bufferToWordArray(t),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}}encryptFileData(e){return F(this,void 0,void 0,function*(){let t=yield this.getKey(),n=this.getIv();return{data:yield crypto.subtle.encrypt({name:this.algo,iv:n},t,e),metadata:n}})}decrypt(e){if("string"==typeof e.data)throw Error("Decryption error: data for decryption should be ArrayBuffed.");let t=this.bufferToWordArray(new Uint8ClampedArray(e.metadata)),n=this.bufferToWordArray(new Uint8ClampedArray(e.data));return ec.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:n},this.encryptedKey,{iv:t,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer}decryptFileData(e){return F(this,void 0,void 0,function*(){if("string"==typeof e.data)throw Error("Decryption error: data for decryption should be ArrayBuffed.");let t=yield this.getKey();return crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)})}get identifier(){return"ACRH"}get algo(){return"AES-CBC"}getIv(){return crypto.getRandomValues(new Uint8Array(ec.BLOCK_SIZE))}getKey(){return F(this,void 0,void 0,function*(){let e=ec.encoder.encode(this.cipherKey),t=yield crypto.subtle.digest("SHA-256",e.buffer);return crypto.subtle.importKey("raw",t,this.algo,!0,["encrypt","decrypt"])})}bufferToWordArray(e){let t,n=[];for(t=0;t<e.length;t+=1)n[t/4|0]|=e[t]<<24-8*t;return this.CryptoJS.lib.WordArray.create(n,e.length)}}function eh(e){let t,n=[];for(t=0;t<e.length;t+=1)n[t/4|0]|=e[t]<<24-8*t;return el.lib.WordArray.create(n,e.length)}ec.BLOCK_SIZE=16,ec.encoder=new TextEncoder,ec.decoder=new TextDecoder;class ep{constructor(e){this.configuration=e,this.iv="0123456789012345",this.allowedKeyEncodings=["hex","utf8","base64","binary"],this.allowedKeyLengths=[128,256],this.allowedModes=["ecb","cbc"],this.defaultOptions={encryptKe
1y:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}HMACSHA256(e){return el.HmacSHA256(e,this.configuration.secretKey).toString(el.enc.Base64)}SHA256(e){return el.SHA256(e).toString(el.enc.Hex)}encrypt(e,t,n){return this.configuration.customEncrypt?this.configuration.customEncrypt(e):this.pnEncrypt(e,t,n)}decrypt(e,t,n){return this.configuration.customDecrypt?this.configuration.customDecrypt(e):this.pnDecrypt(e,t,n)}pnEncrypt(e,t,n){let s=null!=t?t:this.configuration.cipherKey;if(!s)return e;n=this.parseOptions(n);let r=this.getMode(n),i=this.getPaddedKey(s,n);if(this.configuration.useRandomIVs){let t=this.getRandomIV(),n=el.AES.encrypt(e,i,{iv:t,mode:r}).ciphertext;return t.clone().concat(n.clone()).toString(el.enc.Base64)}let a=this.getIV(n);return el.AES.encrypt(e,i,{iv:a,mode:r}).ciphertext.toString(el.enc.Base64)||e}pnDecrypt(e,t,n){let s=null!=t?t:this.configuration.cipherKey;if(!s)return e;n=this.parseOptions(n);let r=this.getMode(n),i=this.getPaddedKey(s,n);if(this.configuration.useRandomIVs){let t=new Uint8ClampedArray(x(e)),n=eh(t.slice(0,16)),s=eh(t.slice(16));try{let e=el.AES.decrypt({ciphertext:s},i,{iv:n,mode:r}).toString(el.enc.Utf8);return JSON.parse(e)}catch(e){return null}}{let t=this.getIV(n);try{let n=el.enc.Base64.parse(e),s=el.AES.decrypt({ciphertext:n},i,{iv:t,mode:r}).toString(el.enc.Utf8);return JSON.parse(s)}catch(e){return null}}}parseOptions(e){var t,n,s,r;if(!e)return this.defaultOptions;let i={encryptKey:null!=(t=e.encryptKey)?t:this.defaultOptions.encryptKey,keyEncoding:null!=(n=e.keyEncoding)?n:this.defaultOptions.keyEncoding,keyLength:null!=(s=e.keyLength)?s:this.defaultOptions.keyLength,mode:null!=(r=e.mode)?r:this.defaultOptions.mode};return -1===this.allowedKeyEncodings.indexOf(i.keyEncoding.toLowerCase())&&(i.keyEncoding=this.defaultOptions.keyEncoding),-1===this.allowedKeyLengths.indexOf(i.keyLength)&&(i.keyLength=this.defaultOptions.keyLength),-1===this.allowedModes.indexOf(i.mode.toLowerCase())&&(i.mode=this.defaultOptions.mode),i}decodeKey(e,t){return"base64"===t.keyEncoding?el.enc.Base64.parse(e):"hex"===t.keyEncoding?el.enc.Hex.parse(e):e}getPaddedKey(e,t){return e=this.decodeKey(e,t),t.encryptKey?el.enc.Utf8.parse(this.SHA256(e).slice(0,32)):e}getMode(e){return"ecb"===e.mode?el.mode.ECB:el.mode.CBC}getIV(e){return"cbc"===e.mode?el.enc.Utf8.parse(this.iv):null}getRandomIV(){return el.lib.WordArray.random(16)}}class ed{encrypt(e,t){return F(this,void 0,void 0,function*(){if(!(t instanceof ArrayBuffer)&&"string"!=typeof t)throw Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer");let n=yield this.getKey(e);return t instanceof ArrayBuffer?this.encryptArrayBuffer(n,t):this.encryptString(n,t)})}encryptArrayBuffer(e,t){return F(this,void 0,void 0,function*(){let n=crypto.getRandomValues(new Uint8Array(16));return this.concatArrayBuffer(n.buffer,(yield crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)))})}encryptString(e,t){return F(this,void 0,void 0,function*(){let n=crypto.getRandomValues(new Uint8Array(16)),s=ed.encoder.encode(t).buffer,r=yield crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,s),i=this.concatArrayBuffer(n.buffer,r);return ed.decoder.decode(i)})}encryptFile(e,t,n){return F(this,void 0,void 0,function*(){var s,r;if((null!=(s=t.contentLength)?s:0)<=0)throw Error("encryption error. empty content");let i=yield this.getKey(e),a=yield t.toArrayBuffer(),o=yield this.encryptArrayBuffer(i,a);return n.create({name:t.name,mimeType:null!=(r=t.mimeType)?r:"application/octet-stream",data:o})})}decrypt(e,t){return F(this,void 0,void 0,function*(){if(!(t instanceof ArrayBuffer)&&"string"!=typeof t)throw Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer");let n=yield this.getKey(e);return t instanceof ArrayBuffer?this.decryptArrayBuffer(n,t):this.decryptString(n,t)})}decryptArrayBuffer(e,t){return F(this,void 0,void 0,function*(){let n=t.slice(0,16);if(t.slice(ed.IV_LENGTH).byteLength<=0)throw Error("decryption error: empty content");return yield crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(ed.IV_LENGTH))})}decryptString(e,t){return F(this,void 0,void 0,function*(){let n=ed.encoder.encode(t).buffer,s=n.slice(0,16),r=n.slice(16),i=yield crypto.subtle.decrypt({
1name:"AES-CBC",iv:s},e,r);return ed.decoder.decode(i)})}decryptFile(e,t,n){return F(this,void 0,void 0,function*(){let s=yield this.getKey(e),r=yield t.toArrayBuffer(),i=yield this.decryptArrayBuffer(s,r);return n.create({name:t.name,mimeType:t.mimeType,data:i})})}getKey(e){return F(this,void 0,void 0,function*(){let t=Array.from(new Uint8Array((yield crypto.subtle.digest("SHA-256",ed.encoder.encode(e))))).map(e=>e.toString(16).padStart(2,"0")).join(""),n=ed.encoder.encode(t.slice(0,32)).buffer;return crypto.subtle.importKey("raw",n,"AES-CBC",!0,["encrypt","decrypt"])})}concatArrayBuffer(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}}ed.IV_LENGTH=16,ed.encoder=new TextEncoder,ed.decoder=new TextDecoder;class eg{constructor(e){this.config=e,this.cryptor=new ep(Object.assign({},e)),this.fileCryptor=new ed}encrypt(e){let t="string"==typeof e?e:eg.decoder.decode(e);return{data:this.cryptor.encrypt(t),metadata:null}}encryptFile(e,t){return F(this,void 0,void 0,function*(){var n;if(!this.config.cipherKey)throw new q("File encryption error: cipher key not set.");return this.fileCryptor.encryptFile(null==(n=this.config)?void 0:n.cipherKey,e,t)})}decrypt(e){let t="string"==typeof e.data?e.data:U(e.data);return this.cryptor.decrypt(t)}decryptFile(e,t){return F(this,void 0,void 0,function*(){if(!this.config.cipherKey)throw new q("File encryption error: cipher key not set.");return this.fileCryptor.decryptFile(this.config.cipherKey,e,t)})}get identifier(){return""}}eg.encoder=new TextEncoder,eg.decoder=new TextDecoder;class ey extends T{static legacyCryptoModule(e){var t;if(!e.cipherKey)throw new q("Crypto module error: cipher key not set.");return new ey({default:new eg(Object.assign(Object.assign({},e),{useRandomIVs:null==(t=e.useRandomIVs)||t})),cryptors:[new ec({cipherKey:e.cipherKey})]})}static aesCbcCryptoModule(e){var t;if(!e.cipherKey)throw new q("Crypto module error: cipher key not set.");return new ey({default:new ec({cipherKey:e.cipherKey}),cryptors:[new eg(Object.assign(Object.assign({},e),{useRandomIVs:null==(t=e.useRandomIVs)||t}))]})}static withDefaultCryptor(e){return new this({default:e})}encrypt(e){let t=e instanceof ArrayBuffer&&this.defaultCryptor.identifier===ey.LEGACY_IDENTIFIER?this.defaultCryptor.encrypt(ey.decoder.decode(e)):this.defaultCryptor.encrypt(e);if(!t.metadata)return t.data;if("string"==typeof t.data)throw Error("Encryption error: encrypted data should be ArrayBuffed.");let n=this.getHeaderData(t);return this.concatArrayBuffer(n,t.data)}encryptFile(e,t){return F(this,void 0,void 0,function*(){if(this.defaultCryptor.identifier===ef.LEGACY_IDENTIFIER)return this.defaultCryptor.encryptFile(e,t);let n=yield this.getFileData(e),s=yield this.defaultCryptor.encryptFileData(n);if("string"==typeof s.data)throw Error("Encryption error: encrypted data should be ArrayBuffed.");return t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(s),s.data)})})}decrypt(e){let t="string"==typeof e?x(e):e,n=ef.tryParse(t),s=this.getCryptor(n),r=n.length>0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw Error("Decryption error: empty content");return s.decrypt({data:t.slice(n.length),metadata:r})}decryptFile(e,t){return F(this,void 0,void 0,function*(){let n=yield e.data.arrayBuffer(),s=ef.tryParse(n),r=this.getCryptor(s);if((null==r?void 0:r.identifier)===ef.LEGACY_IDENTIFIER)return r.decryptFile(e,t);let i=(yield this.getFileData(n)).slice(s.length-s.metadataLength,s.length);return t.create({name:e.name,data:yield this.defaultCryptor.decryptFileData({data:n.slice(s.length),metadata:i})})})}getCryptorFromId(e){let t=this.getAllCryptors().find(t=>e===t.identifier);if(t)return t;throw Error("Unknown cryptor error")}getCryptor(e){if("string"==typeof e){let t=this.getAllCryptors().find(t=>t.identifier===e);if(t)return t;throw Error("Unknown cryptor error")}if(e instanceof em)return this.getCryptorFromId(e.identifier)}getHeaderData(e){if(!e.metadata)return;let t=ef.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),s=0;return n.set(t.data,s),s+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),s),n.buffer}concatArrayBuffer(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}getFileData(e){return F(this,void 0,void 0,function*(){if(e instanceof ArrayBuffer)return e;if(e instanceof R)return e.toArrayBuffer();throw Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")})}}ey.LEGACY_IDENTIFIER="";class ef{static from(e,t){if(e!==ef.LEGACY_IDENTIFIER)return new em(e,t.byteLength)}static tryParse(e){let t,n,s=new Uint8Array(e);if(s.byteLength>
1=4&&(t=s.slice(0,4),this.decoder.decode(t)!==ef.SENTINEL))return ey.LEGACY_IDENTIFIER;if(!(s.byteLength>=5))throw Error("Decryption error: invalid header version");if(s[4]>ef.MAX_VERSION)throw Error("Decryption error: Unknown cryptor error");let r=5+ef.IDENTIFIER_LENGTH;if(!(s.byteLength>=r))throw Error("Decryption error: invalid crypto identifier");n=s.slice(5,r);let i=null;if(!(s.byteLength>=r+1))throw Error("Decryption error: invalid metadata length");return i=s[r],r+=1,255===i&&s.byteLength>=r+2&&(i=new Uint16Array(s.slice(r,r+2)).reduce((e,t)=>(e<<8)+t,0)),new em(this.decoder.decode(n),i)}}ef.SENTINEL="PNED",ef.LEGACY_IDENTIFIER="",ef.IDENTIFIER_LENGTH=4,ef.VERSION=1,ef.MAX_VERSION=1,ef.decoder=new TextDecoder;class em{constructor(e,t){this._identifier=e,this._metadataLength=t}get identifier(){return this._identifier}set identifier(e){this._identifier=e}get metadataLength(){return this._metadataLength}set metadataLength(e){this._metadataLength=e}get version(){return ef.VERSION}get length(){return ef.SENTINEL.length+1+ef.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength}get data(){let e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(ef.SENTINEL)),t[e+=ef.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e);let s=this.metadataLength;return e+=ef.IDENTIFIER_LENGTH,s<255?t[e]=s:t.set([255,s>>8,255&s],e),t}}em.IDENTIFIER_LENGTH=4,em.SENTINEL="PNED";class eb extends Error{static create(e,t){return e instanceof Error?eb.createFromError(e):eb.createFromServiceResponse(e,t)}static createFromError(e){let t=D.PNUnknownCategory,n="Unknown error",s="Error";if(!e)return new eb(n,t,0);if(e instanceof eb)return e;if(e instanceof Error&&(n=e.message,s=e.name),"AbortError"===s||-1!==n.indexOf("Aborted"))t=D.PNCancelledCategory,n="Request cancelled";else if(-1!==n.toLowerCase().indexOf("timeout"))t=D.PNTimeoutCategory,n="Request timeout";else if(-1!==n.toLowerCase().indexOf("network"))t=D.PNNetworkIssuesCategory,n="Network issues";else if("TypeError"===s)t=-1!==n.indexOf("Load failed")||-1!=n.indexOf("Failed to fetch")?D.PNNetworkIssuesCategory:D.PNBadRequestCategory;else if("FetchError"===s){let s=e.code;["ECONNREFUSED","ENETUNREACH","ENOTFOUND","ECONNRESET","EAI_AGAIN"].includes(s)&&(t=D.PNNetworkIssuesCategory),"ECONNREFUSED"===s?n="Connection refused":"ENETUNREACH"===s?n="Network not reachable":"ENOTFOUND"===s?n="Server not found":"ECONNRESET"===s?n="Connection reset by peer":"EAI_AGAIN"===s?n="Name resolution error":"ETIMEDOUT"===s?(t=D.PNTimeoutCategory,n="Request timeout"):n=`Unknown system error: ${e}`}else"Request timeout"===n&&(t=D.PNTimeoutCategory);return new eb(n,t,0,e)}static createFromServiceResponse(e,t){let n,s=D.PNUnknownCategory,r="Unknown error",{status:i}=e;if(null!=t||(t=e.body),402===i?r="Not available for used key set. Contact [email protected]":400===i?(s=D.PNBadRequestCategory,r="Bad request"):403===i&&(s=D.PNAccessDeniedCategory,r="Access denied"),"object"==typeof e&&0===Object.keys(e).length&&(s=D.PNMalformedResponseCategory,r="Malformed response (network issues)",i=400),t&&t.byteLength>0){let s=(new TextDecoder).decode(t);if(-1!==e.headers["content-type"].indexOf("text/javascript")||-1!==e.headers["content-type"].indexOf("application/json"))try{let e=JSON.parse(s);"object"==typeof e&&(Array.isArray(e)?"number"==typeof e[0]&&0===e[0]&&e.length>1&&"string"==typeof e[1]&&(n=e[1]):("error"in e&&(1===e.error||!0===e.error)&&"status"in e&&"number"==typeof e.status&&"message"in e&&"service"in e?(n=e,i=e.status):n=e,"error"in e&&e.error instanceof Error&&(n=e.error)))}catch(e){n=s}else if(-1!==e.headers["content-type"].indexOf("xml")){let e=/<Message>(.*)<\/Message>/gi.exec(s);r=e?`Upload to bucket failed: ${e[1]}`:"Upload to bucket failed."}else n=s}return new eb(r,s,i,n)}constructor(e,t,n,s){super(e),this.category=t,this.statusCode=n,this.errorData=s,this.name="PubNubAPIError"}toStatus(e){return{error:!0,category:this.category,operation:e,statusCode:this.statusCode,errorData:this.errorData,toJSON:function(){let e,t=this.errorData;if(t)try{if("object"==typeof t){let n=Object.assign(Object.assign(Object.assign(Object.assign({},"name"in t?{name:t.name}:{}),"message"in t?{message:t.message}:{}),"stack"in t?{stack:t.stack}:{}),t);e=JSON.parse(JSON.stringify(n,eb.circularReplacer()))}else e=t}catch(t){e={error:"Could not serialize the error object"}}return JSON.stringify(Object.assign(Object.assign({},I(this,["toJSON"])),{errorData:e}))}}}toPubNubError(e,t){return new q(null!=t?t:this.message,this.toStatus(e))}static circularReplacer(){let e=new WeakSet;return function(t,n){if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular]";e.add(n)}return n}}}class ev{constructor(e){this.configuration=e,this.subscriptionWorkerReady=!1,this.workerEventsQueue=[],this.callbacks=new Map,this.setupSubscriptionWorker()}makeSendable(e){let t;if(!e.path.startsWith("/v2/subscribe")&&!e.path.endsWith("/heartbeat")&&!e.path.endsWith("/leave"))return this.configuration.transport.makeSendable(e);let n={type:"send-request",clientIdentifier:this.configuration.clientIdentifier,subscriptionKey:this.configuration.subscriptionKey,logVerbosity:this.configuration.logVerbosity,request:e};return e.cancellable&&(t={abort:()=>{let t={type:"cancel-request",clientIdentifier:this.configuration.clientIdentifier,subscriptionKey:this.configuration.subscriptionKey,logVerbosity:this.configuration.logVerbosity,identifier:e.identifier};this.scheduleEventPost(t)}}),[new Promise((t,s)=>{this.callbacks.set(e.identifier,{resolve:t,reject:s}),this.scheduleEventPost(n)}),t]}request(e){return e}scheduleEventPost(e,t=!1){let n=this.sharedSubscriptionWorker;n?n.port.postMessage(e):t?this.workerEventsQueue.splice(0,0,e):this.workerEventsQueue.push(e)}flushScheduledEvents(){let e=this.sharedSubscriptionWorker;if(!e||0===this.workerEventsQueue.length)return;let t=[];for(let e=0;e<this.workerEventsQueue.length;e++){let n=this.workerEventsQueue[e];if("cancel-request"===n.type&&0!==e)for(let s=0;s<e;s++){let e=this.workerEventsQueue[s];if("send-request"===e.type&&e.request.identifier===n.identifier){t.push(n,e);break}}}this.workerEventsQueue=this.workerEventsQueue.filter(e=>!t.includes(e)),this.workerEventsQueue.forEach(t=>e.port.postMessage(t)),this.workerEventsQueue=[]}get sharedSubscriptionWorker(){return this.subscriptionWorkerReady?this.subscriptionWorker:null}setupSubscriptionWorker(){"undefined"!=typeof SharedWorker&&(this.subscriptionWorker=new SharedWorker(this.configuration.workerUrl,`/pubnub-${this.configuration.sdkVersion}`),this.subscriptionWorker.port.start(),this.scheduleEventPost({type:"client-register",clientIdentifier:this.configuration.clientIdentifier,subscriptionKey:this.configuration.subscriptionKey,userId:this.configuration.userId,heartbeatInterval:this.configuration.heartbeatInterval,logVerbosity:this.configuration.logVerbosity,workerOfflineClientsCheckInterval:this.configuration.workerOfflineClientsCheckInterval,workerUnsubscribeOfflineClients:this.configuration.workerUnsubscribeOfflineClients,workerLogVerbosity:this.configuration.workerLogVerbosity},!0),this.subscriptionWorker.port.onmessage=e=>this.handleWorkerEvent(e))}handleWorkerEvent(e){let{data:t}=e;if("shared-worker-ping"===t.type||"shared-worker-connected"===t.type||"shared-worker-console-log"===t.type||"shared-worker-console-dir"===t.type||t.clientIdentifier===this.configuration.clientIdentifier){if("shared-worker-connected"===t.type)this.subscriptionWorkerReady=!0,this.flushScheduledEvents();else if("shared-worker-console-log"===t.type)console.log(`[SharedWorker] ${t.message}`);else if("shared-worker-console-dir"===t.type)t.message&&console.log(`[SharedWorker] ${t.message}`),console.dir(t.data,{depth:10});else if("shared-worker-ping"===t.type){let{logVerbosity:e,subscriptionKey:t,clientIdentifier:n}=this.configuration;this.scheduleEventPost({type:"client-pong",subscriptionKey:t,clientIdentifier:n,logVerbosity:e})}else if("request-progress-start"===t.type||"request-progress-end"===t.type)this.logRequestProgress(t);else if("request-process-success"===t.type||"request-process-error"===t.type){let{resolve:e,reject:n}=this.callbacks.get(t.identifier);if("request-process-success"===t.type)e({status:t.response.status,url:t.url,headers:t.response.headers,body:t.response.body});
1else{let e=D.PNUnknownCategory,s="Unknown error";if(t.error)"NETWORK_ISSUE"===t.error.type?e=D.PNNetworkIssuesCategory:"TIMEOUT"===t.error.type?e=D.PNTimeoutCategory:"ABORTED"===t.error.type&&(e=D.PNCancelledCategory),s=`${t.error.message} (${t.identifier})`;else if(t.response)return n(eb.create({url:t.url,headers:t.response.headers,body:t.response.body,status:t.response.status},t.response.body));n(new eb(s,e,0,Error(s)))}}}}logRequestProgress(e){var t,n;"request-progress-start"===e.type?(console.log("<<<<<"),console.log(`[${e.timestamp}] ${e.url} 2${JSON.stringify(null!=(t=e.query)?t:{})}`)):(console.log(">>>>>>"),console.log(`[${e.timestamp} / ${e.duration}] ${e.url} 3${JSON.stringify(null!=(n=e.query)?n:{})} 4${e.response}`)),console.log("-----")}}var eS={exports:{}};(function(e){var t={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};function n(){var e,t,n="";for(e=0;e<32;e++)t=16*Math.random()|0,8!==e&&12!==e&&16!==e&&20!==e||(n+="-"),n+=(12===e?4:16===e?3&t|8:t).toString(16);return n}function s(e,n){var s=t[n||"all"];return s&&s.test(e)||!1}n.isUUID=s,n.VERSION="0.1.0",e.uuid=n,e.isUUID=s})(v=eS.exports),null!==eS&&(eS.exports=v.uuid);var ek=_(eS.exports),eE=()=>ek.uuid?ek.uuid():ek();class eO{constructor(e){this.cbor=e}setToken(e){e&&e.length>0?this.token=e:this.token=void 0}getToken(){return this.token}parseToken(e){let t=this.cbor.decodeToken(e);if(void 0!==t){let e=t.res.uuid?Object.keys(t.res.uuid):[],n=Object.keys(t.res.chan),s=Object.keys(t.res.grp),r=t.pat.uuid?Object.keys(t.pat.uuid):[],i=Object.keys(t.pat.chan),a=Object.keys(t.pat.grp),o={version:t.v,timestamp:t.t,ttl:t.ttl,authorized_uuid:t.uuid,signature:t.sig},u=e.length>0,l=n.length>0,c=s.length>0;if(u||l||c){if(o.resources={},u){let n=o.resources.uuids={};e.forEach(e=>n[e]=this.extractPermissions(t.res.uuid[e]))}if(l){let e=o.resources.channels={};n.forEach(n=>e[n]=this.extractPermissions(t.res.chan[n]))}if(c){let e=o.resources.groups={};s.forEach(n=>e[n]=this.extractPermissions(t.res.grp[n]))}}let h=r.length>0,p=i.length>0,d=a.length>0;if(h||p||d){if(o.patterns={},h){let e=o.patterns.uuids={};r.forEach(n=>e[n]=this.extractPermissions(t.pat.uuid[n]))}if(p){let e=o.patterns.channels={};i.forEach(n=>e[n]=this.extractPermissions(t.pat.chan[n]))}if(d){let e=o.patterns.groups={};a.forEach(n=>e[n]=this.extractPermissions(t.pat.grp[n]))}}return t.meta&&Object.keys(t.meta).length>0&&(o.meta=t.meta),o}}extractPermissions(e){let t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128&~e||(t.join=!0),64&~e||(t.update=!0),32&~e||(t.get=!0),8&~e||(t.delete=!0),4&~e||(t.manage=!0),2&~e||(t.write=!0),1&~e||(t.read=!0),t}}(S=C||(C={})).GET="GET",S.POST="POST",S.PATCH="PATCH",S.DELETE="DELETE",S.LOCAL="LOCAL";let eC=e=>encodeURIComponent(e).replace(/[!~*'()]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ew=(e,t)=>{let n=e.map(e=>eC(e));return n.length?n.join(","):null!=t?t:""},eN=(e,t)=>{let n=Object.fromEntries(t.map(e=>[e,!1]));return e.filter(e=>!(t.includes(e)&&!n[e])||(n[e]=!0,!1))},eP=(e,t)=>[...e].filter(n=>t.includes(n)&&e.indexOf(n)===e.lastIndexOf(n)&&t.indexOf(n)===t.lastIndexOf(n));class eM{constructor(e,t,n){this.publishKey=e,this.secretKey=t,this.hasher=n}signature(e){let t=e.path.startsWith("/publish")?C.GET:e.method,n=`${t} 5${this.publishKey} 6${e.path} 7${this.queryParameters(e.queryParameters)} 8`;if(t===C.POST||t===C.PATCH){let t,s=e.body;s&&s instanceof ArrayBuffer?t=eM.textDecoder.decode(s):s&&"object"!=typeof s&&(t=s),t&&(n+=t)}return`v2.${this.hasher(n,this.secretKey)}`.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}queryParameters(e){return Object.keys(e).sort().map(t=>{let n=e[t];return Array.isArray(n)?n.sort().map(e=>`${t}=${eC(e)}`).join("&"):`${t}=${eC(n)}`}).join("&")}}eM.textDecoder=new TextDecoder("utf-8");class e_{constructor(e){this.configuration=e;let{clientConfiguration:{keySet:t},shaHMAC:n}=e;t.secretKey&&n&&(this.signatureGenerator=new eM(t.publishKey,t.secretKey,n))}makeSendable(e){return this.configuration.transport.makeSendable(this.request(e))}request(e){let{clientConfiguration:t}=this.configuration;return(e=this.configuration.transport.request(e)).queryParameters||(e.queryParameters={}),t.useInstanceId&&(e.queryParameters.instanceid=t.getInstanceId()),e.queryParameters.uuid||(e.queryParameters.uuid=t.userId),t.useRequestId&&(e.queryParameters.requestid=e.identifier),e.queryParameters.pnsdk=this.generatePNSDK(),null!=e.origin||(e.origin=t.origin),this.authenticateRequest(e),this.signRequest(e),e}authenticateRequest(e){var t;if(e.path.startsWith("/v2/auth/")||e.path.startsWith("/v3/pam/")||e.path.startsWith("/time"))return;let{clientConfiguration:n,tokenManager:s}=this.configuration,r=null!=(t=s&&s.getToken())?t:n.authKey;r&&(e.queryParameters.auth=r)}signRequest(e){this.signatureGenerator&&!e.path.startsWith("/time")&&(e.queryParameters.timestamp=String(Math.floor((new Date).getTime()/1e3)),e.queryParameters.signature=this.signatureGenerator.signature(e))}generatePNSDK(){let{clientConfiguration:e}=this.configuration;if(e.sdkName)return e.sdkName;let t=`PubNub-JS-${e.sdkFamily}`;e.partnerId&&(t+=`-${e.partnerId}`),t+=`/${e.getVersion()}`;let n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}}class ej{constructor(e="fetch",t=!1,n=!1){if(this.transport=e,this.keepAlive=t,this.logVerbosity=n,"fetch"!==e||window&&window.fetch||(this.transport="xhr"),"fetch"===this.transport&&(ej.originalFetch=fetch.bind(window),this.isFetchMonkeyPatched())){if(ej.originalFetch=ej.getOriginalFetch(),!n)return;console.warn("[PubNub] Native Web Fetch API 'fetch' function monkey patched."),this.isFetchMonkeyPatched(ej.originalFetch)?console.warn("[PubNub] Unable receive native Web Fetch API. There can be issues with subscribe long-poll cancellation"):console.info("[PubNub] Use native Web Fetch API 'fetch' implementation from iframe as APM workaround.")}}makeSendable(e){let t=new AbortController,n={abortController:t,abort:e=>!t.signal.aborted&&t.abort(e)};
8return[this.webTransportRequestFromTransportRequest(e).then(t=>{let s=(new Date).getTime();return this.logRequestProcessProgress(t,e.body),this.sendRequest(t,n).then(e=>e.arrayBuffer().then(t=>[e,t])).then(e=>{let n=e[1].byteLength>0?e[1]:void 0,{status:r,headers:i}=e[0],a={};i.forEach((e,t)=>a[t]=e.toLowerCase());let o={status:r,url:t.url,headers:a,body:n};if(r>=400)throw eb.create(o);return this.logRequestProcessProgress(t,void 0,(new Date).getTime()-s,n),o}).catch(e=>{let t=e;if("string"==typeof e){let n=e.toLowerCase();t=Error(e),!n.includes("timeout")&&n.includes("cancel")&&(t.name="AbortError")}throw eb.create(t)})}),n]}request(e){return e}sendRequest(e,t){return F(this,void 0,void 0,function*(){return"fetch"===this.transport?this.sendFetchRequest(e,t):this.sendXHRRequest(e,t)})}sendFetchRequest(e,t){return F(this,void 0,void 0,function*(){let n,s=new Promise((s,r)=>{n=setTimeout(()=>{clearTimeout(n),r(Error("Request timeout")),t.abort("Cancel because of timeout")},1e3*e.timeout)}),r=new Request(e.url,{method:e.method,headers:e.headers,redirect:"follow",body:e.body});return Promise.race([ej.originalFetch(r,{signal:t.abortController.signal,credentials:"omit",cache:"no-cache"}).then(e=>(n&&clearTimeout(n),e)),s])})}sendXHRRequest(e,t){return F(this,void 0,void 0,function*(){return new Promise((n,s)=>{var r;let i=new XMLHttpRequest;i.open(e.method,e.url,!0),i.responseType="arraybuffer",i.timeout=1e3*e.timeout,t.abortController.signal.onabort=()=>{i.readyState!=XMLHttpRequest.DONE&&i.readyState!=XMLHttpRequest.UNSENT&&i.abort()},Object.entries(null!=(r=e.headers)?r:{}).forEach(([e,t])=>i.setRequestHeader(e,t)),i.onabort=()=>s(Error("Aborted")),i.ontimeout=()=>s(Error("Request timeout")),i.onerror=()=>s(Error("Request timeout")),i.onload=()=>{let e=new Headers;i.getAllResponseHeaders().split("\r\n").forEach(t=>{let[n,s]=t.split(": ");n.length>1&&s.length>1&&e.append(n,s)}),n(new Response(i.response,{status:i.status,headers:e,statusText:i.statusText}))},i.send(e.body)})})}webTransportRequestFromTransportRequest(e){return F(this,void 0,void 0,function*(){var t;let n,s=e.path;if(e.formData&&e.formData.length>0){e.queryParameters={};let t=e.body,s=new FormData;for(let{key:t,value:n}of e.formData)s.append(t,n);try{let e=yield t.toArrayBuffer();s.append("file",new Blob([e],{type:"application/octet-stream"}),t.name)}catch(e){try{let e=yield t.toFileUri();s.append("file",e,t.name)}catch(e){}}n=s}else e.body&&("string"==typeof e.body||e.body instanceof ArrayBuffer)&&(n=e.body);return e.queryParameters&&0!==Object.keys(e.queryParameters).length&&(s=`${s}?${Object.keys(t=e.queryParameters).map(e=>{let n=t[e];return Array.isArray(n)?n.map(t=>`${e}=${eC(t)}`).join("&"):`${e}=${eC(n)}`}).join("&")}`),{url:`${e.origin}${s}`,method:e.method,headers:e.headers,timeout:e.timeout,body:n}})}logRequestProcessProgress(e,t,n,s){if(!this.logVerbosity)return;let{protocol:r,host:i,pathname:a,search:o}=new URL(e.url),u=(new Date).toISOString();if(n){let e=`[${u} / ${n}] 9${r}//${i}${a} 10${o}`;s&&(e+=` 11 12${ej.decoder.decode(s)}`),console.log(">>>>>>"),console.log(e),console.log("-----")}else{let e=`[${u}] 13${r}//${i}${a} 14${o}`;t&&("string"==typeof t||t instanceof ArrayBuffer)&&(e+="string"==typeof t?` 15 16${t}`:` 17 18${ej.decoder.decode(t)}`),console.log("<<<<<"),console.log(e),console.log("-----")}}isFetchMonkeyPatched(e){return!(null!=e?e:fetch).toString().includes("[native code]")&&"fetch"!==fetch.name}static getOriginalFetch(){let e=document.querySelector('iframe[name="pubnub-context-unpatched-fetch"]');return e||((e=document.createElement("iframe")).style.display="none",e.name="pubnub-context-unpatched-fetch",e.src="about:blank",document.body.appendChild(e)),e.contentWindow?e.contentWindow.fetch.bind(e.contentWindow):fetch}}ej.decoder=new TextDecoder;class eA{constructor(){this.listeners=[]}addListener(e){this.listeners.includes(e)||this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}removeAllListeners(){this.listeners=[]}announceStatus(e){this.listeners.forEach(t=>{t.status&&t.status(e)})}
18announcePresence(e){this.listeners.forEach(t=>{t.presence&&t.presence(e)})}announceMessage(e){this.listeners.forEach(t=>{t.message&&t.message(e)})}announceSignal(e){this.listeners.forEach(t=>{t.signal&&t.signal(e)})}announceMessageAction(e){this.listeners.forEach(t=>{t.messageAction&&t.messageAction(e)})}announceFile(e){this.listeners.forEach(t=>{t.file&&t.file(e)})}announceObjects(e){this.listeners.forEach(t=>{t.objects&&t.objects(e)})}announceNetworkUp(){this.listeners.forEach(e=>{e.status&&e.status({category:D.PNNetworkUpCategory})})}announceNetworkDown(){this.listeners.forEach(e=>{e.status&&e.status({category:D.PNNetworkDownCategory})})}announceUser(e){this.listeners.forEach(t=>{t.user&&t.user(e)})}announceSpace(e){this.listeners.forEach(t=>{t.space&&t.space(e)})}announceMembership(e){this.listeners.forEach(t=>{t.membership&&t.membership(e)})}}class eI{constructor(e){this.time=e}onReconnect(e){this.callback=e}startPolling(){this.timeTimer=setInterval(()=>this.callTime(),3e3)}stopPolling(){this.timeTimer&&clearInterval(this.timeTimer),this.timeTimer=null}callTime(){this.time(e=>{e.error||(this.stopPolling(),this.callback&&this.callback())})}}class eF{constructor({maximumCacheSize:e}){this.maximumCacheSize=e,this.hashHistory=[]}getKey(e){var t;return`${e.timetoken}-${this.hashCode(JSON.stringify(null!=(t=e.message)?t:"")).toString()}`}isDuplicate(e){return this.hashHistory.includes(this.getKey(e))}addEntry(e){this.hashHistory.length>=this.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))}clearHistory(){this.hashHistory=[]}hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return t}}class eT{constructor(e,t,n,s,r,i,a){this.configuration=e,this.listenerManager=t,this.eventEmitter=n,this.subscribeCall=s,this.heartbeatCall=r,this.leaveCall=i,this.reconnectionManager=new eI(a),this.dedupingManager=new eF(this.configuration),this.heartbeatChannelGroups={},this.heartbeatChannels={},this.presenceChannelGroups={},this.presenceChannels={},this.heartbeatTimer=null,this.presenceState={},this.pendingChannelGroupSubscriptions=new Set,this.pendingChannelSubscriptions=new Set,this.channelGroups={},this.channels={},this.currentTimetoken="0",this.lastTimetoken="0",this.storedTimetoken=null,this.subscriptionStatusAnnounced=!1,this.isOnline=!0}get subscribedChannels(){return Object.keys(this.channels)}get subscribedChannelGroups(){return Object.keys(this.channelGroups)}get abort(){return this._subscribeAbort}set abort(e){this._subscribeAbort=e}disconnect(){this.stopSubscribeLoop(),this.stopHeartbeatTimer(),this.reconnectionManager.stopPolling()}reconnect(e=!1){this.startSubscribeLoop(),!e&&this.configuration.useSmartHeartbeat&&this.startHeartbeatTimer()}subscribe(e){let{channels:t,channelGroups:n,timetoken:s,withPresence:r=!1,withHeartbeats:i=!1}=e;s&&(this.lastTimetoken=this.currentTimetoken,this.currentTimetoken=s),"0"!==this.currentTimetoken&&0!==this.currentTimetoken&&(this.storedTimetoken=this.currentTimetoken,this.currentTimetoken=0),null==t||t.forEach(e=>{this.pendingChannelSubscriptions.add(e),this.channels[e]={},r&&(this.presenceChannels[e]={}),(i||this.configuration.getHeartbeatInterval())&&(this.heartbeatChannels[e]={})}),null==n||n.forEach(e=>{this.pendingChannelGroupSubscriptions.add(e),this.channelGroups[e]={},r&&(this.presenceChannelGroups[e]={}),(i||this.configuration.getHeartbeatInterval())&&(this.heartbeatChannelGroups[e]={})}),this.subscriptionStatusAnnounced=!1,this.reconnect()}unsubscribe(e,t){let{channels:n,channelGroups:s}=e,r=new Set,i=new Set;null==n||n.forEach(e=>{e in this.channels&&(delete this.channels[e],i.add(e),e in this.heartbeatChannels&&delete this.heartbeatChannels[e]),e in this.presenceState&&delete this.presenceState[e],e in this.presenceChannels&&(delete this.presenceChannels[e],i.add(e))}),null==s||s.forEach(e=>{e in this.channelGroups&&(delete this.channelGroups[e],r.add(e),e in this.heartbeatChannelGroups&&delete this.heartbeatChannelGroups[e]),e in this.presenceState&&delete this.presenceState[e],e in this.presenceChannelGroups&&(delete this.presenceChannelGroups[e],r.add(e))}),0===i.size&&0===r.size||(!1!==this.configuration.suppressLeaveEvents||t||(s=Array.from(r),n=Array.from(i),this.leaveCall({channels:n,channelGroups:s},e=>{let t,{error:r}=e,i=I(e,["error"]);r&&(e.errorData&&"object"==typeof e.errorData&&"message"in e.errorData&&"string"==typeof e.errorData.message?t=e.errorData.message:"message"in e&&"string"==typeof e.message&&(t=e.message)),this.listenerManager.announceStatus(Object.assign(Object.assign({},i),{error:null!=t&&t,affectedChannels:n,affectedChannelGroups:s,currentTimetoken:this.currentTimetoken,lastTimetoken:this.lastTimetoken}
18))})),0===Object.keys(this.channels).length&&0===Object.keys(this.presenceChannels).length&&0===Object.keys(this.channelGroups).length&&0===Object.keys(this.presenceChannelGroups).length&&(this.lastTimetoken=0,this.currentTimetoken=0,this.storedTimetoken=null,this.region=null,this.reconnectionManager.stopPolling()),this.reconnect(!0))}unsubscribeAll(e){this.unsubscribe({channels:this.subscribedChannels,channelGroups:this.subscribedChannelGroups},e)}startSubscribeLoop(){this.stopSubscribeLoop();let e=[...Object.keys(this.channelGroups)],t=[...Object.keys(this.channels)];Object.keys(this.presenceChannelGroups).forEach(t=>e.push(`${t}-pnpres`)),Object.keys(this.presenceChannels).forEach(e=>t.push(`${e}-pnpres`)),0===t.length&&0===e.length||this.subscribeCall({channels:t,channelGroups:e,state:this.presenceState,heartbeat:this.configuration.getPresenceTimeout(),timetoken:this.currentTimetoken,region:null!==this.region?this.region:void 0,filterExpression:this.configuration.filterExpression},(e,t)=>{this.processSubscribeResponse(e,t)})}stopSubscribeLoop(){this._subscribeAbort&&(this._subscribeAbort(),this._subscribeAbort=null)}processSubscribeResponse(e,t){if(e.error){if("object"==typeof e.errorData&&"name"in e.errorData&&"AbortError"===e.errorData.name||e.category===D.PNCancelledCategory)return;return void(e.category===D.PNTimeoutCategory?this.startSubscribeLoop():e.category===D.PNNetworkIssuesCategory||e.category===D.PNMalformedResponseCategory?(this.disconnect(),e.error&&this.configuration.autoNetworkDetection&&this.isOnline&&(this.isOnline=!1,this.listenerManager.announceNetworkDown()),this.reconnectionManager.onReconnect(()=>{this.configuration.autoNetworkDetection&&!this.isOnline&&(this.isOnline=!0,this.listenerManager.announceNetworkUp()),this.reconnect(),this.subscriptionStatusAnnounced=!0;let t={category:D.PNReconnectedCategory,operation:e.operation,lastTimetoken:this.lastTimetoken,currentTimetoken:this.currentTimetoken};this.listenerManager.announceStatus(t)}),this.reconnectionManager.startPolling(),this.listenerManager.announceStatus(Object.assign(Object.assign({},e),{category:D.PNNetworkIssuesCategory}))):(e.category===D.PNBadRequestCategory&&this.stopHeartbeatTimer(),this.listenerManager.announceStatus(e)))}if(this.storedTimetoken?(this.currentTimetoken=this.storedTimetoken,this.storedTimetoken=null):(this.lastTimetoken=this.currentTimetoken,this.currentTimetoken=t.cursor.timetoken),!this.subscriptionStatusAnnounced){let t={category:D.PNConnectedCategory,operation:e.operation,affectedChannels:Array.from(this.pendingChannelSubscriptions),subscribedChannels:this.subscribedChannels,affectedChannelGroups:Array.from(this.pendingChannelGroupSubscriptions),lastTimetoken:this.lastTimetoken,currentTimetoken:this.currentTimetoken};this.subscriptionStatusAnnounced=!0,this.listenerManager.announceStatus(t),this.pendingChannelGroupSubscriptions.clear(),this.pendingChannelSubscriptions.clear()}let{messages:n}=t,{requestMessageCountThreshold:s,dedupeOnSubscribe:r}=this.configuration;s&&n.length>=s&&this.listenerManager.announceStatus({category:D.PNRequestMessageCountExceededCategory,operation:e.operation});try{n.forEach(e=>{if(r&&"message"in e.data&&"timetoken"in e.data){if(this.dedupingManager.isDuplicate(e.data))return;this.dedupingManager.addEntry(e.data)}this.eventEmitter.emitEvent(e)})}catch(t){let e={error:!0,category:D.PNUnknownCategory,errorData:t,statusCode:0};this.listenerManager.announceStatus(e)}this.region=t.cursor.region,this.startSubscribeLoop()}setState(e){let{state:t,channels:n,channelGroups:s}=e;null==n||n.forEach(e=>e in this.channels&&(this.presenceState[e]=t)),null==s||s.forEach(e=>e in this.channelGroups&&(this.presenceState[e]=t))}changePresence(e){let{connected:t,channels:n,channelGroups:s}=e;t?(null==n||n.forEach(e=>this.heartbeatChannels[e]={}),null==s||s.forEach(e=>this.heartbeatChannelGroups[e]={})):(null==n||n.forEach(e=>{e in this.heartbeatChannels&&delete this.heartbeatChannels[e]}),null==s||s.forEach(e=>{e in this.heartbeatChannelGroups&&delete this.heartbeatChannelGroups[e]}),!1===this.configuration.suppressLeaveEvents&&this.leaveCall({channels:n,channelGroups:s},e=>this.listenerManager.announceStatus(e))),this.reconnect()}startHeartbeatTimer(){this.stopHeartbeatTimer();let e=this.configuration.getHeartbeatInterval();e&&0!==e&&(this.sendHeartbeat(),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),1e3*e))}stopHeartbeatTimer(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}sendHeartbeat(){let e=Object.keys(this.heartbeatChannelGroups),t=Object.keys(this.heartbeatChannels);0===t.length&&0===e.length||this.heartbeatCall({channels:t,channelGroups:e,heartbeat:this.configuration.getPresenceTimeout(),state:this.presenceState},e=>{e.error&&this.configuration.announceFailedHeartbeats&&this.listenerManager.announceStatus(e),e.error&&this.configuration.autoNetworkDetection&&this.isOnline&&(this.isOnline=!1,this.disconnect(),this.listenerManager.announceNetworkDown(),this.reconnect()),!e.error&&this.configuration.announceSuccessfulHeartbeats&&this.listenerManager.announceStatus(e)})}}class eR{constructor(e,t,n){this._payload=e,this.setDefaultPayloadStructure(),this.title=t,this.body=n}get payload(){return this._payload}set title(e){this._title=e}set subtitle(e){this._subtitle=e}set body(e){this._body=e}set badge(e){this._badge=e}set sound(e){this._sound=e}setDefaultPayloadStructure(){}toObject(){return{}}}class ex extends eR{constructor(){super(...arguments),this._apnsPushType="apns",this._isSilent=!1}get payload(){return this._payload}set configurations(e){e&&e.length&&(this._configurations=e)}get notification(){return this.payload.aps}get title(){return this._title}set title(e){e&&e.length&&(this.payload.aps.alert.title=e,this._title=e)}get subtitle(){return this._subtitle}
18set subtitle(e){e&&e.length&&(this.payload.aps.alert.subtitle=e,this._subtitle=e)}get body(){return this._body}set body(e){e&&e.length&&(this.payload.aps.alert.body=e,this._body=e)}get badge(){return this._badge}set badge(e){null!=e&&(this.payload.aps.badge=e,this._badge=e)}get sound(){return this._sound}set sound(e){e&&e.length&&(this.payload.aps.sound=e,this._sound=e)}set silent(e){this._isSilent=e}setDefaultPayloadStructure(){this.payload.aps={alert:{}}}toObject(){let e=Object.assign({},this.payload),{aps:t}=e,{alert:n}=t;if(this._isSilent&&(t["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw ReferenceError("APNS2 configuration is missing");let t=[];this._configurations.forEach(e=>{t.push(this.objectFromAPNS2Configuration(e))}),t.length&&(e.pn_push=t)}return n&&Object.keys(n).length||delete t.alert,this._isSilent&&(delete t.alert,delete t.badge,delete t.sound,n={}),this._isSilent||n&&Object.keys(n).length?e:null}objectFromAPNS2Configuration(e){if(!e.targets||!e.targets.length)throw ReferenceError("At least one APNS2 target should be provided");let{collapseId:t,expirationDate:n}=e,s={auth_method:"token",targets:e.targets.map(e=>this.objectFromAPNSTarget(e)),version:"v2"};return t&&t.length&&(s.collapse_id=t),n&&(s.expiration=n.toISOString()),s}objectFromAPNSTarget(e){if(!e.topic||!e.topic.length)throw TypeError("Target 'topic' undefined.");let{topic:t,environment:n="development",excludedDevices:s=[]}=e,r={topic:t,environment:n};return s.length&&(r.excluded_devices=s),r}}class eU extends eR{get payload(){return this._payload}get notification(){return this.payload.notification}get data(){return this.payload.data}get title(){return this._title}set title(e){e&&e.length&&(this.payload.notification.title=e,this._title=e)}get body(){return this._body}set body(e){e&&e.length&&(this.payload.notification.body=e,this._body=e)}get sound(){return this._sound}set sound(e){e&&e.length&&(this.payload.notification.sound=e,this._sound=e)}get icon(){return this._icon}set icon(e){e&&e.length&&(this.payload.notification.icon=e,this._icon=e)}get tag(){return this._tag}set tag(e){e&&e.length&&(this.payload.notification.tag=e,this._tag=e)}set silent(e){this._isSilent=e}setDefaultPayloadStructure(){this.payload.notification={},this.payload.data={}}toObject(){let e=Object.assign({},this.payload.data),t=null,n={};if(Object.keys(this.payload).length>2){let t=I(this.payload,["notification","data"]);e=Object.assign(Object.assign({},e),t)}return this._isSilent?e.notification=this.payload.notification:t=this.payload.notification,Object.keys(e).length&&(n.data=e),t&&Object.keys(t).length&&(n.notification=t),Object.keys(n).length?n:null}}class eD{constructor(e,t){this._payload={apns:{},fcm:{}},this._title=e,this._body=t,this.apns=new ex(this._payload.apns,e,t),this.fcm=new eU(this._payload.fcm,e,t)}set debugging(e){this._debugging=e}get title(){return this._title}get subtitle(){return this._subtitle}set subtitle(e){this._subtitle=e,this.apns.subtitle=e,this.fcm.subtitle=e}get body(){return this._body}get badge(){return this._badge}set badge(e){this._badge=e,this.apns.badge=e,this.fcm.badge=e}get sound(){return this._sound}set sound(e){this._sound=e,this.apns.sound=e,this.fcm.sound=e}buildPayload(e){let t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";let n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("fcm")){let e=this.fcm.toObject();e&&Object.keys(e).length&&(t.pn_gcm=e)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t}}class eq{constructor(e){this.params=e,this.requestIdentifier=eE(),this._cancellationController=null}get cancellationController(){return this._cancellationController}set cancellationController(e){this._cancellationController=e}abort(e){this&&this.cancellationController&&this.cancellationController.abort(e)}operation(){throw Error("Should be implemented by subclass.")}validate(){}parse(e){return F(this,void 0,void 0,function*(){return this.deserializeResponse(e)})}request(){var e,t,n,s;let r={method:null!=(t=null==(e=this.params)?void 0:e.method)?t:C.GET,path:this.path,queryParameters:this.queryParameters,cancellable:null!=(s=null==(n=this.params)?void 0:n.cancellable)&&s,timeout:10,identifier:this.requestIdentifier},i=this.headers;if(i&&(r.headers=i),r.method===C.POST||r.method===C.PATCH){let[e,t]=[this.body,this.formData];t&&(r.formData=t),e&&(r.body=e)}return r}get headers(){}get path(){throw Error("`path` getter should be implemented by subclass.")}get queryParameters(){return{}}get formData(){}get body(){}deserializeResponse(e){let t,n=eq.decoder.decode(e.body),s=e.headers["content-type"];if(!s||-1===s.indexOf("javascript")&&-1===s.indexOf("json"))throw new q("Service response error, check status for details",$(n,e.status));try{t=JSON.parse(n)}catch(t){throw console.error("Error parsing JSON response:",t),new q("Service response error, check status for details",$(n,e.status))}if("status"in t&&"number"==typeof t.status&&t.status>=400)throw eb.create(e);return t}}eq.decoder=new TextDecoder,(k=w||(w={})).PNPublishOperation="PNPublishOperation",k.PNSignalOperation="PNSignalOperation",k.PNSubscribeOperation="PNSubscribeOperation",k.PNUnsubscribeOperation="PNUnsubscribeOperation",k.PNWhereNowOperation="PNWhereNowOperation",k.PNHereNowOperation="PNHereNowOperation",k.PNGlobalHereNowOperation="PNGlobalHereNowOperation",k.PNSetStateOperation="PNSetStateOperation",k.PNGetStateOperation="PNGetStateOperation",k.PNHeartbeatOperation="PNHeartbeatOperation",k.PNAddMessageActionOperation="PNAddActionOperation",k.PNRemoveMessageActionOperation="PNRemoveMessageActionOperation",k.PNGetMessageActionsOperation="PNGetMessageActionsOperation",k.PNTimeOperation="PNTimeOperation",k.PNHistoryOperation="PNHistoryOperation",k.PNDeleteMessagesOperation="PNDeleteMessagesOperation",k.PNFetchMessagesOperation="PNFetchMessagesOperation",k.PNMessageCounts="PNMessageCountsOperation",k.PNGetAllUUIDMetadataOperation="PNGetAllUUIDMetadataOperation",k.PNGetUUIDMetadataOperation="PNGetUUIDMetadataOperation",k.PNSetUUIDMetadataOperation="PNSetUUIDMetadataOperation",k.PNRemoveUUIDMetadataOperation="PNRemoveUUIDMetadataOperation",k.PNGetAllChannelMetadataOperation="PNGetAllChannelMetadataOperation",k.PNGetChannelMetadataOperation="PNGetChannelMetadataOperation",k.PNSetChannelMetadataOperation="PNSetChannelMetadataOperation",k.PNRemoveChannelMetadataOperation="PNRemoveChannelMetadataOperation",k.PNGetMembersOperation="PNGetMembersOperation",k.PNSetMembersOperation="PNSetMembersOperation",k.PNGetMembershipsOperation="PNGetMembershipsOperation",k.PNSetMembershipsOperation="PNSetMembershipsOperation",k.PNListFilesOperation="PNListFilesOperation",k.PNGenerateUploadUrlOperation="PNGenerateUploadUrlOperation",k.PNPublishFileOperation="PNPublishFileOperation",k.PNPublishFileMessageOperation="PNPublishFileMessageOperation",k.PNGetFileUrlOperation="PNGetFileUrlOperation",k.PNDownloadFileOperation="PNDownloadFileOperation",k.PNDeleteFileOperation="PNDeleteFileOperation",k.PNAddPushNotificationEnabledChannelsOperation="PNAddPushNotificationEnabledChannelsOperation",k.PNRemovePushNotificationEnabledChannelsOperation="PNRemovePushNotificationEnabledChannelsOperation",k.PNPushNotificationEnabledChannelsOperation="PNPushNotificationEnabledChannelsOperation",k.PNRemoveAllPushNotificationsOperation="PNRemoveAllPushNotificationsOperation",k.PNChannelGroupsOperation="PNChannelGroupsOperation",k.PNRemoveGroupOperation="PNRemoveGroupOperation",k.PNChannelsForGroupOperation="PNChannelsForGroupOperation",k.PNAddChannelsToGroupOperation="PNAddChannelsToGroupOperation",k.PNRemoveChannelsFromGroupOperation="PNRemoveChannelsFromGroupOperation",k.PNAccessManagerGrant="PNAccessManagerGrant",k.PNAccessManagerGrantToken="PNAccessManagerGrantToken",k.PNAccessManagerAudit="PNAccessManagerAudit",k.PNAccessManagerRevokeToken="PNAccessManagerRevokeToken",k.PNHandshakeOperation="PNHandshakeOperation",k.PNReceiveMessagesOperation="PNReceiveMessagesOperation";var eG=w;(E=N||(N={}))[E.Presence=-2]="Presence",E[E.Message=-1]="Message",E[E.Signal=1]="Signal",E[E.AppContext=2]="AppContext",E[E.MessageAction=3]="MessageAction",E[E.Files=4]="Files";class eK extends eq{constructor(e){var t,n,s;super({cancellable:!0}),this.parameters=e,null!=(t=this.parameters).withPresence||(t.withPresence=!1),null!=(n=this.parameters).channelGroups||(n.channelGroups=[]),null!=(s=this.parameters).channels||(s.channels=[])}operation(){return eG.PNSubscribeOperation}validate(){let{keySet:{subscribeKey:e},channels:t,channelGroups:n}=this.parameters;
18return e?t||n?void 0:"`channels` and `channelGroups` both should not be empty":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){let t,n;try{n=eq.decoder.decode(e.body),t=JSON.parse(n)}catch(e){console.error("Error parsing JSON response:",e)}if(!t)throw new q("Service response error, check status for details",$(n,e.status));let s=t.m.filter(e=>{let t=void 0===e.b?e.c:e.b;return this.parameters.channels&&this.parameters.channels.includes(t)||this.parameters.channelGroups&&this.parameters.channelGroups.includes(t)}).map(e=>{let{e:t}=e;return null!=t||(t=e.c.endsWith("-pnpres")?N.Presence:N.Message),t!=N.Signal&&"string"==typeof e.d?t==N.Message?{type:N.Message,data:this.messageFromEnvelope(e)}:{type:N.Files,data:this.fileFromEnvelope(e)}:t==N.Message?{type:N.Message,data:this.messageFromEnvelope(e)}:t===N.Presence?{type:N.Presence,data:this.presenceEventFromEnvelope(e)}:t==N.Signal?{type:N.Signal,data:this.signalFromEnvelope(e)}:t===N.AppContext?{type:N.AppContext,data:this.appContextFromEnvelope(e)}:t===N.MessageAction?{type:N.MessageAction,data:this.messageActionFromEnvelope(e)}:{type:N.Files,data:this.fileFromEnvelope(e)}});return{cursor:{timetoken:t.t.t,region:t.t.r},messages:s}})}get headers(){return{accept:"text/javascript"}}presenceEventFromEnvelope(e){var t;let{d:n}=e,[s,r]=this.subscriptionChannelFromEnvelope(e),i=s.replace("-pnpres",""),a=null!==r?i:null,o=null!==r?r:i;return"string"!=typeof n&&("data"in n?(n.state=n.data,delete n.data):"action"in n&&"interval"===n.action&&(n.hereNowRefresh=null!=(t=n.here_now_refresh)&&t,delete n.here_now_refresh)),Object.assign({channel:i,subscription:r,actualChannel:a,subscribedChannel:o,timetoken:e.p.t},n)}messageFromEnvelope(e){let[t,n]=this.subscriptionChannelFromEnvelope(e),[s,r]=this.decryptedData(e.d),i={channel:t,subscription:n,actualChannel:null!==n?t:null,subscribedChannel:null!==n?n:t,timetoken:e.p.t,publisher:e.i,message:s};return e.u&&(i.userMetadata=e.u),e.cmt&&(i.customMessageType=e.cmt),r&&(i.error=r),i}signalFromEnvelope(e){let[t,n]=this.subscriptionChannelFromEnvelope(e),s={channel:t,subscription:n,timetoken:e.p.t,publisher:e.i,message:e.d};return e.u&&(s.userMetadata=e.u),e.cmt&&(s.customMessageType=e.cmt),s}messageActionFromEnvelope(e){let[t,n]=this.subscriptionChannelFromEnvelope(e),s=e.d;return{channel:t,subscription:n,timetoken:e.p.t,publisher:e.i,event:s.event,data:Object.assign(Object.assign({},s.data),{uuid:e.i})}}appContextFromEnvelope(e){let[t,n]=this.subscriptionChannelFromEnvelope(e),s=e.d;return{channel:t,subscription:n,timetoken:e.p.t,message:s}}fileFromEnvelope(e){let[t,n]=this.subscriptionChannelFromEnvelope(e),[s,r]=this.decryptedData(e.d),i=r,a={channel:t,subscription:n,timetoken:e.p.t,publisher:e.i};return e.u&&(a.userMetadata=e.u),s?"string"==typeof s?null!=i||(i="Unexpected file information payload data type."):(a.message=s.message,s.file&&(a.file={id:s.file.id,name:s.file.name,url:this.parameters.getFileUrl({id:s.file.id,name:s.file.name,channel:t})})):null!=i||(i="File information payload is missing."),e.cmt&&(a.customMessageType=e.cmt),i&&(a.error=i),a}subscriptionChannelFromEnvelope(e){return[e.c,void 0===e.b?e.c:e.b]}decryptedData(e){let t,n;if(!this.parameters.crypto||"string"!=typeof e)return[e,void 0];try{let n=this.parameters.crypto.decrypt(e);t=n instanceof ArrayBuffer?JSON.parse(e$.decoder.decode(n)):n}catch(e){t=null,n=`Error while decrypting message content: ${e.message}`}return[null!=t?t:e,n]}}class e$ extends eK{get path(){var e;let{keySet:{subscribeKey:t},channels:n}=this.parameters;return`/v2/subscribe/${t}/${ew(null!=(e=null==n?void 0:n.sort())?e:[],",")}/0`}get queryParameters(){let{channelGroups:e,filterExpression:t,heartbeat:n,state:s,timetoken:r,region:i}=this.parameters,a={};return e&&e.length>0&&(a["channel-group"]=e.sort().join(",")),t&&t.length>0&&(a["filter-expr"]=t),n&&(a.heartbeat=n),s&&Object.keys(s).length>0&&(a.state=JSON.stringify(s)),void 0!==r&&"string"==typeof r?r.length>0&&"0"!==r&&(a.tt=r):void 0!==r&&r>0&&(a.tt=r),i&&(a.tr=i),a}}class eL{constructor(e){this.listenerManager=e,this.channelListenerMap=new Map,this.groupListenerMap=new Map}emitEvent(e){var t;if(e.type===N.Message)this.listenerManager.announceMessage(e.data),this.announce("message",e.data,e.data.channel,e.data.subscription);else if(e.type===N.Signal)this.listenerManager.announceSignal(e.data),this.announce("signal",e.data,e.data.channel,e.data.subscription);else if(e.type===N.Presence)this.listenerManager.announcePresence(e.data),this.announce("presence",e.data,null!=(t=e.data.subscription)?t:e.data.channel,e.data.subscription);else if(e.type===N.AppContext){let{data:t}=e,{message:n}=t;if(this.listenerManager.announceObjects(t),this.announce("objects",t,t.channel,t.subscription),"uuid"===n.type){let{message:e,channel:s}=t,r=I(t,["message","channel"]),{event:i,type:a}=n,o=I(n,["event","type"]),u=Object.assign(Object.assign({},r),{spaceId:s,message:Object.assign(Object.assign({},o),{event:"set"===i?"updated":"removed",type:"user"})});this.listenerManager.announceUser(u),this.announce("user",u,u.spaceId,u.subscription)}else if("channel"===n.type){let{message:e,channel:s}=t,r=I(t,["message","channel"]),{event:i,type:a}=n,o=I(n,["event","type"]),u=Object.assign(Object.assign({},r),{spaceId:s,message:Object.assign(Object.assign({},o),{event:"set"===i?"updated":"removed",type:"space"})});this.listenerManager.announceSpace(u),this.announce("space",u,u.spaceId,u.subscription)}else if("membership"===n.type){let{message:e,channel:s}=t,r=I(t,["message","channel"]),{event:i,data:a}=n,o=I(n,["event","data"]),{uuid:u,channel:l}=a,c=I(a,["uuid","channel"]),h=Object.assign(Object.assign({},r),{spaceId:s,message:Object.assign(Object.assign({},o),{event:"set"===i?"updated":"removed",data:Object.assign(Object.assign({},c),{user:u,space:l})})});this.listenerManager.announceMembership(h),this.announce("membership",h,h.spaceId,h.subscription)}}else e.type===N.MessageAction?(this.listenerManager.announceMessageAction(e.data),this.announce("messageAction",e.data,e.data.channel,e.data.subscription)):e.type===N.Files&&(this.listenerManager.announceFile(e.data),this.announce("file",e.data,e.data.channel,e.data.subscription))}addListener(e,t,n){t&&n?(null==t||t.forEach(t=>{if(this.channelListenerMap.has(t)){let n=this.channelListenerMap.get(t);n.includes(e)||n.push(e)}else this.channelListenerMap.set(t,[e])}
18),null==n||n.forEach(t=>{if(this.groupListenerMap.has(t)){let n=this.groupListenerMap.get(t);n.includes(e)||n.push(e)}else this.groupListenerMap.set(t,[e])})):this.listenerManager.addListener(e)}removeListener(e,t,n){t&&n?(null==t||t.forEach(t=>{this.channelListenerMap.has(t)&&this.channelListenerMap.set(t,this.channelListenerMap.get(t).filter(t=>t!==e))}),null==n||n.forEach(t=>{this.groupListenerMap.has(t)&&this.groupListenerMap.set(t,this.groupListenerMap.get(t).filter(t=>t!==e))})):this.listenerManager.removeListener(e)}removeAllListeners(){this.listenerManager.removeAllListeners(),this.channelListenerMap.clear(),this.groupListenerMap.clear()}announce(e,t,n,s){t&&this.channelListenerMap.has(n)&&this.channelListenerMap.get(n).forEach(n=>{let s=n[e];s&&s(t)}),s&&this.groupListenerMap.has(s)&&this.groupListenerMap.get(s).forEach(n=>{let s=n[e];s&&s(t)})}}class eB{constructor(e=!1){this.sync=e,this.listeners=new Set}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(e){let t=()=>{this.listeners.forEach(t=>{t(e)})};this.sync?t():setTimeout(t,0)}}class eH{transition(e,t){var n;if(this.transitionMap.has(t.type))return null==(n=this.transitionMap.get(t.type))?void 0:n(e,t)}constructor(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}on(e,t){return this.transitionMap.set(e,t),this}with(e,t){return[this,e,null!=t?t:[]]}onEnter(e){return this.enterEffects.push(e),this}onExit(e){return this.exitEffects.push(e),this}}class eV extends eB{describe(e){return new eH(e)}start(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})}transition(e){if(!this.currentState)throw Error("Start the engine first");this.notify({type:"eventReceived",event:e});let t=this.currentState.transition(this.currentContext,e);if(t){let[n,s,r]=t;for(let e of this.currentState.exitEffects)this.notify({type:"invocationDispatched",invocation:e(this.currentContext)});let i=this.currentState;this.currentState=n;let a=this.currentContext;for(let t of(this.currentContext=s,this.notify({type:"transitionDone",fromState:i,fromContext:a,toState:n,toContext:s,event:e}),r))this.notify({type:"invocationDispatched",invocation:t});for(let e of this.currentState.enterEffects)this.notify({type:"invocationDispatched",invocation:e(this.currentContext)})}}}class eW{constructor(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}on(e,t){this.handlers.set(e,t)}dispatch(e){if("CANCEL"===e.type){if(this.instances.has(e.payload)){let t=this.instances.get(e.payload);null==t||t.cancel(),this.instances.delete(e.payload)}return}let t=this.handlers.get(e.type);if(!t)throw Error(`Unhandled invocation '${e.type}'`);let n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}dispose(){for(let[e,t]of this.instances.entries())t.cancel(),this.instances.delete(e)}}function ez(e,t){let n=function(...n){return{type:e,payload:null==t?void 0:t(...n)}};return n.type=e,n}function eJ(e,t){let n=(...n)=>({type:e,payload:t(...n),managed:!1});return n.type=e,n}function eX(e,t){let n=(...n)=>({type:e,payload:t(...n),managed:!0});return n.type=e,n.cancel={type:"CANCEL",payload:e,managed:!1},n}class eQ extends Error{constructor(){super("The operation was aborted."),this.name="AbortError",Object.setPrototypeOf(this,new.target.prototype)}}class eY extends eB{constructor(){super(...arguments),this._aborted=!1}get aborted(){return this._aborted}throwIfAborted(){if(this._aborted)throw new eQ}abort(){this._aborted=!0,this.notify(new eQ)}}class eZ{constructor(e,t){this.payload=e,this.dependencies=t}}class e0 extends eZ{constructor(e,t,n){super(e,t),this.asyncFunction=n,this.abortSignal=new eY}start(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies).catch(e=>{})}cancel(){this.abortSignal.abort()}}let e1=e=>(t,n)=>new e0(t,n,e),e2=ez("RECONNECT",()=>({})),e4=ez("DISCONNECT",()=>({})),e5=ez("JOINED",(e,t)=>({channels:e,groups:t})),e6=ez("LEFT",(e,t)=>({channels:e,groups:t})),e3=ez("LEFT_ALL",()=>({})),e8=ez("HEARTBEAT_SUCCESS",e=>({statusCode:e})),e9=ez("HEARTBEAT_FAILURE",e=>e),e7=ez("HEARTBEAT_GIVEUP",()=>({})),te=ez("TIMES_UP",()=>({})),tt=eJ("HEARTBEAT",(e,t)=>({channels:e,groups:t})),tn=eJ("LEAVE",(e,t)=>({channels:e,groups:t})),ts=eJ("EMIT_STATUS",e=>e),tr=eX("WAIT",()=>({})),ti=eX("DELAYED_HEARTBEAT",e=>e);class ta extends eW{constructor(e,t){super(t),this.on(tt.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{heartbeat:s,presenceState:r,config:i}){try{yield s(Object.assign(Object.assign({channels:t.channels,channelGroups:t.groups},i.maintainPresenceState&&{state:r}),{heartbeat:i.presenceTimeout})),e.transition(e8(200))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;return e.transition(e9(t))}}}))),this.on(tn.type,e1((e,t,n)=>F(this,[e,t,n],void 0,function*(e,t,{leave:n,config:s}){if(!s.suppressLeaveEvents)try{n({channels:e.channels,channelGroups:e.groups})}catch(e){}}))),this.on(tr.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{heartbeatDelay:s}){return n.throwIfAborted(),yield s(),n.throwIfAborted(),e.transition(te())}))),this.on(ti.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{heartbeat:s,retryDelay:r,presenceState:i,config:a}){if(!a.retryConfiguration||!a.retryConfiguration.shouldRetry(t.reason,t.attempts))return e.transition(e7());n.throwIfAborted(),yield r(a.retryConfiguration.getDelay(t.attempts,t.reason)),n.throwIfAborted();try{return yield s(Object.assign(Object.assign({channels:t.channels,channelGroups:t.groups},a.maintainPresenceState&&{state:i}),{heartbeat:a.presenceTimeout})),e.transition(e8(200))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;return e.transition(e9(t))}}}))),this.on(ts.type,e1((e,t,n)=>F(this,[e,t,n],void 0,function*(e,t,{emitStatus:n,config:s}){var r;s.announceFailedHeartbeats&&!0===(null==(r=null==e?void 0:e.status)?void 0:r.error)?n(e.status):s.announceSuccessfulHeartbeats&&200===e.statusCode&&n(Object.assign(Object.assign({},e),{operation:eG.PNHeartbeatOperation,error:!1}))})))}}let to=new eH("HEARTBEAT_STOPPED");to.on(e5.type,(e,t)=>to.with({channels:[...e.channels,...t.payload.channels],groups:[...e.groups,...t.payload.groups]})),to.on(e6.type,(e,t)=>to.with({channels:e.channels.filter(e=>!t.payload.channels.includes(e)),groups:e.groups.filter(e=>!t.payload.groups.includes(e))})),to.on(e2.type,(e,t)=>th.with({channels:e.channels,groups:e.groups})),to.on(e3.type,(e,t)=>tp.with(void 0));let tu=new eH("HEARTBEAT_COOLDOWN");tu.onEnter(()=>tr()),tu.onExit(()=>tr.cancel),tu.on(te.type,(e,t)=>th.with({channels:e.channels,groups:e.groups})),tu.on(e5.type,(e,t)=>th.with({channels:[...e.channels,...t.payload.channels],groups:[...e.groups,...t.payload.groups]})),tu.on(e6.type,(e,t)=>th.with({channels:e.channels.filter(e=>!t.payload.channels.includes(e)),groups:e.groups.filter(e=>!t.payload.groups.includes(e))},[tn(t.payload.channels,t.payload.groups)])),tu.on(e4.type,e=>to.with({channels:e.channels,groups:e.groups},[tn(e.channels,e.groups)])),tu.on(e3.type,(e,t)=>tp.with(void 0,[tn(e.channels,e.groups)]));let tl=new eH("HEARTBEAT_FAILED");tl.on(e5.type,(e,t)=>th.with({channels:[...e.channels,...t.payload.channels],groups:[...e.groups,...t.payload.groups]})),tl.on(e6.type,(e,t)=>th.with({channels:e.channels.filter(e=>!t.payload.channels.includes(e)),groups:e.groups.filter(e=>!t.payload.groups.includes(e))},[tn(t.payload.channels,t.payload.groups)])),tl.on(e2.type,(e,t)=>th.with({channels:e.channels,groups:e.groups})),tl.on(e4.type,(e,t)=>to.with({channels:e.channels,groups:e.groups},[tn(e.channels,e.groups)])),tl.on(e3.type,(e,t)=>tp.with(void 0,[tn(e.channels,e.groups)]));let tc=new eH("HEARBEAT_RECONNECTING");tc.onEnter(e=>ti(e)),tc.onExit(()=>ti.cancel),tc.on(e5.type,(e,t)=>th.with({channels:[...e.channels,...t.payload.channels],groups:[...e.groups,...t.payload.groups]})),tc.on(e6.type,(e,t)=>th.with({channels:e.channels.filter(e=>!t.payload.channels.includes(e)),groups:e.groups.filter(e=>!t.payload.groups.includes(e))},[tn(t.payload.channels,t.payload.groups)])),tc.on(e4.type,(e,t)=>{to.with({channels:e.channels,groups:e.groups},[tn(e.channels,e.groups)])}),tc.on(e8.type,(e,t)=>tu.with({channels:e.channels,groups:e.groups})),tc.on(e9.type,(e,t)=>tc.with(Object.assign(Object.assign({},e),{attempts:e.attempts+1,reason:t.payload}))),tc.on(e7.type,(e,t)=>tl.with({channels:e.channels,groups:e.groups})),tc.on(e3.type,(e,t)=>tp.with(void 0,[tn(e.channels,e.groups)]));let th=new eH("HEARTBEATING");th.onEnter(e=>tt(e.channels,e.groups)),th.on(e8.type,(e,t)=>tu.with({channels:e.channels,groups:e.groups})),th.on(e5.type,(e,t)=>th.with({channels:[...e.channels,...t.payload.channels],groups:[...e.groups,...t.payload.groups]})),th.on(e6.type,(e,t)=>th.with({channels:e.channels.filter(e=>!t.payload.channels.includes(e)),groups:e.groups.filter(e=>!t.payload.groups.includes(e))},[tn(t.payload.channels,t.payload.groups)])),th.on(e9.type,(e,t)=>tc.with(Object.assign(Object.assign({},e),{attempts:0,reason:t.payload}))),th.on(e4.type,e=>to.with({channels:e.channels,groups:e.groups},[tn(e.channels,e.groups)])),th.on(e3.type,(e,t)=>tp.with(void 0,[tn(e.channels,e.groups)]));let tp=new eH("HEARTBEAT_INACTIVE");tp.on(e5.type,(e,t)=>th.with({channels:t.payload.channels,groups:t.payload.groups}));class td{get _engine(){return this.engine}constructor(e){this.dependencies=e,this.engine=new eV,this.channels=[],this.groups=[],this.dispatcher=new ta(this.engine,e),this._unsubscribeEngine=this.engine.subscribe(e=>{"invocationDispatched"===e.type&&this.dispatcher.dispatch(e.invocation)}),this.engine.start(tp,void 0)}join({channels:e,groups:t}){this.channels=[...this.channels,...null!=e?e:[]],this.groups=[...this.groups,...null!=t?t:[]],this.engine.transition(e5(this.channels.slice(0),this.groups.slice(0)))}leave({channels:e,groups:t}
18){this.dependencies.presenceState&&(null==e||e.forEach(e=>delete this.dependencies.presenceState[e]),null==t||t.forEach(e=>delete this.dependencies.presenceState[e])),this.engine.transition(e6(null!=e?e:[],null!=t?t:[]))}leaveAll(){this.engine.transition(e3())}dispose(){this._unsubscribeEngine(),this.dispatcher.dispose()}}class tg{static LinearRetryPolicy(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry(e,t){var n;return 403!==(null==(n=null==e?void 0:e.status)?void 0:n.statusCode)&&this.maximumRetry>t},getDelay(e,t){var n;return 1e3*((null!=(n=t.retryAfter)?n:this.delay)+Math.random())},getGiveupReason(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null==(n=null==e?void 0:e.status)?void 0:n.statusCode)?"forbidden operation.":"unknown error"},validate(){if(this.maximumRetry>10)throw Error("Maximum retry for linear retry policy can not be more than 10")}}}static ExponentialRetryPolicy(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry(e,t){var n;return 403!==(null==(n=null==e?void 0:e.status)?void 0:n.statusCode)&&this.maximumRetry>t},getDelay(e,t){var n;return 1e3*((null!=(n=t.retryAfter)?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason(e,t){var n;return this.maximumRetry<=t?"retry attempts exhausted.":403===(null==(n=null==e?void 0:e.status)?void 0:n.statusCode)?"forbidden operation.":"unknown error"},validate(){if(this.minimumDelay<2)throw Error("Minimum delay can not be set less than 2 seconds for retry");if(this.maximumDelay)throw Error("Maximum delay can not be set more than 150 seconds for retry");if(this.maximumRetry>6)throw Error("Maximum retry for exponential retry policy can not be more than 6")}}}}let ty=eX("HANDSHAKE",(e,t)=>({channels:e,groups:t})),tf=eX("RECEIVE_MESSAGES",(e,t,n)=>({channels:e,groups:t,cursor:n})),tm=eJ("EMIT_MESSAGES",e=>e),tb=eJ("EMIT_STATUS",e=>e),tv=eX("RECEIVE_RECONNECT",e=>e),tS=eX("HANDSHAKE_RECONNECT",e=>e),tk=ez("SUBSCRIPTION_CHANGED",(e,t)=>({channels:e,groups:t})),tE=ez("SUBSCRIPTION_RESTORED",(e,t,n,s)=>({channels:e,groups:t,cursor:{timetoken:n,region:null!=s?s:0}})),tO=ez("HANDSHAKE_SUCCESS",e=>e),tC=ez("HANDSHAKE_FAILURE",e=>e),tw=ez("HANDSHAKE_RECONNECT_SUCCESS",e=>({cursor:e})),tN=ez("HANDSHAKE_RECONNECT_FAILURE",e=>e),tP=ez("HANDSHAKE_RECONNECT_GIVEUP",e=>e),tM=ez("RECEIVE_SUCCESS",(e,t)=>({cursor:e,events:t})),t_=ez("RECEIVE_FAILURE",e=>e),tj=ez("RECEIVE_RECONNECT_SUCCESS",(e,t)=>({cursor:e,events:t})),tA=ez("RECEIVE_RECONNECT_FAILURE",e=>e),tI=ez("RECEIVING_RECONNECT_GIVEUP",e=>e),tF=ez("DISCONNECT",()=>({})),tT=ez("RECONNECT",(e,t)=>({cursor:{timetoken:null!=e?e:"",region:null!=t?t:0}})),tR=ez("UNSUBSCRIBE_ALL",()=>({}));class tx extends eW{constructor(e,t){super(t),this.on(ty.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{handshake:s,presenceState:r,config:i}){n.throwIfAborted();try{let a=yield s(Object.assign({abortSignal:n,channels:t.channels,channelGroups:t.groups,filterExpression:i.filterExpression},i.maintainPresenceState&&{state:r}));return e.transition(tO(a))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;return e.transition(tC(t))}}}))),this.on(tf.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{receiveMessages:s,config:r}){n.throwIfAborted();try{let i=yield s({abortSignal:n,channels:t.channels,channelGroups:t.groups,timetoken:t.cursor.timetoken,region:t.cursor.region,filterExpression:r.filterExpression});e.transition(tM(i.cursor,i.messages))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;if(!n.aborted)return e.transition(t_(t))}}}))),this.on(tm.type,e1((e,t,n)=>F(this,[e,t,n],void 0,function*(e,t,{emitMessages:n}){e.length>0&&n(e)}))),this.on(tb.type,e1((e,t,n)=>F(this,[e,t,n],void 0,function*(e,t,{emitStatus:n}){n(e)}))),this.on(tv.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{receiveMessages:s,delay:r,config:i}){if(!i.retryConfiguration||!i.retryConfiguration.shouldRetry(t.reason,t.attempts))return e.transition(tI(new q(i.retryConfiguration?i.retryConfiguration.getGiveupReason(t.reason,t.attempts):"Unable to complete subscribe messages receive.")));n.throwIfAborted(),yield r(i.retryConfiguration.getDelay(t.attempts,t.reason)),n.throwIfAborted();try{let r=yield s({abortSignal:n,channels:t.channels,channelGroups:t.groups,timetoken:t.cursor.timetoken,region:t.cursor.region,filterExpression:i.filterExpression});return e.transition(tj(r.cursor,r.messages))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;return e.transition(tA(t))}}}))),this.on(tS.type,e1((t,n,s)=>F(this,[t,n,s],void 0,function*(t,n,{handshake:s,delay:r,presenceState:i,config:a}){if(!a.retryConfiguration||!a.retryConfiguration.shouldRetry(t.reason,t.attempts))return e.transition(tP(ne
18w q(a.retryConfiguration?a.retryConfiguration.getGiveupReason(t.reason,t.attempts):"Unable to complete subscribe handshake")));n.throwIfAborted(),yield r(a.retryConfiguration.getDelay(t.attempts,t.reason)),n.throwIfAborted();try{let r=yield s(Object.assign({abortSignal:n,channels:t.channels,channelGroups:t.groups,filterExpression:a.filterExpression},a.maintainPresenceState&&{state:i}));return e.transition(tw(r))}catch(t){if(t instanceof q){if(t.status&&t.status.category==D.PNCancelledCategory)return;return e.transition(tN(t))}}})))}}let tU=new eH("HANDSHAKE_FAILED");tU.on(tk.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tU.on(tT.type,(e,t)=>tB.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})),tU.on(tE.type,(e,t)=>{var n,s;return tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:null!=(s=null==(n=null==e?void 0:e.cursor)?void 0:n.region)?s:0}})}),tU.on(tR.type,e=>tH.with());let tD=new eH("HANDSHAKE_STOPPED");tD.on(tk.type,(e,t)=>tD.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tD.on(tT.type,(e,t)=>tB.with(Object.assign(Object.assign({},e),{cursor:t.payload.cursor||e.cursor}))),tD.on(tE.type,(e,t)=>{var n;return tD.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(n=null==e?void 0:e.cursor)?void 0:n.region)||0}})}),tD.on(tR.type,e=>tH.with());let tq=new eH("RECEIVE_FAILED");tq.on(tT.type,(e,t)=>{var n;return tB.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(n=t.payload.cursor)?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),tq.on(tk.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tq.on(tE.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})),tq.on(tR.type,e=>tH.with(void 0));let tG=new eH("RECEIVE_STOPPED");tG.on(tk.type,(e,t)=>tG.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tG.on(tE.type,(e,t)=>tG.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})),tG.on(tT.type,(e,t)=>{var n;return tB.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(n=t.payload.cursor)?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),tG.on(tR.type,()=>tH.with(void 0));let tK=new eH("RECEIVE_RECONNECTING");tK.onEnter(e=>tv(e)),tK.onExit(()=>tv.cancel),tK.on(tj.type,(e,t)=>t$.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tm(t.payload.events)])),tK.on(tA.type,(e,t)=>tK.with(Object.assign(Object.assign({},e),{attempts:e.attempts+1,reason:t.payload}))),tK.on(tI.type,(e,t)=>{var n;return tq.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[tb({category:D.PNDisconnectedUnexpectedlyCategory,error:null==(n=t.payload)?void 0:n.message})])}),tK.on(tF.type,e=>tG.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[tb({category:D.PNDisconnectedCategory})])),tK.on(tE.type,(e,t)=>t$.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})),tK.on(tk.type,(e,t)=>t$.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tK.on(tR.type,e=>tH.with(void 0,[tb({category:D.PNDisconnectedCategory})]));let t$=new eH("RECEIVING");t$.onEnter(e=>tf(e.channels,e.groups,e.cursor)),t$.onExit(()=>tf.cancel),t$.on(tM.type,(e,t)=>t$.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tm(t.payload.events)])),t$.on(tk.type,(e,t)=>0===t.payload.channels.length&&0===t.payload.groups.length?tH.with(void 0):t$.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})),t$.on(tE.type,(e,t)=>0===t.payload.channels.length&&0===t.payload.groups.length?tH.with(void 0):t$.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})),t$.on(t_.type,(e,t)=>tK.with(Object.assign(Object.assign({},e),{attempts:0,reason:t.payload}))),t$.on(tF.type,e=>tG.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[tb({category:D.PNDisconnectedCategory})])),t$.on(tR.type,e=>tH.with(void 0,[tb({category:D.PNDisconnectedCategory})]));let tL=new eH("HANDSHAKE_RECONNECTING");tL.onEnter(e=>tS(e)),tL.onExit(()=>tS.cancel),tL.on(tw.type,(e,t)=>{var n,s;
18let r={timetoken:(null==(n=e.cursor)?void 0:n.timetoken)?null==(s=e.cursor)?void 0:s.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return t$.with({channels:e.channels,groups:e.groups,cursor:r},[tb({category:D.PNConnectedCategory})])}),tL.on(tN.type,(e,t)=>tL.with(Object.assign(Object.assign({},e),{attempts:e.attempts+1,reason:t.payload}))),tL.on(tP.type,(e,t)=>{var n;return tU.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[tb({category:D.PNConnectionErrorCategory,error:null==(n=t.payload)?void 0:n.message})])}),tL.on(tF.type,e=>tD.with({channels:e.channels,groups:e.groups,cursor:e.cursor})),tL.on(tk.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tL.on(tE.type,(e,t)=>{var n,s;return tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null==(n=t.payload.cursor)?void 0:n.region)||(null==(s=null==e?void 0:e.cursor)?void 0:s.region)||0}})}),tL.on(tR.type,e=>tH.with(void 0));let tB=new eH("HANDSHAKING");tB.onEnter(e=>ty(e.channels,e.groups)),tB.onExit(()=>ty.cancel),tB.on(tk.type,(e,t)=>0===t.payload.channels.length&&0===t.payload.groups.length?tH.with(void 0):tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})),tB.on(tO.type,(e,t)=>{var n,s;return t$.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null==(n=null==e?void 0:e.cursor)?void 0:n.timetoken)?null==(s=null==e?void 0:e.cursor)?void 0:s.timetoken:t.payload.timetoken,region:t.payload.region}},[tb({category:D.PNConnectedCategory})])}),tB.on(tC.type,(e,t)=>tL.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})),tB.on(tF.type,e=>tD.with({channels:e.channels,groups:e.groups,cursor:e.cursor})),tB.on(tE.type,(e,t)=>{var n;return tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(n=null==e?void 0:e.cursor)?void 0:n.region)||0}})}),tB.on(tR.type,e=>tH.with());let tH=new eH("UNSUBSCRIBED");tH.on(tk.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups})),tH.on(tE.type,(e,t)=>tB.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor}));class tV{get _engine(){return this.engine}constructor(e){this.engine=new eV,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new tx(this.engine,e),this._unsubscribeEngine=this.engine.subscribe(e=>{"invocationDispatched"===e.type&&this.dispatcher.dispatch(e.invocation)}),this.engine.start(tH,void 0)}subscribe({channels:e,channelGroups:t,timetoken:n,withPresence:s}){this.channels=[...this.channels,...null!=e?e:[]],this.groups=[...this.groups,...null!=t?t:[]],s&&(this.channels.map(e=>this.channels.push(`${e}-pnpres`)),this.groups.map(e=>this.groups.push(`${e}-pnpres`))),n?this.engine.transition(tE(Array.from(new Set([...this.channels,...null!=e?e:[]])),Array.from(new Set([...this.groups,...null!=t?t:[]])),n)):this.engine.transition(tk(Array.from(new Set([...this.channels,...null!=e?e:[]])),Array.from(new Set([...this.groups,...null!=t?t:[]])))),this.dependencies.join&&this.dependencies.join({channels:Array.from(new Set(this.channels.filter(e=>!e.endsWith("-pnpres")))),groups:Array.from(new Set(this.groups.filter(e=>!e.endsWith("-pnpres"))))})}unsubscribe({channels:e=[],channelGroups:t=[]}){let n=eN(this.channels,[...e,...e.map(e=>`${e}-pnpres`)]),s=eN(this.groups,[...t,...t.map(e=>`${e}-pnpres`)]);if(new Set(this.channels).size!==new Set(n).size||new Set(this.groups).size!==new Set(s).size){let r=eP(this.channels,e),i=eP(this.groups,t);this.dependencies.presenceState&&(null==r||r.forEach(e=>delete this.dependencies.presenceState[e]),null==i||i.forEach(e=>delete this.dependencies.presenceState[e])),this.channels=n,this.groups=s,this.engine.transition(tk(Array.from(new Set(this.channels.slice(0))),Array.from(new Set(this.groups.slice(0))))),this.dependencies.leave&&this.dependencies.leave({channels:r.slice(0),groups:i.slice(0)})}}unsubscribeAll(){this.channels=[],this.groups=[],this.dependencies.presenceState&&Object.keys(this.dependencies.presenceState).forEach(e
18=>{delete this.dependencies.presenceState[e]}),this.engine.transition(tk(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()}reconnect({timetoken:e,region:t}){this.engine.transition(tT(e,t))}disconnect(){this.engine.transition(tF()),this.dependencies.leaveAll&&this.dependencies.leaveAll()}getSubscribedChannels(){return Array.from(new Set(this.channels.slice(0)))}getSubscribedChannelGroups(){return Array.from(new Set(this.groups.slice(0)))}dispose(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()}}class tW extends eq{constructor(e){var t;super({method:e.sendByPost?C.POST:C.GET}),this.parameters=e,null!=(t=this.parameters).sendByPost||(t.sendByPost=!1)}operation(){return eG.PNPublishOperation}validate(){let{message:e,channel:t,keySet:{publishKey:n}}=this.parameters;return t?e?n?void 0:"Missing 'publishKey'":"Missing 'message'":"Missing 'channel'"}parse(e){return F(this,void 0,void 0,function*(){return{timetoken:this.deserializeResponse(e)[2]}})}get path(){let{message:e,channel:t,keySet:n}=this.parameters,s=this.prepareMessagePayload(e);return`/publish/${n.publishKey}/${n.subscribeKey}/0/${eC(t)}/0${this.parameters.sendByPost?"":`/${eC(s)}`}`}get queryParameters(){let{customMessageType:e,meta:t,replicate:n,storeInHistory:s,ttl:r}=this.parameters,i={};return e&&(i.custom_message_type=e),void 0!==s&&(i.store=s?"1":"0"),void 0!==r&&(i.ttl=r),void 0===n||n||(i.norep="true"),t&&"object"==typeof t&&(i.meta=JSON.stringify(t)),i}get headers(){if(this.parameters.sendByPost)return{"Content-Type":"application/json"}}get body(){return this.prepareMessagePayload(this.parameters.message)}prepareMessagePayload(e){let{crypto:t}=this.parameters;if(!t)return JSON.stringify(e)||"";let n=t.encrypt(JSON.stringify(e));return JSON.stringify("string"==typeof n?n:U(n))}}class tz extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNSignalOperation}validate(){let{message:e,channel:t,keySet:{publishKey:n}}=this.parameters;return t?e?n?void 0:"Missing 'publishKey'":"Missing 'message'":"Missing 'channel'"}parse(e){return F(this,void 0,void 0,function*(){return{timetoken:this.deserializeResponse(e)[2]}})}get path(){let{keySet:{publishKey:e,subscribeKey:t},channel:n,message:s}=this.parameters,r=JSON.stringify(s);return`/signal/${e}/${t}/0/${eC(n)}/0/${eC(r)}`}get queryParameters(){let{customMessageType:e}=this.parameters,t={};return e&&(t.custom_message_type=e),t}}class tJ extends eK{operation(){return eG.PNReceiveMessagesOperation}validate(){return super.validate()||(this.parameters.timetoken?this.parameters.region?void 0:"region can not be empty":"timetoken can not be empty")}get path(){let{keySet:{subscribeKey:e},channels:t=[]}=this.parameters;return`/v2/subscribe/${e}/${ew(t.sort(),",")}/0`}get queryParameters(){let{channelGroups:e,filterExpression:t,timetoken:n,region:s}=this.parameters,r={ee:""};return e&&e.length>0&&(r["channel-group"]=e.sort().join(",")),t&&t.length>0&&(r["filter-expr"]=t),"string"==typeof n?n&&n.length>0&&(r.tt=n):n&&n>0&&(r.tt=n),s&&(r.tr=s),r}}class tX extends eK{operation(){return eG.PNHandshakeOperation}get path(){let{keySet:{subscribeKey:e},channels:t=[]}=this.parameters;return`/v2/subscribe/${e}/${ew(t.sort(),",")}/0`}get queryParameters(){let{channelGroups:e,filterExpression:t,state:n}=this.parameters,s={tt:0,ee:""};return e&&e.length>0&&(s["channel-group"]=e.sort().join(",")),t&&t.length>0&&(s["filter-expr"]=t),n&&Object.keys(n).length>0&&(s.state=JSON.stringify(n)),s}}class tQ extends eq{constructor(e){var t,n;super(),this.parameters=e,null!=(t=this.parameters).channels||(t.channels=[]),null!=(n=this.parameters).channelGroups||(n.channelGroups=[])}operation(){return eG.PNGetStateOperation}validate(){let{keySet:{subscribeKey:e},channels:t,channelGroups:n}=this.parameters;if(!e)return"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){let t=this.deserializeResponse(e),{channels:n=[],channelGroups:s=[]}=this.parameters,r={channels:{}};return 1===n.length&&0===s.length?r.channels[n[0]]=t.payload:r.channels=t.payload,r})}get path(){let{keySet:{subscribeKey:e},uuid:t,channels:n}=this.parameters;return`/v2/presence/sub-key/${e}/channel/${ew(null!=n?n:[],",")}/uuid/${t}`}get queryParameters(){let{channelGroups:e}=this.parameters;return e&&0!==e.length?{"channel-group":e.join(",")}:{}}}class tY extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNSetStateOperation}validate(){let{keySet:{subscribeKey:e},state:t,channels:n=[],channelGroups:s=[]}=this.parameters;return e?t?0===(null==n?void 0:n.length)&&0===(null==s?void 0:s.length)?"Please provide a list of channels and/or channel-groups":void 0:"Missing State":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){return{state:this.deserializeResponse(e).payload}})}get path(){let{keySet:{subscribeKey:e},uuid:t,channels:n}=this.parameters;return`/v2/presence/sub-key/${e}/channel/${ew(null!=n?n:[],",")}/uuid/${eC(t)}/data`}get queryParameters(){let{channelGroups:e,state:t}=this.parameters,n={state:JSON.stringify(t)};return e&&0!==e.length&&(n["channel-group"]=e.join(",")),n}}class tZ extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNHeartbeatOperation}validate(){let{keySet:{subscribeKey:e},channels:t=[],channelGroups:n=[]}=this.parameters;return e?0===t.length&&0===n.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){let{keySet:{subscribeKey:e},channels:t}=this.parameters;return`/v2/presence/sub-key/${e}/channel/${ew(null!=t?t:[],",")}/heartbeat`}get queryParameters(){let{channelGroups:e,state:t,heartbeat:n}=this.parameters,s={heartbeat:`${n}`};return e&&0!==e.length&&(s["channel-group"]=e.join(",")),t&&(s.state=JSON.stringify(t)),s}}class t0 extends eq{constructor(e){super(),this.parameters=e,this.parameters.channelGroups&&(this.parameters.channelGroups=Array.from(new Set(this.parameters.channelGroups))),this.parameters.channels&&(this.parameters.channels=Array.from(new Set(this.parameters.channels)))}operation(){return eG.PNUnsubscribeOperation}validate(){let{keySet:{subscribeKey:e},channels:t=[],channelGroups:n=[]}=this.parameters;return e?0===t.length&&0===n.length?"At least one `channel` or `channel group` should be provided.":void 0:"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){var e;let{keySet:{subscribeKey:t},channels:n}=this.parameters;return`/v2/presence/sub-key/${t}/channel/${ew(null!=(e=null==n?void 0:n.sort())?e:[],",")}/leave`}get queryParameters(){let{channelGroups:e}=this.parameters;return e&&0!==e.length?{"channel-group":e.sort().join(",")}:{}}}class t1 extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNWhereNowOperation}validate(){if(!this.parameters.keySet.subscribeKey)return"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){let t=this.deserializeResponse(e);return t.payload?{channels:t.payload.channels}:{channels:[]}})}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/presence/sub-key/${e}/uuid/${eC(t)}`}}class t2 extends eq{constructor(e){var t,n,s;super(),this.parameters=e,null!=(t=this.parameters).queryParameters||(t.queryParameters={}),null!=(n=this.parameters).includeUUIDs||(n.includeUUIDs=!0),null!=(s=this.parameters).includeState||(s.includeState=!1)}operation(){let{channels:e=[],channelGroups:t=[]}=this.parameters;return 0===e.length&&0===t.length?eG.PNGlobalHereNowOperation:eG.PNHereNowOperation}validate(){if(!this.parameters.keySet.subscribeKey)return"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){var t,n;let s=this.deserializeResponse(e),r="occupancy"in s?1:s.payload.total_channels,i="occupancy"in s?s.occupancy:s.payload.total_occupancy,a={},o={};return"occupancy"in s?o[this.parameters.channels[0]]={uuids:null!=(t=s.uuids)?t:[],occupancy:i}:o=null!=(n=s.payload.channels)?n:{}
18,Object.keys(o).forEach(e=>{let t=o[e];a[e]={occupants:this.parameters.includeUUIDs?t.uuids.map(e=>"string"==typeof e?{uuid:e,state:null}:e):[],name:e,occupancy:t.occupancy}}),{totalChannels:r,totalOccupancy:i,channels:a}})}get path(){let{keySet:{subscribeKey:e},channels:t,channelGroups:n}=this.parameters,s=`/v2/presence/sub-key/${e}`;return(t&&t.length>0||n&&n.length>0)&&(s+=`/channel/${ew(null!=t?t:[],",")}`),s}get queryParameters(){let{channelGroups:e,includeUUIDs:t,includeState:n,queryParameters:s}=this.parameters;return Object.assign(Object.assign(Object.assign(Object.assign({},t?{}:{disable_uuids:"1"}),null!=n&&n?{state:"1"}:{}),e&&e.length>0?{"channel-group":e.join(",")}:{}),s)}}class t4 extends eq{constructor(e){super({method:C.DELETE}),this.parameters=e}operation(){return eG.PNDeleteMessagesOperation}validate(){return this.parameters.keySet.subscribeKey?this.parameters.channel?void 0:"Missing channel":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v3/history/sub-key/${e}/channel/${eC(t)}`}get queryParameters(){let{start:e,end:t}=this.parameters;return Object.assign(Object.assign({},e?{start:e}:{}),t?{end:t}:{})}}class t5 extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNMessageCounts}validate(){let{keySet:{subscribeKey:e},channels:t,timetoken:n,channelTimetokens:s}=this.parameters;return e?t?n&&s?"`timetoken` and `channelTimetokens` are incompatible together":n||s?s&&s.length>1&&s.length!==t.length?"Length of `channelTimetokens` and `channels` do not match":void 0:"`timetoken` or `channelTimetokens` need to be set":"Missing channels":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){return{channels:this.deserializeResponse(e).channels}})}get path(){return`/v3/history/sub-key/${this.parameters.keySet.subscribeKey}/message-counts/${ew(this.parameters.channels)}`}get queryParameters(){let{channelTimetokens:e}=this.parameters;return this.parameters.timetoken&&(e=[this.parameters.timetoken]),Object.assign(Object.assign({},1===e.length?{timetoken:e[0]}:{}),e.length>1?{channelsTimetoken:e.join(",")}:{})}}class t6 extends eq{constructor(e){super(),this.parameters=e,e.count?e.count=Math.min(e.count,100):e.count=100,null!=e.stringifiedTimeToken||(e.stringifiedTimeToken=!1),null!=e.includeMeta||(e.includeMeta=!1),null!=e.logVerbosity||(e.logVerbosity=!1)}operation(){return eG.PNHistoryOperation}validate(){return this.parameters.keySet.subscribeKey?this.parameters.channel?void 0:"Missing channel":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){let t=this.deserializeResponse(e),n=t[0],s=t[1],r=t[2];return Array.isArray(n)?{messages:n.map(e=>{let t=this.processPayload(e.message),n={entry:t.payload,timetoken:e.timetoken};return t.error&&(n.error=t.error),e.meta&&(n.meta=e.meta),n}),startTimeToken:s,endTimeToken:r}:{messages:[],startTimeToken:s,endTimeToken:r}})}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/history/sub-key/${e}/channel/${eC(t)}`}get queryParameters(){let{start:e,end:t,reverse:n,count:s,stringifiedTimeToken:r,includeMeta:i}=this.parameters;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({count:s,include_token:"true"},e?{start:e}:{}),t?{end:t}:{}),r?{string_message_token:"true"}:{}),null!=n?{reverse:n.toString()}:{}),i?{include_meta:"true"}:{})}processPayload(e){let t,n,{crypto:s,logVerbosity:r}=this.parameters;if(!s||"string"!=typeof e)return{payload:e};try{let n=s.decrypt(e);t=n instanceof ArrayBuffer?JSON.parse(t6.decoder.decode(n)):n}catch(s){r&&console.log("decryption error",s.message),t=e,n=`Error while decrypting message content: ${s.message}`}return{payload:t,error:n}}}(O=P||(P={}))[O.Message=-1]="Message",O[O.Files=4]="Files";class t3 extends eq{constructor(e){var t;super(),this.parameters=e;let n=null!=(t=e.includeMessageActions)&&t,s=e.channels.length>1||n?25:100;e.count?e.count=Math.min(e.count,s):e.count=s,e.includeUuid?e.includeUUID=e.includeUuid:null!=e.includeUUID||(e.includeUUID=!0),null!=e.stringifiedTimeToken||(e.stringifiedTimeToken=!1),null!=e.includeMessageType||(e.includeMessageType=!0),null!=e.logVerbosity||(e.logVerbosity=!1)}operation(){return eG.PNFetchMessagesOperation}validate(){let{keySet:{subscribeKey:e},channels:t,includeMessageActions:n}=this.parameters;return e?t?void 0!==n&&n&&t.length>1?"History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.":void 0:"Missing channels":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){var t;let n=this.deserializeResponse(e),s=null!=(t=n.channels)?t:{},r={};
18return Object.keys(s).forEach(e=>{r[e]=s[e].map(t=>{null===t.message_type&&(t.message_type=P.Message);let n=this.processPayload(e,t),s=Object.assign(Object.assign({channel:e,timetoken:t.timetoken,message:n.payload,messageType:t.message_type},t.custom_message_type?{customMessageType:t.custom_message_type}:{}),{uuid:t.uuid});return t.actions&&(s.actions=t.actions,s.data=t.actions),t.meta&&(s.meta=t.meta),n.error&&(s.error=n.error),s})}),n.more?{channels:r,more:n.more}:{channels:r}})}get path(){let{keySet:{subscribeKey:e},channels:t,includeMessageActions:n}=this.parameters;return`/v3/${n?"history-with-actions":"history"}/sub-key/${e}/channel/${ew(t)}`}get queryParameters(){let{start:e,end:t,count:n,includeCustomMessageType:s,includeMessageType:r,includeMeta:i,includeUUID:a,stringifiedTimeToken:o}=this.parameters;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({max:n},e?{start:e}:{}),t?{end:t}:{}),o?{string_message_token:"true"}:{}),void 0!==i&&i?{include_meta:"true"}:{}),a?{include_uuid:"true"}:{}),null!=s?{include_custom_message_type:s?"true":"false"}:{}),r?{include_message_type:"true"}:{})}processPayload(e,t){let n,s,{crypto:r,logVerbosity:i}=this.parameters;if(!r||"string"!=typeof t.message)return{payload:t.message};try{let e=r.decrypt(t.message);n=e instanceof ArrayBuffer?JSON.parse(t3.decoder.decode(e)):e}catch(e){i&&console.log("decryption error",e.message),n=t.message,s=`Error while decrypting message content: ${e.message}`}if(!s&&n&&t.message_type==P.Files&&"object"==typeof n&&this.isFileMessage(n)){let t=n;return{payload:{message:t.message,file:Object.assign(Object.assign({},t.file),{url:this.parameters.getFileUrl({channel:e,id:t.file.id,name:t.file.name})})},error:s}}return{payload:n,error:s}}isFileMessage(e){return void 0!==e.file}}class t8 extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNGetMessageActionsOperation}validate(){return this.parameters.keySet.subscribeKey?this.parameters.channel?void 0:"Missing message channel":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){let t=this.deserializeResponse(e),n=null,s=null;return t.data.length>0&&(n=t.data[0].actionTimetoken,s=t.data[t.data.length-1].actionTimetoken),{data:t.data,more:t.more,start:n,end:s}})}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v1/message-actions/${e}/channel/${eC(t)}`}get queryParameters(){let{limit:e,start:t,end:n}=this.parameters;return Object.assign(Object.assign(Object.assign({},t?{start:t}:{}),n?{end:n}:{}),e?{limit:e}:{})}}class t9 extends eq{constructor(e){super({method:C.POST}),this.parameters=e}operation(){return eG.PNAddMessageActionOperation}validate(){let{keySet:{subscribeKey:e},action:t,channel:n,messageTimetoken:s}=this.parameters;return e?n?s?t?t.value?t.type?t.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message timetoken":"Missing message channel":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(({data:e})=>({data:e}))})}get path(){let{keySet:{subscribeKey:e},channel:t,messageTimetoken:n}=this.parameters;return`/v1/message-actions/${e}/channel/${eC(t)}/message/${n}`}get headers(){return{"Content-Type":"application/json"}}get body(){return JSON.stringify(this.parameters.action)}}class t7 extends eq{constructor(e){super({method:C.DELETE}),this.parameters=e}operation(){return eG.PNRemoveMessageActionOperation}validate(){let{keySet:{subscribeKey:e},channel:t,messageTimetoken:n,actionTimetoken:s}=this.parameters;return e?t?n?s?void 0:"Missing action timetoken":"Missing message timetoken":"Missing message action channel":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(({data:e})=>({data:e}))})}get path(){let{keySet:{subscribeKey:e},channel:t,actionTimetoken:n,messageTimetoken:s}=this.parameters;return`/v1/message-actions/${e}/channel/${eC(t)}/message/${s}/action/${n}`}}class ne extends eq{constructor(e){var t;
18super(),this.parameters=e,null!=(t=this.parameters).storeInHistory||(t.storeInHistory=!0)}operation(){return eG.PNPublishFileMessageOperation}validate(){let{channel:e,fileId:t,fileName:n}=this.parameters;return e?t?n?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"}parse(e){return F(this,void 0,void 0,function*(){return{timetoken:this.deserializeResponse(e)[2]}})}get path(){let{message:e,channel:t,keySet:{publishKey:n,subscribeKey:s},fileId:r,fileName:i}=this.parameters,a=Object.assign({file:{name:i,id:r}},e?{message:e}:{});return`/v1/files/publish-file/${n}/${s}/0/${eC(t)}/0/${eC(this.prepareMessagePayload(a))}`}get queryParameters(){let{customMessageType:e,storeInHistory:t,ttl:n,meta:s}=this.parameters;return Object.assign(Object.assign(Object.assign({store:t?"1":"0"},e?{custom_message_type:e}:{}),n?{ttl:n}:{}),s&&"object"==typeof s?{meta:JSON.stringify(s)}:{})}prepareMessagePayload(e){let{crypto:t}=this.parameters;if(!t)return JSON.stringify(e)||"";let n=t.encrypt(JSON.stringify(e));return JSON.stringify("string"==typeof n?n:U(n))}}class nt extends eq{constructor(e){super({method:C.LOCAL}),this.parameters=e}operation(){return eG.PNGetFileUrlOperation}validate(){let{channel:e,id:t,name:n}=this.parameters;return e?t?n?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"}parse(e){return F(this,void 0,void 0,function*(){return e.url})}get path(){let{channel:e,id:t,name:n,keySet:{subscribeKey:s}}=this.parameters;return`/v1/files/${s}/channels/${eC(e)}/files/${t}/${n}`}}class nn extends eq{constructor(e){super({method:C.DELETE}),this.parameters=e}operation(){return eG.PNDeleteFileOperation}validate(){let{channel:e,id:t,name:n}=this.parameters;return e?t?n?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"}get path(){let{keySet:{subscribeKey:e},id:t,channel:n,name:s}=this.parameters;return`/v1/files/${e}/channels/${eC(n)}/files/${t}/${s}`}}class ns extends eq{constructor(e){var t;super(),this.parameters=e,null!=(t=this.parameters).limit||(t.limit=100)}operation(){return eG.PNListFilesOperation}validate(){if(!this.parameters.channel)return"channel can't be empty"}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v1/files/${e}/channels/${eC(t)}/files`}get queryParameters(){let{limit:e,next:t}=this.parameters;return Object.assign({limit:e},t?{next:t}:{})}}class nr extends eq{constructor(e){super({method:C.POST}),this.parameters=e}operation(){return eG.PNGenerateUploadUrlOperation}validate(){return this.parameters.channel?this.parameters.name?void 0:"'name' can't be empty":"channel can't be empty"}parse(e){return F(this,void 0,void 0,function*(){let t=this.deserializeResponse(e);return{id:t.data.id,name:t.data.name,url:t.file_upload_request.url,formFields:t.file_upload_request.form_fields}})}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v1/files/${e}/channels/${eC(t)}/generate-upload-url`}get headers(){return{"Content-Type":"application/json"}}get body(){return JSON.stringify({name:this.parameters.name})}}class ni extends eq{constructor(e){super({method:C.POST}),this.parameters=e;let t=e.file.mimeType;t&&(e.formFields=e.formFields.map(e=>"Content-Type"===e.name?{name:e.name,value:t}:e))}operation(){return eG.PNPublishFileOperation}validate(){let{fileId:e,fileName:t,file:n,uploadUrl:s}=this.parameters;return e?t?n?s?void 0:"Validation failed: file upload 'url' can't be empty":"Validation failed: 'file' can't be empty":"Validation failed: file 'name' can't be empty":"Validation failed: file 'id' can't be empty"}parse(e){return F(this,void 0,void 0,function*(){return{status:e.status,message:e.body?ni.decoder.decode(e.body):"OK"}})}request(){return Object.assign(Object.assign({},super.request()),{origin:new URL(this.parameters.uploadUrl).origin,timeout:300})}get path(){let{pathname:e,search:t}=new URL(this.parameters.uploadUrl);return`${e}${t}`}get body(){return this.parameters.file}get formData(){return this.parameters.formFields}}class na{constructor(e){var t;if(this.parameters=e,this.file=null==(t=this.parameters.PubNubFile)?void 0:t.create(e.file),!this.file)throw Error("File upload error: unable to create File object.")}process(){return F(this,void 0,void 0,function*(){let e,t;
18return this.generateFileUploadUrl().then(n=>(e=n.name,t=n.id,this.uploadFile(n))).then(e=>{if(204!==e.status)throw new q("Upload to bucket was unsuccessful",{error:!0,statusCode:e.status,category:D.PNUnknownCategory,operation:eG.PNPublishFileOperation,errorData:{message:e.message}})}).then(()=>this.publishFileMessage(t,e)).catch(e=>{if(e instanceof q)throw e;throw new q("File upload error.",(e instanceof eb?e:eb.create(e)).toStatus(eG.PNPublishFileOperation))})})}generateFileUploadUrl(){return F(this,void 0,void 0,function*(){let e=new nr(Object.assign(Object.assign({},this.parameters),{name:this.file.name,keySet:this.parameters.keySet}));return this.parameters.sendRequest(e)})}uploadFile(e){return F(this,void 0,void 0,function*(){let{cipherKey:t,PubNubFile:n,crypto:s,cryptography:r}=this.parameters,{id:i,name:a,url:o,formFields:u}=e;return this.parameters.PubNubFile.supportsEncryptFile&&(!t&&s?this.file=yield s.encryptFile(this.file,n):t&&r&&(this.file=yield r.encryptFile(t,this.file,n))),this.parameters.sendRequest(new ni({fileId:i,fileName:a,file:this.file,uploadUrl:o,formFields:u}))})}publishFileMessage(e,t){return F(this,void 0,void 0,function*(){var n,s,r,i;let a,o={timetoken:"0"},u=this.parameters.fileUploadPublishRetryLimit,l=!1;do try{o=yield this.parameters.publishFile(Object.assign(Object.assign({},this.parameters),{fileId:e,fileName:t})),l=!0}catch(e){e instanceof q&&(a=e),u-=1}while(!l&&u>0);if(l)return{status:200,timetoken:o.timetoken,id:e,name:t};throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{error:!0,category:null!=(s=null==(n=a.status)?void 0:n.category)?s:D.PNUnknownCategory,statusCode:null!=(i=null==(r=a.status)?void 0:r.statusCode)?i:0,channel:this.parameters.channel,id:e,name:t})})}}class no{subscribe(e){let t=null==e?void 0:e.timetoken;this.pubnub.registerSubscribeCapable(this),this.pubnub.subscribe(Object.assign({channels:this.channelNames,channelGroups:this.groupNames},null!==t&&""!==t&&{timetoken:t}))}unsubscribe(){this.pubnub.unregisterSubscribeCapable(this);let{channels:e,channelGroups:t}=this.pubnub.getSubscribeCapableEntities(),n=this.groupNames.filter(e=>!t.includes(e)),s=this.channelNames.filter(t=>!e.includes(t));0===s.length&&0===n.length||this.pubnub.unsubscribe({channels:s,channelGroups:n})}set onMessage(e){this.listener.message=e}set onPresence(e){this.listener.presence=e}set onSignal(e){this.listener.signal=e}set onObjects(e){this.listener.objects=e}set onMessageAction(e){this.listener.messageAction=e}set onFile(e){this.listener.file=e}addListener(e){this.eventEmitter.addListener(e,this.channelNames,this.groupNames)}removeListener(e){this.eventEmitter.removeListener(e,this.channelNames,this.groupNames)}get channels(){return this.channelNames.slice(0)}get channelGroups(){return this.groupNames.slice(0)}}class nu extends no{constructor({channels:e=[],channelGroups:t=[],subscriptionOptions:n,eventEmitter:s,pubnub:r}){super(),this.channelNames=[],this.groupNames=[],this.subscriptionList=[],this.options=n,this.eventEmitter=s,this.pubnub=r,e.forEach(e=>{let t=this.pubnub.channel(e).subscription(this.options);this.channelNames=[...this.channelNames,...t.channels],this.subscriptionList.push(t)}),t.forEach(e=>{let t=this.pubnub.channelGroup(e).subscription(this.options);this.groupNames=[...this.groupNames,...t.channelGroups],this.subscriptionList.push(t)}),this.listener={},s.addListener(this.listener,this.channelNames,this.groupNames)}addSubscription(e){this.subscriptionList.push(e),this.channelNames=[...this.channelNames,...e.channels],this.groupNames=[...this.groupNames,...e.channelGroups],this.eventEmitter.addListener(this.listener,e.channels,e.channelGroups)}removeSubscription(e){let t=e.channels,n=e.channelGroups;this.channelNames=this.channelNames.filter(e=>!t.includes(e)),this.groupNames=this.groupNames.filter(e=>!n.includes(e)),this.subscriptionList=this.subscriptionList.filter(t=>t!==e),this.eventEmitter.removeListener(this.listener,t,n)}addSubscriptionSet(e){this.subscriptionList=[...this.subscriptionList,...e.subscriptions],this.channelNames=[...this.channelNames,...e.channels],this.groupNames=[...this.groupNames,...e.channelGroups],this.eventEmitter.addListener(this.listener,e.channels,e.channelGroups)}removeSubscriptionSet(e){let t=e.channels,n=e.channelGroups;this.channelNames=this.channelNames.filter(e=>!t.includes(e)),this.groupNames=this.groupNames.filter(e=>!n.includes(e)),this.subscriptionList=this.subscriptionList.filter(t=>!e.subscriptions.includes(t)),this.eventEmitter.removeListener(this.listener,t,n)}get subscriptions(){return this.subscriptionList.slice(0)}}class nl extends no{constructor({channels:e,channelGroups:t,subscriptionOptions:n,eventEmitter:s,pubnub:r}){super(),this.channelNames=[],this.groupNames=[],this.channelNames=e,this.groupNames=t,this.options=n,this.pubnub=r,this.eventEmitter=s,this.listener={},s.addListener(this.listener,this.channelNames,this.groupNames)}addSubscription(e){return new nu({channels:[...this.channelNames,...e.channels],channelGroups:[...this.groupNames,...e.channelGroups],subscriptionOptions:Object.assign(Object.assign({},this.options),null==e?void 0:e.options),eventEmitter:this.eventEmitter,pubnub:this.pubnub})}}class nc{constructor(e,t,n){this.eventEmitter=t,this.pubnub=n,this.id=e}subscription(e){return new nl({channels:[this.id],channelGroups:[],subscriptionOptions:e,eventEmitter:this.eventEmitter,pubnub:this.pubnub})}}class nh{constructor(e,t,n){this.eventEmitter=t,this.pubnub=n,this.name=e}subscription(e){{let t=[this.name];return(null==e?void 0:e.receivePresenceEvents)&&!this.name.endsWith("-pnpres")&&t.push(`${this.name}-pnpres`),new nl({channels:[],channelGroups:t,subscriptionOptions:e,eventEmitter:this.eventEmitter,pubnub:this.pubnub})}}}class np{constructor(e,t,n){this.eventEmitter=t,this.pubnub=n,this.id=e}subscription(e){return new nl({channels:[this.id],channelGroups:[],subscriptionOptions:e,eventEmitter:this.eventEmitter,pubnub:this.pubnub})}}class nd{constructor(e,t,n){this.eventEmitter=t,this.pubnub=n,this.name=e}subscription(e){{let t=[this.name];return(null==e?void 0:e.receivePresenceEvents)&&!this.name.endsWith("-pnpres")&&t.push(`${this.name}-pnpres`),new nl({channels:t,channelGroups:[],subscriptionOptions:e,eventEmitter:this.eventEmitter,pubnub:this.pubnub})}}}class ng extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNRemoveChannelsFromGroupOperation}validate(){let{keySet:{subscribeKey:e},channels:t,channelGroup:n}=this.parameters;return e?n?t?void 0:"Missing channels":"Missing Channel Group":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){let{keySet:{subscribeKey:e},channelGroup:t}=this.parameters;return`/v1/channel-registration/sub-key/${e}/channel-group/${eC(t)}`}get queryParameters(){return{remove:this.parameters.channels.join(",")}}}class ny extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNAddChannelsToGroupOperation}validate(){let{keySet:{subscribeKey:e},channels:t,channelGroup:n}=this.parameters;return e?n?t?void 0:"Missing channels":"Missing Channel Group":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){let{keySet:{subscribeKey:e},channelGroup:t}=this.parameters;return`/v1/channel-registration/sub-key/${e}/channel-group/${eC(t)}`}get queryParameters(){return{add:this.parameters.channels.join(",")}}}class nf extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNChannelsForGroupOperation}validate(){return this.parameters.keySet.subscribeKey?this.parameters.channelGroup?void 0:"Missing Channel Group":"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){return{channels:this.deserializeResponse(e).payload.channels}})}get path(){let{keySet:{subscribeKey:e},channelGroup:t}=this.parameters;return`/v1/channel-registration/sub-key/${e}/channel-group/${eC(t)}`}}class nm extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNRemoveGroupOperation}validate(){return this.parameters.keySet.subscribeKey?this.parameters.channelGroup?void 0:"Missing Channel Group":"Missing Subscribe Key"}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}get path(){let{keySet:{subscribeKey:e},channelGroup:t}=this.parameters;return`/v1/channel-registration/sub-key/${e}/channel-group/${eC(t)}/remove`}}class nb extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNChannelGroupsOperation}validate(){if(!this.parameters.keySet.subscribeKey)return"Missing Subscribe Key"}parse(e){return F(this,void 0,void 0,function*(){return{groups:this.deserializeResponse(e).payload.groups}})}get path(){return`/v1/channel-registration/sub-key/${this.parameters.keySet.subscribeKey}/channel-group`}}class nv{constructor(e,t){this.sendRequest=t,this.keySet=e}listChannels(e,t){return F(this,void 0,void 0,function*(){let n=new nf(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}listGroups(e){return F(this,void 0,void 0,function*(){let t=new nb({keySet:this.keySet});return e?this.sendRequest(t,e):this.sendRequest(t)})}addChannels(e,t){return F(this,void 0,void 0,function*(){let n=new ny(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeChannels(e,t){return F(this,void 0,void 0,function*(){let n=new ng(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}deleteGroup(e,t){return F(this,void 0,void 0,function*(){let n=new nm(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}}class nS extends eq{constructor(e){var t;super(),this.parameters=e,"apns2"===this.parameters.pushGateway&&(null!=(t=this.parameters).environment||(t.environment="development")),this.parameters.count&&this.parameters.count>1e3&&(this.parameters.count=1e3)}operation(){throw Error("Should be implemented in subclass.")}validate(){let{keySet:{subscribeKey:e},action:t,device:n,pushGateway:s}=this.parameters;return e?n?"add"!==t&&"remove"!==t||"channels"in this.parameters&&0!==this.parameters.channels.length?s?"apns2"!==this.parameters.pushGateway||this.parameters.topic?void 0:"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm or apns2)":"Missing Channels":"Missing Device ID (device)":"Missing Subscribe Key"}get path(){let{keySet:{subscribeKey:e},action:t,device:n,pushGateway:s}=this.parameters,r="apns2"===s?`/v2/push/sub-key/${e}/devices-apns2/${n}`:`/v1/push/sub-key/${e}/devices/${n}`;return"remove-device"===t&&(r=`${r}/remove`),r}get queryParameters(){let{start:e,count:t}=this.parameters,n=Object.assign(Object.assign({type:this.parameters.pushGateway},e?{start:e}:{}),t&&t>0?{count:t}:{});if("channels"in this.parameters&&(n[this.parameters.action]=this.parameters.channels.join(",")),"apns2"===this.parameters.pushGateway){let{environment:e,topic:t}=this.parameters;n=Object.assign(Object.assign({},n),{environment:e,topic:t})}return n}}class nk extends nS{constructor(e){super(Object.assign(Object.assign({},e),{action:"remove"}))}operation(){return eG.PNRemovePushNotificationEnabledChannelsOperation}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}}class nE extends nS{constructor(e){super(Object.assign(Object.assign({},e),{action:"list"}))}operation(){return eG.PNPushNotificationEnabledChannelsOperation}parse(e){return F(this,void 0,void 0,function*(){return{channels:this.deserializeResponse(e)}})}}class nO extends nS{constructor(e){super(Object.assign(Object.assign({},e),{action:"add"}))}operation(){return eG.PNAddPushNotificationEnabledChannelsOperation}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}}class nC extends nS{constructor(e){super(Object.assign(Object.assign({},e),{action:"remove-device"}))}operation(){return eG.PNRemoveAllPushNotificationsOperation}parse(e){let t=Object.create(null,{parse:{get:()=>super.parse}});return F(this,void 0,void 0,function*(){return t.parse.call(this,e).then(e=>({}))})}}class nw{constructor(e,t){this.sendRequest=t,this.keySet=e}listChannels(e,t){return F(this,void 0,void 0,function*(){let n=new nE(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}addChannels(e,t){return F(this,void 0,void 0,function*(){let n=new nO(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeChannels(e,t){return F(this,void 0,void 0,function*(){let n=new nk(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}deleteDevice(e,t){return F(this,void 0,void 0,function*(){let n=new nC(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}}class nN extends eq{constructor(e){var t,n;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=(n=e.include).totalCount||(n.totalCount=!1),null!=e.limit||(e.limit=100)}operation(){return eG.PNGetAllChannelMetadataOperation}get path(){return`/v2/objects/${this.parameters.keySet.subscribeKey}/channels`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";return i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({include:["status","type",...e.customFields?["custom"]:[]].join(","),count:`${e.totalCount}`},n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}}class nP extends eq{constructor(e){super({method:C.DELETE}),this.parameters=e}operation(){return eG.PNRemoveChannelMetadataOperation}validate(){if(!this.parameters.channel)return"Channel cannot be empty"}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/objects/${e}/channels/${eC(t)}`}}class nM extends eq{constructor(e){var t,n,s,r,i,a,o,u;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=(n=e.include).totalCount||(n.totalCount=!1),null!=(s=e.include).statusField||(s.statusField=!1),null!=(r=e.include).t
18ypeField||(r.typeField=!1),null!=(i=e.include).channelFields||(i.channelFields=!1),null!=(a=e.include).customChannelFields||(a.customChannelFields=!1),null!=(o=e.include).channelStatusField||(o.channelStatusField=!1),null!=(u=e.include).channelTypeField||(u.channelTypeField=!1),null!=e.limit||(e.limit=100),this.parameters.userId&&(this.parameters.uuid=this.parameters.userId)}operation(){return eG.PNGetMembershipsOperation}validate(){if(!this.parameters.uuid)return"'uuid' cannot be empty"}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/objects/${e}/uuids/${eC(t)}/channels`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e);let a=[];return e.statusField&&a.push("status"),e.typeField&&a.push("type"),e.customFields&&a.push("custom"),e.channelFields&&a.push("channel"),e.channelStatusField&&a.push("channel.status"),e.channelTypeField&&a.push("channel.type"),e.customChannelFields&&a.push("channel.custom"),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({count:`${e.totalCount}`},a.length>0?{include:a.join(",")}:{}),n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}}class n_ extends eq{constructor(e){var t,n,s,r,i,a,o,u;super({method:C.PATCH}),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=(n=e.include).totalCount||(n.totalCount=!1),null!=(s=e.include).statusField||(s.statusField=!1),null!=(r=e.include).typeField||(r.typeField=!1),null!=(i=e.include).channelFields||(i.channelFields=!1),null!=(a=e.include).customChannelFields||(a.customChannelFields=!1),null!=(o=e.include).channelStatusField||(o.channelStatusField=!1),null!=(u=e.include).channelTypeField||(u.channelTypeField=!1),null!=e.limit||(e.limit=100),this.parameters.userId&&(this.parameters.uuid=this.parameters.userId)}operation(){return eG.PNSetMembershipsOperation}validate(){let{uuid:e,channels:t}=this.parameters;return e?t&&0!==t.length?void 0:"Channels cannot be empty":"'uuid' cannot be empty"}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/objects/${e}/uuids/${eC(t)}/channels`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e);let a=["channel.status","channel.type","status"];return e.statusField&&a.push("status"),e.typeField&&a.push("type"),e.customFields&&a.push("custom"),e.channelFields&&a.push("channel"),e.channelStatusField&&a.push("channel.status"),e.channelTypeField&&a.push("channel.type"),e.customChannelFields&&a.push("channel.custom"),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({count:`${e.totalCount}`},a.length>0?{include:a.join(",")}:{}),n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}get body(){let{channels:e,type:t}=this.parameters;return JSON.stringify({[`${t}`]:e.map(e=>"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},status:e.status,type:e.type,custom:e.custom})})}}class nj extends eq{constructor(e){var t;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=e.limit||(e.limit=100)}operation(){return eG.PNGetAllUUIDMetadataOperation}get path(){return`/v2/objects/${this.parameters.keySet.subscribeKey}/uuids`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";return i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({include:["status","type",...e.customFields?["custom"]:[]].join(",")},void 0!==e.totalCount?{count:`${e.totalCount}`}:{}),n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}}class nA extends eq{constructor(e){var t;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!0)}operation(){return eG.PNGetChannelMetadataOperation}validate(){if(!this.parameters.channel)return"Channel cannot be empty"}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/objects/${e}/channels/${eC(t)}`}get queryParameters(){return{include:["status","type",...this.parameters.include.customFields?["custom"]:[]].join(",")}}}class nI extends eq{constructor(e){var t;super({method:C.PATCH}),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!0)}operation(){return eG.PNSetChannelMetadataOperation}validate(){return this.parameters.channel?this.parameters.data?void 0:"Data cannot be empty":"Channel cannot be empty"}get headers(){return this.parameters.ifMatchesEtag?{"If-Match":this.parameters.ifMatchesEtag}:void 0}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/objects/${e}/channels/${eC(t)}`}get queryParameters(){return{include:["status","type",...this.parameters.include.customFields?["custom"]:[]].join(",")}}get body(){return JSON.stringify(this.parameters.data)}}class nF extends eq{constructor(e){super({method:C.DELETE}),this.parameters=e,this.parameters.userId&&(this.parameters.uuid=this.parameters.userId)}operation(){return eG.PNRemoveUUIDMetadataOperation}validate(){if(!this.parameters.uuid)return"'uuid' cannot be empty"}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/objects/${e}/uuids/${eC(t)}`}}class nT extends eq{constructor(e){var t,n,s,r,i,a,o,u;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=(n=e.include).totalCount||(n.totalCount=!1),null!=(s=e.include).statusField||(s.statusField=!1),null!=(r=e.include).t
18ypeField||(r.typeField=!1),null!=(i=e.include).UUIDFields||(i.UUIDFields=!1),null!=(a=e.include).customUUIDFields||(a.customUUIDFields=!1),null!=(o=e.include).UUIDStatusField||(o.UUIDStatusField=!1),null!=(u=e.include).UUIDTypeField||(u.UUIDTypeField=!1),null!=e.limit||(e.limit=100)}operation(){return eG.PNSetMembersOperation}validate(){if(!this.parameters.channel)return"Channel cannot be empty"}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/objects/${e}/channels/${eC(t)}/uuids`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e);let a=[];return e.statusField&&a.push("status"),e.typeField&&a.push("type"),e.customFields&&a.push("custom"),e.UUIDFields&&a.push("uuid"),e.UUIDStatusField&&a.push("uuid.status"),e.UUIDTypeField&&a.push("uuid.type"),e.customUUIDFields&&a.push("uuid.custom"),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({count:`${e.totalCount}`},a.length>0?{include:a.join(",")}:{}),n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}}class nR extends eq{constructor(e){var t,n,s,r,i,a,o,u;super({method:C.PATCH}),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!1),null!=(n=e.include).totalCount||(n.totalCount=!1),null!=(s=e.include).statusField||(s.statusField=!1),null!=(r=e.include).typeField||(r.typeField=!1),null!=(i=e.include).UUIDFields||(i.UUIDFields=!1),null!=(a=e.include).customUUIDFields||(a.customUUIDFields=!1),null!=(o=e.include).UUIDStatusField||(o.UUIDStatusField=!1),null!=(u=e.include).UUIDTypeField||(u.UUIDTypeField=!1),null!=e.limit||(e.limit=100)}operation(){return eG.PNSetMembersOperation}validate(){let{channel:e,uuids:t}=this.parameters;return e?t&&0!==t.length?void 0:"UUIDs cannot be empty":"Channel cannot be empty"}get path(){let{keySet:{subscribeKey:e},channel:t}=this.parameters;return`/v2/objects/${e}/channels/${eC(t)}/uuids`}get queryParameters(){let{include:e,page:t,filter:n,sort:s,limit:r}=this.parameters,i="";i="string"==typeof s?s:Object.entries(null!=s?s:{}).map(([e,t])=>null!==t?`${e}:${t}`:e);let a=["uuid.status","uuid.type","type"];return e.statusField&&a.push("status"),e.typeField&&a.push("type"),e.customFields&&a.push("custom"),e.UUIDFields&&a.push("uuid"),e.UUIDStatusField&&a.push("uuid.status"),e.UUIDTypeField&&a.push("uuid.type"),e.customUUIDFields&&a.push("uuid.custom"),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({count:`${e.totalCount}`},a.length>0?{include:a.join(",")}:{}),n?{filter:n}:{}),(null==t?void 0:t.next)?{start:t.next}:{}),(null==t?void 0:t.prev)?{end:t.prev}:{}),r?{limit:r}:{}),i.length?{sort:i}:{})}get body(){let{uuids:e,type:t}=this.parameters;return JSON.stringify({[`${t}`]:e.map(e=>"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},status:e.status,type:e.type,custom:e.custom})})}}class nx extends eq{constructor(e){var t;super(),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!0),this.parameters.userId&&(this.parameters.uuid=this.parameters.userId)}operation(){return eG.PNGetUUIDMetadataOperation}validate(){if(!this.parameters.uuid)return"'uuid' cannot be empty"}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/objects/${e}/uuids/${eC(t)}`}get queryParameters(){let{include:e}=this.parameters;return{include:["status","type",...e.customFields?["custom"]:[]].join(",")}}}class nU extends eq{constructor(e){var t;super({method:C.PATCH}),this.parameters=e,null!=e.include||(e.include={}),null!=(t=e.include).customFields||(t.customFields=!0),this.parameters.userId&&(this.parameters.uuid=this.parameters.userId)}operation(){return eG.PNSetUUIDMetadataOperation}validate(){return this.parameters.uuid?this.parameters.data?void 0:"Data cannot be empty":"'uuid' cannot be empty"}get headers(){return this.parameters.ifMatchesEtag?{"If-Match":this.parameters.ifMatchesEtag}:void 0}get path(){let{keySet:{subscribeKey:e},uuid:t}=this.parameters;return`/v2/objects/${e}/uuids/${eC(t)}`}get queryParameters(){return{include:["status","type",...this.parameters.include.customFields?["custom"]:[]].join(",")}}get body(){return JSON.stringify(this.parameters.data)}}class nD{constructor(e,t){this.keySet=e.keySet,this.configuration=e,this.sendRequest=t}getAllUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){return this._getAllUUIDMetadata(e,t)})}_getAllUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){null!=t||(t="function"==typeof e?e:void 0);let n=new nj(Object.assign(Object.assign({},e&&"function"!=typeof e?e:{}),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}getUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){return this._getUUIDMetadata(e,t)})}_getUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){let n=e&&"function"!=typeof e?e:{};null!=t||(t="function"==typeof e?e:void 0),n.userId&&(n.uuid=n.userId),null!=n.uuid||
18(n.uuid=this.configuration.userId);let s=new nx(Object.assign(Object.assign({},n),{keySet:this.keySet}));return t?this.sendRequest(s,t):this.sendRequest(s)})}setUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){return this._setUUIDMetadata(e,t)})}_setUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){e.userId&&(e.uuid=e.userId),null!=e.uuid||(e.uuid=this.configuration.userId);let n=new nU(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){return this._removeUUIDMetadata(e,t)})}_removeUUIDMetadata(e,t){return F(this,void 0,void 0,function*(){let n=e&&"function"!=typeof e?e:{};null!=t||(t="function"==typeof e?e:void 0),n.userId&&(n.uuid=n.userId),null!=n.uuid||(n.uuid=this.configuration.userId);let s=new nF(Object.assign(Object.assign({},n),{keySet:this.keySet}));return t?this.sendRequest(s,t):this.sendRequest(s)})}getAllChannelMetadata(e,t){return F(this,void 0,void 0,function*(){return this._getAllChannelMetadata(e,t)})}_getAllChannelMetadata(e,t){return F(this,void 0,void 0,function*(){null!=t||(t="function"==typeof e?e:void 0);let n=new nN(Object.assign(Object.assign({},e&&"function"!=typeof e?e:{}),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}getChannelMetadata(e,t){return F(this,void 0,void 0,function*(){return this._getChannelMetadata(e,t)})}_getChannelMetadata(e,t){return F(this,void 0,void 0,function*(){let n=new nA(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}setChannelMetadata(e,t){return F(this,void 0,void 0,function*(){return this._setChannelMetadata(e,t)})}_setChannelMetadata(e,t){return F(this,void 0,void 0,function*(){let n=new nI(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeChannelMetadata(e,t){return F(this,void 0,void 0,function*(){return this._removeChannelMetadata(e,t)})}_removeChannelMetadata(e,t){return F(this,void 0,void 0,function*(){let n=new nP(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}getChannelMembers(e,t){return F(this,void 0,void 0,function*(){let n=new nT(Object.assign(Object.assign({},e),{keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}setChannelMembers(e,t){return F(this,void 0,void 0,function*(){let n=new nR(Object.assign(Object.assign({},e),{type:"set",keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeChannelMembers(e,t){return F(this,void 0,void 0,function*(){let n=new nR(Object.assign(Object.assign({},e),{type:"delete",keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}getMemberships(e,t){return F(this,void 0,void 0,function*(){let n=e&&"function"!=typeof e?e:{};null!=t||(t="function"==typeof e?e:void 0),n.userId&&(n.uuid=n.userId),null!=n.uuid||
18(n.uuid=this.configuration.userId);let s=new nM(Object.assign(Object.assign({},n),{keySet:this.keySet}));return t?this.sendRequest(s,t):this.sendRequest(s)})}setMemberships(e,t){return F(this,void 0,void 0,function*(){e.userId&&(e.uuid=e.userId),null!=e.uuid||(e.uuid=this.configuration.userId);let n=new n_(Object.assign(Object.assign({},e),{type:"set",keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}removeMemberships(e,t){return F(this,void 0,void 0,function*(){e.userId&&(e.uuid=e.userId),null!=e.uuid||(e.uuid=this.configuration.userId);let n=new n_(Object.assign(Object.assign({},e),{type:"delete",keySet:this.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)})}fetchMemberships(e,t){return F(this,void 0,void 0,function*(){var n,s;if("spaceId"in e){let s={channel:null!=(n=e.spaceId)?n:e.channel,filter:e.filter,limit:e.limit,page:e.page,include:Object.assign({},e.include),sort:e.sort?Object.fromEntries(Object.entries(e.sort).map(([e,t])=>[e.replace("user","uuid"),t])):void 0},r=e=>({status:e.status,data:e.data.map(e=>({user:e.uuid,custom:e.custom,updated:e.updated,eTag:e.eTag})),totalCount:e.totalCount,next:e.next,prev:e.prev});return t?this.getChannelMembers(s,(e,n)=>{t(e,n?r(n):n)}):this.getChannelMembers(s).then(r)}let r={uuid:null!=(s=e.userId)?s:e.uuid,filter:e.filter,limit:e.limit,page:e.page,include:Object.assign({},e.include),sort:e.sort?Object.fromEntries(Object.entries(e.sort).map(([e,t])=>[e.replace("space","channel"),t])):void 0},i=e=>({status:e.status,data:e.data.map(e=>({space:e.channel,custom:e.custom,updated:e.updated,eTag:e.eTag})),totalCount:e.totalCount,next:e.next,prev:e.prev});return t?this.getMemberships(r,(e,n)=>{t(e,n?i(n):n)}):this.getMemberships(r).then(i)})}addMemberships(e,t){return F(this,void 0,void 0,function*(){var n,s,r,i,a,o;if("spaceId"in e){let i={channel:null!=(n=e.spaceId)?n:e.channel,uuids:null!=(r=null==(s=e.users)?void 0:s.map(e=>"string"==typeof e?e:{id:e.userId,custom:e.custom}))?r:e.uuids,limit:0};return t?this.setChannelMembers(i,t):this.setChannelMembers(i)}let u={uuid:null!=(i=e.userId)?i:e.uuid,channels:null!=(o=null==(a=e.spaces)?void 0:a.map(e=>"string"==typeof e?e:{id:e.spaceId,custom:e.custom}))?o:e.channels,limit:0};return t?this.setMemberships(u,t):this.setMemberships(u)})}}class nq extends eq{constructor(){super()}operation(){return eG.PNTimeOperation}parse(e){return F(this,void 0,void 0,function*(){return{timetoken:this.deserializeResponse(e)[0]}})}get path(){return"/time/0"}}class nG extends eq{constructor(e){super(),this.parameters=e}operation(){return eG.PNDownloadFileOperation}validate(){let{channel:e,id:t,name:n}=this.parameters;return e?t?n?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"}parse(e){return F(this,void 0,void 0,function*(){let{cipherKey:t,crypto:n,cryptography:s,name:r,PubNubFile:i}=this.parameters,a=e.headers["content-type"],o,u=e.body;return i.supportsEncryptFile&&(t||n)&&(t&&s?u=yield s.decrypt(t,u):!t&&n&&(o=yield n.decryptFile(i.create({data:u,name:r,mimeType:a}),i))),o||i.create({data:u,name:r,mimeType:a})})}get path(){let{keySet:{subscribeKey:e},channel:t,id:n,name:s}=this.parameters;return`/v1/files/${e}/channels/${eC(t)}/files/${n}/${s}`}}class nK{static notificationPayload(e,t){return new eD(e,t)}static generateUUID(){return eE()}constructor(e){if(this._configuration=e.configuration,this.cryptography=e.cryptography,this.tokenManager=e.tokenManager,this.transport=e.transport,this.crypto=e.crypto,this._objects=new nD(this._configuration,this.sendRequest.bind(this)),this._channelGroups=new nv(this._configuration.keySet,this.sendRequest.bind(this)),this._push=new nw(this._configuration.keySet,this.sendRequest.bind(this)),this.listenerManager=new eA,this.eventEmitter=new eL(this.listenerManager),this.subscribeCapable=new Set,this._configuration.enableEventEngine){let e=this._configuration.getHeartbeatInterval();this.presenceState={},e&&(this.presenceEventEngine=new td({heartbeat:this.heartbeat.bind(this),leave:e=>this.makeUnsubscribe(e,()=>{}),heartbeatDelay:()=>new Promise((t,n)=>{(e=this._configuration.getHeartbeatInterval())?setTimeout(t,1e3*e):n(new q("Heartbeat interval has been reset."))}),retryDelay:e=>new Promise(t=>setTimeout(t,e)),emitStatus:e=>this.listenerManager.announceStatus(e),config:this._configuration,presenceState:this.presenceState})),this.eventEngine=new tV({handshake:this.subscribeHandshake.bind(this),receiveMessages:this.subscribeReceiveMessages.bind(this),delay:e=>new Promise(t=>setTimeout(t,e)),join:this.join.bind(this),leave:this.leave.bind(this),leaveAll:this.leaveAll.bind(this),presenceState:this.presenceState,config:this._configuration,emitMessages:e=>
18{try{e.forEach(e=>this.eventEmitter.emitEvent(e))}catch(t){let e={error:!0,category:D.PNUnknownCategory,errorData:t,statusCode:0};this.listenerManager.announceStatus(e)}},emitStatus:e=>this.listenerManager.announceStatus(e)})}else this.subscriptionManager=new eT(this._configuration,this.listenerManager,this.eventEmitter,this.makeSubscribe.bind(this),this.heartbeat.bind(this),this.makeUnsubscribe.bind(this),this.time.bind(this))}get configuration(){return this._configuration}get _config(){return this.configuration}get authKey(){var e;return null!=(e=this._configuration.authKey)?e:void 0}getAuthKey(){return this.authKey}setAuthKey(e){this._configuration.setAuthKey(e)}get userId(){return this._configuration.userId}set userId(e){if(!e||"string"!=typeof e||0===e.trim().length)throw Error("Missing or invalid userId parameter. Provide a valid string userId");this._configuration.userId=e}getUserId(){return this._configuration.userId}setUserId(e){if(!e||"string"!=typeof e||0===e.trim().length)throw Error("Missing or invalid userId parameter. Provide a valid string userId");this._configuration.userId=e}get filterExpression(){var e;return null!=(e=this._configuration.getFilterExpression())?e:void 0}getFilterExpression(){return this.filterExpression}set filterExpression(e){this._configuration.setFilterExpression(e)}setFilterExpression(e){this.filterExpression=e}get cipherKey(){return this._configuration.getCipherKey()}set cipherKey(e){this._configuration.setCipherKey(e)}setCipherKey(e){this.cipherKey=e}set heartbeatInterval(e){this._configuration.setHeartbeatInterval(e)}setHeartbeatInterval(e){this.heartbeatInterval=e}getVersion(){return this._configuration.getVersion()}_addPnsdkSuffix(e,t){this._configuration._addPnsdkSuffix(e,t)}getUUID(){return this.userId}setUUID(e){this.userId=e}get customEncrypt(){return this._configuration.getCustomEncrypt()}get customDecrypt(){return this._configuration.getCustomDecrypt()}channel(e){return new nd(e,this.eventEmitter,this)}channelGroup(e){return new nh(e,this.eventEmitter,this)}channelMetadata(e){return new nc(e,this.eventEmitter,this)}userMetadata(e){return new np(e,this.eventEmitter,this)}subscriptionSet(e){return new nu(Object.assign(Object.assign({},e),{eventEmitter:this.eventEmitter,pubnub:this}))}sendRequest(e,t){return F(this,void 0,void 0,function*(){let n=e.validate();if(n){if(t)return t(K(n),null);throw new q("Validation failed, check status for details",K(n))}let s=e.request(),r=e.operation();s.formData&&s.formData.length>0||r===eG.PNDownloadFileOperation?s.timeout=this._configuration.getFileTimeout():r===eG.PNSubscribeOperation||r===eG.PNReceiveMessagesOperation?s.timeout=this._configuration.getSubscribeTimeout():s.timeout=this._configuration.getTransactionTimeout();let i={error:!1,operation:r,category:D.PNAcknowledgmentCategory,statusCode:0},[a,o]=this.transport.makeSendable(s);return e.cancellationController=o||null,a.then(t=>{if(i.statusCode=t.status,200!==t.status&&204!==t.status){let e=nK.decoder.decode(t.body),n=t.headers["content-type"];if(n||-1!==n.indexOf("javascript")||-1!==n.indexOf("json")){let t=JSON.parse(e);"object"==typeof t&&"error"in t&&t.error&&"object"==typeof t.error&&(i.errorData=t.error)}else i.responseText=e}return e.parse(t)}).then(e=>t?t(i,e):e).catch(e=>{let n=e instanceof eb?e:eb.create(e);if(t)return t(n.toStatus(r),null);throw n.toPubNubError(r,"REST API request processing error, check status for details")})})}destroy(e){var t;null==(t=this.subscribeCapable)||t.clear(),this.subscriptionManager?(this.subscriptionManager.unsubscribeAll(e),this.subscriptionManager.disconnect()):this.eventEngine&&this.eventEngine.dispose()}stop(){this.destroy()}addListener(e){this.listenerManager.addListener(e)}removeListener(e){this.listenerManager.removeListener(e)}removeAllListeners(){this.listenerManager.removeAllListeners()}publish(e,t){return F(this,void 0,void 0,function*(){{let n=new tW(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule()}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}signal(e,t){return F(this,void 0,void 0,function*(){{let n=new tz(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}fire(e,t){return F(this,void 0,void 0,function*(){return null!=t||(t=()=>{}),this.publish(Object.assign(Object.assign({}
18,e),{replicate:!1,storeInHistory:!1}),t)})}getSubscribedChannels(){return this.subscriptionManager?this.subscriptionManager.subscribedChannels:this.eventEngine?this.eventEngine.getSubscribedChannels():[]}getSubscribedChannelGroups(){return this.subscriptionManager?this.subscriptionManager.subscribedChannelGroups:this.eventEngine?this.eventEngine.getSubscribedChannelGroups():[]}registerSubscribeCapable(e){this.subscribeCapable&&!this.subscribeCapable.has(e)&&this.subscribeCapable.add(e)}unregisterSubscribeCapable(e){this.subscribeCapable&&this.subscribeCapable.has(e)&&this.subscribeCapable.delete(e)}getSubscribeCapableEntities(){{let e={channels:[],channelGroups:[]};if(!this.subscribeCapable)return e;for(let t of this.subscribeCapable)e.channelGroups.push(...t.channelGroups),e.channels.push(...t.channels);return e}}subscribe(e){this.subscriptionManager?this.subscriptionManager.subscribe(e):this.eventEngine&&this.eventEngine.subscribe(e)}makeSubscribe(e,t){{let n=new e$(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule(),getFileUrl:this.getFileUrl.bind(this)}));if(this.sendRequest(n,(e,s)=>{var r;this.subscriptionManager&&(null==(r=this.subscriptionManager.abort)?void 0:r.identifier)===n.requestIdentifier&&(this.subscriptionManager.abort=null),t(e,s)}),this.subscriptionManager){let e=()=>n.abort("Cancel long-poll subscribe request");e.identifier=n.requestIdentifier,this.subscriptionManager.abort=e}}}unsubscribe(e){this.subscriptionManager?this.subscriptionManager.unsubscribe(e):this.eventEngine&&this.eventEngine.unsubscribe(e)}makeUnsubscribe(e,t){{let{channels:n,channelGroups:s}=e;if(s&&(s=s.filter(e=>!e.endsWith("-pnpres"))),n&&(n=n.filter(e=>!e.endsWith("-pnpres"))),0===(null!=s?s:[]).length&&0===(null!=n?n:[]).length)return t({error:!1,operation:eG.PNUnsubscribeOperation,category:D.PNAcknowledgmentCategory,statusCode:200});this.sendRequest(new t0({channels:n,channelGroups:s,keySet:this._configuration.keySet}),t)}}unsubscribeAll(){var e;null==(e=this.subscribeCapable)||e.clear(),this.subscriptionManager?this.subscriptionManager.unsubscribeAll():this.eventEngine&&this.eventEngine.unsubscribeAll()}disconnect(){this.subscriptionManager?this.subscriptionManager.disconnect():this.eventEngine&&this.eventEngine.disconnect()}reconnect(e){this.subscriptionManager?this.subscriptionManager.reconnect():this.eventEngine&&this.eventEngine.reconnect(null!=e?e:{})}subscribeHandshake(e){return F(this,void 0,void 0,function*(){{let t=new tX(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule(),getFileUrl:this.getFileUrl.bind(this)})),n=e.abortSignal.subscribe(e=>{t.abort("Cancel subscribe handshake request")});return this.sendRequest(t).then(e=>(n(),e.cursor))}})}subscribeReceiveMessages(e){return F(this,void 0,void 0,function*(){{let t=new tJ(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule(),getFileUrl:this.getFileUrl.bind(this)})),n=e.abortSignal.subscribe(e=>{t.abort("Cancel long-poll subscribe request")});return this.sendRequest(t).then(e=>(n(),e))}})}getMessageActions(e,t){return F(this,void 0,void 0,function*(){{let n=new t8(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}addMessageAction(e,t){return F(this,void 0,void 0,function*(){{let n=new t9(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}removeMessageAction(e,t){return F(this,void 0,void 0,function*(){{let n=new t7(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}fetchMessages(e,t){return F(this,void 0,void 0,function*(){{let n=new t3(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule(),getFileUrl:this.getFileUrl.bind(this)}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}deleteMessages(e,t){return F(this,void 0,void 0,function*(){{let n=new t4(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}
18messageCounts(e,t){return F(this,void 0,void 0,function*(){{let n=new t5(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}history(e,t){return F(this,void 0,void 0,function*(){{let n=new t6(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule()}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}hereNow(e,t){return F(this,void 0,void 0,function*(){{let n=new t2(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}whereNow(e,t){return F(this,void 0,void 0,function*(){var n;{let s=new t1({uuid:null!=(n=e.uuid)?n:this._configuration.userId,keySet:this._configuration.keySet});return t?this.sendRequest(s,t):this.sendRequest(s)}})}getState(e,t){return F(this,void 0,void 0,function*(){var n;{let s=new tQ(Object.assign(Object.assign({},e),{uuid:null!=(n=e.uuid)?n:this._configuration.userId,keySet:this._configuration.keySet}));return t?this.sendRequest(s,t):this.sendRequest(s)}})}setState(e,t){return F(this,void 0,void 0,function*(){var n,s;{let r,{keySet:i,userId:a}=this._configuration,o=this._configuration.getPresenceTimeout();if(this._configuration.enableEventEngine&&this.presenceState){let t=this.presenceState;null==(n=e.channels)||n.forEach(n=>t[n]=e.state),"channelGroups"in e&&(null==(s=e.channelGroups)||s.forEach(n=>t[n]=e.state))}return r="withHeartbeat"in e?new tZ(Object.assign(Object.assign({},e),{keySet:i,heartbeat:o})):new tY(Object.assign(Object.assign({},e),{keySet:i,uuid:a})),this.subscriptionManager&&this.subscriptionManager.setState(e),t?this.sendRequest(r,t):this.sendRequest(r)}})}presence(e){var t;null==(t=this.subscriptionManager)||t.changePresence(e)}heartbeat(e,t){return F(this,void 0,void 0,function*(){{let{channels:n,channelGroups:s}=e;if(s&&(s=s.filter(e=>!e.endsWith("-pnpres"))),n&&(n=n.filter(e=>!e.endsWith("-pnpres"))),0===(null!=s?s:[]).length&&0===(null!=n?n:[]).length){let e={error:!1,operation:eG.PNHeartbeatOperation,category:D.PNAcknowledgmentCategory,statusCode:200};return t?t(e,{}):Promise.resolve(e)}let r=new tZ(Object.assign(Object.assign({},e),{channels:n,channelGroups:s,keySet:this._configuration.keySet}));return t?this.sendRequest(r,t):this.sendRequest(r)}})}join(e){var t;null==(t=this.presenceEventEngine)||t.join(e)}leave(e){var t;null==(t=this.presenceEventEngine)||t.leave(e)}leaveAll(){var e;null==(e=this.presenceEventEngine)||e.leaveAll()}grantToken(e,t){return F(this,void 0,void 0,function*(){throw Error("Grant Token error: PAM module disabled")})}revokeToken(e,t){return F(this,void 0,void 0,function*(){throw Error("Revoke Token error: PAM module disabled")})}get token(){return this.tokenManager&&this.tokenManager.getToken()}getToken(){return this.token}set token(e){this.tokenManager&&this.tokenManager.setToken(e)}setToken(e){this.token=e}parseToken(e){return this.tokenManager&&this.tokenManager.parseToken(e)}grant(e,t){return F(this,void 0,void 0,function*(){throw Error("Grant error: PAM module disabled")})}audit(e,t){return F(this,void 0,void 0,function*(){throw Error("Grant Permissions error: PAM module disabled")})}get objects(){return this._objects}fetchUsers(e,t){return F(this,void 0,void 0,function*(){return this.objects._getAllUUIDMetadata(e,t)})}fetchUser(e,t){return F(this,void 0,void 0,function*(){return this.objects._getUUIDMetadata(e,t)})}createUser(e,t){return F(this,void 0,void 0,function*(){return this.objects._setUUIDMetadata(e,t)})}updateUser(e,t){return F(this,void 0,void 0,function*(){return this.objects._setUUIDMetadata(e,t)})}removeUser(e,t){return F(this,void 0,void 0,function*(){return this.objects._removeUUIDMetadata(e,t)})}fetchSpaces(e,t){return F(this,void 0,void 0,function*(){return this.objects._getAllChannelMetadata(e,t)})}fetchSpace(e,t){return F(this,void 0,void 0,function*(){return this.objects._getChannelMetadata(e,t)})}createSpace(e,t){return F(this,void 0,void 0,function*(){return this.objects._setChannelMetadata(e,t)})}updateSpace(e,t){return F(this,void 0,void 0,function*(){return this.objects._setChannelMetadata(e,t)})}removeSpace(e,t){return F(this,void 0,void 0,function*(){return this.objects._removeChannelMetadata(e,t)})}fetchMemberships(e,t){return F(this,void 0,void 0,function*(){return this.objects.fetchMemberships(e,t)})}addMemberships(e,t){return F(this,void 0,void 0,function*(){return this.objects.addMemberships(e,t)})}updateMemberships(e,t){return F(this,void 0,void 0,function*(){return this.objects.addMemberships(e,t)})}removeMemberships(e,t){return F(this,void 0,void 0,function*(){var n,s,r;{if("spaceId"in e){let r={channel:null!=(n=e.spaceId)?n:e.channel,uuids:null!=(s=e.userIds)?s:e.uuids,limit:0};return t?this.objects.removeChannelMembers(r,t):this.objects.removeChannelMembers(r)}let i={uuid:e.userId,channels:null!=(r=e.spaceIds)?r:e.channels,limit:0};return t?this.objects.removeMemberships(i,t):this.objects.removeMemberships(i)}})}get channelGroups(){return this._channelGroups}get push(){return this._push}sendFile(e,t){return F(this,void 0,void 0,function*(){{if(!this._configuration.PubNubFile)throw Error("Validation failed: 'PubNubFile' not configured or file upload not supported by the platform.");let n=new na(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,PubNubFile:this._configuration.PubNubFile,fileUploadPublishRetryLimit:this._configuration.fileUploadPublishRetryLimit,file:e.file,sendRequest:this.sendRequest.bind(this),publishFile:this.publishFile.bind(this),crypto:this._configuration.getCryptoModule(),cryptography:this.cryptography?this.cryptography:void 0})),s={error:!1,operation:eG.PNPublishFileOperation,category:D.PNAcknowledgmentCategory,statusCode:0};return n.process().then(e=>(s.statusCode=e.status,t?t(s,e):e)).catch(e=>{let n;throw e instanceof q?n=e.status:e instanceof eb&&(n=e.toStatus(s.operation)),t&&n&&t(n,null),new q("REST API request processing error, check status for details",n)})}})}publishFile(e,t){return F(this,void 0,void 0,function*(){{if(!this._configuration.PubNubFile)throw Error("Validation failed: 'PubNubFile' not configured or file upload not supported by the platform.");let n=new ne(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,crypto:this._configuration.getCryptoModule()}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}listFiles(e,t){return F(this,void 0,void 0,function*(){{let n=new ns(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}getFileUrl(e){var t;{let n=this.transport.request(new nt(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet})).request()),s=null!=(t=n.queryParameters)?t:{},r=Object.keys(s).map(e=>{let t=s[e];return Array.isArray(t)?t.map(t=>`${e}=${eC(t)}`).join("&"):`${e}=${eC(t)}`}).join("&");return`${n.origin}${n.path}?${r}`}}
18downloadFile(e,t){return F(this,void 0,void 0,function*(){{if(!this._configuration.PubNubFile)throw Error("Validation failed: 'PubNubFile' not configured or file upload not supported by the platform.");let n=new nG(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet,PubNubFile:this._configuration.PubNubFile,cryptography:this.cryptography?this.cryptography:void 0,crypto:this._configuration.getCryptoModule()}));return t?this.sendRequest(n,t):yield this.sendRequest(n)}})}deleteFile(e,t){return F(this,void 0,void 0,function*(){{let n=new nn(Object.assign(Object.assign({},e),{keySet:this._configuration.keySet}));return t?this.sendRequest(n,t):this.sendRequest(n)}})}time(e){return F(this,void 0,void 0,function*(){let t=new nq;return e?this.sendRequest(t,e):this.sendRequest(t)})}encrypt(e,t){let n=this._configuration.getCryptoModule();if(!t&&n&&"string"==typeof e){let t=n.encrypt(e);return"string"==typeof t?t:U(t)}if(!this.crypto)throw Error("Encryption error: cypher key not set");return this.crypto.encrypt(e,t)}decrypt(e,t){let n=this._configuration.getCryptoModule();if(!t&&n){let t=n.decrypt(e);return t instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(t)):t}if(!this.crypto)throw Error("Decryption error: cypher key not set");return this.crypto.decrypt(e,t)}encryptFile(e,t){return F(this,void 0,void 0,function*(){var n;if("string"!=typeof e&&(t=e),!t)throw Error("File encryption error. Source file is missing.");if(!this._configuration.PubNubFile)throw Error("File encryption error. File constructor not configured.");if("string"!=typeof e&&!this._configuration.getCryptoModule())throw Error("File encryption error. Crypto module not configured.");if("string"==typeof e){if(!this.cryptography)throw Error("File encryption error. File encryption not available");return this.cryptography.encryptFile(e,t,this._configuration.PubNubFile)}return null==(n=this._configuration.getCryptoModule())?void 0:n.encryptFile(t,this._configuration.PubNubFile)})}decryptFile(e,t){return F(this,void 0,void 0,function*(){var n;if("string"!=typeof e&&(t=e),!t)throw Error("File encryption error. Source file is missing.");if(!this._configuration.PubNubFile)throw Error("File decryption error. File constructor not configured.");if("string"==typeof e&&!this._configuration.getCryptoModule())throw Error("File decryption error. Crypto module not configured.");if("string"==typeof e){if(!this.cryptography)throw Error("File decryption error. File decryption not available");return this.cryptography.decryptFile(e,t,this._configuration.PubNubFile)}return null==(n=this._configuration.getCryptoModule())?void 0:n.decryptFile(t,this._configuration.PubNubFile)})}}nK.decoder=new TextDecoder,nK.OPERATIONS=eG,nK.CATEGORIES=D,nK.ExponentialRetryPolicy=tg.ExponentialRetryPolicy,nK.LinearRetryPolicy=tg.LinearRetryPolicy;class n${constructor(e,t){this.decode=e,this.base64ToBinary=t}decodeToken(e){let t="";e.length%4==3?t="=":e.length%4==2&&(t="==");let n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,s=this.decode(this.base64ToBinary(n));return"object"==typeof s?s:void 0}}class nL extends nK{constructor(e){var t;let n,s,r,i=(e=>{var t,n,s,r,i,a;return e.subscriptionWorkerUrl&&"undefined"==typeof SharedWorker&&(e.subscriptionWorkerUrl=null),Object.assign(Object.assign({},(e=>{var t;let n=Object.assign({},e);if(null!=n.logVerbosity||(n.logVerbosity=!1),null!=n.ssl||(n.ssl=!0),null!=n.transactionalRequestTimeout||(n.transactionalRequestTimeout=15),null!=n.subscribeRequestTimeout||(n.subscribeRequestTimeout=310),null!=n.fileRequestTimeout||(n.fileRequestTimeout=300),null!=n.restore||(n.restore=!1),null!=n.useInstanceId||(n.useInstanceId=!1),null!=n.suppressLeaveEvents||(n.suppressLeaveEvents=!1),null!=n.requestMessageCountThreshold||(n.requestMessageCountThreshold=100),null!=n.autoNetworkDetection||(n.autoNetworkDetection=!1),null!=n.enableEventEngine||(n.enableEventEngine=!1),null!=n.maintainPresenceState||(n.maintainPresenceState=!0),null!=n.useSmartHeartbeat||(n.useSmartHeartbeat=!0),null!=n.keepAlive||(n.keepAlive=!1),n.userId&&n.uuid)throw new q("PubNub client configuration error: use only 'userId'");
18if(null!=n.userId||(n.userId=n.uuid),!n.userId)throw new q("PubNub client configuration error: 'userId' not set");if(0===(null==(t=n.userId)?void 0:t.trim().length))throw new q("PubNub client configuration error: 'userId' is empty");n.origin||(n.origin=Array.from({length:20},(e,t)=>`ps${t+1}.pndsn.com`));let s={subscribeKey:n.subscribeKey,publishKey:n.publishKey,secretKey:n.secretKey};void 0!==n.presenceTimeout&&n.presenceTimeout<20&&(n.presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",20)),void 0!==n.presenceTimeout?n.heartbeatInterval=n.presenceTimeout/2-1:n.presenceTimeout=300;let r=!1,i=!0,a=5,o=!1,u=100,l=!0;return void 0!==n.dedupeOnSubscribe&&"boolean"==typeof n.dedupeOnSubscribe&&(o=n.dedupeOnSubscribe),void 0!==n.maximumCacheSize&&"number"==typeof n.maximumCacheSize&&(u=n.maximumCacheSize),void 0!==n.useRequestId&&"boolean"==typeof n.useRequestId&&(l=n.useRequestId),void 0!==n.announceSuccessfulHeartbeats&&"boolean"==typeof n.announceSuccessfulHeartbeats&&(r=n.announceSuccessfulHeartbeats),void 0!==n.announceFailedHeartbeats&&"boolean"==typeof n.announceFailedHeartbeats&&(i=n.announceFailedHeartbeats),void 0!==n.fileUploadPublishRetryLimit&&"number"==typeof n.fileUploadPublishRetryLimit&&(a=n.fileUploadPublishRetryLimit),Object.assign(Object.assign({},n),{keySet:s,dedupeOnSubscribe:o,maximumCacheSize:u,useRequestId:l,announceSuccessfulHeartbeats:r,announceFailedHeartbeats:i,fileUploadPublishRetryLimit:a})})(e)),{listenToBrowserNetworkEvents:null==(t=e.listenToBrowserNetworkEvents)||t,subscriptionWorkerUrl:e.subscriptionWorkerUrl,subscriptionWorkerOfflineClientsCheckInterval:null!=(n=e.subscriptionWorkerOfflineClientsCheckInterval)?n:10,subscriptionWorkerUnsubscribeOfflineClients:null!=(s=e.subscriptionWorkerUnsubscribeOfflineClients)&&s,subscriptionWorkerLogVerbosity:null!=(r=e.subscriptionWorkerLogVerbosity)&&r,transport:null!=(i=e.transport)?i:"fetch",keepAlive:null==(a=e.keepAlive)||a})})(e),a=Object.assign(Object.assign({},i),{sdkFamily:"Web"});a.PubNubFile=R;let o=((e,t)=>{var n,s;null==(n=e.retryConfiguration)||n.validate(),null!=e.useRandomIVs||(e.useRandomIVs=!0),e.origin=((e,t)=>{let n=e?"https://":"http://";return"string"==typeof t?`${n}${t}`:`${n}${t[Math.floor(Math.random()*t.length)]}`})(null!=(s=e.ssl)&&s,e.origin);let r=e.cryptoModule;r&&delete e.cryptoModule;let i=Object.assign(Object.assign({},e),{_pnsdkSuffix:{},_instanceId:`pn-${eE()}`,_cryptoModule:void 0,_cipherKey:void 0,_setupCryptoModule:t,get instanceId(){if(this.useInstanceId)return this._instanceId},getInstanceId(){if(this.useInstanceId)return this._instanceId},getUserId(){return this.userId},setUserId(e){if(!e||"string"!=typeof e||0===e.trim().length)throw Error("Missing or invalid userId parameter. Provide a valid string userId");this.userId=e},getAuthKey(){return this.authKey},setAuthKey(e){this.authKey=e},getFilterExpression(){return this.filterExpression},setFilterExpression(e){this.filterExpression=e},getCipherKey(){return this._cipherKey},setCipherKey(t){this._cipherKey=t,t||!this._cryptoModule?t&&this._setupCryptoModule&&(this._cryptoModule=this._setupCryptoModule({cipherKey:t,useRandomIVs:e.useRandomIVs,customEncrypt:this.getCustomEncrypt(),customDecrypt:this.getCustomDecrypt()})):this._cryptoModule=void 0},getCryptoModule(){return this._cryptoModule},getUseRandomIVs:()=>e.useRandomIVs,setPresenceTimeout(e){this.heartbeatInterval=e/2-1,this.presenceTimeout=e},getPresenceTimeout(){return this.presenceTimeout},getHeartbeatInterval(){return this.heartbeatInterval},setHeartbeatInterval(e){this.heartbeatInterval=e},getTransactionTimeout(){return this.transactionalRequestTimeout},getSubscribeTimeout(){return this.subscribeRequestTimeout},getFileTimeout(){return this.fileRequestTimeout},get PubNubFile(){return e.PubNubFile},get version(){return"8.10.0"},getVersion(){return this.version},_addPnsdkSuffix(e,t){this._pnsdkSuffix[e]=`${t}`},_getPnsdkSuffix(e){let t=Object.values(this._pnsdkSuffix).join(e);return t.length>0?e+t:""},getUUID(){return this.getUserId()},setUUID(e){this.setUserId(e)},getCustomEncrypt:()=>e.customEncrypt,getCustomDecrypt:()=>e.customDecrypt});return e.cipherKey?i.setCipherKey(e.cipherKey):r&&(i._cryptoModule=r),i})(a,e=>{if(e.cipherKey)return new ey({default:new eg(Object.assign({},e)),cryptors:[new ec({cipherKey:e.cipherKey})]})});n=new eO(new n$(e=>(function e(t){let n=e=>"object"==typeof e&&null!==e&&e.constructor===Object,s=e=>"number"==typeof e&&isFinite(e);if(!n(t))return t;let r={};return Object.keys(t).forEach(i=>
18{let a="string"==typeof i||i instanceof String,o=i,u=t[i];a&&i.indexOf(",")>=0?o=i.split(",").map(Number).reduce((e,t)=>e+String.fromCharCode(t),""):(s(i)||a&&!isNaN(Number(i)))&&(o=String.fromCharCode(s(i)?i:parseInt(i,10))),r[o]=n(u)?e(u):u}),r})(A.decode(e)),x)),(o.getCipherKey()||o.secretKey)&&(s=new ep({secretKey:o.secretKey,cipherKey:o.getCipherKey(),useRandomIVs:o.getUseRandomIVs(),customEncrypt:o.getCustomEncrypt(),customDecrypt:o.getCustomDecrypt()})),r=new ed;let u=new ej(a.transport,o.keepAlive,o.logVerbosity);i.subscriptionWorkerUrl&&(u=new ev({clientIdentifier:o._instanceId,subscriptionKey:o.subscribeKey,userId:o.getUserId(),workerUrl:i.subscriptionWorkerUrl,sdkVersion:o.getVersion(),heartbeatInterval:o.getHeartbeatInterval(),workerOfflineClientsCheckInterval:a.subscriptionWorkerOfflineClientsCheckInterval,workerUnsubscribeOfflineClients:a.subscriptionWorkerUnsubscribeOfflineClients,logVerbosity:o.logVerbosity,workerLogVerbosity:a.subscriptionWorkerLogVerbosity,transport:u})),super({configuration:o,transport:new e_({clientConfiguration:o,tokenManager:n,transport:u}),cryptography:r,tokenManager:n,crypto:s}),(null==(t=e.listenToBrowserNetworkEvents)||t)&&(window.addEventListener("offline",()=>{this.networkDownDetected()}),window.addEventListener("online",()=>{this.networkUpDetected()}))}networkDownDetected(){this.listenerManager.announceNetworkDown(),this._configuration.restore?this.disconnect():this.destroy(!0)}networkUpDetected(){this.listenerManager.announceNetworkUp(),this.reconnect()}}return nL.CryptoModule=ey,nL}()}}]); 19//# sourceMappingURL=fb03831a-bad0319543e71a98.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.